xref: /aoo41x/main/sw/source/filter/ww8/docxexport.hxx (revision 1d2dbeb0)
1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1d2dbeb0SAndrew Rist  * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist  *
11*1d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1d2dbeb0SAndrew Rist  *
13*1d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist  * under the License.
19*1d2dbeb0SAndrew Rist  *
20*1d2dbeb0SAndrew Rist  *************************************************************/
21*1d2dbeb0SAndrew Rist 
22*1d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _DOCXEXPORT_HXX_
25cdf0e10cSrcweir #define _DOCXEXPORT_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "docxattributeoutput.hxx"
28cdf0e10cSrcweir #include "wrtww8.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <sax/fshelper.hxx>
31cdf0e10cSrcweir #include <rtl/ustring.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <cstdio>
34cdf0e10cSrcweir #include <vector>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir class DocxExportFilter;
37cdf0e10cSrcweir class SwNode;
38cdf0e10cSrcweir class SwEndNode;
39cdf0e10cSrcweir class SwTableNode;
40cdf0e10cSrcweir class SwTxtNode;
41cdf0e10cSrcweir class SwGrfNode;
42cdf0e10cSrcweir class SwOLENode;
43cdf0e10cSrcweir class SwSectionNode;
44cdf0e10cSrcweir class SwNumRuleTbl;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir namespace oox {
47cdf0e10cSrcweir     namespace drawingml { class DrawingML; }
48cdf0e10cSrcweir     namespace vml { class VMLExport; }
49cdf0e10cSrcweir }
50cdf0e10cSrcweir 
51cdf0e10cSrcweir /// The class that does all the actual DOCX export-related work.
52cdf0e10cSrcweir class DocxExport : public MSWordExportBase
53cdf0e10cSrcweir {
54cdf0e10cSrcweir     /// Pointer to the filter that owns us.
55cdf0e10cSrcweir     DocxExportFilter *m_pFilter;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir     /// Fast serializer for the document output.
58cdf0e10cSrcweir     ::sax_fastparser::FSHelperPtr m_pDocumentFS;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     /// Access to the DrawingML writer.
61cdf0e10cSrcweir     oox::drawingml::DrawingML *m_pDrawingML;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     /// Attribute output for document.
64cdf0e10cSrcweir     DocxAttributeOutput *m_pAttrOutput;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     /// Sections/headers/footers
67cdf0e10cSrcweir     MSWordSections *m_pSections;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     /// Header counter.
70cdf0e10cSrcweir     sal_Int32 m_nHeaders;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     /// Footer counter.
73cdf0e10cSrcweir     sal_Int32 m_nFooters;
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     /// Exporter of the VML shapes.
76cdf0e10cSrcweir     oox::vml::VMLExport *m_pVMLExport;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir public:
79cdf0e10cSrcweir     /// Access to the attribute output class.
80cdf0e10cSrcweir     virtual AttributeOutputBase& AttrOutput() const;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     /// Access to the sections/headers/footres.
83cdf0e10cSrcweir     virtual MSWordSections& Sections() const;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     /// Hack, unfortunately necessary at some places for now.
86cdf0e10cSrcweir     /// FIXME remove it when possible.
HackIsWW8OrHigher() const87cdf0e10cSrcweir     virtual bool HackIsWW8OrHigher() const { return true; }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     /// Guess the script (asian/western).
90cdf0e10cSrcweir     virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     virtual void AppendBookmarks( const SwTxtNode& rNode, xub_StrLen nAktPos, xub_StrLen nLen );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     virtual void AppendBookmark( const rtl::OUString& rName, bool bSkip = false );
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     /// Returns the relationd id
97cdf0e10cSrcweir     rtl::OString AddRelation( const rtl::OUString& rType, const rtl::OUString& rTarget, const rtl::OUString& rMode );
98cdf0e10cSrcweir 
WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t)99cdf0e10cSrcweir     virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t()*/ ) { /* FIXME no-op for docx, most probably should not even be in MSWordExportBase */ }
WriteChar(sal_Unicode)100cdf0e10cSrcweir     virtual void WriteChar( sal_Unicode ) { /* FIXME */ fprintf( stderr, "HACK! WriteChar() has nothing to do for docx.\n" ); }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     /// Return value indicates if an inherited outline numbering is suppressed.
103cdf0e10cSrcweir     virtual bool DisallowInheritingOutlineNumbering( const SwFmt &rFmt );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     /// Output the actual headers and footers.
106cdf0e10cSrcweir     virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
107cdf0e10cSrcweir             const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     /// Write the field
110cdf0e10cSrcweir     virtual void OutputField( const SwField* pFld, ww::eField eFldType,
111cdf0e10cSrcweir             const String& rFldCmd, sal_uInt8 nMode = nsFieldFlags::WRITEFIELD_ALL );
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     /// Write the data of the form field
114cdf0e10cSrcweir     virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     virtual void DoComboBox(const rtl::OUString &rName,
117cdf0e10cSrcweir                     const rtl::OUString &rHelp,
118cdf0e10cSrcweir                     const rtl::OUString &ToolTip,
119cdf0e10cSrcweir                     const rtl::OUString &rSelected,
120cdf0e10cSrcweir                     com::sun::star::uno::Sequence<rtl::OUString> &rListItems);
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     virtual void DoFormText(const SwInputField * pFld);
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     virtual sal_uLong ReplaceCr( sal_uInt8 nChar );
125cdf0e10cSrcweir 
126cdf0e10cSrcweir protected:
127cdf0e10cSrcweir     /// Format-dependant part of the actual export.
128cdf0e10cSrcweir     virtual void ExportDocument_Impl();
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     /// Output page/section breaks
131cdf0e10cSrcweir     virtual void OutputPageSectionBreaks( const SwTxtNode& );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     /// Output SwEndNode
134cdf0e10cSrcweir     virtual void OutputEndNode( const SwEndNode& );
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     /// Output SwTableNode
137cdf0e10cSrcweir     virtual void OutputTableNode( const SwTableNode& );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     /// Output SwGrfNode
140cdf0e10cSrcweir     virtual void OutputGrfNode( const SwGrfNode& );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     /// Output SwOLENode
143cdf0e10cSrcweir     virtual void OutputOLENode( const SwOLENode& );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum );
147cdf0e10cSrcweir 
SectionBreaksAndFrames(const SwTxtNode & rNode)148cdf0e10cSrcweir     virtual void SectionBreaksAndFrames( const SwTxtNode& rNode ) {}
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     /// Get ready for a new section.
151cdf0e10cSrcweir     virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
152cdf0e10cSrcweir                                      const SwNode& rNd,
153cdf0e10cSrcweir                                      const SwFmtPageDesc* pNewPgDescFmt = 0,
154cdf0e10cSrcweir                                      const SwPageDesc* pNewPgDesc = 0 );
155cdf0e10cSrcweir 
156cdf0e10cSrcweir private:
157cdf0e10cSrcweir     /// Setup pStyles and write styles.xml
158cdf0e10cSrcweir     void InitStyles();
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     /// Write footnotes.xml and endnotes.xml.
161cdf0e10cSrcweir     void WriteFootnotesEndnotes();
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     /// Write the numbering table.
164cdf0e10cSrcweir     virtual void WriteNumbering();
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     /// Write reference to a header/foorter + the actual xml containing the text.
167cdf0e10cSrcweir     void WriteHeaderFooter( const SwFmt& rFmt, bool bHeader, const char* pType );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir     /// Write word/fontTable.xml.
170cdf0e10cSrcweir     void WriteFonts();
171cdf0e10cSrcweir 
172cdf0e10cSrcweir     /// Write docProps/core.xml
173cdf0e10cSrcweir     void WriteProperties();
174cdf0e10cSrcweir 
175cdf0e10cSrcweir public:
176cdf0e10cSrcweir     /// FIXME this is temporary, remotely reminding the method of the same
177cdf0e10cSrcweir     /// name in WW8Export.
178cdf0e10cSrcweir     void WriteMainText();
179cdf0e10cSrcweir 
180cdf0e10cSrcweir     /// Pass the pDocument, pCurrentPam and pOriginalPam to the base class.
181cdf0e10cSrcweir     DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument,
182cdf0e10cSrcweir             SwPaM *pCurrentPam, SwPaM *pOriginalPam );
183cdf0e10cSrcweir 
184cdf0e10cSrcweir     /// Destructor.
185cdf0e10cSrcweir     virtual ~DocxExport();
186cdf0e10cSrcweir 
187cdf0e10cSrcweir     /// Reference to the VMLExport instance for the main document.
188cdf0e10cSrcweir     oox::vml::VMLExport& VMLExporter();
189cdf0e10cSrcweir 
190cdf0e10cSrcweir private:
191cdf0e10cSrcweir     /// No copying.
192cdf0e10cSrcweir     DocxExport( const DocxExport& );
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     /// No copying.
195cdf0e10cSrcweir     DocxExport& operator=( const DocxExport& );
196cdf0e10cSrcweir };
197cdf0e10cSrcweir 
198cdf0e10cSrcweir #endif // _DOCXEXPORT_HXX_
199cdf0e10cSrcweir /* vi:set tabstop=4 shiftwidth=4 expandtab: */
200