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