bump product version to 4.1.6.2
[LibreOffice.git] / xmloff / source / core / xmlexp.cxx
blob77e7a25d70a47043051be79221ea1ef4b31f0100
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <string.h>
22 #include "sal/config.h"
24 #include <officecfg/Office/Common.hxx>
25 #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
26 #include <osl/mutex.hxx>
27 #include <tools/debug.hxx>
28 #include <tools/urlobj.hxx>
29 #include <comphelper/genericpropertyset.hxx>
30 #include <com/sun/star/container/XNameAccess.hpp>
31 #include <com/sun/star/io/XInputStream.hpp>
32 #include <com/sun/star/document/XBinaryStreamResolver.hpp>
33 #include <com/sun/star/xml/sax/SAXInvalidCharacterException.hpp>
34 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
35 #include <com/sun/star/uri/UriReferenceFactory.hpp>
36 #include <com/sun/star/util/MeasureUnit.hpp>
37 #include <comphelper/processfactory.hxx>
38 #include <xmloff/attrlist.hxx>
39 #include <xmloff/nmspmap.hxx>
40 #include <xmloff/xmluconv.hxx>
41 #include "xmloff/xmlnmspe.hxx"
42 #include <xmloff/xmltoken.hxx>
43 #include <xmloff/xmlexp.hxx>
44 #include <xmloff/xmlnumfe.hxx>
45 #include <xmloff/xmlmetae.hxx>
46 #include <xmloff/XMLSettingsExportContext.hxx>
47 #include <xmloff/families.hxx>
48 #include <xmloff/XMLEventExport.hxx>
49 #include "XMLStarBasicExportHandler.hxx"
50 #include "XMLScriptExportHandler.hxx"
51 #include <xmloff/SettingsExportHelper.hxx>
52 #include <com/sun/star/container/XIndexContainer.hpp>
53 #include <com/sun/star/document/XEventsSupplier.hpp>
54 #include <com/sun/star/document/XViewDataSupplier.hpp>
55 #include <xmloff/GradientStyle.hxx>
56 #include <xmloff/HatchStyle.hxx>
57 #include <xmloff/ImageStyle.hxx>
58 #include <TransGradientStyle.hxx>
59 #include <xmloff/MarkerStyle.hxx>
60 #include <xmloff/DashStyle.hxx>
61 #include <xmloff/XMLFontAutoStylePool.hxx>
62 #include "XMLImageMapExport.hxx"
63 #include "XMLBase64Export.hxx"
64 #include "xmloff/xmlerror.hxx"
65 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
66 #include <com/sun/star/beans/PropertyAttribute.hpp>
67 #include "xmloff/XMLFilterServiceNames.h"
68 #include "xmloff/XMLEmbeddedObjectExportFilter.hxx"
69 #include "XMLBasicExportFilter.hxx"
70 #include <rtl/logfile.hxx>
71 #include <cppuhelper/implbase1.hxx>
72 #include <comphelper/extract.hxx>
73 #include <comphelper/servicehelper.hxx>
74 #include "PropertySetMerger.hxx"
76 #include "svl/urihelper.hxx"
77 #include "xmloff/xformsexport.hxx"
79 #include <unotools/docinfohelper.hxx>
80 #include <unotools/bootstrap.hxx>
81 #include <unotools/configmgr.hxx>
82 #include <com/sun/star/document/XDocumentProperties.hpp>
83 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
84 #include <com/sun/star/document/XMLOasisBasicExporter.hpp>
85 #include <com/sun/star/embed/XEncryptionProtectedSource2.hpp>
86 #include <com/sun/star/rdf/XMetadatable.hpp>
87 #include "RDFaExportHelper.hxx"
89 #include <comphelper/xmltools.hxx>
92 using namespace ::osl;
93 using namespace ::com::sun::star;
94 using namespace ::com::sun::star::uno;
95 using namespace ::com::sun::star::frame;
96 using namespace ::com::sun::star::container;
97 using namespace ::com::sun::star::lang;
98 using namespace ::com::sun::star::document;
99 using namespace ::com::sun::star::beans;
100 using namespace ::com::sun::star::xml::sax;
101 using namespace ::com::sun::star::io;
102 using namespace ::xmloff::token;
104 sal_Char const sXML_1_1[] = "1.1";
105 sal_Char const sXML_1_2[] = "1.2";
107 // #i115030#: the XSLT is not finished, and not available via HTTP
108 const sal_Char s_grddl_xsl[] = "http://FIXME";
110 #define XML_MODEL_SERVICE_WRITER "com.sun.star.text.TextDocument"
111 #define XML_MODEL_SERVICE_CALC "com.sun.star.sheet.SpreadsheetDocument"
112 #define XML_MODEL_SERVICE_DRAW "com.sun.star.drawing.DrawingDocument"
113 #define XML_MODEL_SERVICE_IMPRESS "com.sun.star.presentation.PresentationDocument"
114 #define XML_MODEL_SERVICE_MATH "com.sun.star.formula.FormulaProperties"
115 #define XML_MODEL_SERVICE_CHART "com.sun.star.chart.ChartDocument"
117 #define XML_USEPRETTYPRINTING "UsePrettyPrinting"
119 struct XMLServiceMapEntry_Impl
121 const sal_Char *sModelService;
122 sal_Int32 nModelServiceLen;
123 const sal_Char *sFilterService;
124 sal_Int32 nFilterServiceLen;
127 #define SERVICE_MAP_ENTRY( app ) \
128 { XML_MODEL_SERVICE_##app, sizeof(XML_MODEL_SERVICE_##app)-1, \
129 XML_EXPORT_FILTER_##app, sizeof(XML_EXPORT_FILTER_##app)-1 }
131 const XMLServiceMapEntry_Impl aServiceMap[] =
133 SERVICE_MAP_ENTRY( WRITER ),
134 SERVICE_MAP_ENTRY( CALC ),
135 SERVICE_MAP_ENTRY( IMPRESS ),// Impress supports DrawingDocument, too, so
136 SERVICE_MAP_ENTRY( DRAW ), // it must appear before Draw
137 SERVICE_MAP_ENTRY( MATH ),
138 SERVICE_MAP_ENTRY( CHART ),
139 { 0, 0, 0, 0 }
142 //==============================================================================
144 class SAL_DLLPRIVATE SettingsExportFacade : public ::xmloff::XMLSettingsExportContext
146 public:
147 SettingsExportFacade( SvXMLExport& i_rExport )
148 :m_rExport( i_rExport )
152 virtual ~SettingsExportFacade()
156 virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName,
157 const OUString& i_rValue );
158 virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName,
159 enum ::xmloff::token::XMLTokenEnum i_eValue );
161 virtual void StartElement( enum ::xmloff::token::XMLTokenEnum i_eName,
162 const sal_Bool i_bIgnoreWhitespace );
163 virtual void EndElement( const sal_Bool i_bIgnoreWhitespace );
165 virtual void Characters( const OUString& i_rCharacters );
167 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
168 GetComponentContext() const;
169 private:
170 SvXMLExport& m_rExport;
171 ::std::stack< OUString > m_aElements;
174 void SettingsExportFacade::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, const OUString& i_rValue )
176 m_rExport.AddAttribute( XML_NAMESPACE_CONFIG, i_eName, i_rValue );
179 void SettingsExportFacade::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, enum ::xmloff::token::XMLTokenEnum i_eValue )
181 m_rExport.AddAttribute( XML_NAMESPACE_CONFIG, i_eName, i_eValue );
184 void SettingsExportFacade::StartElement( enum ::xmloff::token::XMLTokenEnum i_eName, const sal_Bool i_bIgnoreWhitespace )
186 const OUString sElementName( m_rExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_CONFIG, GetXMLToken( i_eName ) ) );
187 m_rExport.StartElement( sElementName, i_bIgnoreWhitespace );
188 m_aElements.push( sElementName );
191 void SettingsExportFacade::EndElement( const sal_Bool i_bIgnoreWhitespace )
193 const OUString sElementName( m_aElements.top() );
194 m_rExport.EndElement( sElementName, i_bIgnoreWhitespace );
195 m_aElements.pop();
198 void SettingsExportFacade::Characters( const OUString& i_rCharacters )
200 m_rExport.GetDocHandler()->characters( i_rCharacters );
203 Reference< XComponentContext > SettingsExportFacade::GetComponentContext() const
205 return m_rExport.getComponentContext();
208 //==============================================================================
210 class SvXMLExportEventListener : public cppu::WeakImplHelper1<
211 com::sun::star::lang::XEventListener >
213 private:
214 SvXMLExport* pExport;
216 public:
217 SvXMLExportEventListener(SvXMLExport* pExport);
218 virtual ~SvXMLExportEventListener();
220 // XEventListener
221 virtual void SAL_CALL disposing(const lang::EventObject& rEventObject) throw(::com::sun::star::uno::RuntimeException);
224 SvXMLExportEventListener::SvXMLExportEventListener(SvXMLExport* pTempExport)
225 : pExport(pTempExport)
229 SvXMLExportEventListener::~SvXMLExportEventListener()
233 // XEventListener
234 void SAL_CALL SvXMLExportEventListener::disposing( const lang::EventObject& )
235 throw(uno::RuntimeException)
237 if (pExport)
239 pExport->DisposingModel();
240 pExport = NULL;
244 //==============================================================================
246 class SAL_DLLPRIVATE SvXMLExport_Impl
248 public:
249 SvXMLExport_Impl();
251 ::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper;
252 uno::Reference< uri::XUriReferenceFactory > mxUriReferenceFactory;
253 OUString msPackageURI;
254 OUString msPackageURIScheme;
255 // Written OpenDocument file format doesn't fit to the created text document (#i69627#)
256 sal_Bool mbOutlineStyleAsNormalListStyle;
257 sal_Bool mbSaveBackwardCompatibleODF;
259 uno::Reference< embed::XStorage > mxTargetStorage;
261 SvtSaveOptions maSaveOptions;
263 /// relative path of stream in package, e.g. "someobject/content.xml"
264 OUString mStreamPath;
266 /// name of stream in package, e.g., "content.xml"
267 OUString mStreamName;
269 /// stack of backed up namespace maps
270 /// long: depth at which namespace map has been backed up into the stack
271 ::std::stack< ::std::pair< SvXMLNamespaceMap *, long > > mNamespaceMaps;
272 /// counts depth (number of open elements/start tags)
273 long mDepth;
275 ::std::auto_ptr< ::xmloff::RDFaExportHelper> mpRDFaHelper;
277 sal_Bool mbExportTextNumberElement;
278 sal_Bool mbNullDateInitialized;
280 void SetSchemeOf( const OUString& rOrigFileName )
282 sal_Int32 nSep = rOrigFileName.indexOf(':');
283 if( nSep != -1 )
284 msPackageURIScheme = rOrigFileName.copy( 0, nSep );
288 SvXMLExport_Impl::SvXMLExport_Impl()
289 // Written OpenDocument file format doesn't fit to the created text document (#i69627#)
290 : mbOutlineStyleAsNormalListStyle( false )
291 ,mbSaveBackwardCompatibleODF( sal_True )
292 ,mStreamName()
293 ,mNamespaceMaps()
294 ,mDepth(0)
295 ,mpRDFaHelper() // lazy
296 ,mbExportTextNumberElement( sal_False )
297 ,mbNullDateInitialized( sal_False )
299 mxUriReferenceFactory = uri::UriReferenceFactory::create( comphelper::getProcessComponentContext() );
302 //==============================================================================
304 void SvXMLExport::SetDocHandler( const uno::Reference< xml::sax::XDocumentHandler > &rHandler )
306 mxHandler = rHandler;
307 mxExtHandler = uno::Reference<xml::sax::XExtendedDocumentHandler>( mxHandler, UNO_QUERY );
310 void SvXMLExport::_InitCtor()
312 // note: it is not necessary to add XML_NP_XML (it is declared implicitly)
313 if( (getExportFlags() & ~EXPORT_OASIS) != 0 )
315 mpNamespaceMap->Add( GetXMLToken(XML_NP_OFFICE), GetXMLToken(XML_N_OFFICE), XML_NAMESPACE_OFFICE );
316 mpNamespaceMap->Add( GetXMLToken(XML_NP_OOO), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
318 if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS) ) != 0 )
320 mpNamespaceMap->Add( GetXMLToken(XML_NP_FO), GetXMLToken(XML_N_FO_COMPAT), XML_NAMESPACE_FO );
322 if( (getExportFlags() & (EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS) ) != 0 )
324 mpNamespaceMap->Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
326 if( (getExportFlags() & EXPORT_SETTINGS) != 0 )
328 mpNamespaceMap->Add( GetXMLToken(XML_NP_CONFIG), GetXMLToken(XML_N_CONFIG), XML_NAMESPACE_CONFIG );
331 if( (getExportFlags() & (EXPORT_META|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
333 mpNamespaceMap->Add( GetXMLToken(XML_NP_DC), GetXMLToken(XML_N_DC), XML_NAMESPACE_DC );
334 mpNamespaceMap->Add( GetXMLToken(XML_NP_META), GetXMLToken(XML_N_META), XML_NAMESPACE_META );
336 if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_FONTDECLS) ) != 0 )
338 mpNamespaceMap->Add( GetXMLToken(XML_NP_STYLE), GetXMLToken(XML_N_STYLE), XML_NAMESPACE_STYLE );
341 // namespaces for documents
342 if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
344 mpNamespaceMap->Add( GetXMLToken(XML_NP_DC), GetXMLToken(XML_N_DC), XML_NAMESPACE_DC );
345 mpNamespaceMap->Add( GetXMLToken(XML_NP_TEXT), GetXMLToken(XML_N_TEXT), XML_NAMESPACE_TEXT );
346 mpNamespaceMap->Add( GetXMLToken(XML_NP_DRAW), GetXMLToken(XML_N_DRAW), XML_NAMESPACE_DRAW );
347 mpNamespaceMap->Add( GetXMLToken(XML_NP_DR3D), GetXMLToken(XML_N_DR3D), XML_NAMESPACE_DR3D );
348 mpNamespaceMap->Add( GetXMLToken(XML_NP_SVG), GetXMLToken(XML_N_SVG_COMPAT), XML_NAMESPACE_SVG );
349 mpNamespaceMap->Add( GetXMLToken(XML_NP_CHART), GetXMLToken(XML_N_CHART), XML_NAMESPACE_CHART );
350 mpNamespaceMap->Add( GetXMLToken(XML_NP_RPT), GetXMLToken(XML_N_RPT), XML_NAMESPACE_REPORT );
351 mpNamespaceMap->Add( GetXMLToken(XML_NP_TABLE), GetXMLToken(XML_N_TABLE), XML_NAMESPACE_TABLE );
352 mpNamespaceMap->Add( GetXMLToken(XML_NP_NUMBER),GetXMLToken(XML_N_NUMBER), XML_NAMESPACE_NUMBER );
353 mpNamespaceMap->Add( GetXMLToken(XML_NP_OOOW), GetXMLToken(XML_N_OOOW), XML_NAMESPACE_OOOW );
354 mpNamespaceMap->Add( GetXMLToken(XML_NP_OOOC), GetXMLToken(XML_N_OOOC), XML_NAMESPACE_OOOC );
355 mpNamespaceMap->Add( GetXMLToken(XML_NP_OF), GetXMLToken(XML_N_OF), XML_NAMESPACE_OF );
357 if (getDefaultVersion() > SvtSaveOptions::ODFVER_012)
359 mpNamespaceMap->Add(
360 GetXMLToken(XML_NP_TABLE_EXT), GetXMLToken(XML_N_TABLE_EXT), XML_NAMESPACE_TABLE_EXT);
361 mpNamespaceMap->Add(
362 GetXMLToken(XML_NP_CALC_EXT), GetXMLToken(XML_N_CALC_EXT), XML_NAMESPACE_CALC_EXT);
363 mpNamespaceMap->Add(
364 GetXMLToken(XML_NP_DRAW_EXT), GetXMLToken(XML_N_DRAW_EXT), XML_NAMESPACE_DRAW_EXT);
365 mpNamespaceMap->Add(
366 GetXMLToken(XML_NP_LO_EXT), GetXMLToken(XML_N_LO_EXT),
367 XML_NAMESPACE_LO_EXT);
370 if( (getExportFlags() & (EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
372 mpNamespaceMap->Add( GetXMLToken(XML_NP_MATH), GetXMLToken(XML_N_MATH), XML_NAMESPACE_MATH );
373 mpNamespaceMap->Add( GetXMLToken(XML_NP_FORM), GetXMLToken(XML_N_FORM), XML_NAMESPACE_FORM );
375 if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS) ) != 0 )
377 mpNamespaceMap->Add( GetXMLToken(XML_NP_SCRIPT), GetXMLToken(XML_N_SCRIPT), XML_NAMESPACE_SCRIPT );
378 mpNamespaceMap->Add( GetXMLToken(XML_NP_DOM), GetXMLToken(XML_N_DOM), XML_NAMESPACE_DOM );
380 if( (getExportFlags() & EXPORT_CONTENT ) != 0 )
382 mpNamespaceMap->Add( GetXMLToken(XML_NP_XFORMS_1_0), GetXMLToken(XML_N_XFORMS_1_0), XML_NAMESPACE_XFORMS );
383 mpNamespaceMap->Add( GetXMLToken(XML_NP_XSD), GetXMLToken(XML_N_XSD), XML_NAMESPACE_XSD );
384 mpNamespaceMap->Add( GetXMLToken(XML_NP_XSI), GetXMLToken(XML_N_XSI), XML_NAMESPACE_XSI );
385 mpNamespaceMap->Add( GetXMLToken(XML_NP_FIELD), GetXMLToken(XML_N_FIELD), XML_NAMESPACE_FIELD );
386 mpNamespaceMap->Add( GetXMLToken(XML_NP_FORMX), GetXMLToken(XML_N_FORMX), XML_NAMESPACE_FORMX );
388 // RDFa: needed for content and header/footer styles
389 if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
391 mpNamespaceMap->Add( GetXMLToken(XML_NP_XHTML),
392 GetXMLToken(XML_N_XHTML), XML_NAMESPACE_XHTML );
394 // GRDDL: to convert RDFa and meta.xml to RDF
395 if( (getExportFlags() & (EXPORT_META|EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
397 mpNamespaceMap->Add( GetXMLToken(XML_NP_GRDDL),
398 GetXMLToken(XML_N_GRDDL), XML_NAMESPACE_GRDDL );
400 // CSS Text Level 3 for distributed text justification.
401 if ( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES)) != 0 )
403 mpNamespaceMap->Add(
404 GetXMLToken(XML_NP_CSS3TEXT), GetXMLToken(XML_N_CSS3TEXT), XML_NAMESPACE_CSS3TEXT );
407 mxAttrList = (xml::sax::XAttributeList*)mpAttrList;
409 msGraphicObjectProtocol = OUString( "vnd.sun.star.GraphicObject:" );
410 msEmbeddedObjectProtocol = OUString( "vnd.sun.star.EmbeddedObject:" );
412 if (mxModel.is() && !mxEventListener.is())
414 mxEventListener.set( new SvXMLExportEventListener(this));
415 mxModel->addEventListener(mxEventListener);
418 // Determine model type (#i51726#)
419 _DetermineModelType();
421 mbEnableExperimentalOdfExport = getenv("ENABLE_EXPERIMENTAL_ODF_EXPORT") != NULL;
423 // cl: but only if we do export to current oasis format, old openoffice format *must* always be compatible
424 if( (getExportFlags() & EXPORT_OASIS) != 0 )
426 mpImpl->mbSaveBackwardCompatibleODF =
427 officecfg::Office::Common::Save::Document::
428 SaveBackwardCompatibleODF::get( comphelper::getProcessComponentContext() );
432 // Shapes in Writer cannot be named via context menu (#i51726#)
433 void SvXMLExport::_DetermineModelType()
435 meModelType = SvtModuleOptions::E_UNKNOWN_FACTORY;
437 if ( mxModel.is() )
439 meModelType = SvtModuleOptions::ClassifyFactoryByModel( mxModel );
443 SvXMLExport::SvXMLExport(
444 sal_Int16 const eDefaultMeasureUnit /*css::util::MeasureUnit*/,
445 const uno::Reference< uno::XComponentContext >& xContext,
446 const enum XMLTokenEnum eClass, sal_uInt16 nExportFlags )
447 : mpImpl( new SvXMLExport_Impl ),
448 m_xContext(xContext),
449 mpAttrList( new SvXMLAttributeList ),
450 mpNamespaceMap( new SvXMLNamespaceMap ),
451 mpUnitConv( new SvXMLUnitConverter( xContext,
452 util::MeasureUnit::MM_100TH, eDefaultMeasureUnit) ),
453 mpNumExport(0L),
454 mpProgressBarHelper( NULL ),
455 mpEventExport( NULL ),
456 mpImageMapExport( NULL ),
457 mpXMLErrors( NULL ),
458 mbExtended( sal_False ),
459 meClass( eClass ),
460 mnExportFlags( nExportFlags ),
461 mnErrorFlags( ERROR_NO ),
462 msWS( GetXMLToken(XML_WS) ),
463 mbSaveLinkedSections(sal_True)
465 SAL_WARN_IF( !xContext.is(), "xmloff.core", "got no service manager" );
466 _InitCtor();
469 SvXMLExport::SvXMLExport(
470 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
471 const OUString &rFileName,
472 sal_Int16 const eDefaultMeasureUnit /*css::util::MeasureUnit*/,
473 const uno::Reference< xml::sax::XDocumentHandler > & rHandler)
474 : mpImpl( new SvXMLExport_Impl ),
475 m_xContext(xContext),
476 mxHandler( rHandler ),
477 mxExtHandler( rHandler, uno::UNO_QUERY ),
478 mpAttrList( new SvXMLAttributeList ),
479 msOrigFileName( rFileName ),
480 mpNamespaceMap( new SvXMLNamespaceMap ),
481 mpUnitConv( new SvXMLUnitConverter( xContext,
482 util::MeasureUnit::MM_100TH, eDefaultMeasureUnit) ),
483 mpNumExport(0L),
484 mpProgressBarHelper( NULL ),
485 mpEventExport( NULL ),
486 mpImageMapExport( NULL ),
487 mpXMLErrors( NULL ),
488 mbExtended( sal_False ),
489 meClass( XML_TOKEN_INVALID ),
490 mnExportFlags( 0 ),
491 mnErrorFlags( ERROR_NO ),
492 msWS( GetXMLToken(XML_WS) ),
493 mbSaveLinkedSections(sal_True)
495 SAL_WARN_IF( !xContext.is(), "xmloff.core", "got no service manager" );
496 mpImpl->SetSchemeOf( msOrigFileName );
497 _InitCtor();
499 if (mxNumberFormatsSupplier.is())
500 mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
503 SvXMLExport::SvXMLExport(
504 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
505 const OUString &rFileName,
506 const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
507 const Reference< XModel >& rModel,
508 sal_Int16 const eDefaultFieldUnit)
509 : mpImpl( new SvXMLExport_Impl ),
510 m_xContext(xContext),
511 mxModel( rModel ),
512 mxHandler( rHandler ),
513 mxExtHandler( rHandler, uno::UNO_QUERY ),
514 mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
515 mpAttrList( new SvXMLAttributeList ),
516 msOrigFileName( rFileName ),
517 mpNamespaceMap( new SvXMLNamespaceMap ),
518 mpUnitConv( new SvXMLUnitConverter( xContext,
519 util::MeasureUnit::MM_100TH,
520 SvXMLUnitConverter::GetMeasureUnit(eDefaultFieldUnit)) ),
521 mpNumExport(0L),
522 mpProgressBarHelper( NULL ),
523 mpEventExport( NULL ),
524 mpImageMapExport( NULL ),
525 mpXMLErrors( NULL ),
526 mbExtended( sal_False ),
527 meClass( XML_TOKEN_INVALID ),
528 mnExportFlags( 0 ),
529 mnErrorFlags( ERROR_NO ),
530 msWS( GetXMLToken(XML_WS) ),
531 mbSaveLinkedSections(sal_True)
533 SAL_WARN_IF(!xContext.is(), "xmloff.core", "got no service manager" );
534 mpImpl->SetSchemeOf( msOrigFileName );
535 _InitCtor();
537 if (mxNumberFormatsSupplier.is())
538 mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
541 SvXMLExport::~SvXMLExport()
543 delete mpXMLErrors;
544 delete mpImageMapExport;
545 delete mpEventExport;
546 delete mpNamespaceMap;
547 delete mpUnitConv;
548 if (mpProgressBarHelper || mpNumExport)
550 if (mxExportInfo.is())
552 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
553 if (xPropertySetInfo.is())
555 if (mpProgressBarHelper)
557 OUString sProgressMax(XML_PROGRESSMAX);
558 OUString sProgressCurrent(XML_PROGRESSCURRENT);
559 OUString sRepeat(XML_PROGRESSREPEAT);
560 if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
561 xPropertySetInfo->hasPropertyByName(sProgressCurrent))
563 sal_Int32 nProgressMax(mpProgressBarHelper->GetReference());
564 sal_Int32 nProgressCurrent(mpProgressBarHelper->GetValue());
565 uno::Any aAny;
566 aAny <<= nProgressMax;
567 mxExportInfo->setPropertyValue(sProgressMax, aAny);
568 aAny <<= nProgressCurrent;
569 mxExportInfo->setPropertyValue(sProgressCurrent, aAny);
571 if (xPropertySetInfo->hasPropertyByName(sRepeat))
572 mxExportInfo->setPropertyValue(sRepeat, cppu::bool2any(mpProgressBarHelper->GetRepeat()));
574 if (mpNumExport && (mnExportFlags & (EXPORT_AUTOSTYLES | EXPORT_STYLES)))
576 OUString sWrittenNumberFormats(XML_WRITTENNUMBERSTYLES);
577 if (xPropertySetInfo->hasPropertyByName(sWrittenNumberFormats))
579 uno::Sequence<sal_Int32> aWasUsed;
580 mpNumExport->GetWasUsed(aWasUsed);
581 uno::Any aAny;
582 aAny <<= aWasUsed;
583 mxExportInfo->setPropertyValue(sWrittenNumberFormats, aAny);
588 delete mpProgressBarHelper;
589 delete mpNumExport;
592 xmloff::token::ResetTokens();
594 if (mxEventListener.is() && mxModel.is())
595 mxModel->removeEventListener(mxEventListener);
597 delete mpImpl;
600 ///////////////////////////////////////////////////////////////////////
602 // XExporter
603 void SAL_CALL SvXMLExport::setSourceDocument( const uno::Reference< lang::XComponent >& xDoc )
604 throw(lang::IllegalArgumentException, uno::RuntimeException)
606 mxModel = uno::Reference< frame::XModel >::query( xDoc );
607 if( !mxModel.is() )
608 throw lang::IllegalArgumentException();
609 if (mxModel.is() && ! mxEventListener.is())
611 mxEventListener.set( new SvXMLExportEventListener(this));
612 mxModel->addEventListener(mxEventListener);
615 if(!mxNumberFormatsSupplier.is() )
617 mxNumberFormatsSupplier = mxNumberFormatsSupplier.query( mxModel );
618 if(mxNumberFormatsSupplier.is() && mxHandler.is())
619 mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
621 if (mxExportInfo.is())
623 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
624 if (xPropertySetInfo.is())
626 OUString sUsePrettyPrinting(XML_USEPRETTYPRINTING);
627 if (xPropertySetInfo->hasPropertyByName(sUsePrettyPrinting))
629 uno::Any aAny = mxExportInfo->getPropertyValue(sUsePrettyPrinting);
630 if (::cppu::any2bool(aAny))
631 mnExportFlags |= EXPORT_PRETTY;
632 else
633 mnExportFlags &= ~EXPORT_PRETTY;
636 if (mpNumExport && (mnExportFlags & (EXPORT_AUTOSTYLES | EXPORT_STYLES)))
638 OUString sWrittenNumberFormats(XML_WRITTENNUMBERSTYLES);
639 if (xPropertySetInfo->hasPropertyByName(sWrittenNumberFormats))
641 uno::Any aAny = mxExportInfo->getPropertyValue(sWrittenNumberFormats);
642 uno::Sequence<sal_Int32> aWasUsed;
643 if(aAny >>= aWasUsed)
644 mpNumExport->SetWasUsed(aWasUsed);
650 if ( mpImpl->mbSaveBackwardCompatibleODF )
651 mnExportFlags |= EXPORT_SAVEBACKWARDCOMPATIBLE;
652 else
653 mnExportFlags &= ~EXPORT_SAVEBACKWARDCOMPATIBLE;
655 // namespaces for user defined attributes
656 Reference< XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
657 if( xFactory.is() )
661 Reference < XInterface > xIfc =
662 xFactory->createInstance(OUString( "com.sun.star.xml.NamespaceMap") );
663 if( xIfc.is() )
665 Reference< XNameAccess > xNamespaceMap( xIfc, UNO_QUERY );
666 if( xNamespaceMap.is() )
668 Sequence< OUString > aPrefixes( xNamespaceMap->getElementNames() );
670 OUString* pPrefix = aPrefixes.getArray();
671 const sal_Int32 nCount = aPrefixes.getLength();
672 sal_Int32 nIndex;
673 OUString aURL;
675 for( nIndex = 0; nIndex < nCount; ++nIndex, ++pPrefix )
677 if( xNamespaceMap->getByName( *pPrefix ) >>= aURL )
678 _GetNamespaceMap().Add( *pPrefix, aURL, XML_NAMESPACE_UNKNOWN );
683 catch(const com::sun::star::uno::Exception&)
688 // Determine model type (#i51726#)
689 _DetermineModelType();
692 // XInitialize
693 void SAL_CALL SvXMLExport::initialize( const uno::Sequence< uno::Any >& aArguments )
694 throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
696 // #93186# we need to queryInterface every single Any with any expected outcome. This variable hold the queryInterface results.
698 const sal_Int32 nAnyCount = aArguments.getLength();
699 const uno::Any* pAny = aArguments.getConstArray();
701 for( sal_Int32 nIndex = 0; nIndex < nAnyCount; nIndex++, pAny++ )
703 Reference<XInterface> xValue;
704 *pAny >>= xValue;
706 // status indicator
707 uno::Reference<task::XStatusIndicator> xTmpStatus( xValue, UNO_QUERY );
708 if ( xTmpStatus.is() )
709 mxStatusIndicator = xTmpStatus;
711 // graphic resolver
712 uno::Reference<document::XGraphicObjectResolver> xTmpGraphic(
713 xValue, UNO_QUERY );
714 if ( xTmpGraphic.is() )
715 mxGraphicResolver = xTmpGraphic;
717 // object resolver
718 uno::Reference<document::XEmbeddedObjectResolver> xTmpObjectResolver(
719 xValue, UNO_QUERY );
720 if ( xTmpObjectResolver.is() )
721 mxEmbeddedResolver = xTmpObjectResolver;
723 // document handler
724 uno::Reference<xml::sax::XDocumentHandler> xTmpDocHandler(
725 xValue, UNO_QUERY );
726 if( xTmpDocHandler.is() )
728 mxHandler = xTmpDocHandler;
729 *pAny >>= mxExtHandler;
731 if (mxNumberFormatsSupplier.is() && mpNumExport == NULL)
732 mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
735 // property set to transport data across
736 uno::Reference<beans::XPropertySet> xTmpPropertySet(
737 xValue, UNO_QUERY );
738 if( xTmpPropertySet.is() )
739 mxExportInfo = xTmpPropertySet;
742 if( mxExportInfo.is() )
744 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo =
745 mxExportInfo->getPropertySetInfo();
746 OUString sPropName(
747 "BaseURI" );
748 if( xPropertySetInfo->hasPropertyByName(sPropName) )
750 uno::Any aAny = mxExportInfo->getPropertyValue(sPropName);
751 aAny >>= msOrigFileName;
752 mpImpl->msPackageURI = msOrigFileName;
753 mpImpl->SetSchemeOf( msOrigFileName );
755 OUString sRelPath;
756 sPropName = OUString( "StreamRelPath" );
757 if( xPropertySetInfo->hasPropertyByName(sPropName) )
759 uno::Any aAny = mxExportInfo->getPropertyValue(sPropName);
760 aAny >>= sRelPath;
762 OUString sName;
763 sPropName = OUString( "StreamName" );
764 if( xPropertySetInfo->hasPropertyByName(sPropName) )
766 uno::Any aAny = mxExportInfo->getPropertyValue(sPropName);
767 aAny >>= sName;
769 if( !msOrigFileName.isEmpty() && !sName.isEmpty() )
771 INetURLObject aBaseURL( msOrigFileName );
772 if( !sRelPath.isEmpty() )
773 aBaseURL.insertName( sRelPath );
774 aBaseURL.insertName( sName );
775 msOrigFileName = aBaseURL.GetMainURL(INetURLObject::DECODE_TO_IURI);
777 mpImpl->mStreamName = sName; // Note: may be empty (XSLT)
779 // Written OpenDocument file format doesn't fit to the created text document (#i69627#)
780 const OUString sOutlineStyleAsNormalListStyle(
781 "OutlineStyleAsNormalListStyle" );
782 if( xPropertySetInfo->hasPropertyByName( sOutlineStyleAsNormalListStyle ) )
784 uno::Any aAny = mxExportInfo->getPropertyValue( sOutlineStyleAsNormalListStyle );
785 aAny >>= (mpImpl->mbOutlineStyleAsNormalListStyle);
788 OUString sTargetStorage( "TargetStorage" );
789 if( xPropertySetInfo->hasPropertyByName( sTargetStorage ) )
790 mxExportInfo->getPropertyValue( sTargetStorage ) >>= mpImpl->mxTargetStorage;
792 const OUString sExportTextNumberElement(
793 "ExportTextNumberElement" );
794 if( xPropertySetInfo->hasPropertyByName( sExportTextNumberElement ) )
796 uno::Any aAny = mxExportInfo->getPropertyValue( sExportTextNumberElement );
797 aAny >>= (mpImpl->mbExportTextNumberElement);
803 // XFilter
804 sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor ) throw(uno::RuntimeException)
806 RTL_LOGFILE_CONTEXT_AUTHOR( aLogContext, "xmloff", "mb93740",
807 "SvXMLExport::filter" );
809 // check for xHandler first... should have been supplied in initialize
810 if( !mxHandler.is() )
811 return sal_False;
815 const sal_uInt32 nTest =
816 EXPORT_META|EXPORT_STYLES|EXPORT_CONTENT|EXPORT_SETTINGS;
817 if( (mnExportFlags & nTest) == nTest && msOrigFileName.isEmpty() )
819 // evaluate descriptor only for flat files and if a base URI
820 // has not been provided already
821 const sal_Int32 nPropCount = aDescriptor.getLength();
822 const beans::PropertyValue* pProps = aDescriptor.getConstArray();
824 for( sal_Int32 nIndex = 0; nIndex < nPropCount; nIndex++, pProps++ )
826 const OUString& rPropName = pProps->Name;
827 const Any& rValue = pProps->Value;
829 if ( rPropName == "FileName" )
831 if( !(rValue >>= msOrigFileName ) )
832 return sal_False;
834 else if ( rPropName == "FilterName" )
836 if( !(rValue >>= msFilterName ) )
837 return sal_False;
842 #ifdef TIMELOG
843 if (GetModel().is())
845 // print a trace message with the URL
846 OString aUrl(OUStringToOString(GetModel()->getURL(),
847 RTL_TEXTENCODING_ASCII_US));
848 RTL_LOGFILE_CONTEXT_TRACE1( aLogContext, "%s", aUrl.getStr() );
850 // we also want a trace message with the document class
851 OString aClass(OUStringToOString(GetXMLToken(meClass),
852 RTL_TEXTENCODING_ASCII_US));
853 RTL_LOGFILE_CONTEXT_TRACE1( aLogContext, "class=\"%s\"",
854 aClass.getStr() );
856 #endif
858 exportDoc( meClass );
860 catch(const uno::Exception& e)
862 // We must catch exceptions, because according to the
863 // API definition export must not throw one!
864 Sequence<OUString> aSeq(0);
865 SetError( XMLERROR_FLAG_ERROR | XMLERROR_FLAG_SEVERE | XMLERROR_API,
866 aSeq, e.Message, NULL );
869 // return true only if no error occurred
870 return (GetErrorFlags() & (ERROR_DO_NOTHING|ERROR_ERROR_OCCURRED)) == 0;
873 void SAL_CALL SvXMLExport::cancel() throw(uno::RuntimeException)
875 // stop export
876 Sequence<OUString> aEmptySeq;
877 SetError(XMLERROR_CANCEL|XMLERROR_FLAG_SEVERE, aEmptySeq);
880 OUString SAL_CALL SvXMLExport::getName( )
881 throw (::com::sun::star::uno::RuntimeException)
883 return msFilterName;
886 void SAL_CALL SvXMLExport::setName( const OUString& )
887 throw (::com::sun::star::uno::RuntimeException)
889 // do nothing, because it is not possible to set the FilterName
893 // XServiceInfo
894 OUString SAL_CALL SvXMLExport::getImplementationName( ) throw(uno::RuntimeException)
896 OUString aStr;
897 return aStr;
900 sal_Bool SAL_CALL SvXMLExport::supportsService( const OUString& rServiceName ) throw(uno::RuntimeException)
902 return
903 (rServiceName == "com.sun.star.document.ExportFilter") ||
904 (rServiceName == "com.sun.star.xml.XMLExportFilter");
907 uno::Sequence< OUString > SAL_CALL SvXMLExport::getSupportedServiceNames( )
908 throw(uno::RuntimeException)
910 uno::Sequence<OUString> aSeq(2);
911 aSeq[0] = OUString( "com.sun.star.document.ExportFilter");
912 aSeq[1] = OUString( "com.sun.star.xml.XMLExportFilter");
913 return aSeq;
916 ///////////////////////////////////////////////////////////////////////
918 OUString
919 SvXMLExport::EnsureNamespace(OUString const & i_rNamespace,
920 OUString const & i_rPreferredPrefix)
922 OUString sPrefix;
923 sal_uInt16 nKey( _GetNamespaceMap().GetKeyByName( i_rNamespace ) );
924 if( XML_NAMESPACE_UNKNOWN == nKey )
926 // There is no prefix for the namespace, so
927 // we have to generate one and have to add it.
928 sPrefix = i_rPreferredPrefix;
929 nKey = _GetNamespaceMap().GetKeyByPrefix( sPrefix );
930 sal_Int32 n( 0 );
931 OUStringBuffer buf;
932 while( nKey != USHRT_MAX )
934 buf.append( i_rPreferredPrefix );
935 buf.append( ++n );
936 sPrefix = buf.makeStringAndClear();
937 nKey = _GetNamespaceMap().GetKeyByPrefix( sPrefix );
940 if (mpImpl->mNamespaceMaps.empty()
941 || (mpImpl->mNamespaceMaps.top().second != mpImpl->mDepth))
943 // top was created for lower depth... need a new namespace map!
944 mpImpl->mNamespaceMaps.push(
945 ::std::make_pair(mpNamespaceMap, mpImpl->mDepth) );
946 mpNamespaceMap = new SvXMLNamespaceMap( *mpNamespaceMap );
949 // add the namespace to the map and as attribute
950 mpNamespaceMap->Add( sPrefix, i_rNamespace );
951 buf.append( GetXMLToken(XML_XMLNS) );
952 buf.append( sal_Unicode(':') );
953 buf.append( sPrefix );
954 AddAttribute( buf.makeStringAndClear(), i_rNamespace );
956 else
958 // If there is a prefix for the namespace, reuse that.
959 sPrefix = _GetNamespaceMap().GetPrefixByKey( nKey );
961 return sPrefix;
964 ///////////////////////////////////////////////////////////////////////
966 void SvXMLExport::AddAttributeASCII( sal_uInt16 nPrefixKey,
967 const sal_Char *pName,
968 const sal_Char *pValue )
970 OUString sName( OUString::createFromAscii( pName ) );
971 OUString sValue( OUString::createFromAscii( pValue ) );
973 mpAttrList->AddAttribute(
974 _GetNamespaceMap().GetQNameByKey( nPrefixKey, sName ), sValue );
977 void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const sal_Char *pName,
978 const OUString& rValue )
980 OUString sName( OUString::createFromAscii( pName ) );
982 mpAttrList->AddAttribute(
983 _GetNamespaceMap().GetQNameByKey( nPrefixKey, sName ), rValue );
986 void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const OUString& rName,
987 const OUString& rValue )
989 mpAttrList->AddAttribute(
990 _GetNamespaceMap().GetQNameByKey( nPrefixKey, rName ), rValue );
993 void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
994 enum XMLTokenEnum eName,
995 const OUString& rValue )
997 mpAttrList->AddAttribute(
998 _GetNamespaceMap().GetQNameByKey( nPrefixKey, GetXMLToken(eName) ),
999 rValue );
1002 void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
1003 enum XMLTokenEnum eName,
1004 enum XMLTokenEnum eValue)
1006 mpAttrList->AddAttribute(
1007 _GetNamespaceMap().GetQNameByKey( nPrefixKey, GetXMLToken(eName) ),
1008 GetXMLToken(eValue) );
1011 void SvXMLExport::AddAttribute( const OUString& rQName,
1012 const OUString& rValue )
1014 mpAttrList->AddAttribute(
1015 rQName,
1016 rValue );
1019 void SvXMLExport::AddAttribute( const OUString& rQName,
1020 enum ::xmloff::token::XMLTokenEnum eValue )
1022 mpAttrList->AddAttribute(
1023 rQName,
1024 GetXMLToken(eValue) );
1027 void SvXMLExport::AddAttributeList( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
1029 if( xAttrList.is())
1030 mpAttrList->AppendAttributeList( xAttrList );
1033 void SvXMLExport::ClearAttrList()
1035 mpAttrList->Clear();
1038 #ifdef DBG_UTIL
1039 void SvXMLExport::CheckAttrList()
1041 SAL_WARN_IF( mpAttrList->getLength(), "xmloff.core", "XMLExport::CheckAttrList: list is not empty" );
1043 #endif
1045 void SvXMLExport::ImplExportMeta()
1047 CheckAttrList();
1049 _ExportMeta();
1052 void SvXMLExport::ImplExportSettings()
1054 CheckAttrList();
1056 ::std::list< SettingsGroup > aSettings;
1057 sal_Int32 nSettingsCount = 0;
1059 // view settings
1060 uno::Sequence< beans::PropertyValue > aViewSettings;
1061 GetViewSettingsAndViews( aViewSettings );
1062 aSettings.push_back( SettingsGroup( XML_VIEW_SETTINGS, aViewSettings ) );
1063 nSettingsCount += aViewSettings.getLength();
1065 // configuration settings
1066 uno::Sequence<beans::PropertyValue> aConfigSettings;
1067 GetConfigurationSettings( aConfigSettings );
1068 aSettings.push_back( SettingsGroup( XML_CONFIGURATION_SETTINGS, aConfigSettings ) );
1069 nSettingsCount += aConfigSettings.getLength();
1071 // any document specific settings
1072 nSettingsCount += GetDocumentSpecificSettings( aSettings );
1075 SvXMLElementExport aElem( *this,
1076 nSettingsCount != 0,
1077 XML_NAMESPACE_OFFICE, XML_SETTINGS,
1078 sal_True, sal_True );
1080 SettingsExportFacade aSettingsExportContext( *this );
1081 XMLSettingsExportHelper aSettingsExportHelper( aSettingsExportContext );
1083 for ( ::std::list< SettingsGroup >::const_iterator settings = aSettings.begin();
1084 settings != aSettings.end();
1085 ++settings
1088 if ( !settings->aSettings.getLength() )
1089 continue;
1091 OUString sSettingsName( GetXMLToken( settings->eGroupName ) );
1092 OUString sQName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OOO, sSettingsName );
1093 aSettingsExportHelper.exportAllSettings( settings->aSettings, sQName );
1098 void SvXMLExport::ImplExportStyles( sal_Bool )
1100 CheckAttrList();
1103 // <style:styles>
1104 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_STYLES,
1105 sal_True, sal_True );
1107 _ExportStyles( sal_False );
1110 // transfer style names (+ families) TO other components (if appropriate)
1111 if( ( ( mnExportFlags & EXPORT_CONTENT ) == 0 ) && mxExportInfo.is() )
1113 static OUString sStyleNames( "StyleNames" );
1114 static OUString sStyleFamilies( "StyleFamilies" );
1115 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
1116 if ( xPropertySetInfo->hasPropertyByName( sStyleNames ) && xPropertySetInfo->hasPropertyByName( sStyleFamilies ) )
1118 Sequence<sal_Int32> aStyleFamilies;
1119 Sequence<OUString> aStyleNames;
1120 mxAutoStylePool->GetRegisteredNames( aStyleFamilies, aStyleNames );
1121 mxExportInfo->setPropertyValue( sStyleNames, makeAny( aStyleNames ) );
1122 mxExportInfo->setPropertyValue( sStyleFamilies,
1123 makeAny( aStyleFamilies ) );
1128 void SvXMLExport::ImplExportAutoStyles( sal_Bool )
1130 // transfer style names (+ families) FROM other components (if appropriate)
1131 OUString sStyleNames( "StyleNames" );
1132 OUString sStyleFamilies( "StyleFamilies" );
1133 if( ( ( mnExportFlags & EXPORT_STYLES ) == 0 )
1134 && mxExportInfo.is()
1135 && mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleNames )
1136 && mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleFamilies ) )
1138 Sequence<sal_Int32> aStyleFamilies;
1139 mxExportInfo->getPropertyValue( sStyleFamilies ) >>= aStyleFamilies;
1140 Sequence<OUString> aStyleNames;
1141 mxExportInfo->getPropertyValue( sStyleNames ) >>= aStyleNames;
1142 mxAutoStylePool->RegisterNames( aStyleFamilies, aStyleNames );
1146 // <style:automatic-styles>
1147 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE,
1148 XML_AUTOMATIC_STYLES, sal_True, sal_True );
1150 _ExportAutoStyles();
1154 void SvXMLExport::ImplExportMasterStyles( sal_Bool )
1157 // <style:master-styles>
1158 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_MASTER_STYLES,
1159 sal_True, sal_True );
1161 _ExportMasterStyles();
1166 void SvXMLExport::ImplExportContent()
1168 CheckAttrList();
1170 CheckAttrList();
1173 SvXMLElementExport aElemrnt( *this, XML_NAMESPACE_OFFICE, XML_BODY,
1174 sal_True, sal_True );
1176 XMLTokenEnum eClass = meClass;
1177 if( XML_TEXT_GLOBAL == eClass )
1179 AddAttribute( XML_NAMESPACE_TEXT, XML_GLOBAL,
1180 GetXMLToken( XML_TRUE ) );
1181 eClass = XML_TEXT;
1183 if ( XML_GRAPHICS == eClass )
1184 eClass = XML_DRAWING;
1185 // <office:body ...>
1186 SetBodyAttributes();
1187 SvXMLElementExport aElem( *this, meClass != XML_TOKEN_INVALID,
1188 XML_NAMESPACE_OFFICE, eClass,
1189 sal_True, sal_True );
1191 _ExportContent();
1196 void SvXMLExport::SetBodyAttributes()
1200 static void
1201 lcl_AddGrddl(SvXMLExport & rExport, const sal_Int32 /*nExportMode*/)
1203 // check version >= 1.2
1204 switch (rExport.getDefaultVersion()) {
1205 case SvtSaveOptions::ODFVER_011: // fall thru
1206 case SvtSaveOptions::ODFVER_010: return;
1207 default: break;
1210 // #i115030#: disabled
1211 #if 0
1212 if (EXPORT_SETTINGS != nExportMode) // meta, content, styles
1214 rExport.AddAttribute( XML_NAMESPACE_GRDDL, XML_TRANSFORMATION,
1215 OUString(s_grddl_xsl) );
1217 #endif
1220 void SvXMLExport::addChaffWhenEncryptedStorage()
1222 uno::Reference< embed::XEncryptionProtectedSource2 > xEncr(mpImpl->mxTargetStorage, uno::UNO_QUERY);
1224 if (xEncr.is() && xEncr->hasEncryptionData() && mxExtHandler.is())
1226 mxExtHandler->comment(OStringToOUString(comphelper::xml::makeXMLChaff(), RTL_TEXTENCODING_ASCII_US));
1230 sal_uInt32 SvXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass )
1232 bool bOwnGraphicResolver = false;
1233 bool bOwnEmbeddedResolver = false;
1235 if( !mxGraphicResolver.is() || !mxEmbeddedResolver.is() )
1237 Reference< XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
1238 if( xFactory.is() )
1242 if( !mxGraphicResolver.is() )
1244 mxGraphicResolver = Reference< XGraphicObjectResolver >::query(
1245 xFactory->createInstance(
1246 OUString( "com.sun.star.document.ExportGraphicObjectResolver")));
1247 bOwnGraphicResolver = mxGraphicResolver.is();
1250 if( !mxEmbeddedResolver.is() )
1252 mxEmbeddedResolver = Reference< XEmbeddedObjectResolver >::query(
1253 xFactory->createInstance(
1254 OUString( "com.sun.star.document.ExportEmbeddedObjectResolver")));
1255 bOwnEmbeddedResolver = mxEmbeddedResolver.is();
1258 catch(const com::sun::star::uno::Exception&)
1263 if( (getExportFlags() & EXPORT_OASIS) == 0 )
1267 ::comphelper::PropertyMapEntry aInfoMap[] =
1269 { "Class", sizeof("Class")-1, 0,
1270 &::getCppuType((OUString*)0),
1271 PropertyAttribute::MAYBEVOID, 0},
1272 { NULL, 0, 0, NULL, 0, 0 }
1274 Reference< XPropertySet > xConvPropSet(
1275 ::comphelper::GenericPropertySet_CreateInstance(
1276 new ::comphelper::PropertySetInfo( aInfoMap ) ) );
1278 Any aAny;
1279 aAny <<= GetXMLToken( eClass );
1280 xConvPropSet->setPropertyValue(
1281 OUString("Class"), aAny );
1283 Reference< XPropertySet > xPropSet =
1284 mxExportInfo.is()
1285 ? PropertySetMerger_CreateInstance( mxExportInfo,
1286 xConvPropSet )
1287 : xConvPropSet;
1289 Sequence<Any> aArgs( 3 );
1290 aArgs[0] <<= mxHandler;
1291 aArgs[1] <<= xPropSet;
1292 aArgs[2] <<= mxModel;
1294 // get filter component
1295 Reference< xml::sax::XDocumentHandler > xTmpDocHandler(
1296 m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.comp.Oasis2OOoTransformer", aArgs, m_xContext),
1297 UNO_QUERY);
1298 SAL_WARN_IF(!xTmpDocHandler.is(), "xmloff.core", "can't instantiate OASIS transformer component" );
1299 if( xTmpDocHandler.is() )
1301 mxHandler = xTmpDocHandler;
1302 mxExtHandler = uno::Reference<xml::sax::XExtendedDocumentHandler>( mxHandler, UNO_QUERY );
1305 catch(const com::sun::star::uno::Exception&)
1310 mxHandler->startDocument();
1312 addChaffWhenEncryptedStorage();
1314 // <office:document ...>
1315 CheckAttrList();
1317 // namespace attributes
1318 // ( The namespace decls should be first attributes in the element;
1319 // some faulty XML parsers (JAXP1.1) have a problem with this,
1320 // also it's more elegant )
1321 sal_uInt16 nPos = mpNamespaceMap->GetFirstKey();
1322 while( USHRT_MAX != nPos )
1324 mpAttrList->AddAttribute( mpNamespaceMap->GetAttrNameByKey( nPos ),
1325 mpNamespaceMap->GetNameByKey( nPos ) );
1326 nPos = mpNamespaceMap->GetNextKey( nPos );
1331 // office:version = ...
1332 if( !mbExtended )
1334 const sal_Char* pVersion = 0;
1335 switch( getDefaultVersion() )
1337 case SvtSaveOptions::ODFVER_LATEST: pVersion = sXML_1_2; break;
1338 case SvtSaveOptions::ODFVER_012_EXT_COMPAT: pVersion = sXML_1_2; break;
1339 case SvtSaveOptions::ODFVER_012: pVersion = sXML_1_2; break;
1340 case SvtSaveOptions::ODFVER_011: pVersion = sXML_1_1; break;
1341 case SvtSaveOptions::ODFVER_010: break;
1343 default:
1344 SAL_WARN("xmloff.core", "xmloff::SvXMLExport::exportDoc(), unexpected odf default version!");
1347 if( pVersion )
1348 AddAttribute( XML_NAMESPACE_OFFICE, XML_VERSION,
1349 OUString::createFromAscii(pVersion) );
1353 enum XMLTokenEnum eRootService = XML_TOKEN_INVALID;
1354 const sal_Int32 nExportMode = mnExportFlags & (EXPORT_META|EXPORT_STYLES|EXPORT_CONTENT|EXPORT_SETTINGS);
1356 lcl_AddGrddl(*this, nExportMode);
1358 if( EXPORT_META == nExportMode )
1360 // export only meta
1361 eRootService = XML_DOCUMENT_META;
1363 else if ( EXPORT_SETTINGS == nExportMode )
1365 // export only settings
1366 eRootService = XML_DOCUMENT_SETTINGS;
1368 else if( EXPORT_STYLES == nExportMode )
1370 // export only styles
1371 eRootService = XML_DOCUMENT_STYLES;
1373 else if( EXPORT_CONTENT == nExportMode )
1375 // export only content
1376 eRootService = XML_DOCUMENT_CONTENT;
1378 else
1380 // the god'ol one4all element
1381 eRootService = XML_DOCUMENT;
1382 // office:mimetype = ... (only for stream containing the content)
1383 if( eClass != XML_TOKEN_INVALID )
1385 OUString aTmp( "application/vnd.oasis.opendocument." );
1386 aTmp += GetXMLToken( eClass );
1387 AddAttribute( XML_NAMESPACE_OFFICE, XML_MIMETYPE, aTmp );
1391 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, eRootService, sal_True, sal_True );
1393 // meta information
1394 if( mnExportFlags & EXPORT_META )
1395 ImplExportMeta();
1397 // settings
1398 if( mnExportFlags & EXPORT_SETTINGS )
1399 ImplExportSettings();
1401 // scripts
1402 if( mnExportFlags & EXPORT_SCRIPTS )
1403 _ExportScripts();
1405 // font declerations
1406 if( mnExportFlags & EXPORT_FONTDECLS )
1407 _ExportFontDecls();
1409 // styles
1410 if( mnExportFlags & EXPORT_STYLES )
1411 ImplExportStyles( sal_False );
1413 // autostyles
1414 if( mnExportFlags & EXPORT_AUTOSTYLES )
1415 ImplExportAutoStyles( sal_False );
1417 // masterstyles
1418 if( mnExportFlags & EXPORT_MASTERSTYLES )
1419 ImplExportMasterStyles( sal_False );
1421 // contnt
1422 if( mnExportFlags & EXPORT_CONTENT )
1423 ImplExportContent();
1427 mxHandler->endDocument();
1429 if( bOwnGraphicResolver )
1431 Reference< XComponent > xComp( mxGraphicResolver, UNO_QUERY );
1432 xComp->dispose();
1435 if( bOwnEmbeddedResolver )
1437 Reference< XComponent > xComp( mxEmbeddedResolver, UNO_QUERY );
1438 xComp->dispose();
1441 return 0;
1444 void SvXMLExport::ResetNamespaceMap()
1446 delete mpNamespaceMap; mpNamespaceMap = new SvXMLNamespaceMap;
1449 void SvXMLExport::_ExportMeta()
1451 OUString generator( ::utl::DocInfoHelper::GetGeneratorString() );
1452 Reference< XDocumentPropertiesSupplier > xDocPropsSupplier(mxModel,
1453 UNO_QUERY);
1454 if (xDocPropsSupplier.is()) {
1455 Reference<XDocumentProperties> xDocProps(
1456 xDocPropsSupplier->getDocumentProperties());
1457 if (!xDocProps.is()) throw;
1458 // update generator here
1459 xDocProps->setGenerator(generator);
1460 SvXMLMetaExport * pMeta = new SvXMLMetaExport(*this, xDocProps);
1461 uno::Reference<xml::sax::XDocumentHandler> xMeta(pMeta);
1462 pMeta->Export();
1463 } else {
1464 // office:meta
1465 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_META,
1466 sal_True, sal_True );
1468 // BM: #i60323# export generator even if xInfoProp is empty (which is the
1469 // case for charts). The generator does not depend on xInfoProp
1470 SvXMLElementExport anElem( *this, XML_NAMESPACE_META, XML_GENERATOR,
1471 sal_True, sal_True );
1472 Characters(generator);
1477 void SvXMLExport::_ExportScripts()
1479 SvXMLElementExport aElement( *this, XML_NAMESPACE_OFFICE, XML_SCRIPTS, sal_True, sal_True );
1481 // export Basic macros (only for FlatXML)
1482 if ( mnExportFlags & EXPORT_EMBEDDED )
1484 OUString aValue( GetNamespaceMap().GetPrefixByKey( XML_NAMESPACE_OOO ) );
1485 aValue += OUString( ":Basic" );
1486 AddAttribute( XML_NAMESPACE_SCRIPT, XML_LANGUAGE, aValue );
1488 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_SCRIPT, sal_True, sal_True );
1490 // initialize Basic
1491 if ( mxModel.is() )
1493 Reference< beans::XPropertySet > xPSet( mxModel, UNO_QUERY );
1494 if ( xPSet.is() )
1495 xPSet->getPropertyValue( OUString( "BasicLibraries" ) );
1498 Reference < XDocumentHandler > xHdl( new XMLBasicExportFilter( mxHandler ) );
1499 Reference< document::XXMLBasicExporter > xExporter = document::XMLOasisBasicExporter::createWithHandler( m_xContext, xHdl );
1501 Reference< XComponent > xComp( mxModel, UNO_QUERY );
1502 xExporter->setSourceDocument( xComp );
1503 Sequence< PropertyValue > aMediaDesc( 0 );
1504 xExporter->filter( aMediaDesc );
1507 // export document events
1508 Reference< document::XEventsSupplier > xEvents( GetModel(), UNO_QUERY );
1509 GetEventExport().Export( xEvents, sal_True );
1512 void SvXMLExport::_ExportFontDecls()
1514 if( mxFontAutoStylePool.is() )
1515 mxFontAutoStylePool->exportXML();
1518 void SvXMLExport::_ExportStyles( sal_Bool )
1520 uno::Reference< lang::XMultiServiceFactory > xFact( GetModel(), uno::UNO_QUERY );
1521 if( xFact.is())
1523 // export (fill-)gradient-styles
1526 uno::Reference< container::XNameAccess > xGradient( xFact->createInstance( OUString("com.sun.star.drawing.GradientTable" ) ), uno::UNO_QUERY );
1527 if( xGradient.is() )
1529 XMLGradientStyleExport aGradientStyle( *this );
1531 if( xGradient->hasElements() )
1533 uno::Sequence< OUString > aNamesSeq ( xGradient->getElementNames() );
1534 sal_Int32 nCount = aNamesSeq.getLength();
1535 for( sal_Int32 i=0; i<nCount; i++ )
1537 const OUString& rStrName = aNamesSeq[ i ];
1541 uno::Any aValue = xGradient->getByName( rStrName );
1543 aGradientStyle.exportXML( rStrName, aValue );
1545 catch(const container::NoSuchElementException&)
1552 catch(const lang::ServiceNotRegisteredException&)
1556 // export (fill-)hatch-styles
1559 uno::Reference< container::XNameAccess > xHatch( xFact->createInstance( OUString("com.sun.star.drawing.HatchTable" ) ), uno::UNO_QUERY );
1560 if( xHatch.is() )
1562 XMLHatchStyleExport aHatchStyle( *this );
1564 if( xHatch->hasElements() )
1566 uno::Sequence< OUString > aNamesSeq ( xHatch->getElementNames() );
1567 sal_Int32 nCount = aNamesSeq.getLength();
1568 for( sal_Int32 i=0; i<nCount; i++ )
1570 const OUString& rStrName = aNamesSeq[ i ];
1574 uno::Any aValue = xHatch->getByName( rStrName );
1576 aHatchStyle.exportXML( rStrName, aValue );
1578 catch(const container::NoSuchElementException&)
1584 catch(const lang::ServiceNotRegisteredException&)
1588 // export (fill-)bitmap-styles
1591 uno::Reference< container::XNameAccess > xBitmap( xFact->createInstance( OUString("com.sun.star.drawing.BitmapTable" ) ), uno::UNO_QUERY );
1592 if( xBitmap.is() )
1594 XMLImageStyle aImageStyle;
1596 if( xBitmap->hasElements() )
1598 uno::Sequence< OUString > aNamesSeq ( xBitmap->getElementNames() );
1599 sal_Int32 nCount = aNamesSeq.getLength();
1600 for( sal_Int32 i=0; i<nCount; i++ )
1602 const OUString& rStrName = aNamesSeq[ i ];
1606 uno::Any aValue = xBitmap->getByName( rStrName );
1608 aImageStyle.exportXML( rStrName, aValue, *this );
1610 catch(const container::NoSuchElementException&)
1617 catch(const lang::ServiceNotRegisteredException&)
1621 // export transparency-gradient -styles
1624 uno::Reference< container::XNameAccess > xTransGradient( xFact->createInstance( OUString("com.sun.star.drawing.TransparencyGradientTable" ) ), uno::UNO_QUERY );
1625 if( xTransGradient.is() )
1627 XMLTransGradientStyleExport aTransGradientstyle( *this );
1629 if( xTransGradient->hasElements() )
1631 uno::Sequence< OUString > aNamesSeq ( xTransGradient->getElementNames() );
1632 sal_Int32 nCount = aNamesSeq.getLength();
1633 for( sal_Int32 i=0; i<nCount; i++ )
1635 const OUString& rStrName = aNamesSeq[ i ];
1639 uno::Any aValue = xTransGradient->getByName( rStrName );
1641 aTransGradientstyle.exportXML( rStrName, aValue );
1643 catch(const container::NoSuchElementException&)
1650 catch(const lang::ServiceNotRegisteredException&)
1654 // export marker-styles
1657 uno::Reference< container::XNameAccess > xMarker( xFact->createInstance( OUString("com.sun.star.drawing.MarkerTable" ) ), uno::UNO_QUERY );
1658 if( xMarker.is() )
1660 XMLMarkerStyleExport aMarkerStyle( *this );
1662 if( xMarker->hasElements() )
1664 uno::Sequence< OUString > aNamesSeq ( xMarker->getElementNames() );
1665 sal_Int32 nCount = aNamesSeq.getLength();
1666 for( sal_Int32 i=0; i<nCount; i++ )
1668 const OUString& rStrName = aNamesSeq[ i ];
1672 uno::Any aValue = xMarker->getByName( rStrName );
1674 aMarkerStyle.exportXML( rStrName, aValue );
1676 catch(const container::NoSuchElementException&)
1683 catch(const lang::ServiceNotRegisteredException&)
1687 // export dash-styles
1690 uno::Reference< container::XNameAccess > xDashes( xFact->createInstance( OUString("com.sun.star.drawing.DashTable" ) ), uno::UNO_QUERY );
1691 if( xDashes.is() )
1693 XMLDashStyleExport aDashStyle( *this );
1695 if( xDashes->hasElements() )
1697 uno::Sequence< OUString > aNamesSeq ( xDashes->getElementNames() );
1698 sal_Int32 nCount = aNamesSeq.getLength();
1699 for( sal_Int32 i=0; i<nCount; i++ )
1701 const OUString& rStrName = aNamesSeq[ i ];
1705 uno::Any aValue = xDashes->getByName( rStrName );
1707 aDashStyle.exportXML( rStrName, aValue );
1709 catch(const container::NoSuchElementException&)
1716 catch(const lang::ServiceNotRegisteredException&)
1722 XMLTextParagraphExport* SvXMLExport::CreateTextParagraphExport()
1724 return new XMLTextParagraphExport( *this, *(GetAutoStylePool().get()) );
1727 XMLShapeExport* SvXMLExport::CreateShapeExport()
1729 return new XMLShapeExport(*this);
1732 SvXMLAutoStylePoolP* SvXMLExport::CreateAutoStylePool()
1734 return new SvXMLAutoStylePoolP(*this);
1737 XMLPageExport* SvXMLExport::CreatePageExport()
1739 return new XMLPageExport( *this );
1742 SchXMLExportHelper* SvXMLExport::CreateChartExport()
1744 return new SchXMLExportHelper(*this,*GetAutoStylePool().get());
1747 XMLFontAutoStylePool* SvXMLExport::CreateFontAutoStylePool()
1749 return new XMLFontAutoStylePool( *this );
1752 xmloff::OFormLayerXMLExport* SvXMLExport::CreateFormExport()
1754 return new xmloff::OFormLayerXMLExport(*this);
1757 void SvXMLExport::GetViewSettingsAndViews(uno::Sequence<beans::PropertyValue>& rProps)
1759 GetViewSettings(rProps);
1760 uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetModel(), uno::UNO_QUERY);
1761 if(xViewDataSupplier.is())
1763 uno::Reference<container::XIndexAccess> xIndexAccess;
1764 xViewDataSupplier->setViewData( xIndexAccess ); // make sure we get a newly created sequence
1765 xIndexAccess = xViewDataSupplier->getViewData();
1766 sal_Bool bAdd = sal_False;
1767 uno::Any aAny;
1768 if(xIndexAccess.is() && xIndexAccess->hasElements() )
1770 sal_Int32 nCount = xIndexAccess->getCount();
1771 for (sal_Int32 i = 0; i < nCount; i++)
1773 aAny = xIndexAccess->getByIndex(i);
1774 uno::Sequence<beans::PropertyValue> aProps;
1775 if( aAny >>= aProps )
1777 if( aProps.getLength() > 0 )
1779 bAdd = sal_True;
1780 break;
1786 if( bAdd )
1788 sal_Int32 nOldLength(rProps.getLength());
1789 rProps.realloc(nOldLength + 1);
1790 beans::PropertyValue aProp;
1791 aProp.Name = OUString("Views");
1792 aProp.Value <<= xIndexAccess;
1793 rProps[nOldLength] = aProp;
1798 void SvXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>&)
1802 void SvXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>&)
1806 sal_Int32 SvXMLExport::GetDocumentSpecificSettings( ::std::list< SettingsGroup >& _out_rSettings )
1808 (void)_out_rSettings;
1809 return 0;
1812 void SvXMLExport::addDataStyle(const sal_Int32 nNumberFormat, sal_Bool /*bTimeFormat*/ )
1814 if(mpNumExport)
1815 mpNumExport->SetUsed(nNumberFormat);
1818 void SvXMLExport::exportDataStyles()
1820 if(mpNumExport)
1821 mpNumExport->Export(sal_False);
1824 void SvXMLExport::exportAutoDataStyles()
1826 if(mpNumExport)
1827 mpNumExport->Export(sal_True);
1829 if (mxFormExport.is())
1830 mxFormExport->exportAutoControlNumberStyles();
1833 OUString SvXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, sal_Bool /*bTimeFormat*/ ) const
1835 OUString sTemp;
1836 if(mpNumExport)
1837 sTemp = mpNumExport->GetStyleName(nNumberFormat);
1838 return sTemp;
1841 void SvXMLExport::exportAnnotationMeta(const uno::Reference<drawing::XShape>&)
1845 sal_Int32 SvXMLExport::dataStyleForceSystemLanguage(sal_Int32 nFormat) const
1847 return ( mpNumExport != NULL )
1848 ? mpNumExport->ForceSystemLanguage( nFormat ) : nFormat;
1852 OUString SvXMLExport::AddEmbeddedGraphicObject( const OUString& rGraphicObjectURL )
1854 OUString sRet( rGraphicObjectURL );
1855 if( rGraphicObjectURL.startsWith( msGraphicObjectProtocol ) &&
1856 mxGraphicResolver.is() )
1858 if( (getExportFlags() & EXPORT_EMBEDDED) == 0 )
1859 sRet = mxGraphicResolver->resolveGraphicObjectURL( rGraphicObjectURL );
1860 else
1861 sRet = OUString();
1863 else
1864 sRet = GetRelativeReference( sRet );
1866 return sRet;
1869 sal_Bool SvXMLExport::AddEmbeddedGraphicObjectAsBase64( const OUString& rGraphicObjectURL )
1871 sal_Bool bRet = sal_False;
1873 if( (getExportFlags() & EXPORT_EMBEDDED) != 0 &&
1874 rGraphicObjectURL.startsWith( msGraphicObjectProtocol ) &&
1875 mxGraphicResolver.is() )
1877 Reference< XBinaryStreamResolver > xStmResolver( mxGraphicResolver, UNO_QUERY );
1879 if( xStmResolver.is() )
1881 Reference< XInputStream > xIn( xStmResolver->getInputStream( rGraphicObjectURL ) );
1883 if( xIn.is() )
1885 XMLBase64Export aBase64Exp( *this );
1886 bRet = aBase64Exp.exportOfficeBinaryDataElement( xIn );
1891 return bRet;
1894 OUString SvXMLExport::AddEmbeddedObject( const OUString& rEmbeddedObjectURL )
1896 OUString sRet;
1897 if( (rEmbeddedObjectURL.startsWith( msEmbeddedObjectProtocol ) ||
1898 rEmbeddedObjectURL.startsWith( msGraphicObjectProtocol ) ) &&
1899 mxEmbeddedResolver.is() )
1901 sRet =
1902 mxEmbeddedResolver->resolveEmbeddedObjectURL( rEmbeddedObjectURL );
1904 else
1905 sRet = GetRelativeReference( rEmbeddedObjectURL );
1907 return sRet;
1910 sal_Bool SvXMLExport::AddEmbeddedObjectAsBase64( const OUString& rEmbeddedObjectURL )
1912 sal_Bool bRet = sal_False;
1913 if( (rEmbeddedObjectURL.startsWith( msEmbeddedObjectProtocol ) ||
1914 rEmbeddedObjectURL.startsWith( msGraphicObjectProtocol ) ) &&
1915 mxEmbeddedResolver.is() )
1917 Reference < XNameAccess > xNA( mxEmbeddedResolver, UNO_QUERY );
1918 if( xNA.is() )
1920 Any aAny = xNA->getByName( rEmbeddedObjectURL );
1921 Reference < XInputStream > xIn;
1922 aAny >>= xIn;
1923 if( xIn.is() )
1925 XMLBase64Export aBase64Exp( *this );
1926 bRet = aBase64Exp.exportOfficeBinaryDataElement( xIn );
1931 return bRet;
1934 OUString SvXMLExport::EncodeStyleName(
1935 const OUString& rName,
1936 sal_Bool *pEncoded ) const
1938 return GetMM100UnitConverter().encodeStyleName( rName, pEncoded );
1941 ProgressBarHelper* SvXMLExport::GetProgressBarHelper()
1943 if (!mpProgressBarHelper)
1945 mpProgressBarHelper = new ProgressBarHelper(mxStatusIndicator, sal_True);
1947 if (mxExportInfo.is())
1949 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
1950 if (xPropertySetInfo.is())
1952 OUString sProgressRange(XML_PROGRESSRANGE);
1953 OUString sProgressMax(XML_PROGRESSMAX);
1954 OUString sProgressCurrent(XML_PROGRESSCURRENT);
1955 OUString sRepeat(XML_PROGRESSREPEAT);
1956 if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
1957 xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
1958 xPropertySetInfo->hasPropertyByName(sProgressRange))
1960 uno::Any aAny;
1961 sal_Int32 nProgressMax(0);
1962 sal_Int32 nProgressCurrent(0);
1963 sal_Int32 nProgressRange(0);
1964 aAny = mxExportInfo->getPropertyValue(sProgressRange);
1965 if (aAny >>= nProgressRange)
1966 mpProgressBarHelper->SetRange(nProgressRange);
1967 aAny = mxExportInfo->getPropertyValue(sProgressMax);
1968 if (aAny >>= nProgressMax)
1969 mpProgressBarHelper->SetReference(nProgressMax);
1970 aAny = mxExportInfo->getPropertyValue(sProgressCurrent);
1971 if (aAny >>= nProgressCurrent)
1972 mpProgressBarHelper->SetValue(nProgressCurrent);
1974 if (xPropertySetInfo->hasPropertyByName(sRepeat))
1976 uno::Any aAny = mxExportInfo->getPropertyValue(sRepeat);
1977 if (aAny.getValueType() == getBooleanCppuType())
1978 mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
1979 else {
1980 SAL_WARN("xmloff.core", "why is it no boolean?" );
1986 return mpProgressBarHelper;
1989 XMLEventExport& SvXMLExport::GetEventExport()
1991 if( NULL == mpEventExport)
1993 // create EventExport on demand
1994 mpEventExport = new XMLEventExport(*this, NULL);
1996 // and register standard handlers + names
1997 OUString sStarBasic("StarBasic");
1998 mpEventExport->AddHandler(sStarBasic, new XMLStarBasicExportHandler());
1999 OUString sScript("Script");
2000 mpEventExport->AddHandler(sScript, new XMLScriptExportHandler());
2001 mpEventExport->AddTranslationTable(aStandardEventTable);
2004 return *mpEventExport;
2007 XMLImageMapExport& SvXMLExport::GetImageMapExport()
2009 // image map export, create on-demand
2010 if( NULL == mpImageMapExport )
2012 mpImageMapExport = new XMLImageMapExport(*this);
2015 return *mpImageMapExport;
2018 namespace
2020 class theSvXMLExportUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSvXMLExportUnoTunnelId> {};
2023 // XUnoTunnel & co
2024 const uno::Sequence< sal_Int8 > & SvXMLExport::getUnoTunnelId() throw()
2026 return theSvXMLExportUnoTunnelId::get().getSeq();
2029 SvXMLExport* SvXMLExport::getImplementation( uno::Reference< uno::XInterface > xInt ) throw()
2031 uno::Reference< lang::XUnoTunnel > xUT( xInt, uno::UNO_QUERY );
2032 if( xUT.is() )
2034 return
2035 reinterpret_cast<SvXMLExport*>(
2036 sal::static_int_cast<sal_IntPtr>(
2037 xUT->getSomething( SvXMLExport::getUnoTunnelId())));
2039 else
2040 return NULL;
2043 // XUnoTunnel
2044 sal_Int64 SAL_CALL SvXMLExport::getSomething( const uno::Sequence< sal_Int8 >& rId )
2045 throw( uno::RuntimeException )
2047 if( rId.getLength() == 16 && 0 == memcmp( getUnoTunnelId().getConstArray(),
2048 rId.getConstArray(), 16 ) )
2050 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
2052 return 0;
2055 sal_Bool SvXMLExport::ExportEmbeddedOwnObject( Reference< XComponent >& rComp )
2057 OUString sFilterService;
2058 bool bIsChart = false;
2060 Reference < lang::XServiceInfo > xServiceInfo( rComp, UNO_QUERY );
2061 if( xServiceInfo.is() )
2063 const XMLServiceMapEntry_Impl *pEntry = aServiceMap;
2064 while( pEntry->sModelService )
2066 OUString sModelService( pEntry->sModelService,
2067 pEntry->nModelServiceLen,
2068 RTL_TEXTENCODING_ASCII_US );
2069 if( xServiceInfo->supportsService( sModelService ) )
2071 sFilterService = OUString( pEntry->sFilterService,
2072 pEntry->nFilterServiceLen,
2073 RTL_TEXTENCODING_ASCII_US );
2074 bIsChart = sModelService == XML_MODEL_SERVICE_CHART;
2075 break;
2077 pEntry++;
2081 SAL_WARN_IF( !sFilterService.getLength(), "xmloff.core", "no export filter for own object" );
2083 if( sFilterService.isEmpty() )
2084 return sal_False;
2086 Reference < XDocumentHandler > xHdl =
2087 new XMLEmbeddedObjectExportFilter( mxHandler );
2089 Sequence < Any > aArgs( 1 );
2090 // #144135# the filters for embedded objects in flat format are always
2091 // instantiated as Oasis filters and transformed afterwards. Therefore, all
2092 // special handling that is done if the exportFlags do not contain
2093 // EXPORT_OASIS must be changed to properties being passed in the info
2094 // propertyset
2096 if( ! (getExportFlags() & EXPORT_OASIS) &&
2097 bIsChart )
2099 static ::comphelper::PropertyMapEntry aInfoMap[] =
2101 { "ExportTableNumberList", 21, 0, &::getBooleanCppuType(), PropertyAttribute::MAYBEVOID, 0},
2102 { NULL, 0, 0, NULL, 0, 0 }
2104 Reference< XPropertySet > xInfoProp(
2105 ::comphelper::GenericPropertySet_CreateInstance(
2106 new ::comphelper::PropertySetInfo( aInfoMap )));
2108 if( bIsChart )
2109 xInfoProp->setPropertyValue( OUString( "ExportTableNumberList"), makeAny( true ));
2111 aArgs.realloc( 2 );
2112 aArgs[1] <<= xInfoProp;
2114 aArgs[0] <<= xHdl;
2116 Reference< document::XExporter > xExporter(
2117 m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(sFilterService, aArgs, m_xContext),
2118 UNO_QUERY);
2119 SAL_WARN_IF( !xExporter.is(), "xmloff.core", "can't instantiate export filter component for own object" );
2120 if( !xExporter.is() )
2121 return sal_False;
2123 xExporter->setSourceDocument( rComp );
2125 Reference<XFilter> xFilter( xExporter, UNO_QUERY );
2127 Sequence < PropertyValue > aMediaDesc( 0 );
2128 return xFilter->filter( aMediaDesc );
2131 OUString SvXMLExport::GetRelativeReference(const OUString& rValue)
2133 OUString sValue( rValue );
2134 // #i65474# handling of fragment URLs ("#....") is undefined
2135 // they are stored 'as is'
2136 uno::Reference< uri::XUriReference > xUriRef;
2137 if(!sValue.isEmpty() && sValue.getStr()[0] != '#')
2141 xUriRef = mpImpl->mxUriReferenceFactory->parse( rValue );
2142 if( xUriRef.is() && !xUriRef->isAbsolute() )
2144 //#i61943# relative URLs need special handling
2145 INetURLObject aTemp( mpImpl->msPackageURI );
2146 bool bWasAbsolute = false;
2147 sValue = aTemp.smartRel2Abs(sValue, bWasAbsolute ).GetMainURL(INetURLObject::DECODE_TO_IURI);
2150 catch(const uno::Exception&)
2154 if( xUriRef.is() )//no conversion for empty values or for fragments
2156 //conversion for matching schemes only
2157 if( xUriRef->getScheme() == mpImpl->msPackageURIScheme )
2159 sValue = INetURLObject::GetRelURL( msOrigFileName, sValue,
2160 INetURLObject::WAS_ENCODED, INetURLObject::DECODE_TO_IURI, RTL_TEXTENCODING_UTF8, INetURLObject::FSYS_DETECT);
2163 return sValue;
2166 void SvXMLExport::StartElement(sal_uInt16 nPrefix,
2167 enum ::xmloff::token::XMLTokenEnum eName,
2168 sal_Bool bIgnWSOutside )
2170 StartElement(_GetNamespaceMap().GetQNameByKey( nPrefix,
2171 GetXMLToken(eName) ), bIgnWSOutside);
2174 void SvXMLExport::StartElement(const OUString& rName,
2175 sal_Bool bIgnWSOutside )
2177 if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING)
2181 if( bIgnWSOutside && ((mnExportFlags & EXPORT_PRETTY) == EXPORT_PRETTY))
2182 mxHandler->ignorableWhitespace( msWS );
2183 mxHandler->startElement( rName, GetXAttrList() );
2185 catch (const SAXInvalidCharacterException& e)
2187 Sequence<OUString> aPars(1);
2188 aPars[0] = rName;
2189 SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, NULL );
2191 catch (const SAXException& e)
2193 Sequence<OUString> aPars(1);
2194 aPars[0] = rName;
2195 SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE,
2196 aPars, e.Message, NULL );
2199 ClearAttrList();
2200 ++mpImpl->mDepth; // increment nesting depth counter
2203 void SvXMLExport::Characters(const OUString& rChars)
2205 if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING)
2209 mxHandler->characters(rChars);
2211 catch (const SAXInvalidCharacterException& e)
2213 Sequence<OUString> aPars(1);
2214 aPars[0] = rChars;
2215 SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, NULL );
2217 catch (const SAXException& e)
2219 Sequence<OUString> aPars(1);
2220 aPars[0] = rChars;
2221 SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE,
2222 aPars, e.Message, NULL );
2227 void SvXMLExport::EndElement(sal_uInt16 nPrefix,
2228 enum ::xmloff::token::XMLTokenEnum eName,
2229 sal_Bool bIgnWSInside )
2231 EndElement(_GetNamespaceMap().GetQNameByKey( nPrefix, GetXMLToken(eName) ),
2232 bIgnWSInside);
2235 void SvXMLExport::EndElement(const OUString& rName,
2236 sal_Bool bIgnWSInside )
2238 // decrement nesting depth counter & (maybe) restore namespace map
2239 --mpImpl->mDepth;
2240 if (!mpImpl->mNamespaceMaps.empty() &&
2241 (mpImpl->mNamespaceMaps.top().second == mpImpl->mDepth))
2243 delete mpNamespaceMap;
2244 mpNamespaceMap = mpImpl->mNamespaceMaps.top().first;
2245 mpImpl->mNamespaceMaps.pop();
2247 SAL_WARN_IF(!mpImpl->mNamespaceMaps.empty() &&
2248 (mpImpl->mNamespaceMaps.top().second >= mpImpl->mDepth), "xmloff.core", "SvXMLExport: NamespaceMaps corrupted");
2250 if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING)
2254 if( bIgnWSInside && ((mnExportFlags & EXPORT_PRETTY) == EXPORT_PRETTY))
2255 mxHandler->ignorableWhitespace( msWS );
2256 mxHandler->endElement( rName );
2258 catch (const SAXException& e)
2260 Sequence<OUString> aPars(1);
2261 aPars[0] = rName;
2262 SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE,
2263 aPars, e.Message, NULL );
2268 void SvXMLExport::IgnorableWhitespace()
2270 if ((mnExportFlags & EXPORT_PRETTY) != EXPORT_PRETTY)
2271 return;
2273 if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING)
2277 mxHandler->ignorableWhitespace( msWS );
2279 catch (const SAXException& e)
2281 Sequence<OUString> aPars(0);
2282 SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE,
2283 aPars, e.Message, NULL );
2289 void SvXMLExport::SetError(
2290 sal_Int32 nId,
2291 const Sequence<OUString>& rMsgParams,
2292 const OUString& rExceptionMessage,
2293 const Reference<XLocator>& rLocator )
2295 // allow multi-threaded access to the cancel() method
2296 static osl::Mutex aMutex;
2297 osl::MutexGuard aGuard(aMutex);
2299 // maintain error flags
2300 if ( ( nId & XMLERROR_FLAG_ERROR ) != 0 )
2301 mnErrorFlags |= ERROR_ERROR_OCCURRED;
2302 if ( ( nId & XMLERROR_FLAG_WARNING ) != 0 )
2303 mnErrorFlags |= ERROR_WARNING_OCCURRED;
2304 if ( ( nId & XMLERROR_FLAG_SEVERE ) != 0 )
2305 mnErrorFlags |= ERROR_DO_NOTHING;
2307 // create error lsit on demand
2308 if ( mpXMLErrors == NULL )
2309 mpXMLErrors = new XMLErrors();
2311 // save error information
2312 mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage, rLocator );
2315 void SvXMLExport::SetError(
2316 sal_Int32 nId,
2317 const Sequence<OUString>& rMsgParams)
2319 OUString sEmpty;
2320 SetError( nId, rMsgParams, sEmpty, NULL );
2323 void SvXMLExport::DisposingModel()
2325 mxModel.clear();
2326 // Shapes in Writer cannot be named via context menu (#i51726#)
2327 meModelType = SvtModuleOptions::E_UNKNOWN_FACTORY;
2328 mxEventListener.clear();
2331 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SvXMLExport::getComponentContext()
2333 return m_xContext;
2336 ::comphelper::UnoInterfaceToUniqueIdentifierMapper& SvXMLExport::getInterfaceToIdentifierMapper()
2338 return mpImpl->maInterfaceToIdentifierMapper;
2341 // Written OpenDocument file format doesn't fit to the created text document (#i69627#)
2342 sal_Bool SvXMLExport::writeOutlineStyleAsNormalListStyle() const
2344 return mpImpl->mbOutlineStyleAsNormalListStyle;
2347 uno::Reference< embed::XStorage > SvXMLExport::GetTargetStorage()
2349 return mpImpl->mxTargetStorage;
2352 /// returns the currently configured default version for ODF export
2353 SvtSaveOptions::ODFDefaultVersion SvXMLExport::getDefaultVersion() const
2355 if( mpImpl )
2356 return mpImpl->maSaveOptions.GetODFDefaultVersion();
2358 // fatal error, use current version as default
2359 return SvtSaveOptions::ODFVER_012;
2362 OUString SvXMLExport::GetStreamName() const
2364 return mpImpl->mStreamName;
2367 void
2368 SvXMLExport::AddAttributeIdLegacy(
2369 sal_uInt16 const nLegacyPrefix, OUString const& rValue)
2371 switch (getDefaultVersion()) {
2372 case SvtSaveOptions::ODFVER_011: // fall thru
2373 case SvtSaveOptions::ODFVER_010: break;
2374 default: // ODF 1.2: xml:id
2375 AddAttribute(XML_NAMESPACE_XML, XML_ID, rValue);
2377 // in ODF 1.1 this was form:id, anim:id, draw:id, or text:id
2378 // backward compatibility: in ODF 1.2 write _both_ id attrs
2379 AddAttribute(nLegacyPrefix, XML_ID, rValue);
2380 // FIXME: this function simply assumes that rValue is unique
2383 void
2384 SvXMLExport::AddAttributeXmlId(uno::Reference<uno::XInterface> const & i_xIfc)
2386 // check version >= 1.2
2387 switch (getDefaultVersion()) {
2388 case SvtSaveOptions::ODFVER_011: // fall thru
2389 case SvtSaveOptions::ODFVER_010: return;
2390 default: break;
2392 const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc,
2393 uno::UNO_QUERY);
2394 //FIXME not yet...
2395 if ( xMeta.is() )
2397 const beans::StringPair mdref( xMeta->getMetadataReference() );
2398 if ( !mdref.Second.isEmpty() )
2400 const OUString streamName( GetStreamName() );
2401 if ( !streamName.isEmpty() )
2403 if ( streamName.equals(mdref.First) )
2405 AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second );
2407 else
2409 SAL_WARN("xmloff.core","SvXMLExport::AddAttributeXmlId: invalid stream name");
2412 else
2414 // FIXME: this is ugly
2415 // there is no stream name (e.g. XSLT, flat-xml format)!
2416 // but how do we ensure uniqueness in this case?
2417 // a) just omit styles.xml ids -- they are unlikely anyway...
2418 // b) somehow find out whether we are currently exporting styles
2419 // or content, and prefix "s" or "c" => unique
2420 if ( mdref.First == "content.xml" )
2422 AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second );
2424 else
2426 SAL_INFO("xmloff.core", "SvXMLExport::AddAttributeXmlId: no stream name given: dropping styles.xml xml:id");
2433 void
2434 SvXMLExport::AddAttributesRDFa(
2435 uno::Reference<text::XTextContent> const & i_xTextContent)
2437 // check version >= 1.2
2438 switch (getDefaultVersion()) {
2439 case SvtSaveOptions::ODFVER_011: // fall thru
2440 case SvtSaveOptions::ODFVER_010: return;
2441 default: break;
2444 const uno::Reference<rdf::XMetadatable> xMeta(
2445 i_xTextContent, uno::UNO_QUERY);
2446 if (!xMeta.is() || xMeta->getMetadataReference().Second.isEmpty())
2448 return; // no xml:id => no RDFa
2451 if (!mpImpl->mpRDFaHelper.get())
2453 mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaExportHelper(*this) );
2455 mpImpl->mpRDFaHelper->AddRDFa(xMeta);
2458 sal_Bool SvXMLExport::exportTextNumberElement() const
2460 return mpImpl->mbExportTextNumberElement;
2463 sal_Bool SvXMLExport::SetNullDateOnUnitConverter()
2465 // if the null date has already been set, don't set it again (performance)
2466 if (!mpImpl->mbNullDateInitialized)
2467 mpImpl->mbNullDateInitialized = GetMM100UnitConverter().setNullDate(GetModel());
2469 return mpImpl->mbNullDateInitialized;
2472 //=============================================================================
2474 void SvXMLElementExport::StartElement( SvXMLExport& rExp,
2475 sal_uInt16 nPrefixKey,
2476 const OUString& rLName,
2477 sal_Bool bIWSOutside )
2479 aName = rExp.GetNamespaceMap().GetQNameByKey(nPrefixKey, rLName);
2480 rExp.StartElement(aName, bIWSOutside);
2483 SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
2484 sal_uInt16 nPrefixKey,
2485 const sal_Char *pLName,
2486 sal_Bool bIWSOutside,
2487 sal_Bool bIWSInside ) :
2488 rExport( rExp ),
2489 bIgnWS( bIWSInside ),
2490 bDoSomething( sal_True )
2492 OUString sLName( OUString::createFromAscii(pLName) );
2493 StartElement( rExp, nPrefixKey, sLName, bIWSOutside );
2496 SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
2497 sal_uInt16 nPrefixKey,
2498 const OUString& rLName,
2499 sal_Bool bIWSOutside,
2500 sal_Bool bIWSInside ) :
2501 rExport( rExp ),
2502 bIgnWS( bIWSInside ),
2503 bDoSomething( sal_True )
2505 StartElement( rExp, nPrefixKey, rLName, bIWSOutside );
2508 SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
2509 sal_uInt16 nPrefixKey,
2510 enum XMLTokenEnum eLName,
2511 sal_Bool bIWSOutside,
2512 sal_Bool bIWSInside ) :
2513 rExport( rExp ),
2514 bIgnWS( bIWSInside ),
2515 bDoSomething( sal_True )
2517 StartElement( rExp, nPrefixKey, GetXMLToken(eLName), bIWSOutside );
2520 SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
2521 sal_Bool bDoSth,
2522 sal_uInt16 nPrefixKey,
2523 enum XMLTokenEnum eLName,
2524 sal_Bool bIWSOutside,
2525 sal_Bool bIWSInside ) :
2526 rExport( rExp ),
2527 bIgnWS( bIWSInside ),
2528 bDoSomething( bDoSth )
2530 if( bDoSomething )
2531 StartElement( rExport, nPrefixKey, GetXMLToken(eLName), bIWSOutside );
2534 SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
2535 const OUString& rQName,
2536 sal_Bool bIWSOutside,
2537 sal_Bool bIWSInside ) :
2538 rExport( rExp ),
2539 bIgnWS( bIWSInside ),
2540 bDoSomething( sal_True )
2542 aName = rQName;
2543 rExp.StartElement( rQName, bIWSOutside );
2546 SvXMLElementExport::~SvXMLElementExport()
2548 if( bDoSomething )
2550 rExport.EndElement( aName, bIgnWS );
2554 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */