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