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>
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
44class Color;
45class SwFrameFormat;
51class SwStartNode;
52class SwTableNode;
53class SwPageDesc;
54class SwNodeIndex;
55class ImageMap;
56class SwNumRule;
57class SdrObject;
58class SdrUnoObj;
59class SvxBrushItem;
60class SvxFontItem;
63class SwTextFootnote;
64enum class HtmlPosition;
65enum class HtmlTokenId : sal_Int16;
66namespace utl { class TempFileNamed; }
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
76enum 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,
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};
112namespace 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
190struct 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( css::uno::Reference<css::container::XIndexContainer> xForm, 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
207class HTMLControls : public o3tl::sorted_vector<std::unique_ptr<HTMLControl>, o3tl::less_uniqueptr_to<HTMLControl> > {
208};
209
210struct 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
253typedef std::set<std::unique_ptr<SwHTMLFormatInfo>,
254 comphelper::UniquePtrValueLess<SwHTMLFormatInfo>> SwHTMLFormatInfos;
255
256class IDocumentStylePoolAccess;
257
258namespace sw
259{
260enum 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
272class SW_DLLPUBLIC SwHTMLWriter : public Writer
273{
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
278
279 FieldUnit m_eCSS1Unit;
280
281 sal_uInt16 OutHeaderAttrs();
282 const SwPageDesc *MakeHeader( sal_uInt16& rHeaderAtrs );
283 void GetControls();
284
285 void AddLinkTarget( std::u16string_view aURL );
286 void CollectLinkTargets();
287
288 void SetupFilterOptions(std::u16string_view rFilterOptions);
289
290protected:
291 ErrCode WriteStream() override;
292 void SetupFilterOptions(SfxMedium& rMedium) override;
293 void SetupFilterFromPropertyValues(
294 const css::uno::Sequence<css::beans::PropertyValue>& rPropertyValues);
295
296public:
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::TempFileNamed> 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 bool m_bPrettyPrint : 1; // Allows to add new lines to make it more readable
420 // 26
421
423 std::map<sal_uInt16, int> maStartedAttributes;
424
425 OUString m_aRTFOLEMimeType;
426
428 bool m_bExportImagesAsOLE = false;
429
431 std::optional<sal_Int32> m_nShapeDPI;
432
434 std::optional<sal_Int32> m_nLeadingTabWidth;
435
438 explicit SwHTMLWriter( const OUString& rBaseURL, std::u16string_view rFilterOptions = std::u16string_view() );
439 virtual ~SwHTMLWriter() override;
440
441 void Out_SwDoc( SwPaM* ); // write the marked range
442
443 // output all bookmarks of current paragraph
444 void OutAnchor( const OUString& rName );
445 void OutBookmarks();
446 void OutPointFieldmarks( const SwPosition& rPos );
447 void OutImplicitMark( std::u16string_view rMark, const char *pMarkType );
448
449 OUString convertHyperlinkHRefValue(const OUString& rURL);
450
451 void OutHyperlinkHRefValue( const OUString& rURL );
452
453 // output the FlyFrame anchored at current position
454 bool OutFlyFrame( SwNodeOffset nNdIdx, sal_Int32 nContentIdx,
455 HtmlPosition nPos );
456 void OutFrameFormat( AllHtmlFlags nType, const SwFrameFormat& rFormat,
457 const SdrObject *pSdrObj );
458
459 void OutForm( bool bTagOn=true, const SwStartNode *pStNd=nullptr );
460 void OutHiddenForms();
461 void OutHiddenForm( const css::uno::Reference<css::form::XForm>& rForm );
462
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;
467
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 );
473
474 void OutBasic(const SwHTMLWriter& rHTMLWrt);
475
476 // Used to indent inner blocks using dl/dd tags
477 void OutAndSetDefList( sal_uInt16 nNewLvl );
478
479 void OutStyleSheet( const SwPageDesc& rPageDesc );
480
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 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 SwHTMLFrameType GuessFrameType( const SwFrameFormat& rFrameFormat,
548 const SdrObject*& rpStrObj );
549 static SwHTMLFrameType 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
620inline bool SwHTMLWriter::IsCSS1Source( sal_uInt16 n ) const
621{
622 return n == (m_nCSS1OutMode & CSS1_OUTMODE_SOURCE);
623}
624
625inline 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
631inline void SwHTMLWriter::OutCSS1_PropertyAscii( std::string_view pProp,
632 std::string_view rVal )
633{
634 OutCSS1_Property( pProp, rVal, nullptr );
635}
636
637inline void SwHTMLWriter::OutCSS1_Property( std::string_view pProp,
638 const OUString& rVal )
639{
640 OutCSS1_Property( pProp, std::string_view(), &rVal );
641}
642
643
644// Structure caches the current data of the writer to output
645// another part of the document, like e.g. header/footer
646// With the two USHORTs in the ctor a new PaM is created and sets the
647// positions in the document.
648// In dtor all data is restored and the created PaM is deleted again.
649
650class HTMLSaveData
651{
652 SwHTMLWriter& rWrt;
653 std::shared_ptr<SwUnoCursor> pOldPam;
654 SwPaM *pOldEnd;
655 std::unique_ptr<SwHTMLNumRuleInfo> pOldNumRuleInfo; // Owner = this
656 std::unique_ptr<SwHTMLNumRuleInfo> pOldNextNumRuleInfo;
657 sal_uInt16 nOldDefListLvl;
658 SvxFrameDirection nOldDirection;
659 bool bOldWriteAll : 1;
660 bool bOldOutHeader : 1;
661 bool bOldOutFooter : 1;
662 bool bOldOutFlyFrame : 1;
663
664public:
665 HTMLSaveData( SwHTMLWriter&, SwNodeOffset nStt, SwNodeOffset nEnd,
666 bool bSaveNum=true,
667 const SwFrameFormat *pFrameFormat=nullptr );
668 ~HTMLSaveData();
669};
670
671// some function prototypes
672SwHTMLWriter& OutHTML_FrameFormatOLENode( SwHTMLWriter& rWrt, const SwFrameFormat& rFormat,
673 bool bInCntnr );
674SwHTMLWriter& OutHTML_FrameFormatOLENodeGrf( SwHTMLWriter& rWrt, const SwFrameFormat& rFormat,
675 bool bInCntnr, bool bWriteReplacementGraphic = true );
676
677SwHTMLWriter& OutHTML_SwTextNode( SwHTMLWriter&, const SwContentNode& );
678SwHTMLWriter& OutHTML_SwTableNode( SwHTMLWriter& , SwTableNode &, const SwFrameFormat *,
679 const OUString* pCaption=nullptr, bool bTopCaption=false );
680
681SwHTMLWriter& OutHTML_DrawFrameFormatAsControl( SwHTMLWriter& rWrt, const SwDrawFrameFormat& rFormat,
682 const SdrUnoObj& rSdrObj, bool bInCntnr );
683SwHTMLWriter& OutHTML_DrawFrameFormatAsMarquee( SwHTMLWriter& rWrt, const SwDrawFrameFormat& rFormat,
684 const SdrObject& rSdrObj );
685
686SwHTMLWriter& OutHTML_HeaderFooter( SwHTMLWriter& rWrt, const SwFrameFormat& rFrameFormat,
687 bool bHeader );
688
689SwHTMLWriter& 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 = {} );
696SwHTMLWriter& OutHTML_ImageEnd( HtmlWriter& rHtml, SwHTMLWriter& );
697
698SwHTMLWriter& OutHTML_BulletImage( SwHTMLWriter& rWrt, const char *pTag,
699 const SvxBrushItem* pBrush,
700 const OUString& rGraphicURL);
701
702SwHTMLWriter& OutHTML_SwFormatField( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
703SwHTMLWriter& OutHTML_SwFormatFootnote( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
704SwHTMLWriter& OutHTML_SwFormatLineBreak(SwHTMLWriter& rWrt, const SfxPoolItem& rHt);
705SwHTMLWriter& OutHTML_INetFormat( SwHTMLWriter&, const SwFormatINetFormat& rINetFormat, bool bOn );
706
707SwHTMLWriter& OutCSS1_BodyTagStyleOpt( SwHTMLWriter& rWrt, const SfxItemSet& rItemSet );
708SwHTMLWriter& OutCSS1_ParaTagStyleOpt( SwHTMLWriter& rWrt, const SfxItemSet& rItemSet );
709
710SwHTMLWriter& OutCSS1_HintSpanTag( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
711SwHTMLWriter& OutCSS1_HintStyleOpt( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
712
714SwHTMLWriter& OutCSS1_TableBGStyleOpt( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
715
716SwHTMLWriter& OutCSS1_NumberBulletListStyleOpt( SwHTMLWriter& rWrt, const SwNumRule& rNumRule,
717 sal_uInt8 nLevel );
718
719SwHTMLWriter& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt,
720 const SwHTMLNumRuleInfo& rInfo );
721SwHTMLWriter& OutHTML_NumberBulletListEnd( SwHTMLWriter& rWrt,
722 const SwHTMLNumRuleInfo& rNextInfo );
723
724SwHTMLWriter& OutCSS1_SvxBox( SwHTMLWriter& rWrt, const SfxPoolItem& rHt );
725
726OString GetCSS1_Color(const Color& rColor);
727
729bool IgnorePropertyForReqIF(bool bReqIF, std::string_view rProperty, std::string_view rValue,
730 std::optional<sw::Css1Background> oBackground = std::nullopt);
731
732#endif // INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
733
734/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxPoolItem subclass for footnotes and endnotes, stored in the anchor text node.
Definition: fmtftn.hxx:47
Defines the vertical position of a fly frame.
Definition: fmtornt.hxx:37
Style of a layout element.
Definition: frmfmt.hxx:72
Marks a node in the document model.
Definition: ndindex.hxx:31
Starts a section of nodes in the document model.
Definition: node.hxx:348
SwTextAttr subclass for footnotes and endnotes.
Definition: txtftn.hxx:34
HtmlPosition
Definition: htmlfly.hxx:66
HtmlTokenId
NONE
sal_uInt32 Id
OUString Name
FnAttrOut SwAttrFnTab[POOLATTR_END - POOLATTR_BEGIN]
Definition: wrt_fn.hxx:33
HtmlFrmOpts
Definition: wrthtml.hxx:76
@ Replacement
The graphic frame is a replacement image of an OLE object.
SwAttrFnTab aHTMLAttrFnTab
Definition: htmlatr.cxx:3219