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::unique_ptr<std::vector<SwTextFootnote*>> m_pFootEndNotes;
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 
413  explicit SwHTMLWriter( const OUString& rBaseURL, const OUString& rFilterOptions = "" );
414  virtual ~SwHTMLWriter() override;
415 
416  void Out_SwDoc( SwPaM* ); // write the marked range
417 
418  // output all bookmarks of current paragraph
419  void OutAnchor( const OUString& rName );
420  void OutBookmarks();
421  void OutPointFieldmarks( const SwPosition& rPos );
422  void OutImplicitMark( std::u16string_view rMark, const char *pMarkType );
423 
424  OUString convertHyperlinkHRefValue(const OUString& rURL);
425 
426  void OutHyperlinkHRefValue( const OUString& rURL );
427 
428  // output the FlyFrame anchored at current position
429  bool OutFlyFrame( sal_uLong nNdIdx, sal_Int32 nContentIdx,
430  HtmlPosition nPos, HTMLOutContext *pContext = nullptr );
431  void OutFrameFormat( AllHtmlFlags nType, const SwFrameFormat& rFormat,
432  const SdrObject *pSdrObj );
433 
434  void OutForm( bool bTagOn=true, const SwStartNode *pStNd=nullptr );
435  void OutHiddenForms();
436  void OutHiddenForm( const css::uno::Reference<css::form::XForm>& rForm );
437 
438  void OutForm( bool bOn, const css::uno::Reference<css::container::XIndexContainer>& rFormComps );
439  void OutHiddenControls( const css::uno::Reference<css::container::XIndexContainer>& rFormComps,
440  const css::uno::Reference<css::beans::XPropertySet>& rPropSet );
441  bool HasControls() const;
442 
443  void OutFootEndNoteInfo();
444  void OutFootEndNotes();
445  OUString GetFootEndNoteSym( const SwFormatFootnote& rFormatFootnote );
446  void OutFootEndNoteSym( const SwFormatFootnote& rFormatFootnote, const OUString& rNum,
447  sal_uInt16 nScript );
448 
449  void OutBasic(const SwHTMLWriter& rHTMLWrt);
450 
451  void OutAndSetDefList( sal_uInt16 nNewLvl );
452 
453  void OutStyleSheet( const SwPageDesc& rPageDesc );
454 
455  inline void OutCSS1_PropertyAscii( const char *pProp,
456  const char *pVal );
457  inline void OutCSS1_PropertyAscii( const char *pProp,
458  std::string_view rVal );
459  inline void OutCSS1_Property( const char *pProp, const OUString& rVal );
460  void OutCSS1_Property( const char *pProp, std::string_view pVal,
461  const OUString *pSVal );
462  void OutCSS1_UnitProperty( const char *pProp, tools::Long nVal );
463  void OutCSS1_PixelProperty( const char *pProp, tools::Long nVal, bool bVert );
464  void OutCSS1_SfxItemSet( const SfxItemSet& rItemSet, bool bDeep=true );
465 
466  // events of BODY tag from SFX configuration
467  void OutBasicBodyEvents();
468 
469  // BACKGROUND/BGCOLOR option
470  void OutBackground( const SvxBrushItem *pBrushItem, bool bGraphic );
471  void OutBackground( const SfxItemSet& rItemSet, bool bGraphic );
472 
473  void OutLanguage( LanguageType eLang );
474  SvxFrameDirection GetHTMLDirection( SvxFrameDirection nDir ) const;
475  SvxFrameDirection GetHTMLDirection( const SfxItemSet& rItemSet ) const;
476  void OutDirection( SvxFrameDirection nDir );
477  static OString convertDirection(SvxFrameDirection nDirection);
478 
479  // ALT/ALIGN/WIDTH/HEIGHT/HSPACE/VSPACE option of current
480  // frame format output and maybe add a <BR CLEAR=...> at the
481  // beginning of rEndTags
482  OString OutFrameFormatOptions( const SwFrameFormat& rFrameFormat, const OUString& rAltText,
483  HtmlFrmOpts nFrameOpts );
484 
485  void writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameFormat& rFrameFormat, std::u16string_view rAltText, HtmlFrmOpts nFrameOpts);
486 
487  void OutCSS1_TableFrameFormatOptions( const SwFrameFormat& rFrameFormat );
488  void OutCSS1_TableCellBorderHack(const SwFrameFormat& rFrameFormat);
489  void OutCSS1_SectionFormatOptions( const SwFrameFormat& rFrameFormat, const SwFormatCol *pCol );
490  void OutCSS1_FrameFormatOptions( const SwFrameFormat& rFrameFormat, HtmlFrmOpts nFrameOpts,
491  const SdrObject *pSdrObj=nullptr,
492  const SfxItemSet *pItemSet=nullptr );
493  void OutCSS1_FrameFormatBackground( const SwFrameFormat& rFrameFormat );
494 
495  void ChangeParaToken( HtmlTokenId nNew );
496 
497  void IncIndentLevel()
498  {
499  m_nIndentLvl++;
500  }
501  void DecIndentLevel()
502  {
503  if ( m_nIndentLvl ) m_nIndentLvl--;
504  }
505  OString GetIndentString(sal_uInt16 nIncLvl = 0);
506 
507  sal_Int32 GetLineLen()
508  {
509  return static_cast<sal_Int32>(Strm().Tell()-m_nLastLFPos);
510  }
511  void OutNewLine( bool bCheck=false );
512 
513  // for HTMLSaveData
514  SwPaM* GetEndPaM() { return m_pOrigPam; }
515  void SetEndPaM( SwPaM* pPam ) { m_pOrigPam = pPam; }
516 
517  static sal_uInt32 ToPixel( sal_uInt32 nVal, const bool bVert );
518 
519  sal_uInt16 GuessFrameType( const SwFrameFormat& rFrameFormat,
520  const SdrObject*& rpStrObj );
521  static sal_uInt16 GuessOLENodeFrameType( const SwNode& rNd );
522 
523  void CollectFlyFrames();
524 
525  sal_uInt16 GetHTMLFontSize( sal_uInt32 nFontHeight ) const;
526 
527  // Fetch current numbering information.
528  SwHTMLNumRuleInfo& GetNumInfo() { return *m_pNumRuleInfo; }
529 
530  // Fetch current numbering information of next paragraph. They
531  // don't have to exist yet!
532  SwHTMLNumRuleInfo *GetNextNumInfo() { return m_pNextNumRuleInfo.get(); }
533  std::unique_ptr<SwHTMLNumRuleInfo> ReleaseNextNumInfo();
534 
535  // Set the numbering information of next paragraph.
536  void SetNextNumInfo( std::unique_ptr<SwHTMLNumRuleInfo> pNxt );
537 
538  // Fill the numbering information of next paragraph.
539  void FillNextNumInfo();
540 
541  // Clear numbering information of next paragraph.
542  void ClearNextNumInfo();
543 
544  static const SdrObject* GetHTMLControl( const SwDrawFrameFormat& rFormat );
545  static const SdrObject* GetMarqueeTextObj( const SwDrawFrameFormat& rFormat );
546  static sal_uInt16 GetCSS1Selector( const SwFormat *pFormat, OString& rToken,
547  OUString& rClass, sal_uInt16& rRefPoolId,
548  OUString *pPseudo=nullptr );
549 
550  static const SwFormat *GetTemplateFormat( sal_uInt16 nPoolId, IDocumentStylePoolAccess* /*SwDoc*/ pTemplate );
551  static const SwFormat *GetParentFormat( const SwFormat& rFormat, sal_uInt16 nDeep );
552 
553  static void SubtractItemSet( SfxItemSet& rItemSet,
554  const SfxItemSet& rRefItemSet,
555  bool bSetDefaults,
556  bool bClearSame = true,
557  const SfxItemSet *pRefScriptItemSet=nullptr );
558  static bool HasScriptDependentItems( const SfxItemSet& rItemSet,
559  bool bCheckDropCap );
560 
561  static void GetEEAttrsFromDrwObj( SfxItemSet& rItemSet,
562  const SdrObject *pObj );
563 
564  static sal_uInt16 GetDefListLvl( const OUString& rNm, sal_uInt16 nPoolId );
565 
566  sal_uInt32 GetHTMLMode() const
567  {
568  return m_nHTMLMode;
569  }
570  bool IsHTMLMode( sal_uInt32 nMode ) const
571  {
572  return (m_nHTMLMode & nMode) != 0;
573  }
574 
575  inline bool IsCSS1Source( sal_uInt16 n ) const;
576  inline bool IsCSS1Script( sal_uInt16 n ) const;
577 
578  static const char *GetNumFormat( sal_uInt16 nFormat );
579  static void PrepareFontList( const SvxFontItem& rFontItem, OUString& rNames,
580  sal_Unicode cQuote, bool bGeneric );
581  static sal_uInt16 GetCSS1ScriptForScriptType( sal_uInt16 nScriptType );
582  static sal_uInt16 GetLangWhichIdFromScript( sal_uInt16 nScript );
583 
584  FieldUnit GetCSS1Unit() const { return m_eCSS1Unit; }
585 
586  sal_Int32 indexOfDotLeaders( sal_uInt16 nPoolId, const OUString& rText );
587 
589  OString GetNamespace() const;
590 };
591 
592 inline bool SwHTMLWriter::IsCSS1Source( sal_uInt16 n ) const
593 {
594  return n == (m_nCSS1OutMode & CSS1_OUTMODE_SOURCE);
595 }
596 
597 inline bool SwHTMLWriter::IsCSS1Script( sal_uInt16 n ) const
598 {
599  sal_uInt16 nScript = (m_nCSS1OutMode & CSS1_OUTMODE_SCRIPT);
600  return CSS1_OUTMODE_ANY_SCRIPT == nScript || n == nScript;
601 }
602 
603 inline void SwHTMLWriter::OutCSS1_PropertyAscii( const char *pProp,
604  const char *pVal )
605 {
606  OutCSS1_Property( pProp, pVal, nullptr );
607 }
608 
609 inline void SwHTMLWriter::OutCSS1_PropertyAscii( const char *pProp,
610  std::string_view rVal )
611 {
612  OutCSS1_Property( pProp, rVal, nullptr );
613 }
614 
615 inline void SwHTMLWriter::OutCSS1_Property( const char *pProp,
616  const OUString& rVal )
617 {
618  OutCSS1_Property( pProp, std::string_view(), &rVal );
619 }
620 
621 
622 // Structure caches the current data of the writer to output
623 // another part of the document, like e.g. header/footer
624 // With the two USHORTs in the ctor a new PaM is created and sets the
625 // positions in the document.
626 // In dtor all data is restored and the created PaM is deleted again.
627 
628 struct HTMLSaveData
629 {
630  SwHTMLWriter& rWrt;
631  std::shared_ptr<SwUnoCursor> pOldPam;
632  SwPaM *pOldEnd;
633  std::unique_ptr<SwHTMLNumRuleInfo> pOldNumRuleInfo; // Owner = this
634  std::unique_ptr<SwHTMLNumRuleInfo> pOldNextNumRuleInfo;
635  sal_uInt16 nOldDefListLvl;
636  SvxFrameDirection nOldDirection;
637  bool bOldWriteAll : 1;
638  bool bOldOutHeader : 1;
639  bool bOldOutFooter : 1;
640  bool bOldOutFlyFrame : 1;
641 
642  HTMLSaveData( SwHTMLWriter&, sal_uLong nStt, sal_uLong nEnd,
643  bool bSaveNum=true,
644  const SwFrameFormat *pFrameFormat=nullptr );
645  ~HTMLSaveData();
646 };
647 
648 // some function prototypes
649 Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFormat,
650  bool bInCntnr );
651 Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFormat,
652  bool bInCntnr );
653 
654 Writer& OutHTML_SwTextNode( Writer&, const SwContentNode& );
655 Writer& OutHTML_SwTableNode( Writer& , SwTableNode &, const SwFrameFormat *,
656  const OUString* pCaption=nullptr, bool bTopCaption=false );
657 
658 Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt, const SwDrawFrameFormat& rFormat,
659  const SdrUnoObj& rSdrObj, bool bInCntnr );
660 Writer& OutHTML_DrawFrameFormatAsMarquee( Writer& rWrt, const SwDrawFrameFormat& rFormat,
661  const SdrObject& rSdrObj );
662 
663 Writer& OutHTML_HeaderFooter( Writer& rWrt, const SwFrameFormat& rFrameFormat,
664  bool bHeader );
665 
666 Writer& OutHTML_Image( Writer&, const SwFrameFormat& rFormat,
667  const OUString& rGraphicURL,
668  Graphic const & rGraphic, const OUString& rAlternateText,
669  const Size& rRealSize, HtmlFrmOpts nFrameOpts,
670  const char *pMarkType,
671  const ImageMap *pGenImgMap,
672  const OUString& rMimeType = OUString() );
673 
674 Writer& OutHTML_BulletImage( Writer& rWrt, const char *pTag,
675  const SvxBrushItem* pBrush,
676  const OUString& rGraphicURL);
677 
678 Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt );
679 Writer& OutHTML_SwFormatFootnote( Writer& rWrt, const SfxPoolItem& rHt );
680 Writer& OutHTML_INetFormat( Writer&, const SwFormatINetFormat& rINetFormat, bool bOn );
681 
682 Writer& OutCSS1_BodyTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet );
683 Writer& OutCSS1_ParaTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet );
684 
685 Writer& OutCSS1_HintSpanTag( Writer& rWrt, const SfxPoolItem& rHt );
686 Writer& OutCSS1_HintStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
687 
688 Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
689 Writer& OutCSS1_NumberBulletListStyleOpt( Writer& rWrt, const SwNumRule& rNumRule,
690  sal_uInt8 nLevel );
691 
692 Writer& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt,
693  const SwHTMLNumRuleInfo& rInfo );
694 Writer& OutHTML_NumberBulletListEnd( SwHTMLWriter& rWrt,
695  const SwHTMLNumRuleInfo& rNextInfo );
696 
697 Writer& OutCSS1_SvxBox( Writer& rWrt, const SfxPoolItem& rHt );
698 
699 OString GetCSS1_Color(const Color& rColor);
700 
702 bool IgnorePropertyForReqIF(bool bReqIF, std::string_view rProperty, std::string_view rValue);
703 
704 #endif // INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
705 
706 /* 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:3205
Marks a node in the document model.
Definition: ndindex.hxx:31
sal_uInt32 Id
HtmlTokenId
HtmlFrmOpts
Definition: wrthtml.hxx:75
HtmlPosition
Definition: htmlfly.hxx:65