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