1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
20 #define INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
25 #include <string_view>
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>
39 #include <shellio.hxx>
41 #include "htmlfly.hxx"
43 // some forward declarations
46 class SwFlyFrameFormat
;
47 class SwDrawFrameFormat
;
48 class SwFormatINetFormat
;
49 class SwFormatVertOrient
;
50 class SwFormatFootnote
;
61 class SwHTMLNumRuleInfo
;
62 class SwHTMLPosFlyFrames
;
64 enum class HtmlPosition
;
65 enum class HtmlTokenId
: sal_Int16
;
66 namespace utl
{ class TempFileNamed
; }
68 extern SwAttrFnTab aHTMLAttrFnTab
;
70 #define HTML_PARSPACE (o3tl::toTwips(5, o3tl::Length::mm))
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
{
83 Size
= Width
| Height
,
86 SSize
= SWidth
| SHeight
,
106 /// The graphic frame is a replacement image of an OLE object.
109 GenImgAllMask
= Alt
| Size
| AbsSize
| Name
,
110 GenImgMask
= GenImgAllMask
| Align
| Space
| BrClear
113 template<> struct typed_flags
<HtmlFrmOpts
> : is_typed_flags
<HtmlFrmOpts
, ((1<<22)-1)> {};
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
131 #define HTML_DLCOLL_DD 0x4000
132 #define HTML_DLCOLL_DT 0x8000
134 #define CSS1_FMT_ISTAG (USHRT_MAX)
135 #define CSS1_FMT_CMPREF (USHRT_MAX-1)
136 #define CSS1_FMT_SPECIAL (USHRT_MAX-1)
138 // the following flags only specify which descriptors, tags, options,
139 // and so on should be outputted
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
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))
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)
160 // the following flags specify what should be outputted
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))
174 #define CSS1_OUTMODE_ENCODE (sal_uInt16(0x0001U << 10))
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))
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
197 HTMLControl( css::uno::Reference
<css::container::XIndexContainer
> xForm
, SwNodeOffset nIdx
);
200 // operators for the sort array
201 bool operator<( const HTMLControl
& rCtrl
) const
203 return nNdIdx
< rCtrl
.nNdIdx
;
207 class HTMLControls
: public o3tl::sorted_vector
<std::unique_ptr
<HTMLControl
>, o3tl::less_uniqueptr_to
<HTMLControl
> > {
210 struct SwHTMLFormatInfo
212 const SwFormat
*pFormat
; // the format itself
214 OString aToken
; // the token to output
215 OUString aClass
; // the class to output
217 std::optional
<SfxItemSet
> moItemSet
; // the attribute set to output
219 sal_Int32 nLeftMargin
; // some default values for
220 sal_Int32 nRightMargin
; // paragraph styles
221 short nFirstLineIndent
;
223 sal_uInt16 nTopMargin
;
224 sal_uInt16 nBottomMargin
;
226 bool bScriptDependent
;
228 // ctor for a dummy to search
229 explicit SwHTMLFormatInfo( const SwFormat
*pF
) :
236 bScriptDependent(false)
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
);
245 friend bool operator<( const SwHTMLFormatInfo
& rInfo1
,
246 const SwHTMLFormatInfo
& rInfo2
)
248 return reinterpret_cast<sal_IntPtr
>(rInfo1
.pFormat
) < reinterpret_cast<sal_IntPtr
>(rInfo2
.pFormat
);
253 typedef std::set
<std::unique_ptr
<SwHTMLFormatInfo
>,
254 comphelper::UniquePtrValueLess
<SwHTMLFormatInfo
>> SwHTMLFormatInfos
;
256 class IDocumentStylePoolAccess
;
260 enum class Css1Background
272 class SW_DLLPUBLIC SwHTMLWriter
: public Writer
274 SwHTMLPosFlyFrames m_aHTMLPosFlyFrames
;
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
279 FieldUnit m_eCSS1Unit
;
281 sal_uInt16
OutHeaderAttrs();
282 const SwPageDesc
*MakeHeader( sal_uInt16
& rHeaderAtrs
);
285 void AddLinkTarget( std::u16string_view aURL
);
286 void CollectLinkTargets();
288 void SetupFilterOptions(std::u16string_view rFilterOptions
);
291 ErrCode
WriteStream() override
;
292 void SetupFilterOptions(SfxMedium
& rMedium
) override
;
293 void SetupFilterFromPropertyValues(
294 const css::uno::Sequence
<css::beans::PropertyValue
>& rPropertyValues
);
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
;
310 OUString m_aCSS1Selector
; // style selector
311 OUString m_aBulletGrfs
[MAXLEVEL
]; // list graphics
313 css::uno::Reference
<css::container::XIndexContainer
> mxFormComps
; // current form
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
;
321 sal_uInt32 m_aFontHeights
[7]; // font heights 1-7
323 ErrCode m_nWarn
; // warning code
324 sal_uInt32 m_nLastLFPos
; // last position of LF
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
351 LanguageType m_eLang
;
353 // description of the export configuration
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;
361 // description of what will be exported
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
366 // The following two flags specify how attributes are exported:
367 // bTextAttr bOutOpts
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;
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;
382 // flags for style export
384 bool m_bFirstCSS1Rule
: 1; // was a property already written
385 bool m_bFirstCSS1Property
: 1; // was a property already written
388 bool m_bCSS1IgnoreFirstPageDesc
: 1;
390 // what must/can/may not be written?
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
399 bool m_bPreserveForm
: 1; // preserve the current form
401 bool m_bCfgNetscape4
: 1; // Netscape4 hacks
403 bool mbSkipImages
: 1;
404 /// If HTML header and footer should be written as well, or just the content itself.
405 bool mbSkipHeaderFooter
: 1;
406 bool mbEmbedImages
: 1;
407 /// Temporary base URL for paste of images.
408 std::unique_ptr
<utl::TempFileNamed
> mpTempBaseURL
;
409 /// If XHTML markup should be written instead of HTML.
410 bool mbXHTML
= false;
411 /// XML namespace, in case of XHTML.
413 /// If the ReqIF subset of XHTML should be written.
414 bool mbReqIF
= false;
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 bool m_bPrettyPrint
: 1; // Allows to add new lines to make it more readable
422 /// Tracks which text portion attributes are currently open: a which id -> open count map.
423 std::map
<sal_uInt16
, int> maStartedAttributes
;
425 OUString m_aRTFOLEMimeType
;
427 /// ReqIF mode: export images as OLE objects.
428 bool m_bExportImagesAsOLE
= false;
430 /// DPI used when exporting a vector shape as a bitmap.
431 std::optional
<sal_Int32
> m_nShapeDPI
;
433 /// If set, replace leading tabs with this many non-breaking spaces.
434 std::optional
<sal_Int32
> m_nLeadingTabWidth
;
436 /// Construct an instance of SwHTMLWriter and optionally give it
437 /// the filter options directly, which can also be set via SetupFilterOptions().
438 explicit SwHTMLWriter( const OUString
& rBaseURL
, std::u16string_view rFilterOptions
= std::u16string_view() );
439 virtual ~SwHTMLWriter() override
;
441 void Out_SwDoc( SwPaM
* ); // write the marked range
443 // output all bookmarks of current paragraph
444 void OutAnchor( const OUString
& rName
);
446 void OutPointFieldmarks( const SwPosition
& rPos
);
447 void OutImplicitMark( std::u16string_view rMark
, const char *pMarkType
);
449 OUString
convertHyperlinkHRefValue(const OUString
& rURL
);
451 void OutHyperlinkHRefValue( const OUString
& rURL
);
453 // output the FlyFrame anchored at current position
454 bool OutFlyFrame( SwNodeOffset nNdIdx
, sal_Int32 nContentIdx
,
456 void OutFrameFormat( AllHtmlFlags nType
, const SwFrameFormat
& rFormat
,
457 const SdrObject
*pSdrObj
);
459 void OutForm( bool bTagOn
=true, const SwStartNode
*pStNd
=nullptr );
460 void OutHiddenForms();
461 void OutHiddenForm( const css::uno::Reference
<css::form::XForm
>& rForm
);
463 void OutForm( bool bOn
, const css::uno::Reference
<css::container::XIndexContainer
>& rFormComps
);
464 void OutHiddenControls( const css::uno::Reference
<css::container::XIndexContainer
>& rFormComps
,
465 const css::uno::Reference
<css::beans::XPropertySet
>& rPropSet
);
466 bool HasControls() const;
468 void OutFootEndNoteInfo();
469 void OutFootEndNotes();
470 OUString
GetFootEndNoteSym( const SwFormatFootnote
& rFormatFootnote
);
471 void OutFootEndNoteSym( const SwFormatFootnote
& rFormatFootnote
, const OUString
& rNum
,
472 sal_uInt16 nScript
);
474 void OutBasic(const SwHTMLWriter
& rHTMLWrt
);
476 // Used to indent inner blocks using dl/dd tags
477 void OutAndSetDefList( sal_uInt16 nNewLvl
);
479 void OutStyleSheet( const SwPageDesc
& rPageDesc
);
481 inline void OutCSS1_PropertyAscii( std::string_view pProp
,
482 std::string_view rVal
);
483 inline void OutCSS1_Property( std::string_view pProp
, const OUString
& rVal
);
484 void OutCSS1_Property( std::string_view pProp
, std::string_view pVal
,
485 const OUString
*pSVal
, std::optional
<sw::Css1Background
> oBackground
= std::nullopt
);
486 void OutCSS1_UnitProperty( std::string_view pProp
, tools::Long nVal
);
487 void OutCSS1_PixelProperty( std::string_view pProp
, tools::Long nTwips
);
488 void OutCSS1_SfxItemSet( const SfxItemSet
& rItemSet
, bool bDeep
=true );
490 // events of BODY tag from SFX configuration
491 void OutBasicBodyEvents();
493 // BACKGROUND/BGCOLOR option
494 void OutBackground( const SvxBrushItem
*pBrushItem
, bool bGraphic
);
495 void OutBackground( const SfxItemSet
& rItemSet
, bool bGraphic
);
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
);
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
);
509 void writeFrameFormatOptions(HtmlWriter
& aHtml
, const SwFrameFormat
& rFrameFormat
, std::u16string_view rAltText
, HtmlFrmOpts nFrameOpts
);
511 /// Writes the formatting for tables.
512 void OutCSS1_TableFrameFormatOptions( const SwFrameFormat
& rFrameFormat
);
514 /// Writes the borders and background for table cells.
515 void OutCSS1_TableCellBordersAndBG(const SwFrameFormat
& rFrameFormat
, const SvxBrushItem
*pBrushItem
);
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
);
523 void ChangeParaToken( HtmlTokenId nNew
);
525 void IncIndentLevel()
529 void DecIndentLevel()
531 if ( m_nIndentLvl
) m_nIndentLvl
--;
533 OString
GetIndentString(sal_uInt16 nIncLvl
= 0);
535 sal_Int32
GetLineLen()
537 return static_cast<sal_Int32
>(Strm().Tell()-m_nLastLFPos
);
539 void OutNewLine( bool bCheck
=false );
542 SwPaM
* GetEndPaM() { return m_pOrigPam
; }
543 void SetEndPaM( SwPaM
* pPam
) { m_pOrigPam
= pPam
; }
545 static sal_uInt32
ToPixel(sal_uInt32 nTwips
);
546 static Size
ToPixel(Size aTwips
);
548 SwHTMLFrameType
GuessFrameType( const SwFrameFormat
& rFrameFormat
,
549 const SdrObject
*& rpStrObj
);
550 static SwHTMLFrameType
GuessOLENodeFrameType( const SwNode
& rNd
);
552 void CollectFlyFrames();
554 sal_uInt16
GetHTMLFontSize( sal_uInt32 nFontHeight
) const;
556 // Fetch current numbering information.
557 SwHTMLNumRuleInfo
& GetNumInfo() { return *m_pNumRuleInfo
; }
559 // Fetch current numbering information of next paragraph. They
560 // don't have to exist yet!
561 SwHTMLNumRuleInfo
*GetNextNumInfo() { return m_pNextNumRuleInfo
.get(); }
562 std::unique_ptr
<SwHTMLNumRuleInfo
> ReleaseNextNumInfo();
564 // Set the numbering information of next paragraph.
565 void SetNextNumInfo( std::unique_ptr
<SwHTMLNumRuleInfo
> pNxt
);
567 // Fill the numbering information of next paragraph.
568 void FillNextNumInfo();
570 // Clear numbering information of next paragraph.
571 void ClearNextNumInfo();
573 static const SdrObject
* GetHTMLControl( const SwDrawFrameFormat
& rFormat
);
574 static const SdrObject
* GetMarqueeTextObj( const SwDrawFrameFormat
& rFormat
);
575 static sal_uInt16
GetCSS1Selector( const SwFormat
*pFormat
, OString
& rToken
,
576 OUString
& rClass
, sal_uInt16
& rRefPoolId
,
577 OUString
*pPseudo
=nullptr );
579 static const SwFormat
*GetTemplateFormat( sal_uInt16 nPoolId
, IDocumentStylePoolAccess
* /*SwDoc*/ pTemplate
);
580 static const SwFormat
*GetParentFormat( const SwFormat
& rFormat
, sal_uInt16 nDeep
);
582 static void SubtractItemSet( SfxItemSet
& rItemSet
,
583 const SfxItemSet
& rRefItemSet
,
585 bool bClearSame
= true,
586 const SfxItemSet
*pRefScriptItemSet
=nullptr );
587 static bool HasScriptDependentItems( const SfxItemSet
& rItemSet
,
588 bool bCheckDropCap
);
590 static void GetEEAttrsFromDrwObj( SfxItemSet
& rItemSet
,
591 const SdrObject
*pObj
);
593 static sal_uInt16
GetDefListLvl( std::u16string_view rNm
, sal_uInt16 nPoolId
);
595 sal_uInt32
GetHTMLMode() const
599 bool IsHTMLMode( sal_uInt32 nMode
) const
601 return (m_nHTMLMode
& nMode
) != 0;
604 inline bool IsCSS1Source( sal_uInt16 n
) const;
605 inline bool IsCSS1Script( sal_uInt16 n
) const;
607 static const char *GetNumFormat( sal_uInt16 nFormat
);
608 static void PrepareFontList( const SvxFontItem
& rFontItem
, OUString
& rNames
,
609 sal_Unicode cQuote
, bool bGeneric
);
610 static sal_uInt16
GetCSS1ScriptForScriptType( sal_uInt16 nScriptType
);
611 static sal_uInt16
GetLangWhichIdFromScript( sal_uInt16 nScript
);
613 FieldUnit
GetCSS1Unit() const { return m_eCSS1Unit
; }
615 sal_Int32
indexOfDotLeaders( sal_uInt16 nPoolId
, std::u16string_view rText
);
617 /// Determines the prefix string needed to respect the requested namespace alias.
618 OString
GetNamespace() const;
621 inline bool SwHTMLWriter::IsCSS1Source( sal_uInt16 n
) const
623 return n
== (m_nCSS1OutMode
& CSS1_OUTMODE_SOURCE
);
626 inline bool SwHTMLWriter::IsCSS1Script( sal_uInt16 n
) const
628 sal_uInt16 nScript
= (m_nCSS1OutMode
& CSS1_OUTMODE_SCRIPT
);
629 return CSS1_OUTMODE_ANY_SCRIPT
== nScript
|| n
== nScript
;
632 inline void SwHTMLWriter::OutCSS1_PropertyAscii( std::string_view pProp
,
633 std::string_view rVal
)
635 OutCSS1_Property( pProp
, rVal
, nullptr );
638 inline void SwHTMLWriter::OutCSS1_Property( std::string_view pProp
,
639 const OUString
& rVal
)
641 OutCSS1_Property( pProp
, std::string_view(), &rVal
);
645 // Structure caches the current data of the writer to output
646 // another part of the document, like e.g. header/footer
647 // With the two USHORTs in the ctor a new PaM is created and sets the
648 // positions in the document.
649 // In dtor all data is restored and the created PaM is deleted again.
654 std::shared_ptr
<SwUnoCursor
> pOldPam
;
656 std::unique_ptr
<SwHTMLNumRuleInfo
> pOldNumRuleInfo
; // Owner = this
657 std::unique_ptr
<SwHTMLNumRuleInfo
> pOldNextNumRuleInfo
;
658 sal_uInt16 nOldDefListLvl
;
659 SvxFrameDirection nOldDirection
;
660 bool bOldWriteAll
: 1;
661 bool bOldOutHeader
: 1;
662 bool bOldOutFooter
: 1;
663 bool bOldOutFlyFrame
: 1;
665 HTMLSaveData( SwHTMLWriter
&, SwNodeOffset nStt
, SwNodeOffset nEnd
,
667 const SwFrameFormat
*pFrameFormat
=nullptr );
671 // some function prototypes
672 SwHTMLWriter
& OutHTML_FrameFormatOLENode( SwHTMLWriter
& rWrt
, const SwFrameFormat
& rFormat
,
674 SwHTMLWriter
& OutHTML_FrameFormatOLENodeGrf( SwHTMLWriter
& rWrt
, const SwFrameFormat
& rFormat
,
675 bool bInCntnr
, bool bWriteReplacementGraphic
= true );
677 SwHTMLWriter
& OutHTML_SwTextNode( SwHTMLWriter
&, const SwContentNode
& );
678 SwHTMLWriter
& OutHTML_SwTableNode( SwHTMLWriter
& , SwTableNode
&, const SwFrameFormat
*,
679 const OUString
* pCaption
=nullptr, bool bTopCaption
=false );
681 SwHTMLWriter
& OutHTML_DrawFrameFormatAsControl( SwHTMLWriter
& rWrt
, const SwDrawFrameFormat
& rFormat
,
682 const SdrUnoObj
& rSdrObj
, bool bInCntnr
);
683 SwHTMLWriter
& OutHTML_DrawFrameFormatAsMarquee( SwHTMLWriter
& rWrt
, const SwDrawFrameFormat
& rFormat
,
684 const SdrObject
& rSdrObj
);
686 SwHTMLWriter
& OutHTML_HeaderFooter( SwHTMLWriter
& rWrt
, const SwFrameFormat
& rFrameFormat
,
689 SwHTMLWriter
& OutHTML_ImageStart( HtmlWriter
& rHtml
, SwHTMLWriter
&, const SwFrameFormat
& rFormat
,
690 const OUString
& rGraphicURL
,
691 Graphic
const & rGraphic
, const OUString
& rAlternateText
,
692 const Size
& rRealSize
, HtmlFrmOpts nFrameOpts
,
693 const char *pMarkType
,
694 const ImageMap
*pGenImgMap
,
695 std::u16string_view rMimeType
= {} );
696 SwHTMLWriter
& OutHTML_ImageEnd( HtmlWriter
& rHtml
, SwHTMLWriter
& );
698 SwHTMLWriter
& OutHTML_BulletImage( SwHTMLWriter
& rWrt
, const char *pTag
,
699 const SvxBrushItem
* pBrush
,
700 const OUString
& rGraphicURL
);
702 SwHTMLWriter
& OutHTML_SwFormatField( SwHTMLWriter
& rWrt
, const SfxPoolItem
& rHt
);
703 SwHTMLWriter
& OutHTML_SwFormatFootnote( SwHTMLWriter
& rWrt
, const SfxPoolItem
& rHt
);
704 SwHTMLWriter
& OutHTML_SwFormatLineBreak(SwHTMLWriter
& rWrt
, const SfxPoolItem
& rHt
);
705 SwHTMLWriter
& OutHTML_INetFormat( SwHTMLWriter
&, const SwFormatINetFormat
& rINetFormat
, bool bOn
);
707 SwHTMLWriter
& OutCSS1_BodyTagStyleOpt( SwHTMLWriter
& rWrt
, const SfxItemSet
& rItemSet
);
708 SwHTMLWriter
& OutCSS1_ParaTagStyleOpt( SwHTMLWriter
& rWrt
, const SfxItemSet
& rItemSet
);
710 SwHTMLWriter
& OutCSS1_HintSpanTag( SwHTMLWriter
& rWrt
, const SfxPoolItem
& rHt
);
711 SwHTMLWriter
& OutCSS1_HintStyleOpt( SwHTMLWriter
& rWrt
, const SfxPoolItem
& rHt
);
713 /// Writes the background of table rows.
714 SwHTMLWriter
& OutCSS1_TableBGStyleOpt( SwHTMLWriter
& rWrt
, const SfxPoolItem
& rHt
);
716 SwHTMLWriter
& OutCSS1_NumberBulletListStyleOpt( SwHTMLWriter
& rWrt
, const SwNumRule
& rNumRule
,
719 SwHTMLWriter
& OutHTML_NumberBulletListStart( SwHTMLWriter
& rWrt
,
720 const SwHTMLNumRuleInfo
& rInfo
);
721 SwHTMLWriter
& OutHTML_NumberBulletListEnd( SwHTMLWriter
& rWrt
,
722 const SwHTMLNumRuleInfo
& rNextInfo
);
724 SwHTMLWriter
& OutCSS1_SvxBox( SwHTMLWriter
& rWrt
, const SfxPoolItem
& rHt
);
726 OString
GetCSS1_Color(const Color
& rColor
);
728 /// Determines if rProperty with a given rValue has to be suppressed due to ReqIF mode.
729 bool IgnorePropertyForReqIF(bool bReqIF
, std::string_view rProperty
, std::string_view rValue
,
730 std::optional
<sw::Css1Background
> oBackground
= std::nullopt
);
732 #endif // INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
734 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */