1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SW_SOURCE_FILTER_WW8_WW8ATTRIBUTEOUTPUT_HXX
21 #define INCLUDED_SW_SOURCE_FILTER_WW8_WW8ATTRIBUTEOUTPUT_HXX
23 #include "attributeoutputbase.hxx"
25 #include <editeng/boxitem.hxx>
26 #include <sfx2/docfile.hxx>
28 class WW8AttributeOutput
: public AttributeOutputBase
31 /// Export the state of RTL/CJK.
32 virtual void RTLAndCJKState( bool bIsRTL
, sal_uInt16 nScript
) override
;
34 /// Start of the paragraph.
35 virtual sal_Int32
StartParagraph( const ww8::WW8TableNodeInfo::Pointer_t
& /*pTextNodeInfo*/, bool /*bGenerateParaId*/ ) override
{ return 0; }
37 /// End of the paragraph.
38 virtual void EndParagraph( const ww8::WW8TableNodeInfoInner::Pointer_t
& pTextNodeInfoInner
) override
;
40 /// Called in order to output section breaks.
41 virtual void SectionBreaks(const SwNode
& /*rNode*/) override
{}
43 /// Called before we start outputting the attributes.
44 virtual void StartParagraphProperties() override
{}
46 /// Called after we end outputting the attributes.
47 virtual void EndParagraphProperties(const SfxItemSet
& /*rParagraphMarkerProperties*/, const SwRedlineData
* /*pRedlineData*/, const SwRedlineData
* /*pRedlineParagraphMarkerDeleted*/, const SwRedlineData
* /*pRedlineParagraphMarkerInserted*/) override
{}
50 virtual void EmptyParagraph() override
;
52 /// Start of the text run.
54 virtual void StartRun( const SwRedlineData
* pRedlineData
, sal_Int32 nPos
, bool bSingleEmptyRun
= false ) override
;
56 virtual void OnTOXEnding() override
;
58 /// End of the text run.
60 /// No-op for binary filters.
61 virtual void EndRun(const SwTextNode
* pNode
, sal_Int32 nPos
, sal_Int32 nLen
, bool bLastRun
= false) override
;
63 /// Before we start outputting the attributes.
64 virtual void StartRunProperties() override
;
66 /// After we end outputting the attributes.
67 virtual void EndRunProperties( const SwRedlineData
* pRedlineData
) override
;
70 virtual void RunText( const OUString
& rText
, rtl_TextEncoding eCharSet
= RTL_TEXTENCODING_UTF8
, const OUString
& rSymbolFont
= OUString() ) override
;
72 /// Output text (without markup).
73 virtual void RawText(const OUString
& rText
, rtl_TextEncoding eCharSet
) override
;
75 /// Output ruby start.
76 virtual void StartRuby( const SwTextNode
& rNode
, sal_Int32 nPos
, const SwFormatRuby
& rRuby
) override
;
79 virtual void EndRuby(const SwTextNode
& rNode
, sal_Int32 nPos
) override
;
82 virtual bool StartURL(const OUString
& rUrl
, const OUString
& rTarget
, const OUString
& rName
= OUString()) override
;
85 virtual bool EndURL(bool) override
;
87 virtual void FieldVanish(const OUString
& rText
, ww::eField eType
, OUString
const* pBookmarkName
) override
;
90 virtual void Redline( const SwRedlineData
* pRedline
) override
;
92 virtual void FormatDrop( const SwTextNode
& rNode
, const SwFormatDrop
&rSwFormatDrop
, sal_uInt16 nStyle
, ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo
, ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner
) override
;
94 /// Output FKP (Formatted disK Page) - necessary for binary formats only.
95 /// FIXME having it in AttributeOutputBase is probably a hack, it
96 /// should be in WW8AttributeOutput only...
97 virtual void OutputFKP(bool bForce
) override
;
100 virtual void ParagraphStyle( sal_uInt16 nStyle
) override
;
102 virtual void TableInfoCell( const ww8::WW8TableNodeInfoInner::Pointer_t
& pTableTextNodeInfo
) override
;
103 virtual void TableInfoRow( const ww8::WW8TableNodeInfoInner::Pointer_t
& pTableTextNodeInfo
) override
;
104 virtual void TableDefinition( const ww8::WW8TableNodeInfoInner::Pointer_t
& pTableTextNodeInfo
) override
;
105 void TablePositioning(SwFrameFormat
* pFlyFormat
);
106 virtual void TableDefaultBorders( const ww8::WW8TableNodeInfoInner::Pointer_t
& pTableTextNodeInfo
) override
;
107 virtual void TableBackgrounds( const ww8::WW8TableNodeInfoInner::Pointer_t
& pTableTextNodeInfo
) override
;
108 virtual void TableRowRedline( const ww8::WW8TableNodeInfoInner::Pointer_t
& pTableTextNodeInfo
) override
;
109 virtual void TableCellRedline( const ww8::WW8TableNodeInfoInner::Pointer_t
& pTableTextNodeInfo
) override
;
110 virtual void TableHeight( const ww8::WW8TableNodeInfoInner::Pointer_t
& pTableTextNodeInfo
) override
;
111 virtual void TableCanSplit( const ww8::WW8TableNodeInfoInner::Pointer_t
& pTableTextNodeInfo
) override
;
112 virtual void TableBidi( const ww8::WW8TableNodeInfoInner::Pointer_t
& pTableTextNodeInfo
) override
;
113 virtual void TableVerticalCell( const ww8::WW8TableNodeInfoInner::Pointer_t
& pTableTextNodeInfo
) override
;
114 virtual void TableNodeInfoInner( const ww8::WW8TableNodeInfoInner::Pointer_t
& pNodeInfoInner
) override
;
115 virtual void TableOrientation( const ww8::WW8TableNodeInfoInner::Pointer_t
& pTableTextNodeInfoInner
) override
;
116 virtual void TableSpacing( const ww8::WW8TableNodeInfoInner::Pointer_t
& pTableTextNodeInfoInner
) override
;
117 virtual void TableRowEnd( sal_uInt32 nDepth
) override
;
119 /// Start of the styles table.
120 virtual void StartStyles() override
;
122 /// End of the styles table.
123 virtual void EndStyles( sal_uInt16 nNumberOfStyles
) override
;
125 /// Write default style.
126 virtual void DefaultStyle() override
;
128 /// Start of a style in the styles table.
129 virtual void StartStyle( const OUString
& rName
, StyleType eType
,
130 sal_uInt16 nBase
, sal_uInt16 nNext
, sal_uInt16 nLink
, sal_uInt16 nWwIdi
, sal_uInt16 nSlot
,
131 bool bAutoUpdate
) override
;
133 /// End of a style in the styles table.
134 virtual void EndStyle() override
;
136 /// Start of (paragraph or run) properties of a style.
137 virtual void StartStyleProperties( bool bParProp
, sal_uInt16 nStyle
) override
;
139 /// End of (paragraph or run) properties of a style.
140 virtual void EndStyleProperties( bool bParProp
) override
;
142 /// Numbering rule and Id.
143 virtual void OutlineNumbering(sal_uInt8 nLvl
) override
;
146 /// As a paragraph property - the paragraph should be on the next page.
147 virtual void PageBreakBefore( bool bBreak
) override
;
149 /// Write a section break
150 /// msword::ColumnBreak or msword::PageBreak
151 virtual void SectionBreak( sal_uInt8 nC
, bool bBreakAfter
, const WW8_SepInfo
* pSectionInfo
= nullptr, bool bExtraPageBreak
= false ) override
;
153 // preserve DOC page vertical alignment
154 virtual void TextVerticalAdjustment( const css::drawing::TextVerticalAdjust
) override
;
156 /// Start of the section properties.
157 virtual void StartSection() override
;
159 // footnote / endnote section properties
160 virtual void SectFootnoteEndnotePr() override
;
162 /// End of the section properties.
164 /// No-op for binary filters.
165 virtual void EndSection() override
{}
167 /// Protection of forms.
168 virtual void SectionFormProtection( bool bProtected
) override
;
170 /// Numbering of the lines in the document.
171 virtual void SectionLineNumbering( sal_uLong nRestartNo
, const SwLineNumberInfo
& rLnNumInfo
) override
;
173 /// Has different headers/footers for the title page.
174 virtual void SectionTitlePage() override
;
176 /// Description of the page borders.
177 virtual void SectionPageBorders( const SwFrameFormat
* pFormat
, const SwFrameFormat
* pFirstPageFormat
) override
;
179 /// Columns populated from right/numbers on the right side?
180 virtual void SectionBiDi( bool bBiDi
) override
;
182 /// The style of the page numbers.
184 virtual void SectionPageNumbering( sal_uInt16 nNumType
, const ::std::optional
<sal_uInt16
>& oPageRestartNumber
) override
;
186 /// The type of breaking.
187 virtual void SectionType( sal_uInt8 nBreakCode
) override
;
189 /// Definition of a numbering instance.
190 virtual void NumberingDefinition( sal_uInt16 nId
, const SwNumRule
&rRule
) override
;
192 /// All the numbering level information.
193 virtual void NumberingLevel( sal_uInt8 nLevel
,
195 sal_uInt16 nNumberingType
,
197 const sal_uInt8
*pNumLvlPos
,
200 const SfxItemSet
*pOutSet
,
202 sal_Int16 nFirstLineIndex
,
203 sal_Int16 nListTabPos
,
204 const OUString
&rNumberingString
,
205 const SvxBrushItem
* pBrush
, //For i120928,transfer graphic of bullet
206 bool isLegal
) override
;
209 /// Output frames - the implementation.
210 void OutputFlyFrame_Impl( const ww8::Frame
& rFormat
, const Point
& rNdTopLeft
) override
;
212 /// Sfx item Sfx item RES_CHRATR_CASEMAP
213 virtual void CharCaseMap( const SvxCaseMapItem
& ) override
;
215 /// Sfx item Sfx item RES_CHRATR_COLOR
216 virtual void CharColor( const SvxColorItem
& ) override
;
218 /// Sfx item Sfx item RES_CHRATR_CONTOUR
219 virtual void CharContour( const SvxContourItem
& ) override
;
221 /// Sfx item RES_CHRATR_CROSSEDOUT
222 virtual void CharCrossedOut( const SvxCrossedOutItem
& rHt
) override
;
224 /// Sfx item RES_CHRATR_ESCAPEMENT
225 virtual void CharEscapement( const SvxEscapementItem
& ) override
;
227 /// Sfx item RES_CHRATR_FONT
228 virtual void CharFont( const SvxFontItem
& ) override
;
230 /// Sfx item RES_CHRATR_FONTSIZE
231 virtual void CharFontSize( const SvxFontHeightItem
& ) override
;
233 /// Sfx item RES_CHRATR_KERNING
234 virtual void CharKerning( const SvxKerningItem
& ) override
;
236 /// Sfx item RES_CHRATR_LANGUAGE
237 virtual void CharLanguage( const SvxLanguageItem
& ) override
;
239 /// Sfx item RES_CHRATR_POSTURE
240 virtual void CharPosture( const SvxPostureItem
& ) override
;
242 /// Sfx item RES_CHRATR_SHADOWED
243 virtual void CharShadow( const SvxShadowedItem
& ) override
;
245 /// Sfx item RES_CHRATR_UNDERLINE
246 virtual void CharUnderline( const SvxUnderlineItem
& ) override
;
248 /// Sfx item RES_CHRATR_WEIGHT
249 virtual void CharWeight( const SvxWeightItem
& ) override
;
251 /// Sfx item RES_CHRATR_AUTOKERN
252 virtual void CharAutoKern( const SvxAutoKernItem
& ) override
;
254 /// Sfx item RES_CHRATR_BLINK
255 virtual void CharAnimatedText( const SvxBlinkItem
& ) override
;
257 /// Sfx item RES_CHRATR_BACKGROUND
258 virtual void CharBackground( const SvxBrushItem
& ) override
;
260 /// Sfx item RES_CHRATR_CJK_FONT
261 virtual void CharFontCJK( const SvxFontItem
& ) override
;
263 /// Sfx item RES_CHRATR_CJK_FONTSIZE
264 virtual void CharFontSizeCJK( const SvxFontHeightItem
& rHt
) override
{ CharFontSize( rHt
); }
266 /// Sfx item RES_CHRATR_CJK_LANGUAGE
267 virtual void CharLanguageCJK( const SvxLanguageItem
& rHt
) override
{ CharLanguage( rHt
); }
269 /// Sfx item RES_CHRATR_CJK_POSTURE
270 virtual void CharPostureCJK( const SvxPostureItem
& rHt
) override
{ CharPosture( rHt
); }
272 /// Sfx item RES_CHRATR_CJK_WEIGHT
273 virtual void CharWeightCJK( const SvxWeightItem
& rHt
) override
{ CharWeight( rHt
); }
275 /// Sfx item RES_CHRATR_CTL_FONT
276 virtual void CharFontCTL( const SvxFontItem
& ) override
;
278 /// Sfx item RES_CHRATR_CTL_FONTSIZE
279 virtual void CharFontSizeCTL( const SvxFontHeightItem
& rHt
) override
{ CharFontSize( rHt
); }
281 /// Sfx item RES_CHRATR_CTL_LANGUAGE
282 virtual void CharLanguageCTL( const SvxLanguageItem
& rHt
) override
{ CharLanguage( rHt
); }
284 /// Sfx item RES_CHRATR_CTL_POSTURE
285 virtual void CharPostureCTL( const SvxPostureItem
& ) override
;
287 /// Sfx item RES_CHRATR_CTL_WEIGHT
288 virtual void CharWeightCTL( const SvxWeightItem
& ) override
;
290 /// Sfx item RES_CHRATR_BidiRTL
291 virtual void CharBidiRTL( const SfxPoolItem
& rHt
) override
;
293 /// Sfx item RES_CHRATR_IdctHint
294 virtual void CharIdctHint( const SfxPoolItem
& rHt
) override
;
296 /// Sfx item RES_CHRATR_ROTATE
297 virtual void CharRotate( const SvxCharRotateItem
& ) override
;
299 /// Sfx item RES_CHRATR_EMPHASIS_MARK
300 virtual void CharEmphasisMark( const SvxEmphasisMarkItem
& rHt
) override
;
302 /// Sfx item RES_CHRATR_TWO_LINES
303 virtual void CharTwoLines( const SvxTwoLinesItem
& ) override
;
305 /// Sfx item RES_CHRATR_SCALEW
306 virtual void CharScaleWidth( const SvxCharScaleWidthItem
& ) override
;
308 /// Sfx item RES_CHRATR_RELIEF
309 virtual void CharRelief( const SvxCharReliefItem
& ) override
;
311 /// Sfx item RES_CHRATR_HIDDEN
312 virtual void CharHidden( const SvxCharHiddenItem
& ) override
;
314 /// Sfx item RES_CHRATR_BOX
315 virtual void CharBorder( const ::editeng::SvxBorderLine
* pAllBorder
, const sal_uInt16 nDist
, const bool bShadow
) override
;
317 /// Sfx item RES_CHRATR_HIGHLIGHT
318 virtual void CharHighlight( const SvxBrushItem
& ) override
;
320 /// Sfx item RES_TXTATR_INETFMT
321 virtual void TextINetFormat( const SwFormatINetFormat
& ) override
;
323 /// Sfx item RES_TXTATR_CHARFMT
324 virtual void TextCharFormat( const SwFormatCharFormat
& ) override
;
326 /// Sfx item RES_TXTATR_FTN
327 virtual void TextFootnote_Impl( const SwFormatFootnote
& ) override
;
329 /// Sfx item RES_PARATR_LINESPACING
330 virtual void ParaLineSpacing_Impl( short nSpace
, short nMulti
) override
;
332 /// Sfx item RES_PARATR_ADJUST
333 virtual void ParaAdjust( const SvxAdjustItem
& rHt
) override
;
335 /// Sfx item RES_PARATR_SPLIT
336 virtual void ParaSplit( const SvxFormatSplitItem
& ) override
;
338 /// Sfx item RES_PARATR_WIDOWS
339 virtual void ParaWidows( const SvxWidowsItem
& rHt
) override
;
341 /// Sfx item RES_PARATR_TABSTOP
342 virtual void ParaTabStop( const SvxTabStopItem
& rHt
) override
;
344 /// Sfx item RES_PARATR_HYPHENZONE
345 virtual void ParaHyphenZone( const SvxHyphenZoneItem
& ) override
;
347 /// Sfx item RES_PARATR_NUMRULE
348 virtual void ParaNumRule_Impl( const SwTextNode
*pTextNd
, sal_Int32 nLvl
, sal_Int32 nNumId
) override
;
350 /// Sfx item RES_PARATR_SCRIPTSPACE
351 virtual void ParaScriptSpace( const SfxBoolItem
& ) override
;
353 /// Sfx item RES_PARATR_HANGINGPUNCTUATION
354 virtual void ParaHangingPunctuation( const SfxBoolItem
& ) override
;
356 /// Sfx item RES_PARATR_FORBIDDEN_RULES
357 virtual void ParaForbiddenRules( const SfxBoolItem
& ) override
;
359 /// Sfx item RES_PARATR_VERTALIGN
360 virtual void ParaVerticalAlign( const SvxParaVertAlignItem
& ) override
;
362 /// Sfx item RES_PARATR_SNAPTOGRID
363 virtual void ParaSnapToGrid( const SvxParaGridItem
& ) override
;
365 /// Sfx item RES_FRM_SIZE
366 virtual void FormatFrameSize( const SwFormatFrameSize
& ) override
;
368 /// Sfx item RES_PAPER_BIN
369 virtual void FormatPaperBin( const SvxPaperBinItem
& ) override
;
371 /// Sfx item RES_MARGIN_FIRSTLINE
372 virtual void FormatFirstLineIndent(const SvxFirstLineIndentItem
& rFirstLine
) override
;
373 /// Sfx item RES_MARGIN_TEXTLEFT
374 virtual void FormatTextLeftMargin(const SvxTextLeftMarginItem
& rTextLeftMargin
) override
;
375 /// Sfx item RES_MARGIN_RIGHT
376 virtual void FormatRightMargin(const SvxRightMarginItem
& rRightMargin
) override
;
378 /// Sfx item RES_LR_SPACE
379 virtual void FormatLRSpace( const SvxLRSpaceItem
& ) override
;
381 /// Sfx item RES_UL_SPACE
382 virtual void FormatULSpace( const SvxULSpaceItem
& rHt
) override
;
384 /// Sfx item RES_SURROUND
385 virtual void FormatSurround( const SwFormatSurround
& ) override
;
387 /// Sfx item RES_VERT_ORIENT
388 virtual void FormatVertOrientation( const SwFormatVertOrient
& ) override
;
390 /// Sfx item RES_HORI_ORIENT
391 virtual void FormatHorizOrientation( const SwFormatHoriOrient
& ) override
;
393 /// Sfx item RES_ANCHOR
394 virtual void FormatAnchor( const SwFormatAnchor
& ) override
;
396 /// Sfx item RES_BACKGROUND
397 virtual void FormatBackground( const SvxBrushItem
& ) override
;
399 /// Sfx item RES_FILL_STYLE
400 virtual void FormatFillStyle( const XFillStyleItem
& ) override
;
402 /// Sfx item RES_FILL_GRADIENT
403 virtual void FormatFillGradient( const XFillGradientItem
& ) override
;
406 virtual void FormatBox( const SvxBoxItem
& ) override
;
409 virtual void FormatColumns_Impl( sal_uInt16 nCols
, const SwFormatCol
& rCol
, bool bEven
, SwTwips nPageSize
) override
;
411 /// Sfx item RES_KEEP
412 virtual void FormatKeep( const SvxFormatKeepItem
& ) override
;
414 /// Sfx item RES_TEXTGRID
415 virtual void FormatTextGrid( const SwTextGridItem
& ) override
;
417 /// Sfx item RES_LINENUMBER
418 virtual void FormatLineNumbering( const SwFormatLineNumber
& ) override
;
420 /// Sfx item RES_FRAMEDIR
421 virtual void FormatFrameDirection( const SvxFrameDirectionItem
& ) override
;
423 /// Sfx item RES_PARATR_GRABBAG
424 virtual void ParaGrabBag( const SfxGrabBagItem
& ) override
;
426 /// Sfx item RES_TXTATR_GRABBAG
427 virtual void CharGrabBag( const SfxGrabBagItem
& ) override
;
429 // Sfx item RES_PARATR_OUTLINELEVEL
430 virtual void ParaOutlineLevel( const SfxUInt16Item
& ) override
;
432 /// Write the expanded field
433 virtual void WriteExpand( const SwField
* pField
) override
;
435 virtual void RefField ( const SwField
& rField
, const OUString
& rRef
) override
;
436 virtual void HiddenField( const SwField
& rField
) override
;
437 virtual void SetField( const SwField
& rField
, ww::eField eType
, const OUString
& rCmd
) override
;
438 virtual void PostitField( const SwField
* pField
) override
;
439 virtual bool DropdownField( const SwField
* pField
) override
;
440 virtual bool PlaceholderField( const SwField
* pField
) override
;
442 virtual bool AnalyzeURL( const OUString
& rURL
, const OUString
& rTarget
, OUString
* pLinkURL
, OUString
* pMark
) override
;
444 virtual void WriteBookmarkInActParagraph( const OUString
& rName
, sal_Int32 nFirstRunPos
, sal_Int32 nLastRunPos
) override
;
446 void SectionRtlGutter( const SfxBoolItem
& rRtlGutter
) override
;
448 void TextLineBreak(const SwFormatLineBreak
& rLineBreak
) override
;
451 explicit WW8AttributeOutput( WW8Export
&rWW8Export
)
452 : AttributeOutputBase(rWW8Export
.GetWriter().GetMedia()->GetURLObject().GetMainURL(
453 INetURLObject::DecodeMechanism::NONE
))
454 , m_rWW8Export(rWW8Export
)
457 , m_nStyleStartSize(0)
459 , m_nStyleCountPos(0)
461 , mbOnTOXEnding(false)
462 , mbFillStyleIsSet(false)
466 /// Return the right export class.
467 virtual WW8Export
& GetExport() override
{ return m_rWW8Export
; }
470 /// Output the bold etc. attributes
471 void OutputWW8Attribute( sal_uInt8 nId
, bool bVal
);
473 /// Output the bold etc. attributes, the Complex Text Layout version
474 void OutputWW8AttributeCTL( sal_uInt8 nId
, bool bVal
);
476 void TableCellBorders(
477 ww8::WW8TableNodeInfoInner::Pointer_t
const & pTableTextNodeInfoInner
);
481 /// Reference to the export, where to get the data from
482 WW8Export
&m_rWW8Export
;
484 /// For output of styles.
486 /// We have to remember these positions between the StartStyle() and
488 sal_uInt16 m_nPOPosStdLen1
, m_nPOPosStdLen2
;
490 /// For output of styles.
492 /// We have to remember this position between StartStyleProperties() and
493 /// EndStyleProperties().
494 sal_uInt16 m_nStyleStartSize
, m_nStyleLenPos
;
496 /// For output of styles.
498 /// Used between StartStyles() and EndStyles().
499 sal_uLong m_nStyleCountPos
;
501 /// For output of run properties.
503 /// We have to remember the number of field results, and do not export end
504 /// of the field results if we were forced to split text.
505 sal_uInt16 m_nFieldResults
;
508 bool mbFillStyleIsSet
;
510 /// Bookmarks of the current paragraph
511 std::multimap
<sal_Int32
, OUString
> m_aBookmarksOfParagraphStart
;
512 std::multimap
<sal_Int32
, OUString
> m_aBookmarksOfParagraphEnd
;
514 editeng::WordPageMargins m_pageMargins
;
515 bool m_bFromEdge
= false;
518 #endif // INCLUDED_SW_SOURCE_FILTER_WW8_WW8ATTRIBUTEOUTPUT_HXX
520 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */