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