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>
32
35class SwNode;
36class SwEndNode;
37class SwTableNode;
38class SwTextNode;
39class SwGrfNode;
40class SwOLENode;
41class DocxSdrExport;
42
43namespace oox {
44 namespace drawingml { class DrawingML; }
45 namespace vml { class VMLExport; }
46}
47
48namespace com::sun::star {
49 namespace frame { class XModel; }
50 namespace drawing { class XShape; }
51 namespace awt { class XControlModel; }
52}
53
56{
58 bool hasData() const;
61 bool revisionView; // don't show tracked changes
62 bool trackRevisions; // Should 'Track Revisions' be set
63};
64
66struct SdtData
67{
68 OUString namespaces;
69 OUString xpath;
70 OUString data;
71};
72
75{
78
81
84
86 std::unique_ptr<oox::drawingml::DrawingML> m_pDrawingML;
87
89 std::unique_ptr<DocxAttributeOutput> m_pAttrOutput;
90
92 std::unique_ptr<MSWordSections> m_pSections;
93
95 sal_Int32 m_nHeaders;
96
98 sal_Int32 m_nFooters;
99
101 sal_Int32 m_nOLEObjects;
102
105
108
110 std::unique_ptr<oox::vml::VMLExport> m_pVMLExport;
111
113 std::unique_ptr<DocxSdrExport> m_pSdrExport;
114
117
119 bool const m_bTemplate;
120
122
125
127 std::unique_ptr<SvtSecurityMapPersonalInfo> m_pAuthorIDs;
128
130 std::vector<SdtData> m_SdtData;
131
132public:
133
135 const DocxExportFilter& GetFilter() const { return m_rFilter; };
136
138
140 virtual AttributeOutputBase& AttrOutput() const override;
141
144
146 virtual MSWordSections& Sections() const override;
147
148 virtual bool FieldsQuoted() const override { return true; }
149
150 virtual bool AddSectionBreaksForTOX() const override { return true; }
151
152 virtual bool ignoreAttributeForStyleDefaults( sal_uInt16 nWhich ) const override;
153
154 virtual bool PreferPageBreakBefore() const override { return false; }
155
157 virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ) override;
158
159 virtual void AppendBookmarks( const SwTextNode& rNode, sal_Int32 nCurrentPos, sal_Int32 nLen, const SwRedlineData* pRedlineData = nullptr ) override;
160
161 virtual void AppendBookmark( const OUString& rName ) override;
162
163 virtual void AppendAnnotationMarks( const SwWW8AttrIter& rAttrs, sal_Int32 nCurrentPos, sal_Int32 nLen ) override;
164
165 virtual void ExportGrfBullet(const SwTextNode&) override;
166
168 OString AddRelation( const OUString& rType, std::u16string_view rTarget );
169
170 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 */ }
171 virtual void WriteChar( sal_Unicode ) override { SAL_WARN("sw.ww8", "FIXME: WriteChar() has nothing to do for docx."); }
172
174 virtual bool DisallowInheritingOutlineNumbering( const SwFormat &rFormat ) override;
175
177 virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
178 const SwFrameFormat& rFormat, const SwFrameFormat& rLeftHeaderFormat, const SwFrameFormat& rLeftFooterFormat, const SwFrameFormat& rFirstPageFormat,
179 sal_uInt8 nBreakCode, bool bEvenAndOddHeaders ) override;
180
182 virtual void OutputField( const SwField* pField, ww::eField eFieldType,
183 const OUString& rFieldCmd, FieldFlags nMode = FieldFlags::All ) override;
184
186 virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) override;
187 virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark ) override;
188
189 virtual void DoComboBox(const OUString &rName,
190 const OUString &rHelp,
191 const OUString &ToolTip,
192 const OUString &rSelected,
193 const css::uno::Sequence<OUString> &rListItems) override;
194
195 virtual void DoFormText(const SwInputField * pField) override;
196
197 virtual sal_uInt64 ReplaceCr( sal_uInt8 nChar ) override;
198
200 OString OutputChart( css::uno::Reference< css::frame::XModel > const & xModel, sal_Int32 nCount, ::sax_fastparser::FSHelperPtr const & m_pSerializer );
201 OString WriteOLEObject(SwOLEObj& rObject, OUString & io_rProgID);
202 std::pair<OString,OString> WriteActiveXObject(const uno::Reference<css::drawing::XShape>& rxShape,
203 const uno::Reference<awt::XControlModel>& rxControlModel);
204
206 void OutputDML( css::uno::Reference< css::drawing::XShape > const & xShape );
207
208 sal_Int32 WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp, bool bNeedsLastParaId);
209
210 virtual ExportFormat GetExportFormat() const override { return ExportFormat::DOCX; }
211
212 void AddSdtData(const OUString & namespaces, const OUString & xpath, const OUString & data)
213 {
214 m_SdtData.push_back({ namespaces, xpath, data });
215 }
216
217protected:
219 virtual ErrCode ExportDocument_Impl() override;
220
222 virtual void OutputEndNode( const SwEndNode& ) override;
223
225 virtual void OutputGrfNode( const SwGrfNode& ) override;
226
228 virtual void OutputOLENode( const SwOLENode& ) override;
229
230 virtual void OutputLinkedOLE( const OUString& ) override;
231
232 virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFormat* pFormat, sal_uLong nLnNum ) override;
233
234 virtual void SectionBreaksAndFrames( const SwTextNode& /*rNode*/ ) override {}
235
237 virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
238 const SwNode& rNd,
239 const SwFormatPageDesc* pNewPgDescFormat,
240 const SwPageDesc* pNewPgDesc,
241 bool bExtraPageBreak = false) override;
242
243private:
245 void InitStyles();
246
249
251 void WritePostitFields();
252
254 virtual void WriteNumbering() override;
255
257 void WriteHeaderFooter( const SwFormat* pFormat, bool bHeader, const char* pType );
258
260 void WriteFonts();
261
263 void WriteProperties();
264
266 void WriteSettings();
267
270
272 void WriteTheme();
273
274 void WriteGlossary();
275
277 void WriteCustomXml();
278
280 void WriteEmbeddings();
281
283 void WriteVBA();
284
286 bool isMirroredMargin();
287
288public:
291
294 void WriteMainText();
295
297 DocxExport( DocxExportFilter& rFilter, SwDoc& rDocument,
298 std::shared_ptr<SwUnoCursor> & pCurrentPam, SwPaM& rOriginalPam,
299 bool bDocm, bool bTemplate);
300
302 virtual ~DocxExport() override;
303
306
309
312
313 const ::sax_fastparser::FSHelperPtr& GetFS() const { return mpFS; }
314
316
318
319 // Get author id to remove personal info
320 size_t GetInfoID( const OUString sPersonalInfo ) const { return m_pAuthorIDs->GetInfoID(sPersonalInfo); }
321
322 // needed in docxsdrexport.cxx and docxattributeoutput.cxx
323 sal_Int32 getWordCompatibilityModeFromGrabBag() const;
324
325private:
326 DocxExport( const DocxExport& ) = delete;
327
328 DocxExport& operator=( const DocxExport& ) = delete;
329};
330
331#endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXEXPORT_HXX
332
333/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
The class that has handlers for various resource types when exporting as DOCX.
The physical access to the DOCX document (for writing).
The class that does all the actual DOCX export-related work.
Definition: docxexport.hxx:75
virtual void SectionBreaksAndFrames(const SwTextNode &) override
Definition: docxexport.hxx:234
virtual bool FieldsQuoted() const override
Determines if the import filter already quoted fields or not.
Definition: docxexport.hxx:148
virtual void WriteNumbering() override
Write the numbering table.
Definition: docxexport.cxx:794
rtl::Reference< sax_fastparser::FastAttributeList > MainXmlNamespaces()
All xml namespaces to be used at the top of any text .xml file (main doc, headers,...
virtual void AppendAnnotationMarks(const SwWW8AttrIter &rAttrs, sal_Int32 nCurrentPos, sal_Int32 nLen) override
Definition: docxexport.cxx:198
sal_Int32 m_nFooters
Footer counter.
Definition: docxexport.hxx:98
void WriteTheme()
Write word/theme/theme1.xml.
virtual MSWordSections & Sections() const override
Access to the sections/headers/footres.
Definition: docxexport.cxx:121
virtual void OutputField(const SwField *pField, ww::eField eFieldType, const OUString &rFieldCmd, FieldFlags nMode=FieldFlags::All) override
Write the field.
Definition: docxexport.cxx:321
void WritePostitFields()
Write comments.xml.
Definition: docxexport.cxx:752
void SetFloatingTableFrame(const ww8::Frame *pF)
Definition: docxexport.hxx:317
virtual bool DisallowInheritingOutlineNumbering(const SwFormat &rFormat) override
Return value indicates if an inherited outline numbering is suppressed.
Definition: docxexport.cxx:236
const ww8::Frame * m_pFloatingTableFrame
Pointer to the Frame of a floating table it is nested in.
Definition: docxexport.hxx:124
DocxExport(const DocxExport &)=delete
virtual void WriteChar(sal_Unicode) override
Definition: docxexport.hxx:171
OString AddRelation(const OUString &rType, std::u16string_view rTarget)
Returns the relationd id.
Definition: docxexport.cxx:228
std::pair< OString, OString > WriteActiveXObject(const uno::Reference< css::drawing::XShape > &rxShape, const uno::Reference< awt::XControlModel > &rxControlModel)
Definition: docxexport.cxx:461
sal_Int32 WriteOutliner(const OutlinerParaObject &rOutliner, sal_uInt8 nTyp, bool bNeedsLastParaId)
virtual void PrepareNewPageDesc(const SfxItemSet *pSet, const SwNode &rNd, const SwFormatPageDesc *pNewPgDescFormat, const SwPageDesc *pNewPgDesc, bool bExtraPageBreak=false) override
Get ready for a new section.
Definition: docxexport.cxx:642
virtual void AppendBookmark(const OUString &rName) override
Definition: docxexport.cxx:190
DocxExport & operator=(const DocxExport &)=delete
void WriteProperties()
Write docProps/core.xml.
Definition: docxexport.cxx:936
const ww8::Frame * GetFloatingTableFrame() const
Definition: docxexport.hxx:137
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:154
const ::sax_fastparser::FSHelperPtr & GetFS() const
Definition: docxexport.hxx:313
virtual void AppendBookmarks(const SwTextNode &rNode, sal_Int32 nCurrentPos, sal_Int32 nLen, const SwRedlineData *pRedlineData=nullptr) override
Definition: docxexport.cxx:160
const DocxExportFilter & GetFilter() const
Definition: docxexport.hxx:135
std::vector< SdtData > m_SdtData
Storage for sdt data which need to be written to other XMLs.
Definition: docxexport.hxx:130
void WriteSettings()
Write word/settings.xml.
virtual ErrCode ExportDocument_Impl() override
Format-dependent part of the actual export.
Definition: docxexport.cxx:523
virtual void OutputOLENode(const SwOLENode &) override
Output SwOLENode.
Definition: docxexport.cxx:625
bool m_bDocm
If the result will be a .docm file or not.
Definition: docxexport.hxx:116
virtual void ExportGrfBullet(const SwTextNode &) override
Definition: docxexport.cxx:222
virtual sal_uInt64 ReplaceCr(sal_uInt8 nChar) override
Definition: docxexport.cxx:635
OString WriteOLEObject(SwOLEObj &rObject, OUString &io_rProgID)
Definition: docxexport.cxx:413
sal_Int32 m_nHeadersFootersInSection
Footer and Header counter in Section properties.
Definition: docxexport.hxx:107
void AddSdtData(const OUString &namespaces, const OUString &xpath, const OUString &data)
Definition: docxexport.hxx:212
::sax_fastparser::FSHelperPtr m_pDocumentFS
Fast serializer for the document output.
Definition: docxexport.hxx:80
std::unique_ptr< DocxSdrExport > m_pSdrExport
Exporter of drawings.
Definition: docxexport.hxx:113
oox::vml::VMLExport & VMLExporter()
Reference to the VMLExport instance for the main document.
Definition: docxexport.hxx:305
::sax_fastparser::FSHelperPtr mpFS
Fast serializer to output the data.
Definition: docxexport.hxx:83
virtual void OutputGrfNode(const SwGrfNode &) override
Output SwGrfNode.
Definition: docxexport.cxx:620
virtual void AppendSection(const SwPageDesc *pPageDesc, const SwSectionFormat *pFormat, sal_uLong nLnNum) override
Definition: docxexport.cxx:571
DocxExportFilter & m_rFilter
Pointer to the filter that owns us.
Definition: docxexport.hxx:77
void InitStyles()
Setup pStyles and write styles.xml.
Definition: docxexport.cxx:666
void WriteMainText()
FIXME this is temporary, remotely reminding the method of the same name in WW8Export.
virtual void WriteHeadersFooters(sal_uInt8 nHeadFootFlags, const SwFrameFormat &rFormat, const SwFrameFormat &rLeftHeaderFormat, const SwFrameFormat &rLeftFooterFormat, const SwFrameFormat &rFirstPageFormat, sal_uInt8 nBreakCode, bool bEvenAndOddHeaders) override
Output the actual headers and footers.
Definition: docxexport.cxx:258
std::unique_ptr< MSWordSections > m_pSections
Sections/headers/footers.
Definition: docxexport.hxx:92
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:834
virtual void OutputLinkedOLE(const OUString &) override
Definition: docxexport.cxx:630
virtual void DoFormText(const SwInputField *pField) override
Definition: docxexport.cxx:376
bool const m_bTemplate
Export is done into template (.dotx)
Definition: docxexport.hxx:119
virtual void WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t) override
Definition: docxexport.hxx:170
void WriteFootnotesEndnotes()
Write footnotes.xml and endnotes.xml.
Definition: docxexport.cxx:691
std::unique_ptr< DocxAttributeOutput > m_pAttrOutput
Attribute output for document.
Definition: docxexport.hxx:89
bool isMirroredMargin()
return true if Page Layout is set as Mirrored
virtual bool AddSectionBreaksForTOX() const override
Determines the Section Breaks are to be added for TOX Section.
Definition: docxexport.hxx:150
sal_Int32 m_nOLEObjects
OLE objects counter.
Definition: docxexport.hxx:101
virtual ~DocxExport() override
Destructor.
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:336
virtual bool CollapseScriptsforWordOk(sal_uInt16 nScript, sal_uInt16 nWhich) override
Guess the script (asian/western).
Definition: docxexport.cxx:126
virtual void WriteHyperlinkData(const ::sw::mark::IFieldmark &rFieldmark) override
Definition: docxexport.cxx:331
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.
void WriteVBA()
Writes word/vbaProject.bin.
virtual void OutputEndNode(const SwEndNode &) override
Output SwEndNode.
Definition: docxexport.cxx:577
void WriteFonts()
Write word/fontTable.xml.
Definition: docxexport.cxx:908
size_t GetInfoID(const OUString sPersonalInfo) const
Definition: docxexport.hxx:320
void WriteEmbeddings()
Write word/embeddings/Worksheet[n].xlsx.
DocxSdrExport & SdrExporter()
Reference to the DocxSdrExport instance for the main document.
Definition: docxexport.hxx:308
std::unique_ptr< oox::vml::VMLExport > m_pVMLExport
Exporter of the VML shapes.
Definition: docxexport.hxx:110
virtual AttributeOutputBase & AttrOutput() const override
Access to the attribute output class.
Definition: docxexport.cxx:111
std::unique_ptr< SvtSecurityMapPersonalInfo > m_pAuthorIDs
Map authors to remove personal info.
Definition: docxexport.hxx:127
std::unique_ptr< oox::drawingml::DrawingML > m_pDrawingML
Access to the DrawingML writer.
Definition: docxexport.hxx:86
DocxAttributeOutput & DocxAttrOutput() const
Access to the derived attribute output class.
Definition: docxexport.cxx:116
void SetFS(::sax_fastparser::FSHelperPtr const &mpFS)
void WriteDocVars(const sax_fastparser::FSHelperPtr &pFS)
Writes the <w:docVars> part of settings.xml.
Definition: docxexport.cxx:953
virtual void WriteFormData(const ::sw::mark::IFieldmark &rFieldmark) override
Write the data of the form field.
Definition: docxexport.cxx:326
virtual ExportFormat GetExportFormat() const override
Definition: docxexport.hxx:210
void setDefaultTabStop(int stop)
Set the document default tab stop.
Definition: docxexport.hxx:311
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:383
DocxSettingsData m_aSettings
Definition: docxexport.hxx:121
DocxExportFilter & GetFilter()
Definition: docxexport.hxx:134
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.
sal_Int32 getWordCompatibilityModeFromGrabBag() const
sal_Int32 m_nHeaders
Header counter.
Definition: docxexport.hxx:95
void WriteGlossary()
sal_Int32 m_nActiveXControls
ActiveX controls counter.
Definition: docxexport.hxx:104
void OutputDML(css::uno::Reference< css::drawing::XShape > const &xShape)
Writes the shape using drawingML syntax.
Definition: docxexport.cxx:511
void WriteCustomXml()
Write customXml/item[n].xml and customXml/itemProps[n].xml.
Handles DOCX export of drawings.
Base class for WW8Export and DocxExport.
Definition: wrtww8.hxx:451
Class to collect and output the sections/headers/footers.
Definition: wrtww8.hxx:196
Definition: doc.hxx:197
Ends a section of nodes in the document model.
Definition: node.hxx:378
Base class of all fields.
Definition: fldbas.hxx:296
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:36
Base class for various Writer styles.
Definition: format.hxx:47
Style of a layout element.
Definition: frmfmt.hxx:72
Base class of the Writer document model elements.
Definition: node.hxx:98
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
Make exporting a Writer Frame easy.
std::shared_ptr< WW8TableNodeInfoInner > Pointer_t
#define SAL_WARN(area, stream)
def stop(arg=None)
std::shared_ptr< FastSerializerHelper > FSHelperPtr
sal_uIntPtr sal_uLong
Data to be written in the document settings part of the document.
Definition: docxexport.hxx:56
bool evenAndOddHeaders
returns true if there are any non-default settings (i.e. something to write)
Definition: docxexport.hxx:59
bool hasData() const
Data to keep and write to XMLs.
Definition: docxexport.hxx:67
OUString namespaces
Definition: docxexport.hxx:68
OUString data
Definition: docxexport.hxx:70
OUString xpath
Definition: docxexport.hxx:69
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
FieldFlags
Definition: wrtww8.hxx:143