Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _DOCXEXPORT_HXX_
21 : #define _DOCXEXPORT_HXX_
22 :
23 : #include "wrtww8.hxx"
24 :
25 : #include <sax/fshelper.hxx>
26 : #include <sax/fastattribs.hxx>
27 : #include <rtl/ustring.hxx>
28 :
29 : #include <cstdio>
30 : #include <vector>
31 :
32 : class DocxAttributeOutput;
33 : class DocxExportFilter;
34 : class SwNode;
35 : class SwEndNode;
36 : class SwTableNode;
37 : class SwTxtNode;
38 : class SwGrfNode;
39 : class SwOLENode;
40 :
41 : namespace oox {
42 : namespace drawingml { class DrawingML; }
43 : namespace vml { class VMLExport; }
44 : }
45 :
46 : namespace com { namespace sun { namespace star {
47 : namespace frame { class XModel; }
48 : } } }
49 :
50 : /// Data to be written in the document settings part of the document
51 : struct DocxSettingsData
52 : {
53 : DocxSettingsData();
54 : bool hasData() const; /// returns true if there are any non-default settings (i.e. something to write)
55 : bool evenAndOddHeaders;
56 : int defaultTabStop;
57 : };
58 :
59 : /// The class that does all the actual DOCX export-related work.
60 : class DocxExport : public MSWordExportBase
61 : {
62 : /// Pointer to the filter that owns us.
63 : DocxExportFilter *m_pFilter;
64 :
65 : /// Fast serializer for the document output.
66 : ::sax_fastparser::FSHelperPtr m_pDocumentFS;
67 :
68 : /// Access to the DrawingML writer.
69 : oox::drawingml::DrawingML *m_pDrawingML;
70 :
71 : /// Attribute output for document.
72 : DocxAttributeOutput *m_pAttrOutput;
73 :
74 : /// Sections/headers/footers
75 : MSWordSections *m_pSections;
76 :
77 : /// Header counter.
78 : sal_Int32 m_nHeaders;
79 :
80 : /// Footer counter.
81 : sal_Int32 m_nFooters;
82 :
83 : /// Exporter of the VML shapes.
84 : oox::vml::VMLExport *m_pVMLExport;
85 :
86 : DocxSettingsData settings;
87 :
88 : public:
89 :
90 121 : DocxExportFilter& GetFilter() { return *m_pFilter; };
91 168 : const DocxExportFilter& GetFilter() const { return *m_pFilter; };
92 :
93 : /// Access to the attribute output class.
94 : virtual AttributeOutputBase& AttrOutput() const;
95 :
96 : /// Access to the sections/headers/footres.
97 : virtual MSWordSections& Sections() const;
98 :
99 : /// Determines if the format is expected to support unicode.
100 303 : virtual bool SupportsUnicode() const { return true; }
101 :
102 : virtual bool ignoreAttributeForStyles( sal_uInt16 nWhich ) const;
103 :
104 : /// Guess the script (asian/western).
105 : virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich );
106 :
107 : virtual void AppendBookmarks( const SwTxtNode& rNode, xub_StrLen nAktPos, xub_StrLen nLen );
108 :
109 : virtual void AppendBookmark( const rtl::OUString& rName, bool bSkip = false );
110 :
111 : /// Returns the relationd id
112 : rtl::OString AddRelation( const rtl::OUString& rType, const rtl::OUString& rTarget );
113 :
114 85 : 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 */ }
115 0 : virtual void WriteChar( sal_Unicode ) { /* FIXME */ fprintf( stderr, "HACK! WriteChar() has nothing to do for docx.\n" ); }
116 :
117 : /// Return value indicates if an inherited outline numbering is suppressed.
118 : virtual bool DisallowInheritingOutlineNumbering( const SwFmt &rFmt );
119 :
120 : /// Output the actual headers and footers.
121 : virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
122 : const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt, sal_uInt8 nBreakCode );
123 :
124 : /// Write the field
125 : virtual void OutputField( const SwField* pFld, ww::eField eFldType,
126 : const String& rFldCmd, sal_uInt8 nMode = nsFieldFlags::WRITEFIELD_ALL );
127 :
128 : /// Write the data of the form field
129 : virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark );
130 : virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark );
131 :
132 : virtual void DoComboBox(const rtl::OUString &rName,
133 : const rtl::OUString &rHelp,
134 : const rtl::OUString &ToolTip,
135 : const rtl::OUString &rSelected,
136 : com::sun::star::uno::Sequence<rtl::OUString> &rListItems);
137 :
138 : virtual void DoFormText(const SwInputField * pFld);
139 :
140 : virtual sal_uLong ReplaceCr( sal_uInt8 nChar );
141 :
142 : /// Returns the relationd id
143 : rtl::OString OutputChart( com::sun::star::uno::Reference< com::sun::star::frame::XModel >& xModel, sal_Int32 nCount );
144 :
145 : void WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp);
146 :
147 : protected:
148 : /// Format-dependant part of the actual export.
149 : virtual void ExportDocument_Impl();
150 :
151 : /// Output page/section breaks
152 : virtual void OutputPageSectionBreaks( const SwTxtNode& );
153 :
154 : /// Output SwEndNode
155 : virtual void OutputEndNode( const SwEndNode& );
156 :
157 : /// Output SwTableNode
158 : virtual void OutputTableNode( const SwTableNode& );
159 :
160 : /// Output SwGrfNode
161 : virtual void OutputGrfNode( const SwGrfNode& );
162 :
163 : /// Output SwOLENode
164 : virtual void OutputOLENode( const SwOLENode& );
165 :
166 : virtual void OutputLinkedOLE( const rtl::OUString& );
167 :
168 : virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum );
169 :
170 85 : virtual void SectionBreaksAndFrames( const SwTxtNode& /*rNode*/ ) {}
171 :
172 : /// Get ready for a new section.
173 : virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
174 : const SwNode& rNd,
175 : const SwFmtPageDesc* pNewPgDescFmt = 0,
176 : const SwPageDesc* pNewPgDesc = 0 );
177 :
178 : private:
179 : /// Setup pStyles and write styles.xml
180 : void InitStyles();
181 :
182 : /// Write footnotes.xml and endnotes.xml.
183 : void WriteFootnotesEndnotes();
184 :
185 : /// Write comments.xml
186 : void WritePostitFields();
187 :
188 : /// Write the numbering table.
189 : virtual void WriteNumbering();
190 :
191 : /// Write reference to a header/foorter + the actual xml containing the text.
192 : void WriteHeaderFooter( const SwFmt& rFmt, bool bHeader, const char* pType );
193 :
194 : /// Write word/fontTable.xml.
195 : void WriteFonts();
196 :
197 : /// Write docProps/core.xml
198 : void WriteProperties();
199 :
200 : /// Write word/settings.xml
201 : void WriteSettings();
202 :
203 : /// All xml namespaces to be used at the top of any text .xml file (main doc, headers, footers,...)
204 : sax_fastparser::XFastAttributeListRef MainXmlNamespaces( sax_fastparser::FSHelperPtr serializer );
205 :
206 : public:
207 : /// FIXME this is temporary, remotely reminding the method of the same
208 : /// name in WW8Export.
209 : void WriteMainText();
210 :
211 : /// Pass the pDocument, pCurrentPam and pOriginalPam to the base class.
212 : DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument,
213 : SwPaM *pCurrentPam, SwPaM *pOriginalPam );
214 :
215 : /// Destructor.
216 : virtual ~DocxExport();
217 :
218 : /// Reference to the VMLExport instance for the main document.
219 : oox::vml::VMLExport& VMLExporter();
220 :
221 : /// Set the document default tab stop.
222 10 : void setDefaultTabStop( int stop ) { settings.defaultTabStop = stop; }
223 :
224 : private:
225 : /// No copying.
226 : DocxExport( const DocxExport& );
227 :
228 : /// No copying.
229 : DocxExport& operator=( const DocxExport& );
230 : };
231 :
232 : #endif // _DOCXEXPORT_HXX_
233 :
234 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|