1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19 #ifndef INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
20 #define INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
21
22 #include <memory>
23 #include <vector>
24 #include <set>
25 #include <map>
26
27 #include <com/sun/star/container/XIndexContainer.hpp>
28 #include <com/sun/star/form/XForm.hpp>
29 #include <i18nlangtag/lang.h>
30 #include <comphelper/stl_types.hxx>
31 #include <o3tl/sorted_vector.hxx>
32 #include <o3tl/typed_flags_set.hxx>
33 #include <rtl/ref.hxx>
34 #include <svtools/htmlout.hxx>
35 #include <tools/fldunit.hxx>
36
37 #include <shellio.hxx>
38 #include <wrt_fn.hxx>
39 #include "htmlfly.hxx"
40
41 // some forward declarations
42 class Color;
43 class SwFrameFormat;
44 class SwFlyFrameFormat;
45 class SwDrawFrameFormat;
46 class SwFormatINetFormat;
47 class SwFormatVertOrient;
48 class SwFormatFootnote;
49 class SwStartNode;
50 class SwTableNode;
51 class SwPageDesc;
52 class SwNodeIndex;
53 class ImageMap;
54 class SwNumRule;
55 class SdrObject;
56 class SdrUnoObj;
57 class SvxBrushItem;
58 class SvxFontItem;
59 class SwHTMLNumRuleInfo;
60 class SwHTMLPosFlyFrames;
61 class SwTextFootnote;
62 enum class HtmlPosition;
63 enum class HtmlTokenId : sal_Int16;
64 namespace utl { class TempFile; }
65
66 extern SwAttrFnTab aHTMLAttrFnTab;
67
68 #define HTML_PARSPACE (MM50)
69
70 // flags for the output of any kind of frames
71 // BORDER only possible if OutHTML_Image
72 // ANYSIZE indicates, if also VAR_SIZE and MIN_SIZE values should be exported
73 // ABSSIZE indicates, if spacing and framing should be ignored
74 enum class HtmlFrmOpts {
75 NONE = 0,
76 Align = 1<<0,
77 SAlign = 1<<1,
78
79 Width = 1<<2,
80 Height = 1<<3,
81 Size = Width | Height,
82 SWidth = 1<<4,
83 SHeight = 1<<5,
84 SSize = SWidth | SHeight,
85 AnySize = 1<<6,
86 AbsSize = 1<<7,
87 MarginSize = 1<<8,
88
89 Space = 1<<9,
90 SSpace = 1<<10,
91
92 Border = 1<<11,
93 SBorder = 1<<12,
94 SNoBorder = 1<<13,
95
96 SBackground = 1<<14,
97
98 Name = 1<<15,
99 Alt = 1<<16,
100 BrClear = 1<<17,
101 SPixSize = 1<<18,
102 Id = 1<<19,
103 Dir = 1<<20,
104 /// The graphic frame is a replacement image of an OLE object.
105 Replacement = 1<<21,
106
107 GenImgAllMask = Alt | Size | AbsSize | Name,
108 GenImgMask = GenImgAllMask | Align | Space | BrClear
109 };
110 namespace o3tl {
111 template<> struct typed_flags<HtmlFrmOpts> : is_typed_flags<HtmlFrmOpts, ((1<<22)-1)> {};
112 }
113
114 #define HTMLMODE_BLOCK_SPACER 0x00010000
115 #define HTMLMODE_FLOAT_FRAME 0x00020000
116 #define HTMLMODE_VERT_SPACER 0x00040000
117 #define HTMLMODE_NBSP_IN_TABLES 0x00080000
118 #define HTMLMODE_LSPACE_IN_NUMBUL 0x00100000
119 //was HTMLMODE_NO_BR_AT_PAREND 0x00200000
120 #define HTMLMODE_PRINT_EXT 0x00400000
121 #define HTMLMODE_ABS_POS_FLY 0x00800000
122 #define HTMLMODE_ABS_POS_DRAW 0x01000000
123 #define HTMLMODE_FLY_MARGINS 0x02000000
124 #define HTMLMODE_BORDER_NONE 0x04000000
125 #define HTMLMODE_FONT_GENERIC 0x08000000
126 #define HTMLMODE_FRSTLINE_IN_NUMBUL 0x10000000
127 #define HTMLMODE_NO_CONTROL_CENTERING 0x20000000
128
129 #define HTML_DLCOLL_DD 0x4000
130 #define HTML_DLCOLL_DT 0x8000
131
132 #define CSS1_FMT_ISTAG (USHRT_MAX)
133 #define CSS1_FMT_CMPREF (USHRT_MAX-1)
134 #define CSS1_FMT_SPECIAL (USHRT_MAX-1)
135
136 // the following flags only specify which descriptors, tags, options,
137 // and so on should be outputted
138 // bit 0,1,2
139 #define CSS1_OUTMODE_SPAN_NO_ON 0x0000U
140 #define CSS1_OUTMODE_SPAN_TAG_ON 0x0001U
141 #define CSS1_OUTMODE_STYLE_OPT_ON 0x0002U
142 #define CSS1_OUTMODE_RULE_ON 0x0003U
143 #define CSS1_OUTMODE_SPAN_TAG1_ON 0x0004U
144 #define CSS1_OUTMODE_ANY_ON 0x0007U
145
146 // bit 3,4,5
147 #define CSS1_OUTMODE_SPAN_NO_OFF 0x0000U
148 #define CSS1_OUTMODE_SPAN_TAG_OFF (sal_uInt16(0x0001U << 3))
149 #define CSS1_OUTMODE_STYLE_OPT_OFF (sal_uInt16(0x0002U << 3))
150 #define CSS1_OUTMODE_RULE_OFF (sal_uInt16(0x0003U << 3))
151 #define CSS1_OUTMODE_ANY_OFF (sal_uInt16(0x0007U << 3))
152
153 #define CSS1_OUTMODE_ONOFF(a) (CSS1_OUTMODE_##a##_ON|CSS1_OUTMODE_##a##_OFF)
154 #define CSS1_OUTMODE_SPAN_TAG CSS1_OUTMODE_ONOFF(SPAN_TAG)
155 #define CSS1_OUTMODE_STYLE_OPT CSS1_OUTMODE_ONOFF(STYLE_OPT)
156 #define CSS1_OUTMODE_RULE CSS1_OUTMODE_ONOFF(RULE)
157
158 // the following flags specify what should be outputted
159 // bit 6,7,8,9
160 #define CSS1_OUTMODE_TEMPLATE 0x0000U
161 #define CSS1_OUTMODE_BODY (sal_uInt16(0x0001U << 6))
162 #define CSS1_OUTMODE_PARA (sal_uInt16(0x0002U << 6))
163 #define CSS1_OUTMODE_HINT (sal_uInt16(0x0003U << 6))
164 #define CSS1_OUTMODE_FRAME (sal_uInt16(0x0004U << 6))
165 #define CSS1_OUTMODE_TABLE (sal_uInt16(0x0005U << 6))
166 #define CSS1_OUTMODE_TABLEBOX (sal_uInt16(0x0006U << 6))
167 #define CSS1_OUTMODE_DROPCAP (sal_uInt16(0x0007U << 6))
168 #define CSS1_OUTMODE_SECTION (sal_uInt16(0x0008U << 6))
169 #define CSS1_OUTMODE_SOURCE (sal_uInt16(0x000fU << 6))
170
171 // bit 10
172 #define CSS1_OUTMODE_ENCODE (sal_uInt16(0x0001U << 10))
173
174 // bit 11,12,13
175 // don't care about script
176 #define CSS1_OUTMODE_ANY_SCRIPT 0x0000U
177 // no cjk or ctl items
178 #define CSS1_OUTMODE_WESTERN (sal_uInt16(0x0001U << 11))
179 // no western or ctl items
180 #define CSS1_OUTMODE_CJK (sal_uInt16(0x0002U << 11))
181 // no western or cjk items
182 #define CSS1_OUTMODE_CTL (sal_uInt16(0x0003U << 11))
183 // no western, cjk or ctl items
184 #define CSS1_OUTMODE_NO_SCRIPT (sal_uInt16(0x0004U << 11))
185 #define CSS1_OUTMODE_SCRIPT (sal_uInt16(0x0007U << 11))
186
187 // the HTML writer
188 struct HTMLControl
189 {
190 // the form to which the control belongs
191 css::uno::Reference<css::container::XIndexContainer> xFormComps;
192 sal_uLong nNdIdx; // the node in which it's anchored
193 sal_Int32 nCount; // how many controls are on the node
194
195 HTMLControl( const css::uno::Reference<css::container::XIndexContainer>& rForm, sal_uInt32 nIdx );
196 ~HTMLControl();
197
198 // operators for the sort array
operator <HTMLControl199 bool operator<( const HTMLControl& rCtrl ) const
200 {
201 return nNdIdx < rCtrl.nNdIdx;
202 }
203 };
204
205 class HTMLControls : public o3tl::sorted_vector<std::unique_ptr<HTMLControl>, o3tl::less_uniqueptr_to<HTMLControl> > {
206 };
207
208 struct SwHTMLFormatInfo
209 {
210 const SwFormat *pFormat; // the format itself
211
212 OString aToken; // the token to output
213 OUString aClass; // the class to output
214
215 std::unique_ptr<SfxItemSet> pItemSet; // the attribute set to output
216
217 sal_Int32 nLeftMargin; // some default values for
218 sal_Int32 nRightMargin; // paragraph styles
219 short nFirstLineIndent;
220
221 sal_uInt16 nTopMargin;
222 sal_uInt16 nBottomMargin;
223
224 bool bScriptDependent;
225
226 // ctor for a dummy to search
SwHTMLFormatInfoSwHTMLFormatInfo227 explicit SwHTMLFormatInfo( const SwFormat *pF ) :
228 pFormat( pF ),
229 nLeftMargin( 0 ),
230 nRightMargin( 0 ),
231 nFirstLineIndent(0),
232 nTopMargin( 0 ),
233 nBottomMargin( 0 ),
234 bScriptDependent(false)
235 {}
236
237 // ctor for creating of the format information
238 SwHTMLFormatInfo( const SwFormat *pFormat, SwDoc *pDoc, SwDoc *pTemplate,
239 bool bOutStyles, LanguageType eDfltLang=LANGUAGE_DONTKNOW,
240 sal_uInt16 nScript=CSS1_OUTMODE_ANY_SCRIPT );
241 ~SwHTMLFormatInfo();
242
operator <(const SwHTMLFormatInfo & rInfo1,const SwHTMLFormatInfo & rInfo2)243 friend bool operator<( const SwHTMLFormatInfo& rInfo1,
244 const SwHTMLFormatInfo& rInfo2 )
245 {
246 return reinterpret_cast<sal_IntPtr>(rInfo1.pFormat) < reinterpret_cast<sal_IntPtr>(rInfo2.pFormat);
247 }
248
249 };
250
251 typedef std::set<std::unique_ptr<SwHTMLFormatInfo>,
252 comphelper::UniquePtrValueLess<SwHTMLFormatInfo>> SwHTMLFormatInfos;
253
254 class IDocumentStylePoolAccess;
255
256 class SW_DLLPUBLIC SwHTMLWriter : public Writer
257 {
258 std::unique_ptr<SwHTMLPosFlyFrames> m_pHTMLPosFlyFrames;
259 std::unique_ptr<SwHTMLNumRuleInfo> m_pNumRuleInfo;// current numbering
260 std::unique_ptr<SwHTMLNumRuleInfo> m_pNextNumRuleInfo;
261 sal_uInt32 m_nHTMLMode; // description of export configuration
262
263 FieldUnit m_eCSS1Unit;
264
265 sal_uInt16 OutHeaderAttrs();
266 const SwPageDesc *MakeHeader( sal_uInt16& rHeaderAtrs );
267 void GetControls();
268
269 void AddLinkTarget( const OUString& rURL );
270 void CollectLinkTargets();
271
272 void SetupFilterOptions(const OUString& rFilterOptions);
273
274 protected:
275 ErrCode WriteStream() override;
276 void SetupFilterOptions(SfxMedium& rMedium) override;
277
278 public:
279 std::vector<OUString> m_aImgMapNames; // written image maps
280 std::set<OUString> m_aImplicitMarks; // implicit jump marks
281 std::set<OUString> m_aNumRuleNames; // names of exported num rules
282 std::set<OUString> m_aScriptParaStyles; // script dependent para styles
283 std::set<OUString> m_aScriptTextStyles; // script dependent text styles
284 std::vector<OUString> m_aOutlineMarks;
285 std::vector<sal_uInt32> m_aOutlineMarkPoss;
286 HTMLControls m_aHTMLControls; // the forms to be written
287 SwHTMLFormatInfos m_CharFormatInfos;
288 SwHTMLFormatInfos m_TextCollInfos;
289 std::vector<SwFormatINetFormat*> m_aINetFormats; // the "open" INet attributes
290 std::unique_ptr<std::vector<SwTextFootnote*>> m_pFootEndNotes;
291
292 OUString m_aCSS1Selector; // style selector
293 OUString m_aNonConvertableCharacters;
294 OUString m_aBulletGrfs[MAXLEVEL]; // list graphics
295
296 css::uno::Reference<css::container::XIndexContainer> mxFormComps; // current form
297
298 rtl::Reference<SwDoc> m_xTemplate; // HTML template
299 boost::optional<Color> m_xDfltColor; // default colour
300 SwNodeIndex *m_pStartNdIdx; // index of first paragraph
301 const SwPageDesc *m_pCurrPageDesc;// current page style
302 const SwFormatFootnote *m_pFormatFootnote;
303
304 sal_uInt32 m_aFontHeights[7]; // font heights 1-7
305
306 ErrCode m_nWarn; // warning code
307 sal_uInt32 m_nLastLFPos; // last position of LF
308
309 HtmlTokenId m_nLastParaToken; // to hold paragraphs together
310 sal_Int32 m_nBkmkTabPos; // current position in bookmark table
311 sal_uInt16 m_nImgMapCnt;
312 sal_uInt16 m_nFormCntrlCnt;
313 sal_uInt16 m_nEndNote;
314 sal_uInt16 m_nFootNote;
315 sal_Int32 m_nLeftMargin; // left indent (e.g. from lists)
316 sal_Int32 m_nDfltLeftMargin; // defaults which doesn't have to be
317 sal_Int32 m_nDfltRightMargin; // written (from template)
318 short m_nFirstLineIndent; // first line indent (from lists)
319 short m_nDfltFirstLineIndent; // not to write default
320 sal_uInt16 m_nDfltTopMargin; // defaults which doesn't have to be
321 sal_uInt16 m_nDfltBottomMargin; // written (from template)
322 sal_uInt16 m_nIndentLvl; // How far is it indented?
323 sal_Int32 m_nWhishLineLen; // How long can a line be?
324 sal_uInt16 m_nDefListLvl; // which DL level exists now
325 sal_Int32 m_nDefListMargin; // How far is the indentation in DL
326 sal_uInt16 m_nHeaderFooterSpace;
327 sal_uInt16 m_nTextAttrsToIgnore;
328 sal_uInt16 m_nExportMode;
329 sal_uInt16 m_nCSS1OutMode;
330 sal_uInt16 m_nCSS1Script; // contains default script (that's the one
331 // that is not contained in class names)
332 SvxFrameDirection m_nDirection; // the current direction
333
334 rtl_TextEncoding m_eDestEnc;
335 LanguageType m_eLang;
336
337 // description of the export configuration
338 // 0
339 bool m_bCfgOutStyles : 1; // export styles
340 bool m_bCfgPreferStyles : 1; // prefer styles instead of usual tags
341 bool m_bCfgFormFeed : 1; // export form feeds
342 bool m_bCfgStarBasic : 1; // export StarBasic
343 bool m_bCfgCpyLinkedGrfs : 1;
344
345 // description of what will be exported
346
347 bool m_bFirstLine : 1; // is the first line outputted?
348 bool m_bTagOn : 1; // tag on or off i.e. Attr-Start or Attr-End
349
350 // The following two flags specify how attributes are exported:
351 // bTextAttr bOutOpts
352 // 0 0 style sheets
353 // 1 0 Hints: Every attribute will be written as its own tag
354 // and an end tag exists
355 // 0 1 (paragraph)attribute: The Attribute will be exported as option
356 // of an already written tag. There is no end tag.
357 bool m_bTextAttr : 1;
358 // 8
359 bool m_bOutOpts : 1;
360
361 bool m_bOutTable : 1; // Will the table content be written?
362 bool m_bOutHeader : 1;
363 bool m_bOutFooter : 1;
364 bool m_bOutFlyFrame : 1;
365
366 // flags for style export
367
368 bool m_bFirstCSS1Rule : 1; // was a property already written
369 bool m_bFirstCSS1Property : 1; // was a property already written
370
371 // 16
372 bool m_bCSS1IgnoreFirstPageDesc : 1;
373
374 // what must/can/may not be written?
375
376 bool m_bNoAlign : 1; // HTML tag doesn't allow ALIGN=...
377 bool m_bClearLeft : 1; // <BR CLEAR=LEFT> write at end of paragraph
378 bool m_bClearRight : 1; // <BR CLEAR=RIGHT> write at end of paragraph
379 bool m_bLFPossible : 1; // a line break can be inserted
380
381 // others
382
383 bool m_bPreserveForm : 1; // preserve the current form
384
385 bool m_bCfgNetscape4 : 1; // Netscape4 hacks
386
387 bool mbSkipImages : 1;
388 /// If HTML header and footer should be written as well, or just the content itself.
389 bool mbSkipHeaderFooter : 1;
390 bool mbEmbedImages : 1;
391 /// Temporary base URL for paste of images.
392 std::unique_ptr<utl::TempFile> mpTempBaseURL;
393 /// If XHTML markup should be written instead of HTML.
394 bool mbXHTML = false;
395 /// XML namespace, in case of XHTML.
396 OString maNamespace;
397 /// If the ReqIF subset of XHTML should be written.
398 bool mbReqIF = false;
399
400 #define sCSS2_P_CLASS_leaders "leaders"
401 bool m_bCfgPrintLayout : 1; // PrintLayout option for TOC dot leaders
402 bool m_bParaDotLeaders : 1; // for TOC dot leaders
403 // 25
404
405 /// Tracks which text portion attributes are currently open: a which id -> open count map.
406 std::map<sal_uInt16, int> maStartedAttributes;
407
408 /// Construct an instance of SwHTMLWriter and optionally give it
409 /// the filter options directly, which can also be set via SetupFilterOptions().
410 explicit SwHTMLWriter( const OUString& rBaseURL, const OUString& rFilterOptions = "" );
411 virtual ~SwHTMLWriter() override;
412
413 void Out_SwDoc( SwPaM* ); // write the marked range
414
415 // output all bookmarks of current paragraph
416 void OutAnchor( const OUString& rName );
417 void OutBookmarks();
418 void OutPointFieldmarks( const SwPosition& rPos );
419 void OutImplicitMark( const OUString& rMark, const sal_Char *pMarkType );
420
421 OUString convertHyperlinkHRefValue(const OUString& rURL);
422
423 void OutHyperlinkHRefValue( const OUString& rURL );
424
425 // output the FlyFrame anchored at current position
426 bool OutFlyFrame( sal_uLong nNdIdx, sal_Int32 nContentIdx,
427 HtmlPosition nPos, HTMLOutContext *pContext = nullptr );
428 void OutFrameFormat( AllHtmlFlags nType, const SwFrameFormat& rFormat,
429 const SdrObject *pSdrObj );
430
431 void OutForm( bool bTagOn=true, const SwStartNode *pStNd=nullptr );
432 void OutHiddenForms();
433 void OutHiddenForm( const css::uno::Reference<css::form::XForm>& rForm );
434
435 void OutForm( bool bOn, const css::uno::Reference<css::container::XIndexContainer>& rFormComps );
436 void OutHiddenControls( const css::uno::Reference<css::container::XIndexContainer>& rFormComps,
437 const css::uno::Reference<css::beans::XPropertySet>& rPropSet );
438 bool HasControls() const;
439
440 void OutFootEndNoteInfo();
441 void OutFootEndNotes();
442 OUString GetFootEndNoteSym( const SwFormatFootnote& rFormatFootnote );
443 void OutFootEndNoteSym( const SwFormatFootnote& rFormatFootnote, const OUString& rNum,
444 sal_uInt16 nScript );
445
446 void OutBasic();
447
448 void OutAndSetDefList( sal_uInt16 nNewLvl );
449
450 void OutStyleSheet( const SwPageDesc& rPageDesc );
451
452 inline void OutCSS1_PropertyAscii( const sal_Char *pProp,
453 const sal_Char *pVal );
454 inline void OutCSS1_PropertyAscii( const sal_Char *pProp,
455 const OString& rVal );
456 inline void OutCSS1_Property( const sal_Char *pProp, const OUString& rVal );
457 void OutCSS1_Property( const sal_Char *pProp, const sal_Char *pVal,
458 const OUString *pSVal );
459 void OutCSS1_UnitProperty( const sal_Char *pProp, long nVal );
460 void OutCSS1_PixelProperty( const sal_Char *pProp, long nVal, bool bVert );
461 void OutCSS1_SfxItemSet( const SfxItemSet& rItemSet, bool bDeep=true );
462
463 // events of BODY tag from SFX configuration
464 void OutBasicBodyEvents();
465
466 // BACKGROUND/BGCOLOR option
467 void OutBackground( const SvxBrushItem *pBrushItem, bool bGraphic );
468 void OutBackground( const SfxItemSet& rItemSet, bool bGraphic );
469
470 void OutLanguage( LanguageType eLang );
471 SvxFrameDirection GetHTMLDirection( SvxFrameDirection nDir ) const;
472 SvxFrameDirection GetHTMLDirection( const SfxItemSet& rItemSet ) const;
473 void OutDirection( SvxFrameDirection nDir );
474 static OString convertDirection(SvxFrameDirection nDirection);
475
476 // ALT/ALIGN/WIDTH/HEIGHT/HSPACE/VSPACE option of current
477 // frame format output and maybe add a <BR CLEAR=...> at the
478 // beginning of rEndTags
479 OString OutFrameFormatOptions( const SwFrameFormat& rFrameFormat, const OUString& rAltText,
480 HtmlFrmOpts nFrameOpts );
481
482 void writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameFormat& rFrameFormat, const OUString& rAltText, HtmlFrmOpts nFrameOpts);
483
484 void OutCSS1_TableFrameFormatOptions( const SwFrameFormat& rFrameFormat );
485 void OutCSS1_TableCellBorderHack(const SwFrameFormat& rFrameFormat);
486 void OutCSS1_SectionFormatOptions( const SwFrameFormat& rFrameFormat, const SwFormatCol *pCol );
487 void OutCSS1_FrameFormatOptions( const SwFrameFormat& rFrameFormat, HtmlFrmOpts nFrameOpts,
488 const SdrObject *pSdrObj=nullptr,
489 const SfxItemSet *pItemSet=nullptr );
490 void OutCSS1_FrameFormatBackground( const SwFrameFormat& rFrameFormat );
491
492 void ChangeParaToken( HtmlTokenId nNew );
493
IncIndentLevel()494 void IncIndentLevel()
495 {
496 m_nIndentLvl++;
497 }
DecIndentLevel()498 void DecIndentLevel()
499 {
500 if ( m_nIndentLvl ) m_nIndentLvl--;
501 }
502 OString GetIndentString(sal_uInt16 nIncLvl = 0);
503
GetLineLen()504 sal_Int32 GetLineLen()
505 {
506 return static_cast<sal_Int32>(Strm().Tell()-m_nLastLFPos);
507 }
508 void OutNewLine( bool bCheck=false );
509
510 // for HTMLSaveData
GetEndPaM()511 SwPaM* GetEndPaM() { return m_pOrigPam; }
SetEndPaM(SwPaM * pPam)512 void SetEndPaM( SwPaM* pPam ) { m_pOrigPam = pPam; }
513
514 static sal_uInt32 ToPixel( sal_uInt32 nVal, const bool bVert );
515
516 sal_uInt16 GuessFrameType( const SwFrameFormat& rFrameFormat,
517 const SdrObject*& rpStrObj );
518 static sal_uInt16 GuessOLENodeFrameType( const SwNode& rNd );
519
520 void CollectFlyFrames();
521
522 sal_uInt16 GetHTMLFontSize( sal_uInt32 nFontHeight ) const;
523
524 // Fetch current numbering information.
GetNumInfo()525 SwHTMLNumRuleInfo& GetNumInfo() { return *m_pNumRuleInfo; }
526
527 // Fetch current numbering information of next paragraph. They
528 // don't have to exist yet!
GetNextNumInfo()529 SwHTMLNumRuleInfo *GetNextNumInfo() { return m_pNextNumRuleInfo.get(); }
530 std::unique_ptr<SwHTMLNumRuleInfo> ReleaseNextNumInfo();
531
532 // Set the numbering information of next paragraph.
533 void SetNextNumInfo( std::unique_ptr<SwHTMLNumRuleInfo> pNxt );
534
535 // Fill the numbering information of next paragraph.
536 void FillNextNumInfo();
537
538 // Clear numbering information of next paragraph.
539 void ClearNextNumInfo();
540
541 static const SdrObject* GetHTMLControl( const SwDrawFrameFormat& rFormat );
542 static const SdrObject* GetMarqueeTextObj( const SwDrawFrameFormat& rFormat );
543 static sal_uInt16 GetCSS1Selector( const SwFormat *pFormat, OString& rToken,
544 OUString& rClass, sal_uInt16& rRefPoolId,
545 OUString *pPseudo=nullptr );
546
547 static const SwFormat *GetTemplateFormat( sal_uInt16 nPoolId, IDocumentStylePoolAccess* /*SwDoc*/ pTemplate );
548 static const SwFormat *GetParentFormat( const SwFormat& rFormat, sal_uInt16 nDeep );
549
550 static void SubtractItemSet( SfxItemSet& rItemSet,
551 const SfxItemSet& rRefItemSet,
552 bool bSetDefaults,
553 bool bClearSame = true,
554 const SfxItemSet *pRefScriptItemSet=nullptr );
555 static bool HasScriptDependentItems( const SfxItemSet& rItemSet,
556 bool bCheckDropCap );
557
558 static void GetEEAttrsFromDrwObj( SfxItemSet& rItemSet,
559 const SdrObject *pObj );
560
561 static sal_uInt16 GetDefListLvl( const OUString& rNm, sal_uInt16 nPoolId );
562
GetHTMLMode() const563 sal_uInt32 GetHTMLMode() const
564 {
565 return m_nHTMLMode;
566 }
IsHTMLMode(sal_uInt32 nMode) const567 bool IsHTMLMode( sal_uInt32 nMode ) const
568 {
569 return (m_nHTMLMode & nMode) != 0;
570 }
571
572 inline bool IsCSS1Source( sal_uInt16 n ) const;
573 inline bool IsCSS1Script( sal_uInt16 n ) const;
574
575 static const sal_Char *GetNumFormat( sal_uInt16 nFormat );
576 static void PrepareFontList( const SvxFontItem& rFontItem, OUString& rNames,
577 sal_Unicode cQuote, bool bGeneric );
578 static sal_uInt16 GetCSS1ScriptForScriptType( sal_uInt16 nScriptType );
579 static sal_uInt16 GetLangWhichIdFromScript( sal_uInt16 nScript );
580
GetCSS1Unit() const581 FieldUnit GetCSS1Unit() const { return m_eCSS1Unit; }
582
583 sal_Int32 indexOfDotLeaders( sal_uInt16 nPoolId, const OUString& rText );
584
585 /// Determines the prefix string needed to respect the requested namespace alias.
586 OString GetNamespace() const;
587 };
588
IsCSS1Source(sal_uInt16 n) const589 inline bool SwHTMLWriter::IsCSS1Source( sal_uInt16 n ) const
590 {
591 return n == (m_nCSS1OutMode & CSS1_OUTMODE_SOURCE);
592 }
593
IsCSS1Script(sal_uInt16 n) const594 inline bool SwHTMLWriter::IsCSS1Script( sal_uInt16 n ) const
595 {
596 sal_uInt16 nScript = (m_nCSS1OutMode & CSS1_OUTMODE_SCRIPT);
597 return CSS1_OUTMODE_ANY_SCRIPT == nScript || n == nScript;
598 }
599
OutCSS1_PropertyAscii(const sal_Char * pProp,const sal_Char * pVal)600 inline void SwHTMLWriter::OutCSS1_PropertyAscii( const sal_Char *pProp,
601 const sal_Char *pVal )
602 {
603 OutCSS1_Property( pProp, pVal, nullptr );
604 }
605
OutCSS1_PropertyAscii(const sal_Char * pProp,const OString & rVal)606 inline void SwHTMLWriter::OutCSS1_PropertyAscii( const sal_Char *pProp,
607 const OString& rVal )
608 {
609 OutCSS1_Property( pProp, rVal.getStr(), nullptr );
610 }
611
OutCSS1_Property(const sal_Char * pProp,const OUString & rVal)612 inline void SwHTMLWriter::OutCSS1_Property( const sal_Char *pProp,
613 const OUString& rVal )
614 {
615 OutCSS1_Property( pProp, nullptr, &rVal );
616 }
617
618
619 // Structure caches the current data of the writer to output
620 // another part of the document, like e.g. header/footer
621 // With the two USHORTs in the ctor a new PaM is created and sets the
622 // positions in the document.
623 // In dtor all data is restored and the created PaM is deleted again.
624
625 struct HTMLSaveData
626 {
627 SwHTMLWriter& rWrt;
628 std::shared_ptr<SwUnoCursor> pOldPam;
629 SwPaM *pOldEnd;
630 std::unique_ptr<SwHTMLNumRuleInfo> pOldNumRuleInfo; // Owner = this
631 std::unique_ptr<SwHTMLNumRuleInfo> pOldNextNumRuleInfo;
632 sal_uInt16 const nOldDefListLvl;
633 SvxFrameDirection const nOldDirection;
634 bool bOldWriteAll : 1;
635 bool const bOldOutHeader : 1;
636 bool const bOldOutFooter : 1;
637 bool const bOldOutFlyFrame : 1;
638
639 HTMLSaveData( SwHTMLWriter&, sal_uLong nStt, sal_uLong nEnd,
640 bool bSaveNum=true,
641 const SwFrameFormat *pFrameFormat=nullptr );
642 ~HTMLSaveData();
643 };
644
645 // some function prototypes
646 Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFormat,
647 bool bInCntnr );
648 Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFormat,
649 bool bInCntnr );
650
651 Writer& OutHTML_SwTextNode( Writer&, const SwContentNode& );
652 Writer& OutHTML_SwTableNode( Writer& , SwTableNode &, const SwFrameFormat *,
653 const OUString* pCaption=nullptr, bool bTopCaption=false );
654
655 Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt, const SwDrawFrameFormat& rFormat,
656 const SdrUnoObj& rSdrObj, bool bInCntnr );
657 Writer& OutHTML_DrawFrameFormatAsMarquee( Writer& rWrt, const SwDrawFrameFormat& rFormat,
658 const SdrObject& rSdrObj );
659
660 Writer& OutHTML_HeaderFooter( Writer& rWrt, const SwFrameFormat& rFrameFormat,
661 bool bHeader );
662
663 Writer& OutHTML_Image( Writer&, const SwFrameFormat& rFormat,
664 const OUString& rGraphicURL,
665 Graphic const & rGraphic, const OUString& rAlternateText,
666 const Size& rRealSize, HtmlFrmOpts nFrameOpts,
667 const sal_Char *pMarkType,
668 const ImageMap *pGenImgMap,
669 const OUString& rMimeType = OUString() );
670
671 Writer& OutHTML_BulletImage( Writer& rWrt, const sal_Char *pTag,
672 const SvxBrushItem* pBrush,
673 const OUString& rGraphicURL);
674
675 Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt );
676 Writer& OutHTML_SwFormatFootnote( Writer& rWrt, const SfxPoolItem& rHt );
677 Writer& OutHTML_INetFormat( Writer&, const SwFormatINetFormat& rINetFormat, bool bOn );
678
679 Writer& OutCSS1_BodyTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet );
680 Writer& OutCSS1_ParaTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet );
681
682 Writer& OutCSS1_HintSpanTag( Writer& rWrt, const SfxPoolItem& rHt );
683 Writer& OutCSS1_HintStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
684
685 Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
686 Writer& OutCSS1_NumBulListStyleOpt( Writer& rWrt, const SwNumRule& rNumRule,
687 sal_uInt8 nLevel );
688
689 Writer& OutHTML_NumBulListStart( SwHTMLWriter& rWrt,
690 const SwHTMLNumRuleInfo& rInfo );
691 Writer& OutHTML_NumBulListEnd( SwHTMLWriter& rWrt,
692 const SwHTMLNumRuleInfo& rNextInfo );
693
694 Writer& OutCSS1_SvxBox( Writer& rWrt, const SfxPoolItem& rHt );
695
696 OString GetCSS1_Color(const Color& rColor);
697
698 #endif // INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
699
700 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
701