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