1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26
27 #ifdef PRECOMPILED
28 #include "filt_pch.hxx"
29 #endif
30 #include "unointerfacetouniqueidentifiermapper.hxx"
31 #include <osl/mutex.hxx>
32 #include <rtl/uuid.h>
33 #include <tools/debug.hxx>
34 #include <tools/urlobj.hxx>
35 #include <comphelper/genericpropertyset.hxx>
36 #include <com/sun/star/container/XNameAccess.hpp>
37 #include <com/sun/star/io/XInputStream.hpp>
38 #include <com/sun/star/document/XBinaryStreamResolver.hpp>
39 #include <com/sun/star/xml/sax/SAXInvalidCharacterException.hpp>
40 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
41 #include <com/sun/star/uri/UriReferenceFactory.hpp>
42 #include <comphelper/processfactory.hxx>
43 #include <comphelper/configurationhelper.hxx>
44 #include <xmloff/attrlist.hxx>
45 #include <xmloff/nmspmap.hxx>
46 #include <xmloff/xmluconv.hxx>
47 #include "xmloff/xmlnmspe.hxx"
48 #include <xmloff/xmltoken.hxx>
49 #include <xmloff/xmlexp.hxx>
50 #include <xmloff/xmlnumfe.hxx>
51 #include <xmloff/xmlmetae.hxx>
52 #include <xmloff/XMLSettingsExportContext.hxx>
53 #include <xmloff/families.hxx>
54 #include <xmloff/XMLEventExport.hxx>
55 #include "XMLStarBasicExportHandler.hxx"
56 #include "XMLScriptExportHandler.hxx"
57 #include <xmloff/SettingsExportHelper.hxx>
58 #include <com/sun/star/container/XNameAccess.hpp>
59 #include <com/sun/star/container/XIndexContainer.hpp>
60 #include <com/sun/star/document/XEventsSupplier.hpp>
61 #include <com/sun/star/document/XViewDataSupplier.hpp>
62 #include <xmloff/GradientStyle.hxx>
63 #include <xmloff/HatchStyle.hxx>
64 #include <xmloff/ImageStyle.hxx>
65 #include <TransGradientStyle.hxx>
66 #include <xmloff/MarkerStyle.hxx>
67 #include <xmloff/DashStyle.hxx>
68 #include <xmloff/XMLFontAutoStylePool.hxx>
69 #include "XMLImageMapExport.hxx"
70 #include "XMLBase64Export.hxx"
71 #include "xmloff/xmlerror.hxx"
72 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
73 #include <com/sun/star/beans/PropertyAttribute.hpp>
74 #include "xmloff/XMLFilterServiceNames.h"
75 #include "xmloff/XMLEmbeddedObjectExportFilter.hxx"
76 #include "XMLBasicExportFilter.hxx"
77 #include <vos/mutex.hxx>
78 #include <rtl/logfile.hxx>
79 #include <cppuhelper/implbase1.hxx>
80 #include <comphelper/extract.hxx>
81 #include "PropertySetMerger.hxx"
82
83 #include "svl/urihelper.hxx"
84 #include "xmloff/xformsexport.hxx"
85
86 #include <unotools/docinfohelper.hxx>
87 #include <unotools/bootstrap.hxx>
88 #include <unotools/configmgr.hxx>
89 #include <tools/inetdef.hxx>
90 #include <com/sun/star/document/XDocumentProperties.hpp>
91 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
92
93 #include <com/sun/star/rdf/XMetadatable.hpp>
94 #include "RDFaExportHelper.hxx"
95
96
97 using ::rtl::OUString;
98
99 using namespace ::osl;
100 using namespace ::com::sun::star;
101 using namespace ::com::sun::star::uno;
102 using namespace ::com::sun::star::frame;
103 using namespace ::com::sun::star::container;
104 using namespace ::com::sun::star::lang;
105 using namespace ::com::sun::star::document;
106 using namespace ::com::sun::star::beans;
107 using namespace ::com::sun::star::xml::sax;
108 using namespace ::com::sun::star::io;
109 using namespace ::xmloff::token;
110
111 sal_Char __READONLY_DATA sXML_1_1[] = "1.1";
112 sal_Char __READONLY_DATA sXML_1_2[] = "1.2";
113
114 const sal_Char *sOpenOfficeOrgProject ="OpenOffice.org_project";
115
116 // #i115030#: the XSLT is not finished, and not available via HTTP
117 const sal_Char s_grddl_xsl[] = "http://FIXME";
118
119 #define LOGFILE_AUTHOR "mb93740"
120
121 #define XML_MODEL_SERVICE_WRITER "com.sun.star.text.TextDocument"
122 #define XML_MODEL_SERVICE_CALC "com.sun.star.sheet.SpreadsheetDocument"
123 #define XML_MODEL_SERVICE_DRAW "com.sun.star.drawing.DrawingDocument"
124 #define XML_MODEL_SERVICE_IMPRESS "com.sun.star.presentation.PresentationDocument"
125 #define XML_MODEL_SERVICE_MATH "com.sun.star.formula.FormulaProperties"
126 #define XML_MODEL_SERVICE_CHART "com.sun.star.chart.ChartDocument"
127
128 #define XML_USEPRETTYPRINTING "UsePrettyPrinting"
129
130 #define C2U(cChar) OUString( RTL_CONSTASCII_USTRINGPARAM(cChar) )
131
132 struct XMLServiceMapEntry_Impl
133 {
134 const sal_Char *sModelService;
135 sal_Int32 nModelServiceLen;
136 const sal_Char *sFilterService;
137 sal_Int32 nFilterServiceLen;
138 };
139
140 #define SERVICE_MAP_ENTRY( app ) \
141 { XML_MODEL_SERVICE_##app, sizeof(XML_MODEL_SERVICE_##app)-1, \
142 XML_EXPORT_FILTER_##app, sizeof(XML_EXPORT_FILTER_##app)-1 }
143
144 const XMLServiceMapEntry_Impl aServiceMap[] =
145 {
146 SERVICE_MAP_ENTRY( WRITER ),
147 SERVICE_MAP_ENTRY( CALC ),
148 SERVICE_MAP_ENTRY( IMPRESS ),// Impress supports DrawingDocument, too, so
149 SERVICE_MAP_ENTRY( DRAW ), // it must appear before Draw
150 SERVICE_MAP_ENTRY( MATH ),
151 SERVICE_MAP_ENTRY( CHART ),
152 { 0, 0, 0, 0 }
153 };
154
155 //==============================================================================
156
157 class SAL_DLLPRIVATE SettingsExportFacade : public ::xmloff::XMLSettingsExportContext
158 {
159 public:
SettingsExportFacade(SvXMLExport & i_rExport)160 SettingsExportFacade( SvXMLExport& i_rExport )
161 :m_rExport( i_rExport )
162 {
163 }
164
~SettingsExportFacade()165 virtual ~SettingsExportFacade()
166 {
167 }
168
169 virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName,
170 const ::rtl::OUString& i_rValue );
171 virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName,
172 enum ::xmloff::token::XMLTokenEnum i_eValue );
173
174 virtual void StartElement( enum ::xmloff::token::XMLTokenEnum i_eName,
175 const sal_Bool i_bIgnoreWhitespace );
176 virtual void EndElement( const sal_Bool i_bIgnoreWhitespace );
177
178 virtual void Characters( const ::rtl::OUString& i_rCharacters );
179
180 virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
181 GetServiceFactory() const;
182 private:
183 SvXMLExport& m_rExport;
184 ::std::stack< ::rtl::OUString > m_aElements;
185 };
186
AddAttribute(enum::xmloff::token::XMLTokenEnum i_eName,const::rtl::OUString & i_rValue)187 void SettingsExportFacade::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, const ::rtl::OUString& i_rValue )
188 {
189 m_rExport.AddAttribute( XML_NAMESPACE_CONFIG, i_eName, i_rValue );
190 }
191
AddAttribute(enum::xmloff::token::XMLTokenEnum i_eName,enum::xmloff::token::XMLTokenEnum i_eValue)192 void SettingsExportFacade::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, enum ::xmloff::token::XMLTokenEnum i_eValue )
193 {
194 m_rExport.AddAttribute( XML_NAMESPACE_CONFIG, i_eName, i_eValue );
195 }
196
StartElement(enum::xmloff::token::XMLTokenEnum i_eName,const sal_Bool i_bIgnoreWhitespace)197 void SettingsExportFacade::StartElement( enum ::xmloff::token::XMLTokenEnum i_eName, const sal_Bool i_bIgnoreWhitespace )
198 {
199 const ::rtl::OUString sElementName( m_rExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_CONFIG, GetXMLToken( i_eName ) ) );
200 m_rExport.StartElement( sElementName, i_bIgnoreWhitespace );
201 m_aElements.push( sElementName );
202 }
203
EndElement(const sal_Bool i_bIgnoreWhitespace)204 void SettingsExportFacade::EndElement( const sal_Bool i_bIgnoreWhitespace )
205 {
206 const ::rtl::OUString sElementName( m_aElements.top() );
207 m_rExport.EndElement( sElementName, i_bIgnoreWhitespace );
208 m_aElements.pop();
209 }
210
Characters(const::rtl::OUString & i_rCharacters)211 void SettingsExportFacade::Characters( const ::rtl::OUString& i_rCharacters )
212 {
213 m_rExport.GetDocHandler()->characters( i_rCharacters );
214 }
215
GetServiceFactory() const216 Reference< XMultiServiceFactory > SettingsExportFacade::GetServiceFactory() const
217 {
218 return m_rExport.getServiceFactory();
219 }
220
221 //==============================================================================
222
223 class SvXMLExportEventListener : public cppu::WeakImplHelper1<
224 com::sun::star::lang::XEventListener >
225 {
226 private:
227 SvXMLExport* pExport;
228
229 public:
230 SvXMLExportEventListener(SvXMLExport* pExport);
231 virtual ~SvXMLExportEventListener();
232
233 // XEventListener
234 virtual void SAL_CALL disposing(const lang::EventObject& rEventObject) throw(::com::sun::star::uno::RuntimeException);
235 };
236
SvXMLExportEventListener(SvXMLExport * pTempExport)237 SvXMLExportEventListener::SvXMLExportEventListener(SvXMLExport* pTempExport)
238 : pExport(pTempExport)
239 {
240 }
241
~SvXMLExportEventListener()242 SvXMLExportEventListener::~SvXMLExportEventListener()
243 {
244 }
245
246 // XEventListener
disposing(const lang::EventObject &)247 void SAL_CALL SvXMLExportEventListener::disposing( const lang::EventObject& )
248 throw(uno::RuntimeException)
249 {
250 if (pExport)
251 {
252 pExport->DisposingModel();
253 pExport = NULL;
254 }
255 }
256
257 //==============================================================================
258
259 class SvXMLExport_Impl
260 {
261 public:
262 SvXMLExport_Impl();
263
264 ::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper;
265 uno::Reference< uri::XUriReferenceFactory > mxUriReferenceFactory;
266 rtl::OUString msPackageURI;
267 rtl::OUString msPackageURIScheme;
268 // --> OD 2006-09-27 #i69627#
269 sal_Bool mbOutlineStyleAsNormalListStyle;
270 // <--
271 // --> PB 2007-07-06 #i146851#
272 sal_Bool mbSaveBackwardCompatibleODF;
273 // <--
274
275 uno::Reference< embed::XStorage > mxTargetStorage;
276
277 SvtSaveOptions maSaveOptions;
278
279 /// relative path of stream in package, e.g. "someobject/content.xml"
280 ::rtl::OUString mStreamPath;
281
282 const uno::Reference< uno::XComponentContext > mxComponentContext;
283
284 /// name of stream in package, e.g., "content.xml"
285 ::rtl::OUString mStreamName;
286
287 /// stack of backed up namespace maps
288 /// long: depth at which namespace map has been backed up into the stack
289 ::std::stack< ::std::pair< SvXMLNamespaceMap *, long > > mNamespaceMaps;
290 /// counts depth (number of open elements/start tags)
291 long mDepth;
292
293 ::std::auto_ptr< ::xmloff::RDFaExportHelper> mpRDFaHelper;
294
295 // --> OD 2008-11-26 #158694#
296 sal_Bool mbExportTextNumberElement;
297 // <--
298 sal_Bool mbNullDateInitialized;
299
SetSchemeOf(const::rtl::OUString & rOrigFileName)300 void SetSchemeOf( const ::rtl::OUString& rOrigFileName )
301 {
302 sal_Int32 nSep = rOrigFileName.indexOf(':');
303 if( nSep != -1 )
304 msPackageURIScheme = rOrigFileName.copy( 0, nSep );
305 }
306 };
307
SvXMLExport_Impl()308 SvXMLExport_Impl::SvXMLExport_Impl()
309 // --> OD 2006-09-27 #i69627#
310 : mbOutlineStyleAsNormalListStyle( false )
311 // <--
312 // --> PB 2007-07-06 #i146851#
313 ,mbSaveBackwardCompatibleODF( sal_True )
314 // <--
315 ,mxComponentContext( ::comphelper::getProcessComponentContext() )
316 ,mStreamName()
317 ,mNamespaceMaps()
318 ,mDepth(0)
319 ,mpRDFaHelper() // lazy
320 // --> OD 2008-11-26 #158694#
321 ,mbExportTextNumberElement( sal_False )
322 // <--
323 ,mbNullDateInitialized( sal_False )
324 {
325 OSL_ENSURE(mxComponentContext.is(), "SvXMLExport: no ComponentContext");
326 if (!mxComponentContext.is()) throw uno::RuntimeException();
327 mxUriReferenceFactory = uri::UriReferenceFactory::create(
328 mxComponentContext );
329 }
330
331 //==============================================================================
332
SetDocHandler(const uno::Reference<xml::sax::XDocumentHandler> & rHandler)333 void SvXMLExport::SetDocHandler( const uno::Reference< xml::sax::XDocumentHandler > &rHandler )
334 {
335 mxHandler = rHandler;
336 mxExtHandler = uno::Reference<xml::sax::XExtendedDocumentHandler>( mxHandler, UNO_QUERY );
337 }
338
_InitCtor()339 void SvXMLExport::_InitCtor()
340 {
341 // note: it is not necessary to add XML_NP_XML (it is declared implicitly)
342 if( (getExportFlags() & ~EXPORT_OASIS) != 0 )
343 {
344 mpNamespaceMap->Add( GetXMLToken(XML_NP_OFFICE), GetXMLToken(XML_N_OFFICE), XML_NAMESPACE_OFFICE );
345 mpNamespaceMap->Add( GetXMLToken(XML_NP_OOO), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
346 }
347 if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS) ) != 0 )
348 {
349 mpNamespaceMap->Add( GetXMLToken(XML_NP_FO), GetXMLToken(XML_N_FO_COMPAT), XML_NAMESPACE_FO );
350 }
351 if( (getExportFlags() & (EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS) ) != 0 )
352 {
353 mpNamespaceMap->Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
354 }
355 if( (getExportFlags() & EXPORT_SETTINGS) != 0 )
356 {
357 mpNamespaceMap->Add( GetXMLToken(XML_NP_CONFIG), GetXMLToken(XML_N_CONFIG), XML_NAMESPACE_CONFIG );
358 }
359
360 if( (getExportFlags() & (EXPORT_META|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
361 {
362 mpNamespaceMap->Add( GetXMLToken(XML_NP_DC), GetXMLToken(XML_N_DC), XML_NAMESPACE_DC );
363 mpNamespaceMap->Add( GetXMLToken(XML_NP_META), GetXMLToken(XML_N_META), XML_NAMESPACE_META );
364 }
365 if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_FONTDECLS) ) != 0 )
366 {
367 mpNamespaceMap->Add( GetXMLToken(XML_NP_STYLE), GetXMLToken(XML_N_STYLE), XML_NAMESPACE_STYLE );
368 }
369
370 // namespaces for documents
371 if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
372 {
373 mpNamespaceMap->Add( GetXMLToken(XML_NP_DC), GetXMLToken(XML_N_DC), XML_NAMESPACE_DC );
374 mpNamespaceMap->Add( GetXMLToken(XML_NP_TEXT), GetXMLToken(XML_N_TEXT), XML_NAMESPACE_TEXT );
375 mpNamespaceMap->Add( GetXMLToken(XML_NP_DRAW), GetXMLToken(XML_N_DRAW), XML_NAMESPACE_DRAW );
376 mpNamespaceMap->Add( GetXMLToken(XML_NP_DR3D), GetXMLToken(XML_N_DR3D), XML_NAMESPACE_DR3D );
377 mpNamespaceMap->Add( GetXMLToken(XML_NP_SVG), GetXMLToken(XML_N_SVG_COMPAT), XML_NAMESPACE_SVG );
378 mpNamespaceMap->Add( GetXMLToken(XML_NP_CHART), GetXMLToken(XML_N_CHART), XML_NAMESPACE_CHART );
379 mpNamespaceMap->Add( GetXMLToken(XML_NP_RPT), GetXMLToken(XML_N_RPT), XML_NAMESPACE_REPORT );
380 mpNamespaceMap->Add( GetXMLToken(XML_NP_TABLE), GetXMLToken(XML_N_TABLE), XML_NAMESPACE_TABLE );
381 mpNamespaceMap->Add( GetXMLToken(XML_NP_NUMBER),GetXMLToken(XML_N_NUMBER), XML_NAMESPACE_NUMBER );
382 mpNamespaceMap->Add( GetXMLToken(XML_NP_OOOW), GetXMLToken(XML_N_OOOW), XML_NAMESPACE_OOOW );
383 mpNamespaceMap->Add( GetXMLToken(XML_NP_OOOC), GetXMLToken(XML_N_OOOC), XML_NAMESPACE_OOOC );
384 mpNamespaceMap->Add( GetXMLToken(XML_NP_OF), GetXMLToken(XML_N_OF), XML_NAMESPACE_OF );
385
386 if (getDefaultVersion() > SvtSaveOptions::ODFVER_012)
387 {
388 mpNamespaceMap->Add(
389 GetXMLToken(XML_NP_TABLE_EXT), GetXMLToken(XML_N_TABLE_EXT), XML_NAMESPACE_TABLE_EXT);
390 }
391 }
392 if( (getExportFlags() & (EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
393 {
394 mpNamespaceMap->Add( GetXMLToken(XML_NP_MATH), GetXMLToken(XML_N_MATH), XML_NAMESPACE_MATH );
395 mpNamespaceMap->Add( GetXMLToken(XML_NP_FORM), GetXMLToken(XML_N_FORM), XML_NAMESPACE_FORM );
396 }
397 if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS) ) != 0 )
398 {
399 mpNamespaceMap->Add( GetXMLToken(XML_NP_SCRIPT), GetXMLToken(XML_N_SCRIPT), XML_NAMESPACE_SCRIPT );
400 mpNamespaceMap->Add( GetXMLToken(XML_NP_DOM), GetXMLToken(XML_N_DOM), XML_NAMESPACE_DOM );
401 }
402 if( (getExportFlags() & EXPORT_CONTENT ) != 0 )
403 {
404 mpNamespaceMap->Add( GetXMLToken(XML_NP_XFORMS_1_0), GetXMLToken(XML_N_XFORMS_1_0), XML_NAMESPACE_XFORMS );
405 mpNamespaceMap->Add( GetXMLToken(XML_NP_XSD), GetXMLToken(XML_N_XSD), XML_NAMESPACE_XSD );
406 mpNamespaceMap->Add( GetXMLToken(XML_NP_XSI), GetXMLToken(XML_N_XSI), XML_NAMESPACE_XSI );
407 mpNamespaceMap->Add( GetXMLToken(XML_NP_FIELD), GetXMLToken(XML_N_FIELD), XML_NAMESPACE_FIELD );
408 }
409 // RDFa: needed for content and header/footer styles
410 if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
411 {
412 mpNamespaceMap->Add( GetXMLToken(XML_NP_XHTML),
413 GetXMLToken(XML_N_XHTML), XML_NAMESPACE_XHTML );
414 }
415 // GRDDL: to convert RDFa and meta.xml to RDF
416 if( (getExportFlags() & (EXPORT_META|EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
417 {
418 mpNamespaceMap->Add( GetXMLToken(XML_NP_GRDDL),
419 GetXMLToken(XML_N_GRDDL), XML_NAMESPACE_GRDDL );
420 }
421
422 mxAttrList = (xml::sax::XAttributeList*)mpAttrList;
423
424 msPicturesPath = OUString( RTL_CONSTASCII_USTRINGPARAM( "#Pictures/" ) );
425 msObjectsPath = OUString( RTL_CONSTASCII_USTRINGPARAM( "#./" ) );
426 msGraphicObjectProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:" ) );
427 msEmbeddedObjectProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ) );
428
429 if (mxModel.is() && !mxEventListener.is())
430 {
431 mxEventListener.set( new SvXMLExportEventListener(this));
432 mxModel->addEventListener(mxEventListener);
433 }
434
435 // --> OD 2006-03-10 #i51726# - determine model type
436 _DetermineModelType();
437 // <--
438
439 mbEnableExperimentalOdfExport = getenv("ENABLE_EXPERIMENTAL_ODF_EXPORT") != NULL;
440
441 // --> PB 2007-07-06 #146851# - load mbSaveBackwardCompatibleODF from configuration
442
443 // cl: but only if we do export to current oasis format, old openoffice format *must* always be compatible
444 if( (getExportFlags() & EXPORT_OASIS) != 0 )
445 {
446 sal_Bool bTemp = sal_True;
447 if ( ::comphelper::ConfigurationHelper::readDirectKey(
448 getServiceFactory(),
449 C2U("org.openoffice.Office.Common/"), C2U("Save/Document"), C2U("SaveBackwardCompatibleODF"),
450 ::comphelper::ConfigurationHelper::E_READONLY ) >>= bTemp )
451 {
452 mpImpl->mbSaveBackwardCompatibleODF = bTemp;
453 }
454 }
455 // <--
456 }
457
458 // --> OD 2006-03-14 #i51726#
_DetermineModelType()459 void SvXMLExport::_DetermineModelType()
460 {
461 meModelType = SvtModuleOptions::E_UNKNOWN_FACTORY;
462
463 if ( mxModel.is() )
464 {
465 meModelType = SvtModuleOptions::ClassifyFactoryByModel( mxModel );
466 }
467 }
468 // <--
469
470 // #110680#
SvXMLExport(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & xServiceFactory,MapUnit eDfltUnit,const enum XMLTokenEnum eClass,sal_uInt16 nExportFlags)471 SvXMLExport::SvXMLExport(
472 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
473 MapUnit eDfltUnit, const enum XMLTokenEnum eClass, sal_uInt16 nExportFlags )
474 : mpImpl( new SvXMLExport_Impl ),
475 // #110680#
476 mxServiceFactory(xServiceFactory),
477 mpAttrList( new SvXMLAttributeList ),
478 mpNamespaceMap( new SvXMLNamespaceMap ),
479 // #110680#
480 mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, eDfltUnit, getServiceFactory() ) ),
481 mpNumExport(0L),
482 mpProgressBarHelper( NULL ),
483 mpEventExport( NULL ),
484 mpImageMapExport( NULL ),
485 mpXMLErrors( NULL ),
486 mbExtended( sal_False ),
487 meClass( eClass ),
488 mnExportFlags( nExportFlags ),
489 mnErrorFlags( ERROR_NO ),
490 msWS( GetXMLToken(XML_WS) ),
491 mbSaveLinkedSections(sal_True)
492 {
493 DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
494 _InitCtor();
495 }
496
497 // #110680#
SvXMLExport(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & xServiceFactory,const OUString & rFileName,const uno::Reference<xml::sax::XDocumentHandler> & rHandler,MapUnit eDfltUnit)498 SvXMLExport::SvXMLExport(
499 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
500 const OUString &rFileName,
501 const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
502 MapUnit eDfltUnit )
503 : mpImpl( new SvXMLExport_Impl ),
504 // #110680#
505 mxServiceFactory(xServiceFactory),
506 mxHandler( rHandler ),
507 mxExtHandler( rHandler, uno::UNO_QUERY ),
508 mpAttrList( new SvXMLAttributeList ),
509 msOrigFileName( rFileName ),
510 mpNamespaceMap( new SvXMLNamespaceMap ),
511 // #110680#
512 mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, eDfltUnit, getServiceFactory() ) ),
513 mpNumExport(0L),
514 mpProgressBarHelper( NULL ),
515 mpEventExport( NULL ),
516 mpImageMapExport( NULL ),
517 mpXMLErrors( NULL ),
518 mbExtended( sal_False ),
519 meClass( XML_TOKEN_INVALID ),
520 mnExportFlags( 0 ),
521 mnErrorFlags( ERROR_NO ),
522 msWS( GetXMLToken(XML_WS) ),
523 mbSaveLinkedSections(sal_True)
524 {
525 mpImpl->SetSchemeOf( msOrigFileName );
526 DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
527 _InitCtor();
528
529 if (mxNumberFormatsSupplier.is())
530 mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
531 }
532
533 // #110680#
SvXMLExport(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & xServiceFactory,const OUString & rFileName,const uno::Reference<xml::sax::XDocumentHandler> & rHandler,const Reference<XModel> & rModel,sal_Int16 eDfltUnit)534 SvXMLExport::SvXMLExport(
535 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
536 const OUString &rFileName,
537 const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
538 const Reference< XModel >& rModel,
539 sal_Int16 eDfltUnit )
540 : mpImpl( new SvXMLExport_Impl ),
541 // #110680#
542 mxServiceFactory(xServiceFactory),
543 mxModel( rModel ),
544 mxHandler( rHandler ),
545 mxExtHandler( rHandler, uno::UNO_QUERY ),
546 mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
547 mpAttrList( new SvXMLAttributeList ),
548 msOrigFileName( rFileName ),
549 mpNamespaceMap( new SvXMLNamespaceMap ),
550 // #110680#
551 // pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, SvXMLUnitConverter::GetMapUnit(eDfltUnit) ) ),
552 mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, SvXMLUnitConverter::GetMapUnit(eDfltUnit), getServiceFactory() ) ),
553 mpNumExport(0L),
554 mpProgressBarHelper( NULL ),
555 mpEventExport( NULL ),
556 mpImageMapExport( NULL ),
557 mpXMLErrors( NULL ),
558 mbExtended( sal_False ),
559 meClass( XML_TOKEN_INVALID ),
560 mnExportFlags( 0 ),
561 mnErrorFlags( ERROR_NO ),
562 msWS( GetXMLToken(XML_WS) ),
563 mbSaveLinkedSections(sal_True)
564 {
565 mpImpl->SetSchemeOf( msOrigFileName );
566 DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
567 _InitCtor();
568
569 if (mxNumberFormatsSupplier.is())
570 mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
571 }
572
573 // #110680#
SvXMLExport(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & xServiceFactory,const OUString & rFileName,const uno::Reference<xml::sax::XDocumentHandler> & rHandler,const Reference<XModel> & rModel,const Reference<document::XGraphicObjectResolver> & rEmbeddedGraphicObjects,sal_Int16 eDfltUnit)574 SvXMLExport::SvXMLExport(
575 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
576 const OUString &rFileName,
577 const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
578 const Reference< XModel >& rModel,
579 const Reference< document::XGraphicObjectResolver >& rEmbeddedGraphicObjects,
580 sal_Int16 eDfltUnit )
581 : mpImpl( new SvXMLExport_Impl ),
582 // #110680#
583 mxServiceFactory(xServiceFactory),
584 mxModel( rModel ),
585 mxHandler( rHandler ),
586 mxExtHandler( rHandler, uno::UNO_QUERY ),
587 mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
588 mxGraphicResolver( rEmbeddedGraphicObjects ),
589 mpAttrList( new SvXMLAttributeList ),
590 msOrigFileName( rFileName ),
591 mpNamespaceMap( new SvXMLNamespaceMap ),
592 // #110680#
593 mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, SvXMLUnitConverter::GetMapUnit(eDfltUnit), getServiceFactory() ) ),
594 mpNumExport(0L),
595 mpProgressBarHelper( NULL ),
596 mpEventExport( NULL ),
597 mpImageMapExport( NULL ),
598 mpXMLErrors( NULL ),
599 mbExtended( sal_False ),
600 meClass( XML_TOKEN_INVALID ),
601 mnExportFlags( 0 ),
602 mnErrorFlags( ERROR_NO ),
603 msWS( GetXMLToken(XML_WS) ),
604 mbSaveLinkedSections(sal_True)
605 {
606 mpImpl->SetSchemeOf( msOrigFileName );
607 DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
608 _InitCtor();
609
610 if (mxNumberFormatsSupplier.is())
611 mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
612 }
613
~SvXMLExport()614 SvXMLExport::~SvXMLExport()
615 {
616 delete mpXMLErrors;
617 delete mpImageMapExport;
618 delete mpEventExport;
619 delete mpNamespaceMap;
620 delete mpUnitConv;
621 if (mpProgressBarHelper || mpNumExport)
622 {
623 if (mxExportInfo.is())
624 {
625 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
626 if (xPropertySetInfo.is())
627 {
628 if (mpProgressBarHelper)
629 {
630 OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSMAX));
631 OUString sProgressCurrent(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSCURRENT));
632 OUString sRepeat(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSREPEAT));
633 if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
634 xPropertySetInfo->hasPropertyByName(sProgressCurrent))
635 {
636 sal_Int32 nProgressMax(mpProgressBarHelper->GetReference());
637 sal_Int32 nProgressCurrent(mpProgressBarHelper->GetValue());
638 uno::Any aAny;
639 aAny <<= nProgressMax;
640 mxExportInfo->setPropertyValue(sProgressMax, aAny);
641 aAny <<= nProgressCurrent;
642 mxExportInfo->setPropertyValue(sProgressCurrent, aAny);
643 }
644 if (xPropertySetInfo->hasPropertyByName(sRepeat))
645 mxExportInfo->setPropertyValue(sRepeat, cppu::bool2any(mpProgressBarHelper->GetRepeat()));
646 }
647 if (mpNumExport && (mnExportFlags & (EXPORT_AUTOSTYLES | EXPORT_STYLES)))
648 {
649 OUString sWrittenNumberFormats(RTL_CONSTASCII_USTRINGPARAM(XML_WRITTENNUMBERSTYLES));
650 if (xPropertySetInfo->hasPropertyByName(sWrittenNumberFormats))
651 {
652 uno::Sequence<sal_Int32> aWasUsed;
653 mpNumExport->GetWasUsed(aWasUsed);
654 uno::Any aAny;
655 aAny <<= aWasUsed;
656 mxExportInfo->setPropertyValue(sWrittenNumberFormats, aAny);
657 }
658 }
659 }
660 }
661 delete mpProgressBarHelper;
662 delete mpNumExport;
663 }
664
665 xmloff::token::ResetTokens();
666
667 if (mxEventListener.is() && mxModel.is())
668 mxModel->removeEventListener(mxEventListener);
669
670 delete mpImpl;
671 }
672
673 ///////////////////////////////////////////////////////////////////////
674
675 // XExporter
setSourceDocument(const uno::Reference<lang::XComponent> & xDoc)676 void SAL_CALL SvXMLExport::setSourceDocument( const uno::Reference< lang::XComponent >& xDoc )
677 throw(lang::IllegalArgumentException, uno::RuntimeException)
678 {
679 mxModel = uno::Reference< frame::XModel >::query( xDoc );
680 if( !mxModel.is() )
681 throw lang::IllegalArgumentException();
682 if (mxModel.is() && ! mxEventListener.is())
683 {
684 mxEventListener.set( new SvXMLExportEventListener(this));
685 mxModel->addEventListener(mxEventListener);
686 }
687
688 if(!mxNumberFormatsSupplier.is() )
689 {
690 mxNumberFormatsSupplier = mxNumberFormatsSupplier.query( mxModel );
691 if(mxNumberFormatsSupplier.is() && mxHandler.is())
692 mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
693 }
694 if (mxExportInfo.is())
695 {
696 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
697 if (xPropertySetInfo.is())
698 {
699 OUString sUsePrettyPrinting(RTL_CONSTASCII_USTRINGPARAM(XML_USEPRETTYPRINTING));
700 if (xPropertySetInfo->hasPropertyByName(sUsePrettyPrinting))
701 {
702 uno::Any aAny = mxExportInfo->getPropertyValue(sUsePrettyPrinting);
703 if (::cppu::any2bool(aAny))
704 mnExportFlags |= EXPORT_PRETTY;
705 else
706 mnExportFlags &= ~EXPORT_PRETTY;
707 }
708
709 if (mpNumExport && (mnExportFlags & (EXPORT_AUTOSTYLES | EXPORT_STYLES)))
710 {
711 OUString sWrittenNumberFormats(RTL_CONSTASCII_USTRINGPARAM(XML_WRITTENNUMBERSTYLES));
712 if (xPropertySetInfo->hasPropertyByName(sWrittenNumberFormats))
713 {
714 uno::Any aAny = mxExportInfo->getPropertyValue(sWrittenNumberFormats);
715 uno::Sequence<sal_Int32> aWasUsed;
716 if(aAny >>= aWasUsed)
717 mpNumExport->SetWasUsed(aWasUsed);
718 }
719 }
720 }
721 }
722
723 // --> PB 2007-07-06 #i146851#
724 if ( mpImpl->mbSaveBackwardCompatibleODF )
725 mnExportFlags |= EXPORT_SAVEBACKWARDCOMPATIBLE;
726 else
727 mnExportFlags &= ~EXPORT_SAVEBACKWARDCOMPATIBLE;
728 // <--
729
730 // namespaces for user defined attributes
731 Reference< XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
732 if( xFactory.is() )
733 {
734 try
735 {
736 Reference < XInterface > xIfc =
737 xFactory->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM(
738 "com.sun.star.xml.NamespaceMap")) );
739 if( xIfc.is() )
740 {
741 Reference< XNameAccess > xNamespaceMap( xIfc, UNO_QUERY );
742 if( xNamespaceMap.is() )
743 {
744 Sequence< OUString > aPrefixes( xNamespaceMap->getElementNames() );
745
746 OUString* pPrefix = aPrefixes.getArray();
747 const sal_Int32 nCount = aPrefixes.getLength();
748 sal_Int32 nIndex;
749 OUString aURL;
750
751 for( nIndex = 0; nIndex < nCount; ++nIndex, ++pPrefix )
752 {
753 if( xNamespaceMap->getByName( *pPrefix ) >>= aURL )
754 _GetNamespaceMap().Add( *pPrefix, aURL, XML_NAMESPACE_UNKNOWN );
755 }
756 }
757 }
758 }
759 catch( com::sun::star::uno::Exception& )
760 {
761 }
762 }
763
764 // --> OD 2006-03-10 #i51726# - determine model type
765 _DetermineModelType();
766 // <--
767 }
768
769 // XInitialize
initialize(const uno::Sequence<uno::Any> & aArguments)770 void SAL_CALL SvXMLExport::initialize( const uno::Sequence< uno::Any >& aArguments )
771 throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
772 {
773 // #93186# we need to queryInterface every single Any with any expected outcome. This variable hold the queryInterface results.
774
775 const sal_Int32 nAnyCount = aArguments.getLength();
776 const uno::Any* pAny = aArguments.getConstArray();
777
778 for( sal_Int32 nIndex = 0; nIndex < nAnyCount; nIndex++, pAny++ )
779 {
780 Reference<XInterface> xValue;
781 *pAny >>= xValue;
782
783 // status indicator
784 uno::Reference<task::XStatusIndicator> xTmpStatus( xValue, UNO_QUERY );
785 if ( xTmpStatus.is() )
786 mxStatusIndicator = xTmpStatus;
787
788 // graphic resolver
789 uno::Reference<document::XGraphicObjectResolver> xTmpGraphic(
790 xValue, UNO_QUERY );
791 if ( xTmpGraphic.is() )
792 mxGraphicResolver = xTmpGraphic;
793
794 // object resolver
795 uno::Reference<document::XEmbeddedObjectResolver> xTmpObjectResolver(
796 xValue, UNO_QUERY );
797 if ( xTmpObjectResolver.is() )
798 mxEmbeddedResolver = xTmpObjectResolver;
799
800 // document handler
801 uno::Reference<xml::sax::XDocumentHandler> xTmpDocHandler(
802 xValue, UNO_QUERY );
803 if( xTmpDocHandler.is() )
804 {
805 mxHandler = xTmpDocHandler;
806 *pAny >>= mxExtHandler;
807
808 if (mxNumberFormatsSupplier.is() && mpNumExport == NULL)
809 mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
810 }
811
812 // property set to transport data across
813 uno::Reference<beans::XPropertySet> xTmpPropertySet(
814 xValue, UNO_QUERY );
815 if( xTmpPropertySet.is() )
816 mxExportInfo = xTmpPropertySet;
817 }
818
819 if( mxExportInfo.is() )
820 {
821 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo =
822 mxExportInfo->getPropertySetInfo();
823 OUString sPropName(
824 RTL_CONSTASCII_USTRINGPARAM("BaseURI" ) );
825 if( xPropertySetInfo->hasPropertyByName(sPropName) )
826 {
827 uno::Any aAny = mxExportInfo->getPropertyValue(sPropName);
828 aAny >>= msOrigFileName;
829 mpImpl->msPackageURI = msOrigFileName;
830 mpImpl->SetSchemeOf( msOrigFileName );
831 }
832 OUString sRelPath;
833 sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamRelPath" ) );
834 if( xPropertySetInfo->hasPropertyByName(sPropName) )
835 {
836 uno::Any aAny = mxExportInfo->getPropertyValue(sPropName);
837 aAny >>= sRelPath;
838 }
839 OUString sName;
840 sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamName" ) );
841 if( xPropertySetInfo->hasPropertyByName(sPropName) )
842 {
843 uno::Any aAny = mxExportInfo->getPropertyValue(sPropName);
844 aAny >>= sName;
845 }
846 if( msOrigFileName.getLength() && sName.getLength() )
847 {
848 INetURLObject aBaseURL( msOrigFileName );
849 if( sRelPath.getLength() )
850 aBaseURL.insertName( sRelPath );
851 aBaseURL.insertName( sName );
852 msOrigFileName = aBaseURL.GetMainURL(INetURLObject::DECODE_TO_IURI);
853 }
854 mpImpl->mStreamName = sName; // Note: may be empty (XSLT)
855
856 // --> OD 2006-09-26 #i69627#
857 const ::rtl::OUString sOutlineStyleAsNormalListStyle(
858 RTL_CONSTASCII_USTRINGPARAM("OutlineStyleAsNormalListStyle") );
859 if( xPropertySetInfo->hasPropertyByName( sOutlineStyleAsNormalListStyle ) )
860 {
861 uno::Any aAny = mxExportInfo->getPropertyValue( sOutlineStyleAsNormalListStyle );
862 aAny >>= (mpImpl->mbOutlineStyleAsNormalListStyle);
863 }
864 // <--
865
866 OUString sTargetStorage( RTL_CONSTASCII_USTRINGPARAM("TargetStorage") );
867 if( xPropertySetInfo->hasPropertyByName( sTargetStorage ) )
868 mxExportInfo->getPropertyValue( sTargetStorage ) >>= mpImpl->mxTargetStorage;
869
870 // --> OD 2008-11-26 #158694#
871 const ::rtl::OUString sExportTextNumberElement(
872 RTL_CONSTASCII_USTRINGPARAM("ExportTextNumberElement") );
873 if( xPropertySetInfo->hasPropertyByName( sExportTextNumberElement ) )
874 {
875 uno::Any aAny = mxExportInfo->getPropertyValue( sExportTextNumberElement );
876 aAny >>= (mpImpl->mbExportTextNumberElement);
877 }
878 // <--
879 }
880
881 }
882
883 // XFilter
filter(const uno::Sequence<beans::PropertyValue> & aDescriptor)884 sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor ) throw(uno::RuntimeException)
885 {
886 RTL_LOGFILE_CONTEXT_AUTHOR( aLogContext, "xmloff", LOGFILE_AUTHOR,
887 "SvXMLExport::filter" );
888
889 // check for xHandler first... should have been supplied in initialize
890 if( !mxHandler.is() )
891 return sal_False;
892
893 try
894 {
895 const sal_uInt32 nTest =
896 EXPORT_META|EXPORT_STYLES|EXPORT_CONTENT|EXPORT_SETTINGS;
897 if( (mnExportFlags & nTest) == nTest && !msOrigFileName.getLength() )
898 {
899 // evaluate descriptor only for flat files and if a base URI
900 // has not been provided already
901 const sal_Int32 nPropCount = aDescriptor.getLength();
902 const beans::PropertyValue* pProps = aDescriptor.getConstArray();
903
904 for( sal_Int32 nIndex = 0; nIndex < nPropCount; nIndex++, pProps++ )
905 {
906 const OUString& rPropName = pProps->Name;
907 const Any& rValue = pProps->Value;
908
909 if( rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FileName" ) ) )
910 {
911 if( !(rValue >>= msOrigFileName ) )
912 return sal_False;
913 }
914 else if (rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FilterName" ) ) )
915 {
916 if( !(rValue >>= msFilterName ) )
917 return sal_False;
918 }
919 }
920 }
921
922 #ifdef TIMELOG
923 if (GetModel().is())
924 {
925 // print a trace message with the URL
926 ByteString aUrl( (String) GetModel()->getURL(),
927 RTL_TEXTENCODING_ASCII_US );
928 RTL_LOGFILE_CONTEXT_TRACE1( aLogContext, "%s", aUrl.GetBuffer() );
929
930 // we also want a trace message with the document class
931 ByteString aClass( (String)GetXMLToken(meClass),
932 RTL_TEXTENCODING_ASCII_US );
933 RTL_LOGFILE_CONTEXT_TRACE1( aLogContext, "class=\"%s\"",
934 aClass.GetBuffer() );
935 }
936 #endif
937
938 exportDoc( meClass );
939 }
940 catch( uno::Exception e )
941 {
942 // We must catch exceptions, because according to the
943 // API definition export must not throw one!
944 Sequence<OUString> aSeq(0);
945 SetError( XMLERROR_FLAG_ERROR | XMLERROR_FLAG_SEVERE | XMLERROR_API,
946 aSeq, e.Message, NULL );
947 }
948
949 // return true only if no error occured
950 return (GetErrorFlags() & (ERROR_DO_NOTHING|ERROR_ERROR_OCCURED)) == 0;
951 }
952
cancel()953 void SAL_CALL SvXMLExport::cancel() throw(uno::RuntimeException)
954 {
955 // stop export
956 Sequence<OUString> aEmptySeq;
957 SetError(XMLERROR_CANCEL|XMLERROR_FLAG_SEVERE, aEmptySeq);
958 }
959
getName()960 ::rtl::OUString SAL_CALL SvXMLExport::getName( )
961 throw (::com::sun::star::uno::RuntimeException)
962 {
963 return msFilterName;
964 }
965
setName(const::rtl::OUString &)966 void SAL_CALL SvXMLExport::setName( const ::rtl::OUString& )
967 throw (::com::sun::star::uno::RuntimeException)
968 {
969 // do nothing, because it is not possible to set the FilterName
970 }
971
972
973 // XServiceInfo
getImplementationName()974 OUString SAL_CALL SvXMLExport::getImplementationName( ) throw(uno::RuntimeException)
975 {
976 OUString aStr;
977 return aStr;
978 }
979
supportsService(const OUString & rServiceName)980 sal_Bool SAL_CALL SvXMLExport::supportsService( const OUString& rServiceName ) throw(uno::RuntimeException)
981 {
982 return
983 rServiceName.equalsAsciiL(
984 "com.sun.star.document.ExportFilter",
985 sizeof("com.sun.star.document.ExportFilter")-1 ) ||
986 rServiceName.equalsAsciiL(
987 "com.sun.star.xml.XMLExportFilter",
988 sizeof("com.sun.star.xml.XMLExportFilter")-1);
989 }
990
getSupportedServiceNames()991 uno::Sequence< OUString > SAL_CALL SvXMLExport::getSupportedServiceNames( )
992 throw(uno::RuntimeException)
993 {
994 uno::Sequence<OUString> aSeq(2);
995 aSeq[0] = OUString(
996 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportFilter"));
997 aSeq[1] = OUString(
998 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLExportFilter"));
999 return aSeq;
1000 }
1001
1002 ///////////////////////////////////////////////////////////////////////
1003
1004 ::rtl::OUString
EnsureNamespace(::rtl::OUString const & i_rNamespace,::rtl::OUString const & i_rPreferredPrefix)1005 SvXMLExport::EnsureNamespace(::rtl::OUString const & i_rNamespace,
1006 ::rtl::OUString const & i_rPreferredPrefix)
1007 {
1008 ::rtl::OUString sPrefix;
1009 sal_uInt16 nKey( _GetNamespaceMap().GetKeyByName( i_rNamespace ) );
1010 if( XML_NAMESPACE_UNKNOWN == nKey )
1011 {
1012 // There is no prefix for the namespace, so
1013 // we have to generate one and have to add it.
1014 sPrefix = i_rPreferredPrefix;
1015 nKey = _GetNamespaceMap().GetKeyByPrefix( sPrefix );
1016 sal_Int32 n( 0 );
1017 ::rtl::OUStringBuffer buf;
1018 while( nKey != USHRT_MAX )
1019 {
1020 buf.append( i_rPreferredPrefix );
1021 buf.append( ++n );
1022 sPrefix = buf.makeStringAndClear();
1023 nKey = _GetNamespaceMap().GetKeyByPrefix( sPrefix );
1024 }
1025
1026 if (mpImpl->mNamespaceMaps.empty()
1027 || (mpImpl->mNamespaceMaps.top().second != mpImpl->mDepth))
1028 {
1029 // top was created for lower depth... need a new namespace map!
1030 mpImpl->mNamespaceMaps.push(
1031 ::std::make_pair(mpNamespaceMap, mpImpl->mDepth) );
1032 mpNamespaceMap = new SvXMLNamespaceMap( *mpNamespaceMap );
1033 }
1034
1035 // add the namespace to the map and as attribute
1036 mpNamespaceMap->Add( sPrefix, i_rNamespace );
1037 buf.append( GetXMLToken(XML_XMLNS) );
1038 buf.append( sal_Unicode(':') );
1039 buf.append( sPrefix );
1040 AddAttribute( buf.makeStringAndClear(), i_rNamespace );
1041 }
1042 else
1043 {
1044 // If there is a prefix for the namespace, reuse that.
1045 sPrefix = _GetNamespaceMap().GetPrefixByKey( nKey );
1046 }
1047 return sPrefix;
1048 }
1049
1050 ///////////////////////////////////////////////////////////////////////
1051
AddAttributeASCII(sal_uInt16 nPrefixKey,const sal_Char * pName,const sal_Char * pValue)1052 void SvXMLExport::AddAttributeASCII( sal_uInt16 nPrefixKey,
1053 const sal_Char *pName,
1054 const sal_Char *pValue )
1055 {
1056 OUString sName( OUString::createFromAscii( pName ) );
1057 OUString sValue( OUString::createFromAscii( pValue ) );
1058
1059 mpAttrList->AddAttribute(
1060 _GetNamespaceMap().GetQNameByKey( nPrefixKey, sName ), sValue );
1061 }
1062
AddAttribute(sal_uInt16 nPrefixKey,const sal_Char * pName,const OUString & rValue)1063 void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const sal_Char *pName,
1064 const OUString& rValue )
1065 {
1066 OUString sName( OUString::createFromAscii( pName ) );
1067
1068 mpAttrList->AddAttribute(
1069 _GetNamespaceMap().GetQNameByKey( nPrefixKey, sName ), rValue );
1070 }
1071
AddAttribute(sal_uInt16 nPrefixKey,const OUString & rName,const OUString & rValue)1072 void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const OUString& rName,
1073 const OUString& rValue )
1074 {
1075 mpAttrList->AddAttribute(
1076 _GetNamespaceMap().GetQNameByKey( nPrefixKey, rName ), rValue );
1077 }
1078
AddAttribute(sal_uInt16 nPrefixKey,enum XMLTokenEnum eName,const OUString & rValue)1079 void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
1080 enum XMLTokenEnum eName,
1081 const OUString& rValue )
1082 {
1083 mpAttrList->AddAttribute(
1084 _GetNamespaceMap().GetQNameByKey( nPrefixKey, GetXMLToken(eName) ),
1085 rValue );
1086 }
1087
AddAttribute(sal_uInt16 nPrefixKey,enum XMLTokenEnum eName,enum XMLTokenEnum eValue)1088 void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
1089 enum XMLTokenEnum eName,
1090 enum XMLTokenEnum eValue)
1091 {
1092 mpAttrList->AddAttribute(
1093 _GetNamespaceMap().GetQNameByKey( nPrefixKey, GetXMLToken(eName) ),
1094 GetXMLToken(eValue) );
1095 }
1096
AddAttribute(const::rtl::OUString & rQName,const::rtl::OUString & rValue)1097 void SvXMLExport::AddAttribute( const ::rtl::OUString& rQName,
1098 const ::rtl::OUString& rValue )
1099 {
1100 mpAttrList->AddAttribute(
1101 rQName,
1102 rValue );
1103 }
1104
AddAttribute(const::rtl::OUString & rQName,enum::xmloff::token::XMLTokenEnum eValue)1105 void SvXMLExport::AddAttribute( const ::rtl::OUString& rQName,
1106 enum ::xmloff::token::XMLTokenEnum eValue )
1107 {
1108 mpAttrList->AddAttribute(
1109 rQName,
1110 GetXMLToken(eValue) );
1111 }
1112
AddAttributeList(const uno::Reference<xml::sax::XAttributeList> & xAttrList)1113 void SvXMLExport::AddAttributeList( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
1114 {
1115 if( xAttrList.is())
1116 mpAttrList->AppendAttributeList( xAttrList );
1117 }
1118
ClearAttrList()1119 void SvXMLExport::ClearAttrList()
1120 {
1121 mpAttrList->Clear();
1122 }
1123
1124 #ifdef DBG_UTIL
CheckAttrList()1125 void SvXMLExport::CheckAttrList()
1126 {
1127 DBG_ASSERT( !mpAttrList->getLength(),
1128 "XMLExport::CheckAttrList: list is not empty" );
1129 }
1130 #endif
1131
ImplExportMeta()1132 void SvXMLExport::ImplExportMeta()
1133 {
1134 CheckAttrList();
1135
1136 _ExportMeta();
1137 }
1138
ImplExportSettings()1139 void SvXMLExport::ImplExportSettings()
1140 {
1141 CheckAttrList();
1142
1143 ::std::list< SettingsGroup > aSettings;
1144 sal_Int32 nSettingsCount = 0;
1145
1146 // view settings
1147 uno::Sequence< beans::PropertyValue > aViewSettings;
1148 GetViewSettingsAndViews( aViewSettings );
1149 aSettings.push_back( SettingsGroup( XML_VIEW_SETTINGS, aViewSettings ) );
1150 nSettingsCount += aViewSettings.getLength();
1151
1152 // configuration settings
1153 uno::Sequence<beans::PropertyValue> aConfigSettings;
1154 GetConfigurationSettings( aConfigSettings );
1155 aSettings.push_back( SettingsGroup( XML_CONFIGURATION_SETTINGS, aConfigSettings ) );
1156 nSettingsCount += aConfigSettings.getLength();
1157
1158 // any document specific settings
1159 nSettingsCount += GetDocumentSpecificSettings( aSettings );
1160
1161 {
1162 SvXMLElementExport aElem( *this,
1163 nSettingsCount != 0,
1164 XML_NAMESPACE_OFFICE, XML_SETTINGS,
1165 sal_True, sal_True );
1166
1167 SettingsExportFacade aSettingsExportContext( *this );
1168 XMLSettingsExportHelper aSettingsExportHelper( aSettingsExportContext );
1169
1170 for ( ::std::list< SettingsGroup >::const_iterator settings = aSettings.begin();
1171 settings != aSettings.end();
1172 ++settings
1173 )
1174 {
1175 if ( !settings->aSettings.getLength() )
1176 continue;
1177
1178 OUString sSettingsName( GetXMLToken( settings->eGroupName ) );
1179 OUString sQName = GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OOO, sSettingsName );
1180 aSettingsExportHelper.exportAllSettings( settings->aSettings, sQName );
1181 }
1182 }
1183 }
1184
ImplExportStyles(sal_Bool)1185 void SvXMLExport::ImplExportStyles( sal_Bool )
1186 {
1187 CheckAttrList();
1188
1189 // AddAttribute( XML_NAMESPACE_NONE, XML_ID, XML_STYLES_ID );
1190 {
1191 // <style:styles>
1192 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_STYLES,
1193 sal_True, sal_True );
1194
1195 _ExportStyles( sal_False );
1196 }
1197
1198 // transfer style names (+ families) TO other components (if appropriate)
1199 if( ( ( mnExportFlags & EXPORT_CONTENT ) == 0 ) && mxExportInfo.is() )
1200 {
1201 static OUString sStyleNames( RTL_CONSTASCII_USTRINGPARAM("StyleNames") );
1202 static OUString sStyleFamilies( RTL_CONSTASCII_USTRINGPARAM("StyleFamilies") );
1203 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
1204 if ( xPropertySetInfo->hasPropertyByName( sStyleNames ) && xPropertySetInfo->hasPropertyByName( sStyleFamilies ) )
1205 {
1206 Sequence<sal_Int32> aStyleFamilies;
1207 Sequence<OUString> aStyleNames;
1208 mxAutoStylePool->GetRegisteredNames( aStyleFamilies, aStyleNames );
1209 mxExportInfo->setPropertyValue( sStyleNames, makeAny( aStyleNames ) );
1210 mxExportInfo->setPropertyValue( sStyleFamilies,
1211 makeAny( aStyleFamilies ) );
1212 }
1213 }
1214 }
1215
ImplExportAutoStyles(sal_Bool)1216 void SvXMLExport::ImplExportAutoStyles( sal_Bool )
1217 {
1218 // transfer style names (+ families) FROM other components (if appropriate)
1219 OUString sStyleNames( RTL_CONSTASCII_USTRINGPARAM("StyleNames") );
1220 OUString sStyleFamilies( RTL_CONSTASCII_USTRINGPARAM("StyleFamilies") );
1221 if( ( ( mnExportFlags & EXPORT_STYLES ) == 0 )
1222 && mxExportInfo.is()
1223 && mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleNames )
1224 && mxExportInfo->getPropertySetInfo()->hasPropertyByName( sStyleFamilies ) )
1225 {
1226 Sequence<sal_Int32> aStyleFamilies;
1227 mxExportInfo->getPropertyValue( sStyleFamilies ) >>= aStyleFamilies;
1228 Sequence<OUString> aStyleNames;
1229 mxExportInfo->getPropertyValue( sStyleNames ) >>= aStyleNames;
1230 mxAutoStylePool->RegisterNames( aStyleFamilies, aStyleNames );
1231 }
1232
1233 // AddAttributeASCII( XML_NAMESPACE_NONE, XML_ID, XML_AUTO_STYLES_ID );
1234 {
1235 // <style:automatic-styles>
1236 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE,
1237 XML_AUTOMATIC_STYLES, sal_True, sal_True );
1238
1239 #if 0
1240 AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1241 AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, XML_STYLES_HREF );
1242 AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1243 AddAttribute( XML_NAMESPACE_XLINK, XML_ROLE,
1244 pNamespaceMap->GetQNameByKey( XML_NAMESPACE_OFFICE,
1245 GetXMLToken(XML_STYLESHEET)) );
1246 {
1247 // <style:use-styles>
1248 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE,
1249 XML_USE_STYLES, sal_True, sal_True );
1250 }
1251 #endif
1252 _ExportAutoStyles();
1253 }
1254 }
1255
ImplExportMasterStyles(sal_Bool)1256 void SvXMLExport::ImplExportMasterStyles( sal_Bool )
1257 {
1258 {
1259 // <style:master-styles>
1260 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_MASTER_STYLES,
1261 sal_True, sal_True );
1262
1263 _ExportMasterStyles();
1264 }
1265
1266 #if 0
1267 AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1268 AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, XML_AUTO_STYLES_HREF );
1269 AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1270 AddAttribute( XML_NAMESPACE_XLINK, XML_ROLE,
1271 pNamespaceMap->GetQNameByKey( XML_NAMESPACE_OFFICE,
1272 GetXMLToken(XML_STYLESHEET) ) );
1273 {
1274 // <style:use-styles>
1275 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE,
1276 XML_USE_STYLES, sal_True, sal_True );
1277 }
1278 #endif
1279 }
1280
ImplExportContent()1281 void SvXMLExport::ImplExportContent()
1282 {
1283 CheckAttrList();
1284
1285 CheckAttrList();
1286
1287 {
1288 SvXMLElementExport aElemrnt( *this, XML_NAMESPACE_OFFICE, XML_BODY,
1289 sal_True, sal_True );
1290 {
1291 XMLTokenEnum eClass = meClass;
1292 if( XML_TEXT_GLOBAL == eClass )
1293 {
1294 AddAttribute( XML_NAMESPACE_TEXT, XML_GLOBAL,
1295 GetXMLToken( XML_TRUE ) );
1296 eClass = XML_TEXT;
1297 }
1298 // <office:body ...>
1299 SetBodyAttributes();
1300 SvXMLElementExport aElem( *this, meClass != XML_TOKEN_INVALID,
1301 XML_NAMESPACE_OFFICE, eClass,
1302 sal_True, sal_True );
1303
1304 _ExportContent();
1305 }
1306 }
1307 }
1308
SetBodyAttributes()1309 void SvXMLExport::SetBodyAttributes()
1310 {
1311 }
1312
1313 static void
lcl_AddGrddl(SvXMLExport & rExport,const sal_Int32)1314 lcl_AddGrddl(SvXMLExport & rExport, const sal_Int32 /*nExportMode*/)
1315 {
1316 // check version >= 1.2
1317 switch (rExport.getDefaultVersion()) {
1318 case SvtSaveOptions::ODFVER_011: // fall thru
1319 case SvtSaveOptions::ODFVER_010: return;
1320 default: break;
1321 }
1322
1323 // #i115030#: disabled
1324 #if 0
1325 if (EXPORT_SETTINGS != nExportMode) // meta, content, styles
1326 {
1327 rExport.AddAttribute( XML_NAMESPACE_GRDDL, XML_TRANSFORMATION,
1328 OUString::createFromAscii(s_grddl_xsl) );
1329 }
1330 #endif
1331 }
1332
exportDoc(enum::xmloff::token::XMLTokenEnum eClass)1333 sal_uInt32 SvXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass )
1334 {
1335 bool bOwnGraphicResolver = false;
1336 bool bOwnEmbeddedResolver = false;
1337
1338 if( !mxGraphicResolver.is() || !mxEmbeddedResolver.is() )
1339 {
1340 Reference< XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
1341 if( xFactory.is() )
1342 {
1343 try
1344 {
1345 if( !mxGraphicResolver.is() )
1346 {
1347 mxGraphicResolver = Reference< XGraphicObjectResolver >::query(
1348 xFactory->createInstance(
1349 OUString(RTL_CONSTASCII_USTRINGPARAM(
1350 "com.sun.star.document.ExportGraphicObjectResolver"))));
1351 bOwnGraphicResolver = mxGraphicResolver.is();
1352 }
1353
1354 if( !mxEmbeddedResolver.is() )
1355 {
1356 mxEmbeddedResolver = Reference< XEmbeddedObjectResolver >::query(
1357 xFactory->createInstance(
1358 OUString(RTL_CONSTASCII_USTRINGPARAM(
1359 "com.sun.star.document.ExportEmbeddedObjectResolver"))));
1360 bOwnEmbeddedResolver = mxEmbeddedResolver.is();
1361 }
1362 }
1363 catch( com::sun::star::uno::Exception& )
1364 {
1365 }
1366 }
1367 }
1368 if( (getExportFlags() & EXPORT_OASIS) == 0 )
1369 {
1370 Reference< lang::XMultiServiceFactory > xFactory = getServiceFactory();
1371 if( xFactory.is() )
1372 {
1373 try
1374 {
1375 ::comphelper::PropertyMapEntry aInfoMap[] =
1376 {
1377 { "Class", sizeof("Class")-1, 0,
1378 &::getCppuType((::rtl::OUString*)0),
1379 PropertyAttribute::MAYBEVOID, 0},
1380 { NULL, 0, 0, NULL, 0, 0 }
1381 };
1382 Reference< XPropertySet > xConvPropSet(
1383 ::comphelper::GenericPropertySet_CreateInstance(
1384 new ::comphelper::PropertySetInfo( aInfoMap ) ) );
1385
1386 Any aAny;
1387 aAny <<= GetXMLToken( eClass );
1388 xConvPropSet->setPropertyValue(
1389 OUString(RTL_CONSTASCII_USTRINGPARAM("Class")), aAny );
1390
1391 Reference< XPropertySet > xPropSet =
1392 mxExportInfo.is()
1393 ? PropertySetMerger_CreateInstance( mxExportInfo,
1394 xConvPropSet )
1395 : xConvPropSet;
1396
1397 Sequence<Any> aArgs( 3 );
1398 aArgs[0] <<= mxHandler;
1399 aArgs[1] <<= xPropSet;
1400 aArgs[2] <<= mxModel;
1401
1402 // get filter component
1403 Reference< xml::sax::XDocumentHandler > xTmpDocHandler(
1404 xFactory->createInstanceWithArguments(
1405 OUString::createFromAscii("com.sun.star.comp.Oasis2OOoTransformer"),
1406 aArgs), UNO_QUERY);
1407 OSL_ENSURE( xTmpDocHandler.is(),
1408 "can't instantiate OASIS transformer component" );
1409 if( xTmpDocHandler.is() )
1410 {
1411 mxHandler = xTmpDocHandler;
1412 mxExtHandler = uno::Reference<xml::sax::XExtendedDocumentHandler>( mxHandler, UNO_QUERY );
1413 }
1414 }
1415 catch( com::sun::star::uno::Exception& )
1416 {
1417 }
1418 }
1419 }
1420
1421
1422 mxHandler->startDocument();
1423
1424 // <?xml version="1.0" encoding="UTF-8"?>
1425 // xHandler->processingInstruction( S2U( sXML_xml ), S2U( sXML_xml_pi ) );
1426
1427 // <office:document ...>
1428 CheckAttrList();
1429
1430 // namespace attributes
1431 // ( The namespace decls should be first attributes in the element;
1432 // some faulty XML parsers (JAXP1.1) have a problem with this,
1433 // also it's more elegant )
1434 sal_uInt16 nPos = mpNamespaceMap->GetFirstKey();
1435 while( USHRT_MAX != nPos )
1436 {
1437 mpAttrList->AddAttribute( mpNamespaceMap->GetAttrNameByKey( nPos ),
1438 mpNamespaceMap->GetNameByKey( nPos ) );
1439 nPos = mpNamespaceMap->GetNextKey( nPos );
1440 }
1441
1442
1443
1444 // office:version = ...
1445 if( !mbExtended )
1446 {
1447 const sal_Char* pVersion = 0;
1448 switch( getDefaultVersion() )
1449 {
1450 case SvtSaveOptions::ODFVER_LATEST: pVersion = sXML_1_2; break;
1451 case SvtSaveOptions::ODFVER_012: pVersion = sXML_1_2; break;
1452 case SvtSaveOptions::ODFVER_011: pVersion = sXML_1_1; break;
1453 case SvtSaveOptions::ODFVER_010: break;
1454
1455 default:
1456 DBG_ERROR("xmloff::SvXMLExport::exportDoc(), unexpected odf default version!");
1457 }
1458
1459 if( pVersion )
1460 AddAttribute( XML_NAMESPACE_OFFICE, XML_VERSION,
1461 OUString::createFromAscii(pVersion) );
1462 }
1463
1464 {
1465 enum XMLTokenEnum eRootService = XML_TOKEN_INVALID;
1466 const sal_Int32 nExportMode = mnExportFlags & (EXPORT_META|EXPORT_STYLES|EXPORT_CONTENT|EXPORT_SETTINGS);
1467
1468 lcl_AddGrddl(*this, nExportMode);
1469
1470 if( EXPORT_META == nExportMode )
1471 {
1472 // export only meta
1473 eRootService = XML_DOCUMENT_META;
1474 }
1475 else if ( EXPORT_SETTINGS == nExportMode )
1476 {
1477 // export only settings
1478 eRootService = XML_DOCUMENT_SETTINGS;
1479 }
1480 else if( EXPORT_STYLES == nExportMode )
1481 {
1482 // export only styles
1483 eRootService = XML_DOCUMENT_STYLES;
1484 }
1485 else if( EXPORT_CONTENT == nExportMode )
1486 {
1487 // export only content
1488 eRootService = XML_DOCUMENT_CONTENT;
1489 }
1490 else
1491 {
1492 // the god'ol one4all element
1493 eRootService = XML_DOCUMENT;
1494 // office:mimetype = ... (only for stream containing the content)
1495 if( eClass != XML_TOKEN_INVALID )
1496 {
1497 OUString aTmp( RTL_CONSTASCII_USTRINGPARAM("application/vnd.oasis.opendocument.") );
1498 aTmp += GetXMLToken( eClass );
1499 AddAttribute( XML_NAMESPACE_OFFICE, XML_MIMETYPE, aTmp );
1500 }
1501 }
1502
1503 // if( (getExportFlags() & EXPORT_NODOCTYPE) == 0 &&
1504 // xExtHandler.is() )
1505 // {
1506 // OUStringBuffer aDocType(
1507 // GetXMLToken(XML_XML_DOCTYPE_PREFIX).getLength() +
1508 // GetXMLToken(XML_XML_DOCTYPE_SUFFIX).getLength() + 30 );
1509 //
1510 // aDocType.append( GetXMLToken(XML_XML_DOCTYPE_PREFIX) );
1511 // aDocType.append( GetNamespaceMap().GetQNameByKey(
1512 // XML_NAMESPACE_OFFICE, GetXMLToken(eRootService) ) );
1513 // aDocType.append( GetXMLToken(XML_XML_DOCTYPE_SUFFIX) );
1514 // xExtHandler->unknown( aDocType.makeStringAndClear() );
1515 // }
1516
1517 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, eRootService, sal_True, sal_True );
1518
1519 // meta information
1520 if( mnExportFlags & EXPORT_META )
1521 ImplExportMeta();
1522
1523 // settings
1524 if( mnExportFlags & EXPORT_SETTINGS )
1525 ImplExportSettings();
1526
1527 // scripts
1528 if( mnExportFlags & EXPORT_SCRIPTS )
1529 _ExportScripts();
1530
1531 // font declerations
1532 if( mnExportFlags & EXPORT_FONTDECLS )
1533 _ExportFontDecls();
1534
1535 // styles
1536 if( mnExportFlags & EXPORT_STYLES )
1537 ImplExportStyles( sal_False );
1538
1539 // autostyles
1540 if( mnExportFlags & EXPORT_AUTOSTYLES )
1541 ImplExportAutoStyles( sal_False );
1542
1543 // masterstyles
1544 if( mnExportFlags & EXPORT_MASTERSTYLES )
1545 ImplExportMasterStyles( sal_False );
1546
1547 // contnt
1548 if( mnExportFlags & EXPORT_CONTENT )
1549 ImplExportContent();
1550 }
1551
1552
1553 mxHandler->endDocument();
1554
1555 if( bOwnGraphicResolver )
1556 {
1557 Reference< XComponent > xComp( mxGraphicResolver, UNO_QUERY );
1558 xComp->dispose();
1559 }
1560
1561 if( bOwnEmbeddedResolver )
1562 {
1563 Reference< XComponent > xComp( mxEmbeddedResolver, UNO_QUERY );
1564 xComp->dispose();
1565 }
1566
1567 return 0;
1568 }
1569
ResetNamespaceMap()1570 void SvXMLExport::ResetNamespaceMap()
1571 {
1572 delete mpNamespaceMap; mpNamespaceMap = new SvXMLNamespaceMap;
1573 }
1574
_ExportMeta()1575 void SvXMLExport::_ExportMeta()
1576 {
1577 OUString generator( ::utl::DocInfoHelper::GetGeneratorString() );
1578 Reference< XDocumentPropertiesSupplier > xDocPropsSupplier(mxModel,
1579 UNO_QUERY);
1580 if (xDocPropsSupplier.is()) {
1581 Reference<XDocumentProperties> xDocProps(
1582 xDocPropsSupplier->getDocumentProperties());
1583 if (!xDocProps.is()) throw;
1584 // update generator here
1585 xDocProps->setGenerator(generator);
1586 SvXMLMetaExport * pMeta = new SvXMLMetaExport(*this, xDocProps);
1587 uno::Reference<xml::sax::XDocumentHandler> xMeta(pMeta);
1588 pMeta->Export();
1589 } else {
1590 // office:meta
1591 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_META,
1592 sal_True, sal_True );
1593 {
1594 // BM: #i60323# export generator even if xInfoProp is empty (which is the
1595 // case for charts). The generator does not depend on xInfoProp
1596 SvXMLElementExport anElem( *this, XML_NAMESPACE_META, XML_GENERATOR,
1597 sal_True, sal_True );
1598 Characters(generator);
1599 }
1600 }
1601 }
1602
_ExportScripts()1603 void SvXMLExport::_ExportScripts()
1604 {
1605 SvXMLElementExport aElement( *this, XML_NAMESPACE_OFFICE, XML_SCRIPTS, sal_True, sal_True );
1606
1607 // export Basic macros (only for FlatXML)
1608 if ( mnExportFlags & EXPORT_EMBEDDED )
1609 {
1610 ::rtl::OUString aValue( GetNamespaceMap().GetPrefixByKey( XML_NAMESPACE_OOO ) );
1611 aValue += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":Basic" ) );
1612 AddAttribute( XML_NAMESPACE_SCRIPT, XML_LANGUAGE, aValue );
1613
1614 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_SCRIPT, sal_True, sal_True );
1615
1616 // initialize Basic
1617 if ( mxModel.is() )
1618 {
1619 Reference< beans::XPropertySet > xPSet( mxModel, UNO_QUERY );
1620 if ( xPSet.is() )
1621 xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) );
1622 }
1623
1624 Reference< document::XExporter > xExporter;
1625 Reference< lang::XMultiServiceFactory > xMSF( getServiceFactory() );
1626 if ( xMSF.is() )
1627 {
1628 Reference < XDocumentHandler > xHdl( new XMLBasicExportFilter( mxHandler ) );
1629 Sequence < Any > aArgs( 1 );
1630 aArgs[0] <<= xHdl;
1631 xExporter.set( xMSF->createInstanceWithArguments(
1632 OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.XMLOasisBasicExporter" ) ), aArgs ),
1633 UNO_QUERY );
1634 }
1635
1636 OSL_ENSURE( xExporter.is(),
1637 "SvXMLExport::_ExportScripts: can't instantiate export filter component for Basic macros" );
1638
1639 if ( xExporter.is() )
1640 {
1641 Reference< XComponent > xComp( mxModel, UNO_QUERY );
1642 xExporter->setSourceDocument( xComp );
1643 Reference< XFilter > xFilter( xExporter, UNO_QUERY );
1644 if ( xFilter.is() )
1645 {
1646 Sequence < PropertyValue > aMediaDesc( 0 );
1647 xFilter->filter( aMediaDesc );
1648 }
1649 }
1650 }
1651
1652 // export document events
1653 Reference< document::XEventsSupplier > xEvents( GetModel(), UNO_QUERY );
1654 GetEventExport().Export( xEvents, sal_True );
1655 }
1656
_ExportFontDecls()1657 void SvXMLExport::_ExportFontDecls()
1658 {
1659 if( mxFontAutoStylePool.is() )
1660 mxFontAutoStylePool->exportXML();
1661 }
1662
_ExportStyles(sal_Bool)1663 void SvXMLExport::_ExportStyles( sal_Bool )
1664 {
1665 uno::Reference< lang::XMultiServiceFactory > xFact( GetModel(), uno::UNO_QUERY );
1666 if( xFact.is())
1667 {
1668 // export (fill-)gradient-styles
1669 try
1670 {
1671 uno::Reference< container::XNameAccess > xGradient( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable") ) ), uno::UNO_QUERY );
1672 if( xGradient.is() )
1673 {
1674 XMLGradientStyleExport aGradientStyle( *this );
1675
1676 if( xGradient->hasElements() )
1677 {
1678 uno::Sequence< OUString > aNamesSeq ( xGradient->getElementNames() );
1679 sal_Int32 nCount = aNamesSeq.getLength();
1680 for( sal_Int32 i=0; i<nCount; i++ )
1681 {
1682 const OUString& rStrName = aNamesSeq[ i ];
1683
1684 try
1685 {
1686 uno::Any aValue = xGradient->getByName( rStrName );
1687
1688 aGradientStyle.exportXML( rStrName, aValue );
1689 }
1690 catch( container::NoSuchElementException& )
1691 {}
1692 }
1693 }
1694 }
1695 }
1696 catch( lang::ServiceNotRegisteredException& )
1697 {}
1698
1699 // export (fill-)hatch-styles
1700 try
1701 {
1702 uno::Reference< container::XNameAccess > xHatch( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable") ) ), uno::UNO_QUERY );
1703 if( xHatch.is() )
1704 {
1705 XMLHatchStyleExport aHatchStyle( *this );
1706
1707 if( xHatch->hasElements() )
1708 {
1709 uno::Sequence< OUString > aNamesSeq ( xHatch->getElementNames() );
1710 sal_Int32 nCount = aNamesSeq.getLength();
1711 for( sal_Int32 i=0; i<nCount; i++ )
1712 {
1713 const OUString& rStrName = aNamesSeq[ i ];
1714
1715 try
1716 {
1717 uno::Any aValue = xHatch->getByName( rStrName );
1718
1719 aHatchStyle.exportXML( rStrName, aValue );
1720 }
1721 catch( container::NoSuchElementException& )
1722 {}
1723 }
1724 }
1725 }
1726 }
1727 catch( lang::ServiceNotRegisteredException& )
1728 {}
1729
1730 // export (fill-)bitmap-styles
1731 try
1732 {
1733 uno::Reference< container::XNameAccess > xBitmap( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable") ) ), uno::UNO_QUERY );
1734 if( xBitmap.is() )
1735 {
1736 XMLImageStyle aImageStyle;
1737
1738 if( xBitmap->hasElements() )
1739 {
1740 uno::Sequence< OUString > aNamesSeq ( xBitmap->getElementNames() );
1741 sal_Int32 nCount = aNamesSeq.getLength();
1742 for( sal_Int32 i=0; i<nCount; i++ )
1743 {
1744 const OUString& rStrName = aNamesSeq[ i ];
1745
1746 try
1747 {
1748 uno::Any aValue = xBitmap->getByName( rStrName );
1749
1750 aImageStyle.exportXML( rStrName, aValue, *this );
1751 }
1752 catch( container::NoSuchElementException& )
1753 {}
1754 }
1755 }
1756 }
1757 }
1758 catch( lang::ServiceNotRegisteredException& )
1759 {}
1760
1761 // export transparency-gradient -styles
1762 try
1763 {
1764 uno::Reference< container::XNameAccess > xTransGradient( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) ), uno::UNO_QUERY );
1765 if( xTransGradient.is() )
1766 {
1767 XMLTransGradientStyleExport aTransGradientstyle( *this );
1768
1769 if( xTransGradient->hasElements() )
1770 {
1771 uno::Sequence< OUString > aNamesSeq ( xTransGradient->getElementNames() );
1772 sal_Int32 nCount = aNamesSeq.getLength();
1773 for( sal_Int32 i=0; i<nCount; i++ )
1774 {
1775 const OUString& rStrName = aNamesSeq[ i ];
1776
1777 try
1778 {
1779 uno::Any aValue = xTransGradient->getByName( rStrName );
1780
1781 aTransGradientstyle.exportXML( rStrName, aValue );
1782 }
1783 catch( container::NoSuchElementException& )
1784 {}
1785 }
1786 }
1787 }
1788 }
1789 catch( lang::ServiceNotRegisteredException& )
1790 {}
1791
1792 // export marker-styles
1793 try
1794 {
1795 uno::Reference< container::XNameAccess > xMarker( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable") ) ), uno::UNO_QUERY );
1796 if( xMarker.is() )
1797 {
1798 XMLMarkerStyleExport aMarkerStyle( *this );
1799
1800 if( xMarker->hasElements() )
1801 {
1802 uno::Sequence< OUString > aNamesSeq ( xMarker->getElementNames() );
1803 sal_Int32 nCount = aNamesSeq.getLength();
1804 for( sal_Int32 i=0; i<nCount; i++ )
1805 {
1806 const OUString& rStrName = aNamesSeq[ i ];
1807
1808 try
1809 {
1810 uno::Any aValue = xMarker->getByName( rStrName );
1811
1812 aMarkerStyle.exportXML( rStrName, aValue );
1813 }
1814 catch( container::NoSuchElementException& )
1815 {}
1816 }
1817 }
1818 }
1819 }
1820 catch( lang::ServiceNotRegisteredException& )
1821 {}
1822
1823 // export dash-styles
1824 try
1825 {
1826 uno::Reference< container::XNameAccess > xDashes( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable") ) ), uno::UNO_QUERY );
1827 if( xDashes.is() )
1828 {
1829 XMLDashStyleExport aDashStyle( *this );
1830
1831 if( xDashes->hasElements() )
1832 {
1833 uno::Sequence< OUString > aNamesSeq ( xDashes->getElementNames() );
1834 sal_Int32 nCount = aNamesSeq.getLength();
1835 for( sal_Int32 i=0; i<nCount; i++ )
1836 {
1837 const OUString& rStrName = aNamesSeq[ i ];
1838
1839 try
1840 {
1841 uno::Any aValue = xDashes->getByName( rStrName );
1842
1843 aDashStyle.exportXML( rStrName, aValue );
1844 }
1845 catch( container::NoSuchElementException& )
1846 {}
1847 }
1848 }
1849 }
1850 }
1851 catch( lang::ServiceNotRegisteredException& )
1852 {}
1853 }
1854 }
1855
CreateTextParagraphExport()1856 XMLTextParagraphExport* SvXMLExport::CreateTextParagraphExport()
1857 {
1858 return new XMLTextParagraphExport( *this, *(GetAutoStylePool().get()) );
1859 }
1860
CreateShapeExport()1861 XMLShapeExport* SvXMLExport::CreateShapeExport()
1862 {
1863 return new XMLShapeExport(*this);
1864 }
1865
CreateAutoStylePool()1866 SvXMLAutoStylePoolP* SvXMLExport::CreateAutoStylePool()
1867 {
1868 return new SvXMLAutoStylePoolP(*this);
1869 }
1870
CreatePageExport()1871 XMLPageExport* SvXMLExport::CreatePageExport()
1872 {
1873 return new XMLPageExport( *this );
1874 }
1875
CreateChartExport()1876 SchXMLExportHelper* SvXMLExport::CreateChartExport()
1877 {
1878 return new SchXMLExportHelper(*this,*GetAutoStylePool().get());
1879 }
1880
CreateFontAutoStylePool()1881 XMLFontAutoStylePool* SvXMLExport::CreateFontAutoStylePool()
1882 {
1883 return new XMLFontAutoStylePool( *this );
1884 }
1885
CreateFormExport()1886 xmloff::OFormLayerXMLExport* SvXMLExport::CreateFormExport()
1887 {
1888 return new xmloff::OFormLayerXMLExport(*this);
1889 }
1890
GetViewSettingsAndViews(uno::Sequence<beans::PropertyValue> & rProps)1891 void SvXMLExport::GetViewSettingsAndViews(uno::Sequence<beans::PropertyValue>& rProps)
1892 {
1893 GetViewSettings(rProps);
1894 uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetModel(), uno::UNO_QUERY);
1895 if(xViewDataSupplier.is())
1896 {
1897 uno::Reference<container::XIndexAccess> xIndexAccess;
1898 xViewDataSupplier->setViewData( xIndexAccess ); // make sure we get a newly created sequence
1899 xIndexAccess = xViewDataSupplier->getViewData();
1900 sal_Bool bAdd = sal_False;
1901 uno::Any aAny;
1902 if(xIndexAccess.is() && xIndexAccess->hasElements() )
1903 {
1904 sal_Int32 nCount = xIndexAccess->getCount();
1905 for (sal_Int32 i = 0; i < nCount; i++)
1906 {
1907 aAny = xIndexAccess->getByIndex(i);
1908 uno::Sequence<beans::PropertyValue> aProps;
1909 if( aAny >>= aProps )
1910 {
1911 if( aProps.getLength() > 0 )
1912 {
1913 bAdd = sal_True;
1914 break;
1915 }
1916 }
1917 }
1918 }
1919
1920 if( bAdd )
1921 {
1922 sal_Int32 nOldLength(rProps.getLength());
1923 rProps.realloc(nOldLength + 1);
1924 beans::PropertyValue aProp;
1925 aProp.Name = OUString(RTL_CONSTASCII_USTRINGPARAM("Views"));
1926 aProp.Value <<= xIndexAccess;
1927 rProps[nOldLength] = aProp;
1928 }
1929 }
1930 }
1931
GetViewSettings(uno::Sequence<beans::PropertyValue> &)1932 void SvXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>&)
1933 {
1934 }
1935
GetConfigurationSettings(uno::Sequence<beans::PropertyValue> &)1936 void SvXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>&)
1937 {
1938 }
1939
GetDocumentSpecificSettings(::std::list<SettingsGroup> & _out_rSettings)1940 sal_Int32 SvXMLExport::GetDocumentSpecificSettings( ::std::list< SettingsGroup >& _out_rSettings )
1941 {
1942 (void)_out_rSettings;
1943 return 0;
1944 }
1945
addDataStyle(const sal_Int32 nNumberFormat,sal_Bool)1946 void SvXMLExport::addDataStyle(const sal_Int32 nNumberFormat, sal_Bool /*bTimeFormat*/ )
1947 {
1948 if(mpNumExport)
1949 mpNumExport->SetUsed(nNumberFormat);
1950 }
1951
exportDataStyles()1952 void SvXMLExport::exportDataStyles()
1953 {
1954 if(mpNumExport)
1955 mpNumExport->Export(sal_False);
1956 }
1957
exportAutoDataStyles()1958 void SvXMLExport::exportAutoDataStyles()
1959 {
1960 if(mpNumExport)
1961 mpNumExport->Export(sal_True);
1962
1963 if (mxFormExport.is())
1964 mxFormExport->exportAutoControlNumberStyles();
1965 }
1966
getDataStyleName(const sal_Int32 nNumberFormat,sal_Bool) const1967 OUString SvXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, sal_Bool /*bTimeFormat*/ ) const
1968 {
1969 OUString sTemp;
1970 if(mpNumExport)
1971 sTemp = mpNumExport->GetStyleName(nNumberFormat);
1972 return sTemp;
1973 }
1974
exportAnnotationMeta(const uno::Reference<drawing::XShape> &)1975 void SvXMLExport::exportAnnotationMeta(const uno::Reference<drawing::XShape>&)
1976 {
1977 }
1978
dataStyleForceSystemLanguage(sal_Int32 nFormat) const1979 sal_Int32 SvXMLExport::dataStyleForceSystemLanguage(sal_Int32 nFormat) const
1980 {
1981 return ( mpNumExport != NULL )
1982 ? mpNumExport->ForceSystemLanguage( nFormat ) : nFormat;
1983 }
1984
1985
AddEmbeddedGraphicObject(const OUString & rGraphicObjectURL)1986 OUString SvXMLExport::AddEmbeddedGraphicObject( const OUString& rGraphicObjectURL )
1987 {
1988 OUString sRet( rGraphicObjectURL );
1989 if( 0 == rGraphicObjectURL.compareTo( msGraphicObjectProtocol,
1990 msGraphicObjectProtocol.getLength() ) &&
1991 mxGraphicResolver.is() )
1992 {
1993 if( (getExportFlags() & EXPORT_EMBEDDED) == 0 )
1994 sRet = mxGraphicResolver->resolveGraphicObjectURL( rGraphicObjectURL );
1995 else
1996 sRet = OUString();
1997 }
1998 else
1999 sRet = GetRelativeReference( sRet );
2000
2001 return sRet;
2002 }
2003
AddEmbeddedGraphicObjectAsBase64(const OUString & rGraphicObjectURL)2004 sal_Bool SvXMLExport::AddEmbeddedGraphicObjectAsBase64( const OUString& rGraphicObjectURL )
2005 {
2006 sal_Bool bRet = sal_False;
2007
2008 if( (getExportFlags() & EXPORT_EMBEDDED) != 0 &&
2009 0 == rGraphicObjectURL.compareTo( msGraphicObjectProtocol,
2010 msGraphicObjectProtocol.getLength() ) &&
2011 mxGraphicResolver.is() )
2012 {
2013 Reference< XBinaryStreamResolver > xStmResolver( mxGraphicResolver, UNO_QUERY );
2014
2015 if( xStmResolver.is() )
2016 {
2017 Reference< XInputStream > xIn( xStmResolver->getInputStream( rGraphicObjectURL ) );
2018
2019 if( xIn.is() )
2020 {
2021 XMLBase64Export aBase64Exp( *this );
2022 bRet = aBase64Exp.exportOfficeBinaryDataElement( xIn );
2023 }
2024 }
2025 }
2026
2027 return bRet;
2028 }
2029
AddEmbeddedObject(const OUString & rEmbeddedObjectURL)2030 OUString SvXMLExport::AddEmbeddedObject( const OUString& rEmbeddedObjectURL )
2031 {
2032 OUString sRet;
2033 if( (0 == rEmbeddedObjectURL.compareTo( msEmbeddedObjectProtocol,
2034 msEmbeddedObjectProtocol.getLength() ) ||
2035 0 == rEmbeddedObjectURL.compareTo( msGraphicObjectProtocol,
2036 msGraphicObjectProtocol.getLength() ) ) &&
2037 mxEmbeddedResolver.is() )
2038 {
2039 sRet =
2040 mxEmbeddedResolver->resolveEmbeddedObjectURL( rEmbeddedObjectURL );
2041 }
2042 else
2043 sRet = GetRelativeReference( rEmbeddedObjectURL );
2044
2045 return sRet;
2046 }
2047
AddEmbeddedObjectAsBase64(const OUString & rEmbeddedObjectURL)2048 sal_Bool SvXMLExport::AddEmbeddedObjectAsBase64( const OUString& rEmbeddedObjectURL )
2049 {
2050 sal_Bool bRet = sal_False;
2051 if( (0 == rEmbeddedObjectURL.compareTo( msEmbeddedObjectProtocol,
2052 msEmbeddedObjectProtocol.getLength() ) ||
2053 0 == rEmbeddedObjectURL.compareTo( msGraphicObjectProtocol,
2054 msGraphicObjectProtocol.getLength() ) ) &&
2055 mxEmbeddedResolver.is() )
2056 {
2057 Reference < XNameAccess > xNA( mxEmbeddedResolver, UNO_QUERY );
2058 if( xNA.is() )
2059 {
2060 Any aAny = xNA->getByName( rEmbeddedObjectURL );
2061 Reference < XInputStream > xIn;
2062 aAny >>= xIn;
2063 if( xIn.is() )
2064 {
2065 XMLBase64Export aBase64Exp( *this );
2066 bRet = aBase64Exp.exportOfficeBinaryDataElement( xIn );
2067 }
2068 }
2069 }
2070
2071 return bRet;
2072 }
2073
EncodeStyleName(const OUString & rName,sal_Bool * pEncoded) const2074 OUString SvXMLExport::EncodeStyleName(
2075 const OUString& rName,
2076 sal_Bool *pEncoded ) const
2077 {
2078 return GetMM100UnitConverter().encodeStyleName( rName, pEncoded );
2079 }
2080
GetProgressBarHelper()2081 ProgressBarHelper* SvXMLExport::GetProgressBarHelper()
2082 {
2083 if (!mpProgressBarHelper)
2084 {
2085 mpProgressBarHelper = new ProgressBarHelper(mxStatusIndicator, sal_True);
2086
2087 if (mxExportInfo.is())
2088 {
2089 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
2090 if (xPropertySetInfo.is())
2091 {
2092 OUString sProgressRange(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSRANGE));
2093 OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSMAX));
2094 OUString sProgressCurrent(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSCURRENT));
2095 OUString sRepeat(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSREPEAT));
2096 if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
2097 xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
2098 xPropertySetInfo->hasPropertyByName(sProgressRange))
2099 {
2100 uno::Any aAny;
2101 sal_Int32 nProgressMax(0);
2102 sal_Int32 nProgressCurrent(0);
2103 sal_Int32 nProgressRange(0);
2104 aAny = mxExportInfo->getPropertyValue(sProgressRange);
2105 if (aAny >>= nProgressRange)
2106 mpProgressBarHelper->SetRange(nProgressRange);
2107 aAny = mxExportInfo->getPropertyValue(sProgressMax);
2108 if (aAny >>= nProgressMax)
2109 mpProgressBarHelper->SetReference(nProgressMax);
2110 aAny = mxExportInfo->getPropertyValue(sProgressCurrent);
2111 if (aAny >>= nProgressCurrent)
2112 mpProgressBarHelper->SetValue(nProgressCurrent);
2113 }
2114 if (xPropertySetInfo->hasPropertyByName(sRepeat))
2115 {
2116 uno::Any aAny = mxExportInfo->getPropertyValue(sRepeat);
2117 if (aAny.getValueType() == getBooleanCppuType())
2118 mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
2119 else {
2120 DBG_ERRORFILE("why is it no boolean?");
2121 }
2122 }
2123 }
2124 }
2125 }
2126 return mpProgressBarHelper;
2127 }
2128
GetEventExport()2129 XMLEventExport& SvXMLExport::GetEventExport()
2130 {
2131 if( NULL == mpEventExport)
2132 {
2133 // create EventExport on demand
2134 mpEventExport = new XMLEventExport(*this, NULL);
2135
2136 // and register standard handlers + names
2137 OUString sStarBasic(RTL_CONSTASCII_USTRINGPARAM("StarBasic"));
2138 mpEventExport->AddHandler(sStarBasic, new XMLStarBasicExportHandler());
2139 OUString sScript(RTL_CONSTASCII_USTRINGPARAM("Script"));
2140 mpEventExport->AddHandler(sScript, new XMLScriptExportHandler());
2141 mpEventExport->AddTranslationTable(aStandardEventTable);
2142 }
2143
2144 return *mpEventExport;
2145 }
2146
GetImageMapExport()2147 XMLImageMapExport& SvXMLExport::GetImageMapExport()
2148 {
2149 // image map export, create on-demand
2150 if( NULL == mpImageMapExport )
2151 {
2152 mpImageMapExport = new XMLImageMapExport(*this);
2153 }
2154
2155 return *mpImageMapExport;
2156 }
2157
2158 // XUnoTunnel & co
getUnoTunnelId()2159 const uno::Sequence< sal_Int8 > & SvXMLExport::getUnoTunnelId() throw()
2160 {
2161 static uno::Sequence< sal_Int8 > * pSeq = 0;
2162 if( !pSeq )
2163 {
2164 Guard< Mutex > aGuard( Mutex::getGlobalMutex() );
2165 if( !pSeq )
2166 {
2167 static uno::Sequence< sal_Int8 > aSeq( 16 );
2168 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
2169 pSeq = &aSeq;
2170 }
2171 }
2172 return *pSeq;
2173 }
2174
getImplementation(uno::Reference<uno::XInterface> xInt)2175 SvXMLExport* SvXMLExport::getImplementation( uno::Reference< uno::XInterface > xInt ) throw()
2176 {
2177 uno::Reference< lang::XUnoTunnel > xUT( xInt, uno::UNO_QUERY );
2178 if( xUT.is() )
2179 {
2180 return
2181 reinterpret_cast<SvXMLExport*>(
2182 sal::static_int_cast<sal_IntPtr>(
2183 xUT->getSomething( SvXMLExport::getUnoTunnelId())));
2184 }
2185 else
2186 return NULL;
2187 }
2188
2189 // XUnoTunnel
getSomething(const uno::Sequence<sal_Int8> & rId)2190 sal_Int64 SAL_CALL SvXMLExport::getSomething( const uno::Sequence< sal_Int8 >& rId )
2191 throw( uno::RuntimeException )
2192 {
2193 if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
2194 rId.getConstArray(), 16 ) )
2195 {
2196 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
2197 }
2198 return 0;
2199 }
2200
ExportEmbeddedOwnObject(Reference<XComponent> & rComp)2201 sal_Bool SvXMLExport::ExportEmbeddedOwnObject( Reference< XComponent >& rComp )
2202 {
2203 OUString sFilterService;
2204 bool bIsChart = false;
2205
2206 Reference < lang::XServiceInfo > xServiceInfo( rComp, UNO_QUERY );
2207 if( xServiceInfo.is() )
2208 {
2209 const XMLServiceMapEntry_Impl *pEntry = aServiceMap;
2210 while( pEntry->sModelService )
2211 {
2212 OUString sModelService( pEntry->sModelService,
2213 pEntry->nModelServiceLen,
2214 RTL_TEXTENCODING_ASCII_US );
2215 if( xServiceInfo->supportsService( sModelService ) )
2216 {
2217 sFilterService = OUString( pEntry->sFilterService,
2218 pEntry->nFilterServiceLen,
2219 RTL_TEXTENCODING_ASCII_US );
2220 bIsChart = sModelService.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( XML_MODEL_SERVICE_CHART ));
2221 break;
2222 }
2223 pEntry++;
2224 }
2225 }
2226
2227 OSL_ENSURE( sFilterService.getLength(), "no export filter for own object" );
2228
2229 if( !sFilterService.getLength() )
2230 return sal_False;
2231
2232 Reference < XDocumentHandler > xHdl =
2233 new XMLEmbeddedObjectExportFilter( mxHandler );
2234
2235 Sequence < Any > aArgs( 1 );
2236 // #144135# the filters for embedded objects in flat format are always
2237 // instantiated as Oasis filters and transformed afterwards. Therefore, all
2238 // special handling that is done if the exportFlags do not contain
2239 // EXPORT_OASIS must be changed to properties being passed in the info
2240 // propertyset
2241
2242 if( ! (getExportFlags() & EXPORT_OASIS) &&
2243 bIsChart )
2244 {
2245 static ::comphelper::PropertyMapEntry aInfoMap[] =
2246 {
2247 { RTL_CONSTASCII_STRINGPARAM("ExportTableNumberList"), 0, &::getBooleanCppuType(), PropertyAttribute::MAYBEVOID, 0},
2248 { NULL, 0, 0, NULL, 0, 0 }
2249 };
2250 Reference< XPropertySet > xInfoProp(
2251 ::comphelper::GenericPropertySet_CreateInstance(
2252 new ::comphelper::PropertySetInfo( aInfoMap )));
2253
2254 if( bIsChart )
2255 xInfoProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("ExportTableNumberList")), makeAny( true ));
2256
2257 aArgs.realloc( 2 );
2258 aArgs[1] <<= xInfoProp;
2259 }
2260 aArgs[0] <<= xHdl;
2261
2262 // #110680#
2263 // Reference< lang::XMultiServiceFactory > xServiceFactory = comphelper::getProcessServiceFactory();
2264 Reference< lang::XMultiServiceFactory > xServiceFactory = getServiceFactory();
2265
2266 Reference< document::XExporter > xExporter(
2267 xServiceFactory->createInstanceWithArguments( sFilterService, aArgs),
2268 UNO_QUERY);
2269 OSL_ENSURE( xExporter.is(),
2270 "can't instantiate export filter component for own object" );
2271 if( !xExporter.is() )
2272 return sal_False;
2273
2274 xExporter->setSourceDocument( rComp );
2275
2276 Reference<XFilter> xFilter( xExporter, UNO_QUERY );
2277
2278 Sequence < PropertyValue > aMediaDesc( 0 );
2279 return xFilter->filter( aMediaDesc );
2280 }
2281
GetRelativeReference(const OUString & rValue)2282 OUString SvXMLExport::GetRelativeReference(const OUString& rValue)
2283 {
2284 OUString sValue( rValue );
2285 // #i65474# handling of fragment URLs ("#....") is undefined
2286 // they are stored 'as is'
2287 uno::Reference< uri::XUriReference > xUriRef;
2288 if(sValue.getLength() && sValue.getStr()[0] != '#')
2289 {
2290 try
2291 {
2292 xUriRef = mpImpl->mxUriReferenceFactory->parse( rValue );
2293 if( xUriRef.is() && !xUriRef->isAbsolute() )
2294 {
2295 //#i61943# relative URLs need special handling
2296 INetURLObject aTemp( mpImpl->msPackageURI );
2297 bool bWasAbsolute = false;
2298 sValue = aTemp.smartRel2Abs(sValue, bWasAbsolute ).GetMainURL(INetURLObject::DECODE_TO_IURI);
2299 }
2300 }
2301 catch( uno::Exception& )
2302 {
2303 }
2304 }
2305 OUString sRet = sValue;
2306 if( xUriRef.is() )//no conversion for empty values or for fragments
2307 {
2308 //conversion for matching schemes only
2309 if( xUriRef->getScheme() == mpImpl->msPackageURIScheme )
2310 {
2311 sValue = INetURLObject::GetRelURL( msOrigFileName, sValue,
2312 INetURLObject::WAS_ENCODED, INetURLObject::DECODE_TO_IURI, RTL_TEXTENCODING_UTF8, INetURLObject::FSYS_DETECT);
2313 }
2314 }
2315 return sValue;
2316 }
2317
StartElement(sal_uInt16 nPrefix,enum::xmloff::token::XMLTokenEnum eName,sal_Bool bIgnWSOutside)2318 void SvXMLExport::StartElement(sal_uInt16 nPrefix,
2319 enum ::xmloff::token::XMLTokenEnum eName,
2320 sal_Bool bIgnWSOutside )
2321 {
2322 StartElement(_GetNamespaceMap().GetQNameByKey( nPrefix,
2323 GetXMLToken(eName) ), bIgnWSOutside);
2324 }
2325
StartElement(const OUString & rName,sal_Bool bIgnWSOutside)2326 void SvXMLExport::StartElement(const OUString& rName,
2327 sal_Bool bIgnWSOutside )
2328 {
2329 if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING)
2330 {
2331 try
2332 {
2333 if( bIgnWSOutside && ((mnExportFlags & EXPORT_PRETTY) == EXPORT_PRETTY))
2334 mxHandler->ignorableWhitespace( msWS );
2335 mxHandler->startElement( rName, GetXAttrList() );
2336 }
2337 catch ( SAXInvalidCharacterException& e )
2338 {
2339 Sequence<OUString> aPars(1);
2340 aPars[0] = rName;
2341 SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, NULL );
2342 }
2343 catch ( SAXException& e )
2344 {
2345 Sequence<OUString> aPars(1);
2346 aPars[0] = rName;
2347 SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE,
2348 aPars, e.Message, NULL );
2349 }
2350 }
2351 ClearAttrList();
2352 ++mpImpl->mDepth; // increment nesting depth counter
2353 }
2354
Characters(const::rtl::OUString & rChars)2355 void SvXMLExport::Characters(const ::rtl::OUString& rChars)
2356 {
2357 if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING)
2358 {
2359 try
2360 {
2361 mxHandler->characters(rChars);
2362 }
2363 catch ( SAXInvalidCharacterException& e )
2364 {
2365 Sequence<OUString> aPars(1);
2366 aPars[0] = rChars;
2367 SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, NULL );
2368 }
2369 catch ( SAXException& e )
2370 {
2371 Sequence<OUString> aPars(1);
2372 aPars[0] = rChars;
2373 SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE,
2374 aPars, e.Message, NULL );
2375 }
2376 }
2377 }
2378
EndElement(sal_uInt16 nPrefix,enum::xmloff::token::XMLTokenEnum eName,sal_Bool bIgnWSInside)2379 void SvXMLExport::EndElement(sal_uInt16 nPrefix,
2380 enum ::xmloff::token::XMLTokenEnum eName,
2381 sal_Bool bIgnWSInside )
2382 {
2383 EndElement(_GetNamespaceMap().GetQNameByKey( nPrefix, GetXMLToken(eName) ),
2384 bIgnWSInside);
2385 }
2386
EndElement(const OUString & rName,sal_Bool bIgnWSInside)2387 void SvXMLExport::EndElement(const OUString& rName,
2388 sal_Bool bIgnWSInside )
2389 {
2390 // decrement nesting depth counter & (maybe) restore namespace map
2391 --mpImpl->mDepth;
2392 if (!mpImpl->mNamespaceMaps.empty() &&
2393 (mpImpl->mNamespaceMaps.top().second == mpImpl->mDepth))
2394 {
2395 delete mpNamespaceMap;
2396 mpNamespaceMap = mpImpl->mNamespaceMaps.top().first;
2397 mpImpl->mNamespaceMaps.pop();
2398 }
2399 OSL_ENSURE(mpImpl->mNamespaceMaps.empty() ||
2400 (mpImpl->mNamespaceMaps.top().second < mpImpl->mDepth),
2401 "SvXMLExport: NamespaceMaps corrupted");
2402
2403 if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING)
2404 {
2405 try
2406 {
2407 if( bIgnWSInside && ((mnExportFlags & EXPORT_PRETTY) == EXPORT_PRETTY))
2408 mxHandler->ignorableWhitespace( msWS );
2409 mxHandler->endElement( rName );
2410 }
2411 catch ( SAXException& e )
2412 {
2413 Sequence<OUString> aPars(1);
2414 aPars[0] = rName;
2415 SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE,
2416 aPars, e.Message, NULL );
2417 }
2418 }
2419 }
2420
IgnorableWhitespace()2421 void SvXMLExport::IgnorableWhitespace()
2422 {
2423 if ((mnExportFlags & EXPORT_PRETTY) != EXPORT_PRETTY)
2424 return;
2425
2426 if ((mnErrorFlags & ERROR_DO_NOTHING) != ERROR_DO_NOTHING)
2427 {
2428 try
2429 {
2430 mxHandler->ignorableWhitespace( msWS );
2431 }
2432 catch ( SAXException& e )
2433 {
2434 Sequence<OUString> aPars(0);
2435 SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE,
2436 aPars, e.Message, NULL );
2437 }
2438 }
2439 }
2440
2441
SetError(sal_Int32 nId,const Sequence<OUString> & rMsgParams,const OUString & rExceptionMessage,const Reference<XLocator> & rLocator)2442 void SvXMLExport::SetError(
2443 sal_Int32 nId,
2444 const Sequence<OUString>& rMsgParams,
2445 const OUString& rExceptionMessage,
2446 const Reference<XLocator>& rLocator )
2447 {
2448 // allow multi-threaded access to the cancel() method
2449 static ::vos::OMutex aMutex;
2450 ::vos::OGuard aGuard(aMutex);
2451
2452 // maintain error flags
2453 if ( ( nId & XMLERROR_FLAG_ERROR ) != 0 )
2454 mnErrorFlags |= ERROR_ERROR_OCCURED;
2455 if ( ( nId & XMLERROR_FLAG_WARNING ) != 0 )
2456 mnErrorFlags |= ERROR_WARNING_OCCURED;
2457 if ( ( nId & XMLERROR_FLAG_SEVERE ) != 0 )
2458 mnErrorFlags |= ERROR_DO_NOTHING;
2459
2460 // create error lsit on demand
2461 if ( mpXMLErrors == NULL )
2462 mpXMLErrors = new XMLErrors();
2463
2464 // save error information
2465 mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage, rLocator );
2466 }
2467
SetError(sal_Int32 nId,const Sequence<OUString> & rMsgParams)2468 void SvXMLExport::SetError(
2469 sal_Int32 nId,
2470 const Sequence<OUString>& rMsgParams)
2471 {
2472 OUString sEmpty;
2473 SetError( nId, rMsgParams, sEmpty, NULL );
2474 }
2475
2476
GetErrors()2477 XMLErrors* SvXMLExport::GetErrors()
2478 {
2479 return mpXMLErrors;
2480 }
2481
DisposingModel()2482 void SvXMLExport::DisposingModel()
2483 {
2484 mxModel.clear();
2485 // --> OD 2006-03-13 #i51726#
2486 meModelType = SvtModuleOptions::E_UNKNOWN_FACTORY;;
2487 // <--
2488 mxEventListener.clear();
2489 }
2490
2491 // #110680#
getServiceFactory()2492 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SvXMLExport::getServiceFactory()
2493 {
2494 // #110680#
2495 return mxServiceFactory;
2496 }
2497
2498 uno::Reference< uno::XComponentContext >
GetComponentContext() const2499 SvXMLExport::GetComponentContext() const
2500 {
2501 return mpImpl->mxComponentContext;
2502 }
2503
getInterfaceToIdentifierMapper()2504 ::comphelper::UnoInterfaceToUniqueIdentifierMapper& SvXMLExport::getInterfaceToIdentifierMapper()
2505 {
2506 return mpImpl->maInterfaceToIdentifierMapper;
2507 }
2508
2509 // --> OD 2006-09-27 #i69627#
writeOutlineStyleAsNormalListStyle() const2510 sal_Bool SvXMLExport::writeOutlineStyleAsNormalListStyle() const
2511 {
2512 return mpImpl->mbOutlineStyleAsNormalListStyle;
2513 }
2514 // <--
2515
GetTargetStorage()2516 uno::Reference< embed::XStorage > SvXMLExport::GetTargetStorage()
2517 {
2518 return mpImpl->mxTargetStorage;
2519 }
2520
2521 /// returns the currently configured default version for odf export
getDefaultVersion() const2522 SvtSaveOptions::ODFDefaultVersion SvXMLExport::getDefaultVersion() const
2523 {
2524 if( mpImpl )
2525 return mpImpl->maSaveOptions.GetODFDefaultVersion();
2526
2527 // fatal error, use current version as default
2528 return SvtSaveOptions::ODFVER_012;
2529 }
2530
GetStreamName() const2531 ::rtl::OUString SvXMLExport::GetStreamName() const
2532 {
2533 return mpImpl->mStreamName;
2534 }
2535
2536 void
AddAttributeIdLegacy(sal_uInt16 const nLegacyPrefix,::rtl::OUString const & rValue)2537 SvXMLExport::AddAttributeIdLegacy(
2538 sal_uInt16 const nLegacyPrefix, ::rtl::OUString const& rValue)
2539 {
2540 switch (getDefaultVersion()) {
2541 case SvtSaveOptions::ODFVER_011: // fall thru
2542 case SvtSaveOptions::ODFVER_010: break;
2543 default: // ODF 1.2: xml:id
2544 AddAttribute(XML_NAMESPACE_XML, XML_ID, rValue);
2545 }
2546 // in ODF 1.1 this was form:id, anim:id, draw:id, or text:id
2547 // backward compatibility: in ODF 1.2 write _both_ id attrs
2548 AddAttribute(nLegacyPrefix, XML_ID, rValue);
2549 // FIXME: this function simply assumes that rValue is unique
2550 }
2551
2552 void
AddAttributeXmlId(uno::Reference<uno::XInterface> const & i_xIfc)2553 SvXMLExport::AddAttributeXmlId(uno::Reference<uno::XInterface> const & i_xIfc)
2554 {
2555 // check version >= 1.2
2556 switch (getDefaultVersion()) {
2557 case SvtSaveOptions::ODFVER_011: // fall thru
2558 case SvtSaveOptions::ODFVER_010: return;
2559 default: break;
2560 }
2561 const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc,
2562 uno::UNO_QUERY);
2563 //FIXME not yet...
2564 // OSL_ENSURE(xMeta.is(), "xml:id: not XMetadatable");
2565 if ( xMeta.is() )
2566 {
2567 const beans::StringPair mdref( xMeta->getMetadataReference() );
2568 if ( !mdref.Second.equalsAscii("") )
2569 {
2570 const ::rtl::OUString streamName( GetStreamName() );
2571 if ( streamName.getLength() )
2572 {
2573 if ( streamName.equals(mdref.First) )
2574 {
2575 AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second );
2576 }
2577 else
2578 {
2579 OSL_ENSURE(false, "SvXMLExport::AddAttributeXmlId: "
2580 "invalid stream name");
2581 }
2582 }
2583 else
2584 {
2585 // FIXME: this is ugly
2586 // there is no stream name (e.g. XSLT, flat-xml format)!
2587 // but how do we ensure uniqueness in this case?
2588 // a) just omit styles.xml ids -- they are unlikely anyway...
2589 // b) somehow find out whether we are currently exporting styles
2590 // or content, and prefix "s" or "c" => unique
2591 if ( mdref.First.equalsAscii("content.xml") )
2592 {
2593 AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second );
2594 }
2595 else
2596 {
2597 OSL_TRACE("SvXMLExport::AddAttributeXmlId: "
2598 "no stream name given: dropping styles.xml xml:id");
2599 }
2600 }
2601 }
2602 }
2603 }
2604
2605 void
AddAttributesRDFa(uno::Reference<text::XTextContent> const & i_xTextContent)2606 SvXMLExport::AddAttributesRDFa(
2607 uno::Reference<text::XTextContent> const & i_xTextContent)
2608 {
2609 // check version >= 1.2
2610 switch (getDefaultVersion()) {
2611 case SvtSaveOptions::ODFVER_011: // fall thru
2612 case SvtSaveOptions::ODFVER_010: return;
2613 default: break;
2614 }
2615
2616 const uno::Reference<rdf::XMetadatable> xMeta(
2617 i_xTextContent, uno::UNO_QUERY);
2618 if (!xMeta.is() || !xMeta->getMetadataReference().Second.getLength())
2619 {
2620 return; // no xml:id => no RDFa
2621 }
2622
2623 if (!mpImpl->mpRDFaHelper.get())
2624 {
2625 mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaExportHelper(*this) );
2626 }
2627 mpImpl->mpRDFaHelper->AddRDFa(xMeta);
2628 }
2629
exportTextNumberElement() const2630 sal_Bool SvXMLExport::exportTextNumberElement() const
2631 {
2632 return mpImpl->mbExportTextNumberElement;
2633 }
2634
SetNullDateOnUnitConverter()2635 sal_Bool SvXMLExport::SetNullDateOnUnitConverter()
2636 {
2637 // if the null date has already been set, don't set it again (performance)
2638 if (!mpImpl->mbNullDateInitialized)
2639 mpImpl->mbNullDateInitialized = GetMM100UnitConverter().setNullDate(GetModel());
2640
2641 return mpImpl->mbNullDateInitialized;
2642 }
2643
2644
2645 //=============================================================================
2646
2647
StartElement(const sal_uInt16 nPrefixKey,const OUString & rLName,const sal_Bool bIgnoreWhitespaceOutside)2648 void SvXMLElementExport::StartElement(
2649 const sal_uInt16 nPrefixKey,
2650 const OUString& rLName,
2651 const sal_Bool bIgnoreWhitespaceOutside )
2652 {
2653 maElementName = mrExport.GetNamespaceMap().GetQNameByKey(nPrefixKey, rLName);
2654 mrExport.StartElement(maElementName, bIgnoreWhitespaceOutside);
2655 }
2656
SvXMLElementExport(SvXMLExport & rExp,sal_uInt16 nPrefixKey,const sal_Char * pLName,sal_Bool bIWSOutside,sal_Bool bIWSInside)2657 SvXMLElementExport::SvXMLElementExport(
2658 SvXMLExport& rExp,
2659 sal_uInt16 nPrefixKey,
2660 const sal_Char *pLName,
2661 sal_Bool bIWSOutside,
2662 sal_Bool bIWSInside )
2663 : mrExport( rExp )
2664 , maElementName()
2665 , mbIgnoreWhitespaceInside( bIWSInside )
2666 , mbDoSomething( sal_True )
2667 {
2668 const OUString sLName( OUString::createFromAscii( pLName ) );
2669 StartElement( nPrefixKey, sLName, bIWSOutside );
2670 }
2671
SvXMLElementExport(SvXMLExport & rExp,sal_uInt16 nPrefixKey,const OUString & rLName,sal_Bool bIWSOutside,sal_Bool bIWSInside)2672 SvXMLElementExport::SvXMLElementExport(
2673 SvXMLExport& rExp,
2674 sal_uInt16 nPrefixKey,
2675 const OUString& rLName,
2676 sal_Bool bIWSOutside,
2677 sal_Bool bIWSInside )
2678 : mrExport( rExp )
2679 , maElementName()
2680 , mbIgnoreWhitespaceInside( bIWSInside )
2681 , mbDoSomething( sal_True )
2682 {
2683 StartElement( nPrefixKey, rLName, bIWSOutside );
2684 }
2685
SvXMLElementExport(SvXMLExport & rExp,sal_uInt16 nPrefixKey,enum XMLTokenEnum eLName,sal_Bool bIWSOutside,sal_Bool bIWSInside)2686 SvXMLElementExport::SvXMLElementExport(
2687 SvXMLExport& rExp,
2688 sal_uInt16 nPrefixKey,
2689 enum XMLTokenEnum eLName,
2690 sal_Bool bIWSOutside,
2691 sal_Bool bIWSInside )
2692 : mrExport( rExp )
2693 , maElementName()
2694 , mbIgnoreWhitespaceInside( bIWSInside )
2695 , mbDoSomething( sal_True )
2696 {
2697 StartElement( nPrefixKey, GetXMLToken(eLName), bIWSOutside );
2698 }
2699
SvXMLElementExport(SvXMLExport & rExp,sal_Bool bDoSth,sal_uInt16 nPrefixKey,const sal_Char * pLName,sal_Bool bIWSOutside,sal_Bool bIWSInside)2700 SvXMLElementExport::SvXMLElementExport(
2701 SvXMLExport& rExp,
2702 sal_Bool bDoSth,
2703 sal_uInt16 nPrefixKey,
2704 const sal_Char *pLName,
2705 sal_Bool bIWSOutside,
2706 sal_Bool bIWSInside )
2707 : mrExport( rExp )
2708 , maElementName()
2709 , mbIgnoreWhitespaceInside( bIWSInside )
2710 , mbDoSomething( bDoSth )
2711 {
2712 if ( mbDoSomething )
2713 {
2714 const OUString sLName( OUString::createFromAscii( pLName ) );
2715 StartElement( nPrefixKey, sLName, bIWSOutside );
2716 }
2717 }
2718
SvXMLElementExport(SvXMLExport & rExp,sal_Bool bDoSth,sal_uInt16 nPrefixKey,const OUString & rLName,sal_Bool bIWSOutside,sal_Bool bIWSInside)2719 SvXMLElementExport::SvXMLElementExport(
2720 SvXMLExport& rExp,
2721 sal_Bool bDoSth,
2722 sal_uInt16 nPrefixKey,
2723 const OUString& rLName,
2724 sal_Bool bIWSOutside,
2725 sal_Bool bIWSInside )
2726 : mrExport( rExp )
2727 , maElementName()
2728 , mbIgnoreWhitespaceInside( bIWSInside )
2729 , mbDoSomething( bDoSth )
2730 {
2731 if ( mbDoSomething )
2732 StartElement( nPrefixKey, rLName, bIWSOutside );
2733 }
2734
SvXMLElementExport(SvXMLExport & rExp,sal_Bool bDoSth,sal_uInt16 nPrefixKey,enum XMLTokenEnum eLName,sal_Bool bIWSOutside,sal_Bool bIWSInside)2735 SvXMLElementExport::SvXMLElementExport(
2736 SvXMLExport& rExp,
2737 sal_Bool bDoSth,
2738 sal_uInt16 nPrefixKey,
2739 enum XMLTokenEnum eLName,
2740 sal_Bool bIWSOutside,
2741 sal_Bool bIWSInside )
2742 : mrExport( rExp )
2743 , maElementName()
2744 , mbIgnoreWhitespaceInside( bIWSInside )
2745 , mbDoSomething( bDoSth )
2746 {
2747 if ( mbDoSomething )
2748 StartElement( nPrefixKey, GetXMLToken( eLName ), bIWSOutside );
2749 }
2750
SvXMLElementExport(SvXMLExport & rExp,const OUString & rQName,sal_Bool bIWSOutside,sal_Bool bIWSInside)2751 SvXMLElementExport::SvXMLElementExport(
2752 SvXMLExport& rExp,
2753 const OUString& rQName,
2754 sal_Bool bIWSOutside,
2755 sal_Bool bIWSInside )
2756 : mrExport( rExp )
2757 , maElementName()
2758 , mbIgnoreWhitespaceInside( bIWSInside )
2759 , mbDoSomething( sal_True )
2760 {
2761 maElementName = rQName;
2762 rExp.StartElement( rQName, bIWSOutside );
2763 }
2764
~SvXMLElementExport()2765 SvXMLElementExport::~SvXMLElementExport()
2766 {
2767 if ( mbDoSomething )
2768 {
2769 mrExport.EndElement( maElementName, mbIgnoreWhitespaceInside );
2770 }
2771 }
2772
2773