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_XMLOFF_XMLEXP_HXX
21 #define INCLUDED_XMLOFF_XMLEXP_HXX
22 
23 #include <sal/config.h>
24 #include <xmloff/dllapi.h>
25 #include <sal/types.h>
26 
27 #include <com/sun/star/lang/XUnoTunnel.hpp>
28 #include <rtl/ustring.hxx>
29 #include <xmloff/attrlist.hxx>
30 #include <xmloff/txtparae.hxx>
31 #include <xmloff/formlayerexport.hxx>
32 #include <xmloff/xmlnumfe.hxx>
33 #include <xmloff/xmlaustp.hxx>
34 #include <xmloff/shapeexport.hxx>
35 #include <xmloff/xmltoken.hxx>
36 #include <xmloff/SchXMLExportHelper.hxx>
37 #include <xmloff/XMLFontAutoStylePool.hxx>
38 #include <xmloff/xmluconv.hxx>
39 #include <com/sun/star/document/XFilter.hpp>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
41 #include <com/sun/star/document/XExporter.hpp>
42 #include <com/sun/star/lang/XInitialization.hpp>
43 #include <com/sun/star/container/XNamed.hpp>
44 
45 #include <unotools/saveopt.hxx>
46 #include <unotools/securityoptions.hxx>
47 
48 #include <xmloff/XMLPageExport.hxx>
49 #include <comphelper/servicehelper.hxx>
50 #include <cppuhelper/implbase.hxx>
51 #include <tools/fldunit.hxx>
52 #include <vcl/errcode.hxx>
53 
54 #include <vector>
55 #include <memory>
56 #include <o3tl/typed_flags_set.hxx>
57 
58 namespace com::sun::star::beans { class XPropertySet; }
59 namespace com::sun::star::document { class XEmbeddedObjectResolver; }
60 namespace com::sun::star::document { class XGraphicStorageHandler; }
61 namespace com::sun::star::embed { class XStorage; }
62 namespace com::sun::star::graphic { class XGraphic; }
63 namespace com::sun::star::lang { class XEventListener; }
64 namespace com::sun::star::task { class XStatusIndicator; }
65 namespace com::sun::star::uno { class XComponentContext; }
66 namespace com::sun::star::util { class XNumberFormatsSupplier; }
67 namespace com::sun::star::xml::sax { class XAttributeList; }
68 namespace com::sun::star::xml::sax { class XDocumentHandler; }
69 namespace com::sun::star::xml::sax { class XExtendedDocumentHandler; }
70 namespace com::sun::star::xml::sax { class XLocator; }
71 
72 class SvXMLNamespaceMap;
73 class SvtSecurityMapPersonalInfo;
74 class SvXMLExport_Impl;
75 class ProgressBarHelper;
76 class XMLEventExport;
77 class XMLImageMapExport;
78 class XMLErrors;
79 class LanguageTag;
80 enum class SvXMLErrorFlags;
81 
82 // Shapes in Writer cannot be named via context menu (#i51726#)
83 #include <unotools/moduleoptions.hxx>
84 
85 namespace com::sun::star {
86     namespace frame { class XModel; }
87     namespace lang { struct Locale; }
88 }
89 namespace comphelper { class UnoInterfaceToUniqueIdentifierMapper; }
90 
91 enum class SvXMLExportFlags {
92     NONE                     = 0,
93     META                     = 0x0001,
94     STYLES                   = 0x0002,
95     MASTERSTYLES             = 0x0004,
96     AUTOSTYLES               = 0x0008,
97     CONTENT                  = 0x0010,
98     SCRIPTS                  = 0x0020,
99     SETTINGS                 = 0x0040,
100     FONTDECLS                = 0x0080,
101     EMBEDDED                 = 0x0100,
102     PRETTY                   = 0x0400,
103     OASIS                    = 0x8000,
104     ALL                      = 0x05ff
105 };
106 namespace o3tl
107 {
108     template<> struct typed_flags<SvXMLExportFlags> : is_typed_flags<SvXMLExportFlags, 0x85ff> {};
109 }
110 
111 class XMLOFF_DLLPUBLIC SvXMLExport : public cppu::WeakImplHelper<
112              css::document::XFilter,
113              css::lang::XServiceInfo,
114              css::document::XExporter,
115              css::lang::XInitialization,
116              css::container::XNamed,
117              css::lang::XUnoTunnel>
118 {
119     std::unique_ptr<SvXMLExport_Impl>            mpImpl;            // dummy
120 
121     css::uno::Reference< css::uno::XComponentContext > m_xContext;
122     OUString m_implementationName;
123 
124     css::uno::Reference< css::frame::XModel > mxModel;
125     css::uno::Reference< css::xml::sax::XDocumentHandler >            mxHandler;      // the handlers
126     css::uno::Reference< css::xml::sax::XExtendedDocumentHandler >    mxExtHandler;
127     css::uno::Reference< css::util::XNumberFormatsSupplier > mxNumberFormatsSupplier;
128     css::uno::Reference< css::document::XGraphicStorageHandler > mxGraphicStorageHandler;
129     css::uno::Reference< css::document::XEmbeddedObjectResolver > mxEmbeddedResolver;
130     css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator;
131     css::uno::Reference< css::beans::XPropertySet > mxExportInfo;
132     css::uno::Reference< css::lang::XEventListener > mxEventListener;
133 
134     rtl::Reference<SvXMLAttributeList>          mxAttrList;        // a common attribute list
135 
136     OUString     msOrigFileName; // the original URL
137     OUString     msFilterName;
138     OUString     msImgFilterName;
139     std::unique_ptr<SvXMLNamespaceMap> mpNamespaceMap;    // the namespace map
140     std::unique_ptr<SvtSecurityMapPersonalInfo> mpAuthorIDs; // map authors to remove personal info
141     SvXMLUnitConverter          maUnitConv;        // the unit converter
142     std::unique_ptr<SvXMLNumFmtExport> mpNumExport;
143     std::unique_ptr<ProgressBarHelper> mpProgressBarHelper;
144 
145     rtl::Reference< XMLTextParagraphExport > mxTextParagraphExport;
146     rtl::Reference< XMLShapeExport > mxShapeExport;
147     rtl::Reference< SvXMLAutoStylePoolP > mxAutoStylePool;
148     rtl::Reference< SchXMLExportHelper > mxChartExport;
149     rtl::Reference< XMLPageExport > mxPageExport;
150     rtl::Reference< XMLFontAutoStylePool > mxFontAutoStylePool;
151     rtl::Reference< xmloff::OFormLayerXMLExport > mxFormExport;
152     std::unique_ptr<XMLEventExport> mpEventExport;
153     std::unique_ptr<XMLImageMapExport> mpImageMapExport;
154     std::unique_ptr<XMLErrors>  mpXMLErrors;
155 
156     const enum ::xmloff::token::XMLTokenEnum meClass;
157     SAL_DLLPRIVATE void InitCtor_();
158 
159     SvXMLExportFlags  mnExportFlags;
160     SvXMLErrorFlags   mnErrorFlags;
161 
162     const OUString               msWS;           // " "
163 
164     // Shapes in Writer cannot be named via context menu (#i51726#)
165     SvtModuleOptions::EFactory meModelType;
166     SAL_DLLPRIVATE void DetermineModelType_();
167 
168     SAL_DLLPRIVATE void ImplExportMeta(); // <office:meta>
169     SAL_DLLPRIVATE void ImplExportSettings(); // <office:settings>
170     SAL_DLLPRIVATE void ImplExportStyles(); // <office:styles>
171     SAL_DLLPRIVATE void ImplExportAutoStyles();
172         // <office:automatic-styles>
173     SAL_DLLPRIVATE void ImplExportMasterStyles();
174         // <office:master-styles>
175     SAL_DLLPRIVATE void ImplExportContent(); // <office:body>
176     virtual void SetBodyAttributes();
177     void GetViewSettingsAndViews(css::uno::Sequence<css::beans::PropertyValue>& rProps);
178 
179 protected:
setExportFlags(SvXMLExportFlags nExportFlags)180     void setExportFlags( SvXMLExportFlags nExportFlags ) { mnExportFlags = nExportFlags; }
181 
182     // Get (modifiable) namespace map
GetNamespaceMap_()183     SvXMLNamespaceMap& GetNamespaceMap_() { return *mpNamespaceMap; }
184 
185     // get a new namespace map (used in starmath to have a default namespace)
186     void ResetNamespaceMap();
187 
188     /// Override this method to export the content of <office:meta>.
189     /// There is a default implementation.
190     virtual void ExportMeta_();
191 
192     /// Override this method to export the content of <office:scripts>.
193     /// There is a default implementation.
194     virtual void ExportScripts_();
195 
196     /// Override this method to export the font declarations
197     /// The default implementation will export the contents of the
198     /// XMLFontAutoStylePool if it has been created.
199     virtual void ExportFontDecls_();
200 
201     /// Override this method to export the content of <style:styles>.
202     /// If bUsed is set, used styles should be exported only.
203     /// Overriding Methods must call this method !
204     virtual void ExportStyles_( bool bUsed );
205 
206     /// Override this method to export the contents of <style:auto-styles>.
207     virtual void ExportAutoStyles_() = 0;
208 
209     /// Override this method to export the contents of <style:master-styles>.
210     virtual void ExportMasterStyles_() = 0;
211 
212     /// Override this method to export the content of <office:body>.
213     virtual void ExportContent_() = 0;
214 
215     OUString const & GetSourceShellID() const;
216     OUString const & GetDestinationShellID() const;
217 
218     // save linked sections? (may be false in global documents)
219     bool mbSaveLinkedSections;
220 
221     virtual XMLTextParagraphExport* CreateTextParagraphExport();
222     virtual XMLShapeExport* CreateShapeExport();
223     virtual SvXMLAutoStylePoolP* CreateAutoStylePool();
224     SchXMLExportHelper* CreateChartExport();
225     virtual XMLPageExport* CreatePageExport();
226     virtual XMLFontAutoStylePool* CreateFontAutoStylePool();
227     xmloff::OFormLayerXMLExport* CreateFormExport();
228     virtual void GetViewSettings(css::uno::Sequence<css::beans::PropertyValue>& aProps);
229     virtual void GetConfigurationSettings(css::uno::Sequence<css::beans::PropertyValue>& aProps);
230 
231     struct SettingsGroup
232     {
233         ::xmloff::token::XMLTokenEnum                     eGroupName;
234         css::uno::Sequence< css::beans::PropertyValue >   aSettings;
235 
SettingsGroupSvXMLExport::SettingsGroup236         SettingsGroup(
237                 const ::xmloff::token::XMLTokenEnum _eGroupName,
238                 const css::uno::Sequence< css::beans::PropertyValue >& _rSettings )
239             :eGroupName( _eGroupName )
240             ,aSettings( _rSettings )
241         {
242         }
243     };
244     /** returns the current document settings
245 
246         The default implementation will obtain the view settings by calling GetViewSettingsAndViews, and the
247         configuration settings by calling GetConfigurationSettings, and return them together with the proper XML token.
248 
249         @return
250             the accumulated count of all settings in all groups
251     */
252     virtual sal_Int32 GetDocumentSpecificSettings( ::std::vector< SettingsGroup >& _out_rSettings );
253 
GetEmbeddedResolver() const254     const css::uno::Reference< css::document::XEmbeddedObjectResolver >& GetEmbeddedResolver() const { return mxEmbeddedResolver; }
255     inline void SetEmbeddedResolver( css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver );
256 
GetGraphicStorageHandler() const257     const css::uno::Reference<css::document::XGraphicStorageHandler> & GetGraphicStorageHandler() const
258     {
259         return mxGraphicStorageHandler;
260     }
261     void SetGraphicStorageHandler(css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler);
262 
263     void SetDocHandler( const css::uno::Reference< css::xml::sax::XDocumentHandler > &rHandler );
264 
265     bool mbAutoStylesCollected;
266 public:
267 
268     SvXMLExport(
269         const css::uno::Reference< css::uno::XComponentContext >& xContext,
270         OUString const & implementationName,
271         sal_Int16 const eDefaultMeasureUnit /*css::util::MeasureUnit*/,
272         const enum ::xmloff::token::XMLTokenEnum eClass,
273         SvXMLExportFlags nExportFlag );
274 
275     SvXMLExport(
276         const css::uno::Reference< css::uno::XComponentContext >& xContext,
277         OUString const & implementationName,
278         const OUString& rFileName,
279         sal_Int16 const eDefaultMeasureUnit /*css::util::MeasureUnit*/,
280         const css::uno::Reference< css::xml::sax::XDocumentHandler > & rHandler);
281 
282     SvXMLExport(
283         const css::uno::Reference< css::uno::XComponentContext >& xContext,
284         OUString const & implementationName,
285         const OUString& rFileName,
286         const css::uno::Reference< css::xml::sax::XDocumentHandler > & rHandler,
287         const css::uno::Reference< css::frame::XModel > &,
288         FieldUnit const eDefaultFieldUnit,
289         SvXMLExportFlags nExportFlag );
290 
291     virtual ~SvXMLExport() override;
292 
293     virtual void collectAutoStyles();
294 
295     // XExporter
296     virtual void SAL_CALL setSourceDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
297 
298     // XFilter
299     virtual sal_Bool SAL_CALL filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override;
300     virtual void SAL_CALL cancel() override;
301 
302     // XInitialization
303     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
304 
305     // XNamed
306     virtual OUString SAL_CALL getName(  ) override;
307     virtual void SAL_CALL setName( const OUString& aName ) override;
308 
309     // XServiceInfo
310     virtual OUString SAL_CALL getImplementationName(  ) final override;
311     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) final override;
312     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) final override;
313 
314     // XUnoTunnel
315     UNO3_GETIMPLEMENTATION_DECL(SvXMLExport)
316 
317     /** ensures that the given namespace is in scope at the next started
318         element.
319 
320         <p>If the namespace is not yet declared, the necessary attribute will
321         be added, as well.</p>
322 
323         @param i_rNamespace         the namespace to be declared
324 
325         @returns the actual prefix that the namespace is associated with
326       */
327     OUString EnsureNamespace(OUString const & i_rNamespace );
328 
329     // Check if common attribute list is empty.
330 #ifndef DBG_UTIL
CheckAttrList()331     void CheckAttrList() { (void) this; /* avoid loplugin:staticmethods */ }
332 #else
333     void CheckAttrList();
334 #endif
335 
336     // Clear common attribute list.
337     void ClearAttrList();
338 
339     // Add an attribute to the common attribute list.
340     void AddAttributeASCII( sal_uInt16 nPrefix, const char *pName,
341                             const char *pValue );
342     void AddAttribute( sal_uInt16 nPrefix, const char *pName,
343                        const OUString& rValue );
344     void AddAttribute( sal_uInt16 nPrefix, const OUString& rName,
345                        const OUString& rValue );
346     void AddAttribute( sal_uInt16 nPrefix,
347                        enum ::xmloff::token::XMLTokenEnum eName,
348                        const OUString& rValue );
349     void AddAttribute( sal_uInt16 nPrefix,
350                        enum ::xmloff::token::XMLTokenEnum eName,
351                        enum ::xmloff::token::XMLTokenEnum eValue );
352     void AddAttribute( const OUString& rQName,
353                        const OUString& rValue );
354     void AddAttribute( const OUString& rQName,
355                        enum ::xmloff::token::XMLTokenEnum eValue );
356 
357     /** Add language tag attributes, deciding which are necessary.
358 
359         @param  nPrefix
360                 Namespace prefix for *:language, *:script and *:country
361 
362         @param  nPrefixRfc
363                 Namespace prefix for *:rfc-language-tag
364 
365         @param  bWriteEmpty
366                 Whether to write empty *:language and *:country attribute
367                 values in case of an empty locale (denoting system).
368      */
369     void AddLanguageTagAttributes( sal_uInt16 nPrefix, sal_uInt16 nPrefixRfc,
370             const css::lang::Locale& rLocale, bool bWriteEmpty);
371 
372     /** Same as AddLanguageTagAttributes() but with LanguageTag parameter
373         instead of Locale.
374      */
375     void AddLanguageTagAttributes( sal_uInt16 nPrefix, sal_uInt16 nPrefixRfc,
376             const LanguageTag& rLanguageTag, bool bWriteEmpty );
377 
378     // add several attributes to the common attribute list
379     void AddAttributeList( const css::uno::Reference<
380                                   css::xml::sax::XAttributeList >& xAttrList );
381 
382     // Get common attribute list as implementation or interface.
GetAttrList()383     SvXMLAttributeList &GetAttrList() { return *mxAttrList; }
GetXAttrList() const384     css::uno::Reference< css::xml::sax::XAttributeList > GetXAttrList() const { return mxAttrList; }
385 
386     // Get document handler. This methods are not const, because the
387     // reference allows modifications through the handler.
GetDocHandler() const388     const css::uno::Reference< css::xml::sax::XDocumentHandler > & GetDocHandler() const { return mxHandler; }
389 
390     // Get original URL.
GetOrigFileName() const391     const OUString& GetOrigFileName() const { return msOrigFileName; }
392 
393     // Get (const) namespace map.
GetNamespaceMap() const394     const SvXMLNamespaceMap& GetNamespaceMap() const { return *mpNamespaceMap; }
395 
396     // Get author id to remove personal info
GetInfoID(const OUString sPersonalInfo) const397     size_t GetInfoID( const OUString sPersonalInfo ) const { return mpAuthorIDs->GetInfoID(sPersonalInfo); }
398 
399     // Get unit converter
GetMM100UnitConverter() const400     const SvXMLUnitConverter& GetMM100UnitConverter() const { return maUnitConv; }
401 
GetMM100UnitConverter()402     SvXMLUnitConverter& GetMM100UnitConverter() { return maUnitConv; }
403 
404     void addChaffWhenEncryptedStorage();
405 
406     // Export the document.
407     virtual ErrCode exportDoc( enum ::xmloff::token::XMLTokenEnum eClass = ::xmloff::token::XML_TOKEN_INVALID );
408 
409     void collectDataStyles(bool bFromUsedStyles);
410     virtual void addDataStyle(const sal_Int32 nNumberFormat, bool bTimeFormat = false );
411     virtual void exportDataStyles();
412     virtual void exportAutoDataStyles();
413     virtual OUString getDataStyleName(const sal_Int32 nNumberFormat, bool bTimeFormat = false ) const;
414     sal_Int32 dataStyleForceSystemLanguage(sal_Int32 nFormat) const;
415 
416     virtual void exportAnnotationMeta( const css::uno::Reference < css::drawing::XShape >& xShape);
417 
418     // Get XModel
419     const css::uno::Reference< css::frame::XModel > &
GetModel() const420                GetModel() const { return mxModel; }
421     // Get XNumberFormatsSupplier
GetNumberFormatsSupplier()422     css::uno::Reference< css::util::XNumberFormatsSupplier > & GetNumberFormatsSupplier() { return mxNumberFormatsSupplier; }
SetNumberFormatsSupplier(const css::uno::Reference<css::util::XNumberFormatsSupplier> & _xNumberFormatSupplier)423     void SetNumberFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier >& _xNumberFormatSupplier)
424     {
425         mxNumberFormatsSupplier = _xNumberFormatSupplier;
426         if ( mxNumberFormatsSupplier.is() && mxHandler.is() )
427             mpNumExport.reset( new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier) );
428     }
429 
430     // get export helper for text
431     inline rtl::Reference< XMLTextParagraphExport > const & GetTextParagraphExport();
432 
433     // get export helper for shapes
434     inline rtl::Reference< XMLShapeExport > const & GetShapeExport();
435 
436     // get auto style pool
437     inline rtl::Reference< SvXMLAutoStylePoolP > const & GetAutoStylePool();
438 
439     // get Page Export
440     inline rtl::Reference< XMLPageExport > const & GetPageExport();
441 
442     // get chart export helper
443     inline rtl::Reference< SchXMLExportHelper > const & GetChartExport();
444 
445     // get font auto style pool
446     inline rtl::Reference< XMLFontAutoStylePool > const & GetFontAutoStylePool();
447 
448     ProgressBarHelper*  GetProgressBarHelper();
449 
450     // get Formlayer Export
451     inline rtl::Reference< xmloff::OFormLayerXMLExport > const & GetFormExport();
452     inline bool HasFormExport() const;
453 
454     // get XPropertySet with export information
getExportInfo() const455     const css::uno::Reference< css::beans::XPropertySet >& getExportInfo() const { return mxExportInfo; }
456 
GetStatusIndicator() const457     const css::uno::Reference< css::task::XStatusIndicator >& GetStatusIndicator() const { return mxStatusIndicator; }
458 
459     /// get Event export, with handlers for script types "None" and
460     /// "StarBasic" already registered; other handlers may be registered, too.
461     XMLEventExport& GetEventExport();
462 
463     /// get the export for image maps
464     XMLImageMapExport& GetImageMapExport();
465 
466     OUString AddEmbeddedXGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, OUString & rOutMimeType, OUString const & rRequestedName = OUString());
467     bool AddEmbeddedXGraphicAsBase64(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
468     bool GetGraphicMimeTypeFromStream(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, OUString & rOutMimeType);
469 
470     OUString AddEmbeddedObject(
471                             const OUString& rEmbeddedObjectURL );
472     bool AddEmbeddedObjectAsBase64(
473                             const OUString& rEmbeddedObjectURL );
474 
475     OUString EncodeStyleName( const OUString& rName,
476                                      bool *pEncoded=nullptr ) const;
477 
478     // save linked sections?
IsSaveLinkedSections() const479     bool IsSaveLinkedSections() const { return mbSaveLinkedSections; }
480 
481     // get export flags
getExportFlags() const482     SvXMLExportFlags getExportFlags() const { return mnExportFlags; }
483 
484     void ExportEmbeddedOwnObject(
485         css::uno::Reference<css::lang::XComponent > const & rComp );
486 
487     OUString GetRelativeReference(const OUString& rValue);
488 
489     // methods for accessing the document handler and handling SAX errors
490     void StartElement(sal_uInt16 nPrefix,
491                         enum ::xmloff::token::XMLTokenEnum eName,
492                         bool bIgnWSOutside );
493     void StartElement(const OUString& rName,
494                         bool bIgnWSOutside );
495     void Characters(const OUString& rChars);
496     void EndElement(sal_uInt16 nPrefix,
497                         enum ::xmloff::token::XMLTokenEnum eName,
498                         bool bIgnWSInside );
499     void EndElement(const OUString& rName,
500                         bool bIgnWSInside );
501     void IgnorableWhitespace();
502 
503     /**
504      * Record an error condition that occurred during export. The
505      * behavior of SetError can be modified using the error flag
506      * constants.
507      */
508     void SetError(
509         /// error ID, may contain an error flag
510         sal_Int32 nId,
511         /// string parameters for the error message
512         const css::uno::Sequence< OUString> & rMsgParams,
513         /// original exception message (if applicable)
514         const OUString& rExceptionMessage,
515         /// error location (if applicable)
516         const css::uno::Reference<css::xml::sax::XLocator> & rLocator );
517 
518     void SetError(
519         sal_Int32 nId,
520         const css::uno::Sequence< OUString> & rMsgParams);
521 
522     virtual void DisposingModel();
523 
524     ::comphelper::UnoInterfaceToUniqueIdentifierMapper& getInterfaceToIdentifierMapper();
525 
getComponentContext() const526     const css::uno::Reference< css::uno::XComponentContext >& getComponentContext() const { return m_xContext;}
527 
528     // Shapes in Writer cannot be named via context menu (#i51726#)
GetModelType() const529     SvtModuleOptions::EFactory GetModelType() const
530     {
531         return meModelType;
532     }
533 
534     // Written OpenDocument file format doesn't fit to the created text document (#i69627#)
535     bool writeOutlineStyleAsNormalListStyle() const;
536 
537     css::uno::Reference< css::embed::XStorage > const & GetTargetStorage() const;
538 
539     /// returns value of ODF version attribute
540     char const* GetODFVersionAttributeValue() const;
541 
542     /// returns the deterministic version for odf export
543     SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const;
544 
545     // FIXME: this is only for legacy stuff that has not yet been adapted
546     //        to implement XMetadatable; this can write duplicate IDs!
547     /// add xml:id and legacy namespace id
548     void SAL_DLLPRIVATE AddAttributeIdLegacy(
549             sal_uInt16 const nLegacyPrefix, OUString const& rValue);
550 
551     /// add xml:id attribute (for RDF metadata)
552     void AddAttributeXmlId(css::uno::Reference<css::uno::XInterface> const & i_xIfc);
553 
554     /// add RDFa attributes for a metadatable text content
555     void AddAttributesRDFa( css::uno::Reference<css::text::XTextContent> const & i_xTextContent);
556 
557     bool exportTextNumberElement() const;
558 
559     /// set null date from model to unit converter, if not already done
560     bool SetNullDateOnUnitConverter();
561 
562     /// Get clamped mimetype for image export (empty if none)
563     OUString const & GetImageFilterName() const;
564 };
565 
GetTextParagraphExport()566 inline rtl::Reference< XMLTextParagraphExport > const & SvXMLExport::GetTextParagraphExport()
567 {
568     if( !mxTextParagraphExport.is() )
569         mxTextParagraphExport = CreateTextParagraphExport();
570 
571     return mxTextParagraphExport;
572 }
573 
GetShapeExport()574 inline rtl::Reference< XMLShapeExport > const & SvXMLExport::GetShapeExport()
575 {
576     if( !mxShapeExport.is() )
577         mxShapeExport = CreateShapeExport();
578 
579     return mxShapeExport;
580 }
581 
GetAutoStylePool()582 inline rtl::Reference< SvXMLAutoStylePoolP > const & SvXMLExport::GetAutoStylePool()
583 {
584     if( !mxAutoStylePool.is() )
585         mxAutoStylePool = CreateAutoStylePool();
586 
587     return mxAutoStylePool;
588 }
589 
GetChartExport()590 inline rtl::Reference< SchXMLExportHelper > const & SvXMLExport::GetChartExport()
591 {
592     if( !mxChartExport.is() )
593         mxChartExport = CreateChartExport();
594 
595     return mxChartExport;
596 }
597 
GetPageExport()598 inline rtl::Reference< XMLPageExport > const & SvXMLExport::GetPageExport()
599 {
600     if( !mxPageExport.is() )
601         mxPageExport = CreatePageExport();
602 
603     return mxPageExport;
604 }
605 
GetFontAutoStylePool()606 inline rtl::Reference< XMLFontAutoStylePool > const & SvXMLExport::GetFontAutoStylePool()
607 {
608     if( !mxFontAutoStylePool.is() )
609         mxFontAutoStylePool = CreateFontAutoStylePool();
610 
611     return mxFontAutoStylePool;
612 }
613 
GetFormExport()614 inline rtl::Reference< xmloff::OFormLayerXMLExport > const & SvXMLExport::GetFormExport()
615 {
616     if( !mxFormExport.is() )
617         mxFormExport = CreateFormExport();
618 
619     return mxFormExport;
620 }
621 
HasFormExport() const622 inline bool SvXMLExport::HasFormExport() const
623 {
624     return mxFormExport.is();
625 }
626 
SetEmbeddedResolver(css::uno::Reference<css::document::XEmbeddedObjectResolver> const & _xEmbeddedResolver)627 inline void SvXMLExport::SetEmbeddedResolver(
628     css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver )
629 {
630     mxEmbeddedResolver = _xEmbeddedResolver;
631 }
632 
SetGraphicStorageHandler(css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler)633 inline void SvXMLExport::SetGraphicStorageHandler(
634     css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler)
635 {
636     mxGraphicStorageHandler = rxGraphicStorageHandler;
637 }
638 
639 // Helper class to export an element.
640 class XMLOFF_DLLPUBLIC SvXMLElementExport
641 {
642     SvXMLExport& mrExport;
643     OUString maElementName;
644     const bool mbIgnoreWhitespaceInside :1;
645     const bool mbDoSomething :1;
646 
647     SAL_DLLPRIVATE
648     void StartElement(
649         const sal_uInt16 nPrefix,
650         const OUString& rName,
651         const bool bIgnoreWhitespaceOutside );
652 
653 public:
654 
655     // The constructor prints a start tag that has the common attributes
656     // of the XMLExport instance attached.
657     SvXMLElementExport( SvXMLExport& rExp, sal_uInt16 nPrefix,
658                         const char *pName,
659                         bool bIgnWSOutside, bool bIgnWSInside );
660     SvXMLElementExport( SvXMLExport& rExp, sal_uInt16 nPrefix,
661                         const OUString& rName,
662                         bool bIgnWSOutside, bool bIgnWSInside );
663     SvXMLElementExport( SvXMLExport& rExp, sal_uInt16 nPrefix,
664                         enum ::xmloff::token::XMLTokenEnum eName,
665                         bool bIgnWSOutside, bool bIgnWSInside );
666     SvXMLElementExport( SvXMLExport& rExp, const OUString& rQName,
667                         bool bIgnWSOutside, bool bIgnWSInside );
668 
669     // These constructors do nothing if bDoSomething is not set
670     SvXMLElementExport( SvXMLExport& rExp, bool bDoSomething,
671                         sal_uInt16 nPrefix,
672                         enum ::xmloff::token::XMLTokenEnum eName,
673                         bool bIgnWSOutside, bool bIgnWSInside );
674 
675     // The destructor prints an end tag.
676     ~SvXMLElementExport();
677 };
678 
679 #endif  //  _XMLOFF_SVXMLEXP_HXX
680 
681 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
682