LibreOffice Module sw (master)  1
docxexport.hxx
Go to the documentation of this file.
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 INCLUDED_SW_SOURCE_FILTER_WW8_DOCXEXPORT_HXX
21 #define INCLUDED_SW_SOURCE_FILTER_WW8_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 <memory>
31 #include <vector>
32 #include <boost/optional.hpp>
33 #include <ndole.hxx>
34 
36 class DocxExportFilter;
37 class SwNode;
38 class SwEndNode;
39 class SwTableNode;
40 class SwTextNode;
41 class SwGrfNode;
42 class SwOLENode;
43 class DocxSdrExport;
44 
45 namespace oox {
46  namespace drawingml { class DrawingML; }
47  namespace vml { class VMLExport; }
48 }
49 
50 namespace com { namespace sun { namespace star {
51  namespace frame { class XModel; }
52  namespace drawing { class XShape; }
53  namespace awt { class XControlModel; }
54 } } }
55 
58 {
60  bool hasData() const;
63  bool trackRevisions; // Should 'Track Revisions' be set
64 };
65 
68 {
71 
74 
77 
79  std::unique_ptr<oox::drawingml::DrawingML> m_pDrawingML;
80 
82  std::unique_ptr<DocxAttributeOutput> m_pAttrOutput;
83 
85  std::unique_ptr<MSWordSections> m_pSections;
86 
88  sal_Int32 m_nHeaders;
89 
91  sal_Int32 m_nFooters;
92 
94  sal_Int32 m_nOLEObjects;
95 
97  sal_Int32 m_nActiveXControls;
98 
101 
103  std::unique_ptr<oox::vml::VMLExport> m_pVMLExport;
104 
106  std::unique_ptr<DocxSdrExport> m_pSdrExport;
107 
109  bool const m_bDocm;
110 
112  bool const m_bTemplate;
113 
115 
118 
119 public:
120 
122  const DocxExportFilter& GetFilter() const { return *m_pFilter; };
123 
125 
127  virtual AttributeOutputBase& AttrOutput() const override;
128 
131 
133  virtual MSWordSections& Sections() const override;
134 
135  virtual bool SupportsOneColumnBreak() const override { return true; }
136 
137  virtual bool FieldsQuoted() const override { return true; }
138 
139  virtual bool AddSectionBreaksForTOX() const override { return true; }
140 
141  virtual bool ignoreAttributeForStyleDefaults( sal_uInt16 nWhich ) const override;
142 
143  virtual bool PreferPageBreakBefore() const override { return false; }
144 
146  virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ) override;
147 
148  virtual void AppendBookmarks( const SwTextNode& rNode, sal_Int32 nCurrentPos, sal_Int32 nLen ) override;
149 
150  virtual void AppendBookmark( const OUString& rName ) override;
151 
152  virtual void AppendAnnotationMarks( const SwTextNode& rNode, sal_Int32 nCurrentPos, sal_Int32 nLen ) override;
153 
154  virtual void ExportGrfBullet(const SwTextNode&) override;
155 
157  OString AddRelation( const OUString& rType, const OUString& rTarget );
158 
159  virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t()*/ ) override { /* FIXME no-op for docx, most probably should not even be in MSWordExportBase */ }
160  virtual void WriteChar( sal_Unicode ) override { /* FIXME */ fprintf( stderr, "HACK! WriteChar() has nothing to do for docx.\n" ); }
161 
163  virtual bool DisallowInheritingOutlineNumbering( const SwFormat &rFormat ) override;
164 
166  virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
167  const SwFrameFormat& rFormat, const SwFrameFormat& rLeftFormat, const SwFrameFormat& rFirstPageFormat, sal_uInt8 nBreakCode ) override;
168 
170  virtual void OutputField( const SwField* pField, ww::eField eFieldType,
171  const OUString& rFieldCmd, FieldFlags nMode = FieldFlags::All ) override;
172 
174  virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) override;
175  virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark ) override;
176 
177  virtual void DoComboBox(const OUString &rName,
178  const OUString &rHelp,
179  const OUString &ToolTip,
180  const OUString &rSelected,
181  css::uno::Sequence<OUString> &rListItems) override;
182 
183  virtual void DoFormText(const SwInputField * pField) override;
184 
185  virtual sal_uLong ReplaceCr( sal_uInt8 nChar ) override;
186 
188  OString OutputChart( css::uno::Reference< css::frame::XModel > const & xModel, sal_Int32 nCount, ::sax_fastparser::FSHelperPtr const & m_pSerializer );
189  OString WriteOLEObject(SwOLEObj& rObject, OUString & io_rProgID);
190  std::pair<OString,OString> WriteActiveXObject(const uno::Reference<css::drawing::XShape>& rxShape,
191  const uno::Reference<awt::XControlModel>& rxControlModel);
192 
194  void OutputDML( css::uno::Reference< css::drawing::XShape > const & xShape );
195 
196  void WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp);
197 
198  virtual ExportFormat GetExportFormat() const override { return ExportFormat::DOCX; }
199 
200 protected:
202  virtual ErrCode ExportDocument_Impl() override;
203 
205  virtual void OutputEndNode( const SwEndNode& ) override;
206 
208  virtual void OutputGrfNode( const SwGrfNode& ) override;
209 
211  virtual void OutputOLENode( const SwOLENode& ) override;
212 
213  virtual void OutputLinkedOLE( const OUString& ) override;
214 
215  virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFormat* pFormat, sal_uLong nLnNum ) override;
216 
217  virtual void SectionBreaksAndFrames( const SwTextNode& /*rNode*/ ) override {}
218 
220  virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
221  const SwNode& rNd,
222  const SwFormatPageDesc* pNewPgDescFormat,
223  const SwPageDesc* pNewPgDesc ) override;
224 
225 private:
227  void InitStyles();
228 
230  void WriteFootnotesEndnotes();
231 
233  void WritePostitFields();
234 
236  virtual void WriteNumbering() override;
237 
239  void WriteHeaderFooter( const SwFormat* pFormat, bool bHeader, const char* pType );
240 
242  void WriteFonts();
243 
245  void WriteProperties();
246 
248  void WriteSettings();
249 
251  void WriteTheme();
252 
253  void WriteGlossary();
254 
256  void WriteCustomXml();
257 
259  void WriteEmbeddings();
260 
262  void WriteVBA();
263 
265  bool isMirroredMargin();
266 
267 public:
270 
273  void WriteMainText();
274 
276  DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument, SwPaM* pCurrentPam, SwPaM* pOriginalPam,
277  bool bDocm, bool bTemplate);
278 
280  virtual ~DocxExport() override;
281 
284 
287 
289  void setDefaultTabStop( int stop ) { m_aSettings.defaultTabStop = stop; }
290 
291  const ::sax_fastparser::FSHelperPtr& GetFS() { return mpFS; }
292 
293  void SetFS(::sax_fastparser::FSHelperPtr const & mpFS);
294 
295  void SetFloatingTableFrame(const ww8::Frame* pF) { m_pFloatingTableFrame = pF; }
296 
297 private:
298  DocxExport( const DocxExport& ) = delete;
299 
300  DocxExport& operator=( const DocxExport& ) = delete;
301 };
302 
303 #endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXEXPORT_HXX
304 
305 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const DocxExportFilter & GetFilter() const
Definition: docxexport.hxx:122
void WriteFootnotesEndnotes()
Write footnotes.xml and endnotes.xml.
Definition: docxexport.cxx:669
std::unique_ptr< MSWordSections > m_pSections
Sections/headers/footers.
Definition: docxexport.hxx:85
void InitStyles()
Setup pStyles and write styles.xml.
Definition: docxexport.cxx:646
virtual void DoFormText(const SwInputField *pField) override
Definition: docxexport.cxx:378
virtual void OutputLinkedOLE(const OUString &) override
Definition: docxexport.cxx:610
std::unique_ptr< oox::vml::VMLExport > m_pVMLExport
Exporter of the VML shapes.
Definition: docxexport.hxx:103
bool hasData() const
sal_Int32 m_nHeadersFootersInSection
Footer and Header counter in Section properties.
Definition: docxexport.hxx:100
Class to collect and output the sections/headers/footers.
Definition: wrtww8.hxx:199
DocxAttributeOutput & DocxAttrOutput() const
Access to the derived attribute output class.
Definition: docxexport.cxx:106
The class that has handlers for various resource types when exporting as DOCX.
Handles DOCX export of drawings.
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
sal_Int32 m_nOLEObjects
OLE objects counter.
Definition: docxexport.hxx:94
virtual bool DisallowInheritingOutlineNumbering(const SwFormat &rFormat) override
Return value indicates if an inherited outline numbering is suppressed.
Definition: docxexport.cxx:229
virtual void AppendBookmarks(const SwTextNode &rNode, sal_Int32 nCurrentPos, sal_Int32 nLen) override
Definition: docxexport.cxx:150
css::uno::Reference< css::xml::sax::XFastAttributeList > XFastAttributeListRef
std::pair< OString, OString > WriteActiveXObject(const uno::Reference< css::drawing::XShape > &rxShape, const uno::Reference< awt::XControlModel > &rxControlModel)
Definition: docxexport.cxx:449
virtual bool PreferPageBreakBefore() const override
If saving page break is preferred as a paragraph attribute (yes) or as a special character (no)...
Definition: docxexport.hxx:143
virtual ExportFormat GetExportFormat() const override
Definition: docxexport.hxx:198
sal_uIntPtr sal_uLong
virtual void WriteHyperlinkData(const ::sw::mark::IFieldmark &rFieldmark) override
Definition: docxexport.cxx:324
Base class of all fields.
Definition: fldbas.hxx:279
bool const m_bDocm
If the result will be a .docm file or not.
Definition: docxexport.hxx:109
Definition: doc.hxx:185
void WriteSettings()
Write word/settings.xml.
Definition: docxexport.cxx:900
DocxExport & operator=(const DocxExport &)=delete
void WriteGlossary()
void WriteFonts()
Write word/fontTable.xml.
Definition: docxexport.cxx:857
virtual void WriteHeadersFooters(sal_uInt8 nHeadFootFlags, const SwFrameFormat &rFormat, const SwFrameFormat &rLeftFormat, const SwFrameFormat &rFirstPageFormat, sal_uInt8 nBreakCode) override
Output the actual headers and footers.
Definition: docxexport.cxx:251
const ::sax_fastparser::FSHelperPtr & GetFS()
Definition: docxexport.hxx:291
virtual void OutputGrfNode(const SwGrfNode &) override
Output SwGrfNode.
Definition: docxexport.cxx:600
void WriteCustomXml()
Write customXml/item[n].xml and customXml/itemProps[n].xml.
bool isMirroredMargin()
return true if Page Layout is set as Mirrored
sax_fastparser::XFastAttributeListRef MainXmlNamespaces()
All xml namespaces to be used at the top of any text .xml file (main doc, headers, footers,...)
The class that does all the actual DOCX export-related work.
Definition: docxexport.hxx:67
virtual void SectionBreaksAndFrames(const SwTextNode &) override
Definition: docxexport.hxx:217
sal_uInt16 sal_Unicode
FieldFlags
Definition: wrtww8.hxx:147
std::unique_ptr< DocxAttributeOutput > m_pAttrOutput
Attribute output for document.
Definition: docxexport.hxx:82
bool const m_bTemplate
Export is done into template (.dotx)
Definition: docxexport.hxx:112
virtual bool ignoreAttributeForStyleDefaults(sal_uInt16 nWhich) const override
Used to filter out attributes that can be e.g. written to .doc but not to .docx.
virtual AttributeOutputBase & AttrOutput() const override
Access to the attribute output class.
Definition: docxexport.cxx:101
OString OutputChart(css::uno::Reference< css::frame::XModel > const &xModel, sal_Int32 nCount,::sax_fastparser::FSHelperPtr const &m_pSerializer)
Returns the relationd id.
Definition: docxexport.cxx:385
sal_Int32 m_nFooters
Footer counter.
Definition: docxexport.hxx:91
eField
Definition: fields.hxx:26
void WritePostitFields()
Write comments.xml.
Definition: docxexport.cxx:726
sal_Int32 m_nHeaders
Header counter.
Definition: docxexport.hxx:88
const ww8::Frame * m_pFloatingTableFrame
Pointer to the Frame of a floating table it is nested in.
Definition: docxexport.hxx:117
virtual void AppendAnnotationMarks(const SwTextNode &rNode, sal_Int32 nCurrentPos, sal_Int32 nLen) override
Definition: docxexport.cxx:191
OString WriteOLEObject(SwOLEObj &rObject, OUString &io_rProgID)
Definition: docxexport.cxx:401
void WriteOutliner(const OutlinerParaObject &rOutliner, sal_uInt8 nTyp)
virtual void AppendSection(const SwPageDesc *pPageDesc, const SwSectionFormat *pFormat, sal_uLong nLnNum) override
Definition: docxexport.cxx:551
void WriteHeaderFooter(const SwFormat *pFormat, bool bHeader, const char *pType)
Write reference to a header/footer + the actual xml containing the text.
Definition: docxexport.cxx:781
OString AddRelation(const OUString &rType, const OUString &rTarget)
Returns the relationd id.
Definition: docxexport.cxx:221
virtual MSWordSections & Sections() const override
Access to the sections/headers/footres.
Definition: docxexport.cxx:111
Base class for various Writer styles.
Definition: format.hxx:43
virtual void WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t) override
Definition: docxexport.hxx:159
void WriteEmbeddings()
Write word/embeddings/Worksheet[n].xlsx.
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
void WriteProperties()
Write docProps/core.xml.
Definition: docxexport.cxx:883
Style of a layout element.
Definition: frmfmt.hxx:57
virtual bool CollapseScriptsforWordOk(sal_uInt16 nScript, sal_uInt16 nWhich) override
Guess the script (asian/western).
Definition: docxexport.cxx:116
virtual void WriteChar(sal_Unicode) override
Definition: docxexport.hxx:160
void OutputDML(css::uno::Reference< css::drawing::XShape > const &xShape)
Writes the shape using drawingML syntax.
Definition: docxexport.cxx:497
std::unique_ptr< oox::drawingml::DrawingML > m_pDrawingML
Access to the DrawingML writer.
Definition: docxexport.hxx:79
virtual void OutputOLENode(const SwOLENode &) override
Output SwOLENode.
Definition: docxexport.cxx:605
void SetFS(::sax_fastparser::FSHelperPtr const &mpFS)
std::shared_ptr< FastSerializerHelper > FSHelperPtr
DocxSettingsData m_aSettings
Definition: docxexport.hxx:114
virtual void OutputEndNode(const SwEndNode &) override
Output SwEndNode.
Definition: docxexport.cxx:557
void setDefaultTabStop(int stop)
Set the document default tab stop.
Definition: docxexport.hxx:289
virtual void DoComboBox(const OUString &rName, const OUString &rHelp, const OUString &ToolTip, const OUString &rSelected, css::uno::Sequence< OUString > &rListItems) override
Definition: docxexport.cxx:331
DocxExportFilter & GetFilter()
Definition: docxexport.hxx:121
std::unique_ptr< DocxSdrExport > m_pSdrExport
Exporter of drawings.
Definition: docxexport.hxx:106
virtual void WriteNumbering() override
Write the numbering table.
Definition: docxexport.cxx:746
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
virtual bool SupportsOneColumnBreak() const override
Determines if column break with one column should be exported or not.
Definition: docxexport.hxx:135
virtual sal_uLong ReplaceCr(sal_uInt8 nChar) override
Definition: docxexport.cxx:615
virtual void PrepareNewPageDesc(const SfxItemSet *pSet, const SwNode &rNd, const SwFormatPageDesc *pNewPgDescFormat, const SwPageDesc *pNewPgDesc) override
Get ready for a new section.
Definition: docxexport.cxx:622
::sax_fastparser::FSHelperPtr m_pDocumentFS
Fast serializer for the document output.
Definition: docxexport.hxx:73
oox::vml::VMLExport & VMLExporter()
Reference to the VMLExport instance for the main document.
Definition: docxexport.hxx:283
virtual bool FieldsQuoted() const override
Determines if the import filter already quoted fields or not.
Definition: docxexport.hxx:137
void WriteVBA()
Writes word/vbaProject.bin.
DocxExportFilter * m_pFilter
Pointer to the filter that owns us.
Definition: docxexport.hxx:70
unsigned char sal_uInt8
Make exporting a Writer Frame easy.
DocxSdrExport & SdrExporter()
Reference to the DocxSdrExport instance for the main document.
Definition: docxexport.hxx:286
virtual ErrCode ExportDocument_Impl() override
Format-dependent part of the actual export.
Definition: docxexport.cxx:509
void WriteTheme()
Write word/theme/theme1.xml.
virtual void WriteFormData(const ::sw::mark::IFieldmark &rFieldmark) override
Write the data of the form field.
Definition: docxexport.cxx:319
sal_Int32 m_nActiveXControls
ActiveX controls counter.
Definition: docxexport.hxx:97
The physical access to the DOCX document (for writing).
std::shared_ptr< WW8TableNodeInfoInner > Pointer_t
virtual void OutputField(const SwField *pField, ww::eField eFieldType, const OUString &rFieldCmd, FieldFlags nMode=FieldFlags::All) override
Write the field.
Definition: docxexport.cxx:314
const ww8::Frame * GetFloatingTableFrame()
Definition: docxexport.hxx:124
::sax_fastparser::FSHelperPtr mpFS
Fast serializer to output the data.
Definition: docxexport.hxx:76
bool evenAndOddHeaders
returns true if there are any non-default settings (i.e. something to write)
Definition: docxexport.hxx:61
virtual void AppendBookmark(const OUString &rName) override
Definition: docxexport.cxx:180
Base class for WW8Export and DocxExport.
Definition: wrtww8.hxx:453
virtual ~DocxExport() override
Destructor.
Ends a section of nodes in the document model.
Definition: node.hxx:333
void SetFloatingTableFrame(const ww8::Frame *pF)
Definition: docxexport.hxx:295
DocxExport(DocxExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam, bool bDocm, bool bTemplate)
Pass the pDocument, pCurrentPam and pOriginalPam to the base class.
Data to be written in the document settings part of the document.
Definition: docxexport.hxx:57
virtual bool AddSectionBreaksForTOX() const override
Determines the Section Breaks are to be added for TOX Section.
Definition: docxexport.hxx:139
virtual void ExportGrfBullet(const SwTextNode &) override
Definition: docxexport.cxx:215
Base class of the Writer document model elements.
Definition: node.hxx:79
void WriteMainText()
FIXME this is temporary, remotely reminding the method of the same name in WW8Export.