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