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 
34 class DocxExportFilter;
35 class SwNode;
36 class SwEndNode;
37 class SwTableNode;
38 class SwTextNode;
39 class SwGrfNode;
40 class SwOLENode;
41 class DocxSdrExport;
42 
43 namespace oox {
44  namespace drawingml { class DrawingML; }
45  namespace vml { class VMLExport; }
46 }
47 
48 namespace 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 
67 {
70 
73 
76 
78  std::unique_ptr<oox::drawingml::DrawingML> m_pDrawingML;
79 
81  std::unique_ptr<DocxAttributeOutput> m_pAttrOutput;
82 
84  std::unique_ptr<MSWordSections> m_pSections;
85 
87  sal_Int32 m_nHeaders;
88 
90  sal_Int32 m_nFooters;
91 
93  sal_Int32 m_nOLEObjects;
94 
96  sal_Int32 m_nActiveXControls;
97 
100 
102  std::unique_ptr<oox::vml::VMLExport> m_pVMLExport;
103 
105  std::unique_ptr<DocxSdrExport> m_pSdrExport;
106 
108  bool m_bDocm;
109 
111  bool const m_bTemplate;
112 
114 
117 
119  std::unique_ptr<SvtSecurityMapPersonalInfo> m_pAuthorIDs;
120 
121 public:
122 
124  const DocxExportFilter& GetFilter() const { return m_rFilter; };
125 
127 
129  virtual AttributeOutputBase& AttrOutput() const override;
130 
133 
135  virtual MSWordSections& Sections() const override;
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 SwWW8AttrIter& rAttrs, sal_Int32 nCurrentPos, sal_Int32 nLen ) override;
153 
154  virtual void ExportGrfBullet(const SwTextNode&) override;
155 
157  OString AddRelation( const OUString& rType, std::u16string_view 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 { SAL_WARN("sw.ww8", "FIXME: WriteChar() has nothing to do for docx."); }
161 
163  virtual bool DisallowInheritingOutlineNumbering( const SwFormat &rFormat ) override;
164 
166  virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
167  const SwFrameFormat& rFormat, const SwFrameFormat& rLeftHeaderFormat, const SwFrameFormat& rLeftFooterFormat, const SwFrameFormat& rFirstPageFormat,
168  sal_uInt8 nBreakCode, bool bEvenAndOddHeaders ) override;
169 
171  virtual void OutputField( const SwField* pField, ww::eField eFieldType,
172  const OUString& rFieldCmd, FieldFlags nMode = FieldFlags::All ) override;
173 
175  virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) override;
176  virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark ) override;
177 
178  virtual void DoComboBox(const OUString &rName,
179  const OUString &rHelp,
180  const OUString &ToolTip,
181  const OUString &rSelected,
182  const css::uno::Sequence<OUString> &rListItems) override;
183 
184  virtual void DoFormText(const SwInputField * pField) override;
185 
186  virtual sal_uLong ReplaceCr( sal_uInt8 nChar ) override;
187 
189  OString OutputChart( css::uno::Reference< css::frame::XModel > const & xModel, sal_Int32 nCount, ::sax_fastparser::FSHelperPtr const & m_pSerializer );
190  OString WriteOLEObject(SwOLEObj& rObject, OUString & io_rProgID);
191  std::pair<OString,OString> WriteActiveXObject(const uno::Reference<css::drawing::XShape>& rxShape,
192  const uno::Reference<awt::XControlModel>& rxControlModel);
193 
195  void OutputDML( css::uno::Reference< css::drawing::XShape > const & xShape );
196 
197  sal_Int32 WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp, bool bNeedsLastParaId);
198 
199  virtual ExportFormat GetExportFormat() const override { return ExportFormat::DOCX; }
200 
201 protected:
203  virtual ErrCode ExportDocument_Impl() override;
204 
206  virtual void OutputEndNode( const SwEndNode& ) override;
207 
209  virtual void OutputGrfNode( const SwGrfNode& ) override;
210 
212  virtual void OutputOLENode( const SwOLENode& ) override;
213 
214  virtual void OutputLinkedOLE( const OUString& ) override;
215 
216  virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFormat* pFormat, sal_uLong nLnNum ) override;
217 
218  virtual void SectionBreaksAndFrames( const SwTextNode& /*rNode*/ ) override {}
219 
221  virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
222  const SwNode& rNd,
223  const SwFormatPageDesc* pNewPgDescFormat,
224  const SwPageDesc* pNewPgDesc,
225  bool bExtraPageBreak = false) override;
226 
227 private:
229  void InitStyles();
230 
232  void WriteFootnotesEndnotes();
233 
235  void WritePostitFields();
236 
238  virtual void WriteNumbering() override;
239 
241  void WriteHeaderFooter( const SwFormat* pFormat, bool bHeader, const char* pType );
242 
244  void WriteFonts();
245 
247  void WriteProperties();
248 
250  void WriteSettings();
251 
253  void WriteDocVars(const sax_fastparser::FSHelperPtr& pFS);
254 
256  void WriteTheme();
257 
258  void WriteGlossary();
259 
261  void WriteCustomXml();
262 
264  void WriteEmbeddings();
265 
267  void WriteVBA();
268 
270  bool isMirroredMargin();
271 
272 public:
275 
278  void WriteMainText();
279 
281  DocxExport( DocxExportFilter& rFilter, SwDoc& rDocument,
282  std::shared_ptr<SwUnoCursor> & pCurrentPam, SwPaM& rOriginalPam,
283  bool bDocm, bool bTemplate);
284 
286  virtual ~DocxExport() override;
287 
290 
293 
295  void setDefaultTabStop( int stop ) { m_aSettings.defaultTabStop = stop; }
296 
297  const ::sax_fastparser::FSHelperPtr& GetFS() const { return mpFS; }
298 
299  void SetFS(::sax_fastparser::FSHelperPtr const & mpFS);
300 
301  void SetFloatingTableFrame(const ww8::Frame* pF) { m_pFloatingTableFrame = pF; }
302 
303  // Get author id to remove personal info
304  size_t GetInfoID( const OUString sPersonalInfo ) const { return m_pAuthorIDs->GetInfoID(sPersonalInfo); }
305 
306  // needed in docxsdrexport.cxx and docxattributeoutput.cxx
307  sal_Int32 getWordCompatibilityModeFromGrabBag() const;
308 
309 private:
310  DocxExport( const DocxExport& ) = delete;
311 
312  DocxExport& operator=( const DocxExport& ) = delete;
313 };
314 
315 #endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXEXPORT_HXX
316 
317 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const DocxExportFilter & GetFilter() const
Definition: docxexport.hxx:124
void WriteFootnotesEndnotes()
Write footnotes.xml and endnotes.xml.
Definition: docxexport.cxx:668
std::unique_ptr< SvtSecurityMapPersonalInfo > m_pAuthorIDs
Map authors to remove personal info.
Definition: docxexport.hxx:119
std::unique_ptr< MSWordSections > m_pSections
Sections/headers/footers.
Definition: docxexport.hxx:84
void InitStyles()
Setup pStyles and write styles.xml.
Definition: docxexport.cxx:645
virtual void DoFormText(const SwInputField *pField) override
Definition: docxexport.cxx:370
virtual void OutputLinkedOLE(const OUString &) override
Definition: docxexport.cxx:609
std::unique_ptr< oox::vml::VMLExport > m_pVMLExport
Exporter of the VML shapes.
Definition: docxexport.hxx:102
bool hasData() const
sal_Int32 m_nHeadersFootersInSection
Footer and Header counter in Section properties.
Definition: docxexport.hxx:99
Class to collect and output the sections/headers/footers.
Definition: wrtww8.hxx:194
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:108
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:93
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
std::pair< OString, OString > WriteActiveXObject(const uno::Reference< css::drawing::XShape > &rxShape, const uno::Reference< awt::XControlModel > &rxControlModel)
Definition: docxexport.cxx:447
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:199
sal_uIntPtr sal_uLong
virtual void WriteHyperlinkData(const ::sw::mark::IFieldmark &rFieldmark) override
Definition: docxexport.cxx:323
Base class of all fields.
Definition: fldbas.hxx:289
Definition: doc.hxx:188
exports com.sun.star. awt
void WriteSettings()
Write word/settings.xml.
Definition: docxexport.cxx:989
DocxExport & operator=(const DocxExport &)=delete
void WriteGlossary()
void WriteFonts()
Write word/fontTable.xml.
Definition: docxexport.cxx:875
virtual void OutputGrfNode(const SwGrfNode &) override
Output SwGrfNode.
Definition: docxexport.cxx:599
void WriteCustomXml()
Write customXml/item[n].xml and customXml/itemProps[n].xml.
bool isMirroredMargin()
return true if Page Layout is set as Mirrored
The class that does all the actual DOCX export-related work.
Definition: docxexport.hxx:66
size_t GetInfoID(const OUString sPersonalInfo) const
Definition: docxexport.hxx:304
virtual void SectionBreaksAndFrames(const SwTextNode &) override
Definition: docxexport.hxx:218
sal_uInt16 sal_Unicode
FieldFlags
Definition: wrtww8.hxx:141
std::unique_ptr< DocxAttributeOutput > m_pAttrOutput
Attribute output for document.
Definition: docxexport.hxx:81
const ww8::Frame * GetFloatingTableFrame() const
Definition: docxexport.hxx:126
sal_Int32 getWordCompatibilityModeFromGrabBag() const
bool const m_bTemplate
Export is done into template (.dotx)
Definition: docxexport.hxx:111
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:377
sal_Int32 m_nFooters
Footer counter.
Definition: docxexport.hxx:90
void WritePostitFields()
Write comments.xml.
Definition: docxexport.cxx:725
sal_Int32 m_nHeaders
Header counter.
Definition: docxexport.hxx:87
const ww8::Frame * m_pFloatingTableFrame
Pointer to the Frame of a floating table it is nested in.
Definition: docxexport.hxx:116
exports com.sun.star. drawing
OString WriteOLEObject(SwOLEObj &rObject, OUString &io_rProgID)
Definition: docxexport.cxx:399
virtual void AppendSection(const SwPageDesc *pPageDesc, const SwSectionFormat *pFormat, sal_uLong nLnNum) override
Definition: docxexport.cxx:550
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:803
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:46
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
const ::sax_fastparser::FSHelperPtr & GetFS() const
Definition: docxexport.hxx:297
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:621
void WriteProperties()
Write docProps/core.xml.
Definition: docxexport.cxx:901
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:160
DocxExportFilter & m_rFilter
Pointer to the filter that owns us.
Definition: docxexport.hxx:69
void OutputDML(css::uno::Reference< css::drawing::XShape > const &xShape)
Writes the shape using drawingML syntax.
Definition: docxexport.cxx:495
std::unique_ptr< oox::drawingml::DrawingML > m_pDrawingML
Access to the DrawingML writer.
Definition: docxexport.hxx:78
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:249
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:330
virtual void OutputOLENode(const SwOLENode &) override
Output SwOLENode.
Definition: docxexport.cxx:604
void SetFS(::sax_fastparser::FSHelperPtr const &mpFS)
std::shared_ptr< FastSerializerHelper > FSHelperPtr
DocxSettingsData m_aSettings
Definition: docxexport.hxx:113
virtual void OutputEndNode(const SwEndNode &) override
Output SwEndNode.
Definition: docxexport.cxx:556
rtl::Reference< sax_fastparser::FastAttributeList > MainXmlNamespaces()
All xml namespaces to be used at the top of any text .xml file (main doc, headers, footers,...)
void setDefaultTabStop(int stop)
Set the document default tab stop.
Definition: docxexport.hxx:295
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:123
std::unique_ptr< DocxSdrExport > m_pSdrExport
Exporter of drawings.
Definition: docxexport.hxx:105
virtual void WriteNumbering() override
Write the numbering table.
Definition: docxexport.cxx:765
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
virtual sal_uLong ReplaceCr(sal_uInt8 nChar) override
Definition: docxexport.cxx:614
::sax_fastparser::FSHelperPtr m_pDocumentFS
Fast serializer for the document output.
Definition: docxexport.hxx:72
oox::vml::VMLExport & VMLExporter()
Reference to the VMLExport instance for the main document.
Definition: docxexport.hxx:289
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.
unsigned char sal_uInt8
Make exporting a Writer Frame easy.
DocxSdrExport & SdrExporter()
Reference to the DocxSdrExport instance for the main document.
Definition: docxexport.hxx:292
virtual ErrCode ExportDocument_Impl() override
Format-dependent part of the actual export.
Definition: docxexport.cxx:507
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:318
void WriteDocVars(const sax_fastparser::FSHelperPtr &pFS)
Writes the part of settings.xml.
Definition: docxexport.cxx:918
sal_Int32 m_nActiveXControls
ActiveX controls counter.
Definition: docxexport.hxx:96
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:313
::sax_fastparser::FSHelperPtr mpFS
Fast serializer to output the data.
Definition: docxexport.hxx:75
bool evenAndOddHeaders
returns true if there are any non-default settings (i.e. something to write)
Definition: docxexport.hxx:59
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:449
virtual ~DocxExport() override
Destructor.
Ends a section of nodes in the document model.
Definition: node.hxx:342
void SetFloatingTableFrame(const ww8::Frame *pF)
Definition: docxexport.hxx:301
Data to be written in the document settings part of the document.
Definition: docxexport.hxx:55
OString AddRelation(const OUString &rType, std::u16string_view rTarget)
Returns the relationd id.
Definition: docxexport.cxx:219
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:213
sal_Int32 WriteOutliner(const OutlinerParaObject &rOutliner, sal_uInt8 nTyp, bool bNeedsLastParaId)
Base class of the Writer document model elements.
Definition: node.hxx:80
void WriteMainText()
FIXME this is temporary, remotely reminding the method of the same name in WW8Export.