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