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 void StartParagraph( ww8::WW8TableNodeInfo::Pointer_t
/*pTextNodeInfo*/ ) override
{}
37 /// End of the paragraph.
38 virtual void EndParagraph( 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
, 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
) 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
) override
;
85 virtual bool EndURL(bool) override
;
87 virtual void FieldVanish( const OUString
& rText
, ww::eField eType
) 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( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo
) override
;
103 virtual void TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo
) override
;
104 virtual void TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo
) override
;
105 virtual void TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo
) override
;
106 virtual void TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo
) override
;
107 virtual void TableRowRedline( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo
) override
;
108 virtual void TableCellRedline( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo
) override
;
109 virtual void TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo
) override
;
110 virtual void TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo
) override
;
111 virtual void TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo
) override
;
112 virtual void TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo
) override
;
113 virtual void TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner
) override
;
114 virtual void TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
) override
;
115 virtual void TableSpacing( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
) override
;
116 virtual void TableRowEnd( sal_uInt32 nDepth
) override
;
118 /// Start of the styles table.
119 virtual void StartStyles() override
;
121 /// End of the styles table.
122 virtual void EndStyles( sal_uInt16 nNumberOfStyles
) override
;
124 /// Write default style.
125 virtual void DefaultStyle() override
;
127 /// Start of a style in the styles table.
128 virtual void StartStyle( const OUString
& rName
, StyleType eType
,
129 sal_uInt16 nBase
, sal_uInt16 nNext
, sal_uInt16 nWwIdi
, sal_uInt16 nId
,
130 bool bAutoUpdate
) override
;
132 /// End of a style in the styles table.
133 virtual void EndStyle() override
;
135 /// Start of (paragraph or run) properties of a style.
136 virtual void StartStyleProperties( bool bParProp
, sal_uInt16 nStyle
) override
;
138 /// End of (paragraph or run) properties of a style.
139 virtual void EndStyleProperties( bool bParProp
) override
;
141 /// Numbering rule and Id.
142 virtual void OutlineNumbering(sal_uInt8 nLvl
) override
;
145 /// As a paragraph property - the paragraph should be on the next page.
146 virtual void PageBreakBefore( bool bBreak
) override
;
148 /// Write a section break
149 /// msword::ColumnBreak or msword::PageBreak
150 virtual void SectionBreak( sal_uInt8 nC
, bool bBreakAfter
, const WW8_SepInfo
* pSectionInfo
= nullptr ) override
;
152 // preserve DOC page vertical alignment
153 virtual void TextVerticalAdjustment( const css::drawing::TextVerticalAdjust
) override
;
155 /// Start of the section properties.
156 virtual void StartSection() override
;
158 // footnote / endnote section properties
159 virtual void SectFootnoteEndnotePr() override
;
161 /// End of the section properties.
163 /// No-op for binary filters.
164 virtual void EndSection() override
{}
166 /// Protection of forms.
167 virtual void SectionFormProtection( bool bProtected
) override
;
169 /// Numbering of the lines in the document.
170 virtual void SectionLineNumbering( sal_uLong nRestartNo
, const SwLineNumberInfo
& rLnNumInfo
) override
;
172 /// Has different headers/footers for the title page.
173 virtual void SectionTitlePage() override
;
175 /// Description of the page borders.
176 virtual void SectionPageBorders( const SwFrameFormat
* pFormat
, const SwFrameFormat
* pFirstPageFormat
) override
;
178 /// Columns populated from right/numbers on the right side?
179 virtual void SectionBiDi( bool bBiDi
) override
;
181 /// The style of the page numbers.
183 virtual void SectionPageNumbering( sal_uInt16 nNumType
, const ::std::optional
<sal_uInt16
>& oPageRestartNumber
) override
;
185 /// The type of breaking.
186 virtual void SectionType( sal_uInt8 nBreakCode
) override
;
188 /// Definition of a numbering instance.
189 virtual void NumberingDefinition( sal_uInt16 nId
, const SwNumRule
&rRule
) override
;
191 /// All the numbering level information.
192 virtual void NumberingLevel( sal_uInt8 nLevel
,
194 sal_uInt16 nNumberingType
,
196 const sal_uInt8
*pNumLvlPos
,
199 const SfxItemSet
*pOutSet
,
201 sal_Int16 nFirstLineIndex
,
202 sal_Int16 nListTabPos
,
203 const OUString
&rNumberingString
,
204 const SvxBrushItem
* pBrush
) override
; //For i120928,transfer graphic of bullet
207 /// Output frames - the implementation.
208 void OutputFlyFrame_Impl( const ww8::Frame
& rFormat
, const Point
& rNdTopLeft
) override
;
210 /// Sfx item Sfx item RES_CHRATR_CASEMAP
211 virtual void CharCaseMap( const SvxCaseMapItem
& ) override
;
213 /// Sfx item Sfx item RES_CHRATR_COLOR
214 virtual void CharColor( const SvxColorItem
& ) override
;
216 /// Sfx item Sfx item RES_CHRATR_CONTOUR
217 virtual void CharContour( const SvxContourItem
& ) override
;
219 /// Sfx item RES_CHRATR_CROSSEDOUT
220 virtual void CharCrossedOut( const SvxCrossedOutItem
& rHt
) override
;
222 /// Sfx item RES_CHRATR_ESCAPEMENT
223 virtual void CharEscapement( const SvxEscapementItem
& ) override
;
225 /// Sfx item RES_CHRATR_FONT
226 virtual void CharFont( const SvxFontItem
& ) override
;
228 /// Sfx item RES_CHRATR_FONTSIZE
229 virtual void CharFontSize( const SvxFontHeightItem
& ) override
;
231 /// Sfx item RES_CHRATR_KERNING
232 virtual void CharKerning( const SvxKerningItem
& ) override
;
234 /// Sfx item RES_CHRATR_LANGUAGE
235 virtual void CharLanguage( const SvxLanguageItem
& ) override
;
237 /// Sfx item RES_CHRATR_POSTURE
238 virtual void CharPosture( const SvxPostureItem
& ) override
;
240 /// Sfx item RES_CHRATR_SHADOWED
241 virtual void CharShadow( const SvxShadowedItem
& ) override
;
243 /// Sfx item RES_CHRATR_UNDERLINE
244 virtual void CharUnderline( const SvxUnderlineItem
& ) override
;
246 /// Sfx item RES_CHRATR_WEIGHT
247 virtual void CharWeight( const SvxWeightItem
& ) override
;
249 /// Sfx item RES_CHRATR_AUTOKERN
250 virtual void CharAutoKern( const SvxAutoKernItem
& ) override
;
252 /// Sfx item RES_CHRATR_BLINK
253 virtual void CharAnimatedText( const SvxBlinkItem
& ) override
;
255 /// Sfx item RES_CHRATR_BACKGROUND
256 virtual void CharBackground( const SvxBrushItem
& ) override
;
258 /// Sfx item RES_CHRATR_CJK_FONT
259 virtual void CharFontCJK( const SvxFontItem
& ) override
;
261 /// Sfx item RES_CHRATR_CJK_FONTSIZE
262 virtual void CharFontSizeCJK( const SvxFontHeightItem
& rHt
) override
{ CharFontSize( rHt
); }
264 /// Sfx item RES_CHRATR_CJK_LANGUAGE
265 virtual void CharLanguageCJK( const SvxLanguageItem
& rHt
) override
{ CharLanguage( rHt
); }
267 /// Sfx item RES_CHRATR_CJK_POSTURE
268 virtual void CharPostureCJK( const SvxPostureItem
& rHt
) override
{ CharPosture( rHt
); }
270 /// Sfx item RES_CHRATR_CJK_WEIGHT
271 virtual void CharWeightCJK( const SvxWeightItem
& rHt
) override
{ CharWeight( rHt
); }
273 /// Sfx item RES_CHRATR_CTL_FONT
274 virtual void CharFontCTL( const SvxFontItem
& ) override
;
276 /// Sfx item RES_CHRATR_CTL_FONTSIZE
277 virtual void CharFontSizeCTL( const SvxFontHeightItem
& rHt
) override
{ CharFontSize( rHt
); }
279 /// Sfx item RES_CHRATR_CTL_LANGUAGE
280 virtual void CharLanguageCTL( const SvxLanguageItem
& rHt
) override
{ CharLanguage( rHt
); }
282 /// Sfx item RES_CHRATR_CTL_POSTURE
283 virtual void CharPostureCTL( const SvxPostureItem
& ) override
;
285 /// Sfx item RES_CHRATR_CTL_WEIGHT
286 virtual void CharWeightCTL( const SvxWeightItem
& ) override
;
288 /// Sfx item RES_CHRATR_BidiRTL
289 virtual void CharBidiRTL( const SfxPoolItem
& rHt
) override
;
291 /// Sfx item RES_CHRATR_IdctHint
292 virtual void CharIdctHint( const SfxPoolItem
& rHt
) override
;
294 /// Sfx item RES_CHRATR_ROTATE
295 virtual void CharRotate( const SvxCharRotateItem
& ) override
;
297 /// Sfx item RES_CHRATR_EMPHASIS_MARK
298 virtual void CharEmphasisMark( const SvxEmphasisMarkItem
& rHt
) override
;
300 /// Sfx item RES_CHRATR_TWO_LINES
301 virtual void CharTwoLines( const SvxTwoLinesItem
& ) override
;
303 /// Sfx item RES_CHRATR_SCALEW
304 virtual void CharScaleWidth( const SvxCharScaleWidthItem
& ) override
;
306 /// Sfx item RES_CHRATR_RELIEF
307 virtual void CharRelief( const SvxCharReliefItem
& ) override
;
309 /// Sfx item RES_CHRATR_HIDDEN
310 virtual void CharHidden( const SvxCharHiddenItem
& ) override
;
312 /// Sfx item RES_CHRATR_BOX
313 virtual void CharBorder( const ::editeng::SvxBorderLine
* pAllBorder
, const sal_uInt16 nDist
, const bool bShadow
) override
;
315 /// Sfx item RES_CHRATR_HIGHLIGHT
316 virtual void CharHighlight( const SvxBrushItem
& ) override
;
318 /// Sfx item RES_TXTATR_INETFMT
319 virtual void TextINetFormat( const SwFormatINetFormat
& ) override
;
321 /// Sfx item RES_TXTATR_CHARFMT
322 virtual void TextCharFormat( const SwFormatCharFormat
& ) override
;
324 /// Sfx item RES_TXTATR_FTN
325 virtual void TextFootnote_Impl( const SwFormatFootnote
& ) override
;
327 /// Sfx item RES_PARATR_LINESPACING
328 virtual void ParaLineSpacing_Impl( short nSpace
, short nMulti
) override
;
330 /// Sfx item RES_PARATR_ADJUST
331 virtual void ParaAdjust( const SvxAdjustItem
& rHt
) override
;
333 /// Sfx item RES_PARATR_SPLIT
334 virtual void ParaSplit( const SvxFormatSplitItem
& ) override
;
336 /// Sfx item RES_PARATR_WIDOWS
337 virtual void ParaWidows( const SvxWidowsItem
& rHt
) override
;
339 /// Sfx item RES_PARATR_TABSTOP
340 virtual void ParaTabStop( const SvxTabStopItem
& rHt
) override
;
342 /// Sfx item RES_PARATR_HYPHENZONE
343 virtual void ParaHyphenZone( const SvxHyphenZoneItem
& ) override
;
345 /// Sfx item RES_PARATR_NUMRULE
346 virtual void ParaNumRule_Impl( const SwTextNode
*pTextNd
, sal_Int32 nLvl
, sal_Int32 nNumId
) override
;
348 /// Sfx item RES_PARATR_SCRIPTSPACE
349 virtual void ParaScriptSpace( const SfxBoolItem
& ) override
;
351 /// Sfx item RES_PARATR_HANGINGPUNCTUATION
352 virtual void ParaHangingPunctuation( const SfxBoolItem
& ) override
;
354 /// Sfx item RES_PARATR_FORBIDDEN_RULES
355 virtual void ParaForbiddenRules( const SfxBoolItem
& ) override
;
357 /// Sfx item RES_PARATR_VERTALIGN
358 virtual void ParaVerticalAlign( const SvxParaVertAlignItem
& ) override
;
360 /// Sfx item RES_PARATR_SNAPTOGRID
361 virtual void ParaSnapToGrid( const SvxParaGridItem
& ) override
;
363 /// Sfx item RES_FRM_SIZE
364 virtual void FormatFrameSize( const SwFormatFrameSize
& ) override
;
366 /// Sfx item RES_PAPER_BIN
367 virtual void FormatPaperBin( const SvxPaperBinItem
& ) override
;
369 /// Sfx item RES_LR_SPACE
370 virtual void FormatLRSpace( const SvxLRSpaceItem
& ) override
;
372 /// Sfx item RES_UL_SPACE
373 virtual void FormatULSpace( const SvxULSpaceItem
& rHt
) override
;
375 /// Sfx item RES_SURROUND
376 virtual void FormatSurround( const SwFormatSurround
& ) override
;
378 /// Sfx item RES_VERT_ORIENT
379 virtual void FormatVertOrientation( const SwFormatVertOrient
& ) override
;
381 /// Sfx item RES_HORI_ORIENT
382 virtual void FormatHorizOrientation( const SwFormatHoriOrient
& ) override
;
384 /// Sfx item RES_ANCHOR
385 virtual void FormatAnchor( const SwFormatAnchor
& ) override
;
387 /// Sfx item RES_BACKGROUND
388 virtual void FormatBackground( const SvxBrushItem
& ) override
;
390 /// Sfx item RES_FILL_STYLE
391 virtual void FormatFillStyle( const XFillStyleItem
& ) override
;
393 /// Sfx item RES_FILL_GRADIENT
394 virtual void FormatFillGradient( const XFillGradientItem
& ) override
;
397 virtual void FormatBox( const SvxBoxItem
& ) override
;
400 virtual void FormatColumns_Impl( sal_uInt16 nCols
, const SwFormatCol
& rCol
, bool bEven
, SwTwips nPageSize
) override
;
402 /// Sfx item RES_KEEP
403 virtual void FormatKeep( const SvxFormatKeepItem
& ) override
;
405 /// Sfx item RES_TEXTGRID
406 virtual void FormatTextGrid( const SwTextGridItem
& ) override
;
408 /// Sfx item RES_LINENUMBER
409 virtual void FormatLineNumbering( const SwFormatLineNumber
& ) override
;
411 /// Sfx item RES_FRAMEDIR
412 virtual void FormatFrameDirection( const SvxFrameDirectionItem
& ) override
;
414 /// Sfx item RES_PARATR_GRABBAG
415 virtual void ParaGrabBag( const SfxGrabBagItem
& ) override
;
417 /// Sfx item RES_TXTATR_GRABBAG
418 virtual void CharGrabBag( const SfxGrabBagItem
& ) override
;
420 // Sfx item RES_PARATR_OUTLINELEVEL
421 virtual void ParaOutlineLevel( const SfxUInt16Item
& ) override
;
423 /// Write the expanded field
424 virtual void WriteExpand( const SwField
* pField
) override
;
426 virtual void RefField ( const SwField
& rField
, const OUString
& rRef
) override
;
427 virtual void HiddenField( const SwField
& rField
) override
;
428 virtual void SetField( const SwField
& rField
, ww::eField eType
, const OUString
& rCmd
) override
;
429 virtual void PostitField( const SwField
* pField
) override
;
430 virtual bool DropdownField( const SwField
* pField
) override
;
431 virtual bool PlaceholderField( const SwField
* pField
) override
;
433 virtual bool AnalyzeURL( const OUString
& rURL
, const OUString
& rTarget
, OUString
* pLinkURL
, OUString
* pMark
) override
;
435 virtual void WriteBookmarkInActParagraph( const OUString
& rName
, sal_Int32 nFirstRunPos
, sal_Int32 nLastRunPos
) override
;
437 /// Reference to the export, where to get the data from
438 WW8Export
&m_rWW8Export
;
440 /// For output of styles.
442 /// We have to remember these positions between the StartStyle() and
444 sal_uInt16 nPOPosStdLen1
, nPOPosStdLen2
;
446 /// For output of styles.
448 /// We have to remember this position between StartStyleProperties() and
449 /// EndStyleProperties().
450 sal_uInt16 m_nStyleStartSize
, m_nStyleLenPos
;
452 /// For output of styles.
454 /// Used between StartStyles() and EndStyles().
455 sal_uLong m_nStyleCountPos
;
457 /// For output of run properties.
459 /// We have to remember the number of field results, and do not export end
460 /// of the field results if we were forced to split text.
461 sal_uInt16 m_nFieldResults
;
465 /// Bookmarks of the current paragraph
466 std::multimap
<sal_Int32
, OUString
> m_aBookmarksOfParagraphStart
;
467 std::multimap
<sal_Int32
, OUString
> m_aBookmarksOfParagraphEnd
;
470 explicit WW8AttributeOutput( WW8Export
&rWW8Export
)
471 : AttributeOutputBase(rWW8Export
.GetWriter().GetMedia()->GetURLObject().GetMainURL(
472 INetURLObject::DecodeMechanism::NONE
))
473 , m_rWW8Export(rWW8Export
)
476 , m_nStyleStartSize(0)
478 , m_nStyleCountPos(0)
480 , mbOnTOXEnding(false)
484 /// Return the right export class.
485 virtual WW8Export
& GetExport() override
{ return m_rWW8Export
; }
488 /// Output the bold etc. attributes
489 void OutputWW8Attribute( sal_uInt8 nId
, bool bVal
);
491 /// Output the bold etc. attributes, the Complex Text Layout version
492 void OutputWW8AttributeCTL( sal_uInt8 nId
, bool bVal
);
494 void TableCellBorders(
495 ww8::WW8TableNodeInfoInner::Pointer_t
const & pTableTextNodeInfoInner
);
499 editeng::WordPageMargins m_pageMargins
;
500 bool m_bFromEdge
= false;
504 #endif // INCLUDED_SW_SOURCE_FILTER_WW8_WW8ATTRIBUTEOUTPUT_HXX
506 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */