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 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_xmloff.hxx"
24
25 #ifdef PRECOMPILED
26 #include "filt_pch.hxx"
27 #endif
28 #include "unointerfacetouniqueidentifiermapper.hxx"
29 #include <osl/mutex.hxx>
30 #include <rtl/uuid.h>
31 #include <tools/debug.hxx>
32 #include <tools/urlobj.hxx>
33 #include <comphelper/genericpropertyset.hxx>
34 #include <com/sun/star/container/XNameAccess.hpp>
35 #include <com/sun/star/io/XInputStream.hpp>
36 #include <com/sun/star/document/XBinaryStreamResolver.hpp>
37 #include <com/sun/star/xml/sax/SAXInvalidCharacterException.hpp>
38 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
39 #include <com/sun/star/uri/UriReferenceFactory.hpp>
40 #include <comphelper/processfactory.hxx>
41 #include <comphelper/configurationhelper.hxx>
42 #include <xmloff/attrlist.hxx>
43 #include <xmloff/nmspmap.hxx>
44 #include <xmloff/xmluconv.hxx>
45 #include "xmloff/xmlnmspe.hxx"
46 #include <xmloff/xmltoken.hxx>
47 #include <xmloff/xmlexp.hxx>
48 #include <xmloff/xmlnumfe.hxx>
49 #include <xmloff/xmlmetae.hxx>
50 #include <xmloff/XMLSettingsExportContext.hxx>
51 #include <xmloff/families.hxx>
52 #include <xmloff/XMLEventExport.hxx>
53 #include "XMLStarBasicExportHandler.hxx"
54 #include "XMLScriptExportHandler.hxx"
55 #include <xmloff/SettingsExportHelper.hxx>
56 #include <com/sun/star/container/XNameAccess.hpp>
57 #include <com/sun/star/container/XIndexContainer.hpp>
58 #include <com/sun/star/document/XEventsSupplier.hpp>
59 #include <com/sun/star/document/XViewDataSupplier.hpp>
60 #include <xmloff/GradientStyle.hxx>
61 #include <xmloff/HatchStyle.hxx>
62 #include <xmloff/ImageStyle.hxx>
63 #include <TransGradientStyle.hxx>
64 #include <xmloff/MarkerStyle.hxx>
65 #include <xmloff/DashStyle.hxx>
66 #include <xmloff/XMLFontAutoStylePool.hxx>
67 #include "XMLImageMapExport.hxx"
68 #include "XMLBase64Export.hxx"
69 #include "xmloff/xmlerror.hxx"
70 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
71 #include <com/sun/star/beans/PropertyAttribute.hpp>
72 #include "xmloff/XMLFilterServiceNames.h"
73 #include "xmloff/XMLEmbeddedObjectExportFilter.hxx"
74 #include "XMLBasicExportFilter.hxx"
75 #include <vos/mutex.hxx>
76 #include <rtl/logfile.hxx>
77 #include <cppuhelper/implbase1.hxx>
78 #include <comphelper/extract.hxx>
79 #include "PropertySetMerger.hxx"
80
81 #include "svl/urihelper.hxx"
82 #include "xmloff/xformsexport.hxx"
83
84 #include <unotools/docinfohelper.hxx>
85 #include <unotools/bootstrap.hxx>
86 #include <unotools/configmgr.hxx>
87 #include <tools/inetdef.hxx>
88 #include <com/sun/star/document/XDocumentProperties.hpp>
89 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
90
91 #include <com/sun/star/rdf/XMetadatable.hpp>
92 #include "RDFaExportHelper.hxx"
93
94
95 using ::rtl::OUString;
96
97 using namespace ::osl;
98 using namespace ::com::sun::star;
99 using namespace ::com::sun::star::uno;
100 using namespace ::com::sun::star::frame;
101 using namespace ::com::sun::star::container;
102 using namespace ::com::sun::star::lang;
103 using namespace ::com::sun::star::document;
104 using namespace ::com::sun::star::beans;
105 using namespace ::com::sun::star::xml::sax;
106 using namespace ::com::sun::star::io;
107 using namespace ::xmloff::token;
108
109 sal_Char __READONLY_DATA sXML_1_1[] = "1.1";
110 sal_Char __READONLY_DATA sXML_1_2[] = "1.2";
111 sal_Char __READONLY_DATA sXML_1_3[] = "1.3";
112
113 const sal_Char *sOpenOfficeOrgProject ="OpenOffice.org_project";
114
115 // #i115030#: the XSLT is not finished, and not available via HTTP
116 const sal_Char s_grddl_xsl[] = "http://FIXME";
117
118 #define LOGFILE_AUTHOR "mb93740"
119
120 #define XML_MODEL_SERVICE_WRITER "com.sun.star.text.TextDocument"
121 #define XML_MODEL_SERVICE_CALC "com.sun.star.sheet.SpreadsheetDocument"
122 #define XML_MODEL_SERVICE_DRAW "com.sun.star.drawing.DrawingDocument"
123 #define XML_MODEL_SERVICE_IMPRESS "com.sun.star.presentation.PresentationDocument"
124 #define XML_MODEL_SERVICE_MATH "com.sun.star.formula.FormulaProperties"
125 #define XML_MODEL_SERVICE_CHART "com.sun.star.chart.ChartDocument"
126
127 #define XML_USEPRETTYPRINTING "UsePrettyPrinting"
128
129 #define C2U(cChar) OUString( RTL_CONSTASCII_USTRINGPARAM(cChar) )
130
131 struct XMLServiceMapEntry_Impl
132 {
133 const sal_Char *sModelService;
134 sal_Int32 nModelServiceLen;
135 const sal_Char *sFilterService;
136 sal_Int32 nFilterServiceLen;
137 };
138
139 #define SERVICE_MAP_ENTRY( app ) \
140 { XML_MODEL_SERVICE_##app, sizeof(XML_MODEL_SERVICE_##app)-1, \
141 XML_EXPORT_FILTER_##app, sizeof(XML_EXPORT_FILTER_##app)-1 }
142
143 const XMLServiceMapEntry_Impl aServiceMap[] =
144 {
145 SERVICE_MAP_ENTRY( WRITER ),
146 SERVICE_MAP_ENTRY( CALC ),
147 SERVICE_MAP_ENTRY( IMPRESS ),// Impress supports DrawingDocument, too, so
148 SERVICE_MAP_ENTRY( DRAW ), // it must appear before Draw
149 SERVICE_MAP_ENTRY( MATH ),
150 SERVICE_MAP_ENTRY( CHART ),
151 { 0, 0, 0, 0 }
152 };
153
154 //==============================================================================
155
156 class SAL_DLLPRIVATE SettingsExportFacade : public ::xmloff::XMLSettingsExportContext
157 {
158 public:
SettingsExportFacade(SvXMLExport & i_rExport)159 SettingsExportFacade( SvXMLExport& i_rExport )
160 :m_rExport( i_rExport )
161 {
162 }
163
~SettingsExportFacade()164 virtual ~SettingsExportFacade()
165 {
166 }
167
168 virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName,
169 const ::rtl::OUString& i_rValue );
170 virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName,
171 enum ::xmloff::token::XMLTokenEnum i_eValue );
172
173 virtual void StartElement( enum ::xmloff::token::XMLTokenEnum i_eName,
174 const sal_Bool i_bIgnoreWhitespace );
175 virtual void EndElement( const sal_Bool i_bIgnoreWhitespace );
176
177 virtual void Characters( const ::rtl::OUString& i_rCharacters );
178
179 virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
180 GetServiceFactory() const;
181 private:
182 SvXMLExport& m_rExport;
183 ::std::stack< ::rtl::OUString > m_aElements;
184 };
185
AddAttribute(enum::xmloff::token::XMLTokenEnum i_eName,const::rtl::OUString & i_rValue)186 void SettingsExportFacade::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, const ::rtl::OUString& i_rValue )
187 {
188 m_rExport.AddAttribute( XML_NAMESPACE_CONFIG, i_eName, i_rValue );
189 }
190
AddAttribute(enum::xmloff::token::XMLTokenEnum i_eName,enum::xmloff::token::XMLTokenEnum i_eValue)191 void SettingsExportFacade::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, enum ::xmloff::token::XMLTokenEnum i_eValue )
192 {
193 m_rExport.AddAttribute( XML_NAMESPACE_CONFIG, i_eName, i_eValue );
194 }
195
StartElement(enum::xmloff::token::XMLTokenEnum i_eName,const sal_Bool i_bIgnoreWhitespace)196 void SettingsExportFacade::StartElement( enum ::xmloff::token::XMLTokenEnum i_eName, const sal_Bool i_bIgnoreWhitespace )
197 {
198 const ::rtl::OUString sElementName( m_rExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_CONFIG, GetXMLToken( i_eName ) ) );
199 m_rExport.StartElement( sElementName, i_bIgnoreWhitespace );
200 m_aElements.push( sElementName );
201 }
202
EndElement(const sal_Bool i_bIgnoreWhitespace)203 void SettingsExportFacade::EndElement( const sal_Bool i_bIgnoreWhitespace )
204 {
205 const ::rtl::OUString sElementName( m_aElements.top() );
206 m_rExport.EndElement( sElementName, i_bIgnoreWhitespace );
207 m_aElements.pop();
208 }
209
Characters(const::rtl::OUString & i_rCharacters)210 void SettingsExportFacade::Characters( const ::rtl::OUString& i_rCharacters )
211 {
212 m_rExport.GetDocHandler()->characters( i_rCharacters );
213 }
214
GetServiceFactory() const215 Reference< XMultiServiceFactory > SettingsExportFacade::GetServiceFactory() const
216 {
217 return m_rExport.getServiceFactory();
218 }
219
220 //==============================================================================
221
222 class SvXMLExportEventListener : public cppu::WeakImplHelper1<
223 com::sun::star::lang::XEventListener >
224 {
225 private:
226 SvXMLExport* pExport;
227
228 public:
229 SvXMLExportEventListener(SvXMLExport* pExport);
230 virtual ~SvXMLExportEventListener();
231
232 // XEventListener
233 virtual void SAL_CALL disposing(const lang::EventObject& rEventObject);
234 };
235
SvXMLExportEventListener(SvXMLExport * pTempExport)236 SvXMLExportEventListener::SvXMLExportEventListener(SvXMLExport* pTempExport)
237 : pExport(pTempExport)
238 {
239 }
240
~SvXMLExportEventListener()241 SvXMLExportEventListener::~SvXMLExportEventListener()
242 {
243 }
244
245 // XEventListener
disposing(const lang::EventObject &)246 void SAL_CALL SvXMLExportEventListener::disposing( const lang::EventObject& )
247 {
248 if (pExport)
249 {
250 pExport->DisposingModel();
251 pExport = NULL;
252 }
253 }
254
255 //==============================================================================
256
257 class SvXMLExport_Impl
258 {
259 public:
260 SvXMLExport_Impl();
261
262 ::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper;
263 uno::Reference< uri::XUriReferenceFactory > mxUriReferenceFactory;
264 rtl::OUString msPackageURI;
265 rtl::OUString msPackageURIScheme;
266 // --> OD 2006-09-27 #i69627#
267 sal_Bool mbOutlineStyleAsNormalListStyle;
268 // <--
269 // --> PB 2007-07-06 #i146851#
270 sal_Bool mbSaveBackwardCompatibleODF;
271 // <--
272
273 uno::Reference< embed::XStorage > mxTargetStorage;
274
275 SvtSaveOptions maSaveOptions;
276
277 // relative path of stream in package, e.g. "someobject/content.xml"
278 ::rtl::OUString mStreamPath;
279
280 const uno::Reference< uno::XComponentContext > mxComponentContext;
281
282 // name of stream in package, e.g., "content.xml"
283 ::rtl::OUString mStreamName;
284
285 // stack of backed up namespace maps
286 // long: depth at which namespace map has been backed up into the stack
287 ::std::stack< ::std::pair< SvXMLNamespaceMap *, long > > mNamespaceMaps;
288 // counts depth (number of open elements/start tags)
289 long mDepth;
290
291 ::std::auto_ptr< ::xmloff::RDFaExportHelper> mpRDFaHelper;
292
293 // --> OD 2008-11-26 #158694#
294 sal_Bool mbExportTextNumberElement;
295 // <--
296 sal_Bool mbNullDateInitialized;
297
SetSchemeOf(const::rtl::OUString & rOrigFileName)298 void SetSchemeOf( const ::rtl::OUString& rOrigFileName )
299 {
300 sal_Int32 nSep = rOrigFileName.indexOf(':');
301 if( nSep != -1 )
302 msPackageURIScheme = rOrigFileName.copy( 0, nSep );
303 }
304 };
305
SvXMLExport_Impl()306 SvXMLExport_Impl::SvXMLExport_Impl()
307 // --> OD 2006-09-27 #i69627#
308 : mbOutlineStyleAsNormalListStyle( false )
309 // <--
310 // --> PB 2007-07-06 #i146851#
311 ,mbSaveBackwardCompatibleODF( sal_True )
312 // <--
313 ,mxComponentContext( ::comphelper::getProcessComponentContext() )
314 ,mStreamName()
315 ,mNamespaceMaps()
316 ,mDepth(0)
317 ,mpRDFaHelper() // lazy
318 // --> OD 2008-11-26 #158694#
319 ,mbExportTextNumberElement( sal_False )
320 // <--
321 ,mbNullDateInitialized( sal_False )
322 {
323 OSL_ENSURE(mxComponentContext.is(), "SvXMLExport: no ComponentContext");
324 if (!mxComponentContext.is()) throw uno::RuntimeException();
325 mxUriReferenceFactory = uri::UriReferenceFactory::create(
326 mxComponentContext );
327 }
328
329 //==============================================================================
330
SetDocHandler(const uno::Reference<xml::sax::XDocumentHandler> & rHandler)331 void SvXMLExport::SetDocHandler( const uno::Reference< xml::sax::XDocumentHandler > &rHandler )
332 {
333 mxHandler = rHandler;
334 mxExtHandler = uno::Reference<xml::sax::XExtendedDocumentHandler>( mxHandler, UNO_QUERY );
335 }
336
_InitCtor()337 void SvXMLExport::_InitCtor()
338 {
339 // note: it is not necessary to add XML_NP_XML (it is declared implicitly)
340 if( (getExportFlags() & ~EXPORT_OASIS) != 0 )
341 {
342 mpNamespaceMap->Add( GetXMLToken(XML_NP_OFFICE), GetXMLToken(XML_N_OFFICE), XML_NAMESPACE_OFFICE );
343 mpNamespaceMap->Add( GetXMLToken(XML_NP_OOO), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
344 }
345 if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS) ) != 0 )
346 {
347 mpNamespaceMap->Add( GetXMLToken(XML_NP_FO), GetXMLToken(XML_N_FO_COMPAT), XML_NAMESPACE_FO );
348 }
349 if( (getExportFlags() & (EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS) ) != 0 )
350 {
351 mpNamespaceMap->Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
352 }
353 if( (getExportFlags() & EXPORT_SETTINGS) != 0 )
354 {
355 mpNamespaceMap->Add( GetXMLToken(XML_NP_CONFIG), GetXMLToken(XML_N_CONFIG), XML_NAMESPACE_CONFIG );
356 }
357
358 if( (getExportFlags() & (EXPORT_META|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
359 {
360 mpNamespaceMap->Add( GetXMLToken(XML_NP_DC), GetXMLToken(XML_N_DC), XML_NAMESPACE_DC );
361 mpNamespaceMap->Add( GetXMLToken(XML_NP_META), GetXMLToken(XML_N_META), XML_NAMESPACE_META );
362 }
363 if( (getExportFlags() & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_FONTDECLS) ) != 0 )
364 {
365 mpNamespaceMap->Add( GetXMLToken(XML_NP_STYLE), GetXMLToken(XML_N_STYLE), XML_NAMESPACE_STYLE );
366 }
367
368 // namespaces for documents
369 if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
370 {
371 mpNamespaceMap->Add( GetXMLToken(XML_NP_DC), GetXMLToken(XML_N_DC), XML_NAMESPACE_DC );
372 mpNamespaceMap->Add( GetXMLToken(XML_NP_TEXT), GetXMLToken(XML_N_TEXT), XML_NAMESPACE_TEXT );
373 mpNamespaceMap->Add( GetXMLToken(XML_NP_DRAW), GetXMLToken(XML_N_DRAW), XML_NAMESPACE_DRAW );
374 mpNamespaceMap->Add( GetXMLToken(XML_NP_DR3D), GetXMLToken(XML_N_DR3D), XML_NAMESPACE_DR3D );
375 mpNamespaceMap->Add( GetXMLToken(XML_NP_SVG), GetXMLToken(XML_N_SVG_COMPAT), XML_NAMESPACE_SVG );
376 mpNamespaceMap->Add( GetXMLToken(XML_NP_CHART), GetXMLToken(XML_N_CHART), XML_NAMESPACE_CHART );
377 mpNamespaceMap->Add( GetXMLToken(XML_NP_RPT), GetXMLToken(XML_N_RPT), XML_NAMESPACE_REPORT );
378 mpNamespaceMap->Add( GetXMLToken(XML_NP_TABLE), GetXMLToken(XML_N_TABLE), XML_NAMESPACE_TABLE );
379 mpNamespaceMap->Add( GetXMLToken(XML_NP_NUMBER),GetXMLToken(XML_N_NUMBER), XML_NAMESPACE_NUMBER );
380 mpNamespaceMap->Add( GetXMLToken(XML_NP_OOOW), GetXMLToken(XML_N_OOOW), XML_NAMESPACE_OOOW );
381 mpNamespaceMap->Add( GetXMLToken(XML_NP_OOOC), GetXMLToken(XML_N_OOOC), XML_NAMESPACE_OOOC );
382 mpNamespaceMap->Add( GetXMLToken(XML_NP_OF), GetXMLToken(XML_N_OF), XML_NAMESPACE_OF );
383
384 if (SvtSaveOptions::IsODFExtended( getDefaultVersion() ))
385 {
386 mpNamespaceMap->Add(
387 GetXMLToken(XML_NP_TABLE_EXT), GetXMLToken(XML_N_TABLE_EXT), XML_NAMESPACE_TABLE_EXT);
388 }
389 }
390 if( (getExportFlags() & (EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
391 {
392 mpNamespaceMap->Add( GetXMLToken(XML_NP_MATH), GetXMLToken(XML_N_MATH), XML_NAMESPACE_MATH );
393 mpNamespaceMap->Add( GetXMLToken(XML_NP_FORM), GetXMLToken(XML_N_FORM), XML_NAMESPACE_FORM );
394 }
395 if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS) ) != 0 )
396 {
397 mpNamespaceMap->Add( GetXMLToken(XML_NP_SCRIPT), GetXMLToken(XML_N_SCRIPT), XML_NAMESPACE_SCRIPT );
398 mpNamespaceMap->Add( GetXMLToken(XML_NP_DOM), GetXMLToken(XML_N_DOM), XML_NAMESPACE_DOM );
399 }
400 if( (getExportFlags() & EXPORT_CONTENT ) != 0 )
401 {
402 mpNamespaceMap->Add( GetXMLToken(XML_NP_XFORMS_1_0), GetXMLToken(XML_N_XFORMS_1_0), XML_NAMESPACE_XFORMS );
403 mpNamespaceMap->Add( GetXMLToken(XML_NP_XSD), GetXMLToken(XML_N_XSD), XML_NAMESPACE_XSD );
404 mpNamespaceMap->Add( GetXMLToken(XML_NP_XSI), GetXMLToken(XML_N_XSI), XML_NAMESPACE_XSI );
405 mpNamespaceMap->Add( GetXMLToken(XML_NP_FIELD), GetXMLToken(XML_N_FIELD), XML_NAMESPACE_FIELD );
406 }
407 // RDFa: needed for content and header/footer styles
408 if( (getExportFlags() & (EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
409 {
410 mpNamespaceMap->Add( GetXMLToken(XML_NP_XHTML),
411 GetXMLToken(XML_N_XHTML), XML_NAMESPACE_XHTML );
412 }
413 // GRDDL: to convert RDFa and meta.xml to RDF
414 if( (getExportFlags() & (EXPORT_META|EXPORT_STYLES|EXPORT_AUTOSTYLES|EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
415 {
416 mpNamespaceMap->Add( GetXMLToken(XML_NP_GRDDL),
417 GetXMLToken(XML_N_GRDDL), XML_NAMESPACE_GRDDL );
418 }
419
420 mxAttrList = (xml::sax::XAttributeList*)mpAttrList;
421
422 msPicturesPath = OUString( RTL_CONSTASCII_USTRINGPARAM( "#Pictures/" ) );
423 msObjectsPath = OUString( RTL_CONSTASCII_USTRINGPARAM( "#./" ) );
424 msGraphicObjectProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:" ) );
425 msEmbeddedObjectProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ) );
426
427 if (mxModel.is() && !mxEventListener.is())
428 {
429 mxEventListener.set( new SvXMLExportEventListener(this));
430 mxModel->addEventListener(mxEventListener);
431 }
432
433 // --> OD 2006-03-10 #i51726# - determine model type
434 _DetermineModelType();
435 // <--
436
437 mbEnableExperimentalOdfExport = getenv("ENABLE_EXPERIMENTAL_ODF_EXPORT") != NULL;
438
439 // --> PB 2007-07-06 #146851# - load mbSaveBackwardCompatibleODF from configuration
440
441 // cl: but only if we do export to current oasis format, old openoffice format *must* always be compatible
442 if( (getExportFlags() & EXPORT_OASIS) != 0 )
443 {
444 sal_Bool bTemp = sal_True;
445 if ( ::comphelper::ConfigurationHelper::readDirectKey(
446 getServiceFactory(),
447 C2U("org.openoffice.Office.Common/"), C2U("Save/Document"), C2U("SaveBackwardCompatibleODF"),
448 ::comphelper::ConfigurationHelper::E_READONLY ) >>= bTemp )
449 {
450 mpImpl->mbSaveBackwardCompatibleODF = bTemp;
451 }
452 }
453 // <--
454 }
455
456 // --> OD 2006-03-14 #i51726#
_DetermineModelType()457 void SvXMLExport::_DetermineModelType()
458 {
459 meModelType = SvtModuleOptions::E_UNKNOWN_FACTORY;
460
461 if ( mxModel.is() )
462 {
463 meModelType = SvtModuleOptions::ClassifyFactoryByModel( mxModel );
464 }
465 }
466 // <--
467
468 // #110680#
SvXMLExport(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & xServiceFactory,MapUnit eDfltUnit,const enum XMLTokenEnum eClass,sal_uInt16 nExportFlags)469 SvXMLExport::SvXMLExport(
470 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
471 MapUnit eDfltUnit, const enum XMLTokenEnum eClass, sal_uInt16 nExportFlags )
472 : mpImpl( new SvXMLExport_Impl ),
473 // #110680#
474 mxServiceFactory(xServiceFactory),
475 mpAttrList( new SvXMLAttributeList ),
476 mpNamespaceMap( new SvXMLNamespaceMap ),
477 // #110680#
478 mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, eDfltUnit, getServiceFactory() ) ),
479 mpNumExport(0L),
480 mpProgressBarHelper( NULL ),
481 mpEventExport( NULL ),
482 mpImageMapExport( NULL ),
483 mpXMLErrors( NULL ),
484 mbExtended( sal_False ),
485 meClass( eClass ),
486 mnExportFlags( nExportFlags ),
487 mnErrorFlags( ERROR_NO ),
488 msWS( GetXMLToken(XML_WS) ),
489 mbSaveLinkedSections(sal_True)
490 {
491 DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
492 _InitCtor();
493 }
494
495 // #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)496 SvXMLExport::SvXMLExport(
497 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
498 const OUString &rFileName,
499 const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
500 MapUnit eDfltUnit )
501 : mpImpl( new SvXMLExport_Impl ),
502 // #110680#
503 mxServiceFactory(xServiceFactory),
504 mxHandler( rHandler ),
505 mxExtHandler( rHandler, uno::UNO_QUERY ),
506 mpAttrList( new SvXMLAttributeList ),
507 msOrigFileName( rFileName ),
508 mpNamespaceMap( new SvXMLNamespaceMap ),
509 // #110680#
510 mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, eDfltUnit, getServiceFactory() ) ),
511 mpNumExport(0L),
512 mpProgressBarHelper( NULL ),
513 mpEventExport( NULL ),
514 mpImageMapExport( NULL ),
515 mpXMLErrors( NULL ),
516 mbExtended( sal_False ),
517 meClass( XML_TOKEN_INVALID ),
518 mnExportFlags( 0 ),
519 mnErrorFlags( ERROR_NO ),
520 msWS( GetXMLToken(XML_WS) ),
521 mbSaveLinkedSections(sal_True)
522 {
523 mpImpl->SetSchemeOf( msOrigFileName );
524 DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
525 _InitCtor();
526
527 if (mxNumberFormatsSupplier.is())
528 mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
529 }
530
531 // #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)532 SvXMLExport::SvXMLExport(
533 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
534 const OUString &rFileName,
535 const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
536 const Reference< XModel >& rModel,
537 sal_Int16 eDfltUnit )
538 : mpImpl( new SvXMLExport_Impl ),
539 // #110680#
540 mxServiceFactory(xServiceFactory),
541 mxModel( rModel ),
542 mxHandler( rHandler ),
543 mxExtHandler( rHandler, uno::UNO_QUERY ),
544 mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
545 mpAttrList( new SvXMLAttributeList ),
546 msOrigFileName( rFileName ),
547 mpNamespaceMap( new SvXMLNamespaceMap ),
548 // #110680#
549 // pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, SvXMLUnitConverter::GetMapUnit(eDfltUnit) ) ),
550 mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, SvXMLUnitConverter::GetMapUnit(eDfltUnit), getServiceFactory() ) ),
551 mpNumExport(0L),
552 mpProgressBarHelper( NULL ),
553 mpEventExport( NULL ),
554 mpImageMapExport( NULL ),
555 mpXMLErrors( NULL ),
556 mbExtended( sal_False ),
557 meClass( XML_TOKEN_INVALID ),
558 mnExportFlags( 0 ),
559 mnErrorFlags( ERROR_NO ),
560 msWS( GetXMLToken(XML_WS) ),
561 mbSaveLinkedSections(sal_True)
562 {
563 mpImpl->SetSchemeOf( msOrigFileName );
564 DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
565 _InitCtor();
566
567 if (mxNumberFormatsSupplier.is())
568 mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
569 }
570
571 // #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)572 SvXMLExport::SvXMLExport(
573 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
574 const OUString &rFileName,
575 const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
576 const Reference< XModel >& rModel,
577 const Reference< document::XGraphicObjectResolver >& rEmbeddedGraphicObjects,
578 sal_Int16 eDfltUnit )
579 : mpImpl( new SvXMLExport_Impl ),
580 // #110680#
581 mxServiceFactory(xServiceFactory),
582 mxModel( rModel ),
583 mxHandler( rHandler ),
584 mxExtHandler( rHandler, uno::UNO_QUERY ),
585 mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
586 mxGraphicResolver( rEmbeddedGraphicObjects ),
587 mpAttrList( new SvXMLAttributeList ),
588 msOrigFileName( rFileName ),
589 mpNamespaceMap( new SvXMLNamespaceMap ),
590 // #110680#
591 mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, SvXMLUnitConverter::GetMapUnit(eDfltUnit), getServiceFactory() ) ),
592 mpNumExport(0L),
593 mpProgressBarHelper( NULL ),
594 mpEventExport( NULL ),
595 mpImageMapExport( NULL ),
596 mpXMLErrors( NULL ),
597 mbExtended( sal_False ),
598 meClass( XML_TOKEN_INVALID ),
599 mnExportFlags( 0 ),
600 mnErrorFlags( ERROR_NO ),
601 msWS( GetXMLToken(XML_WS) ),
602 mbSaveLinkedSections(sal_True)
603 {
604 mpImpl->SetSchemeOf( msOrigFileName );
605 DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
606 _InitCtor();
607
608 if (mxNumberFormatsSupplier.is())
609 mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
610 }
611
~SvXMLExport()612 SvXMLExport::~SvXMLExport()
613 {
614 delete mpXMLErrors;
615 delete mpImageMapExport;
616 delete mpEventExport;
617 delete mpNamespaceMap;
618 delete mpUnitConv;
619 if (mpProgressBarHelper || mpNumExport)
620 {
621 if (mxExportInfo.is())
622 {
623 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
624 if (xPropertySetInfo.is())
625 {
626 if (mpProgressBarHelper)
627 {
628 OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSMAX));
629 OUString sProgressCurrent(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSCURRENT));
630 OUString sRepeat(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSREPEAT));
631 if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
632 xPropertySetInfo->hasPropertyByName(sProgressCurrent))
633 {
634 sal_Int32 nProgressMax(mpProgressBarHelper->GetReference());
635 sal_Int32 nProgressCurrent(mpProgressBarHelper->GetValue());
636 uno::Any aAny;
637 aAny <<= nProgressMax;
638 mxExportInfo->setPropertyValue(sProgressMax, aAny);
639 aAny <<= nProgressCurrent;
640 mxExportInfo->setPropertyValue(sProgressCurrent, aAny);
641 }
642 if (xPropertySetInfo->hasPropertyByName(sRepeat))
643 mxExportInfo->setPropertyValue(sRepeat, cppu::bool2any(mpProgressBarHelper->GetRepeat()));
644 }
645 if (mpNumExport && (mnExportFlags & (EXPORT_AUTOSTYLES | EXPORT_STYLES)))
646 {
647 OUString sWrittenNumberFormats(RTL_CONSTASCII_USTRINGPARAM(XML_WRITTENNUMBERSTYLES));
648 if (xPropertySetInfo->hasPropertyByName(sWrittenNumberFormats))
649 {
650 uno::Sequence<sal_Int32> aWasUsed;
651 mpNumExport->GetWasUsed(aWasUsed);
652 uno::Any aAny;
653 aAny <<= aWasUsed;
654 mxExportInfo->setPropertyValue(sWrittenNumberFormats, aAny);
655 }
656 }
657 }
658 }
659 delete mpProgressBarHelper;
660 delete mpNumExport;
661 }
662
663 xmloff::token::ResetTokens();
664
665 if (mxEventListener.is() && mxModel.is())
666 mxModel->removeEventListener(mxEventListener);
667
668 delete mpImpl;
669 }
670
671 ///////////////////////////////////////////////////////////////////////
672
673 // XExporter
setSourceDocument(const uno::Reference<lang::XComponent> & xDoc)674 void SAL_CALL SvXMLExport::setSourceDocument( const uno::Reference< lang::XComponent >& xDoc )
675 {
676 mxModel = uno::Reference< frame::XModel >::query( xDoc );
677 if( !mxModel.is() )
678 throw lang::IllegalArgumentException();
679 if (mxModel.is() && ! mxEventListener.is())
680 {
681 mxEventListener.set( new SvXMLExportEventListener(this));
682 mxModel->addEventListener(mxEventListener);
683 }
684
685 if(!mxNumberFormatsSupplier.is() )
686 {
687 mxNumberFormatsSupplier = mxNumberFormatsSupplier.query( mxModel );
688 if(mxNumberFormatsSupplier.is() && mxHandler.is())
689 mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
690 }
691 if (mxExportInfo.is())
692 {
693 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
694 if (xPropertySetInfo.is())
695 {
696 OUString sUsePrettyPrinting(RTL_CONSTASCII_USTRINGPARAM(XML_USEPRETTYPRINTING));
697 if (xPropertySetInfo->hasPropertyByName(sUsePrettyPrinting))
698 {
699 uno::Any aAny = mxExportInfo->getPropertyValue(sUsePrettyPrinting);
700 try
701 {
702 if (::cppu::any2bool(aAny))
703 mnExportFlags |= EXPORT_PRETTY;
704 else
705 mnExportFlags &= ~EXPORT_PRETTY;
706 }
707 catch ( lang::IllegalArgumentException& )
708 {
709 DBG_ERRORFILE("why is bUsePrettyPrint not boolean?");
710 }
711 }
712
713 if (mpNumExport && (mnExportFlags & (EXPORT_AUTOSTYLES | EXPORT_STYLES)))
714 {
715 OUString sWrittenNumberFormats(RTL_CONSTASCII_USTRINGPARAM(XML_WRITTENNUMBERSTYLES));
716 if (xPropertySetInfo->hasPropertyByName(sWrittenNumberFormats))
717 {
718 uno::Any aAny = mxExportInfo->getPropertyValue(sWrittenNumberFormats);
719 uno::Sequence<sal_Int32> aWasUsed;
720 if(aAny >>= aWasUsed)
721 mpNumExport->SetWasUsed(aWasUsed);
722 }
723 }
724 }
725 }
726
727 // --> PB 2007-07-06 #i146851#
728 if ( mpImpl->mbSaveBackwardCompatibleODF )
729 mnExportFlags |= EXPORT_SAVEBACKWARDCOMPATIBLE;
730 else
731 mnExportFlags &= ~EXPORT_SAVEBACKWARDCOMPATIBLE;
732 // <--
733
734 // namespaces for user defined attributes
735 Reference< XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
736 if( xFactory.is() )
737 {
738 try
739 {
740 Reference < XInterface > xIfc =
741 xFactory->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM(
742 "com.sun.star.xml.NamespaceMap")) );
743 if( xIfc.is() )
744 {
745 Reference< XNameAccess > xNamespaceMap( xIfc, UNO_QUERY );
746 if( xNamespaceMap.is() )
747 {
748 Sequence< OUString > aPrefixes( xNamespaceMap->getElementNames() );
749
750 OUString* pPrefix = aPrefixes.getArray();
751 const sal_Int32 nCount = aPrefixes.getLength();
752 sal_Int32 nIndex;
753 OUString aURL;
754
755 for( nIndex = 0; nIndex < nCount; ++nIndex, ++pPrefix )
756 {
757 if( xNamespaceMap->getByName( *pPrefix ) >>= aURL )
758 _GetNamespaceMap().Add( *pPrefix, aURL, XML_NAMESPACE_UNKNOWN );
759 }
760 }
761 }
762 }
763 catch( com::sun::star::uno::Exception& )
764 {
765 }
766 }
767
768 // --> OD 2006-03-10 #i51726# - determine model type
769 _DetermineModelType();
770 // <--
771 }
772
773 // XInitialize
initialize(const uno::Sequence<uno::Any> & aArguments)774 void SAL_CALL SvXMLExport::initialize( const uno::Sequence< uno::Any >& aArguments )
775 {
776 // #93186# we need to queryInterface every single Any with any expected outcome. This variable hold the queryInterface results.
777
778 const sal_Int32 nAnyCount = aArguments.getLength();
779 const uno::Any* pAny = aArguments.getConstArray();
780
781 for( sal_Int32 nIndex = 0; nIndex < nAnyCount; nIndex++, pAny++ )
782 {
783 Reference<XInterface> xValue;
784 *pAny >>= xValue;
785
786 // status indicator
787 uno::Reference<task::XStatusIndicator> xTmpStatus( xValue, UNO_QUERY );
788 if ( xTmpStatus.is() )
789 mxStatusIndicator = xTmpStatus;
790
791 // graphic resolver
792 uno::Reference<document::XGraphicObjectResolver> xTmpGraphic(
793 xValue, UNO_QUERY );
794 if ( xTmpGraphic.is() )
795 mxGraphicResolver = xTmpGraphic;
796
797 // object resolver
798 uno::Reference<document::XEmbeddedObjectResolver> xTmpObjectResolver(
799 xValue, UNO_QUERY );
800 if ( xTmpObjectResolver.is() )
801 mxEmbeddedResolver = xTmpObjectResolver;
802
803 // document handler
804 uno::Reference<xml::sax::XDocumentHandler> xTmpDocHandler(
805 xValue, UNO_QUERY );
806 if( xTmpDocHandler.is() )
807 {
808 mxHandler = xTmpDocHandler;
809 *pAny >>= mxExtHandler;
810
811 if (mxNumberFormatsSupplier.is() && mpNumExport == NULL)
812 mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
813 }
814
815 // property set to transport data across
816 uno::Reference<beans::XPropertySet> xTmpPropertySet(
817 xValue, UNO_QUERY );
818 if( xTmpPropertySet.is() )
819 mxExportInfo = xTmpPropertySet;
820 }
821
822 if( mxExportInfo.is() )
823 {
824 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo =
825 mxExportInfo->getPropertySetInfo();
826 OUString sPropName(
827 RTL_CONSTASCII_USTRINGPARAM("BaseURI" ) );
828 if( xPropertySetInfo->hasPropertyByName(sPropName) )
829 {
830 uno::Any aAny = mxExportInfo->getPropertyValue(sPropName);
831 aAny >>= msOrigFileName;
832 mpImpl->msPackageURI = msOrigFileName;
833 mpImpl->SetSchemeOf( msOrigFileName );
834 }
835 OUString sRelPath;
836 sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamRelPath" ) );
837 if( xPropertySetInfo->hasPropertyByName(sPropName) )
838 {
839 uno::Any aAny = mxExportInfo->getPropertyValue(sPropName);
840 aAny >>= sRelPath;
841 }
842 OUString sName;
843 sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamName" ) );
844 if( xPropertySetInfo->hasPropertyByName(sPropName) )
845 {
846 uno::Any aAny = mxExportInfo->getPropertyValue(sPropName);
847 aAny >>= sName;
848 }
849 if( msOrigFileName.getLength() && sName.getLength() )
850 {
851 INetURLObject aBaseURL( msOrigFileName );
852 if( sRelPath.getLength() )
853 aBaseURL.insertName( sRelPath );
854 aBaseURL.insertName( sName );
855 msOrigFileName = aBaseURL.GetMainURL(INetURLObject::DECODE_TO_IURI);
856 }
857 mpImpl->mStreamName = sName; // Note: may be empty (XSLT)
858
859 // --> OD 2006-09-26 #i69627#
860 const ::rtl::OUString sOutlineStyleAsNormalListStyle(
861 RTL_CONSTASCII_USTRINGPARAM("OutlineStyleAsNormalListStyle") );
862 if( xPropertySetInfo->hasPropertyByName( sOutlineStyleAsNormalListStyle ) )
863 {
864 uno::Any aAny = mxExportInfo->getPropertyValue( sOutlineStyleAsNormalListStyle );
865 aAny >>= (mpImpl->mbOutlineStyleAsNormalListStyle);
866 }
867 // <--
868
869 OUString sTargetStorage( RTL_CONSTASCII_USTRINGPARAM("TargetStorage") );
870 if( xPropertySetInfo->hasPropertyByName( sTargetStorage ) )
871 mxExportInfo->getPropertyValue( sTargetStorage ) >>= mpImpl->mxTargetStorage;
872
873 // --> OD 2008-11-26 #158694#
874 const ::rtl::OUString sExportTextNumberElement(
875 RTL_CONSTASCII_USTRINGPARAM("ExportTextNumberElement") );
876 if( xPropertySetInfo->hasPropertyByName( sExportTextNumberElement ) )
877 {
878 uno::Any aAny = mxExportInfo->getPropertyValue( sExportTextNumberElement );
879 aAny >>= (mpImpl->mbExportTextNumberElement);
880 }
881 // <--
882 }
883
884 }
885
886 // XFilter
filter(const uno::Sequence<beans::PropertyValue> & aDescriptor)887 sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor )
888 {
889 RTL_LOGFILE_CONTEXT_AUTHOR( aLogContext, "xmloff", LOGFILE_AUTHOR,
890 "SvXMLExport::filter" );
891
892 // check for xHandler first... should have been supplied in initialize
893 if( !mxHandler.is() )
894 return sal_False;
895
896 try
897 {
898 const sal_uInt32 nTest =
899 EXPORT_META|EXPORT_STYLES|EXPORT_CONTENT|EXPORT_SETTINGS;
900 if( (mnExportFlags & nTest) == nTest && !msOrigFileName.getLength() )
901 {
902 // evaluate descriptor only for flat files and if a base URI
903 // has not been provided already
904 const sal_Int32 nPropCount = aDescriptor.getLength();
905 const beans::PropertyValue* pProps = aDescriptor.getConstArray();
906
907 for( sal_Int32 nIndex = 0; nIndex < nPropCount; nIndex++, pProps++ )
908 {
909 const OUString& rPropName = pProps->Name;
910 const Any& rValue = pProps->Value;
911
912 if( rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FileName" ) ) )
913 {
914 if( !(rValue >>= msOrigFileName ) )
915 return sal_False;
916 }
917 else if (rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FilterName" ) ) )
918 {
919 if( !(rValue >>= msFilterName ) )
920 return sal_False;
921 }
922 }
923 }
924
925 #ifdef TIMELOG
926 if (GetModel().is())
927 {
928 // print a trace message with the URL
929 ByteString aUrl( (String) GetModel()->getURL(),
930 RTL_TEXTENCODING_ASCII_US );
931 RTL_LOGFILE_CONTEXT_TRACE1( aLogContext, "%s", aUrl.GetBuffer() );
932
933 // we also want a trace message with the document class
934 ByteString aClass( (String)GetXMLToken(meClass),
935 RTL_TEXTENCODING_ASCII_US );
936 RTL_LOGFILE_CONTEXT_TRACE1( aLogContext, "class=\"%s\"",
937 aClass.GetBuffer() );
938 }
939 #endif
940
941 exportDoc( meClass );
942 }
943 catch( uno::Exception e )
944 {
945 // We must catch exceptions, because according to the
946 // API definition export must not throw one!
947 Sequence<OUString> aSeq(0);
948 SetError( XMLERROR_FLAG_ERROR | XMLERROR_FLAG_SEVERE | XMLERROR_API,
949 aSeq, e.Message, NULL );
950 }
951
952 // return true only if no error occurred
953 return (GetErrorFlags() & (ERROR_DO_NOTHING|ERROR_ERROR_OCCURED)) == 0;
954 }
955
cancel()956 void SAL_CALL SvXMLExport::cancel()
957 {
958 // stop export
959 Sequence<OUString> aEmptySeq;
960 SetError(XMLERROR_CANCEL|XMLERROR_FLAG_SEVERE, aEmptySeq);
961 }
962
getName()963 ::rtl::OUString SAL_CALL SvXMLExport::getName( )
964 {
965 return msFilterName;
966 }
967
setName(const::rtl::OUString &)968 void SAL_CALL SvXMLExport::setName( const ::rtl::OUString& )
969 {
970 // do nothing, because it is not possible to set the FilterName
971 }
972
973
974 // XServiceInfo
getImplementationName()975 OUString SAL_CALL SvXMLExport::getImplementationName( )
976 {
977 OUString aStr;
978 return aStr;
979 }
980
supportsService(const OUString & rServiceName)981 sal_Bool SAL_CALL SvXMLExport::supportsService( const OUString& rServiceName )
982 {
983 return
984 rServiceName.equalsAsciiL(
985 "com.sun.star.document.ExportFilter",
986 sizeof("com.sun.star.document.ExportFilter")-1 ) ||
987 rServiceName.equalsAsciiL(
988 "com.sun.star.xml.XMLExportFilter",
989 sizeof("com.sun.star.xml.XMLExportFilter")-1);
990 }
991
getSupportedServiceNames()992 uno::Sequence< OUString > SAL_CALL SvXMLExport::getSupportedServiceNames( )
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 // <office: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 // <office: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 // <office: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 // <office: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 // <office: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 aElement( *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 {
1446 const sal_Char* pVersion = 0;
1447 switch( getDefaultVersion() )
1448 {
1449 case SvtSaveOptions::ODFVER_013_EXT: pVersion = sXML_1_3; break;
1450 case SvtSaveOptions::ODFVER_013: pVersion = sXML_1_3; break;
1451 case SvtSaveOptions::ODFVER_012_EXT: pVersion = sXML_1_2; break;
1452 case SvtSaveOptions::ODFVER_012: pVersion = sXML_1_2; break;
1453 case SvtSaveOptions::ODFVER_011: pVersion = sXML_1_1; break;
1454 case SvtSaveOptions::ODFVER_010: break;
1455
1456 default:
1457 DBG_ERROR("xmloff::SvXMLExport::exportDoc(), unexpected odf default version!");
1458 }
1459
1460 if( pVersion )
1461 AddAttribute( XML_NAMESPACE_OFFICE, XML_VERSION,
1462 OUString::createFromAscii(pVersion) );
1463 }
1464
1465 {
1466 enum XMLTokenEnum eRootService = XML_TOKEN_INVALID;
1467 const sal_Int32 nExportMode = mnExportFlags & (EXPORT_META|EXPORT_STYLES|EXPORT_CONTENT|EXPORT_SETTINGS);
1468
1469 lcl_AddGrddl(*this, nExportMode);
1470
1471 if( EXPORT_META == nExportMode )
1472 {
1473 // export only meta
1474 eRootService = XML_DOCUMENT_META;
1475 }
1476 else if ( EXPORT_SETTINGS == nExportMode )
1477 {
1478 // export only settings
1479 eRootService = XML_DOCUMENT_SETTINGS;
1480 }
1481 else if( EXPORT_STYLES == nExportMode )
1482 {
1483 // export only styles
1484 eRootService = XML_DOCUMENT_STYLES;
1485 }
1486 else if( EXPORT_CONTENT == nExportMode )
1487 {
1488 // export only content
1489 eRootService = XML_DOCUMENT_CONTENT;
1490 }
1491 else
1492 {
1493 // the good'ol one4all element
1494 eRootService = XML_DOCUMENT;
1495 // office:mimetype = ... (only for stream containing the content)
1496 if( eClass != XML_TOKEN_INVALID )
1497 {
1498 OUString aTmp( RTL_CONSTASCII_USTRINGPARAM("application/vnd.oasis.opendocument.") );
1499 aTmp += GetXMLToken( eClass );
1500 AddAttribute( XML_NAMESPACE_OFFICE, XML_MIMETYPE, aTmp );
1501 }
1502 }
1503
1504 // if( (getExportFlags() & EXPORT_NODOCTYPE) == 0 &&
1505 // xExtHandler.is() )
1506 // {
1507 // OUStringBuffer aDocType(
1508 // GetXMLToken(XML_XML_DOCTYPE_PREFIX).getLength() +
1509 // GetXMLToken(XML_XML_DOCTYPE_SUFFIX).getLength() + 30 );
1510 //
1511 // aDocType.append( GetXMLToken(XML_XML_DOCTYPE_PREFIX) );
1512 // aDocType.append( GetNamespaceMap().GetQNameByKey(
1513 // XML_NAMESPACE_OFFICE, GetXMLToken(eRootService) ) );
1514 // aDocType.append( GetXMLToken(XML_XML_DOCTYPE_SUFFIX) );
1515 // xExtHandler->unknown( aDocType.makeStringAndClear() );
1516 // }
1517
1518 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, eRootService, sal_True, sal_True );
1519
1520 // meta information
1521 if( mnExportFlags & EXPORT_META )
1522 ImplExportMeta();
1523
1524 // settings
1525 if( mnExportFlags & EXPORT_SETTINGS )
1526 ImplExportSettings();
1527
1528 // scripts
1529 if( mnExportFlags & EXPORT_SCRIPTS )
1530 _ExportScripts();
1531
1532 // font declarations
1533 if( mnExportFlags & EXPORT_FONTDECLS )
1534 _ExportFontDecls();
1535
1536 // styles
1537 if( mnExportFlags & EXPORT_STYLES )
1538 ImplExportStyles( sal_False );
1539
1540 // autostyles
1541 if( mnExportFlags & EXPORT_AUTOSTYLES )
1542 ImplExportAutoStyles( sal_False );
1543
1544 // masterstyles
1545 if( mnExportFlags & EXPORT_MASTERSTYLES )
1546 ImplExportMasterStyles( sal_False );
1547
1548 // content
1549 if( mnExportFlags & EXPORT_CONTENT )
1550 ImplExportContent();
1551 }
1552
1553
1554 mxHandler->endDocument();
1555
1556 if( bOwnGraphicResolver )
1557 {
1558 Reference< XComponent > xComp( mxGraphicResolver, UNO_QUERY );
1559 xComp->dispose();
1560 }
1561
1562 if( bOwnEmbeddedResolver )
1563 {
1564 Reference< XComponent > xComp( mxEmbeddedResolver, UNO_QUERY );
1565 xComp->dispose();
1566 }
1567
1568 return 0;
1569 }
1570
ResetNamespaceMap()1571 void SvXMLExport::ResetNamespaceMap()
1572 {
1573 delete mpNamespaceMap; mpNamespaceMap = new SvXMLNamespaceMap;
1574 }
1575
_ExportMeta()1576 void SvXMLExport::_ExportMeta()
1577 {
1578 OUString generator( ::utl::DocInfoHelper::GetGeneratorString() );
1579 Reference< XDocumentPropertiesSupplier > xDocPropsSupplier(mxModel,
1580 UNO_QUERY);
1581 if (xDocPropsSupplier.is()) {
1582 Reference<XDocumentProperties> xDocProps(
1583 xDocPropsSupplier->getDocumentProperties());
1584 if (!xDocProps.is()) throw;
1585 // update generator here
1586 xDocProps->setGenerator(generator);
1587 SvXMLMetaExport * pMeta = new SvXMLMetaExport(*this, xDocProps);
1588 uno::Reference<xml::sax::XDocumentHandler> xMeta(pMeta);
1589 pMeta->Export();
1590 } else {
1591 // office:meta
1592 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_META,
1593 sal_True, sal_True );
1594 {
1595 // BM: #i60323# export generator even if xInfoProp is empty (which is the
1596 // case for charts). The generator does not depend on xInfoProp
1597 SvXMLElementExport anElem( *this, XML_NAMESPACE_META, XML_GENERATOR,
1598 sal_True, sal_True );
1599 Characters(generator);
1600 }
1601 }
1602 }
1603
_ExportScripts()1604 void SvXMLExport::_ExportScripts()
1605 {
1606 SvXMLElementExport aElement( *this, XML_NAMESPACE_OFFICE, XML_SCRIPTS, sal_True, sal_True );
1607
1608 // export Basic macros (only for FlatXML)
1609 if ( mnExportFlags & EXPORT_EMBEDDED )
1610 {
1611 ::rtl::OUString aValue( GetNamespaceMap().GetPrefixByKey( XML_NAMESPACE_OOO ) );
1612 aValue += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":Basic" ) );
1613 AddAttribute( XML_NAMESPACE_SCRIPT, XML_LANGUAGE, aValue );
1614
1615 SvXMLElementExport aElem( *this, XML_NAMESPACE_OFFICE, XML_SCRIPT, sal_True, sal_True );
1616
1617 // initialize Basic
1618 if ( mxModel.is() )
1619 {
1620 Reference< beans::XPropertySet > xPSet( mxModel, UNO_QUERY );
1621 if ( xPSet.is() )
1622 xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) );
1623 }
1624
1625 Reference< document::XExporter > xExporter;
1626 Reference< lang::XMultiServiceFactory > xMSF( getServiceFactory() );
1627 if ( xMSF.is() )
1628 {
1629 Reference < XDocumentHandler > xHdl( new XMLBasicExportFilter( mxHandler ) );
1630 Sequence < Any > aArgs( 1 );
1631 aArgs[0] <<= xHdl;
1632 xExporter.set( xMSF->createInstanceWithArguments(
1633 OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.XMLOasisBasicExporter" ) ), aArgs ),
1634 UNO_QUERY );
1635 }
1636
1637 OSL_ENSURE( xExporter.is(),
1638 "SvXMLExport::_ExportScripts: can't instantiate export filter component for Basic macros" );
1639
1640 if ( xExporter.is() )
1641 {
1642 Reference< XComponent > xComp( mxModel, UNO_QUERY );
1643 xExporter->setSourceDocument( xComp );
1644 Reference< XFilter > xFilter( xExporter, UNO_QUERY );
1645 if ( xFilter.is() )
1646 {
1647 Sequence < PropertyValue > aMediaDesc( 0 );
1648 xFilter->filter( aMediaDesc );
1649 }
1650 }
1651 }
1652
1653 // export document events
1654 Reference< document::XEventsSupplier > xEvents( GetModel(), UNO_QUERY );
1655 GetEventExport().Export( xEvents, sal_True );
1656 }
1657
_ExportFontDecls()1658 void SvXMLExport::_ExportFontDecls()
1659 {
1660 if( mxFontAutoStylePool.is() )
1661 mxFontAutoStylePool->exportXML();
1662 }
1663
_ExportStyles(sal_Bool)1664 void SvXMLExport::_ExportStyles( sal_Bool )
1665 {
1666 uno::Reference< lang::XMultiServiceFactory > xFact( GetModel(), uno::UNO_QUERY );
1667 if( xFact.is())
1668 {
1669 // export (fill-)gradient-styles
1670 try
1671 {
1672 uno::Reference< container::XNameAccess > xGradient( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable") ) ), uno::UNO_QUERY );
1673 if( xGradient.is() )
1674 {
1675 XMLGradientStyleExport aGradientStyle( *this );
1676
1677 if( xGradient->hasElements() )
1678 {
1679 uno::Sequence< OUString > aNamesSeq ( xGradient->getElementNames() );
1680 sal_Int32 nCount = aNamesSeq.getLength();
1681 for( sal_Int32 i=0; i<nCount; i++ )
1682 {
1683 const OUString& rStrName = aNamesSeq[ i ];
1684
1685 try
1686 {
1687 uno::Any aValue = xGradient->getByName( rStrName );
1688
1689 aGradientStyle.exportXML( rStrName, aValue );
1690 }
1691 catch( container::NoSuchElementException& )
1692 {}
1693 }
1694 }
1695 }
1696 }
1697 catch( lang::ServiceNotRegisteredException& )
1698 {}
1699
1700 // export (fill-)hatch-styles
1701 try
1702 {
1703 uno::Reference< container::XNameAccess > xHatch( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable") ) ), uno::UNO_QUERY );
1704 if( xHatch.is() )
1705 {
1706 XMLHatchStyleExport aHatchStyle( *this );
1707
1708 if( xHatch->hasElements() )
1709 {
1710 uno::Sequence< OUString > aNamesSeq ( xHatch->getElementNames() );
1711 sal_Int32 nCount = aNamesSeq.getLength();
1712 for( sal_Int32 i=0; i<nCount; i++ )
1713 {
1714 const OUString& rStrName = aNamesSeq[ i ];
1715
1716 try
1717 {
1718 uno::Any aValue = xHatch->getByName( rStrName );
1719
1720 aHatchStyle.exportXML( rStrName, aValue );
1721 }
1722 catch( container::NoSuchElementException& )
1723 {}
1724 }
1725 }
1726 }
1727 }
1728 catch( lang::ServiceNotRegisteredException& )
1729 {}
1730
1731 // export (fill-)bitmap-styles
1732 try
1733 {
1734 uno::Reference< container::XNameAccess > xBitmap( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable") ) ), uno::UNO_QUERY );
1735 if( xBitmap.is() )
1736 {
1737 XMLImageStyle aImageStyle;
1738
1739 if( xBitmap->hasElements() )
1740 {
1741 uno::Sequence< OUString > aNamesSeq ( xBitmap->getElementNames() );
1742 sal_Int32 nCount = aNamesSeq.getLength();
1743 for( sal_Int32 i=0; i<nCount; i++ )
1744 {
1745 const OUString& rStrName = aNamesSeq[ i ];
1746
1747 try
1748 {
1749 uno::Any aValue = xBitmap->getByName( rStrName );
1750
1751 aImageStyle.exportXML( rStrName, aValue, *this );
1752 }
1753 catch( container::NoSuchElementException& )
1754 {}
1755 }
1756 }
1757 }
1758 }
1759 catch( lang::ServiceNotRegisteredException& )
1760 {}
1761
1762 // export transparency-gradient -styles
1763 try
1764 {
1765 uno::Reference< container::XNameAccess > xTransGradient( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) ), uno::UNO_QUERY );
1766 if( xTransGradient.is() )
1767 {
1768 XMLTransGradientStyleExport aTransGradientstyle( *this );
1769
1770 if( xTransGradient->hasElements() )
1771 {
1772 uno::Sequence< OUString > aNamesSeq ( xTransGradient->getElementNames() );
1773 sal_Int32 nCount = aNamesSeq.getLength();
1774 for( sal_Int32 i=0; i<nCount; i++ )
1775 {
1776 const OUString& rStrName = aNamesSeq[ i ];
1777
1778 try
1779 {
1780 uno::Any aValue = xTransGradient->getByName( rStrName );
1781
1782 aTransGradientstyle.exportXML( rStrName, aValue );
1783 }
1784 catch( container::NoSuchElementException& )
1785 {}
1786 }
1787 }
1788 }
1789 }
1790 catch( lang::ServiceNotRegisteredException& )
1791 {}
1792
1793 // export marker-styles
1794 try
1795 {
1796 uno::Reference< container::XNameAccess > xMarker( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable") ) ), uno::UNO_QUERY );
1797 if( xMarker.is() )
1798 {
1799 XMLMarkerStyleExport aMarkerStyle( *this );
1800
1801 if( xMarker->hasElements() )
1802 {
1803 uno::Sequence< OUString > aNamesSeq ( xMarker->getElementNames() );
1804 sal_Int32 nCount = aNamesSeq.getLength();
1805 for( sal_Int32 i=0; i<nCount; i++ )
1806 {
1807 const OUString& rStrName = aNamesSeq[ i ];
1808
1809 try
1810 {
1811 uno::Any aValue = xMarker->getByName( rStrName );
1812
1813 aMarkerStyle.exportXML( rStrName, aValue );
1814 }
1815 catch( container::NoSuchElementException& )
1816 {}
1817 }
1818 }
1819 }
1820 }
1821 catch( lang::ServiceNotRegisteredException& )
1822 {}
1823
1824 // export dash-styles
1825 try
1826 {
1827 uno::Reference< container::XNameAccess > xDashes( xFact->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable") ) ), uno::UNO_QUERY );
1828 if( xDashes.is() )
1829 {
1830 XMLDashStyleExport aDashStyle( *this );
1831
1832 if( xDashes->hasElements() )
1833 {
1834 uno::Sequence< OUString > aNamesSeq ( xDashes->getElementNames() );
1835 sal_Int32 nCount = aNamesSeq.getLength();
1836 for( sal_Int32 i=0; i<nCount; i++ )
1837 {
1838 const OUString& rStrName = aNamesSeq[ i ];
1839
1840 try
1841 {
1842 uno::Any aValue = xDashes->getByName( rStrName );
1843
1844 aDashStyle.exportXML( rStrName, aValue );
1845 }
1846 catch( container::NoSuchElementException& )
1847 {}
1848 }
1849 }
1850 }
1851 }
1852 catch( lang::ServiceNotRegisteredException& )
1853 {}
1854 }
1855 }
1856
CreateTextParagraphExport()1857 XMLTextParagraphExport* SvXMLExport::CreateTextParagraphExport()
1858 {
1859 return new XMLTextParagraphExport( *this, *(GetAutoStylePool().get()) );
1860 }
1861
CreateShapeExport()1862 XMLShapeExport* SvXMLExport::CreateShapeExport()
1863 {
1864 return new XMLShapeExport(*this);
1865 }
1866
CreateAutoStylePool()1867 SvXMLAutoStylePoolP* SvXMLExport::CreateAutoStylePool()
1868 {
1869 return new SvXMLAutoStylePoolP(*this);
1870 }
1871
CreatePageExport()1872 XMLPageExport* SvXMLExport::CreatePageExport()
1873 {
1874 return new XMLPageExport( *this );
1875 }
1876
CreateChartExport()1877 SchXMLExportHelper* SvXMLExport::CreateChartExport()
1878 {
1879 return new SchXMLExportHelper(*this,*GetAutoStylePool().get());
1880 }
1881
CreateFontAutoStylePool()1882 XMLFontAutoStylePool* SvXMLExport::CreateFontAutoStylePool()
1883 {
1884 return new XMLFontAutoStylePool( *this );
1885 }
1886
CreateFormExport()1887 xmloff::OFormLayerXMLExport* SvXMLExport::CreateFormExport()
1888 {
1889 return new xmloff::OFormLayerXMLExport(*this);
1890 }
1891
GetViewSettingsAndViews(uno::Sequence<beans::PropertyValue> & rProps)1892 void SvXMLExport::GetViewSettingsAndViews(uno::Sequence<beans::PropertyValue>& rProps)
1893 {
1894 GetViewSettings(rProps);
1895 uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetModel(), uno::UNO_QUERY);
1896 if(xViewDataSupplier.is())
1897 {
1898 uno::Reference<container::XIndexAccess> xIndexAccess;
1899 xViewDataSupplier->setViewData( xIndexAccess ); // make sure we get a newly created sequence
1900 xIndexAccess = xViewDataSupplier->getViewData();
1901 sal_Bool bAdd = sal_False;
1902 uno::Any aAny;
1903 if(xIndexAccess.is() && xIndexAccess->hasElements() )
1904 {
1905 sal_Int32 nCount = xIndexAccess->getCount();
1906 for (sal_Int32 i = 0; i < nCount; i++)
1907 {
1908 aAny = xIndexAccess->getByIndex(i);
1909 uno::Sequence<beans::PropertyValue> aProps;
1910 if( aAny >>= aProps )
1911 {
1912 if( aProps.getLength() > 0 )
1913 {
1914 bAdd = sal_True;
1915 break;
1916 }
1917 }
1918 }
1919 }
1920
1921 if( bAdd )
1922 {
1923 sal_Int32 nOldLength(rProps.getLength());
1924 rProps.realloc(nOldLength + 1);
1925 beans::PropertyValue aProp;
1926 aProp.Name = OUString(RTL_CONSTASCII_USTRINGPARAM("Views"));
1927 aProp.Value <<= xIndexAccess;
1928 rProps[nOldLength] = aProp;
1929 }
1930 }
1931 }
1932
GetViewSettings(uno::Sequence<beans::PropertyValue> &)1933 void SvXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>&)
1934 {
1935 }
1936
GetConfigurationSettings(uno::Sequence<beans::PropertyValue> &)1937 void SvXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>&)
1938 {
1939 }
1940
GetDocumentSpecificSettings(::std::list<SettingsGroup> & _out_rSettings)1941 sal_Int32 SvXMLExport::GetDocumentSpecificSettings( ::std::list< SettingsGroup >& _out_rSettings )
1942 {
1943 (void)_out_rSettings;
1944 return 0;
1945 }
1946
addDataStyle(const sal_Int32 nNumberFormat,sal_Bool)1947 void SvXMLExport::addDataStyle(const sal_Int32 nNumberFormat, sal_Bool /*bTimeFormat*/ )
1948 {
1949 if(mpNumExport)
1950 mpNumExport->SetUsed(nNumberFormat);
1951 }
1952
exportDataStyles()1953 void SvXMLExport::exportDataStyles()
1954 {
1955 if(mpNumExport)
1956 mpNumExport->Export(sal_False);
1957 }
1958
exportAutoDataStyles()1959 void SvXMLExport::exportAutoDataStyles()
1960 {
1961 if(mpNumExport)
1962 mpNumExport->Export(sal_True);
1963
1964 if (mxFormExport.is())
1965 mxFormExport->exportAutoControlNumberStyles();
1966 }
1967
getDataStyleName(const sal_Int32 nNumberFormat,sal_Bool) const1968 OUString SvXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, sal_Bool /*bTimeFormat*/ ) const
1969 {
1970 OUString sTemp;
1971 if(mpNumExport)
1972 sTemp = mpNumExport->GetStyleName(nNumberFormat);
1973 return sTemp;
1974 }
1975
exportAnnotationMeta(const uno::Reference<drawing::XShape> &)1976 void SvXMLExport::exportAnnotationMeta(const uno::Reference<drawing::XShape>&)
1977 {
1978 }
1979
dataStyleForceSystemLanguage(sal_Int32 nFormat) const1980 sal_Int32 SvXMLExport::dataStyleForceSystemLanguage(sal_Int32 nFormat) const
1981 {
1982 return ( mpNumExport != NULL )
1983 ? mpNumExport->ForceSystemLanguage( nFormat ) : nFormat;
1984 }
1985
1986
AddEmbeddedGraphicObject(const OUString & rGraphicObjectURL)1987 OUString SvXMLExport::AddEmbeddedGraphicObject( const OUString& rGraphicObjectURL )
1988 {
1989 OUString sRet( rGraphicObjectURL );
1990 if( 0 == rGraphicObjectURL.compareTo( msGraphicObjectProtocol,
1991 msGraphicObjectProtocol.getLength() ) &&
1992 mxGraphicResolver.is() )
1993 {
1994 if( (getExportFlags() & EXPORT_EMBEDDED) == 0 )
1995 sRet = mxGraphicResolver->resolveGraphicObjectURL( rGraphicObjectURL );
1996 else
1997 sRet = OUString();
1998 }
1999 else
2000 sRet = GetRelativeReference( sRet );
2001
2002 return sRet;
2003 }
2004
AddEmbeddedGraphicObjectAsBase64(const OUString & rGraphicObjectURL)2005 sal_Bool SvXMLExport::AddEmbeddedGraphicObjectAsBase64( const OUString& rGraphicObjectURL )
2006 {
2007 sal_Bool bRet = sal_False;
2008
2009 if( (getExportFlags() & EXPORT_EMBEDDED) != 0 &&
2010 0 == rGraphicObjectURL.compareTo( msGraphicObjectProtocol,
2011 msGraphicObjectProtocol.getLength() ) &&
2012 mxGraphicResolver.is() )
2013 {
2014 Reference< XBinaryStreamResolver > xStmResolver( mxGraphicResolver, UNO_QUERY );
2015
2016 if( xStmResolver.is() )
2017 {
2018 Reference< XInputStream > xIn( xStmResolver->getInputStream( rGraphicObjectURL ) );
2019
2020 if( xIn.is() )
2021 {
2022 XMLBase64Export aBase64Exp( *this );
2023 bRet = aBase64Exp.exportOfficeBinaryDataElement( xIn );
2024 }
2025 }
2026 }
2027
2028 return bRet;
2029 }
2030
AddEmbeddedObject(const OUString & rEmbeddedObjectURL)2031 OUString SvXMLExport::AddEmbeddedObject( const OUString& rEmbeddedObjectURL )
2032 {
2033 OUString sRet;
2034 if( (0 == rEmbeddedObjectURL.compareTo( msEmbeddedObjectProtocol,
2035 msEmbeddedObjectProtocol.getLength() ) ||
2036 0 == rEmbeddedObjectURL.compareTo( msGraphicObjectProtocol,
2037 msGraphicObjectProtocol.getLength() ) ) &&
2038 mxEmbeddedResolver.is() )
2039 {
2040 sRet =
2041 mxEmbeddedResolver->resolveEmbeddedObjectURL( rEmbeddedObjectURL );
2042 }
2043 else
2044 sRet = GetRelativeReference( rEmbeddedObjectURL );
2045
2046 return sRet;
2047 }
2048
AddEmbeddedObjectAsBase64(const OUString & rEmbeddedObjectURL)2049 sal_Bool SvXMLExport::AddEmbeddedObjectAsBase64( const OUString& rEmbeddedObjectURL )
2050 {
2051 sal_Bool bRet = sal_False;
2052 if( (0 == rEmbeddedObjectURL.compareTo( msEmbeddedObjectProtocol,
2053 msEmbeddedObjectProtocol.getLength() ) ||
2054 0 == rEmbeddedObjectURL.compareTo( msGraphicObjectProtocol,
2055 msGraphicObjectProtocol.getLength() ) ) &&
2056 mxEmbeddedResolver.is() )
2057 {
2058 Reference < XNameAccess > xNA( mxEmbeddedResolver, UNO_QUERY );
2059 if( xNA.is() )
2060 {
2061 Any aAny = xNA->getByName( rEmbeddedObjectURL );
2062 Reference < XInputStream > xIn;
2063 aAny >>= xIn;
2064 if( xIn.is() )
2065 {
2066 XMLBase64Export aBase64Exp( *this );
2067 bRet = aBase64Exp.exportOfficeBinaryDataElement( xIn );
2068 }
2069 }
2070 }
2071
2072 return bRet;
2073 }
2074
EncodeStyleName(const OUString & rName,sal_Bool * pEncoded) const2075 OUString SvXMLExport::EncodeStyleName(
2076 const OUString& rName,
2077 sal_Bool *pEncoded ) const
2078 {
2079 return GetMM100UnitConverter().encodeStyleName( rName, pEncoded );
2080 }
2081
GetProgressBarHelper()2082 ProgressBarHelper* SvXMLExport::GetProgressBarHelper()
2083 {
2084 if (!mpProgressBarHelper)
2085 {
2086 mpProgressBarHelper = new ProgressBarHelper(mxStatusIndicator, sal_True);
2087
2088 if (mxExportInfo.is())
2089 {
2090 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo();
2091 if (xPropertySetInfo.is())
2092 {
2093 OUString sProgressRange(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSRANGE));
2094 OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSMAX));
2095 OUString sProgressCurrent(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSCURRENT));
2096 OUString sRepeat(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSREPEAT));
2097 if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
2098 xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
2099 xPropertySetInfo->hasPropertyByName(sProgressRange))
2100 {
2101 uno::Any aAny;
2102 sal_Int32 nProgressMax(0);
2103 sal_Int32 nProgressCurrent(0);
2104 sal_Int32 nProgressRange(0);
2105 aAny = mxExportInfo->getPropertyValue(sProgressRange);
2106 if (aAny >>= nProgressRange)
2107 mpProgressBarHelper->SetRange(nProgressRange);
2108 aAny = mxExportInfo->getPropertyValue(sProgressMax);
2109 if (aAny >>= nProgressMax)
2110 mpProgressBarHelper->SetReference(nProgressMax);
2111 aAny = mxExportInfo->getPropertyValue(sProgressCurrent);
2112 if (aAny >>= nProgressCurrent)
2113 mpProgressBarHelper->SetValue(nProgressCurrent);
2114 }
2115 if (xPropertySetInfo->hasPropertyByName(sRepeat))
2116 {
2117 uno::Any aAny = mxExportInfo->getPropertyValue(sRepeat);
2118 if (aAny.getValueType() == getBooleanCppuType())
2119 mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
2120 else {
2121 DBG_ERRORFILE("why is it no boolean?");
2122 }
2123 }
2124 }
2125 }
2126 }
2127 return mpProgressBarHelper;
2128 }
2129
GetEventExport()2130 XMLEventExport& SvXMLExport::GetEventExport()
2131 {
2132 if( NULL == mpEventExport)
2133 {
2134 // create EventExport on demand
2135 mpEventExport = new XMLEventExport(*this, NULL);
2136
2137 // and register standard handlers + names
2138 OUString sStarBasic(RTL_CONSTASCII_USTRINGPARAM("StarBasic"));
2139 mpEventExport->AddHandler(sStarBasic, new XMLStarBasicExportHandler());
2140 OUString sScript(RTL_CONSTASCII_USTRINGPARAM("Script"));
2141 mpEventExport->AddHandler(sScript, new XMLScriptExportHandler());
2142 mpEventExport->AddTranslationTable(aStandardEventTable);
2143 }
2144
2145 return *mpEventExport;
2146 }
2147
GetImageMapExport()2148 XMLImageMapExport& SvXMLExport::GetImageMapExport()
2149 {
2150 // image map export, create on-demand
2151 if( NULL == mpImageMapExport )
2152 {
2153 mpImageMapExport = new XMLImageMapExport(*this);
2154 }
2155
2156 return *mpImageMapExport;
2157 }
2158
2159 // XUnoTunnel & co
getUnoTunnelId()2160 const uno::Sequence< sal_Int8 > & SvXMLExport::getUnoTunnelId() throw()
2161 {
2162 static uno::Sequence< sal_Int8 > * pSeq = 0;
2163 if( !pSeq )
2164 {
2165 Guard< Mutex > aGuard( Mutex::getGlobalMutex() );
2166 if( !pSeq )
2167 {
2168 static uno::Sequence< sal_Int8 > aSeq( 16 );
2169 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
2170 pSeq = &aSeq;
2171 }
2172 }
2173 return *pSeq;
2174 }
2175
getImplementation(uno::Reference<uno::XInterface> xInt)2176 SvXMLExport* SvXMLExport::getImplementation( uno::Reference< uno::XInterface > xInt ) throw()
2177 {
2178 uno::Reference< lang::XUnoTunnel > xUT( xInt, uno::UNO_QUERY );
2179 if( xUT.is() )
2180 {
2181 return
2182 reinterpret_cast<SvXMLExport*>(
2183 sal::static_int_cast<sal_IntPtr>(
2184 xUT->getSomething( SvXMLExport::getUnoTunnelId())));
2185 }
2186 else
2187 return NULL;
2188 }
2189
2190 // XUnoTunnel
getSomething(const uno::Sequence<sal_Int8> & rId)2191 sal_Int64 SAL_CALL SvXMLExport::getSomething( const uno::Sequence< sal_Int8 >& rId )
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 /* vim: set noet sw=4 ts=4: */
2774