update dev300-m58
[ooovba.git] / sw / source / filter / ww8 / docxattributeoutput.hxx
blobcbe5345e4076f7ae2dae540e9a2ccfdef47ebf8d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile$
10 * $Revision$
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"
35 #include "fields.hxx"
37 #include <sax/fshelper.hxx>
38 #include <sax/fastattribs.hxx>
39 #include <vcl/vclenum.hxx>
41 #include <fldbas.hxx>
43 #include <vector>
45 class DocxExport;
47 class SwGrfNode;
49 namespace docx { class FootnotesList; }
50 namespace oox { namespace drawingml { class DrawingML; } }
52 struct FieldInfos
54 const SwField* pField;
55 ww::eField eType;
56 bool bOpen;
57 bool bClose;
58 String sCmd;
61 enum DocxColBreakStatus
63 COLBRK_NONE,
64 COLBRK_POSTPONE,
65 COLBRK_WRITE
68 class DocxAttributeOutput : public AttributeOutputBase
70 public:
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 );
80 /// Empty paragraph.
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 );
110 /// Output ruby end.
111 virtual void EndRuby();
113 /// Output URL start.
114 virtual bool StartURL( const String& rUrl, const String& rTarget );
116 /// Output URL end.
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.
135 void EndRedline();
137 virtual void FormatDrop( const SwTxtNode& rNode, const SwFmtDrop& rSwFmtDrop, USHORT nStyle, ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo, ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner );
139 /// Output style.
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 );
193 /// Page break
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 );
230 /// Start the font.
231 void StartFont( const String& rFamilyName ) const;
233 /// End the font.
234 void EndFont() const;
236 /// Alternate name for the font.
237 void FontAlternateName( const String& rName ) const;
239 /// Font charset.
240 void FontCharset( sal_uInt8 nCharSet ) const;
242 /// Font family.
243 void FontFamilyType( FontFamily eFamily ) const;
245 /// Font pitch.
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,
259 USHORT nStart,
260 USHORT nNumberingType,
261 SvxAdjust eAdjust,
262 const BYTE *pNumLvlPos,
263 BYTE nFollow,
264 const wwFont *pFont,
265 const SfxItemSet *pOutSet,
266 sal_Int16 nIndentAt,
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 );
275 private:
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( );
317 void EndTableRow( );
319 void EndTable();
321 /// End cell, row, and even the entire table if necessary.
322 void FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t pInner, bool bForceEmptyParagraph = false );
324 protected:
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_TXTATR_HARDBLANK
438 virtual void TextHardBlank( const SwFmtHardBlank& );
440 /// Sfx item RES_PARATR_LINESPACING
441 virtual void ParaLineSpacing_Impl( short nSpace, short nMulti );
443 /// Sfx item RES_PARATR_ADJUST
444 virtual void ParaAdjust( const SvxAdjustItem& rAdjust );
446 /// Sfx item RES_PARATR_SPLIT
447 virtual void ParaSplit( const SvxFmtSplitItem& rSplit );
449 /// Sfx item RES_PARATR_WIDOWS
450 virtual void ParaWidows( const SvxWidowsItem& rWidows );
452 /// Sfx item RES_PARATR_TABSTOP
453 virtual void ParaTabStop( const SvxTabStopItem& rTabStop );
455 /// Sfx item RES_PARATR_HYPHENZONE
456 virtual void ParaHyphenZone( const SvxHyphenZoneItem& );
458 /// Sfx item RES_PARATR_NUMRULE
459 virtual void ParaNumRule_Impl( const SwTxtNode *pTxtNd, sal_Int32 nLvl, sal_Int32 nNumId );
461 /// Sfx item RES_PARATR_SCRIPTSPACE
462 virtual void ParaScriptSpace( const SfxBoolItem& );
464 /// Sfx item RES_PARATR_VERTALIGN
465 virtual void ParaVerticalAlign( const SvxParaVertAlignItem& rAlign );
467 /// Sfx item RES_PARATR_SNAPTOGRID
468 virtual void ParaSnapToGrid( const SvxParaGridItem& );
470 /// Sfx item RES_FRM_SIZE
471 virtual void FormatFrameSize( const SwFmtFrmSize& );
473 /// Sfx item RES_PAPER_BIN
474 virtual void FormatPaperBin( const SvxPaperBinItem& );
476 /// Sfx item RES_LR_SPACE
477 virtual void FormatLRSpace( const SvxLRSpaceItem& rLRSpace );
479 /// Sfx item RES_UL_SPACE
480 virtual void FormatULSpace( const SvxULSpaceItem& rULSpace );
482 /// Sfx item RES_SURROUND
483 virtual void FormatSurround( const SwFmtSurround& );
485 /// Sfx item RES_VERT_ORIENT
486 virtual void FormatVertOrientation( const SwFmtVertOrient& );
488 /// Sfx item RES_HORI_ORIENT
489 virtual void FormatHorizOrientation( const SwFmtHoriOrient& );
491 /// Sfx item RES_ANCHOR
492 virtual void FormatAnchor( const SwFmtAnchor& );
494 /// Sfx item RES_BACKGROUND
495 virtual void FormatBackground( const SvxBrushItem& );
497 /// Sfx item RES_BOX
498 virtual void FormatBox( const SvxBoxItem& );
500 /// Sfx item RES_COL
501 virtual void FormatColumns_Impl( USHORT nCols, const SwFmtCol & rCol, bool bEven, SwTwips nPageSize );
503 /// Sfx item RES_KEEP
504 virtual void FormatKeep( const SvxFmtKeepItem& );
506 /// Sfx item RES_TEXTGRID
507 virtual void FormatTextGrid( const SwTextGridItem& );
509 /// Sfx item RES_LINENUMBER
510 virtual void FormatLineNumbering( const SwFmtLineNumber& );
512 /// Sfx item RES_FRAMEDIR
513 virtual void FormatFrameDirection( const SvxFrameDirectionItem& );
515 /// Write the expanded field
516 virtual void WriteExpand( const SwField* pFld );
518 virtual void RefField( const SwField& rFld, const String& rRef );
519 virtual void HiddenField( const SwField& rFld );
520 virtual void SetField( const SwField& rFld, ww::eField eType, const String& rCmd );
521 virtual void PostitField( const SwField* pFld );
522 virtual bool DropdownField( const SwField* pFld );
524 virtual bool AnalyzeURL( const String& rURL, const String& rTarget, String* pLinkURL, String* pMark );
526 /// Reference to the export, where to get the data from
527 DocxExport &m_rExport;
529 /// Fast serializer to output the data
530 ::sax_fastparser::FSHelperPtr m_pSerializer;
532 /// DrawingML access
533 oox::drawingml::DrawingML &m_rDrawingML;
535 private:
537 void DoWriteBookmarks( );
539 void StartField_Impl( FieldInfos& rInfos, sal_Bool bWriteRun = sal_False );
540 void DoWriteCmd( String& rCmd );
541 void CmdField_Impl( FieldInfos& rInfos );
542 void EndField_Impl( FieldInfos& rInfos );
544 ::sax_fastparser::FastAttributeList *m_pFontsAttrList, *m_pEastAsianLayoutAttrList;
545 ::sax_fastparser::FastAttributeList *m_pCharLangAttrList;
546 ::sax_fastparser::FastAttributeList *m_pSpacingAttrList;
547 ::sax_fastparser::FastAttributeList *m_pHyperlinkAttrList;
549 ::docx::FootnotesList *m_pFootnotesList;
550 ::docx::FootnotesList *m_pEndnotesList;
552 const WW8_SepInfo *m_pSectionInfo;
554 /// Redline data to remember in the text run.
555 const SwRedlineData *m_pRedlineData;
557 /// Id of the redline
558 sal_Int32 m_nRedlineId;
560 /// Flag indicating that the section properties are being written
561 sal_Bool m_bOpenedSectPr;
563 /// Field data to remember in the text run
564 std::vector< FieldInfos > m_Fields;
565 String m_sFieldBkm;
566 sal_Int32 m_nNextMarkId;
568 /// Bookmarks to output
569 std::vector<rtl::OString> m_rMarksStart;
570 std::vector<rtl::OString> m_rMarksEnd;
572 /// Maps of the bookmarks ids
573 std::map<rtl::OString, USHORT> m_rOpenedMarksIds;
575 /// The current table helper
576 SwWriteTable *m_pTableWrt;
578 /// Remember if we are in an open cell, or not.
579 bool m_bTableCellOpen;
581 /// Remember the current table depth.
582 sal_uInt32 m_nTableDepth;
584 bool m_bParagraphOpened;
586 // Remember that a column break has to be opened at the
587 // beginning of the next paragraph
588 DocxColBreakStatus m_nColBreakStatus;
590 public:
591 DocxAttributeOutput( DocxExport &rExport, ::sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML );
593 virtual ~DocxAttributeOutput();
595 /// Return the right export class.
596 virtual MSWordExportBase& GetExport();
598 /// For eg. the output of the styles, we need to switch the serializer to enother one.
599 void SetSerializer( ::sax_fastparser::FSHelperPtr pSerializer ) { m_pSerializer = pSerializer; }
601 /// Occasionnaly need to use this serializer from the outside
602 ::sax_fastparser::FSHelperPtr GetSerializer( ) { return m_pSerializer; }
604 /// Do we have any footnotes?
605 bool HasFootnotes();
607 /// Do we have any endnotes?
608 bool HasEndnotes();
610 /// Output the content of the footnotes.xml resp. endnotes.xml
611 void FootnotesEndnotes( bool bFootnotes );
614 #endif // _DOCXATTRIBUTEOUTPUT_HXX_
616 /* vi:set tabstop=4 shiftwidth=4 expandtab: */