android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / filter / ww8 / docxattributeoutput.hxx
blob86d49a28c1572cb35cc848a9eb1f45f3e69d6431
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_SW_SOURCE_FILTER_WW8_DOCXATTRIBUTEOUTPUT_HXX
21 #define INCLUDED_SW_SOURCE_FILTER_WW8_DOCXATTRIBUTEOUTPUT_HXX
23 #include <memory>
24 #include <string_view>
26 #include "attributeoutputbase.hxx"
27 #include "fields.hxx"
28 #include <IMark.hxx>
29 #include "docxexport.hxx"
30 #include <wrtswtbl.hxx>
31 #include <redline.hxx>
33 #include <editeng/boxitem.hxx>
34 #include <sax/fshelper.hxx>
35 #include <sax/fastattribs.hxx>
36 #include <vcl/vclenum.hxx>
37 #include <svx/xenum.hxx>
39 #include <fldbas.hxx>
41 #include <vector>
42 #include <optional>
43 #include <o3tl/sorted_vector.hxx>
44 #include <oox/export/vmlexport.hxx>
45 #include <oox/export/drawingml.hxx>
46 #include "docxtablestyleexport.hxx"
48 #include <com/sun/star/table/BorderLine2.hpp>
49 #include <com/sun/star/drawing/FillStyle.hpp>
51 class SwGrfNode;
52 class SdrObject;
53 enum class SvxBoxItemLine;
54 enum class SwLineBreakClear;
55 class SwContentControl;
57 namespace docx { class FootnotesList; }
58 namespace oox::drawingml { class DrawingML; }
60 struct FieldInfos
62 std::shared_ptr<const SwField> pField;
63 const ::sw::mark::IFieldmark* pFieldmark;
64 ww::eField eType;
65 bool bOpen;
66 bool bSep;
67 bool bClose;
68 OUString sCmd;
69 FieldInfos()
70 : pFieldmark(nullptr), eType(ww::eUNKNOWN)
71 , bOpen(false), bSep(false), bClose(false)
75 enum DocxColBreakStatus
77 COLBRK_NONE,
78 COLBRK_POSTPONE,
79 COLBRK_WRITEANDPOSTPONE,
80 COLBRK_WRITE
83 /**
84 * A structure that holds information about the options selected
85 * when outputting a border to DOCX.
87 * There are 3 functions that initialize this structure:
88 * - lcl_getTableDefaultBorderOptions - retrieves the options for when outputting table default borders
89 * - lcl_getTableCellBorderOptions - retrieves the options for when outputting table cell borders
90 * - lcl_getBoxBorderOptions - retrieves the options for when outputting box borders
93 struct OutputBorderOptions
95 sal_Int32 tag = 0;
96 bool bUseStartEnd = false;
97 bool bWriteTag = true;
98 bool bWriteDistance = false;
99 SvxShadowLocation aShadowLocation = SvxShadowLocation::NONE;
100 std::shared_ptr<editeng::WordBorderDistances> pDistances;
103 struct DocxTableExportContext;
106 * A structure that holds flags for the table export.
108 struct TableReference
110 /// Remember if we are in an open cell, or not.
111 bool m_bTableCellOpen;
113 /// If paragraph sdt got opened in this table cell.
114 bool m_bTableCellParaSdtOpen;
116 /// Remember if we are in a deleted/inserted cell, or not.
117 bool m_bTableCellChanged;
119 /// Remember the current table depth.
120 sal_uInt32 m_nTableDepth;
122 TableReference()
123 : m_bTableCellOpen(false),
124 m_bTableCellParaSdtOpen(false),
125 m_bTableCellChanged(false),
126 m_nTableDepth(0)
131 /** Using framePr, a paragraph can be enclosed in a frame described by its pPr paragraph settings,
132 * and therefore it needs to apply the frame's properties when exporting the paragraph properties.
134 class FramePrHelper
136 ww8::Frame* m_pFrame;
137 sal_Int32 m_nTableDepth;
138 bool m_bUseFrameBorders;
139 bool m_bUseFrameBackground;
140 bool m_bUseFrameTextDirection;
142 public:
143 FramePrHelper()
144 : m_pFrame(nullptr)
145 , m_nTableDepth(0)
146 , m_bUseFrameBorders(true)
147 , m_bUseFrameBackground(true)
148 , m_bUseFrameTextDirection(true)
151 ww8::Frame* Frame() { return m_pFrame; }
152 void SetFrame(ww8::Frame* pSet, sal_Int32 nTableDepth = -1);
153 bool UseFrameBorders(sal_Int32 nTableDepth);
154 void SetUseFrameBorders(bool bSet) { m_bUseFrameBorders = bSet; }
155 bool UseFrameBackground();
156 void SetUseFrameBackground(bool bSet) { m_bUseFrameBackground = bSet; }
157 bool UseFrameTextDirection(sal_Int32 nTableDepth);
158 void SetUseFrameTextDirection(bool bSet) { m_bUseFrameTextDirection = bSet; }
161 class SdtBlockHelper
163 public:
164 SdtBlockHelper()
165 : m_nId(0)
166 , m_bStartedSdt(false)
167 , m_bShowingPlaceHolder(false)
168 , m_nTabIndex(0)
169 , m_nSdtPrToken(0)
172 sal_Int32 m_nId;
173 bool m_bStartedSdt;
174 rtl::Reference<sax_fastparser::FastAttributeList> m_pTokenChildren;
175 rtl::Reference<sax_fastparser::FastAttributeList> m_pTokenAttributes;
176 rtl::Reference<sax_fastparser::FastAttributeList> m_pTextAttrs;
177 rtl::Reference<sax_fastparser::FastAttributeList> m_pDataBindingAttrs;
178 OUString m_aColor;
179 OUString m_aAppearance;
180 OUString m_aPlaceHolderDocPart;
181 bool m_bShowingPlaceHolder;
182 OUString m_aAlias;
183 OUString m_aTag;
184 sal_Int32 m_nTabIndex;
185 OUString m_aLock;
186 sal_Int32 m_nSdtPrToken;
188 void DeleteAndResetTheLists();
190 void WriteSdtBlock(const ::sax_fastparser::FSHelperPtr& pSerializer, bool bRunTextIsOn, bool bParagraphHasDrawing);
191 void WriteExtraParams(const ::sax_fastparser::FSHelperPtr& pSerializer);
193 /// Closes a currently open SDT block.
194 void EndSdtBlock(const ::sax_fastparser::FSHelperPtr& pSerializer);
196 void GetSdtParamsFromGrabBag(const uno::Sequence<beans::PropertyValue>& aGrabBagSdt);
199 /// The class that has handlers for various resource types when exporting as DOCX.
200 class DocxAttributeOutput : public AttributeOutputBase, public oox::vml::VMLTextExport, public oox::drawingml::DMLTextExport
202 public:
203 /// Export the state of RTL/CJK.
204 virtual void RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript ) override;
206 /// Start of the paragraph.
207 virtual sal_Int32 StartParagraph(ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo,
208 bool bGenerateParaId) override;
210 /// End of the paragraph.
211 virtual void EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) override;
213 /// Empty paragraph.
214 virtual void EmptyParagraph() override;
216 /// Called in order to output section breaks.
217 virtual void SectionBreaks(const SwNode& rNode) override;
219 /// Called before we start outputting the attributes.
220 virtual void StartParagraphProperties() override;
222 /// Called after we end outputting the attributes.
223 virtual void EndParagraphProperties(const SfxItemSet& rParagraphMarkerProperties, const SwRedlineData* pRedlineData, const SwRedlineData* pRedlineParagraphMarkerDeleted, const SwRedlineData* pRedlineParagraphMarkerInserted) override;
225 /// Start of the text run.
226 virtual void StartRun( const SwRedlineData* pRedlineData, sal_Int32 nPos, bool bSingleEmptyRun = false ) override;
228 /// End of the text run.
229 virtual void EndRun(const SwTextNode* pNode, sal_Int32 nPos, sal_Int32 nLen, bool bLastRun = false) override;
231 /// Called before we start outputting the attributes.
232 virtual void StartRunProperties() override;
234 /// Called after we end outputting the attributes.
235 virtual void EndRunProperties( const SwRedlineData* pRedlineData ) override;
237 virtual bool FootnoteEndnoteRefTag() override;
239 virtual void SectFootnoteEndnotePr() override;
241 virtual void WritePostitFieldReference() override;
243 /// Output text (inside a run).
244 virtual void RunText( const OUString& rText, rtl_TextEncoding eCharSet = RTL_TEXTENCODING_UTF8, const OUString& rSymbolFont = OUString() ) override;
246 /// Output text (without markup).
247 virtual void RawText(const OUString& rText, rtl_TextEncoding eCharSet) override;
249 /// Output ruby start.
250 virtual void StartRuby( const SwTextNode& rNode, sal_Int32 nPos, const SwFormatRuby& rRuby ) override;
252 /// Output ruby end.
253 virtual void EndRuby(const SwTextNode& rNode, sal_Int32 nPos) override;
255 /// Output URL start.
256 virtual bool StartURL( const OUString& rUrl, const OUString& rTarget ) override;
258 /// Output URL end.
259 virtual bool EndURL(bool) override;
261 virtual void FieldVanish(const OUString& rText, ww::eField eType, OUString const*) override;
263 /// Output redlining.
265 /// The common attribute that can be among the run properties.
266 virtual void Redline( const SwRedlineData* pRedline ) override;
268 /// Output redlining.
270 /// Start of the tag that encloses the run, fills the info according to
271 /// the value of pRedlineData.
272 void StartRedline( const SwRedlineData * pRedlineData, bool bLastRun );
274 /// Output redlining.
276 /// End of the tag that encloses the run.
277 void EndRedline( const SwRedlineData * pRedlineData, bool bLastRun );
279 virtual void SetStateOfFlyFrame( FlyProcessingState nStateOfFlyFrame ) override;
280 virtual void SetAnchorIsLinkedToNode( bool bAnchorLinkedToNode ) override;
281 virtual bool IsFlyProcessingPostponed() override;
282 virtual void ResetFlyProcessingFlag() override;
284 virtual void FormatDrop( const SwTextNode& rNode, const SwFormatDrop& rSwFormatDrop, sal_uInt16 nStyle, ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo, ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) override;
286 /// Output style.
287 virtual void ParagraphStyle( sal_uInt16 nStyle ) override;
289 virtual void TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
290 virtual void TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
291 virtual void TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
292 virtual void TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
293 void TableDefaultCellMargins( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner );
294 virtual void TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
295 virtual void TableRowRedline( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
296 virtual void TableCellRedline( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
297 virtual void TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
298 virtual void TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
299 virtual void TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
300 virtual void TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
301 virtual void TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner ) override;
302 virtual void TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
303 virtual void TableSpacing( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
304 virtual void TableRowEnd( sal_uInt32 nDepth ) override;
306 /// Start of the styles table.
307 virtual void StartStyles() override;
309 /// End of the styles table.
310 virtual void EndStyles( sal_uInt16 nNumberOfStyles ) override;
312 /// Write default style.
313 virtual void DefaultStyle() override;
315 /// Write Doc Defaults
316 void DocDefaults( );
318 /// Write latent styles.
319 void LatentStyles();
321 /** Similar to OutputItem(), but write something only if it is not the default.
323 This is to output the docDefaults, and we should write something out
324 only in case it is not what MSO already uses for the document by default.
326 void OutputDefaultItem(const SfxPoolItem& rHt);
328 /// Start of a style in the styles table.
329 virtual void StartStyle( const OUString& rName, StyleType eType,
330 sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 nLink, sal_uInt16 nWwId, sal_uInt16 nSlot,
331 bool bAutoUpdate ) override;
333 /// End of a style in the styles table.
334 virtual void EndStyle() override;
336 /// Start of (paragraph or run) properties of a style.
337 virtual void StartStyleProperties( bool bParProp, sal_uInt16 nStyle ) override;
339 /// End of (paragraph or run) properties of a style.
340 virtual void EndStyleProperties( bool bParProp ) override;
342 /// Numbering rule and Id.
343 virtual void OutlineNumbering(sal_uInt8 nLvl) override;
345 /// Page break
346 /// As a paragraph property - the paragraph should be on the next page.
347 virtual void PageBreakBefore( bool bBreak ) override;
349 /// Write a section break
350 /// msword::ColumnBreak or msword::PageBreak
351 /// bBreakAfter: the break must be scheduled for insertion in the end of current paragraph
352 virtual void SectionBreak( sal_uInt8 nC, bool bBreakAfter, const WW8_SepInfo* pSectionInfo = nullptr, bool bExtraPageBreak = false ) override;
354 // preserve DOCX page vertical alignment
355 virtual void TextVerticalAdjustment( const css::drawing::TextVerticalAdjust ) override;
357 /// Start of the section properties.
358 virtual void StartSection() override;
360 /// End of the section properties.
361 virtual void EndSection() override;
363 /// Protection of forms.
364 virtual void SectionFormProtection( bool bProtected ) override;
366 /// Numbering of the lines in the document.
367 virtual void SectionLineNumbering( sal_uLong nRestartNo, const SwLineNumberInfo& rLnNumInfo ) override;
369 /// Has different headers/footers for the title page.
370 virtual void SectionTitlePage() override;
372 /// Description of the page borders.
373 virtual void SectionPageBorders( const SwFrameFormat* pFormat, const SwFrameFormat* pFirstPageFormat ) override;
375 /// Columns populated from right/numbers on the right side?
376 virtual void SectionBiDi( bool bBiDi ) override;
378 /// The style of the page numbers.
380 virtual void SectionPageNumbering( sal_uInt16 nNumType, const ::std::optional<sal_uInt16>& oPageRestartNumber ) override;
382 /// The type of breaking.
383 virtual void SectionType( sal_uInt8 nBreakCode ) override;
385 /// Start the font.
386 void StartFont( const OUString& rFamilyName ) const;
388 /// End the font.
389 void EndFont() const;
391 /// Alternate name for the font.
392 void FontAlternateName( const OUString& rName ) const;
394 /// Font charset.
395 void FontCharset( sal_uInt8 nCharSet, rtl_TextEncoding nEncoding ) const;
397 /// Font family.
398 void FontFamilyType( FontFamily eFamily ) const;
400 /// Font pitch.
401 void FontPitchType( FontPitch ePitch ) const;
403 /// Write out the font into the document, if it's an embedded font.
404 void EmbedFont( std::u16string_view name, FontFamily family, FontPitch pitch );
406 /// Definition of a numbering instance.
407 virtual void NumberingDefinition( sal_uInt16 nId, const SwNumRule &rRule ) override;
409 /// Numbering definition that overrides abstract numbering definition
410 virtual void OverrideNumberingDefinition( SwNumRule const& rRule,
411 sal_uInt16 nNum, sal_uInt16 nAbstractNum,
412 const std::map< size_t, size_t > & rLevelOverrides ) override;
414 /// Start of the abstract numbering definition instance.
415 virtual void StartAbstractNumbering( sal_uInt16 nId ) override;
417 /// End of the abstract numbering definition instance.
418 virtual void EndAbstractNumbering() override;
420 /// All the numbering level information.
421 virtual void NumberingLevel( sal_uInt8 nLevel,
422 sal_uInt16 nStart,
423 sal_uInt16 nNumberingType,
424 SvxAdjust eAdjust,
425 const sal_uInt8 *pNumLvlPos,
426 sal_uInt8 nFollow,
427 const wwFont *pFont,
428 const SfxItemSet *pOutSet,
429 sal_Int16 nIndentAt,
430 sal_Int16 nFirstLineIndex,
431 sal_Int16 nListTabPos,
432 const OUString &rNumberingString,
433 const SvxBrushItem* pBrush ) override;
435 void WriteField_Impl(const SwField* pField, ww::eField eType,
436 const OUString& rFieldCmd, FieldFlags nMode,
437 OUString const* pBookmarkName = nullptr);
438 void WriteFormData_Impl( const ::sw::mark::IFieldmark& rFieldmark );
440 void WriteBookmarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds, const SwRedlineData* pRedlineData = nullptr );
441 void WriteFinalBookmarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds );
442 void WriteAnnotationMarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds );
443 /// End possibly opened paragraph sdt block.
444 void EndParaSdtBlock();
446 void WriteFloatingTable(ww8::Frame const* pParentFrame);
448 private:
449 /// Initialize the structures where we are going to collect some of the paragraph properties.
451 /// Some of the properties have to be collected from more sources, and are
452 /// actually not written between StartParagraphProperties and
453 /// EndParagraphProperties. They are output in this method, which is
454 /// supposed to be called just before outputting </rPr> whenever it is done.
455 void InitCollectedParagraphProperties();
457 /// Output what we collected during the run properties output.
459 /// @see WriteCollectedParagrapProperties().
460 void WriteCollectedParagraphProperties();
462 /// Initialize the structures where we are going to collect some of the run properties.
464 /// This is an equivalent of InitCollectedParagraphProperties(), resp.
465 /// WriteCollectectedParagraphProperties().
467 /// @see InitCollectedParagraphProperties().
468 void InitCollectedRunProperties();
470 /// Output what we collected during the run properties output.
472 /// @see InitCollectedRunproperties(), WriteCollectedParagraphProperties()
473 void WriteCollectedRunProperties();
475 /// Output graphic fly frames or replacement graphics for OLE nodes.
477 /// For graphic frames, just use the first two parameters, for OLE
478 /// replacement graphics, set the first as 0, and pass the remaining three.
480 /// @see WriteOLE2Obj()
481 void FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size& rSize, const SwFlyFrameFormat* pOLEFrameFormat, SwOLENode* pOLENode, const SdrObject* pSdrObj = nullptr);
482 void WriteSrcRect(const css::uno::Reference<css::beans::XPropertySet>& xShapePropSet,
483 const SwFrameFormat* pFrameFormat);
484 void WriteOLE2Obj( const SdrObject* pSdrObj, SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat, const sal_Int8 nFormulaAlignment);
485 bool WriteOLEChart( const SdrObject* pSdrObj, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat);
486 bool WriteOLEMath( const SwOLENode& rNode, const sal_Int8 nAlign );
487 void PostponeOLE( SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat );
488 void WriteOLE( SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* rFlyFrameFormat );
489 void WriteOLEShape(const SwFlyFrameFormat& rFrameFormat, const Size& rSize,
490 std::string_view rShapeId, const OUString& rImageId);
491 static OString GetOLEStyle(const SwFlyFrameFormat& rFormat, const Size& rSize);
492 void ExportOLESurround(const SwFormatSurround& rWrap);
494 void WriteActiveXControl(const SdrObject* pObject, const SwFrameFormat& rFrameFormat, bool bInsideRun);
495 bool ExportAsActiveXControl(const SdrObject* pObject) const;
497 void InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner );
498 void StartTable( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner );
499 void StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner );
500 void StartTableCell( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner, sal_uInt32 nCell, sal_uInt32 nRow );
501 void TableCellProperties( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner, sal_uInt32 nCell, sal_uInt32 nRow );
502 void EndTableCell( sal_uInt32 nCell );
503 void EndTableRow( );
504 void EndTable();
505 void SyncNodelessCells(ww8::WW8TableNodeInfoInner::Pointer_t const & pInner, sal_Int32 nCell, sal_uInt32 nRow);
506 void PopulateFrameProperties(const SwFrameFormat* pFrameFormat, const Size& rSize);
507 static bool TextBoxIsFramePr(const SwFrameFormat& rFrameFormat);
508 /// End cell, row, and even the entire table if necessary.
509 void FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t const & pInner, bool bForceEmptyParagraph = false );
511 void WriteFFData( const FieldInfos& rInfos );
512 void WritePendingPlaceholder();
514 void EmbedFontStyle( std::u16string_view name, int tag, FontFamily family, FontItalic italic, FontWeight weight,
515 FontPitch pitch );
518 * Translate an ico value to the corresponding HighlightColorValues enumaration item
520 * @param[in] nIco ico value [0..16]
521 * @return color name (e.g. "red"), if color is inside [1..16] range
522 * empty string, otherwise
524 static OString TransHighlightColor( sal_uInt8 nIco );
525 protected:
527 /// Output frames - the implementation.
528 virtual void OutputFlyFrame_Impl( const ww8::Frame& rFormat, const Point& rNdTopLeft ) override;
530 /// Sfx item Sfx item RES_CHRATR_CASEMAP
531 virtual void CharCaseMap( const SvxCaseMapItem& rCaseMap ) override;
533 /// Sfx item Sfx item RES_CHRATR_COLOR
534 virtual void CharColor( const SvxColorItem& rColor) override;
536 /// Sfx item Sfx item RES_CHRATR_CONTOUR
537 virtual void CharContour( const SvxContourItem& rContour ) override;
539 /// Sfx item RES_CHRATR_CROSSEDOUT
540 virtual void CharCrossedOut( const SvxCrossedOutItem& rCrossedOut ) override;
542 /// Sfx item RES_CHRATR_ESCAPEMENT
543 virtual void CharEscapement( const SvxEscapementItem& rEscapement ) override;
545 /// Sfx item RES_CHRATR_FONT
546 virtual void CharFont( const SvxFontItem& rFont ) override;
548 /// Sfx item RES_CHRATR_FONTSIZE
549 virtual void CharFontSize( const SvxFontHeightItem& rFontSize ) override;
551 /// Sfx item RES_CHRATR_KERNING
552 virtual void CharKerning( const SvxKerningItem& rKerning ) override;
554 /// Sfx item RES_CHRATR_LANGUAGE
555 virtual void CharLanguage( const SvxLanguageItem& rLanguage ) override;
557 /// Sfx item RES_CHRATR_POSTURE
558 virtual void CharPosture( const SvxPostureItem& rPosture ) override;
560 /// Sfx item RES_CHRATR_SHADOWED
561 virtual void CharShadow( const SvxShadowedItem& rShadow ) override;
563 /// Sfx item RES_CHRATR_UNDERLINE
564 virtual void CharUnderline( const SvxUnderlineItem& rUnderline ) override;
566 /// Sfx item RES_CHRATR_WEIGHT
567 virtual void CharWeight( const SvxWeightItem& rWeight ) override;
569 /// Sfx item RES_CHRATR_AUTOKERN
570 virtual void CharAutoKern( const SvxAutoKernItem& ) override;
572 /// Sfx item RES_CHRATR_BLINK
573 virtual void CharAnimatedText( const SvxBlinkItem& rBlink ) override;
575 /// Sfx item RES_CHRATR_BACKGROUND
576 virtual void CharBackground( const SvxBrushItem& rBrush ) override;
578 /// Sfx item RES_CHRATR_CJK_FONT
579 virtual void CharFontCJK( const SvxFontItem& rFont ) override;
581 /// Sfx item RES_CHRATR_CJK_FONTSIZE
582 virtual void CharFontSizeCJK( const SvxFontHeightItem& rFontSize ) override { CharFontSize( rFontSize ); }
584 /// Sfx item RES_CHRATR_CJK_LANGUAGE
585 virtual void CharLanguageCJK( const SvxLanguageItem& rLanguageItem ) override { CharLanguage( rLanguageItem ); }
587 /// Sfx item RES_CHRATR_CJK_POSTURE
588 virtual void CharPostureCJK( const SvxPostureItem& rPosture ) override;
590 /// Sfx item RES_CHRATR_CJK_WEIGHT
591 virtual void CharWeightCJK( const SvxWeightItem& rWeight ) override;
593 /// Sfx item RES_CHRATR_CTL_FONT
594 virtual void CharFontCTL( const SvxFontItem& rFont ) override;
596 /// Sfx item RES_CHRATR_CTL_FONTSIZE
597 virtual void CharFontSizeCTL( const SvxFontHeightItem& rFontSize ) override { CharFontSize( rFontSize ); }
599 /// Sfx item RES_CHRATR_CTL_LANGUAGE
600 virtual void CharLanguageCTL( const SvxLanguageItem& rLanguageItem ) override { CharLanguage( rLanguageItem); }
602 /// Sfx item RES_CHRATR_CTL_POSTURE
603 virtual void CharPostureCTL( const SvxPostureItem& rWeight ) override;
605 /// Sfx item RES_CHRATR_CTL_WEIGHT
606 virtual void CharWeightCTL( const SvxWeightItem& rWeight ) override;
608 /// Sfx item RES_CHRATR_BidiRTL
609 virtual void CharBidiRTL( const SfxPoolItem& ) override;
611 /// Sfx item RES_CHRATR_IdctHint
612 virtual void CharIdctHint( const SfxPoolItem& ) override;
614 /// Sfx item RES_CHRATR_ROTATE
615 virtual void CharRotate( const SvxCharRotateItem& rRotate ) override;
617 /// Sfx item RES_CHRATR_EMPHASIS_MARK
618 virtual void CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark ) override;
620 /// Sfx item RES_CHRATR_TWO_LINES
621 virtual void CharTwoLines( const SvxTwoLinesItem& rTwoLines ) override;
623 /// Sfx item RES_CHRATR_SCALEW
624 virtual void CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth ) override;
626 /// Sfx item RES_CHRATR_RELIEF
627 virtual void CharRelief( const SvxCharReliefItem& rRelief) override;
629 /// Sfx item RES_CHRATR_HIDDEN
630 virtual void CharHidden( const SvxCharHiddenItem& rHidden ) override;
632 /// Sfx item RES_CHRATR_BOX
633 virtual void CharBorder( const ::editeng::SvxBorderLine* pAllBorder, const sal_uInt16 nDist, const bool bShadow ) override;
635 /// Sfx item RES_CHRATR_HIGHLIGHT
636 virtual void CharHighlight( const SvxBrushItem& rHighlight ) override;
638 /// Sfx item RES_TXTATR_INETFMT
639 virtual void TextINetFormat( const SwFormatINetFormat& ) override;
641 /// Sfx item RES_TXTATR_CHARFMT
642 virtual void TextCharFormat( const SwFormatCharFormat& ) override;
644 /// Sfx item RES_TXTATR_FTN
645 virtual void TextFootnote_Impl( const SwFormatFootnote& ) override;
647 /// Output the footnote/endnote reference (if there's one to output).
648 void FootnoteEndnoteReference();
650 /// Sfx item RES_PARATR_LINESPACING
651 virtual void ParaLineSpacing_Impl( short nSpace, short nMulti ) override;
653 /// Sfx item RES_PARATR_ADJUST
654 virtual void ParaAdjust( const SvxAdjustItem& rAdjust ) override;
656 /// Sfx item RES_PARATR_SPLIT
657 virtual void ParaSplit( const SvxFormatSplitItem& rSplit ) override;
659 /// Sfx item RES_PARATR_WIDOWS
660 virtual void ParaWidows( const SvxWidowsItem& rWidows ) override;
662 /// Sfx item RES_PARATR_TABSTOP
663 virtual void ParaTabStop( const SvxTabStopItem& rTabStop ) override;
665 /// Sfx item RES_PARATR_HYPHENZONE
666 virtual void ParaHyphenZone( const SvxHyphenZoneItem& ) override;
668 /// Sfx item RES_PARATR_NUMRULE
669 virtual void ParaNumRule_Impl( const SwTextNode *pTextNd, sal_Int32 nLvl, sal_Int32 nNumId ) override;
671 /// Sfx item RES_PARATR_SCRIPTSPACE
672 virtual void ParaScriptSpace( const SfxBoolItem& ) override;
674 /// Sfx item RES_PARATR_HANGINGPUNCTUATION
675 virtual void ParaHangingPunctuation( const SfxBoolItem& ) override;
677 /// Sfx item RES_PARATR_FORBIDDEN_RULES
678 virtual void ParaForbiddenRules( const SfxBoolItem& ) override;
680 /// Sfx item RES_PARATR_VERTALIGN
681 virtual void ParaVerticalAlign( const SvxParaVertAlignItem& rAlign ) override;
683 /// Sfx item RES_PARATR_SNAPTOGRID
684 virtual void ParaSnapToGrid( const SvxParaGridItem& ) override;
686 /// Sfx item RES_FRM_SIZE
687 virtual void FormatFrameSize( const SwFormatFrameSize& ) override;
689 /// Sfx item RES_PAPER_BIN
690 virtual void FormatPaperBin( const SvxPaperBinItem& ) override;
692 /// Sfx item RES_MARGIN_FIRSTLINE
693 virtual void FormatFirstLineIndent(const SvxFirstLineIndentItem & rFirstLine) override;
694 /// Sfx item RES_MARGIN_TEXTLEFT
695 virtual void FormatTextLeftMargin(const SvxTextLeftMarginItem & rTextLeftMargin) override;
696 /// Sfx item RES_MARGIN_RIGHT
697 virtual void FormatRightMargin(const SvxRightMarginItem & rRightMargin) override;
699 /// Sfx item RES_LR_SPACE
700 virtual void FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) override;
702 /// Sfx item RES_UL_SPACE
703 virtual void FormatULSpace( const SvxULSpaceItem& rULSpace ) override;
705 /// Sfx item RES_SURROUND
706 virtual void FormatSurround( const SwFormatSurround& ) override;
708 /// Sfx item RES_VERT_ORIENT
709 virtual void FormatVertOrientation( const SwFormatVertOrient& ) override;
711 /// Sfx item RES_HORI_ORIENT
712 virtual void FormatHorizOrientation( const SwFormatHoriOrient& ) override;
714 /// Sfx item RES_ANCHOR
715 virtual void FormatAnchor( const SwFormatAnchor& ) override;
717 /// Sfx item RES_BACKGROUND
718 virtual void FormatBackground( const SvxBrushItem& ) override;
720 /// Sfx item RES_FILL_STYLE
721 virtual void FormatFillStyle( const XFillStyleItem& ) override;
723 /// Sfx item RES_FILL_GRADIENT
724 virtual void FormatFillGradient( const XFillGradientItem& ) override;
726 /// Sfx item RES_BOX
727 virtual void FormatBox( const SvxBoxItem& ) override;
729 /// Sfx item RES_COL
730 virtual void FormatColumns_Impl( sal_uInt16 nCols, const SwFormatCol & rCol, bool bEven, SwTwips nPageSize ) override;
732 /// Sfx item RES_KEEP
733 virtual void FormatKeep( const SvxFormatKeepItem& ) override;
735 /// Sfx item RES_TEXTGRID
736 virtual void FormatTextGrid( const SwTextGridItem& ) override;
738 /// Sfx item RES_LINENUMBER
739 virtual void FormatLineNumbering( const SwFormatLineNumber& ) override;
741 /// Sfx item RES_FRAMEDIR
742 virtual void FormatFrameDirection( const SvxFrameDirectionItem& ) override;
744 /// Sfx item RES_PARATR_GRABBAG
745 virtual void ParaGrabBag( const SfxGrabBagItem& ) override;
747 /// Sfx item RES_CHRATR_GRABBAG
748 virtual void CharGrabBag( const SfxGrabBagItem& ) override;
750 // Sfx item RES_PARATR_OUTLINELEVEL
751 virtual void ParaOutlineLevel( const SfxUInt16Item& ) override;
753 /// Write the expanded field
754 virtual void WriteExpand( const SwField* pField ) override;
756 virtual void RefField( const SwField& rField, const OUString& rRef ) override;
757 virtual void HiddenField( const SwField& rField ) override;
758 virtual void SetField( const SwField& rField, ww::eField eType, const OUString& rCmd ) override;
759 virtual void PostitField( const SwField* pField ) override;
760 virtual bool DropdownField( const SwField* pField ) override;
761 virtual bool PlaceholderField( const SwField* pField ) override;
763 virtual bool AnalyzeURL( const OUString& rURL, const OUString& rTarget, OUString* pLinkURL, OUString* pMark ) override;
765 virtual void WriteBookmarkInActParagraph( const OUString& rName, sal_Int32 nFirstRunPos, sal_Int32 nLastRunPos ) override;
767 void SectionRtlGutter( const SfxBoolItem& rRtlGutter) override;
769 void TextLineBreak(const SwFormatLineBreak& rLineBreak) override;
771 /// Writes a clearing line break at the end of run properties, if there are any.
772 void WriteLineBreak();
774 private:
776 void DoWriteBookmarkTagStart(const OUString& bookmarkName);
777 void DoWriteBookmarkTagEnd(sal_Int32 nId);
778 void DoWriteMoveRangeTagStart(std::u16string_view bookmarkName,
779 bool bFrom, const SwRedlineData* pRedlineData);
780 void DoWriteMoveRangeTagEnd(sal_Int32 nId, bool bFrom);
781 void DoWriteBookmarksStart(std::vector<OUString>& rStarts, const SwRedlineData* pRedlineData = nullptr);
782 void DoWriteBookmarksEnd(std::vector<OUString>& rEnds);
783 void DoWriteBookmarkStartIfExist(sal_Int32 nRunPos);
784 void DoWriteBookmarkEndIfExist(sal_Int32 nRunPos);
786 void DoWritePermissionTagStart(std::u16string_view permission);
787 void DoWritePermissionTagEnd(std::u16string_view permission);
788 void DoWritePermissionsStart();
789 void DoWritePermissionsEnd();
791 void DoWriteAnnotationMarks( );
792 void WritePostponedGraphic();
793 void WritePostponedMath(const SwOLENode* pObject, sal_Int8 /*nAlign*/);
794 void WritePostponedFormControl(const SdrObject* pObject);
795 void WritePostponedActiveXControl(bool bInsideRun);
796 void WritePostponedDiagram();
797 void WritePostponedChart();
798 void WritePostponedOLE();
799 void WritePostponedDMLDrawing();
800 void WritePostponedCustomShape();
801 void WriteFlyFrame(const ww8::Frame& rFrame);
803 void WriteFormDateStart(const OUString& sFullDate, const OUString& sDateFormat, const OUString& sLang, const uno::Sequence<beans::PropertyValue>& aGrabBagSdt);
804 void WriteSdtPlainText(const OUString& sValue, const uno::Sequence<beans::PropertyValue>& aGrabBagSdt);
805 void WriteSdtDropDownStart(const OUString& rName, OUString const& rSelected, uno::Sequence<OUString> const& rListItems);
806 void WriteSdtDropDownEnd(OUString const& rSelected, uno::Sequence<OUString> const& rListItems);
807 void WriteContentControlStart();
808 void WriteContentControlEnd();
810 void StartField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun = false );
811 void DoWriteCmd( std::u16string_view rCmd );
812 void CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun );
813 void CmdEndField_Impl( const SwTextNode* pNode, sal_Int32 nPos, bool bWriteRun );
814 void EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos& rInfos );
815 void DoWriteFieldRunProperties( const SwTextNode* pNode, sal_Int32 nPos, bool bWriteCombChars = false );
817 /// Reference to the export, where to get the data from
818 DocxExport &m_rExport;
820 /// Fast serializer to output the data
821 ::sax_fastparser::FSHelperPtr m_pSerializer;
823 /// DrawingML access
824 oox::drawingml::DrawingML &m_rDrawingML;
826 rtl::Reference<sax_fastparser::FastAttributeList> m_pFontsAttrList;
827 rtl::Reference<sax_fastparser::FastAttributeList> m_pEastAsianLayoutAttrList;
828 rtl::Reference<sax_fastparser::FastAttributeList> m_pCharLangAttrList;
829 rtl::Reference<sax_fastparser::FastAttributeList> m_pSectionSpacingAttrList;
830 rtl::Reference<sax_fastparser::FastAttributeList> m_pLRSpaceAttrList;
831 rtl::Reference<sax_fastparser::FastAttributeList> m_pParagraphSpacingAttrList;
832 rtl::Reference<sax_fastparser::FastAttributeList> m_pHyperlinkAttrList;
833 std::shared_ptr<SwContentControl> m_pContentControl;
834 /// If the current SDT around runs should be ended before the current run.
835 bool m_bEndCharSdt;
836 /// Attributes of the run color
837 rtl::Reference<sax_fastparser::FastAttributeList> m_pColorAttrList;
838 sal_uInt8 m_nCharTransparence = 0;
839 /// Attributes of the paragraph background
840 rtl::Reference<sax_fastparser::FastAttributeList> m_pBackgroundAttrList;
841 OUString m_sOriginalBackgroundColor;
842 OUString m_hyperLinkAnchor;
843 bool m_endPageRef;
844 std::unique_ptr<docx::FootnotesList> m_pFootnotesList;
845 std::unique_ptr<docx::FootnotesList> m_pEndnotesList;
846 int m_footnoteEndnoteRefTag;
847 OUString m_footnoteCustomLabel;
848 std::unique_ptr< const WW8_SepInfo > m_pSectionInfo;
850 /// Redline data to remember in the text run.
851 const SwRedlineData *m_pRedlineData;
853 /// Id of the redline
854 sal_Int32 m_nRedlineId;
856 /// Flag indicating that the section properties are being written
857 bool m_bOpenedSectPr;
858 /// Did we have a section break in this paragraph? Set by StartSection(), reset by the next StartParagraph().
859 bool m_bHadSectPr;
861 /// Flag indicating that the Run Text is being written
862 bool m_bRunTextIsOn;
864 /// Flag indicating that the header \ footer are being written
865 bool m_bWritingHeaderFooter;
866 bool m_bAnchorLinkedToNode;
868 /// Flag indicating that multiple runs of a field are being written
869 bool m_bWritingField;
871 /// Field data to remember in the text run
872 bool m_bPreventDoubleFieldsHandling;
873 std::vector< FieldInfos > m_Fields;
874 OUString m_sFieldBkm;
875 sal_Int32 m_nNextBookmarkId;
876 sal_Int32 m_nNextAnnotationMarkId;
878 /// [MS-DOCX] section 2.6.2.3
879 sal_Int32 m_nNextParaId = 1; // MUST be greater than 0
881 OUString m_sRawText;
883 /// The first frame (anchored to the main text) is 0.
884 /// The second frame what is anchored to the previous in, is 1
885 /// The third anchored inside the second is the 2 etc.
886 sal_uInt32 m_nEmbedFlyLevel;
888 /// Stores the flys what are anchored inside a fly
889 std::vector<ww8::Frame> m_vPostponedFlys;
891 /// Bookmarks to output
892 std::vector<OUString> m_rBookmarksStart;
893 std::vector<OUString> m_rBookmarksEnd;
894 SwRedlineData* m_pMoveRedlineData;
896 /// Bookmarks to output at the end
897 std::vector<OUString> m_rFinalBookmarksStart;
898 std::vector<OUString> m_rFinalBookmarksEnd;
900 /// Bookmarks of the current paragraph
901 std::multimap<sal_Int32, OUString> m_aBookmarksOfParagraphStart;
902 std::multimap<sal_Int32, OUString> m_aBookmarksOfParagraphEnd;
904 /// Permissions to output
905 std::vector<OUString> m_rPermissionsStart;
906 std::vector<OUString> m_rPermissionsEnd;
908 /// Annotation marks to output
909 std::vector<OUString> m_rAnnotationMarksStart;
910 std::vector<OUString> m_rAnnotationMarksEnd;
912 /// Maps of the bookmarks ids
913 std::map<OUString, sal_Int32> m_rOpenedBookmarksIds;
915 /// Name of the last opened bookmark.
916 OUString m_sLastOpenedBookmark;
918 /// Set of ids of the saved bookmarks (used only for moveRange, yet)
919 std::unordered_set<sal_Int32> m_rSavedBookmarksIds;
921 /// Maps of the annotation marks ids
922 std::map<OUString, sal_Int32> m_rOpenedAnnotationMarksIds;
924 /// Name of the last opened annotation mark.
925 OUString m_sLastOpenedAnnotationMark;
927 /// If there are bookmarks around sequence fields, this map contains the
928 /// names of these bookmarks for each sequence.
929 std::map<OUString, std::vector<OUString> > m_aSeqBookmarksNames;
931 /// GrabBag for text effects like glow, shadow, ...
932 std::vector<css::beans::PropertyValue> m_aTextEffectsGrabBag;
934 /// The current table helper
935 std::unique_ptr<SwWriteTable> m_xTableWrt;
937 FramePrHelper m_aFramePr;
939 bool m_bParagraphOpened;
940 bool m_bParagraphFrameOpen;
941 bool m_bIsFirstParagraph;
942 bool m_bAlternateContentChoiceOpen;
943 bool m_bPostponedProcessingFly;
945 // Remember that a column break has to be opened at the
946 // beginning of the next paragraph
947 DocxColBreakStatus m_nColBreakStatus;
949 // Remember that a page break has to be opened at the
950 // beginning of the next paragraph
951 bool m_bPostponedPageBreak;
953 // This paragraph must end with page break
954 bool m_bPageBreakAfter = false;
956 std::stack< std::vector<ww8::Frame> > m_aFramesOfParagraph;
957 o3tl::sorted_vector<const SwFrameFormat*> m_aFloatingTablesOfParagraph;
958 sal_Int32 m_nTextFrameLevel;
960 // close of hyperlink needed
961 bool m_closeHyperlinkInThisRun;
962 bool m_closeHyperlinkInPreviousRun;
963 // Count nested HyperLinks
964 std::vector<sal_Int32> m_nHyperLinkCount;
965 sal_Int16 m_nFieldsInHyperlink;
967 // If the exported numbering rule defines the outlines
968 bool m_bExportingOutline;
970 struct PostponedGraphic
972 PostponedGraphic( const SwGrfNode* n, Size s, const SdrObject* sObj )
973 : grfNode( n ), size( s ), pSdrObj(sObj) {};
975 const SwGrfNode* grfNode;
976 Size size;
977 const SdrObject* pSdrObj;
979 std::optional< std::vector<PostponedGraphic> > m_oPostponedGraphic;
980 struct PostponedDiagram
982 PostponedDiagram( const SdrObject* o, const SwFrameFormat* frm ) : object( o ), frame( frm ) {};
983 const SdrObject* object;
984 const SwFrameFormat* frame;
986 std::optional< std::vector<PostponedDiagram> > m_oPostponedDiagrams;
988 struct PostponedDrawing
990 PostponedDrawing( const SdrObject* sdrObj, const SwFrameFormat* frm) : object( sdrObj ), frame( frm ) {};
991 const SdrObject* object;
992 const SwFrameFormat* frame;
994 std::optional< std::vector<PostponedDrawing> > m_oPostponedDMLDrawings;
995 std::optional< std::vector<PostponedDrawing> > m_oPostponedCustomShape;
997 struct PostponedOLE
999 PostponedOLE( SwOLENode* rObject, const Size& rSize, const SwFlyFrameFormat* rFrame ) : object( rObject ), size( rSize ), frame( rFrame ) {};
1000 SwOLENode* object;
1001 const Size size;
1002 const SwFlyFrameFormat* frame;
1004 std::optional< std::vector<PostponedOLE> > m_oPostponedOLEs;
1006 struct PostponedMathObjects
1008 SwOLENode* pMathObject;
1009 sal_Int8 nMathObjAlignment;
1011 std::vector<PostponedMathObjects> m_aPostponedMaths;
1012 /// count charts consistently for unit tests
1013 unsigned int m_nChartCount;
1014 struct PostponedChart
1016 PostponedChart( const SdrObject* sdrObject, const Size& rSize, const SwFlyFrameFormat* rFrame ) : object(sdrObject), size(rSize), frame(rFrame) {};
1017 const SdrObject* object;
1018 const Size size;
1019 const SwFlyFrameFormat* frame;
1021 std::vector<PostponedChart> m_aPostponedCharts;
1022 std::vector<const SdrObject*> m_aPostponedFormControls;
1023 std::vector<PostponedDrawing> m_aPostponedActiveXControls;
1024 const SwField* m_PendingPlaceholder;
1026 /// Used to store the parent status of a PostIt (parent/child/neither)
1027 enum class ParentStatus
1029 None,
1030 IsParent,
1031 HasParent
1033 struct PostItDOCXData{
1034 sal_Int32 id;
1035 sal_Int32 lastParaId = 0; // [MS-DOCX] 2.5.3.1 CT_CommentEx needs paraId attribute
1036 ParentStatus parentStatus = ParentStatus::None;
1037 size_t parentIndex = 0;
1039 /// Maps postit fields to ID's, used in commentRangeStart/End, commentReference and comment.xml.
1040 std::vector<std::pair<const SwPostItField*, PostItDOCXData>> m_postitFields;
1041 /// Number of postit fields which already have a commentReference written.
1042 unsigned int m_postitFieldsMaxId;
1043 int m_anchorId;
1044 int m_nextFontId;
1045 struct EmbeddedFontRef
1047 OString relId;
1048 OString fontKey;
1051 TableReference m_tableReference;
1053 std::map< OUString, EmbeddedFontRef > m_FontFilesMap; // font file url to data
1055 // Remember first cell (used for default borders/margins) of each table
1056 std::vector<ww8::WW8TableNodeInfoInner::Pointer_t> m_TableFirstCells;
1057 // Remember last open and closed cells on each level
1058 std::vector<sal_Int32> m_LastOpenCell;
1059 std::vector<sal_Int32> m_LastClosedCell;
1061 std::optional<css::drawing::FillStyle> m_oFillStyle;
1062 /// If FormatBox() already handled fill style / gradient.
1063 bool m_bIgnoreNextFill;
1065 editeng::WordPageMargins m_pageMargins;
1067 std::shared_ptr<DocxTableStyleExport> m_pTableStyleExport;
1068 // flag to check if auto spacing was set in original file
1069 bool m_bParaBeforeAutoSpacing,m_bParaAfterAutoSpacing;
1070 // store hardcoded value which was set during import.
1071 sal_Int32 m_nParaBeforeSpacing,m_nParaAfterSpacing;
1073 SdtBlockHelper m_aParagraphSdt;
1074 SdtBlockHelper m_aRunSdt;
1076 /// State of the Fly at current position
1077 FlyProcessingState m_nStateOfFlyFrame;
1079 /// Same as m_aParagraphSdtPrAlias, but its content is available till the SDT is closed.
1080 OUString m_aStartedParagraphSdtPrAlias;
1082 std::vector<std::map<SvxBoxItemLine, css::table::BorderLine2>> m_aTableStyleConfs;
1084 std::optional<SwLineBreakClear> m_oLineBreakClear;
1086 public:
1087 DocxAttributeOutput( DocxExport &rExport, const ::sax_fastparser::FSHelperPtr& pSerializer, oox::drawingml::DrawingML* pDrawingML );
1089 virtual ~DocxAttributeOutput() override;
1091 /// Return the right export class.
1092 virtual DocxExport& GetExport() override;
1093 const DocxExport& GetExport() const { return const_cast< DocxAttributeOutput* >( this )->GetExport(); }
1095 /// For e.g. the output of the styles, we need to switch the serializer to another one.
1096 void SetSerializer( ::sax_fastparser::FSHelperPtr const & pSerializer );
1098 /// Occasionally need to use this serializer from the outside
1099 const ::sax_fastparser::FSHelperPtr& GetSerializer( ) const { return m_pSerializer; }
1101 /// Do we have any footnotes?
1102 bool HasFootnotes() const;
1104 /// Do we have any endnotes?
1105 bool HasEndnotes() const;
1107 /// Output the content of the footnotes.xml resp. endnotes.xml
1108 void FootnotesEndnotes( bool bFootnotes );
1110 /// writes the footnotePr/endnotePr (depending on tag) section
1111 static void WriteFootnoteEndnotePr( ::sax_fastparser::FSHelperPtr const & fs, int tag, const SwEndNoteInfo& info, int listtag );
1113 bool HasPostitFields() const;
1114 enum class hasProperties { no, yes };
1115 hasProperties WritePostitFields();
1116 void WritePostItFieldsResolved();
1118 /// VMLTextExport
1119 virtual void WriteOutliner(const OutlinerParaObject& rParaObj) override;
1120 virtual void WriteVMLTextBox(css::uno::Reference<css::drawing::XShape> xShape) override;
1121 /// DMLTextExport
1122 virtual void WriteTextBox(css::uno::Reference<css::drawing::XShape> xShape) override;
1123 virtual css::uno::Reference<css::text::XTextFrame> GetUnoTextFrame(
1124 css::uno::Reference<css::drawing::XShape> xShape) override;
1125 virtual oox::drawingml::DrawingML& GetDrawingML() override;
1126 virtual bool MaybeOutputBrushItem(SfxItemSet const&) override;
1128 void BulletDefinition(int nId, const Graphic& rGraphic, Size aSize) override;
1130 void SetWritingHeaderFooter( bool bWritingHeaderFooter ) { m_bWritingHeaderFooter = bWritingHeaderFooter; }
1131 bool GetWritingHeaderFooter( ) const { return m_bWritingHeaderFooter; }
1132 void SetAlternateContentChoiceOpen( bool bAltContentChoiceOpen ) { m_bAlternateContentChoiceOpen = bAltContentChoiceOpen; }
1133 bool IsAlternateContentChoiceOpen( ) const { return m_bAlternateContentChoiceOpen; }
1134 void GetSdtEndBefore(const SdrObject* pSdrObj);
1135 bool IsFirstParagraph() const { return m_bIsFirstParagraph; }
1137 /// Stores the table export state to the passed context and resets own state.
1138 void pushToTableExportContext(DocxTableExportContext& rContext);
1139 /// Restores from the remembered state.
1140 void popFromTableExportContext(DocxTableExportContext const & rContext);
1142 static OString convertToOOXMLHoriOrient(sal_Int16 nOrient, bool bIsPosToggle);
1143 static OString convertToOOXMLVertOrient(sal_Int16 nOrient);
1144 static OString convertToOOXMLVertOrientRel(sal_Int16 nOrientRel);
1145 static OString convertToOOXMLHoriOrientRel(sal_Int16 nOrientRel);
1146 static void ImplCellMargins( sax_fastparser::FSHelperPtr const & pSerializer, const SvxBoxItem& rBox, sal_Int32 tag, bool bUseStartEnd, const SvxBoxItem* pDefaultMargins = nullptr);
1147 template <class... Args>
1148 static void AddToAttrList(rtl::Reference<sax_fastparser::FastAttributeList>& pAttrList, Args&&... args)
1150 if (!pAttrList)
1151 pAttrList = sax_fastparser::FastSerializerHelper::createAttrList();
1152 pAttrList->add(std::forward<Args>(args)...);
1155 static const sal_Int32 Tag_StartParagraph_1 = 1;
1156 static const sal_Int32 Tag_StartParagraph_2 = 2;
1157 static const sal_Int32 Tag_WriteSdtBlock = 3;
1158 static const sal_Int32 Tag_StartParagraphProperties = 4;
1159 static const sal_Int32 Tag_InitCollectedParagraphProperties = 5;
1160 static const sal_Int32 Tag_StartRun_1 = 6;
1161 static const sal_Int32 Tag_StartRun_2 = 7;
1162 static const sal_Int32 Tag_StartRun_3 = 8;
1163 static const sal_Int32 Tag_EndRun_1 = 9;
1164 static const sal_Int32 Tag_EndRun_2 = 10;
1165 static const sal_Int32 Tag_StartRunProperties = 11;
1166 static const sal_Int32 Tag_InitCollectedRunProperties = 12;
1167 static const sal_Int32 Tag_Redline_1 = 13;
1168 static const sal_Int32 Tag_Redline_2 = 14;
1169 static const sal_Int32 Tag_TableDefinition = 15;
1170 static const sal_Int32 Tag_OutputFlyFrame = 16;
1171 static const sal_Int32 Tag_StartSection = 17;
1175 * All the information that should be stashed away when we're in the middle of
1176 * of a table export and still have to do something else, e.g. export a shape.
1178 struct DocxTableExportContext
1180 DocxAttributeOutput& m_rOutput;
1181 ww8::WW8TableInfo::Pointer_t m_pTableInfo;
1182 bool m_bTableCellOpen;
1183 bool m_bStartedParaSdt;
1184 bool m_bStartedRunSdt;
1185 sal_uInt32 m_nTableDepth;
1186 sal_Int32 m_nHyperLinkCount = 0;
1187 DocxTableExportContext(DocxAttributeOutput& rOutput) : m_rOutput(rOutput) { m_rOutput.pushToTableExportContext(*this); }
1188 ~DocxTableExportContext() { m_rOutput.popFromTableExportContext(*this); }
1191 namespace docx {
1193 rtl::Reference<sax_fastparser::FastAttributeList> SurroundToVMLWrap(SwFormatSurround const& rSurround);
1197 #endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXATTRIBUTEOUTPUT_HXX
1199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */