1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DOCXATTRIBUTEOUTPUT_HXX_
32 #define _DOCXATTRIBUTEOUTPUT_HXX_
34 #include "attributeoutputbase.hxx"
37 #include <sax/fshelper.hxx>
38 #include <sax/fastattribs.hxx>
39 #include <vcl/vclenum.hxx>
49 namespace docx
{ class FootnotesList
; }
50 namespace oox
{ namespace drawingml
{ class DrawingML
; } }
54 const SwField
* pField
;
61 enum DocxColBreakStatus
68 class DocxAttributeOutput
: public AttributeOutputBase
71 /// Export the state of RTL/CJK.
72 virtual void RTLAndCJKState( bool bIsRTL
, sal_uInt16 nScript
);
74 /// Start of the paragraph.
75 virtual void StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo
);
77 /// End of the paragraph.
78 virtual void EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner
);
81 virtual void EmptyParagraph();
83 /// Called before we start outputting the attributes.
84 virtual void StartParagraphProperties( const SwTxtNode
& rNode
);
86 /// Called after we end outputting the attributes.
87 virtual void EndParagraphProperties();
89 /// Start of the text run.
90 virtual void StartRun( const SwRedlineData
* pRedlineData
);
92 /// End of the text run.
93 virtual void EndRun();
95 /// Called before we start outputting the attributes.
96 virtual void StartRunProperties();
98 /// Called after we end outputting the attributes.
99 virtual void EndRunProperties( const SwRedlineData
* pRedlineData
);
101 /// Output text (inside a run).
102 virtual void RunText( const String
& rText
, rtl_TextEncoding eCharSet
= RTL_TEXTENCODING_UTF8
);
104 /// Output text (without markup).
105 virtual void RawText( const String
& rText
, bool bForceUnicode
, rtl_TextEncoding eCharSet
);
107 /// Output ruby start.
108 virtual void StartRuby( const SwTxtNode
& rNode
, const SwFmtRuby
& rRuby
);
111 virtual void EndRuby();
113 /// Output URL start.
114 virtual bool StartURL( const String
& rUrl
, const String
& rTarget
);
117 virtual bool EndURL();
119 virtual void FieldVanish( const String
& rTxt
, ww::eField eType
);
121 /// Output redlining.
123 /// The common attribute that can be among the run properties.
124 virtual void Redline( const SwRedlineData
* pRedline
);
126 /// Output redlining.
128 /// Start of the tag that encloses the run, fills the info according to
129 /// the value of m_pRedlineData.
130 void StartRedline( const SwRedlineData
* pRedlineData
);
132 /// Output redlining.
134 /// End of the tag that encloses the run.
137 virtual void FormatDrop( const SwTxtNode
& rNode
, const SwFmtDrop
& rSwFmtDrop
, USHORT nStyle
, ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo
, ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner
);
140 virtual void ParagraphStyle( USHORT nStyle
);
142 virtual void TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
);
144 virtual void TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
);
146 virtual void TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
);
148 virtual void TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
);
150 virtual void TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
);
152 virtual void TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
);
154 virtual void TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
);
156 virtual void TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
);
158 virtual void TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
);
160 virtual void TableNodeInfo( ww8::WW8TableNodeInfo::Pointer_t pNodeInfo
);
162 virtual void TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner
);
164 virtual void TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
);
166 virtual void TableRowEnd( sal_uInt32 nDepth
= 1 );
168 /// Start of the styles table.
169 virtual void StartStyles();
171 /// End of the styles table.
172 virtual void EndStyles( USHORT nNumberOfStyles
);
174 /// Write default style.
175 virtual void DefaultStyle( USHORT nStyle
);
177 /// Start of a style in the styles table.
178 virtual void StartStyle( const String
& rName
, bool bPapFmt
,
179 USHORT nBase
, USHORT nNext
, USHORT nWwId
, USHORT nId
);
181 /// End of a style in the styles table.
182 virtual void EndStyle();
184 /// Start of (paragraph or run) properties of a style.
185 virtual void StartStyleProperties( bool bParProp
, USHORT nStyle
);
187 /// End of (paragraph or run) properties of a style.
188 virtual void EndStyleProperties( bool bParProp
);
190 /// Numbering rule and Id.
191 virtual void OutlineNumbering( BYTE nLvl
, const SwNumFmt
&rNFmt
, const SwFmt
&rFmt
);
194 /// As a paragraph property - the paragraph should be on the next page.
195 virtual void PageBreakBefore( bool bBreak
);
197 /// Write a section break
198 /// msword::ColumnBreak or msword::PageBreak
199 virtual void SectionBreak( BYTE nC
, const WW8_SepInfo
* pSectionInfo
= NULL
);
201 /// Start of the section properties.
202 virtual void StartSection();
204 /// End of the section properties.
205 virtual void EndSection();
207 /// Protection of forms.
208 virtual void SectionFormProtection( bool bProtected
);
210 /// Numbering of the lines in the document.
211 virtual void SectionLineNumbering( ULONG nRestartNo
, const SwLineNumberInfo
& rLnNumInfo
);
213 /// Has different headers/footers for the title page.
214 virtual void SectionTitlePage();
216 /// Description of the page borders.
217 virtual void SectionPageBorders( const SwFrmFmt
* pFmt
, const SwFrmFmt
* pFirstPageFmt
);
219 /// Columns populated from right/numbers on the right side?
220 virtual void SectionBiDi( bool bBiDi
);
222 /// The style of the page numbers.
224 /// nPageRestartNumberr being 0 means no restart.
225 virtual void SectionPageNumbering( USHORT nNumType
, USHORT nPageRestartNumber
);
227 /// The type of breaking.
228 virtual void SectionType( BYTE nBreakCode
);
231 void StartFont( const String
& rFamilyName
) const;
234 void EndFont() const;
236 /// Alternate name for the font.
237 void FontAlternateName( const String
& rName
) const;
240 void FontCharset( sal_uInt8 nCharSet
) const;
243 void FontFamilyType( FontFamily eFamily
) const;
246 void FontPitchType( FontPitch ePitch
) const;
248 /// Definition of a numbering instance.
249 virtual void NumberingDefinition( USHORT nId
, const SwNumRule
&rRule
);
251 /// Start of the abstract numbering definition instance.
252 virtual void StartAbstractNumbering( USHORT nId
);
254 /// End of the abstract numbering definition instance.
255 virtual void EndAbstractNumbering();
257 /// All the numbering level information.
258 virtual void NumberingLevel( BYTE nLevel
,
260 USHORT nNumberingType
,
262 const BYTE
*pNumLvlPos
,
265 const SfxItemSet
*pOutSet
,
267 sal_Int16 nFirstLineIndex
,
268 sal_Int16 nListTabPos
,
269 const String
&rNumberingString
);
271 void WriteField_Impl( const SwField
* pFld
, ww::eField eType
, const String
& rFldCmd
, BYTE nMode
);
273 void WriteBookmarks_Impl( std::vector
< rtl::OUString
>& rStarts
, std::vector
< rtl::OUString
>& rEnds
);
276 /// Initialize the structures where we are going to collect some of the paragraph properties.
278 /// Some of the properties have to be collected from more sources, and are
279 /// actually not written between StartParagraphProperties and
280 /// EndParagraphProperties. They are output in this method, which is
281 /// supposed to be called just before outputting </rPr> whenever it is done.
282 void InitCollectedParagraphProperties();
284 /// Output what we collected during the run properties output.
286 /// @see WriteCollectedParagrapProperties().
287 void WriteCollectedParagraphProperties();
289 /// Initialize the structures where we are going to collect some of the run properties.
291 /// This is an equivalent of InitCollectedParagraphProperties(), resp.
292 /// WriteCollectectedParagraphProperties().
294 /// @see InitCollectedParagraphProperties().
295 void InitCollectedRunProperties();
297 /// Output what we collected during the run properties output.
299 /// @see InitCollectedRunProperies(), WriteCollectedParagraphProperties()
300 void WriteCollectedRunProperties();
302 /// Output graphic fly frames.
303 void FlyFrameGraphic( const SwGrfNode
& rGrfNode
, const Size
& rSize
);
305 void InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
);
307 void StartTable( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
);
309 void StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
);
311 void StartTableCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
);
313 void TableCellProperties( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner
);
315 void EndTableCell( );
321 /// End cell, row, and even the entire table if necessary.
322 void FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t pInner
, bool bForceEmptyParagraph
= false );
326 /// Output frames - the implementation.
327 virtual void OutputFlyFrame_Impl( const sw::Frame
& rFmt
, const Point
& rNdTopLeft
);
329 /// Sfx item Sfx item RES_CHRATR_CASEMAP
330 virtual void CharCaseMap( const SvxCaseMapItem
& rCaseMap
);
332 /// Sfx item Sfx item RES_CHRATR_COLOR
333 virtual void CharColor( const SvxColorItem
& rColor
);
335 /// Sfx item Sfx item RES_CHRATR_CONTOUR
336 virtual void CharContour( const SvxContourItem
& rContour
);
338 /// Sfx item RES_CHRATR_CROSSEDOUT
339 virtual void CharCrossedOut( const SvxCrossedOutItem
& rCrossedOut
);
341 /// Sfx item RES_CHRATR_ESCAPEMENT
342 virtual void CharEscapement( const SvxEscapementItem
& rEscapement
);
344 /// Sfx item RES_CHRATR_FONT
345 virtual void CharFont( const SvxFontItem
& rFont
);
347 /// Sfx item RES_CHRATR_FONTSIZE
348 virtual void CharFontSize( const SvxFontHeightItem
& rFontSize
);
350 /// Sfx item RES_CHRATR_KERNING
351 virtual void CharKerning( const SvxKerningItem
& rKerning
);
353 /// Sfx item RES_CHRATR_LANGUAGE
354 virtual void CharLanguage( const SvxLanguageItem
& rLanguage
);
356 /// Sfx item RES_CHRATR_POSTURE
357 virtual void CharPosture( const SvxPostureItem
& rPosture
);
359 /// Sfx item RES_CHRATR_SHADOWED
360 virtual void CharShadow( const SvxShadowedItem
& rShadow
);
362 /// Sfx item RES_CHRATR_UNDERLINE
363 virtual void CharUnderline( const SvxUnderlineItem
& rUnderline
);
365 /// Sfx item RES_CHRATR_WEIGHT
366 virtual void CharWeight( const SvxWeightItem
& rWeight
);
368 /// Sfx item RES_CHRATR_AUTOKERN
369 virtual void CharAutoKern( const SvxAutoKernItem
& );
371 /// Sfx item RES_CHRATR_BLINK
372 virtual void CharAnimatedText( const SvxBlinkItem
& rBlink
);
374 /// Sfx item RES_CHRATR_BACKGROUND
375 virtual void CharBackground( const SvxBrushItem
& rBrush
);
377 /// Sfx item RES_CHRATR_CJK_FONT
378 virtual void CharFontCJK( const SvxFontItem
& rFont
);
380 /// Sfx item RES_CHRATR_CJK_FONTSIZE
381 virtual void CharFontSizeCJK( const SvxFontHeightItem
& rFontSize
) { CharFontSize( rFontSize
); }
383 /// Sfx item RES_CHRATR_CJK_LANGUAGE
384 virtual void CharLanguageCJK( const SvxLanguageItem
& rLanguageItem
) { CharLanguage( rLanguageItem
); }
386 /// Sfx item RES_CHRATR_CJK_POSTURE
387 virtual void CharPostureCJK( const SvxPostureItem
& rPosture
);
389 /// Sfx item RES_CHRATR_CJK_WEIGHT
390 virtual void CharWeightCJK( const SvxWeightItem
& rWeight
);
392 /// Sfx item RES_CHRATR_CTL_FONT
393 virtual void CharFontCTL( const SvxFontItem
& rFont
);
395 /// Sfx item RES_CHRATR_CTL_FONTSIZE
396 virtual void CharFontSizeCTL( const SvxFontHeightItem
& rFontSize
) { CharFontSize( rFontSize
); }
398 /// Sfx item RES_CHRATR_CTL_LANGUAGE
399 virtual void CharLanguageCTL( const SvxLanguageItem
& rLanguageItem
) { CharLanguage( rLanguageItem
); }
401 /// Sfx item RES_CHRATR_CTL_POSTURE
402 virtual void CharPostureCTL( const SvxPostureItem
& rWeight
);
404 /// Sfx item RES_CHRATR_CTL_WEIGHT
405 virtual void CharWeightCTL( const SvxWeightItem
& rWeight
);
407 /// Sfx item RES_CHRATR_ROTATE
408 virtual void CharRotate( const SvxCharRotateItem
& rRotate
);
410 /// Sfx item RES_CHRATR_EMPHASIS_MARK
411 virtual void CharEmphasisMark( const SvxEmphasisMarkItem
& rEmphasisMark
);
413 /// Sfx item RES_CHRATR_TWO_LINES
414 virtual void CharTwoLines( const SvxTwoLinesItem
& rTwoLines
);
416 /// Sfx item RES_CHRATR_SCALEW
417 virtual void CharScaleWidth( const SvxCharScaleWidthItem
& rScaleWidth
);
419 /// Sfx item RES_CHRATR_RELIEF
420 virtual void CharRelief( const SvxCharReliefItem
& rRelief
);
422 /// Sfx item RES_CHRATR_HIDDEN
423 virtual void CharHidden( const SvxCharHiddenItem
& rHidden
);
425 /// Sfx item RES_TXTATR_INETFMT
426 virtual void TextINetFormat( const SwFmtINetFmt
& );
428 /// Sfx item RES_TXTATR_CHARFMT
429 virtual void TextCharFormat( const SwFmtCharFmt
& );
431 /// Sfx item RES_TXTATR_FTN
432 virtual void TextFootnote_Impl( const SwFmtFtn
& );
434 /// Output the footnote/endnote reference (if there's one to output).
435 void FootnoteEndnoteReference();
437 /// Sfx item RES_PARATR_LINESPACING
438 virtual void ParaLineSpacing_Impl( short nSpace
, short nMulti
);
440 /// Sfx item RES_PARATR_ADJUST
441 virtual void ParaAdjust( const SvxAdjustItem
& rAdjust
);
443 /// Sfx item RES_PARATR_SPLIT
444 virtual void ParaSplit( const SvxFmtSplitItem
& rSplit
);
446 /// Sfx item RES_PARATR_WIDOWS
447 virtual void ParaWidows( const SvxWidowsItem
& rWidows
);
449 /// Sfx item RES_PARATR_TABSTOP
450 virtual void ParaTabStop( const SvxTabStopItem
& rTabStop
);
452 /// Sfx item RES_PARATR_HYPHENZONE
453 virtual void ParaHyphenZone( const SvxHyphenZoneItem
& );
455 /// Sfx item RES_PARATR_NUMRULE
456 virtual void ParaNumRule_Impl( const SwTxtNode
*pTxtNd
, sal_Int32 nLvl
, sal_Int32 nNumId
);
458 /// Sfx item RES_PARATR_SCRIPTSPACE
459 virtual void ParaScriptSpace( const SfxBoolItem
& );
461 /// Sfx item RES_PARATR_VERTALIGN
462 virtual void ParaVerticalAlign( const SvxParaVertAlignItem
& rAlign
);
464 /// Sfx item RES_PARATR_SNAPTOGRID
465 virtual void ParaSnapToGrid( const SvxParaGridItem
& );
467 /// Sfx item RES_FRM_SIZE
468 virtual void FormatFrameSize( const SwFmtFrmSize
& );
470 /// Sfx item RES_PAPER_BIN
471 virtual void FormatPaperBin( const SvxPaperBinItem
& );
473 /// Sfx item RES_LR_SPACE
474 virtual void FormatLRSpace( const SvxLRSpaceItem
& rLRSpace
);
476 /// Sfx item RES_UL_SPACE
477 virtual void FormatULSpace( const SvxULSpaceItem
& rULSpace
);
479 /// Sfx item RES_SURROUND
480 virtual void FormatSurround( const SwFmtSurround
& );
482 /// Sfx item RES_VERT_ORIENT
483 virtual void FormatVertOrientation( const SwFmtVertOrient
& );
485 /// Sfx item RES_HORI_ORIENT
486 virtual void FormatHorizOrientation( const SwFmtHoriOrient
& );
488 /// Sfx item RES_ANCHOR
489 virtual void FormatAnchor( const SwFmtAnchor
& );
491 /// Sfx item RES_BACKGROUND
492 virtual void FormatBackground( const SvxBrushItem
& );
495 virtual void FormatBox( const SvxBoxItem
& );
498 virtual void FormatColumns_Impl( USHORT nCols
, const SwFmtCol
& rCol
, bool bEven
, SwTwips nPageSize
);
500 /// Sfx item RES_KEEP
501 virtual void FormatKeep( const SvxFmtKeepItem
& );
503 /// Sfx item RES_TEXTGRID
504 virtual void FormatTextGrid( const SwTextGridItem
& );
506 /// Sfx item RES_LINENUMBER
507 virtual void FormatLineNumbering( const SwFmtLineNumber
& );
509 /// Sfx item RES_FRAMEDIR
510 virtual void FormatFrameDirection( const SvxFrameDirectionItem
& );
512 /// Write the expanded field
513 virtual void WriteExpand( const SwField
* pFld
);
515 virtual void RefField( const SwField
& rFld
, const String
& rRef
);
516 virtual void HiddenField( const SwField
& rFld
);
517 virtual void SetField( const SwField
& rFld
, ww::eField eType
, const String
& rCmd
);
518 virtual void PostitField( const SwField
* pFld
);
519 virtual bool DropdownField( const SwField
* pFld
);
521 virtual bool AnalyzeURL( const String
& rURL
, const String
& rTarget
, String
* pLinkURL
, String
* pMark
);
523 /// Reference to the export, where to get the data from
524 DocxExport
&m_rExport
;
526 /// Fast serializer to output the data
527 ::sax_fastparser::FSHelperPtr m_pSerializer
;
530 oox::drawingml::DrawingML
&m_rDrawingML
;
534 void DoWriteBookmarks( );
536 void StartField_Impl( FieldInfos
& rInfos
, sal_Bool bWriteRun
= sal_False
);
537 void DoWriteCmd( String
& rCmd
);
538 void CmdField_Impl( FieldInfos
& rInfos
);
539 void EndField_Impl( FieldInfos
& rInfos
);
541 ::sax_fastparser::FastAttributeList
*m_pFontsAttrList
, *m_pEastAsianLayoutAttrList
;
542 ::sax_fastparser::FastAttributeList
*m_pCharLangAttrList
;
543 ::sax_fastparser::FastAttributeList
*m_pSpacingAttrList
;
544 ::sax_fastparser::FastAttributeList
*m_pHyperlinkAttrList
;
546 ::docx::FootnotesList
*m_pFootnotesList
;
547 ::docx::FootnotesList
*m_pEndnotesList
;
549 const WW8_SepInfo
*m_pSectionInfo
;
551 /// Redline data to remember in the text run.
552 const SwRedlineData
*m_pRedlineData
;
554 /// Id of the redline
555 sal_Int32 m_nRedlineId
;
557 /// Flag indicating that the section properties are being written
558 sal_Bool m_bOpenedSectPr
;
560 /// Field data to remember in the text run
561 std::vector
< FieldInfos
> m_Fields
;
563 sal_Int32 m_nNextMarkId
;
565 /// Bookmarks to output
566 std::vector
<rtl::OString
> m_rMarksStart
;
567 std::vector
<rtl::OString
> m_rMarksEnd
;
569 /// Maps of the bookmarks ids
570 std::map
<rtl::OString
, USHORT
> m_rOpenedMarksIds
;
572 /// The current table helper
573 SwWriteTable
*m_pTableWrt
;
575 /// Remember if we are in an open cell, or not.
576 bool m_bTableCellOpen
;
578 /// Remember the current table depth.
579 sal_uInt32 m_nTableDepth
;
581 bool m_bParagraphOpened
;
583 // Remember that a column break has to be opened at the
584 // beginning of the next paragraph
585 DocxColBreakStatus m_nColBreakStatus
;
588 DocxAttributeOutput( DocxExport
&rExport
, ::sax_fastparser::FSHelperPtr pSerializer
, oox::drawingml::DrawingML
* pDrawingML
);
590 virtual ~DocxAttributeOutput();
592 /// Return the right export class.
593 virtual MSWordExportBase
& GetExport();
595 /// For eg. the output of the styles, we need to switch the serializer to enother one.
596 void SetSerializer( ::sax_fastparser::FSHelperPtr pSerializer
) { m_pSerializer
= pSerializer
; }
598 /// Occasionnaly need to use this serializer from the outside
599 ::sax_fastparser::FSHelperPtr
GetSerializer( ) { return m_pSerializer
; }
601 /// Do we have any footnotes?
604 /// Do we have any endnotes?
607 /// Output the content of the footnotes.xml resp. endnotes.xml
608 void FootnotesEndnotes( bool bFootnotes
);
611 #endif // _DOCXATTRIBUTEOUTPUT_HXX_
613 /* vi:set tabstop=4 shiftwidth=4 expandtab: */