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