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 <sal/log.hxx>
26 #include <sax/fshelper.hxx>
27 #include <rtl/ustring.hxx>
28 
29 #include <memory>
30 #include <ndole.hxx>
31 
33 class DocxExportFilter;
34 class SwNode;
35 class SwEndNode;
36 class SwTableNode;
37 class SwTextNode;
38 class SwGrfNode;
39 class SwOLENode;
40 class DocxSdrExport;
41 
42 namespace oox {
43  namespace drawingml { class DrawingML; }
44  namespace vml { class VMLExport; }
45 }
46 
47 namespace com::sun::star {
48  namespace frame { class XModel; }
49  namespace drawing { class XShape; }
50  namespace awt { class XControlModel; }
51 }
52 
55 {
57  bool hasData() const;
60  bool revisionView; // don't show tracked changes
61  bool trackRevisions; // Should 'Track Revisions' be set
62 };
63 
66 {
69 
72 
75 
77  std::unique_ptr<oox::drawingml::DrawingML> m_pDrawingML;
78 
80  std::unique_ptr<DocxAttributeOutput> m_pAttrOutput;
81 
83  std::unique_ptr<MSWordSections> m_pSections;
84 
86  sal_Int32 m_nHeaders;
87 
89  sal_Int32 m_nFooters;
90 
92  sal_Int32 m_nOLEObjects;
93 
95  sal_Int32 m_nActiveXControls;
96 
99 
101  std::unique_ptr<oox::vml::VMLExport> m_pVMLExport;
102 
104  std::unique_ptr<DocxSdrExport> m_pSdrExport;
105 
107  bool m_bDocm;
108 
110  bool const m_bTemplate;
111 
113 
116 
117 public:
118 
120  const DocxExportFilter& GetFilter() const { return m_rFilter; };
121 
123 
125  virtual AttributeOutputBase& AttrOutput() const override;
126 
129 
131  virtual MSWordSections& Sections() const override;
132 
133  virtual bool FieldsQuoted() const override { return true; }
134 
135  virtual bool AddSectionBreaksForTOX() const override { return true; }
136 
137  virtual bool ignoreAttributeForStyleDefaults( sal_uInt16 nWhich ) const override;
138 
139  virtual bool PreferPageBreakBefore() const override { return false; }
140 
142  virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ) override;
143 
144  virtual void AppendBookmarks( const SwTextNode& rNode, sal_Int32 nCurrentPos, sal_Int32 nLen ) override;
145 
146  virtual void AppendBookmark( const OUString& rName ) override;
147 
148  virtual void AppendAnnotationMarks( const SwWW8AttrIter& rAttrs, sal_Int32 nCurrentPos, sal_Int32 nLen ) override;
149 
150  virtual void ExportGrfBullet(const SwTextNode&) override;
151 
153  OString AddRelation( const OUString& rType, const OUString& rTarget );
154 
155  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 */ }
156  virtual void WriteChar( sal_Unicode ) override { SAL_WARN("sw.ww8", "FIXME: WriteChar() has nothing to do for docx."); }
157 
159  virtual bool DisallowInheritingOutlineNumbering( const SwFormat &rFormat ) override;
160 
162  virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
163  const SwFrameFormat& rFormat, const SwFrameFormat& rLeftFormat, const SwFrameFormat& rFirstPageFormat, sal_uInt8 nBreakCode ) override;
164 
166  virtual void OutputField( const SwField* pField, ww::eField eFieldType,
167  const OUString& rFieldCmd, FieldFlags nMode = FieldFlags::All ) override;
168 
170  virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) override;
171  virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark ) override;
172 
173  virtual void DoComboBox(const OUString &rName,
174  const OUString &rHelp,
175  const OUString &ToolTip,
176  const OUString &rSelected,
177  const css::uno::Sequence<OUString> &rListItems) override;
178 
179  virtual void DoFormText(const SwInputField * pField) override;
180 
181  virtual sal_uLong ReplaceCr( sal_uInt8 nChar ) override;
182 
184  OString OutputChart( css::uno::Reference< css::frame::XModel > const & xModel, sal_Int32 nCount, ::sax_fastparser::FSHelperPtr const & m_pSerializer );
185  OString WriteOLEObject(SwOLEObj& rObject, OUString & io_rProgID);
186  std::pair<OString,OString> WriteActiveXObject(const uno::Reference<css::drawing::XShape>& rxShape,
187  const uno::Reference<awt::XControlModel>& rxControlModel);
188 
190  void OutputDML( css::uno::Reference< css::drawing::XShape > const & xShape );
191 
192  void WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp);
193 
194  virtual ExportFormat GetExportFormat() const override { return ExportFormat::DOCX; }
195 
196 protected:
198  virtual ErrCode ExportDocument_Impl() override;
199 
201  virtual void OutputEndNode( const SwEndNode& ) override;
202 
204  virtual void OutputGrfNode( const SwGrfNode& ) override;
205 
207  virtual void OutputOLENode( const SwOLENode& ) override;
208 
209  virtual void OutputLinkedOLE( const OUString& ) override;
210 
211  virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFormat* pFormat, sal_uLong nLnNum ) override;
212 
213  virtual void SectionBreaksAndFrames( const SwTextNode& /*rNode*/ ) override {}
214 
216  virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
217  const SwNode& rNd,
218  const SwFormatPageDesc* pNewPgDescFormat,
219  const SwPageDesc* pNewPgDesc ) override;
220 
221 private:
223  void InitStyles();
224 
226  void WriteFootnotesEndnotes();
227 
229  void WritePostitFields();
230 
232  virtual void WriteNumbering() override;
233 
235  void WriteHeaderFooter( const SwFormat* pFormat, bool bHeader, const char* pType );
236 
238  void WriteFonts();
239 
241  void WriteProperties();
242 
244  void WriteSettings();
245 
247  void WriteDocVars(const sax_fastparser::FSHelperPtr& pFS);
248 
250  void WriteTheme();
251 
252  void WriteGlossary();
253 
255  void WriteCustomXml();
256 
258  void WriteEmbeddings();
259 
261  void WriteVBA();
262 
264  bool isMirroredMargin();
265 
266 public:
269 
272  void WriteMainText();
273 
275  DocxExport( DocxExportFilter& rFilter, SwDoc& rDocument,
276  std::shared_ptr<SwUnoCursor> & pCurrentPam, SwPaM& rOriginalPam,
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() const { 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:120
void WriteFootnotesEndnotes()
Write footnotes.xml and endnotes.xml.
Definition: docxexport.cxx:667
std::unique_ptr< MSWordSections > m_pSections
Sections/headers/footers.
Definition: docxexport.hxx:83
void InitStyles()
Setup pStyles and write styles.xml.
Definition: docxexport.cxx:644
virtual void DoFormText(const SwInputField *pField) override
Definition: docxexport.cxx:369
virtual void OutputLinkedOLE(const OUString &) override
Definition: docxexport.cxx:608
std::unique_ptr< oox::vml::VMLExport > m_pVMLExport
Exporter of the VML shapes.
Definition: docxexport.hxx:101
bool hasData() const
sal_Int32 m_nHeadersFootersInSection
Footer and Header counter in Section properties.
Definition: docxexport.hxx:98
Class to collect and output the sections/headers/footers.
Definition: wrtww8.hxx:193
DocxAttributeOutput & DocxAttrOutput() const
Access to the derived attribute output class.
Definition: docxexport.cxx:104
bool m_bDocm
If the result will be a .docm file or not.
Definition: docxexport.hxx:107
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:92
virtual bool DisallowInheritingOutlineNumbering(const SwFormat &rFormat) override
Return value indicates if an inherited outline numbering is suppressed.
Definition: docxexport.cxx:227
virtual void AppendBookmarks(const SwTextNode &rNode, sal_Int32 nCurrentPos, sal_Int32 nLen) override
Definition: docxexport.cxx:148
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:446
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:139
virtual ExportFormat GetExportFormat() const override
Definition: docxexport.hxx:194
sal_uIntPtr sal_uLong
virtual void WriteHyperlinkData(const ::sw::mark::IFieldmark &rFieldmark) override
Definition: docxexport.cxx:322
Base class of all fields.
Definition: fldbas.hxx:289
Definition: doc.hxx:186
exports com.sun.star. awt
void WriteSettings()
Write word/settings.xml.
Definition: docxexport.cxx:972
DocxExport & operator=(const DocxExport &)=delete
void WriteGlossary()
void WriteFonts()
Write word/fontTable.xml.
Definition: docxexport.cxx:858
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:249
virtual void OutputGrfNode(const SwGrfNode &) override
Output SwGrfNode.
Definition: docxexport.cxx:598
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:65
virtual void SectionBreaksAndFrames(const SwTextNode &) override
Definition: docxexport.hxx:213
sal_uInt16 sal_Unicode
FieldFlags
Definition: wrtww8.hxx:141
std::unique_ptr< DocxAttributeOutput > m_pAttrOutput
Attribute output for document.
Definition: docxexport.hxx:80
const ww8::Frame * GetFloatingTableFrame() const
Definition: docxexport.hxx:122
bool const m_bTemplate
Export is done into template (.dotx)
Definition: docxexport.hxx:110
exports com.sun.star. frame
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:99
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:376
sal_Int32 m_nFooters
Footer counter.
Definition: docxexport.hxx:89
void WritePostitFields()
Write comments.xml.
Definition: docxexport.cxx:724
sal_Int32 m_nHeaders
Header counter.
Definition: docxexport.hxx:86
const ww8::Frame * m_pFloatingTableFrame
Pointer to the Frame of a floating table it is nested in.
Definition: docxexport.hxx:115
exports com.sun.star. drawing
OString WriteOLEObject(SwOLEObj &rObject, OUString &io_rProgID)
Definition: docxexport.cxx:398
void WriteOutliner(const OutlinerParaObject &rOutliner, sal_uInt8 nTyp)
virtual void AppendSection(const SwPageDesc *pPageDesc, const SwSectionFormat *pFormat, sal_uLong nLnNum) override
Definition: docxexport.cxx:549
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:782
OString AddRelation(const OUString &rType, const OUString &rTarget)
Returns the relationd id.
Definition: docxexport.cxx:219
virtual MSWordSections & Sections() const override
Access to the sections/headers/footres.
Definition: docxexport.cxx:109
virtual void AppendAnnotationMarks(const SwWW8AttrIter &rAttrs, sal_Int32 nCurrentPos, sal_Int32 nLen) override
Definition: docxexport.cxx:189
Base class for various Writer styles.
Definition: format.hxx:44
virtual void WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t) override
Definition: docxexport.hxx:155
void WriteEmbeddings()
Write word/embeddings/Worksheet[n].xlsx.
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
const ::sax_fastparser::FSHelperPtr & GetFS() const
Definition: docxexport.hxx:291
void WriteProperties()
Write docProps/core.xml.
Definition: docxexport.cxx:884
Style of a layout element.
Definition: frmfmt.hxx:58
virtual bool CollapseScriptsforWordOk(sal_uInt16 nScript, sal_uInt16 nWhich) override
Guess the script (asian/western).
Definition: docxexport.cxx:114
virtual void WriteChar(sal_Unicode) override
Definition: docxexport.hxx:156
DocxExportFilter & m_rFilter
Pointer to the filter that owns us.
Definition: docxexport.hxx:68
void OutputDML(css::uno::Reference< css::drawing::XShape > const &xShape)
Writes the shape using drawingML syntax.
Definition: docxexport.cxx:494
std::unique_ptr< oox::drawingml::DrawingML > m_pDrawingML
Access to the DrawingML writer.
Definition: docxexport.hxx:77
virtual void DoComboBox(const OUString &rName, const OUString &rHelp, const OUString &ToolTip, const OUString &rSelected, const css::uno::Sequence< OUString > &rListItems) override
Definition: docxexport.cxx:329
virtual void OutputOLENode(const SwOLENode &) override
Output SwOLENode.
Definition: docxexport.cxx:603
void SetFS(::sax_fastparser::FSHelperPtr const &mpFS)
std::shared_ptr< FastSerializerHelper > FSHelperPtr
DocxSettingsData m_aSettings
Definition: docxexport.hxx:112
virtual void OutputEndNode(const SwEndNode &) override
Output SwEndNode.
Definition: docxexport.cxx:555
void setDefaultTabStop(int stop)
Set the document default tab stop.
Definition: docxexport.hxx:289
DocxExport(DocxExportFilter &rFilter, SwDoc &rDocument, std::shared_ptr< SwUnoCursor > &pCurrentPam, SwPaM &rOriginalPam, bool bDocm, bool bTemplate)
Pass the pDocument, pCurrentPam and pOriginalPam to the base class.
DocxExportFilter & GetFilter()
Definition: docxexport.hxx:119
std::unique_ptr< DocxSdrExport > m_pSdrExport
Exporter of drawings.
Definition: docxexport.hxx:104
virtual void WriteNumbering() override
Write the numbering table.
Definition: docxexport.cxx:744
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:80
virtual sal_uLong ReplaceCr(sal_uInt8 nChar) override
Definition: docxexport.cxx:613
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:620
::sax_fastparser::FSHelperPtr m_pDocumentFS
Fast serializer for the document output.
Definition: docxexport.hxx:71
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:133
void WriteVBA()
Writes word/vbaProject.bin.
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:506
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:317
void WriteDocVars(const sax_fastparser::FSHelperPtr &pFS)
Writes the part of settings.xml.
Definition: docxexport.cxx:901
sal_Int32 m_nActiveXControls
ActiveX controls counter.
Definition: docxexport.hxx:95
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:312
::sax_fastparser::FSHelperPtr mpFS
Fast serializer to output the data.
Definition: docxexport.hxx:74
bool evenAndOddHeaders
returns true if there are any non-default settings (i.e. something to write)
Definition: docxexport.hxx:58
virtual void AppendBookmark(const OUString &rName) override
Definition: docxexport.cxx:178
#define SAL_WARN(area, stream)
Base class for WW8Export and DocxExport.
Definition: wrtww8.hxx:448
virtual ~DocxExport() override
Destructor.
Ends a section of nodes in the document model.
Definition: node.hxx:341
void SetFloatingTableFrame(const ww8::Frame *pF)
Definition: docxexport.hxx:295
Data to be written in the document settings part of the document.
Definition: docxexport.hxx:54
virtual bool AddSectionBreaksForTOX() const override
Determines the Section Breaks are to be added for TOX Section.
Definition: docxexport.hxx:135
virtual void ExportGrfBullet(const SwTextNode &) override
Definition: docxexport.cxx:213
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.