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 namespace sw
259 {
260 enum class Css1Background
261 {
262  Attr = 1,
263  Page = 2,
264  Table = 3,
265  Fly = 4,
266  Section = 5,
267  TableRow = 6,
268  TableCell = 7,
269 };
270 }
271 
272 class SW_DLLPUBLIC SwHTMLWriter : public Writer
273 {
274  std::unique_ptr<SwHTMLPosFlyFrames> m_pHTMLPosFlyFrames;
275  std::unique_ptr<SwHTMLNumRuleInfo> m_pNumRuleInfo;// current numbering
276  std::unique_ptr<SwHTMLNumRuleInfo> m_pNextNumRuleInfo;
277  sal_uInt32 m_nHTMLMode; // description of export configuration
278 
279  FieldUnit m_eCSS1Unit;
280 
281  sal_uInt16 OutHeaderAttrs();
282  const SwPageDesc *MakeHeader( sal_uInt16& rHeaderAtrs );
283  void GetControls();
284 
285  void AddLinkTarget( const OUString& rURL );
286  void CollectLinkTargets();
287 
288  void SetupFilterOptions(std::u16string_view rFilterOptions);
289 
290 protected:
291  ErrCode WriteStream() override;
292  void SetupFilterOptions(SfxMedium& rMedium) override;
293  void SetupFilterFromPropertyValues(
294  const css::uno::Sequence<css::beans::PropertyValue>& rPropertyValues);
295 
296 public:
297  std::vector<OUString> m_aImgMapNames; // written image maps
298  std::set<OUString> m_aImplicitMarks; // implicit jump marks
299  std::set<OUString> m_aNumRuleNames; // names of exported num rules
300  std::set<OUString> m_aScriptParaStyles; // script dependent para styles
301  std::set<OUString> m_aScriptTextStyles; // script dependent text styles
302  std::vector<OUString> m_aOutlineMarks;
303  std::vector<SwNodeOffset> m_aOutlineMarkPoss;
304  HTMLControls m_aHTMLControls; // the forms to be written
305  SwHTMLFormatInfos m_CharFormatInfos;
306  SwHTMLFormatInfos m_TextCollInfos;
307  std::vector<SwFormatINetFormat*> m_aINetFormats; // the "open" INet attributes
308  std::optional<std::vector<SwTextFootnote*>> m_xFootEndNotes;
309 
310  OUString m_aCSS1Selector; // style selector
311  OUString m_aBulletGrfs[MAXLEVEL]; // list graphics
312 
313  css::uno::Reference<css::container::XIndexContainer> mxFormComps; // current form
314 
315  rtl::Reference<SwDoc> m_xTemplate; // HTML template
316  std::optional<Color> m_xDfltColor; // default colour
317  SwNodeIndex *m_pStartNdIdx; // index of first paragraph
318  const SwPageDesc *m_pCurrPageDesc;// current page style
319  const SwFormatFootnote *m_pFormatFootnote;
320 
321  sal_uInt32 m_aFontHeights[7]; // font heights 1-7
322 
323  ErrCode m_nWarn; // warning code
324  sal_uInt32 m_nLastLFPos; // last position of LF
325 
326  HtmlTokenId m_nLastParaToken; // to hold paragraphs together
327  sal_Int32 m_nBkmkTabPos; // current position in bookmark table
328  sal_uInt16 m_nImgMapCnt;
329  sal_uInt16 m_nFormCntrlCnt;
330  sal_uInt16 m_nEndNote;
331  sal_uInt16 m_nFootNote;
332  sal_Int32 m_nLeftMargin; // left indent (e.g. from lists)
333  sal_Int32 m_nDfltLeftMargin; // defaults which doesn't have to be
334  sal_Int32 m_nDfltRightMargin; // written (from template)
335  short m_nFirstLineIndent; // first line indent (from lists)
336  short m_nDfltFirstLineIndent; // not to write default
337  sal_uInt16 m_nDfltTopMargin; // defaults which doesn't have to be
338  sal_uInt16 m_nDfltBottomMargin; // written (from template)
339  sal_uInt16 m_nIndentLvl; // How far is it indented?
340  sal_Int32 m_nWishLineLen; // How long can a line be?
341  sal_uInt16 m_nDefListLvl; // which DL level exists now
342  sal_Int32 m_nDefListMargin; // How far is the indentation in DL
343  sal_uInt16 m_nHeaderFooterSpace;
344  sal_uInt16 m_nTextAttrsToIgnore;
345  sal_uInt16 m_nExportMode;
346  sal_uInt16 m_nCSS1OutMode;
347  sal_uInt16 m_nCSS1Script; // contains default script (that's the one
348  // that is not contained in class names)
349  SvxFrameDirection m_nDirection; // the current direction
350 
351  LanguageType m_eLang;
352 
353  // description of the export configuration
354  // 0
355  bool m_bCfgOutStyles : 1; // export styles
356  bool m_bCfgPreferStyles : 1; // prefer styles instead of usual tags
357  bool m_bCfgFormFeed : 1; // export form feeds
358  bool m_bCfgStarBasic : 1; // export StarBasic
359  bool m_bCfgCpyLinkedGrfs : 1;
360 
361  // description of what will be exported
362 
363  bool m_bFirstLine : 1; // is the first line outputted?
364  bool m_bTagOn : 1; // tag on or off i.e. Attr-Start or Attr-End
365 
366  // The following two flags specify how attributes are exported:
367  // bTextAttr bOutOpts
368  // 0 0 style sheets
369  // 1 0 Hints: Every attribute will be written as its own tag
370  // and an end tag exists
371  // 0 1 (paragraph)attribute: The Attribute will be exported as option
372  // of an already written tag. There is no end tag.
373  bool m_bTextAttr : 1;
374  // 8
375  bool m_bOutOpts : 1;
376 
377  bool m_bOutTable : 1; // Will the table content be written?
378  bool m_bOutHeader : 1;
379  bool m_bOutFooter : 1;
380  bool m_bOutFlyFrame : 1;
381 
382  // flags for style export
383 
384  bool m_bFirstCSS1Rule : 1; // was a property already written
385  bool m_bFirstCSS1Property : 1; // was a property already written
386 
387  // 16
388  bool m_bCSS1IgnoreFirstPageDesc : 1;
389 
390  // what must/can/may not be written?
391 
392  bool m_bNoAlign : 1; // HTML tag doesn't allow ALIGN=...
393  bool m_bClearLeft : 1; // <BR CLEAR=LEFT> write at end of paragraph
394  bool m_bClearRight : 1; // <BR CLEAR=RIGHT> write at end of paragraph
395  bool m_bLFPossible : 1; // a line break can be inserted
396 
397  // others
398 
399  bool m_bPreserveForm : 1; // preserve the current form
400 
401  bool m_bCfgNetscape4 : 1; // Netscape4 hacks
402 
403  bool mbSkipImages : 1;
405  bool mbSkipHeaderFooter : 1;
406  bool mbEmbedImages : 1;
408  std::unique_ptr<utl::TempFile> mpTempBaseURL;
410  bool mbXHTML = false;
412  OString maNamespace;
414  bool mbReqIF = false;
415 
416 #define sCSS2_P_CLASS_leaders "leaders"
417  bool m_bCfgPrintLayout : 1; // PrintLayout option for TOC dot leaders
418  bool m_bParaDotLeaders : 1; // for TOC dot leaders
419  // 25
420 
422  std::map<sal_uInt16, int> maStartedAttributes;
423 
424  OUString m_aRTFOLEMimeType;
425 
427  bool m_bExportImagesAsOLE = false;
428 
430  std::optional<sal_Int32> m_nShapeDPI;
431 
433  std::optional<sal_Int32> m_nLeadingTabWidth;
434 
437  explicit SwHTMLWriter( const OUString& rBaseURL, std::u16string_view rFilterOptions = std::u16string_view() );
438  virtual ~SwHTMLWriter() override;
439 
440  void Out_SwDoc( SwPaM* ); // write the marked range
441 
442  // output all bookmarks of current paragraph
443  void OutAnchor( const OUString& rName );
444  void OutBookmarks();
445  void OutPointFieldmarks( const SwPosition& rPos );
446  void OutImplicitMark( std::u16string_view rMark, const char *pMarkType );
447 
448  OUString convertHyperlinkHRefValue(const OUString& rURL);
449 
450  void OutHyperlinkHRefValue( const OUString& rURL );
451 
452  // output the FlyFrame anchored at current position
453  bool OutFlyFrame( SwNodeOffset nNdIdx, sal_Int32 nContentIdx,
454  HtmlPosition nPos );
455  void OutFrameFormat( AllHtmlFlags nType, const SwFrameFormat& rFormat,
456  const SdrObject *pSdrObj );
457 
458  void OutForm( bool bTagOn=true, const SwStartNode *pStNd=nullptr );
459  void OutHiddenForms();
460  void OutHiddenForm( const css::uno::Reference<css::form::XForm>& rForm );
461 
462  void OutForm( bool bOn, const css::uno::Reference<css::container::XIndexContainer>& rFormComps );
463  void OutHiddenControls( const css::uno::Reference<css::container::XIndexContainer>& rFormComps,
464  const css::uno::Reference<css::beans::XPropertySet>& rPropSet );
465  bool HasControls() const;
466 
467  void OutFootEndNoteInfo();
468  void OutFootEndNotes();
469  OUString GetFootEndNoteSym( const SwFormatFootnote& rFormatFootnote );
470  void OutFootEndNoteSym( const SwFormatFootnote& rFormatFootnote, const OUString& rNum,
471  sal_uInt16 nScript );
472 
473  void OutBasic(const SwHTMLWriter& rHTMLWrt);
474 
475  void OutAndSetDefList( sal_uInt16 nNewLvl );
476 
477  void OutStyleSheet( const SwPageDesc& rPageDesc );
478 
479  inline void OutCSS1_PropertyAscii( const char *pProp,
480  const char *pVal );
481  inline void OutCSS1_PropertyAscii( const char *pProp,
482  std::string_view rVal );
483  inline void OutCSS1_Property( const char *pProp, const OUString& rVal );
484  void OutCSS1_Property( const char *pProp, std::string_view pVal,
485  const OUString *pSVal, std::optional<sw::Css1Background> oBackground = std::nullopt );
486  void OutCSS1_UnitProperty( const char *pProp, tools::Long nVal );
487  void OutCSS1_PixelProperty( const char *pProp, tools::Long nVal, bool bVert );
488  void OutCSS1_SfxItemSet( const SfxItemSet& rItemSet, bool bDeep=true );
489 
490  // events of BODY tag from SFX configuration
491  void OutBasicBodyEvents();
492 
493  // BACKGROUND/BGCOLOR option
494  void OutBackground( const SvxBrushItem *pBrushItem, bool bGraphic );
495  void OutBackground( const SfxItemSet& rItemSet, bool bGraphic );
496 
497  void OutLanguage( LanguageType eLang );
498  SvxFrameDirection GetHTMLDirection( SvxFrameDirection nDir ) const;
499  SvxFrameDirection GetHTMLDirection( const SfxItemSet& rItemSet ) const;
500  void OutDirection( SvxFrameDirection nDir );
501  static OString convertDirection(SvxFrameDirection nDirection);
502 
503  // ALT/ALIGN/WIDTH/HEIGHT/HSPACE/VSPACE option of current
504  // frame format output and maybe add a <BR CLEAR=...> at the
505  // beginning of rEndTags
506  OString OutFrameFormatOptions( const SwFrameFormat& rFrameFormat, const OUString& rAltText,
507  HtmlFrmOpts nFrameOpts );
508 
509  void writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameFormat& rFrameFormat, std::u16string_view rAltText, HtmlFrmOpts nFrameOpts);
510 
512  void OutCSS1_TableFrameFormatOptions( const SwFrameFormat& rFrameFormat );
513 
515  void OutCSS1_TableCellBordersAndBG(const SwFrameFormat& rFrameFormat, const SvxBrushItem *pBrushItem);
516 
517  void OutCSS1_SectionFormatOptions( const SwFrameFormat& rFrameFormat, const SwFormatCol *pCol );
518  void OutCSS1_FrameFormatOptions( const SwFrameFormat& rFrameFormat, HtmlFrmOpts nFrameOpts,
519  const SdrObject *pSdrObj=nullptr,
520  const SfxItemSet *pItemSet=nullptr );
521  void OutCSS1_FrameFormatBackground( const SwFrameFormat& rFrameFormat );
522 
523  void ChangeParaToken( HtmlTokenId nNew );
524 
525  void IncIndentLevel()
526  {
527  m_nIndentLvl++;
528  }
529  void DecIndentLevel()
530  {
531  if ( m_nIndentLvl ) m_nIndentLvl--;
532  }
533  OString GetIndentString(sal_uInt16 nIncLvl = 0);
534 
535  sal_Int32 GetLineLen()
536  {
537  return static_cast<sal_Int32>(Strm().Tell()-m_nLastLFPos);
538  }
539  void OutNewLine( bool bCheck=false );
540 
541  // for HTMLSaveData
542  SwPaM* GetEndPaM() { return m_pOrigPam; }
543  void SetEndPaM( SwPaM* pPam ) { m_pOrigPam = pPam; }
544 
545  static sal_uInt32 ToPixel( sal_uInt32 nVal, const bool bVert );
546 
547  sal_uInt16 GuessFrameType( const SwFrameFormat& rFrameFormat,
548  const SdrObject*& rpStrObj );
549  static sal_uInt16 GuessOLENodeFrameType( const SwNode& rNd );
550 
551  void CollectFlyFrames();
552 
553  sal_uInt16 GetHTMLFontSize( sal_uInt32 nFontHeight ) const;
554 
555  // Fetch current numbering information.
556  SwHTMLNumRuleInfo& GetNumInfo() { return *m_pNumRuleInfo; }
557 
558  // Fetch current numbering information of next paragraph. They
559  // don't have to exist yet!
560  SwHTMLNumRuleInfo *GetNextNumInfo() { return m_pNextNumRuleInfo.get(); }
561  std::unique_ptr<SwHTMLNumRuleInfo> ReleaseNextNumInfo();
562 
563  // Set the numbering information of next paragraph.
564  void SetNextNumInfo( std::unique_ptr<SwHTMLNumRuleInfo> pNxt );
565 
566  // Fill the numbering information of next paragraph.
567  void FillNextNumInfo();
568 
569  // Clear numbering information of next paragraph.
570  void ClearNextNumInfo();
571 
572  static const SdrObject* GetHTMLControl( const SwDrawFrameFormat& rFormat );
573  static const SdrObject* GetMarqueeTextObj( const SwDrawFrameFormat& rFormat );
574  static sal_uInt16 GetCSS1Selector( const SwFormat *pFormat, OString& rToken,
575  OUString& rClass, sal_uInt16& rRefPoolId,
576  OUString *pPseudo=nullptr );
577 
578  static const SwFormat *GetTemplateFormat( sal_uInt16 nPoolId, IDocumentStylePoolAccess* /*SwDoc*/ pTemplate );
579  static const SwFormat *GetParentFormat( const SwFormat& rFormat, sal_uInt16 nDeep );
580 
581  static void SubtractItemSet( SfxItemSet& rItemSet,
582  const SfxItemSet& rRefItemSet,
583  bool bSetDefaults,
584  bool bClearSame = true,
585  const SfxItemSet *pRefScriptItemSet=nullptr );
586  static bool HasScriptDependentItems( const SfxItemSet& rItemSet,
587  bool bCheckDropCap );
588 
589  static void GetEEAttrsFromDrwObj( SfxItemSet& rItemSet,
590  const SdrObject *pObj );
591 
592  static sal_uInt16 GetDefListLvl( std::u16string_view rNm, sal_uInt16 nPoolId );
593 
594  sal_uInt32 GetHTMLMode() const
595  {
596  return m_nHTMLMode;
597  }
598  bool IsHTMLMode( sal_uInt32 nMode ) const
599  {
600  return (m_nHTMLMode & nMode) != 0;
601  }
602 
603  inline bool IsCSS1Source( sal_uInt16 n ) const;
604  inline bool IsCSS1Script( sal_uInt16 n ) const;
605 
606  static const char *GetNumFormat( sal_uInt16 nFormat );
607  static void PrepareFontList( const SvxFontItem& rFontItem, OUString& rNames,
608  sal_Unicode cQuote, bool bGeneric );
609  static sal_uInt16 GetCSS1ScriptForScriptType( sal_uInt16 nScriptType );
610  static sal_uInt16 GetLangWhichIdFromScript( sal_uInt16 nScript );
611 
612  FieldUnit GetCSS1Unit() const { return m_eCSS1Unit; }
613 
614  sal_Int32 indexOfDotLeaders( sal_uInt16 nPoolId, std::u16string_view rText );
615 
617  OString GetNamespace() const;
618 };
619 
620 inline bool SwHTMLWriter::IsCSS1Source( sal_uInt16 n ) const
621 {
622  return n == (m_nCSS1OutMode & CSS1_OUTMODE_SOURCE);
623 }
624 
625 inline bool SwHTMLWriter::IsCSS1Script( sal_uInt16 n ) const
626 {
627  sal_uInt16 nScript = (m_nCSS1OutMode & CSS1_OUTMODE_SCRIPT);
628  return CSS1_OUTMODE_ANY_SCRIPT == nScript || n == nScript;
629 }
630 
631 inline void SwHTMLWriter::OutCSS1_PropertyAscii( const char *pProp,
632  const char *pVal )
633 {
634  OutCSS1_Property( pProp, pVal, nullptr );
635 }
636 
637 inline void SwHTMLWriter::OutCSS1_PropertyAscii( const char *pProp,
638  std::string_view rVal )
639 {
640  OutCSS1_Property( pProp, rVal, nullptr );
641 }
642 
643 inline void SwHTMLWriter::OutCSS1_Property( const char *pProp,
644  const OUString& rVal )
645 {
646  OutCSS1_Property( pProp, std::string_view(), &rVal );
647 }
648 
649 
650 // Structure caches the current data of the writer to output
651 // another part of the document, like e.g. header/footer
652 // With the two USHORTs in the ctor a new PaM is created and sets the
653 // positions in the document.
654 // In dtor all data is restored and the created PaM is deleted again.
655 
656 struct HTMLSaveData
657 {
658  SwHTMLWriter& rWrt;
659  std::shared_ptr<SwUnoCursor> pOldPam;
660  SwPaM *pOldEnd;
661  std::unique_ptr<SwHTMLNumRuleInfo> pOldNumRuleInfo; // Owner = this
662  std::unique_ptr<SwHTMLNumRuleInfo> pOldNextNumRuleInfo;
663  sal_uInt16 nOldDefListLvl;
664  SvxFrameDirection nOldDirection;
665  bool bOldWriteAll : 1;
666  bool bOldOutHeader : 1;
667  bool bOldOutFooter : 1;
668  bool bOldOutFlyFrame : 1;
669 
670  HTMLSaveData( SwHTMLWriter&, SwNodeOffset nStt, SwNodeOffset nEnd,
671  bool bSaveNum=true,
672  const SwFrameFormat *pFrameFormat=nullptr );
673  ~HTMLSaveData();
674 };
675 
676 // some function prototypes
677 Writer& OutHTML_FrameFormatOLENode( Writer& rWrt, const SwFrameFormat& rFormat,
678  bool bInCntnr );
679 Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFormat,
680  bool bInCntnr );
681 
682 Writer& OutHTML_SwTextNode( Writer&, const SwContentNode& );
683 Writer& OutHTML_SwTableNode( Writer& , SwTableNode &, const SwFrameFormat *,
684  const OUString* pCaption=nullptr, bool bTopCaption=false );
685 
686 Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt, const SwDrawFrameFormat& rFormat,
687  const SdrUnoObj& rSdrObj, bool bInCntnr );
688 Writer& OutHTML_DrawFrameFormatAsMarquee( Writer& rWrt, const SwDrawFrameFormat& rFormat,
689  const SdrObject& rSdrObj );
690 
691 Writer& OutHTML_HeaderFooter( Writer& rWrt, const SwFrameFormat& rFrameFormat,
692  bool bHeader );
693 
694 Writer& OutHTML_ImageStart( HtmlWriter& rHtml, Writer&, const SwFrameFormat& rFormat,
695  const OUString& rGraphicURL,
696  Graphic const & rGraphic, const OUString& rAlternateText,
697  const Size& rRealSize, HtmlFrmOpts nFrameOpts,
698  const char *pMarkType,
699  const ImageMap *pGenImgMap,
700  const OUString& rMimeType = OUString() );
701 Writer& OutHTML_ImageEnd( HtmlWriter& rHtml, Writer& );
702 
703 Writer& OutHTML_BulletImage( Writer& rWrt, const char *pTag,
704  const SvxBrushItem* pBrush,
705  const OUString& rGraphicURL);
706 
707 Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt );
708 Writer& OutHTML_SwFormatFootnote( Writer& rWrt, const SfxPoolItem& rHt );
709 Writer& OutHTML_SwFormatLineBreak(Writer& rWrt, const SfxPoolItem& rHt);
710 Writer& OutHTML_INetFormat( Writer&, const SwFormatINetFormat& rINetFormat, bool bOn );
711 
712 Writer& OutCSS1_BodyTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet );
713 Writer& OutCSS1_ParaTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet );
714 
715 Writer& OutCSS1_HintSpanTag( Writer& rWrt, const SfxPoolItem& rHt );
716 Writer& OutCSS1_HintStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
717 
719 Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
720 
721 Writer& OutCSS1_NumberBulletListStyleOpt( Writer& rWrt, const SwNumRule& rNumRule,
722  sal_uInt8 nLevel );
723 
724 Writer& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt,
725  const SwHTMLNumRuleInfo& rInfo,
726  bool& rAtLeastOneNumbered );
727 Writer& OutHTML_NumberBulletListEnd( SwHTMLWriter& rWrt,
728  const SwHTMLNumRuleInfo& rNextInfo );
729 
730 Writer& OutCSS1_SvxBox( Writer& rWrt, const SfxPoolItem& rHt );
731 
732 OString GetCSS1_Color(const Color& rColor);
733 
735 bool IgnorePropertyForReqIF(bool bReqIF, std::string_view rProperty, std::string_view rValue,
736  std::optional<sw::Css1Background> oBackground = std::nullopt);
737 
738 #endif // INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
739 
740 /* 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:3214
Marks a node in the document model.
Definition: ndindex.hxx:30
sal_uInt32 Id
HtmlTokenId
HtmlFrmOpts
Definition: wrthtml.hxx:76
HtmlPosition
Definition: htmlfly.hxx:69