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 
20 #ifndef INCLUDED_SW_SOURCE_FILTER_WW8_DOCXATTRIBUTEOUTPUT_HXX
21 #define INCLUDED_SW_SOURCE_FILTER_WW8_DOCXATTRIBUTEOUTPUT_HXX
22 
23 #include <memory>
24 #include <string_view>
25 
26 #include "attributeoutputbase.hxx"
27 #include "fields.hxx"
28 #include <IMark.hxx>
29 #include "docxexport.hxx"
30 #include <wrtswtbl.hxx>
31 
32 #include <editeng/boxitem.hxx>
33 #include <sax/fshelper.hxx>
34 #include <sax/fastattribs.hxx>
35 #include <vcl/vclenum.hxx>
36 #include <svx/xenum.hxx>
37 
38 #include <fldbas.hxx>
39 
40 #include <vector>
41 #include <optional>
42 #include <o3tl/sorted_vector.hxx>
43 #include <oox/export/vmlexport.hxx>
44 #include <oox/export/drawingml.hxx>
45 #include "docxtablestyleexport.hxx"
46 
47 #include <com/sun/star/table/BorderLine2.hpp>
48 #include <com/sun/star/drawing/FillStyle.hpp>
49 
50 class SwGrfNode;
51 class SdrObject;
52 enum class SvxBoxItemLine;
53 
54 namespace docx { class FootnotesList; }
55 namespace oox::drawingml { class DrawingML; }
56 
57 struct FieldInfos
58 {
59     std::shared_ptr<const SwField> pField;
60     const ::sw::mark::IFieldmark* pFieldmark;
61     ww::eField  eType;
62     bool        bOpen;
63     bool        bSep;
64     bool        bClose;
65     OUString    sCmd;
FieldInfosFieldInfos66     FieldInfos()
67         : pFieldmark(nullptr), eType(ww::eUNKNOWN)
68         , bOpen(false), bSep(false), bClose(false)
69     {}
70 };
71 
72 enum DocxColBreakStatus
73 {
74     COLBRK_NONE,
75     COLBRK_POSTPONE,
76     COLBRK_WRITEANDPOSTPONE,
77     COLBRK_WRITE
78 };
79 
80 /**
81  * A structure that holds information about the options selected
82  * when outputting a border to DOCX.
83  *
84  * There are 3 functions that initialize this structure:
85  * - lcl_getTableDefaultBorderOptions - retrieves the options for when outputting table default borders
86  * - lcl_getTableCellBorderOptions    - retrieves the options for when outputting table cell borders
87  * - lcl_getBoxBorderOptions          - retrieves the options for when outputting box borders
88  *
89  */
90 struct OutputBorderOptions
91 {
92     sal_Int32           tag = 0;
93     bool                bUseStartEnd = false;
94     bool                bWriteTag = true;
95     bool                bWriteDistance = false;
96     SvxShadowLocation   aShadowLocation = SvxShadowLocation::NONE;
97     std::shared_ptr<editeng::WordBorderDistances> pDistances;
98 };
99 
100 struct DocxTableExportContext;
101 
102 /**
103  * A structure that holds flags for the table export.
104  */
105 struct TableReference
106 {
107     /// Remember if we are in an open cell, or not.
108     bool m_bTableCellOpen;
109 
110     /// If paragraph sdt got opened in this table cell.
111     bool m_bTableCellParaSdtOpen;
112 
113     /// Remember the current table depth.
114     sal_uInt32 m_nTableDepth;
115 
TableReferenceTableReference116     TableReference()
117         : m_bTableCellOpen(false),
118         m_bTableCellParaSdtOpen(false),
119         m_nTableDepth(0)
120     {
121     }
122 };
123 
124 /// The class that has handlers for various resource types when exporting as DOCX.
125 class DocxAttributeOutput : public AttributeOutputBase, public oox::vml::VMLTextExport, public oox::drawingml::DMLTextExport
126 {
127 public:
128     /// Export the state of RTL/CJK.
129     virtual void RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript ) override;
130 
131     /// Start of the paragraph.
132     virtual sal_Int32 StartParagraph(ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo,
133                                      bool bGenerateParaId) override;
134 
135     /// End of the paragraph.
136     virtual void EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) override;
137 
138     /// Empty paragraph.
139     virtual void EmptyParagraph() override;
140 
141     /// Called in order to output section breaks.
142     virtual void SectionBreaks(const SwNode& rNode) override;
143 
144     /// Called before we start outputting the attributes.
145     virtual void StartParagraphProperties() override;
146 
147     /// Called after we end outputting the attributes.
148     virtual void EndParagraphProperties(const SfxItemSet& rParagraphMarkerProperties, const SwRedlineData* pRedlineData, const SwRedlineData* pRedlineParagraphMarkerDeleted, const SwRedlineData* pRedlineParagraphMarkerInserted) override;
149 
150     /// Start of the text run.
151     virtual void StartRun( const SwRedlineData* pRedlineData, sal_Int32 nPos, bool bSingleEmptyRun = false ) override;
152 
153     /// End of the text run.
154     virtual void EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool bLastRun = false) override;
155 
156     /// Called before we start outputting the attributes.
157     virtual void StartRunProperties() override;
158 
159     /// Called after we end outputting the attributes.
160     virtual void EndRunProperties( const SwRedlineData* pRedlineData ) override;
161 
162     virtual bool FootnoteEndnoteRefTag() override;
163 
164     virtual void SectFootnoteEndnotePr() override;
165 
166     virtual void WritePostitFieldReference() override;
167 
168     /// Output text (inside a run).
169     virtual void RunText( const OUString& rText, rtl_TextEncoding eCharSet = RTL_TEXTENCODING_UTF8 ) override;
170 
171     /// Output text (without markup).
172     virtual void RawText(const OUString& rText, rtl_TextEncoding eCharSet) override;
173 
174     /// Output ruby start.
175     virtual void StartRuby( const SwTextNode& rNode, sal_Int32 nPos, const SwFormatRuby& rRuby ) override;
176 
177     /// Output ruby end.
178     virtual void EndRuby(const SwTextNode& rNode, sal_Int32 nPos) override;
179 
180     /// Output URL start.
181     virtual bool StartURL( const OUString& rUrl, const OUString& rTarget ) override;
182 
183     /// Output URL end.
184     virtual bool EndURL(bool) override;
185 
186     virtual void FieldVanish(const OUString& rText, ww::eField eType, OUString const*) override;
187 
188     /// Output redlining.
189     ///
190     /// The common attribute that can be among the run properties.
191     virtual void Redline( const SwRedlineData* pRedline ) override;
192 
193     /// Output redlining.
194     ///
195     /// Start of the tag that encloses the run, fills the info according to
196     /// the value of pRedlineData.
197     void StartRedline( const SwRedlineData * pRedlineData );
198 
199     /// Output redlining.
200     ///
201     /// End of the tag that encloses the run.
202     void EndRedline( const SwRedlineData * pRedlineData );
203 
204     virtual void SetStateOfFlyFrame( FlyProcessingState nStateOfFlyFrame ) override;
205     virtual void SetAnchorIsLinkedToNode( bool bAnchorLinkedToNode ) override;
206     virtual bool IsFlyProcessingPostponed() override;
207     virtual void ResetFlyProcessingFlag() override;
208 
209     virtual void FormatDrop( const SwTextNode& rNode, const SwFormatDrop& rSwFormatDrop, sal_uInt16 nStyle, ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo, ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) override;
210 
211     /// Output style.
212     virtual void ParagraphStyle( sal_uInt16 nStyle ) override;
213 
214     virtual void TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
215     virtual void TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
216     virtual void TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
217     virtual void TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
218     void TableDefaultCellMargins( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner );
219     virtual void TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
220     virtual void TableRowRedline( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
221     virtual void TableCellRedline( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
222     virtual void TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
223     virtual void TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
224     virtual void TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
225     virtual void TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
226     virtual void TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner ) override;
227     virtual void TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
228     virtual void TableSpacing( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) override;
229     virtual void TableRowEnd( sal_uInt32 nDepth ) override;
230 
231     /// Start of the styles table.
232     virtual void StartStyles() override;
233 
234     /// End of the styles table.
235     virtual void EndStyles( sal_uInt16 nNumberOfStyles ) override;
236 
237     /// Write default style.
238     virtual void DefaultStyle() override;
239 
240     /// Write Doc Defaults
241     void DocDefaults( );
242 
243     /// Write latent styles.
244     void LatentStyles();
245 
246     /** Similar to OutputItem(), but write something only if it is not the default.
247 
248         This is to output the docDefaults, and we should write something out
249         only in case it is not what MSO already uses for the document by default.
250     */
251     void OutputDefaultItem(const SfxPoolItem& rHt);
252 
253     /// Start of a style in the styles table.
254     virtual void StartStyle( const OUString& rName, StyleType eType,
255             sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 nWwId, sal_uInt16 nId,
256             bool bAutoUpdate ) override;
257 
258     /// End of a style in the styles table.
259     virtual void EndStyle() override;
260 
261     /// Start of (paragraph or run) properties of a style.
262     virtual void StartStyleProperties( bool bParProp, sal_uInt16 nStyle ) override;
263 
264     /// End of (paragraph or run) properties of a style.
265     virtual void EndStyleProperties( bool bParProp ) override;
266 
267     /// Numbering rule and Id.
268     virtual void OutlineNumbering(sal_uInt8 nLvl) override;
269 
270     /// Page break
271     /// As a paragraph property - the paragraph should be on the next page.
272     virtual void PageBreakBefore( bool bBreak ) override;
273 
274     /// Write a section break
275     /// msword::ColumnBreak or msword::PageBreak
276     /// bBreakAfter: the break must be scheduled for insertion in the end of current paragraph
277     virtual void SectionBreak( sal_uInt8 nC, bool bBreakAfter, const WW8_SepInfo* pSectionInfo = nullptr, bool bExtraPageBreak = false ) override;
278 
279     // preserve DOCX page vertical alignment
280     virtual void TextVerticalAdjustment( const css::drawing::TextVerticalAdjust ) override;
281 
282     /// Start of the section properties.
283     virtual void StartSection() override;
284 
285     /// End of the section properties.
286     virtual void EndSection() override;
287 
288     /// Protection of forms.
289     virtual void SectionFormProtection( bool bProtected ) override;
290 
291     /// Numbering of the lines in the document.
292     virtual void SectionLineNumbering( sal_uLong nRestartNo, const SwLineNumberInfo& rLnNumInfo ) override;
293 
294     /// Has different headers/footers for the title page.
295     virtual void SectionTitlePage() override;
296 
297     /// Description of the page borders.
298     virtual void SectionPageBorders( const SwFrameFormat* pFormat, const SwFrameFormat* pFirstPageFormat ) override;
299 
300     /// Columns populated from right/numbers on the right side?
301     virtual void SectionBiDi( bool bBiDi ) override;
302 
303     /// The style of the page numbers.
304     ///
305     virtual void SectionPageNumbering( sal_uInt16 nNumType, const ::std::optional<sal_uInt16>& oPageRestartNumber ) override;
306 
307     /// The type of breaking.
308     virtual void SectionType( sal_uInt8 nBreakCode ) override;
309 
310     /// Start the font.
311     void StartFont( const OUString& rFamilyName ) const;
312 
313     /// End the font.
314     void EndFont() const;
315 
316     /// Alternate name for the font.
317     void FontAlternateName( const OUString& rName ) const;
318 
319     /// Font charset.
320     void FontCharset( sal_uInt8 nCharSet, rtl_TextEncoding nEncoding ) const;
321 
322     /// Font family.
323     void FontFamilyType( FontFamily eFamily ) const;
324 
325     /// Font pitch.
326     void FontPitchType( FontPitch ePitch ) const;
327 
328     /// Write out the font into the document, if it's an embedded font.
329     void EmbedFont( std::u16string_view name, FontFamily family, FontPitch pitch );
330 
331     /// Definition of a numbering instance.
332     virtual void NumberingDefinition( sal_uInt16 nId, const SwNumRule &rRule ) override;
333 
334     /// Numbering definition that overrides abstract numbering definition
335     virtual void OverrideNumberingDefinition( SwNumRule const& rRule,
336             sal_uInt16 nNum, sal_uInt16 nAbstractNum,
337             const std::map< size_t, size_t > & rLevelOverrides ) override;
338 
339     /// Start of the abstract numbering definition instance.
340     virtual void StartAbstractNumbering( sal_uInt16 nId ) override;
341 
342     /// End of the abstract numbering definition instance.
343     virtual void EndAbstractNumbering() override;
344 
345     /// All the numbering level information.
346     virtual void NumberingLevel( sal_uInt8 nLevel,
347         sal_uInt16 nStart,
348         sal_uInt16 nNumberingType,
349         SvxAdjust eAdjust,
350         const sal_uInt8 *pNumLvlPos,
351         sal_uInt8 nFollow,
352         const wwFont *pFont,
353         const SfxItemSet *pOutSet,
354         sal_Int16 nIndentAt,
355         sal_Int16 nFirstLineIndex,
356         sal_Int16 nListTabPos,
357         const OUString &rNumberingString,
358         const SvxBrushItem* pBrush ) override;
359 
360     void WriteField_Impl(const SwField* pField, ww::eField eType,
361             const OUString& rFieldCmd, FieldFlags nMode,
362             OUString const* pBookmarkName = nullptr);
363     void WriteFormData_Impl( const ::sw::mark::IFieldmark& rFieldmark );
364 
365     void WriteBookmarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds );
366     void WriteFinalBookmarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds );
367     void WriteAnnotationMarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds );
368     void PushRelIdCache();
369     /// End possibly opened paragraph sdt block.
370     void EndParaSdtBlock();
371 
372     void WriteFloatingTable(ww8::Frame const* pParentFrame);
373 
374 private:
375     /// Initialize the structures where we are going to collect some of the paragraph properties.
376     ///
377     /// Some of the properties have to be collected from more sources, and are
378     /// actually not written between StartParagraphProperties and
379     /// EndParagraphProperties.  They are output in this method, which is
380     /// supposed to be called just before outputting </rPr> whenever it is done.
381     void InitCollectedParagraphProperties();
382 
383     /// Output what we collected during the run properties output.
384     ///
385     /// @see WriteCollectedParagrapProperties().
386     void WriteCollectedParagraphProperties();
387 
388     /// Initialize the structures where we are going to collect some of the run properties.
389     ///
390     /// This is an equivalent of InitCollectedParagraphProperties(), resp.
391     /// WriteCollectectedParagraphProperties().
392     ///
393     /// @see InitCollectedParagraphProperties().
394     void InitCollectedRunProperties();
395 
396     /// Output what we collected during the run properties output.
397     ///
398     /// @see InitCollectedRunproperties(), WriteCollectedParagraphProperties()
399     void WriteCollectedRunProperties();
400 
401     /// Output graphic fly frames or replacement graphics for OLE nodes.
402     ///
403     /// For graphic frames, just use the first two parameters, for OLE
404     /// replacement graphics, set the first as 0, and pass the remaining three.
405     ///
406     /// @see WriteOLE2Obj()
407     void FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size& rSize, const SwFlyFrameFormat* pOLEFrameFormat, SwOLENode* pOLENode, const SdrObject* pSdrObj = nullptr);
408     void WriteSrcRect(const css::uno::Reference<css::beans::XPropertySet>& xShapePropSet,
409                       const SwFrameFormat* pFrameFormat);
410     void WriteOLE2Obj( const SdrObject* pSdrObj, SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat, const sal_Int8 nFormulaAlignment);
411     bool WriteOLEChart( const SdrObject* pSdrObj, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat);
412     bool WriteOLEMath( const SwOLENode& rNode, const sal_Int8 nAlign );
413     void PostponeOLE( SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat );
414     void WriteOLE( SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* rFlyFrameFormat );
415     void WriteOLEShape(const SwFlyFrameFormat& rFrameFormat, const Size& rSize,
416                        const OString& rShapeId, const OUString& rImageId);
417     static OString GetOLEStyle(const SwFlyFrameFormat& rFormat, const Size& rSize);
418     void ExportOLESurround(const SwFormatSurround& rWrap);
419 
420     void WriteActiveXControl(const SdrObject* pObject, const SwFrameFormat& rFrameFormat, bool bInsideRun);
421     bool ExportAsActiveXControl(const SdrObject* pObject) const;
422 
423     void InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner );
424     void StartTable( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner );
425     void StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner );
426     void StartTableCell( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner, sal_uInt32 nCell, sal_uInt32 nRow );
427     void TableCellProperties( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner, sal_uInt32 nCell, sal_uInt32 nRow );
428     void EndTableCell( sal_uInt32 nCell );
429     void EndTableRow( );
430     void EndTable();
431     void SyncNodelessCells(ww8::WW8TableNodeInfoInner::Pointer_t const & pInner, sal_Int32 nCell, sal_uInt32 nRow);
432     void PopulateFrameProperties(const SwFrameFormat* pFrameFormat, const Size& rSize);
433     static bool TextBoxIsFramePr(const SwFrameFormat& rFrameFormat);
434     /// End cell, row, and even the entire table if necessary.
435     void FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t const & pInner, bool bForceEmptyParagraph = false );
436 
437     void WriteFFData( const FieldInfos& rInfos );
438     void WritePendingPlaceholder();
439 
440     void EmbedFontStyle( std::u16string_view name, int tag, FontFamily family, FontItalic italic, FontWeight weight,
441         FontPitch pitch );
442 
443     /**
444      * Translate an ico value to the corresponding HighlightColorValues enumaration item
445      *
446      * @param[in]   nIco      ico value [0..16]
447      * @return      color name (e.g. "red"), if color is inside [1..16] range
448      *              empty string, otherwise
449     **/
450     static OString TransHighlightColor( sal_uInt8 nIco );
451 protected:
452 
453     /// Output frames - the implementation.
454     virtual void OutputFlyFrame_Impl( const ww8::Frame& rFormat, const Point& rNdTopLeft ) override;
455 
456     /// Sfx item Sfx item RES_CHRATR_CASEMAP
457     virtual void CharCaseMap( const SvxCaseMapItem& rCaseMap ) override;
458 
459     /// Sfx item Sfx item RES_CHRATR_COLOR
460     virtual void CharColor( const SvxColorItem& rColor) override;
461 
462     /// Sfx item Sfx item RES_CHRATR_CONTOUR
463     virtual void CharContour( const SvxContourItem& rContour ) override;
464 
465     /// Sfx item RES_CHRATR_CROSSEDOUT
466     virtual void CharCrossedOut( const SvxCrossedOutItem& rCrossedOut ) override;
467 
468     /// Sfx item RES_CHRATR_ESCAPEMENT
469     virtual void CharEscapement( const SvxEscapementItem& rEscapement ) override;
470 
471     /// Sfx item RES_CHRATR_FONT
472     virtual void CharFont( const SvxFontItem& rFont ) override;
473 
474     /// Sfx item RES_CHRATR_FONTSIZE
475     virtual void CharFontSize( const SvxFontHeightItem& rFontSize ) override;
476 
477     /// Sfx item RES_CHRATR_KERNING
478     virtual void CharKerning( const SvxKerningItem& rKerning ) override;
479 
480     /// Sfx item RES_CHRATR_LANGUAGE
481     virtual void CharLanguage( const SvxLanguageItem& rLanguage ) override;
482 
483     /// Sfx item RES_CHRATR_POSTURE
484     virtual void CharPosture( const SvxPostureItem& rPosture ) override;
485 
486     /// Sfx item RES_CHRATR_SHADOWED
487     virtual void CharShadow( const SvxShadowedItem& rShadow ) override;
488 
489     /// Sfx item RES_CHRATR_UNDERLINE
490     virtual void CharUnderline( const SvxUnderlineItem& rUnderline ) override;
491 
492     /// Sfx item RES_CHRATR_WEIGHT
493     virtual void CharWeight( const SvxWeightItem& rWeight ) override;
494 
495     /// Sfx item RES_CHRATR_AUTOKERN
496     virtual void CharAutoKern( const SvxAutoKernItem& ) override;
497 
498     /// Sfx item RES_CHRATR_BLINK
499     virtual void CharAnimatedText( const SvxBlinkItem& rBlink ) override;
500 
501     /// Sfx item RES_CHRATR_BACKGROUND
502     virtual void CharBackground( const SvxBrushItem& rBrush ) override;
503 
504     /// Sfx item RES_CHRATR_CJK_FONT
505     virtual void CharFontCJK( const SvxFontItem& rFont ) override;
506 
507     /// Sfx item RES_CHRATR_CJK_FONTSIZE
CharFontSizeCJK(const SvxFontHeightItem & rFontSize)508     virtual void CharFontSizeCJK( const SvxFontHeightItem& rFontSize ) override { CharFontSize( rFontSize ); }
509 
510     /// Sfx item RES_CHRATR_CJK_LANGUAGE
CharLanguageCJK(const SvxLanguageItem & rLanguageItem)511     virtual void CharLanguageCJK( const SvxLanguageItem& rLanguageItem ) override { CharLanguage( rLanguageItem ); }
512 
513     /// Sfx item RES_CHRATR_CJK_POSTURE
514     virtual void CharPostureCJK( const SvxPostureItem& rPosture ) override;
515 
516     /// Sfx item RES_CHRATR_CJK_WEIGHT
517     virtual void CharWeightCJK( const SvxWeightItem& rWeight ) override;
518 
519     /// Sfx item RES_CHRATR_CTL_FONT
520     virtual void CharFontCTL( const SvxFontItem& rFont ) override;
521 
522     /// Sfx item RES_CHRATR_CTL_FONTSIZE
CharFontSizeCTL(const SvxFontHeightItem & rFontSize)523     virtual void CharFontSizeCTL( const SvxFontHeightItem& rFontSize ) override { CharFontSize( rFontSize ); }
524 
525     /// Sfx item RES_CHRATR_CTL_LANGUAGE
CharLanguageCTL(const SvxLanguageItem & rLanguageItem)526     virtual void CharLanguageCTL( const SvxLanguageItem& rLanguageItem ) override { CharLanguage( rLanguageItem); }
527 
528     /// Sfx item RES_CHRATR_CTL_POSTURE
529     virtual void CharPostureCTL( const SvxPostureItem& rWeight ) override;
530 
531     /// Sfx item RES_CHRATR_CTL_WEIGHT
532     virtual void CharWeightCTL( const SvxWeightItem& rWeight ) override;
533 
534     /// Sfx item RES_CHRATR_BidiRTL
535     virtual void CharBidiRTL( const SfxPoolItem& ) override;
536 
537     /// Sfx item RES_CHRATR_IdctHint
538     virtual void CharIdctHint( const SfxPoolItem& ) override;
539 
540     /// Sfx item RES_CHRATR_ROTATE
541     virtual void CharRotate( const SvxCharRotateItem& rRotate ) override;
542 
543     /// Sfx item RES_CHRATR_EMPHASIS_MARK
544     virtual void CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark ) override;
545 
546     /// Sfx item RES_CHRATR_TWO_LINES
547     virtual void CharTwoLines( const SvxTwoLinesItem& rTwoLines ) override;
548 
549     /// Sfx item RES_CHRATR_SCALEW
550     virtual void CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth ) override;
551 
552     /// Sfx item RES_CHRATR_RELIEF
553     virtual void CharRelief( const SvxCharReliefItem& rRelief) override;
554 
555     /// Sfx item RES_CHRATR_HIDDEN
556     virtual void CharHidden( const SvxCharHiddenItem& rHidden ) override;
557 
558     /// Sfx item RES_CHRATR_BOX
559     virtual void CharBorder( const ::editeng::SvxBorderLine* pAllBorder, const sal_uInt16 nDist, const bool bShadow ) override;
560 
561     /// Sfx item RES_CHRATR_HIGHLIGHT
562     virtual void CharHighlight( const SvxBrushItem& rHighlight ) override;
563 
564     /// Sfx item RES_TXTATR_INETFMT
565     virtual void TextINetFormat( const SwFormatINetFormat& ) override;
566 
567     /// Sfx item RES_TXTATR_CHARFMT
568     virtual void TextCharFormat( const SwFormatCharFormat& ) override;
569 
570     /// Sfx item RES_TXTATR_FTN
571     virtual void TextFootnote_Impl( const SwFormatFootnote& ) override;
572 
573     /// Output the footnote/endnote reference (if there's one to output).
574     void FootnoteEndnoteReference();
575 
576     /// Sfx item RES_PARATR_LINESPACING
577     virtual void ParaLineSpacing_Impl( short nSpace, short nMulti ) override;
578 
579     /// Sfx item RES_PARATR_ADJUST
580     virtual void ParaAdjust( const SvxAdjustItem& rAdjust ) override;
581 
582     /// Sfx item RES_PARATR_SPLIT
583     virtual void ParaSplit( const SvxFormatSplitItem& rSplit ) override;
584 
585     /// Sfx item RES_PARATR_WIDOWS
586     virtual void ParaWidows( const SvxWidowsItem& rWidows ) override;
587 
588     /// Sfx item RES_PARATR_TABSTOP
589     virtual void ParaTabStop( const SvxTabStopItem& rTabStop ) override;
590 
591     /// Sfx item RES_PARATR_HYPHENZONE
592     virtual void ParaHyphenZone( const SvxHyphenZoneItem& ) override;
593 
594     /// Sfx item RES_PARATR_NUMRULE
595     virtual void ParaNumRule_Impl( const SwTextNode *pTextNd, sal_Int32 nLvl, sal_Int32 nNumId ) override;
596 
597     /// Sfx item RES_PARATR_SCRIPTSPACE
598     virtual void ParaScriptSpace( const SfxBoolItem& ) override;
599 
600     /// Sfx item RES_PARATR_HANGINGPUNCTUATION
601     virtual void ParaHangingPunctuation( const SfxBoolItem& ) override;
602 
603     /// Sfx item RES_PARATR_FORBIDDEN_RULES
604     virtual void ParaForbiddenRules( const SfxBoolItem& ) override;
605 
606     /// Sfx item RES_PARATR_VERTALIGN
607     virtual void ParaVerticalAlign( const SvxParaVertAlignItem& rAlign ) override;
608 
609     /// Sfx item RES_PARATR_SNAPTOGRID
610     virtual void ParaSnapToGrid( const SvxParaGridItem& ) override;
611 
612     /// Sfx item RES_FRM_SIZE
613     virtual void FormatFrameSize( const SwFormatFrameSize& ) override;
614 
615     /// Sfx item RES_PAPER_BIN
616     virtual void FormatPaperBin( const SvxPaperBinItem& ) override;
617 
618     /// Sfx item RES_LR_SPACE
619     virtual void FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) override;
620 
621     /// Sfx item RES_UL_SPACE
622     virtual void FormatULSpace( const SvxULSpaceItem& rULSpace ) override;
623 
624     /// Sfx item RES_SURROUND
625     virtual void FormatSurround( const SwFormatSurround& ) override;
626 
627     /// Sfx item RES_VERT_ORIENT
628     virtual void FormatVertOrientation( const SwFormatVertOrient& ) override;
629 
630     /// Sfx item RES_HORI_ORIENT
631     virtual void FormatHorizOrientation( const SwFormatHoriOrient& ) override;
632 
633     /// Sfx item RES_ANCHOR
634     virtual void FormatAnchor( const SwFormatAnchor& ) override;
635 
636     /// Sfx item RES_BACKGROUND
637     virtual void FormatBackground( const SvxBrushItem& ) override;
638 
639     /// Sfx item RES_FILL_STYLE
640     virtual void FormatFillStyle( const XFillStyleItem& ) override;
641 
642     /// Sfx item RES_FILL_GRADIENT
643     virtual void FormatFillGradient( const XFillGradientItem& ) override;
644 
645     /// Sfx item RES_BOX
646     virtual void FormatBox( const SvxBoxItem& ) override;
647 
648     /// Sfx item RES_COL
649     virtual void FormatColumns_Impl( sal_uInt16 nCols, const SwFormatCol & rCol, bool bEven, SwTwips nPageSize ) override;
650 
651     /// Sfx item RES_KEEP
652     virtual void FormatKeep( const SvxFormatKeepItem& ) override;
653 
654     /// Sfx item RES_TEXTGRID
655     virtual void FormatTextGrid( const SwTextGridItem& ) override;
656 
657     /// Sfx item RES_LINENUMBER
658     virtual void FormatLineNumbering( const SwFormatLineNumber& ) override;
659 
660     /// Sfx item RES_FRAMEDIR
661     virtual void FormatFrameDirection( const SvxFrameDirectionItem& ) override;
662 
663     /// Sfx item RES_PARATR_GRABBAG
664     virtual void ParaGrabBag( const SfxGrabBagItem& ) override;
665 
666     /// Sfx item RES_CHRATR_GRABBAG
667     virtual void CharGrabBag( const SfxGrabBagItem& ) override;
668 
669     // Sfx item RES_PARATR_OUTLINELEVEL
670     virtual void ParaOutlineLevel( const SfxUInt16Item& ) override;
671 
672     /// Write the expanded field
673     virtual void WriteExpand( const SwField* pField ) override;
674 
675     virtual void RefField( const SwField& rField, const OUString& rRef ) override;
676     virtual void HiddenField( const SwField& rField ) override;
677     virtual void SetField( const SwField& rField, ww::eField eType, const OUString& rCmd ) override;
678     virtual void PostitField( const SwField* pField ) override;
679     virtual bool DropdownField( const SwField* pField ) override;
680     virtual bool PlaceholderField( const SwField* pField ) override;
681 
682     virtual bool AnalyzeURL( const OUString& rURL, const OUString& rTarget, OUString* pLinkURL, OUString* pMark ) override;
683 
684     virtual void WriteBookmarkInActParagraph( const OUString& rName, sal_Int32 nFirstRunPos, sal_Int32 nLastRunPos ) override;
685 
686     void SectionRtlGutter( const SfxBoolItem& rRtlGutter) override;
687 
688     /// Reference to the export, where to get the data from
689     DocxExport &m_rExport;
690 
691     /// Fast serializer to output the data
692     ::sax_fastparser::FSHelperPtr m_pSerializer;
693 
694     /// DrawingML access
695     oox::drawingml::DrawingML &m_rDrawingML;
696 
697 private:
698 
699     void DoWriteBookmarkTagStart(const OUString & bookmarkName);
700     void DoWriteBookmarkTagEnd(sal_Int32 nId);
701     void DoWriteBookmarksStart(std::vector<OUString>& rStarts);
702     void DoWriteBookmarksEnd(std::vector<OUString>& rEnds);
703     void DoWriteBookmarkStartIfExist(sal_Int32 nRunPos);
704     void DoWriteBookmarkEndIfExist(sal_Int32 nRunPos);
705 
706     void DoWritePermissionTagStart(const OUString & permission);
707     void DoWritePermissionTagEnd(const OUString & permission);
708     void DoWritePermissionsStart();
709     void DoWritePermissionsEnd();
710 
711     void DoWriteAnnotationMarks( );
712     void WritePostponedGraphic();
713     void WritePostponedMath(const SwOLENode* pObject, sal_Int8 /*nAlign*/);
714     void WritePostponedFormControl(const SdrObject* pObject);
715     void WritePostponedActiveXControl(bool bInsideRun);
716     void WritePostponedDiagram();
717     void WritePostponedChart();
718     void WritePostponedOLE();
719     void WritePostponedDMLDrawing();
720     void WritePostponedCustomShape();
721     void WriteFlyFrame(const ww8::Frame& rFrame);
722 
723     void WriteSdtBlock(sal_Int32& nSdtPrToken,
724                        rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrTokenChildren,
725                        rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrTokenAttributes,
726                        rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrDataBindingAttrs,
727                        rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrTextAttrs,
728                        OUString& rSdtPrAlias,
729                        bool bPara);
730     /// Closes a currently open SDT block.
731     void EndSdtBlock();
732 
733     void WriteFormDateStart(const OUString& sFullDate, const OUString& sDateFormat, const OUString& sLang);
734     void WriteSdtDropDownStart(std::u16string_view rName, OUString const& rSelected, uno::Sequence<OUString> const& rListItems);
735     void WriteSdtDropDownEnd(OUString const& rSelected, uno::Sequence<OUString> const& rListItems);
736     void WriteSdtEnd();
737 
738     void StartField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun = false );
739     void DoWriteCmd( const OUString& rCmd );
740     void CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun );
741     void CmdEndField_Impl( const SwTextNode* pNode, sal_Int32 nPos, bool bWriteRun );
742     void EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos& rInfos );
743     void DoWriteFieldRunProperties( const SwTextNode* pNode, sal_Int32 nPos, bool bWriteCombChars = false );
744 
745     static void AddToAttrList( rtl::Reference<sax_fastparser::FastAttributeList>& pAttrList, sal_Int32 nAttrName, const char* sAttrValue );
746     static void AddToAttrList( rtl::Reference<sax_fastparser::FastAttributeList>& pAttrList, sal_Int32 nArgs, ... );
747 
748     rtl::Reference<sax_fastparser::FastAttributeList> m_pFontsAttrList;
749     rtl::Reference<sax_fastparser::FastAttributeList> m_pEastAsianLayoutAttrList;
750     rtl::Reference<sax_fastparser::FastAttributeList> m_pCharLangAttrList;
751     rtl::Reference<sax_fastparser::FastAttributeList> m_pSectionSpacingAttrList;
752     rtl::Reference<sax_fastparser::FastAttributeList> m_pParagraphSpacingAttrList;
753     rtl::Reference<sax_fastparser::FastAttributeList> m_pHyperlinkAttrList;
754     /// If the current SDT around runs should be ended before the current run.
755     bool m_bEndCharSdt;
756     /// If an SDT around runs is currently open.
757     bool m_bStartedCharSdt;
758     /// If an SDT around paragraphs is currently open.
759     bool m_bStartedParaSdt;
760     /// Attributes of the run color
761     rtl::Reference<sax_fastparser::FastAttributeList> m_pColorAttrList;
762     sal_uInt8 m_nCharTransparence = 0;
763     /// Attributes of the paragraph background
764     rtl::Reference<sax_fastparser::FastAttributeList> m_pBackgroundAttrList;
765     OUString m_sOriginalBackgroundColor;
766     OUString m_hyperLinkAnchor;
767     bool m_endPageRef;
768     std::unique_ptr<docx::FootnotesList> m_pFootnotesList;
769     std::unique_ptr<docx::FootnotesList> m_pEndnotesList;
770     int m_footnoteEndnoteRefTag;
771     OUString m_footnoteCustomLabel;
772     std::unique_ptr< const WW8_SepInfo > m_pSectionInfo;
773 
774     /// Redline data to remember in the text run.
775     const SwRedlineData *m_pRedlineData;
776 
777     /// Id of the redline
778     sal_Int32 m_nRedlineId;
779 
780     /// Flag indicating that the section properties are being written
781     bool m_bOpenedSectPr;
782     /// Did we have a section break in this paragraph? Set by StartSection(), reset by the next StartParagraph().
783     bool m_bHadSectPr;
784 
785     /// Flag indicating that the Run Text is being written
786     bool m_bRunTextIsOn;
787 
788     /// Flag indicating that the header \ footer are being written
789     bool m_bWritingHeaderFooter;
790     bool m_bAnchorLinkedToNode;
791 
792     /// Flag indicating that multiple runs of a field are being written
793     bool m_bWritingField;
794 
795     /// Field data to remember in the text run
796     bool m_bPreventDoubleFieldsHandling;
797     std::vector< FieldInfos > m_Fields;
798     OUString m_sFieldBkm;
799     sal_Int32 m_nNextBookmarkId;
800     sal_Int32 m_nNextAnnotationMarkId;
801 
802     /// [MS-DOCX] section 2.6.2.3
803     sal_Int32 m_nNextParaId = 1; // MUST be greater than 0
804 
805     OUString m_sRawText;
806 
807     /// The first frame (anchored to the main text) is 0.
808     /// The second frame what is anchored to the previous in, is 1
809     /// The third anchored inside the second is the 2 etc.
810     sal_uInt32 m_nEmbedFlyLevel;
811 
812     /// Stores the flys what are anchored inside a fly
813     std::vector<ww8::Frame> m_vPostponedFlys;
814 
815     /// Bookmarks to output
816     std::vector<OUString> m_rBookmarksStart;
817     std::vector<OUString> m_rBookmarksEnd;
818 
819     /// Bookmarks to output at the end
820     std::vector<OUString> m_rFinalBookmarksStart;
821     std::vector<OUString> m_rFinalBookmarksEnd;
822 
823     /// Bookmarks of the current paragraph
824     std::multimap<sal_Int32, OUString> m_aBookmarksOfParagraphStart;
825     std::multimap<sal_Int32, OUString> m_aBookmarksOfParagraphEnd;
826 
827     /// Permissions to output
828     std::vector<OUString> m_rPermissionsStart;
829     std::vector<OUString> m_rPermissionsEnd;
830 
831     /// Annotation marks to output
832     std::vector<OString> m_rAnnotationMarksStart;
833     std::vector<OString> m_rAnnotationMarksEnd;
834 
835     /// Maps of the bookmarks ids
836     std::map<OUString, sal_Int32> m_rOpenedBookmarksIds;
837 
838     /// Name of the last opened bookmark.
839     OString m_sLastOpenedBookmark;
840 
841     /// Maps of the annotation marks ids
842     std::map<OString, sal_Int32> m_rOpenedAnnotationMarksIds;
843 
844     /// Name of the last opened annotation mark.
845     OString m_sLastOpenedAnnotationMark;
846 
847     /// If there are bookmarks around sequence fields, this map contains the
848     /// names of these bookmarks for each sequence.
849     std::map<OUString, std::vector<OString> > m_aSeqBookmarksNames;
850 
851     /// GrabBag for text effects like glow, shadow, ...
852     std::vector<css::beans::PropertyValue> m_aTextEffectsGrabBag;
853 
854     /// The current table helper
855     std::unique_ptr<SwWriteTable> m_xTableWrt;
856 
857     ww8::Frame* m_pCurrentFrame;
858 
859     bool m_bParagraphOpened;
860     bool m_bParagraphFrameOpen;
861     bool m_bIsFirstParagraph;
862     bool m_bAlternateContentChoiceOpen;
863     bool m_bPostponedProcessingFly;
864 
865     // Remember that a column break has to be opened at the
866     // beginning of the next paragraph
867     DocxColBreakStatus m_nColBreakStatus;
868 
869     // Remember that a page break has to be opened at the
870     // beginning of the next paragraph
871     bool m_bPostponedPageBreak;
872 
873     // This paragraph must end with page break
874     bool m_bPageBreakAfter = false;
875 
876     std::stack< std::vector<ww8::Frame> > m_aFramesOfParagraph;
877     o3tl::sorted_vector<const SwFrameFormat*> m_aFloatingTablesOfParagraph;
878     sal_Int32 m_nTextFrameLevel;
879 
880     // close of hyperlink needed
881     bool m_closeHyperlinkInThisRun;
882     bool m_closeHyperlinkInPreviousRun;
883     bool m_startedHyperlink;
884     // Count nested HyperLinks
885     sal_Int32 m_nHyperLinkCount;
886     sal_Int16 m_nFieldsInHyperlink;
887 
888     // If the exported numbering rule defines the outlines
889     bool m_bExportingOutline;
890 
891     struct PostponedGraphic
892     {
PostponedGraphicDocxAttributeOutput::PostponedGraphic893         PostponedGraphic( const SwGrfNode* n, Size s, const SdrObject* sObj )
894             : grfNode( n ), size( s ), pSdrObj(sObj) {};
895 
896         const SwGrfNode* grfNode;
897         Size size;
898         const SdrObject* pSdrObj;
899     };
900     std::unique_ptr< std::vector<PostponedGraphic> > m_pPostponedGraphic;
901     struct PostponedDiagram
902     {
PostponedDiagramDocxAttributeOutput::PostponedDiagram903         PostponedDiagram( const SdrObject* o, const SwFrameFormat* frm ) : object( o ), frame( frm ) {};
904         const SdrObject* object;
905         const SwFrameFormat* frame;
906     };
907     std::unique_ptr< std::vector<PostponedDiagram> > m_pPostponedDiagrams;
908 
909     struct PostponedDrawing
910     {
PostponedDrawingDocxAttributeOutput::PostponedDrawing911         PostponedDrawing( const SdrObject* sdrObj, const SwFrameFormat* frm) : object( sdrObj ), frame( frm ) {};
912         const SdrObject* object;
913         const SwFrameFormat* frame;
914     };
915     std::unique_ptr< std::vector<PostponedDrawing> > m_pPostponedDMLDrawings;
916     std::unique_ptr< std::vector<PostponedDrawing> > m_pPostponedCustomShape;
917 
918     struct PostponedOLE
919     {
PostponedOLEDocxAttributeOutput::PostponedOLE920         PostponedOLE( SwOLENode* rObject, const Size& rSize, const SwFlyFrameFormat* rFrame ) : object( rObject ), size( rSize ), frame( rFrame ) {};
921         SwOLENode* object;
922         const Size size;
923         const SwFlyFrameFormat* frame;
924     };
925     std::unique_ptr< std::vector<PostponedOLE> > m_pPostponedOLEs;
926 
927     struct PostponedMathObjects
928     {
929         SwOLENode* pMathObject;
930         sal_Int8 nMathObjAlignment;
931     };
932     std::vector<PostponedMathObjects> m_aPostponedMaths;
933     /// count charts consistently for unit tests
934     unsigned int m_nChartCount;
935     struct PostponedChart
936     {
PostponedChartDocxAttributeOutput::PostponedChart937         PostponedChart( const SdrObject* sdrObject, const Size& rSize, const SwFlyFrameFormat* rFrame ) : object(sdrObject), size(rSize), frame(rFrame) {};
938         const SdrObject* object;
939         const Size size;
940         const SwFlyFrameFormat* frame;
941     };
942     std::vector<PostponedChart> m_aPostponedCharts;
943     std::vector<const SdrObject*> m_aPostponedFormControls;
944     std::vector<PostponedDrawing> m_aPostponedActiveXControls;
945     const SwField* pendingPlaceholder;
946 
947     struct PostItDOCXData{
948         sal_Int32 id;
949         sal_Int32 lastParaId = 0; // [MS-DOCX] 2.5.3.1 CT_CommentEx needs paraId attribute
950     };
951     /// Maps postit fields to ID's, used in commentRangeStart/End, commentReference and comment.xml.
952     std::vector<std::pair<const SwPostItField*, PostItDOCXData>> m_postitFields;
953     /// Number of postit fields which already have a commentReference written.
954     unsigned int m_postitFieldsMaxId;
955     int m_anchorId;
956     int m_nextFontId;
957     struct EmbeddedFontRef
958     {
959         OString relId;
960         OString fontKey;
961     };
962 
963     std::unique_ptr<TableReference> m_tableReference;
964 
965     std::map< OUString, EmbeddedFontRef > fontFilesMap; // font file url to data
966 
967     // Remember first cell (used for default borders/margins) of each table
968     std::vector<ww8::WW8TableNodeInfoInner::Pointer_t> tableFirstCells;
969     // Remember last open and closed cells on each level
970     std::vector<sal_Int32> lastOpenCell;
971     std::vector<sal_Int32> lastClosedCell;
972 
973     std::optional<css::drawing::FillStyle> m_oFillStyle;
974     /// If FormatBox() already handled fill style / gradient.
975     bool m_bIgnoreNextFill;
976 
977     editeng::WordPageMargins m_pageMargins;
978 
979     std::shared_ptr<DocxTableStyleExport> m_pTableStyleExport;
980     // flag to check if auto spacing was set in original file
981     bool m_bParaBeforeAutoSpacing,m_bParaAfterAutoSpacing;
982     // store hardcoded value which was set during import.
983     sal_Int32 m_nParaBeforeSpacing,m_nParaAfterSpacing;
984 
985     std::pair<OString, OUString> getExistingGraphicRelId(BitmapChecksum aChecksum);
986     void cacheGraphicRelId(BitmapChecksum nChecksum, OString const & rRelId, OUString const & rFileName);
987 
988     /// RelId <-> Graphic* cache, so that in case of alternate content, the same graphic only gets written once.
989     std::stack< std::map<BitmapChecksum, std::pair<OString, OUString>> > m_aRelIdCache;
990 
991     /// RelId <-> BitmapChecksum cache, similar to m_aRelIdCache, but used for non-Writer graphics, handled in oox.
992     std::stack< std::map<BitmapChecksum, std::pair<OUString, OUString>> > m_aSdrRelIdCache;
993 
994     /// members to control the existence of grabbagged SDT properties in the paragraph
995     sal_Int32 m_nParagraphSdtPrToken;
996     rtl::Reference<sax_fastparser::FastAttributeList> m_pParagraphSdtPrTokenChildren;
997     rtl::Reference<sax_fastparser::FastAttributeList> m_pParagraphSdtPrTokenAttributes;
998     rtl::Reference<sax_fastparser::FastAttributeList> m_pParagraphSdtPrDataBindingAttrs;
999     rtl::Reference<sax_fastparser::FastAttributeList> m_pParagraphSdtPrTextAttrs;
1000     /// members to control the existence of grabbagged SDT properties in the text run
1001     sal_Int32 m_nRunSdtPrToken;
1002     /// State of the Fly at current position
1003     FlyProcessingState m_nStateOfFlyFrame;
1004     rtl::Reference<sax_fastparser::FastAttributeList> m_pRunSdtPrTokenChildren;
1005     rtl::Reference<sax_fastparser::FastAttributeList> m_pRunSdtPrDataBindingAttrs;
1006     rtl::Reference<sax_fastparser::FastAttributeList> m_pRunSdtPrTextAttrs;
1007     /// Value of the <w:alias> paragraph SDT element.
1008     OUString m_aParagraphSdtPrAlias;
1009     /// Same as m_aParagraphSdtPrAlias, but its content is available till the SDT is closed.
1010     OUString m_aStartedParagraphSdtPrAlias;
1011     OUString m_aRunSdtPrAlias;
1012     /// Currently paragraph SDT has a <w:id> child element.
1013     bool m_bParagraphSdtHasId;
1014 
1015     std::vector<std::map<SvxBoxItemLine, css::table::BorderLine2>> m_aTableStyleConfs;
1016 
1017 public:
1018     DocxAttributeOutput( DocxExport &rExport, const ::sax_fastparser::FSHelperPtr& pSerializer, oox::drawingml::DrawingML* pDrawingML );
1019 
1020     virtual ~DocxAttributeOutput() override;
1021 
1022     /// Return the right export class.
1023     virtual DocxExport& GetExport() override;
GetExport() const1024     const DocxExport& GetExport() const { return const_cast< DocxAttributeOutput* >( this )->GetExport(); }
1025 
1026     /// For e.g. the output of the styles, we need to switch the serializer to another one.
1027     void SetSerializer( ::sax_fastparser::FSHelperPtr const & pSerializer );
1028 
1029     /// Occasionally need to use this serializer from the outside
GetSerializer() const1030     const ::sax_fastparser::FSHelperPtr& GetSerializer( ) const { return m_pSerializer; }
1031 
1032     /// Do we have any footnotes?
1033     bool HasFootnotes() const;
1034 
1035     /// Do we have any endnotes?
1036     bool HasEndnotes() const;
1037 
1038     /// Output the content of the footnotes.xml resp. endnotes.xml
1039     void FootnotesEndnotes( bool bFootnotes );
1040 
1041     /// writes the footnotePr/endnotePr (depending on tag) section
1042     static void WriteFootnoteEndnotePr( ::sax_fastparser::FSHelperPtr const & fs, int tag, const SwEndNoteInfo& info, int listtag );
1043 
1044     bool HasPostitFields() const;
1045     enum class hasResolved { no, yes };
1046     hasResolved WritePostitFields();
1047     void WritePostItFieldsResolved();
1048 
1049     /// VMLTextExport
1050     virtual void WriteOutliner(const OutlinerParaObject& rParaObj) override;
1051     virtual void WriteVMLTextBox(css::uno::Reference<css::drawing::XShape> xShape) override;
1052     /// DMLTextExport
1053     virtual void WriteTextBox(css::uno::Reference<css::drawing::XShape> xShape) override;
1054     virtual OUString FindRelId(BitmapChecksum nChecksum) override;
1055     virtual OUString FindFileName(BitmapChecksum nChecksum) override;
1056     virtual void CacheRelId(BitmapChecksum nChecksum, const OUString& rRelId, const OUString& rFileName) override;
1057     virtual css::uno::Reference<css::text::XTextFrame> GetUnoTextFrame(
1058         css::uno::Reference<css::drawing::XShape> xShape) override;
1059     virtual oox::drawingml::DrawingML& GetDrawingML() override;
1060     virtual bool MaybeOutputBrushItem(SfxItemSet const&) override;
1061 
1062     void BulletDefinition(int nId, const Graphic& rGraphic, Size aSize) override;
1063 
SetWritingHeaderFooter(bool bWritingHeaderFooter)1064     void SetWritingHeaderFooter( bool bWritingHeaderFooter )    {   m_bWritingHeaderFooter = bWritingHeaderFooter;   }
GetWritingHeaderFooter() const1065     bool GetWritingHeaderFooter( ) const  {   return m_bWritingHeaderFooter;  }
SetAlternateContentChoiceOpen(bool bAltContentChoiceOpen)1066     void SetAlternateContentChoiceOpen( bool bAltContentChoiceOpen ) { m_bAlternateContentChoiceOpen = bAltContentChoiceOpen; }
IsAlternateContentChoiceOpen() const1067     bool IsAlternateContentChoiceOpen( ) const { return m_bAlternateContentChoiceOpen; }
1068     void GetSdtEndBefore(const SdrObject* pSdrObj);
IsFirstParagraph() const1069     bool IsFirstParagraph() const { return m_bIsFirstParagraph; }
1070 
1071     /// Stores the table export state to the passed context and resets own state.
1072     void pushToTableExportContext(DocxTableExportContext& rContext);
1073     /// Restores from the remembered state.
1074     void popFromTableExportContext(DocxTableExportContext const & rContext);
1075 };
1076 
1077 /**
1078 * All the information that should be stashed away when we're in the middle of
1079 * of a table export and still have to do something else, e.g. export a shape.
1080 */
1081 struct DocxTableExportContext
1082 {
1083     DocxAttributeOutput& m_rOutput;
1084     ww8::WW8TableInfo::Pointer_t m_pTableInfo;
1085     bool m_bTableCellOpen;
1086     bool m_bStartedParaSdt;
1087     sal_uInt32 m_nTableDepth;
DocxTableExportContextDocxTableExportContext1088     DocxTableExportContext(DocxAttributeOutput& rOutput) : m_rOutput(rOutput) { m_rOutput.pushToTableExportContext(*this); }
~DocxTableExportContextDocxTableExportContext1089     ~DocxTableExportContext() { m_rOutput.popFromTableExportContext(*this); }
1090 };
1091 
1092 namespace docx {
1093 
1094 rtl::Reference<sax_fastparser::FastAttributeList> SurroundToVMLWrap(SwFormatSurround const& rSurround);
1095 
1096 }
1097 
1098 #endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXATTRIBUTEOUTPUT_HXX
1099 
1100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1101