xref: /AOO41X/main/xmloff/source/core/xmlimp.cxx (revision a5258243accf51c522d45cf65e4b16cb17a336f7)
1cdf0e10cSrcweir /*************************************************************************
2cdf0e10cSrcweir  *
3cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4cdf0e10cSrcweir  *
5cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6cdf0e10cSrcweir  *
7cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8cdf0e10cSrcweir  *
9cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10cdf0e10cSrcweir  *
11cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14cdf0e10cSrcweir  *
15cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20cdf0e10cSrcweir  *
21cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25cdf0e10cSrcweir  *
26cdf0e10cSrcweir  ************************************************************************/
27cdf0e10cSrcweir 
28cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
30cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp>
31cdf0e10cSrcweir #include <tools/debug.hxx>
32cdf0e10cSrcweir #include <tools/urlobj.hxx>
33cdf0e10cSrcweir #include <osl/mutex.hxx>
34cdf0e10cSrcweir #include <rtl/uuid.h>
35cdf0e10cSrcweir #include <rtl/memory.h>
36cdf0e10cSrcweir #include <svl/svarray.hxx>
37cdf0e10cSrcweir #include "unointerfacetouniqueidentifiermapper.hxx"
38cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
39cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
40cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
41cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
42cdf0e10cSrcweir #include <xmloff/XMLFontStylesContext.hxx>
43cdf0e10cSrcweir #include <xmloff/xmlictxt.hxx>
44cdf0e10cSrcweir #include <xmloff/xmlimp.hxx>
45cdf0e10cSrcweir #include <xmloff/xmlnumfi.hxx>
46cdf0e10cSrcweir #include "XMLEventImportHelper.hxx"
47cdf0e10cSrcweir #include "XMLStarBasicContextFactory.hxx"
48cdf0e10cSrcweir #include "XMLScriptContextFactory.hxx"
49cdf0e10cSrcweir #include "StyleMap.hxx"
50cdf0e10cSrcweir #include <xmloff/ProgressBarHelper.hxx>
51cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
52cdf0e10cSrcweir #include "xmloff/xmlerror.hxx"
53cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
54cdf0e10cSrcweir #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
55cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
56cdf0e10cSrcweir #include <com/sun/star/document/XBinaryStreamResolver.hpp>
57cdf0e10cSrcweir #include <com/sun/star/document/XStorageBasedDocument.hpp>
58cdf0e10cSrcweir #include <com/sun/star/xml/sax/XLocator.hpp>
59cdf0e10cSrcweir #include <com/sun/star/packages/zip/ZipIOException.hpp>
60cdf0e10cSrcweir #include <comphelper/namecontainer.hxx>
61cdf0e10cSrcweir #include <rtl/logfile.hxx>
62cdf0e10cSrcweir #include <tools/string.hxx> // used in StartElement for logging
63cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
64cdf0e10cSrcweir #include <comphelper/extract.hxx>
65cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
66cdf0e10cSrcweir #include <comphelper/documentconstants.hxx>
67cdf0e10cSrcweir #include <comphelper/storagehelper.hxx>
68cdf0e10cSrcweir #include <unotools/fontcvt.hxx>
69cdf0e10cSrcweir 
70cdf0e10cSrcweir #include <com/sun/star/rdf/XMetadatable.hpp>
71cdf0e10cSrcweir #include <com/sun/star/rdf/XRepositorySupplier.hpp>
72cdf0e10cSrcweir #include "RDFaImportHelper.hxx"
73cdf0e10cSrcweir 
74cdf0e10cSrcweir #define LOGFILE_AUTHOR "unknown"
75cdf0e10cSrcweir 
76cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySetInfo;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir using ::rtl::OUString;
79cdf0e10cSrcweir using ::rtl::OUStringBuffer;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir using namespace ::osl;
82cdf0e10cSrcweir using namespace ::com::sun::star;
83cdf0e10cSrcweir using namespace ::com::sun::star::frame;
84cdf0e10cSrcweir using namespace ::com::sun::star::uno;
85cdf0e10cSrcweir using namespace ::com::sun::star::util;
86cdf0e10cSrcweir using namespace ::com::sun::star::io;
87cdf0e10cSrcweir using namespace ::com::sun::star::container;
88cdf0e10cSrcweir using namespace ::com::sun::star::document;
89cdf0e10cSrcweir using namespace ::xmloff::token;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__office[] = "_office";
92cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__office_ext[] = "_office_ooo";
93cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__ooo[] = "_ooo";
94cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__ooow[] = "_ooow";
95cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__oooc[] = "_oooc";
96cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__of[] = "_of";
97cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__style[] = "_style";
98cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__text[] = "_text";
99cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__table[] = "_table";
100cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__table_ext[] = "_table_ooo";
101cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__draw[] = "_draw";
102cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__draw_ext[] = "_draw_ooo";
103cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__dr3d[] = "_dr3d";
104cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__fo[] = "_fo";
105cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__xlink[] = "_xlink";
106cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__dc[] = "_dc";
107cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__dom[] = "_dom";
108cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__meta[] = "_meta";
109cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__number[] = "_number";
110cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__svg[] = "_svg";
111cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__chart[] = "_chart";
112cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__math[] = "_math";
113cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__form[] = "_form";
114cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__script[] = "_script";
115cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__config[] = "_config";
116cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__db[] = "_db";
117cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__xforms[] = "_xforms";
118cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__xsd[] = "_xsd";
119cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__xsi[] = "_xsi";
120cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__field[] = "_field";
121cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__xhtml[] = "_xhtml";
122cdf0e10cSrcweir 
123cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__fo_old[] = "__fo";
124cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__xlink_old[] = "__xlink";
125cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__office_old[] = "__office";
126cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__style_old[] = "__style";
127cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__text_old[] = "__text";
128cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__table_old[] = "__table";
129cdf0e10cSrcweir sal_Char __READONLY_DATA sXML_np__meta_old[] = "__meta";
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 
133cdf0e10cSrcweir class SvXMLImportEventListener : public cppu::WeakImplHelper1<
134cdf0e10cSrcweir 							com::sun::star::lang::XEventListener >
135cdf0e10cSrcweir {
136cdf0e10cSrcweir private:
137cdf0e10cSrcweir 	SvXMLImport*	pImport;
138cdf0e10cSrcweir 
139cdf0e10cSrcweir public:
140cdf0e10cSrcweir 							SvXMLImportEventListener(SvXMLImport* pImport);
141cdf0e10cSrcweir 	virtual					~SvXMLImportEventListener();
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 							// XEventListener
144cdf0e10cSrcweir 	virtual void SAL_CALL disposing(const lang::EventObject& rEventObject) throw(::com::sun::star::uno::RuntimeException);
145cdf0e10cSrcweir };
146cdf0e10cSrcweir 
147cdf0e10cSrcweir SvXMLImportEventListener::SvXMLImportEventListener(SvXMLImport* pTempImport)
148cdf0e10cSrcweir 	: pImport(pTempImport)
149cdf0e10cSrcweir {
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
152cdf0e10cSrcweir SvXMLImportEventListener::~SvXMLImportEventListener()
153cdf0e10cSrcweir {
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir // XEventListener
157cdf0e10cSrcweir void SAL_CALL SvXMLImportEventListener::disposing( const lang::EventObject& )
158cdf0e10cSrcweir 	throw(uno::RuntimeException)
159cdf0e10cSrcweir {
160cdf0e10cSrcweir 	if (pImport)
161cdf0e10cSrcweir 	{
162cdf0e10cSrcweir 		pImport->DisposingModel();
163cdf0e10cSrcweir 		pImport = NULL;
164cdf0e10cSrcweir 	}
165cdf0e10cSrcweir }
166cdf0e10cSrcweir 
167cdf0e10cSrcweir //==============================================================================
168*a5258243SPedro Giffuni // --> ORW
169*a5258243SPedro Giffuni namespace
170*a5258243SPedro Giffuni {
171*a5258243SPedro Giffuni     class DocumentInfo
172*a5258243SPedro Giffuni     {
173*a5258243SPedro Giffuni         private:
174*a5258243SPedro Giffuni             sal_uInt16 mnGeneratorVersion;
175*a5258243SPedro Giffuni 
176*a5258243SPedro Giffuni         public:
177*a5258243SPedro Giffuni             DocumentInfo( const SvXMLImport& rImport )
178*a5258243SPedro Giffuni                 : mnGeneratorVersion( SvXMLImport::ProductVersionUnknown )
179*a5258243SPedro Giffuni             {
180*a5258243SPedro Giffuni                 sal_Int32 nUPD, nBuild;
181*a5258243SPedro Giffuni                 if ( rImport.getBuildIds( nUPD, nBuild ) )
182*a5258243SPedro Giffuni                 {
183*a5258243SPedro Giffuni                     if ( nUPD >= 640 && nUPD <= 645 )
184*a5258243SPedro Giffuni                     {
185*a5258243SPedro Giffuni                         mnGeneratorVersion = SvXMLImport::OOo_1x;
186*a5258243SPedro Giffuni                     }
187*a5258243SPedro Giffuni                     else if ( nUPD == 680 )
188*a5258243SPedro Giffuni                     {
189*a5258243SPedro Giffuni                         mnGeneratorVersion = SvXMLImport::OOo_2x;
190*a5258243SPedro Giffuni                     }
191*a5258243SPedro Giffuni                     else if ( nUPD == 300 && nBuild <= 9379 )
192*a5258243SPedro Giffuni                     {
193*a5258243SPedro Giffuni                         mnGeneratorVersion = SvXMLImport::OOo_30x;
194*a5258243SPedro Giffuni                     }
195*a5258243SPedro Giffuni                     else if ( nUPD == 310 )
196*a5258243SPedro Giffuni                     {
197*a5258243SPedro Giffuni                         mnGeneratorVersion = SvXMLImport::OOo_31x;
198*a5258243SPedro Giffuni                     }
199*a5258243SPedro Giffuni                     else if ( nUPD == 320 )
200*a5258243SPedro Giffuni                     {
201*a5258243SPedro Giffuni                         mnGeneratorVersion = SvXMLImport::OOo_32x;
202*a5258243SPedro Giffuni                     }
203*a5258243SPedro Giffuni                     else if ( nUPD == 330 )
204*a5258243SPedro Giffuni                     {
205*a5258243SPedro Giffuni                         mnGeneratorVersion = SvXMLImport::OOo_33x;
206*a5258243SPedro Giffuni                     }
207*a5258243SPedro Giffuni                     else if ( nUPD == 340 )
208*a5258243SPedro Giffuni                     {
209*a5258243SPedro Giffuni                         mnGeneratorVersion = SvXMLImport::OOo_34x;
210*a5258243SPedro Giffuni                     }
211*a5258243SPedro Giffuni                 }
212*a5258243SPedro Giffuni             }
213*a5258243SPedro Giffuni 
214*a5258243SPedro Giffuni             ~DocumentInfo()
215*a5258243SPedro Giffuni             {}
216*a5258243SPedro Giffuni 
217*a5258243SPedro Giffuni             const sal_uInt16 getGeneratorVersion() const
218*a5258243SPedro Giffuni             {
219*a5258243SPedro Giffuni                 return mnGeneratorVersion;
220*a5258243SPedro Giffuni             }
221*a5258243SPedro Giffuni     };
222*a5258243SPedro Giffuni }
223*a5258243SPedro Giffuni // <--
224cdf0e10cSrcweir 
225cdf0e10cSrcweir class SvXMLImport_Impl
226cdf0e10cSrcweir {
227cdf0e10cSrcweir public:
228cdf0e10cSrcweir 	FontToSubsFontConverter hBatsFontConv;
229cdf0e10cSrcweir 	FontToSubsFontConverter hMathFontConv;
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 	bool mbOwnGraphicResolver;
232cdf0e10cSrcweir 	bool mbOwnEmbeddedResolver;
233cdf0e10cSrcweir 	INetURLObject aBaseURL;
234cdf0e10cSrcweir     INetURLObject aDocBase;
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     /// name of stream in package, e.g., "content.xml"
237cdf0e10cSrcweir     ::rtl::OUString mStreamName;
238cdf0e10cSrcweir 
239cdf0e10cSrcweir     ::rtl::OUString aODFVersion;
240cdf0e10cSrcweir 
241cdf0e10cSrcweir     // --> OD 2004-08-10 #i28749# - boolean, indicating that position attributes
242cdf0e10cSrcweir     // of shapes are given in horizontal left-to-right layout. This is the case
243cdf0e10cSrcweir     // for the OpenOffice.org file format.
244cdf0e10cSrcweir     sal_Bool mbShapePositionInHoriL2R;
245cdf0e10cSrcweir     // <--
246cdf0e10cSrcweir     // --> OD 2007-12-19 #152540#
247cdf0e10cSrcweir     sal_Bool mbTextDocInOOoFileFormat;
248cdf0e10cSrcweir     // <--
249cdf0e10cSrcweir 
250cdf0e10cSrcweir     const uno::Reference< uno::XComponentContext > mxComponentContext;
251cdf0e10cSrcweir 
252cdf0e10cSrcweir     std::auto_ptr< xmloff::RDFaImportHelper > mpRDFaHelper;
253cdf0e10cSrcweir 
254*a5258243SPedro Giffuni     // --> ORW
255*a5258243SPedro Giffuni     std::auto_ptr< DocumentInfo > mpDocumentInfo;
256cdf0e10cSrcweir     // <--
257*a5258243SPedro Giffuni 
258*a5258243SPedro Giffuni     SvXMLImport_Impl()
259*a5258243SPedro Giffuni         : hBatsFontConv( 0 )
260*a5258243SPedro Giffuni         , hMathFontConv( 0 )
261*a5258243SPedro Giffuni         , mbOwnGraphicResolver( false )
262*a5258243SPedro Giffuni         , mbOwnEmbeddedResolver( false )
263*a5258243SPedro Giffuni         , mStreamName()
264*a5258243SPedro Giffuni         , mbShapePositionInHoriL2R( sal_False )
265*a5258243SPedro Giffuni         , mbTextDocInOOoFileFormat( sal_False )
266*a5258243SPedro Giffuni         , mxComponentContext( ::comphelper::getProcessComponentContext() )
267*a5258243SPedro Giffuni         , mpRDFaHelper() // lazy
268*a5258243SPedro Giffuni         // --> ORW
269*a5258243SPedro Giffuni         , mpDocumentInfo() // lazy
270cdf0e10cSrcweir         // <--
271cdf0e10cSrcweir     {
272cdf0e10cSrcweir         OSL_ENSURE(mxComponentContext.is(), "SvXMLImport: no ComponentContext");
273cdf0e10cSrcweir         if (!mxComponentContext.is()) throw uno::RuntimeException();
274cdf0e10cSrcweir     }
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	~SvXMLImport_Impl()
277cdf0e10cSrcweir 	{
278cdf0e10cSrcweir 		if( hBatsFontConv )
279cdf0e10cSrcweir 			DestroyFontToSubsFontConverter( hBatsFontConv );
280cdf0e10cSrcweir 		if( hMathFontConv )
281cdf0e10cSrcweir 			DestroyFontToSubsFontConverter( hMathFontConv );
282cdf0e10cSrcweir 	}
283cdf0e10cSrcweir 
284*a5258243SPedro Giffuni     // --> ORW
285*a5258243SPedro Giffuni     const sal_uInt16 getGeneratorVersion( const SvXMLImport& rImport )
286*a5258243SPedro Giffuni     {
287*a5258243SPedro Giffuni         if ( !mpDocumentInfo.get() )
288*a5258243SPedro Giffuni         {
289*a5258243SPedro Giffuni             mpDocumentInfo.reset( new DocumentInfo( rImport ) );
290*a5258243SPedro Giffuni         }
291*a5258243SPedro Giffuni 
292*a5258243SPedro Giffuni         return mpDocumentInfo->getGeneratorVersion();
293*a5258243SPedro Giffuni     }
294*a5258243SPedro Giffuni     // <--
295*a5258243SPedro Giffuni 
296cdf0e10cSrcweir 	::comphelper::UnoInterfaceToUniqueIdentifierMapper	maInterfaceToIdentifierMapper;
297cdf0e10cSrcweir };
298cdf0e10cSrcweir 
299cdf0e10cSrcweir typedef SvXMLImportContext *SvXMLImportContextPtr;
300cdf0e10cSrcweir SV_DECL_PTRARR( SvXMLImportContexts_Impl, SvXMLImportContextPtr, 20, 5 )
301cdf0e10cSrcweir SV_IMPL_PTRARR( SvXMLImportContexts_Impl, SvXMLImportContextPtr )
302cdf0e10cSrcweir 
303cdf0e10cSrcweir SvXMLImportContext *SvXMLImport::CreateContext( sal_uInt16 nPrefix,
304cdf0e10cSrcweir 										 const OUString& rLocalName,
305cdf0e10cSrcweir 										 const uno::Reference< xml::sax::XAttributeList >& )
306cdf0e10cSrcweir {
307cdf0e10cSrcweir 	return new SvXMLImportContext( *this, nPrefix, rLocalName );
308cdf0e10cSrcweir }
309cdf0e10cSrcweir 
310cdf0e10cSrcweir void SvXMLImport::_InitCtor()
311cdf0e10cSrcweir {
312cdf0e10cSrcweir 	if( mnImportFlags != 0 )
313cdf0e10cSrcweir 	{
314cdf0e10cSrcweir 		// implicit "xml" namespace prefix
315cdf0e10cSrcweir 		mpNamespaceMap->Add( GetXMLToken(XML_XML), GetXMLToken(XML_N_XML),
316cdf0e10cSrcweir                             XML_NAMESPACE_XML );
317cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office ) ),
318cdf0e10cSrcweir 							GetXMLToken(XML_N_OFFICE),
319cdf0e10cSrcweir 							XML_NAMESPACE_OFFICE );
320cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office_ext ) ),
321cdf0e10cSrcweir 							GetXMLToken(XML_N_OFFICE_EXT),
322cdf0e10cSrcweir 							XML_NAMESPACE_OFFICE_EXT );
323cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__ooo ) ), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
324cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__style) ),
325cdf0e10cSrcweir 							GetXMLToken(XML_N_STYLE),
326cdf0e10cSrcweir 							XML_NAMESPACE_STYLE );
327cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__text) ),
328cdf0e10cSrcweir 							GetXMLToken(XML_N_TEXT),
329cdf0e10cSrcweir 							XML_NAMESPACE_TEXT );
330cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__table ) ),
331cdf0e10cSrcweir 							GetXMLToken(XML_N_TABLE),
332cdf0e10cSrcweir 							XML_NAMESPACE_TABLE );
333cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__table_ext ) ),
334cdf0e10cSrcweir 							GetXMLToken(XML_N_TABLE_EXT),
335cdf0e10cSrcweir 							XML_NAMESPACE_TABLE_EXT );
336cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__draw ) ),
337cdf0e10cSrcweir 							GetXMLToken(XML_N_DRAW),
338cdf0e10cSrcweir 							XML_NAMESPACE_DRAW );
339cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__draw_ext ) ),
340cdf0e10cSrcweir 							GetXMLToken(XML_N_DRAW_EXT),
341cdf0e10cSrcweir 							XML_NAMESPACE_DRAW_EXT );
342cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM (sXML_np__dr3d ) ),
343cdf0e10cSrcweir 							GetXMLToken(XML_N_DR3D),
344cdf0e10cSrcweir 							XML_NAMESPACE_DR3D );
345cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__fo) ),
346cdf0e10cSrcweir 							GetXMLToken(XML_N_FO_COMPAT),
347cdf0e10cSrcweir 							XML_NAMESPACE_FO );
348cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xlink) ),
349cdf0e10cSrcweir 							GetXMLToken(XML_N_XLINK),
350cdf0e10cSrcweir 							XML_NAMESPACE_XLINK );
351cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__dc) ),
352cdf0e10cSrcweir 							GetXMLToken(XML_N_DC),
353cdf0e10cSrcweir 							XML_NAMESPACE_DC );
354cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__dom ) ),
355cdf0e10cSrcweir 							GetXMLToken(XML_N_DOM),
356cdf0e10cSrcweir 							XML_NAMESPACE_DOM );
357cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__meta) ),
358cdf0e10cSrcweir 							GetXMLToken(XML_N_META),
359cdf0e10cSrcweir 							XML_NAMESPACE_META );
360cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__number) ),
361cdf0e10cSrcweir 							GetXMLToken(XML_N_NUMBER),
362cdf0e10cSrcweir 							XML_NAMESPACE_NUMBER );
363cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__svg) ),
364cdf0e10cSrcweir 							GetXMLToken(XML_N_SVG_COMPAT),
365cdf0e10cSrcweir 							XML_NAMESPACE_SVG );
366cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__chart) ),
367cdf0e10cSrcweir 							GetXMLToken(XML_N_CHART),
368cdf0e10cSrcweir 							XML_NAMESPACE_CHART );
369cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__math) ),
370cdf0e10cSrcweir 							GetXMLToken(XML_N_MATH),
371cdf0e10cSrcweir 							XML_NAMESPACE_MATH );
372cdf0e10cSrcweir         mpNamespaceMap->Add(OUString(RTL_CONSTASCII_USTRINGPARAM( sXML_np__form )),
373cdf0e10cSrcweir                             GetXMLToken(XML_N_FORM),
374cdf0e10cSrcweir 							XML_NAMESPACE_FORM );
375cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__script) ),
376cdf0e10cSrcweir 							GetXMLToken(XML_N_SCRIPT),
377cdf0e10cSrcweir 							XML_NAMESPACE_SCRIPT );
378cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__config) ),
379cdf0e10cSrcweir 							GetXMLToken(XML_N_CONFIG),
380cdf0e10cSrcweir 							XML_NAMESPACE_CONFIG );
381cdf0e10cSrcweir         mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xforms) ),
382cdf0e10cSrcweir                             GetXMLToken(XML_N_XFORMS_1_0),
383cdf0e10cSrcweir                             XML_NAMESPACE_XFORMS );
384cdf0e10cSrcweir         mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xsd) ),
385cdf0e10cSrcweir                             GetXMLToken(XML_N_XSD),
386cdf0e10cSrcweir                             XML_NAMESPACE_XSD );
387cdf0e10cSrcweir         mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xsi) ),
388cdf0e10cSrcweir                             GetXMLToken(XML_N_XSI),
389cdf0e10cSrcweir                             XML_NAMESPACE_XFORMS );
390cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__ooow ) ), GetXMLToken(XML_N_OOOW), XML_NAMESPACE_OOOW );
391cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__oooc ) ), GetXMLToken(XML_N_OOOC), XML_NAMESPACE_OOOC );
392cdf0e10cSrcweir         mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__field ) ), GetXMLToken(XML_N_FIELD), XML_NAMESPACE_FIELD );
393cdf0e10cSrcweir 		mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__of ) ),
394cdf0e10cSrcweir                             GetXMLToken(XML_N_OF), XML_NAMESPACE_OF );
395cdf0e10cSrcweir         mpNamespaceMap->Add(
396cdf0e10cSrcweir             OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xhtml ) ),
397cdf0e10cSrcweir             GetXMLToken(XML_N_XHTML), XML_NAMESPACE_XHTML );
398cdf0e10cSrcweir 	}
399cdf0e10cSrcweir 
400cdf0e10cSrcweir 	msPackageProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) );
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 	if (mxNumberFormatsSupplier.is())
403cdf0e10cSrcweir 		mpNumImport = new SvXMLNumFmtHelper(mxNumberFormatsSupplier, getServiceFactory());
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 	if (mxModel.is() && !mxEventListener.is())
406cdf0e10cSrcweir 	{
407cdf0e10cSrcweir 		mxEventListener.set(new SvXMLImportEventListener(this));
408cdf0e10cSrcweir 		mxModel->addEventListener(mxEventListener);
409cdf0e10cSrcweir 	}
410cdf0e10cSrcweir 
411cdf0e10cSrcweir     ::comphelper::UnoInterfaceToUniqueIdentifierMapper	maInterfaceToIdentifierMapper;
412cdf0e10cSrcweir 
413cdf0e10cSrcweir }
414cdf0e10cSrcweir 
415cdf0e10cSrcweir // #110680#
416cdf0e10cSrcweir SvXMLImport::SvXMLImport(
417cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
418cdf0e10cSrcweir 	sal_uInt16 nImportFlags ) throw ()
419cdf0e10cSrcweir :	mpImpl( new SvXMLImport_Impl() ),
420cdf0e10cSrcweir 	mpNamespaceMap( new SvXMLNamespaceMap ),
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 	// #110680#
423cdf0e10cSrcweir 	// pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM ) ),
424cdf0e10cSrcweir 	mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM, xServiceFactory ) ),
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 	mpContexts( new SvXMLImportContexts_Impl ),
427cdf0e10cSrcweir 	mpNumImport( NULL ),
428cdf0e10cSrcweir 	mpProgressBarHelper( NULL ),
429cdf0e10cSrcweir 	mpEventImportHelper( NULL ),
430cdf0e10cSrcweir 	mpXMLErrors( NULL ),
431cdf0e10cSrcweir 	mpStyleMap(0),
432cdf0e10cSrcweir 	mnImportFlags( nImportFlags ),
433cdf0e10cSrcweir 	mnErrorFlags(0),
434cdf0e10cSrcweir 	// #110680#
435cdf0e10cSrcweir 	mxServiceFactory(xServiceFactory),
436cdf0e10cSrcweir     mbIsFormsSupported( sal_True ),
437cdf0e10cSrcweir 	mbIsTableShapeSupported( false ),
438cdf0e10cSrcweir     mbIsGraphicLoadOnDemandSupported( true )
439cdf0e10cSrcweir {
440cdf0e10cSrcweir 	DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
441cdf0e10cSrcweir 	_InitCtor();
442cdf0e10cSrcweir }
443cdf0e10cSrcweir 
444cdf0e10cSrcweir // #110680#
445cdf0e10cSrcweir SvXMLImport::SvXMLImport(
446cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
447cdf0e10cSrcweir 	const Reference< XModel > & rModel ) throw ()
448cdf0e10cSrcweir :	mxModel( rModel ),
449cdf0e10cSrcweir 	mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
450cdf0e10cSrcweir 	mpImpl( new SvXMLImport_Impl() ),
451cdf0e10cSrcweir 	mpNamespaceMap( new SvXMLNamespaceMap ),
452cdf0e10cSrcweir 	// #110680#
453cdf0e10cSrcweir 	// pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM ) ),
454cdf0e10cSrcweir 	mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM, xServiceFactory ) ),
455cdf0e10cSrcweir 	mpContexts( new SvXMLImportContexts_Impl ),
456cdf0e10cSrcweir 	mpNumImport( NULL ),
457cdf0e10cSrcweir 	mpProgressBarHelper( NULL ),
458cdf0e10cSrcweir 	mpEventImportHelper( NULL ),
459cdf0e10cSrcweir 	mpXMLErrors( NULL ),
460cdf0e10cSrcweir 	mpStyleMap(0),
461cdf0e10cSrcweir 	mnImportFlags( IMPORT_ALL ),
462cdf0e10cSrcweir 	mnErrorFlags(0),
463cdf0e10cSrcweir 	// #110680#
464cdf0e10cSrcweir 	mxServiceFactory(xServiceFactory),
465cdf0e10cSrcweir 	mbIsFormsSupported( sal_True ),
466cdf0e10cSrcweir 	mbIsTableShapeSupported( false ),
467cdf0e10cSrcweir     mbIsGraphicLoadOnDemandSupported( true )
468cdf0e10cSrcweir {
469cdf0e10cSrcweir 	DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
470cdf0e10cSrcweir 	_InitCtor();
471cdf0e10cSrcweir }
472cdf0e10cSrcweir 
473cdf0e10cSrcweir // #110680#
474cdf0e10cSrcweir SvXMLImport::SvXMLImport(
475cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
476cdf0e10cSrcweir 	const Reference< XModel > & rModel,
477cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::document::XGraphicObjectResolver > & rGraphicObjects ) throw ()
478cdf0e10cSrcweir :	mxModel( rModel ),
479cdf0e10cSrcweir 	mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
480cdf0e10cSrcweir 	mxGraphicResolver( rGraphicObjects ),
481cdf0e10cSrcweir 	mpImpl( new SvXMLImport_Impl() ),
482cdf0e10cSrcweir 	mpNamespaceMap( new SvXMLNamespaceMap ),
483cdf0e10cSrcweir 	// #110680#
484cdf0e10cSrcweir 	// pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM ) ),
485cdf0e10cSrcweir 	mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM, xServiceFactory ) ),
486cdf0e10cSrcweir 	mpContexts( new SvXMLImportContexts_Impl ),
487cdf0e10cSrcweir 	mpNumImport( NULL ),
488cdf0e10cSrcweir 	mpProgressBarHelper( NULL ),
489cdf0e10cSrcweir 	mpEventImportHelper( NULL ),
490cdf0e10cSrcweir 	mpXMLErrors( NULL ),
491cdf0e10cSrcweir 	mpStyleMap(0),
492cdf0e10cSrcweir 	mnImportFlags( IMPORT_ALL ),
493cdf0e10cSrcweir 	mnErrorFlags(0),
494cdf0e10cSrcweir 	// #110680#
495cdf0e10cSrcweir 	mxServiceFactory(xServiceFactory),
496cdf0e10cSrcweir     mbIsFormsSupported( sal_True ),
497cdf0e10cSrcweir     mbIsGraphicLoadOnDemandSupported( true )
498cdf0e10cSrcweir {
499cdf0e10cSrcweir 	DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
500cdf0e10cSrcweir 	_InitCtor();
501cdf0e10cSrcweir }
502cdf0e10cSrcweir 
503cdf0e10cSrcweir SvXMLImport::~SvXMLImport() throw ()
504cdf0e10cSrcweir {
505cdf0e10cSrcweir     delete mpXMLErrors;
506cdf0e10cSrcweir 	delete mpNamespaceMap;
507cdf0e10cSrcweir 	delete mpUnitConv;
508cdf0e10cSrcweir 	delete mpEventImportHelper;
509cdf0e10cSrcweir 	if( mpContexts )
510cdf0e10cSrcweir 	{
511cdf0e10cSrcweir 		while( mpContexts->Count() )
512cdf0e10cSrcweir 		{
513cdf0e10cSrcweir 			sal_uInt16 n = mpContexts->Count() - 1;
514cdf0e10cSrcweir 			SvXMLImportContext *pContext = (*mpContexts)[n];
515cdf0e10cSrcweir 			mpContexts->Remove( n, 1 );
516cdf0e10cSrcweir 			if( pContext )
517cdf0e10cSrcweir 				pContext->ReleaseRef();
518cdf0e10cSrcweir 		}
519cdf0e10cSrcweir 		delete mpContexts;
520cdf0e10cSrcweir 	}
521cdf0e10cSrcweir 
522cdf0e10cSrcweir 	//	delete pImageMapImportHelper;
523cdf0e10cSrcweir 
524cdf0e10cSrcweir 	//	#i9518# the import component might not be deleted until after the document has been closed,
525cdf0e10cSrcweir 	//	so the stuff that accesses the document has been moved to endDocument.
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 	//	pNumImport is allocated in the ctor, so it must also be deleted here in case the component
528cdf0e10cSrcweir 	//	is created and deleted without actually importing.
529cdf0e10cSrcweir 	delete mpNumImport;
530cdf0e10cSrcweir 	delete mpProgressBarHelper;
531cdf0e10cSrcweir 
532cdf0e10cSrcweir 	xmloff::token::ResetTokens();
533cdf0e10cSrcweir 
534cdf0e10cSrcweir 	if( mpImpl )
535cdf0e10cSrcweir 		delete mpImpl;
536cdf0e10cSrcweir 
537cdf0e10cSrcweir 	if (mxEventListener.is() && mxModel.is())
538cdf0e10cSrcweir 		mxModel->removeEventListener(mxEventListener);
539cdf0e10cSrcweir }
540cdf0e10cSrcweir 
541cdf0e10cSrcweir // XUnoTunnel & co
542cdf0e10cSrcweir const uno::Sequence< sal_Int8 > & SvXMLImport::getUnoTunnelId() throw()
543cdf0e10cSrcweir {
544cdf0e10cSrcweir 	static uno::Sequence< sal_Int8 > * pSeq = 0;
545cdf0e10cSrcweir 	if( !pSeq )
546cdf0e10cSrcweir 	{
547cdf0e10cSrcweir 		Guard< Mutex > aGuard( Mutex::getGlobalMutex() );
548cdf0e10cSrcweir 		if( !pSeq )
549cdf0e10cSrcweir 		{
550cdf0e10cSrcweir 			static uno::Sequence< sal_Int8 > aSeq( 16 );
551cdf0e10cSrcweir 			rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
552cdf0e10cSrcweir 			pSeq = &aSeq;
553cdf0e10cSrcweir 		}
554cdf0e10cSrcweir 	}
555cdf0e10cSrcweir 	return *pSeq;
556cdf0e10cSrcweir }
557cdf0e10cSrcweir 
558cdf0e10cSrcweir SvXMLImport* SvXMLImport::getImplementation( uno::Reference< uno::XInterface > xInt ) throw()
559cdf0e10cSrcweir {
560cdf0e10cSrcweir 	uno::Reference< lang::XUnoTunnel > xUT( xInt, uno::UNO_QUERY );
561cdf0e10cSrcweir 	if( xUT.is() )
562cdf0e10cSrcweir 	{
563cdf0e10cSrcweir 		return
564cdf0e10cSrcweir 			reinterpret_cast<SvXMLImport*>(
565cdf0e10cSrcweir 				sal::static_int_cast<sal_IntPtr>(
566cdf0e10cSrcweir 					xUT->getSomething( SvXMLImport::getUnoTunnelId())));
567cdf0e10cSrcweir 	}
568cdf0e10cSrcweir 	else
569cdf0e10cSrcweir 		return NULL;
570cdf0e10cSrcweir }
571cdf0e10cSrcweir 
572cdf0e10cSrcweir // XUnoTunnel
573cdf0e10cSrcweir sal_Int64 SAL_CALL SvXMLImport::getSomething( const uno::Sequence< sal_Int8 >& rId )
574cdf0e10cSrcweir 	throw( uno::RuntimeException )
575cdf0e10cSrcweir {
576cdf0e10cSrcweir 	if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
577cdf0e10cSrcweir 														 rId.getConstArray(), 16 ) )
578cdf0e10cSrcweir 	{
579cdf0e10cSrcweir 		return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
580cdf0e10cSrcweir 	}
581cdf0e10cSrcweir 	return 0;
582cdf0e10cSrcweir }
583cdf0e10cSrcweir 
584cdf0e10cSrcweir void SAL_CALL SvXMLImport::startDocument( void )
585cdf0e10cSrcweir 	throw( xml::sax::SAXException, uno::RuntimeException )
586cdf0e10cSrcweir {
587cdf0e10cSrcweir     RTL_LOGFILE_TRACE_AUTHOR( "xmloff", LOGFILE_AUTHOR, "{ SvXMLImport::startDocument" );
588cdf0e10cSrcweir 
589cdf0e10cSrcweir 	if( !mxGraphicResolver.is() || !mxEmbeddedResolver.is() )
590cdf0e10cSrcweir 	{
591cdf0e10cSrcweir 		Reference< lang::XMultiServiceFactory > xFactory( mxModel,	UNO_QUERY );
592cdf0e10cSrcweir 		if( xFactory.is() )
593cdf0e10cSrcweir 		{
594cdf0e10cSrcweir 			try
595cdf0e10cSrcweir 			{
596cdf0e10cSrcweir 				if( !mxGraphicResolver.is() )
597cdf0e10cSrcweir 				{
598cdf0e10cSrcweir 					mxGraphicResolver = Reference< XGraphicObjectResolver >::query(
599cdf0e10cSrcweir 						xFactory->createInstance(
600cdf0e10cSrcweir 							OUString(RTL_CONSTASCII_USTRINGPARAM(
601cdf0e10cSrcweir 								// #99870# Import... instead of Export...
602cdf0e10cSrcweir 								"com.sun.star.document.ImportGraphicObjectResolver"))));
603cdf0e10cSrcweir 					mpImpl->mbOwnGraphicResolver = mxGraphicResolver.is();
604cdf0e10cSrcweir 				}
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 				if( !mxEmbeddedResolver.is() )
607cdf0e10cSrcweir 				{
608cdf0e10cSrcweir 					mxEmbeddedResolver = Reference< XEmbeddedObjectResolver >::query(
609cdf0e10cSrcweir 						xFactory->createInstance(
610cdf0e10cSrcweir 							OUString(RTL_CONSTASCII_USTRINGPARAM(
611cdf0e10cSrcweir 								// #99870# Import... instead of Export...
612cdf0e10cSrcweir 								"com.sun.star.document.ImportEmbeddedObjectResolver"))));
613cdf0e10cSrcweir 					mpImpl->mbOwnEmbeddedResolver = mxEmbeddedResolver.is();
614cdf0e10cSrcweir 				}
615cdf0e10cSrcweir 			}
616cdf0e10cSrcweir 			catch( com::sun::star::uno::Exception& )
617cdf0e10cSrcweir 			{
618cdf0e10cSrcweir 			}
619cdf0e10cSrcweir 		}
620cdf0e10cSrcweir 	}
621cdf0e10cSrcweir }
622cdf0e10cSrcweir 
623cdf0e10cSrcweir void SAL_CALL SvXMLImport::endDocument( void )
624cdf0e10cSrcweir 	throw( xml::sax::SAXException, uno::RuntimeException)
625cdf0e10cSrcweir {
626cdf0e10cSrcweir     RTL_LOGFILE_TRACE_AUTHOR( "xmloff", LOGFILE_AUTHOR, "} SvXMLImport::startDocument" );
627cdf0e10cSrcweir 
628cdf0e10cSrcweir 	//	#i9518# All the stuff that accesses the document has to be done here, not in the dtor,
629cdf0e10cSrcweir 	//	because the SvXMLImport dtor might not be called until after the document has been closed.
630cdf0e10cSrcweir 
631cdf0e10cSrcweir     if (mpImpl->mpRDFaHelper.get())
632cdf0e10cSrcweir     {
633cdf0e10cSrcweir         const uno::Reference<rdf::XRepositorySupplier> xRS(mxModel,
634cdf0e10cSrcweir             uno::UNO_QUERY);
635cdf0e10cSrcweir         if (xRS.is())
636cdf0e10cSrcweir         {
637cdf0e10cSrcweir             mpImpl->mpRDFaHelper->InsertRDFa( xRS );
638cdf0e10cSrcweir         }
639cdf0e10cSrcweir     }
640cdf0e10cSrcweir 
641cdf0e10cSrcweir 	if (mpNumImport)
642cdf0e10cSrcweir 	{
643cdf0e10cSrcweir 		delete mpNumImport;
644cdf0e10cSrcweir 		mpNumImport = NULL;
645cdf0e10cSrcweir 	}
646cdf0e10cSrcweir 	if (mxImportInfo.is())
647cdf0e10cSrcweir 	{
648cdf0e10cSrcweir 		uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
649cdf0e10cSrcweir 		if (xPropertySetInfo.is())
650cdf0e10cSrcweir 		{
651cdf0e10cSrcweir 			if (mpProgressBarHelper)
652cdf0e10cSrcweir 			{
653cdf0e10cSrcweir 				OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSMAX));
654cdf0e10cSrcweir 				OUString sProgressCurrent(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSCURRENT));
655cdf0e10cSrcweir                 OUString sRepeat(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSREPEAT));
656cdf0e10cSrcweir 				if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
657cdf0e10cSrcweir 					xPropertySetInfo->hasPropertyByName(sProgressCurrent))
658cdf0e10cSrcweir 				{
659cdf0e10cSrcweir 					sal_Int32 nProgressMax(mpProgressBarHelper->GetReference());
660cdf0e10cSrcweir 					sal_Int32 nProgressCurrent(mpProgressBarHelper->GetValue());
661cdf0e10cSrcweir 					uno::Any aAny;
662cdf0e10cSrcweir 					aAny <<= nProgressMax;
663cdf0e10cSrcweir 					mxImportInfo->setPropertyValue(sProgressMax, aAny);
664cdf0e10cSrcweir 					aAny <<= nProgressCurrent;
665cdf0e10cSrcweir 					mxImportInfo->setPropertyValue(sProgressCurrent, aAny);
666cdf0e10cSrcweir 				}
667cdf0e10cSrcweir                 if (xPropertySetInfo->hasPropertyByName(sRepeat))
668cdf0e10cSrcweir                     mxImportInfo->setPropertyValue(sRepeat, cppu::bool2any(mpProgressBarHelper->GetRepeat()));
669cdf0e10cSrcweir                 // pProgressBarHelper is deleted in dtor
670cdf0e10cSrcweir 			}
671cdf0e10cSrcweir 			OUString sNumberStyles(RTL_CONSTASCII_USTRINGPARAM(XML_NUMBERSTYLES));
672cdf0e10cSrcweir 			if (mxNumberStyles.is() && xPropertySetInfo->hasPropertyByName(sNumberStyles))
673cdf0e10cSrcweir 			{
674cdf0e10cSrcweir 				uno::Any aAny;
675cdf0e10cSrcweir 				aAny <<= mxNumberStyles;
676cdf0e10cSrcweir 				mxImportInfo->setPropertyValue(sNumberStyles, aAny);
677cdf0e10cSrcweir 			}
678cdf0e10cSrcweir 		}
679cdf0e10cSrcweir 	}
680cdf0e10cSrcweir 
681cdf0e10cSrcweir 	if( mxFontDecls.Is() )
682cdf0e10cSrcweir 		((SvXMLStylesContext *)&mxFontDecls)->Clear();
683cdf0e10cSrcweir 	if( mxStyles.Is() )
684cdf0e10cSrcweir 		((SvXMLStylesContext *)&mxStyles)->Clear();
685cdf0e10cSrcweir 	if( mxAutoStyles.Is() )
686cdf0e10cSrcweir 		((SvXMLStylesContext *)&mxAutoStyles)->Clear();
687cdf0e10cSrcweir 	if( mxMasterStyles.Is() )
688cdf0e10cSrcweir 		((SvXMLStylesContext *)&mxMasterStyles)->Clear();
689cdf0e10cSrcweir 
690cdf0e10cSrcweir     // possible form-layer related knittings which can only be done when
691cdf0e10cSrcweir     // the whole document exists
692cdf0e10cSrcweir     if ( mxFormImport.is() )
693cdf0e10cSrcweir         mxFormImport->documentDone();
694cdf0e10cSrcweir 
695cdf0e10cSrcweir 	//	The shape import helper does the z-order sorting in the dtor,
696cdf0e10cSrcweir 	//	so it must be deleted here, too.
697cdf0e10cSrcweir 	mxShapeImport = NULL;
698cdf0e10cSrcweir 
699cdf0e10cSrcweir 	if( mpImpl->mbOwnGraphicResolver )
700cdf0e10cSrcweir 	{
701cdf0e10cSrcweir 		Reference< lang::XComponent > xComp( mxGraphicResolver, UNO_QUERY );
702cdf0e10cSrcweir 		xComp->dispose();
703cdf0e10cSrcweir 	}
704cdf0e10cSrcweir 
705cdf0e10cSrcweir 	if( mpImpl->mbOwnEmbeddedResolver )
706cdf0e10cSrcweir 	{
707cdf0e10cSrcweir 		Reference< lang::XComponent > xComp( mxEmbeddedResolver, UNO_QUERY );
708cdf0e10cSrcweir 		xComp->dispose();
709cdf0e10cSrcweir 	}
710cdf0e10cSrcweir 	if( mpStyleMap )
711cdf0e10cSrcweir 	{
712cdf0e10cSrcweir 		mpStyleMap->release();
713cdf0e10cSrcweir 		mpStyleMap = 0;
714cdf0e10cSrcweir 	}
715cdf0e10cSrcweir 
716cdf0e10cSrcweir     if ( mpXMLErrors != NULL )
717cdf0e10cSrcweir     {
718cdf0e10cSrcweir         mpXMLErrors->ThrowErrorAsSAXException( XMLERROR_FLAG_SEVERE );
719cdf0e10cSrcweir     }
720cdf0e10cSrcweir }
721cdf0e10cSrcweir 
722cdf0e10cSrcweir void SAL_CALL SvXMLImport::startElement( const OUString& rName,
723cdf0e10cSrcweir 										 const uno::Reference< xml::sax::XAttributeList >& xAttrList )
724cdf0e10cSrcweir 	throw(xml::sax::SAXException, uno::RuntimeException)
725cdf0e10cSrcweir {
726cdf0e10cSrcweir 	SvXMLNamespaceMap *pRewindMap = 0;
727cdf0e10cSrcweir 
728cdf0e10cSrcweir 	// Process namespace attributes. This must happen before creating the
729cdf0e10cSrcweir 	// context, because namespace decaration apply to the element name itself.
730cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
731cdf0e10cSrcweir 	for( sal_Int16 i=0; i < nAttrCount; i++ )
732cdf0e10cSrcweir 	{
733cdf0e10cSrcweir 		const OUString& rAttrName = xAttrList->getNameByIndex( i );
734cdf0e10cSrcweir         if ( rAttrName.equalsAscii("office:version") )
735cdf0e10cSrcweir         {
736cdf0e10cSrcweir             mpImpl->aODFVersion = xAttrList->getValueByIndex( i );
737cdf0e10cSrcweir 
738cdf0e10cSrcweir             // the ODF version in content.xml and manifest.xml must be the same starting from ODF1.2
739cdf0e10cSrcweir             if ( mpImpl->mStreamName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "content.xml" ) ) )
740cdf0e10cSrcweir               && !IsODFVersionConsistent( mpImpl->aODFVersion ) )
741cdf0e10cSrcweir             {
742cdf0e10cSrcweir                 throw xml::sax::SAXException(
743cdf0e10cSrcweir                         ::rtl::OUString(
744cdf0e10cSrcweir                             RTL_CONSTASCII_USTRINGPARAM( "Inconsistent ODF versions in content.xml and manifest.xml!" ) ),
745cdf0e10cSrcweir                         uno::Reference< uno::XInterface >(),
746cdf0e10cSrcweir                         uno::makeAny(
747cdf0e10cSrcweir                             packages::zip::ZipIOException(
748cdf0e10cSrcweir                                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
749cdf0e10cSrcweir                                     "Inconsistent ODF versions in content.xml and manifest.xml!" ) ),
750cdf0e10cSrcweir 							    Reference< XInterface >() ) ) );
751cdf0e10cSrcweir             }
752cdf0e10cSrcweir         }
753cdf0e10cSrcweir         else if( ( rAttrName.getLength() >= 5 ) &&
754cdf0e10cSrcweir             ( rAttrName.compareTo( GetXMLToken(XML_XMLNS), 5 ) == 0 ) &&
755cdf0e10cSrcweir 			( rAttrName.getLength() == 5 || ':' == rAttrName[5] ) )
756cdf0e10cSrcweir 		{
757cdf0e10cSrcweir 			if( !pRewindMap )
758cdf0e10cSrcweir 			{
759cdf0e10cSrcweir 				pRewindMap = mpNamespaceMap;
760cdf0e10cSrcweir 				mpNamespaceMap = new SvXMLNamespaceMap( *mpNamespaceMap );
761cdf0e10cSrcweir 			}
762cdf0e10cSrcweir 			const OUString& rAttrValue = xAttrList->getValueByIndex( i );
763cdf0e10cSrcweir 
764cdf0e10cSrcweir             OUString aPrefix( ( rAttrName.getLength() == 5 )
765cdf0e10cSrcweir                                  ? OUString()
766cdf0e10cSrcweir                                  : rAttrName.copy( 6 ) );
767cdf0e10cSrcweir 			// Add namespace, but only if it is known.
768cdf0e10cSrcweir 			sal_uInt16 nKey = mpNamespaceMap->AddIfKnown( aPrefix, rAttrValue );
769cdf0e10cSrcweir 			// If namespace is unknwon, try to match a name with similar
770cdf0e10cSrcweir 			// TC Id an version
771cdf0e10cSrcweir             if( XML_NAMESPACE_UNKNOWN == nKey  )
772cdf0e10cSrcweir 			{
773cdf0e10cSrcweir 				OUString aTestName( rAttrValue );
774cdf0e10cSrcweir 				if( SvXMLNamespaceMap::NormalizeURI( aTestName ) )
775cdf0e10cSrcweir 					nKey = mpNamespaceMap->AddIfKnown( aPrefix, aTestName );
776cdf0e10cSrcweir 			}
777cdf0e10cSrcweir 			// If that namespace is not known, too, add it as unknown
778cdf0e10cSrcweir             if( XML_NAMESPACE_UNKNOWN == nKey  )
779cdf0e10cSrcweir 				mpNamespaceMap->Add( aPrefix, rAttrValue );
780cdf0e10cSrcweir 
781cdf0e10cSrcweir 		}
782cdf0e10cSrcweir 	}
783cdf0e10cSrcweir 
784cdf0e10cSrcweir 	// Get element's namespace and local name.
785cdf0e10cSrcweir 	OUString aLocalName;
786cdf0e10cSrcweir 	sal_uInt16 nPrefix =
787cdf0e10cSrcweir 		mpNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
788cdf0e10cSrcweir 
789cdf0e10cSrcweir 	// If there are contexts already, call a CreateChildContext at the topmost
790cdf0e10cSrcweir 	// context. Otherwise, create a default context.
791cdf0e10cSrcweir 	SvXMLImportContext *pContext;
792cdf0e10cSrcweir 	sal_uInt16 nCount = mpContexts->Count();
793cdf0e10cSrcweir 	if( nCount > 0 )
794cdf0e10cSrcweir 	{
795cdf0e10cSrcweir 		pContext = (*mpContexts)[nCount - 1]->CreateChildContext( nPrefix,
796cdf0e10cSrcweir 																 aLocalName,
797cdf0e10cSrcweir 																 xAttrList );
798cdf0e10cSrcweir         DBG_ASSERT( pContext && pContext->GetPrefix() == nPrefix,
799cdf0e10cSrcweir 				"SvXMLImport::startElement: created context has wrong prefix" );
800cdf0e10cSrcweir 	}
801cdf0e10cSrcweir 	else
802cdf0e10cSrcweir 	{
803cdf0e10cSrcweir #ifdef TIMELOG
804cdf0e10cSrcweir         // If we do profiling, we want a trace message for the first element
805cdf0e10cSrcweir         // in order to identify the stream.
806cdf0e10cSrcweir         ByteString aString( (String)rName, RTL_TEXTENCODING_ASCII_US );
807cdf0e10cSrcweir         RTL_LOGFILE_TRACE_AUTHOR1( "xmloff", LOGFILE_AUTHOR,
808cdf0e10cSrcweir                                    "SvXMLImport::StartElement( \"%s\", ... )",
809cdf0e10cSrcweir                                    aString.GetBuffer() );
810cdf0e10cSrcweir #endif
811cdf0e10cSrcweir 
812cdf0e10cSrcweir 		pContext = CreateContext( nPrefix, aLocalName, xAttrList );
813cdf0e10cSrcweir 		if( (nPrefix & XML_NAMESPACE_UNKNOWN_FLAG) != 0 &&
814cdf0e10cSrcweir 			IS_TYPE( SvXMLImportContext, pContext ) )
815cdf0e10cSrcweir 		{
816cdf0e10cSrcweir 			OUString aMsg( RTL_CONSTASCII_USTRINGPARAM( "Root element unknown" ) );
817cdf0e10cSrcweir     		Reference<xml::sax::XLocator> xDummyLocator;
818cdf0e10cSrcweir 			Sequence < OUString > aParams(1);
819cdf0e10cSrcweir 			aParams.getArray()[0] = rName;
820cdf0e10cSrcweir 
821cdf0e10cSrcweir 			SetError( XMLERROR_FLAG_SEVERE|XMLERROR_UNKNWON_ROOT,
822cdf0e10cSrcweir 					  aParams, aMsg, xDummyLocator );
823cdf0e10cSrcweir 		}
824cdf0e10cSrcweir 	}
825cdf0e10cSrcweir 
826cdf0e10cSrcweir 	DBG_ASSERT( pContext, "SvXMLImport::startElement: missing context" );
827cdf0e10cSrcweir 	if( !pContext )
828cdf0e10cSrcweir 		pContext = new SvXMLImportContext( *this, nPrefix, aLocalName );
829cdf0e10cSrcweir 
830cdf0e10cSrcweir 	pContext->AddRef();
831cdf0e10cSrcweir 
832cdf0e10cSrcweir 	// Remeber old namespace map.
833cdf0e10cSrcweir 	if( pRewindMap )
834cdf0e10cSrcweir 		pContext->SetRewindMap( pRewindMap );
835cdf0e10cSrcweir 
836cdf0e10cSrcweir 	// Call a startElement at the new context.
837cdf0e10cSrcweir 	pContext->StartElement( xAttrList );
838cdf0e10cSrcweir 
839cdf0e10cSrcweir 	// Push context on stack.
840cdf0e10cSrcweir 	mpContexts->Insert( pContext, nCount );
841cdf0e10cSrcweir }
842cdf0e10cSrcweir 
843cdf0e10cSrcweir void SAL_CALL SvXMLImport::endElement( const OUString&
844cdf0e10cSrcweir #ifdef DBG_UTIL
845cdf0e10cSrcweir rName
846cdf0e10cSrcweir #endif
847cdf0e10cSrcweir )
848cdf0e10cSrcweir 	throw(xml::sax::SAXException, uno::RuntimeException)
849cdf0e10cSrcweir {
850cdf0e10cSrcweir 	sal_uInt16 nCount = mpContexts->Count();
851cdf0e10cSrcweir 	DBG_ASSERT( nCount, "SvXMLImport::endElement: no context left" );
852cdf0e10cSrcweir 	if( nCount > 0 )
853cdf0e10cSrcweir 	{
854cdf0e10cSrcweir 		// Get topmost context and remove it from the stack.
855cdf0e10cSrcweir 		SvXMLImportContext *pContext = (*mpContexts)[nCount-1];
856cdf0e10cSrcweir 		mpContexts->Remove( nCount-1, 1 );
857cdf0e10cSrcweir 
858cdf0e10cSrcweir #ifdef DBG_UTIL
859cdf0e10cSrcweir 		// Non product only: check if endElement call matches startELement call.
860cdf0e10cSrcweir 		OUString aLocalName;
861cdf0e10cSrcweir 		sal_uInt16 nPrefix =
862cdf0e10cSrcweir 			mpNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
863cdf0e10cSrcweir 		DBG_ASSERT( pContext->GetPrefix() == nPrefix,
864cdf0e10cSrcweir 				"SvXMLImport::endElement: popped context has wrong prefix" );
865cdf0e10cSrcweir 		DBG_ASSERT( pContext->GetLocalName() == aLocalName,
866cdf0e10cSrcweir 				"SvXMLImport::endElement: popped context has wrong lname" );
867cdf0e10cSrcweir #endif
868cdf0e10cSrcweir 
869cdf0e10cSrcweir 		// Call a EndElement at the current context.
870cdf0e10cSrcweir 		pContext->EndElement();
871cdf0e10cSrcweir 
872cdf0e10cSrcweir 		// Get a namespace map to rewind.
873cdf0e10cSrcweir 		SvXMLNamespaceMap *pRewindMap = pContext->GetRewindMap();
874cdf0e10cSrcweir 
875cdf0e10cSrcweir 		// Delete the current context.
876cdf0e10cSrcweir 		pContext->ReleaseRef();
877cdf0e10cSrcweir 		pContext = 0;
878cdf0e10cSrcweir 
879cdf0e10cSrcweir 		// Rewind a namespace map.
880cdf0e10cSrcweir 		if( pRewindMap )
881cdf0e10cSrcweir 		{
882cdf0e10cSrcweir 			delete mpNamespaceMap;
883cdf0e10cSrcweir 			mpNamespaceMap = pRewindMap;
884cdf0e10cSrcweir 		}
885cdf0e10cSrcweir 	}
886cdf0e10cSrcweir }
887cdf0e10cSrcweir 
888cdf0e10cSrcweir void SAL_CALL SvXMLImport::characters( const OUString& rChars )
889cdf0e10cSrcweir 	throw(xml::sax::SAXException, uno::RuntimeException)
890cdf0e10cSrcweir {
891cdf0e10cSrcweir 	sal_uInt16 nCount = mpContexts->Count();
892cdf0e10cSrcweir 	if( nCount > 0 )
893cdf0e10cSrcweir 	{
894cdf0e10cSrcweir 		(*mpContexts)[nCount - 1]->Characters( rChars );
895cdf0e10cSrcweir 	}
896cdf0e10cSrcweir }
897cdf0e10cSrcweir 
898cdf0e10cSrcweir void SAL_CALL SvXMLImport::ignorableWhitespace( const OUString& )
899cdf0e10cSrcweir 	throw(xml::sax::SAXException, uno::RuntimeException)
900cdf0e10cSrcweir {
901cdf0e10cSrcweir }
902cdf0e10cSrcweir 
903cdf0e10cSrcweir void SAL_CALL SvXMLImport::processingInstruction( const OUString&,
904cdf0e10cSrcweir 									   const OUString& )
905cdf0e10cSrcweir 	throw(xml::sax::SAXException, uno::RuntimeException)
906cdf0e10cSrcweir {
907cdf0e10cSrcweir }
908cdf0e10cSrcweir 
909cdf0e10cSrcweir void SAL_CALL SvXMLImport::setDocumentLocator( const uno::Reference< xml::sax::XLocator >& rLocator )
910cdf0e10cSrcweir 	throw(xml::sax::SAXException, uno::RuntimeException)
911cdf0e10cSrcweir {
912cdf0e10cSrcweir 	mxLocator = rLocator;
913cdf0e10cSrcweir }
914cdf0e10cSrcweir 
915cdf0e10cSrcweir // XExtendedDocumentHandler
916cdf0e10cSrcweir void SAL_CALL SvXMLImport::startCDATA( void ) throw(xml::sax::SAXException, uno::RuntimeException)
917cdf0e10cSrcweir {
918cdf0e10cSrcweir }
919cdf0e10cSrcweir 
920cdf0e10cSrcweir void SAL_CALL SvXMLImport::endCDATA( void ) throw(uno::RuntimeException)
921cdf0e10cSrcweir {
922cdf0e10cSrcweir }
923cdf0e10cSrcweir 
924cdf0e10cSrcweir void SAL_CALL SvXMLImport::comment( const OUString& )
925cdf0e10cSrcweir 	throw(xml::sax::SAXException, uno::RuntimeException)
926cdf0e10cSrcweir {
927cdf0e10cSrcweir }
928cdf0e10cSrcweir 
929cdf0e10cSrcweir void SAL_CALL SvXMLImport::allowLineBreak( void )
930cdf0e10cSrcweir 	throw(xml::sax::SAXException, uno::RuntimeException)
931cdf0e10cSrcweir {
932cdf0e10cSrcweir }
933cdf0e10cSrcweir 
934cdf0e10cSrcweir void SAL_CALL SvXMLImport::unknown( const OUString& )
935cdf0e10cSrcweir 	throw(xml::sax::SAXException, uno::RuntimeException)
936cdf0e10cSrcweir {
937cdf0e10cSrcweir }
938cdf0e10cSrcweir 
939cdf0e10cSrcweir void SvXMLImport::SetStatistics(const uno::Sequence< beans::NamedValue> &)
940cdf0e10cSrcweir {
941cdf0e10cSrcweir     GetProgressBarHelper()->SetRepeat(sal_False);
942cdf0e10cSrcweir     GetProgressBarHelper()->SetReference(0);
943cdf0e10cSrcweir }
944cdf0e10cSrcweir 
945cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
946cdf0e10cSrcweir 
947cdf0e10cSrcweir // XImporter
948cdf0e10cSrcweir void SAL_CALL SvXMLImport::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc )
949cdf0e10cSrcweir 	throw(lang::IllegalArgumentException, uno::RuntimeException)
950cdf0e10cSrcweir {
951cdf0e10cSrcweir 	mxModel = uno::Reference< frame::XModel >::query( xDoc );
952cdf0e10cSrcweir 	if( !mxModel.is() )
953cdf0e10cSrcweir 		throw lang::IllegalArgumentException();
954cdf0e10cSrcweir 	if (mxModel.is() && !mxEventListener.is())
955cdf0e10cSrcweir 	{
956cdf0e10cSrcweir 		mxEventListener.set(new SvXMLImportEventListener(this));
957cdf0e10cSrcweir 		mxModel->addEventListener(mxEventListener);
958cdf0e10cSrcweir 	}
959cdf0e10cSrcweir 
960cdf0e10cSrcweir 	DBG_ASSERT( !mpNumImport, "number format import already exists." );
961cdf0e10cSrcweir 	if( mpNumImport )
962cdf0e10cSrcweir 	{
963cdf0e10cSrcweir 		delete mpNumImport;
964cdf0e10cSrcweir 		mpNumImport = 0;
965cdf0e10cSrcweir 	}
966cdf0e10cSrcweir }
967cdf0e10cSrcweir 
968cdf0e10cSrcweir // XFilter
969cdf0e10cSrcweir sal_Bool SAL_CALL SvXMLImport::filter( const uno::Sequence< beans::PropertyValue >& )
970cdf0e10cSrcweir     throw (uno::RuntimeException)
971cdf0e10cSrcweir {
972cdf0e10cSrcweir     return sal_False;
973cdf0e10cSrcweir }
974cdf0e10cSrcweir 
975cdf0e10cSrcweir void SAL_CALL SvXMLImport::cancel(  )
976cdf0e10cSrcweir     throw (uno::RuntimeException)
977cdf0e10cSrcweir {
978cdf0e10cSrcweir }
979cdf0e10cSrcweir 
980cdf0e10cSrcweir // XInitialize
981cdf0e10cSrcweir void SAL_CALL SvXMLImport::initialize( const uno::Sequence< uno::Any >& aArguments )
982cdf0e10cSrcweir 	throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
983cdf0e10cSrcweir {
984cdf0e10cSrcweir 	const sal_Int32 nAnyCount = aArguments.getLength();
985cdf0e10cSrcweir 	const uno::Any* pAny = aArguments.getConstArray();
986cdf0e10cSrcweir 
987cdf0e10cSrcweir 	for( sal_Int32 nIndex = 0; nIndex < nAnyCount; nIndex++, pAny++ )
988cdf0e10cSrcweir     {
989cdf0e10cSrcweir         Reference<XInterface> xValue;
990cdf0e10cSrcweir         *pAny >>= xValue;
991cdf0e10cSrcweir 
992cdf0e10cSrcweir         uno::Reference<task::XStatusIndicator> xTmpStatusIndicator(
993cdf0e10cSrcweir             xValue, UNO_QUERY );
994cdf0e10cSrcweir 		if( xTmpStatusIndicator.is() )
995cdf0e10cSrcweir 			mxStatusIndicator = xTmpStatusIndicator;
996cdf0e10cSrcweir 
997cdf0e10cSrcweir         uno::Reference<document::XGraphicObjectResolver> xTmpGraphicResolver(
998cdf0e10cSrcweir             xValue, UNO_QUERY );
999cdf0e10cSrcweir 		if( xTmpGraphicResolver.is() )
1000cdf0e10cSrcweir 			mxGraphicResolver = xTmpGraphicResolver;
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir         uno::Reference<document::XEmbeddedObjectResolver> xTmpObjectResolver(
1003cdf0e10cSrcweir             xValue, UNO_QUERY );
1004cdf0e10cSrcweir         if( xTmpObjectResolver.is() )
1005cdf0e10cSrcweir             mxEmbeddedResolver = xTmpObjectResolver;
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir         uno::Reference<beans::XPropertySet> xTmpPropSet( xValue, UNO_QUERY );
1008cdf0e10cSrcweir         if( xTmpPropSet.is() )
1009cdf0e10cSrcweir         {
1010cdf0e10cSrcweir             mxImportInfo = xTmpPropSet;
1011cdf0e10cSrcweir             uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
1012cdf0e10cSrcweir             if (xPropertySetInfo.is())
1013cdf0e10cSrcweir 			{
1014cdf0e10cSrcweir                 OUString sPropName(RTL_CONSTASCII_USTRINGPARAM(XML_NUMBERSTYLES));
1015cdf0e10cSrcweir                 if (xPropertySetInfo->hasPropertyByName(sPropName))
1016cdf0e10cSrcweir 				{
1017cdf0e10cSrcweir                     uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1018cdf0e10cSrcweir                     aAny >>= mxNumberStyles;
1019cdf0e10cSrcweir 				}
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir 				sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("PrivateData" ) );
1022cdf0e10cSrcweir                 if (xPropertySetInfo->hasPropertyByName(sPropName))
1023cdf0e10cSrcweir 				{
1024cdf0e10cSrcweir 					Reference < XInterface > xIfc;
1025cdf0e10cSrcweir                     uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1026cdf0e10cSrcweir                     aAny >>= xIfc;
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir 					StyleMap *pSMap = StyleMap::getImplementation( xIfc );
1029cdf0e10cSrcweir 					if( pSMap )
1030cdf0e10cSrcweir 					{
1031cdf0e10cSrcweir 						mpStyleMap = pSMap;
1032cdf0e10cSrcweir 						mpStyleMap->acquire();
1033cdf0e10cSrcweir 					}
1034cdf0e10cSrcweir 				}
1035cdf0e10cSrcweir 				OUString sBaseURI;
1036cdf0e10cSrcweir 				sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("BaseURI" ) );
1037cdf0e10cSrcweir                 if (xPropertySetInfo->hasPropertyByName(sPropName))
1038cdf0e10cSrcweir 				{
1039cdf0e10cSrcweir                     uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1040cdf0e10cSrcweir                     aAny >>= sBaseURI;
1041cdf0e10cSrcweir 					mpImpl->aBaseURL.SetURL( sBaseURI );
1042cdf0e10cSrcweir                     mpImpl->aDocBase.SetURL( sBaseURI );
1043cdf0e10cSrcweir 				}
1044cdf0e10cSrcweir 				OUString sRelPath;
1045cdf0e10cSrcweir 				sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamRelPath" ) );
1046cdf0e10cSrcweir 				if( xPropertySetInfo->hasPropertyByName(sPropName) )
1047cdf0e10cSrcweir 				{
1048cdf0e10cSrcweir 					uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1049cdf0e10cSrcweir 					aAny >>= sRelPath;
1050cdf0e10cSrcweir 				}
1051cdf0e10cSrcweir 				OUString sName;
1052cdf0e10cSrcweir 				sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamName" ) );
1053cdf0e10cSrcweir 				if( xPropertySetInfo->hasPropertyByName(sPropName) )
1054cdf0e10cSrcweir 				{
1055cdf0e10cSrcweir 					uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1056cdf0e10cSrcweir 					aAny >>= sName;
1057cdf0e10cSrcweir 				}
1058cdf0e10cSrcweir 				if( sBaseURI.getLength() && sName.getLength() )
1059cdf0e10cSrcweir 				{
1060cdf0e10cSrcweir 					if( sRelPath.getLength() )
1061cdf0e10cSrcweir 						mpImpl->aBaseURL.insertName( sRelPath );
1062cdf0e10cSrcweir 					mpImpl->aBaseURL.insertName( sName );
1063cdf0e10cSrcweir 				}
1064cdf0e10cSrcweir                 mpImpl->mStreamName = sName; // Note: may be empty (XSLT)
1065cdf0e10cSrcweir                 // --> OD 2004-08-10 #i28749# - retrieve property <ShapePositionInHoriL2R>
1066cdf0e10cSrcweir                 sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("ShapePositionInHoriL2R" ) );
1067cdf0e10cSrcweir                 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1068cdf0e10cSrcweir                 {
1069cdf0e10cSrcweir                     uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1070cdf0e10cSrcweir                     aAny >>= (mpImpl->mbShapePositionInHoriL2R);
1071cdf0e10cSrcweir                 }
1072cdf0e10cSrcweir                 // <--
1073cdf0e10cSrcweir                 // --> OD 2007-12-19 #152540#
1074cdf0e10cSrcweir                 sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("TextDocInOOoFileFormat" ) );
1075cdf0e10cSrcweir                 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1076cdf0e10cSrcweir                 {
1077cdf0e10cSrcweir                     uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1078cdf0e10cSrcweir                     aAny >>= (mpImpl->mbTextDocInOOoFileFormat);
1079cdf0e10cSrcweir                 }
1080cdf0e10cSrcweir                 // <--
1081cdf0e10cSrcweir             }
1082cdf0e10cSrcweir 		}
1083cdf0e10cSrcweir 	}
1084cdf0e10cSrcweir }
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir // XServiceInfo
1087cdf0e10cSrcweir OUString SAL_CALL SvXMLImport::getImplementationName()
1088cdf0e10cSrcweir 	throw(uno::RuntimeException)
1089cdf0e10cSrcweir {
1090cdf0e10cSrcweir 	OUString aStr;
1091cdf0e10cSrcweir 	return aStr;
1092cdf0e10cSrcweir }
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir sal_Bool SAL_CALL SvXMLImport::supportsService( const OUString& rServiceName )
1095cdf0e10cSrcweir 	throw(::com::sun::star::uno::RuntimeException)
1096cdf0e10cSrcweir {
1097cdf0e10cSrcweir     return
1098cdf0e10cSrcweir         rServiceName.equalsAsciiL(
1099cdf0e10cSrcweir             "com.sun.star.document.ImportFilter",
1100cdf0e10cSrcweir             sizeof("com.sun.star.document.ImportFilter")-1 ) ||
1101cdf0e10cSrcweir         rServiceName.equalsAsciiL(
1102cdf0e10cSrcweir             "com.sun.star.xml.XMLImportFilter",
1103cdf0e10cSrcweir             sizeof("com.sun.star.xml.XMLImportFilter")-1);
1104cdf0e10cSrcweir }
1105cdf0e10cSrcweir 
1106cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvXMLImport::getSupportedServiceNames(  )
1107cdf0e10cSrcweir 	throw(uno::RuntimeException)
1108cdf0e10cSrcweir {
1109cdf0e10cSrcweir     uno::Sequence<OUString> aSeq(2);
1110cdf0e10cSrcweir     aSeq[0] = OUString(
1111cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportFilter"));
1112cdf0e10cSrcweir     aSeq[1] = OUString(
1113cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLImportFilter"));
1114cdf0e10cSrcweir     return aSeq;
1115cdf0e10cSrcweir }
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir XMLTextImportHelper* SvXMLImport::CreateTextImport()
1120cdf0e10cSrcweir {
1121cdf0e10cSrcweir 	return new XMLTextImportHelper( mxModel, *this );
1122cdf0e10cSrcweir }
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir XMLShapeImportHelper* SvXMLImport::CreateShapeImport()
1125cdf0e10cSrcweir {
1126cdf0e10cSrcweir 	return new XMLShapeImportHelper( *this, mxModel );
1127cdf0e10cSrcweir }
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir #ifndef SVX_LIGHT
1130cdf0e10cSrcweir SchXMLImportHelper* SvXMLImport::CreateChartImport()
1131cdf0e10cSrcweir {
1132cdf0e10cSrcweir 	return new SchXMLImportHelper();
1133cdf0e10cSrcweir }
1134cdf0e10cSrcweir #endif
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir #ifndef SVX_LIGHT
1137cdf0e10cSrcweir ::xmloff::OFormLayerXMLImport* SvXMLImport::CreateFormImport()
1138cdf0e10cSrcweir {
1139cdf0e10cSrcweir 	return new ::xmloff::OFormLayerXMLImport(*this);
1140cdf0e10cSrcweir }
1141cdf0e10cSrcweir #endif // #ifndef SVX_LIGHT
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////////
1145cdf0e10cSrcweir //
1146cdf0e10cSrcweir // Get or create fill/line/lineend-style-helper
1147cdf0e10cSrcweir //
1148cdf0e10cSrcweir 
1149cdf0e10cSrcweir const Reference< container::XNameContainer > & SvXMLImport::GetGradientHelper()
1150cdf0e10cSrcweir {
1151cdf0e10cSrcweir 	if( !mxGradientHelper.is() )
1152cdf0e10cSrcweir 	{
1153cdf0e10cSrcweir 		if( mxModel.is() )
1154cdf0e10cSrcweir 		{
1155cdf0e10cSrcweir 			Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1156cdf0e10cSrcweir 			if( xServiceFact.is() )
1157cdf0e10cSrcweir 			{
1158cdf0e10cSrcweir 				try
1159cdf0e10cSrcweir 				{
1160cdf0e10cSrcweir 					mxGradientHelper =  Reference< container::XNameContainer >( xServiceFact->createInstance(
1161cdf0e10cSrcweir 						OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GradientTable" ) ) ), UNO_QUERY);
1162cdf0e10cSrcweir 				}
1163cdf0e10cSrcweir 				catch( lang::ServiceNotRegisteredException& )
1164cdf0e10cSrcweir 				{}
1165cdf0e10cSrcweir 			}
1166cdf0e10cSrcweir 		}
1167cdf0e10cSrcweir 	}
1168cdf0e10cSrcweir 
1169cdf0e10cSrcweir 	return mxGradientHelper;
1170cdf0e10cSrcweir }
1171cdf0e10cSrcweir 
1172cdf0e10cSrcweir const Reference< container::XNameContainer > & SvXMLImport::GetHatchHelper()
1173cdf0e10cSrcweir {
1174cdf0e10cSrcweir 	if( !mxHatchHelper.is() )
1175cdf0e10cSrcweir 	{
1176cdf0e10cSrcweir 		if( mxModel.is() )
1177cdf0e10cSrcweir 		{
1178cdf0e10cSrcweir 			Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1179cdf0e10cSrcweir 			if( xServiceFact.is() )
1180cdf0e10cSrcweir 			{
1181cdf0e10cSrcweir 				try
1182cdf0e10cSrcweir 				{
1183cdf0e10cSrcweir 					mxHatchHelper =  Reference< container::XNameContainer >( xServiceFact->createInstance(
1184cdf0e10cSrcweir 						OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.HatchTable" ) ) ), UNO_QUERY);
1185cdf0e10cSrcweir 				}
1186cdf0e10cSrcweir 				catch( lang::ServiceNotRegisteredException& )
1187cdf0e10cSrcweir 				{}
1188cdf0e10cSrcweir 			}
1189cdf0e10cSrcweir 		}
1190cdf0e10cSrcweir 	}
1191cdf0e10cSrcweir 
1192cdf0e10cSrcweir 	return mxHatchHelper;
1193cdf0e10cSrcweir }
1194cdf0e10cSrcweir 
1195cdf0e10cSrcweir const Reference< container::XNameContainer > & SvXMLImport::GetBitmapHelper()
1196cdf0e10cSrcweir {
1197cdf0e10cSrcweir 	if( !mxBitmapHelper.is() )
1198cdf0e10cSrcweir 	{
1199cdf0e10cSrcweir 		if( mxModel.is() )
1200cdf0e10cSrcweir 		{
1201cdf0e10cSrcweir 			Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1202cdf0e10cSrcweir 			if( xServiceFact.is() )
1203cdf0e10cSrcweir 			{
1204cdf0e10cSrcweir 				try
1205cdf0e10cSrcweir 				{
1206cdf0e10cSrcweir 					mxBitmapHelper =  Reference< container::XNameContainer >( xServiceFact->createInstance(
1207cdf0e10cSrcweir 						OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.BitmapTable" ) ) ), UNO_QUERY);
1208cdf0e10cSrcweir 				}
1209cdf0e10cSrcweir 				catch( lang::ServiceNotRegisteredException& )
1210cdf0e10cSrcweir 				{}
1211cdf0e10cSrcweir 			}
1212cdf0e10cSrcweir 		}
1213cdf0e10cSrcweir 	}
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir 	return mxBitmapHelper;
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir 
1218cdf0e10cSrcweir const Reference< container::XNameContainer > & SvXMLImport::GetTransGradientHelper()
1219cdf0e10cSrcweir {
1220cdf0e10cSrcweir 	if( !mxTransGradientHelper.is() )
1221cdf0e10cSrcweir 	{
1222cdf0e10cSrcweir 		if( mxModel.is() )
1223cdf0e10cSrcweir 		{
1224cdf0e10cSrcweir 			Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1225cdf0e10cSrcweir 			if( xServiceFact.is() )
1226cdf0e10cSrcweir 			{
1227cdf0e10cSrcweir 				try
1228cdf0e10cSrcweir 				{
1229cdf0e10cSrcweir 					mxTransGradientHelper =  Reference< container::XNameContainer >( xServiceFact->createInstance(
1230cdf0e10cSrcweir 						OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TransparencyGradientTable" ) ) ), UNO_QUERY);
1231cdf0e10cSrcweir 				}
1232cdf0e10cSrcweir 				catch( lang::ServiceNotRegisteredException& )
1233cdf0e10cSrcweir 				{}
1234cdf0e10cSrcweir 			}
1235cdf0e10cSrcweir 		}
1236cdf0e10cSrcweir 	}
1237cdf0e10cSrcweir 
1238cdf0e10cSrcweir 	return mxTransGradientHelper;
1239cdf0e10cSrcweir }
1240cdf0e10cSrcweir 
1241cdf0e10cSrcweir const Reference< container::XNameContainer > & SvXMLImport::GetMarkerHelper()
1242cdf0e10cSrcweir {
1243cdf0e10cSrcweir 	if( !mxMarkerHelper.is() )
1244cdf0e10cSrcweir 	{
1245cdf0e10cSrcweir 		if( mxModel.is() )
1246cdf0e10cSrcweir 		{
1247cdf0e10cSrcweir 			Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1248cdf0e10cSrcweir 			if( xServiceFact.is() )
1249cdf0e10cSrcweir 			{
1250cdf0e10cSrcweir 				try
1251cdf0e10cSrcweir 				{
1252cdf0e10cSrcweir 					mxMarkerHelper =  Reference< container::XNameContainer >( xServiceFact->createInstance(
1253cdf0e10cSrcweir 						OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.MarkerTable" ) ) ), UNO_QUERY);
1254cdf0e10cSrcweir 				}
1255cdf0e10cSrcweir 				catch( lang::ServiceNotRegisteredException& )
1256cdf0e10cSrcweir 				{}
1257cdf0e10cSrcweir 			}
1258cdf0e10cSrcweir 		}
1259cdf0e10cSrcweir 	}
1260cdf0e10cSrcweir 
1261cdf0e10cSrcweir 	return mxMarkerHelper;
1262cdf0e10cSrcweir }
1263cdf0e10cSrcweir 
1264cdf0e10cSrcweir const Reference< container::XNameContainer > & SvXMLImport::GetDashHelper()
1265cdf0e10cSrcweir {
1266cdf0e10cSrcweir 	if( !mxDashHelper.is() )
1267cdf0e10cSrcweir 	{
1268cdf0e10cSrcweir 		if( mxModel.is() )
1269cdf0e10cSrcweir 		{
1270cdf0e10cSrcweir 			Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1271cdf0e10cSrcweir 			if( xServiceFact.is() )
1272cdf0e10cSrcweir 			{
1273cdf0e10cSrcweir 				try
1274cdf0e10cSrcweir 				{
1275cdf0e10cSrcweir 					mxDashHelper =  Reference< container::XNameContainer >( xServiceFact->createInstance(
1276cdf0e10cSrcweir 						OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DashTable" ) ) ), UNO_QUERY);
1277cdf0e10cSrcweir 				}
1278cdf0e10cSrcweir 				catch( lang::ServiceNotRegisteredException& )
1279cdf0e10cSrcweir 				{}
1280cdf0e10cSrcweir 			}
1281cdf0e10cSrcweir 		}
1282cdf0e10cSrcweir 	}
1283cdf0e10cSrcweir 
1284cdf0e10cSrcweir 	return mxDashHelper;
1285cdf0e10cSrcweir }
1286cdf0e10cSrcweir 
1287cdf0e10cSrcweir sal_Bool SvXMLImport::IsPackageURL( const ::rtl::OUString& rURL ) const
1288cdf0e10cSrcweir {
1289cdf0e10cSrcweir 
1290cdf0e10cSrcweir 	// if, and only if, only parts are imported, then we're in a package
1291cdf0e10cSrcweir 	const sal_uInt32 nTest = IMPORT_META|IMPORT_STYLES|IMPORT_CONTENT|IMPORT_SETTINGS;
1292cdf0e10cSrcweir 	if( (mnImportFlags & nTest) == nTest )
1293cdf0e10cSrcweir 		return sal_False;
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir 	// Some quick tests: Some may rely on the package structure!
1296cdf0e10cSrcweir 	sal_Int32 nLen = rURL.getLength();
1297cdf0e10cSrcweir 	if( (nLen > 0 && '/' == rURL[0]) )
1298cdf0e10cSrcweir 		// RFC2396 net_path or abs_path
1299cdf0e10cSrcweir 		return sal_False;
1300cdf0e10cSrcweir 	else if( nLen > 1 && '.' == rURL[0] )
1301cdf0e10cSrcweir 	{
1302cdf0e10cSrcweir 		if( '.' == rURL[1] )
1303cdf0e10cSrcweir 			// ../: We are never going up one level, so we know
1304cdf0e10cSrcweir 			// it's not an external URI
1305cdf0e10cSrcweir 			return sal_False;
1306cdf0e10cSrcweir 		else if( '/' == rURL[1] )
1307cdf0e10cSrcweir 			// we are remaining on a level, so it's an package URI
1308cdf0e10cSrcweir 			return sal_True;
1309cdf0e10cSrcweir 	}
1310cdf0e10cSrcweir 
1311cdf0e10cSrcweir 	// Now check for a RFC2396 schema
1312cdf0e10cSrcweir 	sal_Int32 nPos = 1;
1313cdf0e10cSrcweir 	while( nPos < nLen )
1314cdf0e10cSrcweir 	{
1315cdf0e10cSrcweir 		switch( rURL[nPos] )
1316cdf0e10cSrcweir 		{
1317cdf0e10cSrcweir 		case '/':
1318cdf0e10cSrcweir 			// a relative path segement
1319cdf0e10cSrcweir 			return sal_True;
1320cdf0e10cSrcweir 		case ':':
1321cdf0e10cSrcweir 			// a schema
1322cdf0e10cSrcweir 			return sal_False;
1323cdf0e10cSrcweir 		default:
1324cdf0e10cSrcweir 			break;
1325cdf0e10cSrcweir 			// we don't care about any other characters
1326cdf0e10cSrcweir 		}
1327cdf0e10cSrcweir 		++nPos;
1328cdf0e10cSrcweir 	}
1329cdf0e10cSrcweir 
1330cdf0e10cSrcweir 	return sal_True;
1331cdf0e10cSrcweir }
1332cdf0e10cSrcweir 
1333cdf0e10cSrcweir ::rtl::OUString SvXMLImport::ResolveGraphicObjectURL( const ::rtl::OUString& rURL,
1334cdf0e10cSrcweir 									                  sal_Bool bLoadOnDemand )
1335cdf0e10cSrcweir {
1336cdf0e10cSrcweir 	::rtl::OUString sRet;
1337cdf0e10cSrcweir 
1338cdf0e10cSrcweir 	if( IsPackageURL( rURL ) )
1339cdf0e10cSrcweir 	{
1340cdf0e10cSrcweir 		if( !bLoadOnDemand && mxGraphicResolver.is() )
1341cdf0e10cSrcweir 		{
1342cdf0e10cSrcweir 			::rtl::OUString		aTmp( msPackageProtocol );
1343cdf0e10cSrcweir 			aTmp += rURL;
1344cdf0e10cSrcweir 			sRet = mxGraphicResolver->resolveGraphicObjectURL( aTmp );
1345cdf0e10cSrcweir 		}
1346cdf0e10cSrcweir 
1347cdf0e10cSrcweir 		if( !sRet.getLength() )
1348cdf0e10cSrcweir 		{
1349cdf0e10cSrcweir 			sRet = msPackageProtocol;
1350cdf0e10cSrcweir 			sRet += rURL;
1351cdf0e10cSrcweir 		}
1352cdf0e10cSrcweir 	}
1353cdf0e10cSrcweir 
1354cdf0e10cSrcweir 	if( !sRet.getLength() )
1355cdf0e10cSrcweir 		sRet = GetAbsoluteReference( rURL );
1356cdf0e10cSrcweir 
1357cdf0e10cSrcweir 	return sRet;
1358cdf0e10cSrcweir }
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir Reference< XOutputStream > SvXMLImport::GetStreamForGraphicObjectURLFromBase64()
1361cdf0e10cSrcweir {
1362cdf0e10cSrcweir 	Reference< XOutputStream > xOStm;
1363cdf0e10cSrcweir 	Reference< document::XBinaryStreamResolver > xStmResolver( mxGraphicResolver, UNO_QUERY );
1364cdf0e10cSrcweir 
1365cdf0e10cSrcweir 	if( xStmResolver.is() )
1366cdf0e10cSrcweir         xOStm = xStmResolver->createOutputStream();
1367cdf0e10cSrcweir 
1368cdf0e10cSrcweir 	return xOStm;
1369cdf0e10cSrcweir }
1370cdf0e10cSrcweir 
1371cdf0e10cSrcweir ::rtl::OUString SvXMLImport::ResolveGraphicObjectURLFromBase64(
1372cdf0e10cSrcweir 								 const Reference < XOutputStream >& rOut )
1373cdf0e10cSrcweir {
1374cdf0e10cSrcweir 	OUString sURL;
1375cdf0e10cSrcweir 	Reference< document::XBinaryStreamResolver > xStmResolver( mxGraphicResolver, UNO_QUERY );
1376cdf0e10cSrcweir 	if( xStmResolver.is() )
1377cdf0e10cSrcweir 		sURL = xStmResolver->resolveOutputStream( rOut );
1378cdf0e10cSrcweir 
1379cdf0e10cSrcweir 	return sURL;
1380cdf0e10cSrcweir }
1381cdf0e10cSrcweir 
1382cdf0e10cSrcweir ::rtl::OUString SvXMLImport::ResolveEmbeddedObjectURL(
1383cdf0e10cSrcweir 									const ::rtl::OUString& rURL,
1384cdf0e10cSrcweir 									const ::rtl::OUString& rClassId )
1385cdf0e10cSrcweir {
1386cdf0e10cSrcweir 	::rtl::OUString sRet;
1387cdf0e10cSrcweir 
1388cdf0e10cSrcweir 	if( IsPackageURL( rURL ) )
1389cdf0e10cSrcweir 	{
1390cdf0e10cSrcweir 		if ( mxEmbeddedResolver.is() )
1391cdf0e10cSrcweir 		{
1392cdf0e10cSrcweir 			OUString sURL( rURL );
1393cdf0e10cSrcweir 			if( rClassId.getLength() )
1394cdf0e10cSrcweir 			{
1395cdf0e10cSrcweir 				sURL += OUString( sal_Unicode('!') );
1396cdf0e10cSrcweir 				sURL += rClassId;
1397cdf0e10cSrcweir 			}
1398cdf0e10cSrcweir 			sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL( sURL );
1399cdf0e10cSrcweir 		}
1400cdf0e10cSrcweir 	}
1401cdf0e10cSrcweir 	else
1402cdf0e10cSrcweir 		sRet = GetAbsoluteReference( rURL );
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir 	return sRet;
1405cdf0e10cSrcweir }
1406cdf0e10cSrcweir 
1407cdf0e10cSrcweir Reference < XOutputStream >
1408cdf0e10cSrcweir 		SvXMLImport::GetStreamForEmbeddedObjectURLFromBase64()
1409cdf0e10cSrcweir {
1410cdf0e10cSrcweir 	Reference < XOutputStream > xOLEStream;
1411cdf0e10cSrcweir 
1412cdf0e10cSrcweir 	if( mxEmbeddedResolver.is() )
1413cdf0e10cSrcweir 	{
1414cdf0e10cSrcweir 		Reference< XNameAccess > xNA( mxEmbeddedResolver, UNO_QUERY );
1415cdf0e10cSrcweir 		if( xNA.is() )
1416cdf0e10cSrcweir 		{
1417cdf0e10cSrcweir 			OUString aURL( RTL_CONSTASCII_USTRINGPARAM( "Obj12345678" ) );
1418cdf0e10cSrcweir 			Any aAny = xNA->getByName( aURL );
1419cdf0e10cSrcweir 			aAny >>= xOLEStream;
1420cdf0e10cSrcweir 		}
1421cdf0e10cSrcweir 	}
1422cdf0e10cSrcweir 
1423cdf0e10cSrcweir 	return xOLEStream;
1424cdf0e10cSrcweir }
1425cdf0e10cSrcweir 
1426cdf0e10cSrcweir ::rtl::OUString SvXMLImport::ResolveEmbeddedObjectURLFromBase64()
1427cdf0e10cSrcweir {
1428cdf0e10cSrcweir 	::rtl::OUString sRet;
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir 	if( mxEmbeddedResolver.is() )
1431cdf0e10cSrcweir 	{
1432cdf0e10cSrcweir 		OUString aURL( RTL_CONSTASCII_USTRINGPARAM( "Obj12345678" ) );
1433cdf0e10cSrcweir 		sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL( aURL );
1434cdf0e10cSrcweir 	}
1435cdf0e10cSrcweir 
1436cdf0e10cSrcweir 	return sRet;
1437cdf0e10cSrcweir }
1438cdf0e10cSrcweir 
1439cdf0e10cSrcweir void SvXMLImport::AddStyleDisplayName( sal_uInt16 nFamily,
1440cdf0e10cSrcweir 									   const OUString& rName,
1441cdf0e10cSrcweir 									   const OUString& rDisplayName )
1442cdf0e10cSrcweir {
1443cdf0e10cSrcweir 	if( !mpStyleMap )
1444cdf0e10cSrcweir 	{
1445cdf0e10cSrcweir 		mpStyleMap = new StyleMap;
1446cdf0e10cSrcweir 		mpStyleMap->acquire();
1447cdf0e10cSrcweir 		if( mxImportInfo.is() )
1448cdf0e10cSrcweir 		{
1449cdf0e10cSrcweir 			OUString sPrivateData(
1450cdf0e10cSrcweir 					RTL_CONSTASCII_USTRINGPARAM("PrivateData" ) );
1451cdf0e10cSrcweir             Reference< beans::XPropertySetInfo > xPropertySetInfo =
1452cdf0e10cSrcweir 				mxImportInfo->getPropertySetInfo();
1453cdf0e10cSrcweir             if( xPropertySetInfo.is() &&
1454cdf0e10cSrcweir 				xPropertySetInfo->hasPropertyByName(sPrivateData) )
1455cdf0e10cSrcweir 			{
1456cdf0e10cSrcweir 				Reference < XInterface > xIfc(
1457cdf0e10cSrcweir 						static_cast< XUnoTunnel *>( mpStyleMap ) );
1458cdf0e10cSrcweir 				Any aAny;
1459cdf0e10cSrcweir 				aAny <<= xIfc;
1460cdf0e10cSrcweir 				mxImportInfo->setPropertyValue( sPrivateData, aAny );
1461cdf0e10cSrcweir 			}
1462cdf0e10cSrcweir 		}
1463cdf0e10cSrcweir 	}
1464cdf0e10cSrcweir 
1465cdf0e10cSrcweir 	StyleMap::key_type aKey( nFamily, rName );
1466cdf0e10cSrcweir 	StyleMap::value_type aValue( aKey, rDisplayName );
1467cdf0e10cSrcweir 	::std::pair<StyleMap::iterator,bool> aRes( mpStyleMap->insert( aValue ) );
1468cdf0e10cSrcweir 	OSL_ENSURE( aRes.second, "duplicate style name" );
1469cdf0e10cSrcweir 
1470cdf0e10cSrcweir }
1471cdf0e10cSrcweir 
1472cdf0e10cSrcweir OUString SvXMLImport::GetStyleDisplayName( sal_uInt16 nFamily,
1473cdf0e10cSrcweir 										   const OUString& rName ) const
1474cdf0e10cSrcweir {
1475cdf0e10cSrcweir 	OUString sName( rName );
1476cdf0e10cSrcweir 	if( mpStyleMap && rName.getLength() )
1477cdf0e10cSrcweir 	{
1478cdf0e10cSrcweir 		StyleMap::key_type aKey( nFamily, rName );
1479cdf0e10cSrcweir 		StyleMap::const_iterator aIter = mpStyleMap->find( aKey );
1480cdf0e10cSrcweir 		if( aIter != mpStyleMap->end() )
1481cdf0e10cSrcweir 			sName = (*aIter).second;
1482cdf0e10cSrcweir 	}
1483cdf0e10cSrcweir 	return sName;
1484cdf0e10cSrcweir }
1485cdf0e10cSrcweir 
1486cdf0e10cSrcweir void SvXMLImport::SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&)
1487cdf0e10cSrcweir {
1488cdf0e10cSrcweir }
1489cdf0e10cSrcweir 
1490cdf0e10cSrcweir void SvXMLImport::SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&)
1491cdf0e10cSrcweir {
1492cdf0e10cSrcweir }
1493cdf0e10cSrcweir 
1494cdf0e10cSrcweir void SvXMLImport::SetDocumentSpecificSettings(const ::rtl::OUString& _rSettingsGroupName, const uno::Sequence<beans::PropertyValue>& _rSettings)
1495cdf0e10cSrcweir {
1496cdf0e10cSrcweir     (void)_rSettingsGroupName;
1497cdf0e10cSrcweir     (void)_rSettings;
1498cdf0e10cSrcweir }
1499cdf0e10cSrcweir 
1500cdf0e10cSrcweir ProgressBarHelper*	SvXMLImport::GetProgressBarHelper()
1501cdf0e10cSrcweir {
1502cdf0e10cSrcweir 	if (!mpProgressBarHelper)
1503cdf0e10cSrcweir 	{
1504cdf0e10cSrcweir 		mpProgressBarHelper = new ProgressBarHelper(mxStatusIndicator, sal_False);
1505cdf0e10cSrcweir 
1506cdf0e10cSrcweir 		if (mxImportInfo.is())
1507cdf0e10cSrcweir 		{
1508cdf0e10cSrcweir 			uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
1509cdf0e10cSrcweir 			if (xPropertySetInfo.is())
1510cdf0e10cSrcweir 			{
1511cdf0e10cSrcweir 				OUString sProgressRange(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSRANGE));
1512cdf0e10cSrcweir 				OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSMAX));
1513cdf0e10cSrcweir 				OUString sProgressCurrent(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSCURRENT));
1514cdf0e10cSrcweir                 OUString sRepeat(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSREPEAT));
1515cdf0e10cSrcweir 				if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
1516cdf0e10cSrcweir 					xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
1517cdf0e10cSrcweir 					xPropertySetInfo->hasPropertyByName(sProgressRange))
1518cdf0e10cSrcweir 				{
1519cdf0e10cSrcweir 					uno::Any aAny;
1520cdf0e10cSrcweir 					sal_Int32 nProgressMax(0);
1521cdf0e10cSrcweir 					sal_Int32 nProgressCurrent(0);
1522cdf0e10cSrcweir 					sal_Int32 nProgressRange(0);
1523cdf0e10cSrcweir 					aAny = mxImportInfo->getPropertyValue(sProgressRange);
1524cdf0e10cSrcweir 					if (aAny >>= nProgressRange)
1525cdf0e10cSrcweir 						mpProgressBarHelper->SetRange(nProgressRange);
1526cdf0e10cSrcweir 					aAny = mxImportInfo->getPropertyValue(sProgressMax);
1527cdf0e10cSrcweir 					if (aAny >>= nProgressMax)
1528cdf0e10cSrcweir 						mpProgressBarHelper->SetReference(nProgressMax);
1529cdf0e10cSrcweir 					aAny = mxImportInfo->getPropertyValue(sProgressCurrent);
1530cdf0e10cSrcweir 					if (aAny >>= nProgressCurrent)
1531cdf0e10cSrcweir 						mpProgressBarHelper->SetValue(nProgressCurrent);
1532cdf0e10cSrcweir 				}
1533cdf0e10cSrcweir                 if (xPropertySetInfo->hasPropertyByName(sRepeat))
1534cdf0e10cSrcweir                 {
1535cdf0e10cSrcweir                     uno::Any aAny = mxImportInfo->getPropertyValue(sRepeat);
1536cdf0e10cSrcweir                     if (aAny.getValueType() == getBooleanCppuType())
1537cdf0e10cSrcweir                         mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
1538cdf0e10cSrcweir                     else {
1539cdf0e10cSrcweir                         DBG_ERRORFILE("why is it no boolean?");
1540cdf0e10cSrcweir                     }
1541cdf0e10cSrcweir                 }
1542cdf0e10cSrcweir 			}
1543cdf0e10cSrcweir 		}
1544cdf0e10cSrcweir 	}
1545cdf0e10cSrcweir 	return mpProgressBarHelper;
1546cdf0e10cSrcweir }
1547cdf0e10cSrcweir 
1548cdf0e10cSrcweir void SvXMLImport::AddNumberStyle(sal_Int32 nKey, const OUString& rName)
1549cdf0e10cSrcweir {
1550cdf0e10cSrcweir 	if (!mxNumberStyles.is())
1551cdf0e10cSrcweir 		mxNumberStyles = uno::Reference< container::XNameContainer >( comphelper::NameContainer_createInstance( ::getCppuType((const sal_Int32*)0)) );
1552cdf0e10cSrcweir 	if (mxNumberStyles.is())
1553cdf0e10cSrcweir 	{
1554cdf0e10cSrcweir 		uno::Any aAny;
1555cdf0e10cSrcweir 		aAny <<= nKey;
1556cdf0e10cSrcweir 		try
1557cdf0e10cSrcweir 		{
1558cdf0e10cSrcweir 			mxNumberStyles->insertByName(rName, aAny);
1559cdf0e10cSrcweir 		}
1560cdf0e10cSrcweir 		catch ( uno::Exception& )
1561cdf0e10cSrcweir 		{
1562cdf0e10cSrcweir 			DBG_ERROR("Numberformat could not be inserted");
1563cdf0e10cSrcweir 		}
1564cdf0e10cSrcweir 	}
1565cdf0e10cSrcweir 	else {
1566cdf0e10cSrcweir 		DBG_ERROR("not possible to create NameContainer");
1567cdf0e10cSrcweir     }
1568cdf0e10cSrcweir }
1569cdf0e10cSrcweir 
1570cdf0e10cSrcweir XMLEventImportHelper& SvXMLImport::GetEventImport()
1571cdf0e10cSrcweir {
1572cdf0e10cSrcweir #ifndef SVX_LIGHT
1573cdf0e10cSrcweir 	if (!mpEventImportHelper)
1574cdf0e10cSrcweir 	{
1575cdf0e10cSrcweir 		// construct event helper and register StarBasic handler and standard
1576cdf0e10cSrcweir 		// event tables
1577cdf0e10cSrcweir 		mpEventImportHelper = new XMLEventImportHelper();
1578cdf0e10cSrcweir 		OUString sStarBasic(GetXMLToken(XML_STARBASIC));
1579cdf0e10cSrcweir 		mpEventImportHelper->RegisterFactory(sStarBasic,
1580cdf0e10cSrcweir 											new XMLStarBasicContextFactory());
1581cdf0e10cSrcweir 		OUString sScript(GetXMLToken(XML_SCRIPT));
1582cdf0e10cSrcweir 		mpEventImportHelper->RegisterFactory(sScript,
1583cdf0e10cSrcweir 											new XMLScriptContextFactory());
1584cdf0e10cSrcweir 		mpEventImportHelper->AddTranslationTable(aStandardEventTable);
1585cdf0e10cSrcweir 
1586cdf0e10cSrcweir         // register StarBasic event handler with capitalized spelling
1587cdf0e10cSrcweir 		OUString sStarBasicCap(RTL_CONSTASCII_USTRINGPARAM("StarBasic"));
1588cdf0e10cSrcweir 		mpEventImportHelper->RegisterFactory(sStarBasicCap,
1589cdf0e10cSrcweir 											new XMLStarBasicContextFactory());
1590cdf0e10cSrcweir 	}
1591cdf0e10cSrcweir #endif
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir 	return *mpEventImportHelper;
1594cdf0e10cSrcweir }
1595cdf0e10cSrcweir 
1596cdf0e10cSrcweir void SvXMLImport::SetFontDecls( XMLFontStylesContext *pFontDecls )
1597cdf0e10cSrcweir {
1598cdf0e10cSrcweir 	mxFontDecls = pFontDecls;
1599cdf0e10cSrcweir 	GetTextImport()->SetFontDecls( pFontDecls );
1600cdf0e10cSrcweir }
1601cdf0e10cSrcweir 
1602cdf0e10cSrcweir void SvXMLImport::SetStyles( SvXMLStylesContext *pStyles )
1603cdf0e10cSrcweir {
1604cdf0e10cSrcweir 	mxStyles = pStyles;
1605cdf0e10cSrcweir }
1606cdf0e10cSrcweir 
1607cdf0e10cSrcweir void SvXMLImport::SetAutoStyles( SvXMLStylesContext *pAutoStyles )
1608cdf0e10cSrcweir {
1609cdf0e10cSrcweir 	if (pAutoStyles && mxNumberStyles.is() && (mnImportFlags & IMPORT_CONTENT) )
1610cdf0e10cSrcweir 	{
1611cdf0e10cSrcweir 		uno::Reference<xml::sax::XAttributeList> xAttrList;
1612cdf0e10cSrcweir 		uno::Sequence< ::rtl::OUString > aNames = mxNumberStyles->getElementNames();
1613cdf0e10cSrcweir 		sal_uInt32 nCount(aNames.getLength());
1614cdf0e10cSrcweir 		if (nCount)
1615cdf0e10cSrcweir 		{
1616cdf0e10cSrcweir 			const OUString* pNames = aNames.getConstArray();
1617cdf0e10cSrcweir 			if ( pNames )
1618cdf0e10cSrcweir 			{
1619cdf0e10cSrcweir 				SvXMLStyleContext* pContext;
1620cdf0e10cSrcweir 				uno::Any aAny;
1621cdf0e10cSrcweir 				sal_Int32 nKey(0);
1622cdf0e10cSrcweir 				for (sal_uInt32 i = 0; i < nCount; i++, pNames++)
1623cdf0e10cSrcweir 				{
1624cdf0e10cSrcweir 					aAny = mxNumberStyles->getByName(*pNames);
1625cdf0e10cSrcweir 					if (aAny >>= nKey)
1626cdf0e10cSrcweir 					{
1627cdf0e10cSrcweir 						pContext = new SvXMLNumFormatContext( *this, XML_NAMESPACE_NUMBER,
1628cdf0e10cSrcweir 									*pNames, xAttrList, nKey, *pAutoStyles );
1629cdf0e10cSrcweir 						pAutoStyles->AddStyle(*pContext);
1630cdf0e10cSrcweir 					}
1631cdf0e10cSrcweir 				}
1632cdf0e10cSrcweir 			}
1633cdf0e10cSrcweir 		}
1634cdf0e10cSrcweir 	}
1635cdf0e10cSrcweir 	mxAutoStyles = pAutoStyles;
1636cdf0e10cSrcweir 	GetTextImport()->SetAutoStyles( pAutoStyles );
1637cdf0e10cSrcweir 	GetShapeImport()->SetAutoStylesContext( pAutoStyles );
1638cdf0e10cSrcweir #ifndef SVX_LIGHT
1639cdf0e10cSrcweir 	GetChartImport()->SetAutoStylesContext( pAutoStyles );
1640cdf0e10cSrcweir 	GetFormImport()->setAutoStyleContext( pAutoStyles );
1641cdf0e10cSrcweir #endif
1642cdf0e10cSrcweir }
1643cdf0e10cSrcweir 
1644cdf0e10cSrcweir void SvXMLImport::SetMasterStyles( SvXMLStylesContext *pMasterStyles )
1645cdf0e10cSrcweir {
1646cdf0e10cSrcweir 	mxMasterStyles = pMasterStyles;
1647cdf0e10cSrcweir }
1648cdf0e10cSrcweir 
1649cdf0e10cSrcweir XMLFontStylesContext *SvXMLImport::GetFontDecls()
1650cdf0e10cSrcweir {
1651cdf0e10cSrcweir 	return (XMLFontStylesContext *)&mxFontDecls;
1652cdf0e10cSrcweir }
1653cdf0e10cSrcweir 
1654cdf0e10cSrcweir SvXMLStylesContext *SvXMLImport::GetStyles()
1655cdf0e10cSrcweir {
1656cdf0e10cSrcweir 	return (SvXMLStylesContext *)&mxStyles;
1657cdf0e10cSrcweir }
1658cdf0e10cSrcweir 
1659cdf0e10cSrcweir SvXMLStylesContext *SvXMLImport::GetAutoStyles()
1660cdf0e10cSrcweir {
1661cdf0e10cSrcweir 	return (SvXMLStylesContext *)&mxAutoStyles;
1662cdf0e10cSrcweir }
1663cdf0e10cSrcweir 
1664cdf0e10cSrcweir SvXMLStylesContext *SvXMLImport::GetMasterStyles()
1665cdf0e10cSrcweir {
1666cdf0e10cSrcweir 	return (SvXMLStylesContext *)&mxMasterStyles;
1667cdf0e10cSrcweir }
1668cdf0e10cSrcweir 
1669cdf0e10cSrcweir const XMLFontStylesContext *SvXMLImport::GetFontDecls() const
1670cdf0e10cSrcweir {
1671cdf0e10cSrcweir 	return (const XMLFontStylesContext *)&mxFontDecls;
1672cdf0e10cSrcweir }
1673cdf0e10cSrcweir 
1674cdf0e10cSrcweir const SvXMLStylesContext *SvXMLImport::GetStyles() const
1675cdf0e10cSrcweir {
1676cdf0e10cSrcweir 	return (const SvXMLStylesContext *)&mxStyles;
1677cdf0e10cSrcweir }
1678cdf0e10cSrcweir 
1679cdf0e10cSrcweir const SvXMLStylesContext *SvXMLImport::GetAutoStyles() const
1680cdf0e10cSrcweir {
1681cdf0e10cSrcweir 	return (const SvXMLStylesContext *)&mxAutoStyles;
1682cdf0e10cSrcweir }
1683cdf0e10cSrcweir 
1684cdf0e10cSrcweir const SvXMLStylesContext *SvXMLImport::GetMasterStyles() const
1685cdf0e10cSrcweir {
1686cdf0e10cSrcweir 	return (const SvXMLStylesContext *)&mxMasterStyles;
1687cdf0e10cSrcweir }
1688cdf0e10cSrcweir 
1689cdf0e10cSrcweir OUString SvXMLImport::GetAbsoluteReference(const OUString& rValue) const
1690cdf0e10cSrcweir {
1691cdf0e10cSrcweir 	if( rValue.getLength() == 0 || rValue[0] == '#' )
1692cdf0e10cSrcweir 		return rValue;
1693cdf0e10cSrcweir 
1694cdf0e10cSrcweir 	INetURLObject aAbsURL;
1695cdf0e10cSrcweir 	if( mpImpl->aBaseURL.GetNewAbsURL( rValue, &aAbsURL ) )
1696cdf0e10cSrcweir 		return aAbsURL.GetMainURL( INetURLObject::DECODE_TO_IURI );
1697cdf0e10cSrcweir 	else
1698cdf0e10cSrcweir 		return rValue;
1699cdf0e10cSrcweir }
1700cdf0e10cSrcweir 
1701cdf0e10cSrcweir sal_Bool SvXMLImport::IsODFVersionConsistent( const ::rtl::OUString& aODFVersion )
1702cdf0e10cSrcweir {
1703cdf0e10cSrcweir     // the check returns sal_False only if the storage version could be retrieved
1704cdf0e10cSrcweir     sal_Bool bResult = sal_True;
1705cdf0e10cSrcweir 
1706cdf0e10cSrcweir     if ( aODFVersion.getLength() && aODFVersion.compareTo( ODFVER_012_TEXT ) >= 0 )
1707cdf0e10cSrcweir     {
1708cdf0e10cSrcweir         // check the consistency only for the ODF1.2 and later ( according to content.xml )
1709cdf0e10cSrcweir         // manifest.xml might have no version, it should be checked here and the correct version should be set
1710cdf0e10cSrcweir         try
1711cdf0e10cSrcweir         {
1712cdf0e10cSrcweir             uno::Reference< document::XStorageBasedDocument > xDoc( mxModel, uno::UNO_QUERY_THROW );
1713cdf0e10cSrcweir             uno::Reference< embed::XStorage > xStor = xDoc->getDocumentStorage();
1714cdf0e10cSrcweir             uno::Reference< beans::XPropertySet > xStorProps( xStor, uno::UNO_QUERY_THROW );
1715cdf0e10cSrcweir 
1716cdf0e10cSrcweir             // the check should be done only for OASIS format
1717cdf0e10cSrcweir             ::rtl::OUString aMediaType;
1718cdf0e10cSrcweir             xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ) ) >>= aMediaType;
1719cdf0e10cSrcweir             if ( ::comphelper::OStorageHelper::GetXStorageFormat( xStor ) >= SOFFICE_FILEFORMAT_8 )
1720cdf0e10cSrcweir             {
1721cdf0e10cSrcweir                 sal_Bool bRepairPackage = sal_False;
1722cdf0e10cSrcweir                 try
1723cdf0e10cSrcweir                 {
1724cdf0e10cSrcweir                     xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) ) )
1725cdf0e10cSrcweir                         >>= bRepairPackage;
1726cdf0e10cSrcweir                 } catch ( uno::Exception& )
1727cdf0e10cSrcweir                 {}
1728cdf0e10cSrcweir 
1729cdf0e10cSrcweir                 // check only if not in Repair mode
1730cdf0e10cSrcweir                 if ( !bRepairPackage )
1731cdf0e10cSrcweir                 {
1732cdf0e10cSrcweir                     ::rtl::OUString aStorVersion;
1733cdf0e10cSrcweir                     xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) )
1734cdf0e10cSrcweir                         >>= aStorVersion;
1735cdf0e10cSrcweir 
1736cdf0e10cSrcweir                     // if the storage version is set in manifest.xml, it must be the same as in content.xml
1737cdf0e10cSrcweir                     // if not, set it explicitly to be used further ( it will work even for readonly storage )
1738cdf0e10cSrcweir                     // This workaround is not nice, but I see no other way to handle it, since there are
1739cdf0e10cSrcweir                     // ODF1.2 documents without version in manifest.xml
1740cdf0e10cSrcweir                     if ( aStorVersion.getLength() )
1741cdf0e10cSrcweir                         bResult = aODFVersion.equals( aStorVersion );
1742cdf0e10cSrcweir                     else
1743cdf0e10cSrcweir                         xStorProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ),
1744cdf0e10cSrcweir                                                       uno::makeAny( aODFVersion ) );
1745cdf0e10cSrcweir 
1746cdf0e10cSrcweir                     if ( bResult )
1747cdf0e10cSrcweir                     {
1748cdf0e10cSrcweir                         sal_Bool bInconsistent = sal_False;
1749cdf0e10cSrcweir                         xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsInconsistent" ) ) )
1750cdf0e10cSrcweir                             >>= bInconsistent;
1751cdf0e10cSrcweir                         bResult = !bInconsistent;
1752cdf0e10cSrcweir                     }
1753cdf0e10cSrcweir                 }
1754cdf0e10cSrcweir             }
1755cdf0e10cSrcweir         }
1756cdf0e10cSrcweir         catch( uno::Exception& )
1757cdf0e10cSrcweir         {}
1758cdf0e10cSrcweir     }
1759cdf0e10cSrcweir 
1760cdf0e10cSrcweir     return bResult;
1761cdf0e10cSrcweir }
1762cdf0e10cSrcweir 
1763cdf0e10cSrcweir void SvXMLImport::_CreateNumberFormatsSupplier()
1764cdf0e10cSrcweir {
1765cdf0e10cSrcweir     DBG_ASSERT( !mxNumberFormatsSupplier.is(),
1766cdf0e10cSrcweir                 "number formats supplier already exists!" );
1767cdf0e10cSrcweir     if(mxModel.is())
1768cdf0e10cSrcweir     	mxNumberFormatsSupplier =
1769cdf0e10cSrcweir         	uno::Reference< util::XNumberFormatsSupplier> (mxModel, uno::UNO_QUERY);
1770cdf0e10cSrcweir }
1771cdf0e10cSrcweir 
1772cdf0e10cSrcweir 
1773cdf0e10cSrcweir void SvXMLImport::_CreateDataStylesImport()
1774cdf0e10cSrcweir {
1775cdf0e10cSrcweir     DBG_ASSERT( mpNumImport == NULL, "data styles import already exists!" );
1776cdf0e10cSrcweir     uno::Reference<util::XNumberFormatsSupplier> xNum =
1777cdf0e10cSrcweir         GetNumberFormatsSupplier();
1778cdf0e10cSrcweir     if ( xNum.is() )
1779cdf0e10cSrcweir         mpNumImport = new SvXMLNumFmtHelper(xNum, getServiceFactory());
1780cdf0e10cSrcweir }
1781cdf0e10cSrcweir 
1782cdf0e10cSrcweir 
1783cdf0e10cSrcweir sal_Unicode SvXMLImport::ConvStarBatsCharToStarSymbol( sal_Unicode c )
1784cdf0e10cSrcweir {
1785cdf0e10cSrcweir 	sal_Unicode cNew = c;
1786cdf0e10cSrcweir 	if( !mpImpl->hBatsFontConv )
1787cdf0e10cSrcweir 	{
1788cdf0e10cSrcweir 		OUString sStarBats( RTL_CONSTASCII_USTRINGPARAM( "StarBats" ) );
1789cdf0e10cSrcweir 		mpImpl->hBatsFontConv = CreateFontToSubsFontConverter( sStarBats,
1790cdf0e10cSrcweir 				 FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS );
1791cdf0e10cSrcweir 		OSL_ENSURE( mpImpl->hBatsFontConv, "Got no symbol font converter" );
1792cdf0e10cSrcweir 	}
1793cdf0e10cSrcweir 	if( mpImpl->hBatsFontConv )
1794cdf0e10cSrcweir 	{
1795cdf0e10cSrcweir 		cNew = ConvertFontToSubsFontChar( mpImpl->hBatsFontConv, c );
1796cdf0e10cSrcweir 	}
1797cdf0e10cSrcweir 
1798cdf0e10cSrcweir 	return cNew;
1799cdf0e10cSrcweir }
1800cdf0e10cSrcweir 
1801cdf0e10cSrcweir sal_Unicode SvXMLImport::ConvStarMathCharToStarSymbol( sal_Unicode c )
1802cdf0e10cSrcweir {
1803cdf0e10cSrcweir 	sal_Unicode cNew = c;
1804cdf0e10cSrcweir 	if( !mpImpl->hMathFontConv )
1805cdf0e10cSrcweir 	{
1806cdf0e10cSrcweir 		OUString sStarMath( RTL_CONSTASCII_USTRINGPARAM( "StarMath" ) );
1807cdf0e10cSrcweir 		mpImpl->hMathFontConv = CreateFontToSubsFontConverter( sStarMath,
1808cdf0e10cSrcweir 				 FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS );
1809cdf0e10cSrcweir 		OSL_ENSURE( mpImpl->hMathFontConv, "Got no symbol font converter" );
1810cdf0e10cSrcweir 	}
1811cdf0e10cSrcweir 	if( mpImpl->hMathFontConv )
1812cdf0e10cSrcweir 	{
1813cdf0e10cSrcweir 		cNew = ConvertFontToSubsFontChar( mpImpl->hMathFontConv, c );
1814cdf0e10cSrcweir 	}
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir 	return cNew;
1817cdf0e10cSrcweir }
1818cdf0e10cSrcweir 
1819cdf0e10cSrcweir 
1820cdf0e10cSrcweir 
1821cdf0e10cSrcweir void SvXMLImport::SetError(
1822cdf0e10cSrcweir     sal_Int32 nId,
1823cdf0e10cSrcweir     const Sequence<OUString>& rMsgParams,
1824cdf0e10cSrcweir     const OUString& rExceptionMessage,
1825cdf0e10cSrcweir     const Reference<xml::sax::XLocator>& rLocator )
1826cdf0e10cSrcweir {
1827cdf0e10cSrcweir     // maintain error flags
1828cdf0e10cSrcweir     if ( ( nId & XMLERROR_FLAG_ERROR ) != 0 )
1829cdf0e10cSrcweir         mnErrorFlags |= ERROR_ERROR_OCCURED;
1830cdf0e10cSrcweir     if ( ( nId & XMLERROR_FLAG_WARNING ) != 0 )
1831cdf0e10cSrcweir         mnErrorFlags |= ERROR_WARNING_OCCURED;
1832cdf0e10cSrcweir     if ( ( nId & XMLERROR_FLAG_SEVERE ) != 0 )
1833cdf0e10cSrcweir         mnErrorFlags |= ERROR_DO_NOTHING;
1834cdf0e10cSrcweir 
1835cdf0e10cSrcweir     // create error list on demand
1836cdf0e10cSrcweir     if ( mpXMLErrors == NULL )
1837cdf0e10cSrcweir         mpXMLErrors = new XMLErrors();
1838cdf0e10cSrcweir 
1839cdf0e10cSrcweir     // save error information
1840cdf0e10cSrcweir     // use document locator (if none supplied)
1841cdf0e10cSrcweir     mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage,
1842cdf0e10cSrcweir                            rLocator.is() ? rLocator : mxLocator );
1843cdf0e10cSrcweir }
1844cdf0e10cSrcweir 
1845cdf0e10cSrcweir void SvXMLImport::SetError(
1846cdf0e10cSrcweir     sal_Int32 nId,
1847cdf0e10cSrcweir     const Sequence<OUString>& rMsgParams)
1848cdf0e10cSrcweir {
1849cdf0e10cSrcweir     OUString sEmpty;
1850cdf0e10cSrcweir     SetError( nId, rMsgParams, sEmpty, NULL );
1851cdf0e10cSrcweir }
1852cdf0e10cSrcweir 
1853cdf0e10cSrcweir void SvXMLImport::SetError(
1854cdf0e10cSrcweir     sal_Int32 nId)
1855cdf0e10cSrcweir {
1856cdf0e10cSrcweir     Sequence<OUString> aSeq(0);
1857cdf0e10cSrcweir     SetError( nId, aSeq );
1858cdf0e10cSrcweir }
1859cdf0e10cSrcweir 
1860cdf0e10cSrcweir void SvXMLImport::SetError(
1861cdf0e10cSrcweir     sal_Int32 nId,
1862cdf0e10cSrcweir     const OUString& rMsg1)
1863cdf0e10cSrcweir {
1864cdf0e10cSrcweir     Sequence<OUString> aSeq(1);
1865cdf0e10cSrcweir     OUString* pSeq = aSeq.getArray();
1866cdf0e10cSrcweir     pSeq[0] = rMsg1;
1867cdf0e10cSrcweir     SetError( nId, aSeq );
1868cdf0e10cSrcweir }
1869cdf0e10cSrcweir 
1870cdf0e10cSrcweir void SvXMLImport::SetError(
1871cdf0e10cSrcweir     sal_Int32 nId,
1872cdf0e10cSrcweir     const OUString& rMsg1,
1873cdf0e10cSrcweir     const OUString& rMsg2)
1874cdf0e10cSrcweir {
1875cdf0e10cSrcweir     Sequence<OUString> aSeq(2);
1876cdf0e10cSrcweir     OUString* pSeq = aSeq.getArray();
1877cdf0e10cSrcweir     pSeq[0] = rMsg1;
1878cdf0e10cSrcweir     pSeq[1] = rMsg2;
1879cdf0e10cSrcweir     SetError( nId, aSeq );
1880cdf0e10cSrcweir }
1881cdf0e10cSrcweir 
1882cdf0e10cSrcweir void SvXMLImport::SetError(
1883cdf0e10cSrcweir     sal_Int32 nId,
1884cdf0e10cSrcweir     const OUString& rMsg1,
1885cdf0e10cSrcweir     const OUString& rMsg2,
1886cdf0e10cSrcweir     const OUString& rMsg3)
1887cdf0e10cSrcweir {
1888cdf0e10cSrcweir     Sequence<OUString> aSeq(3);
1889cdf0e10cSrcweir     OUString* pSeq = aSeq.getArray();
1890cdf0e10cSrcweir     pSeq[0] = rMsg1;
1891cdf0e10cSrcweir     pSeq[1] = rMsg2;
1892cdf0e10cSrcweir     pSeq[2] = rMsg3;
1893cdf0e10cSrcweir     SetError( nId, aSeq );
1894cdf0e10cSrcweir }
1895cdf0e10cSrcweir 
1896cdf0e10cSrcweir void SvXMLImport::SetError(
1897cdf0e10cSrcweir     sal_Int32 nId,
1898cdf0e10cSrcweir     const OUString& rMsg1,
1899cdf0e10cSrcweir     const OUString& rMsg2,
1900cdf0e10cSrcweir     const OUString& rMsg3,
1901cdf0e10cSrcweir     const OUString& rMsg4)
1902cdf0e10cSrcweir {
1903cdf0e10cSrcweir     Sequence<OUString> aSeq(4);
1904cdf0e10cSrcweir     OUString* pSeq = aSeq.getArray();
1905cdf0e10cSrcweir     pSeq[0] = rMsg1;
1906cdf0e10cSrcweir     pSeq[1] = rMsg2;
1907cdf0e10cSrcweir     pSeq[2] = rMsg3;
1908cdf0e10cSrcweir     pSeq[3] = rMsg4;
1909cdf0e10cSrcweir     SetError( nId, aSeq );
1910cdf0e10cSrcweir }
1911cdf0e10cSrcweir 
1912cdf0e10cSrcweir XMLErrors* SvXMLImport::GetErrors()
1913cdf0e10cSrcweir {
1914cdf0e10cSrcweir 	return mpXMLErrors;
1915cdf0e10cSrcweir }
1916cdf0e10cSrcweir 
1917cdf0e10cSrcweir void SvXMLImport::DisposingModel()
1918cdf0e10cSrcweir {
1919cdf0e10cSrcweir 	if( mxFontDecls.Is() )
1920cdf0e10cSrcweir 		((SvXMLStylesContext *)&mxFontDecls)->Clear();
1921cdf0e10cSrcweir 	if( mxStyles.Is() )
1922cdf0e10cSrcweir 		((SvXMLStylesContext *)&mxStyles)->Clear();
1923cdf0e10cSrcweir 	if( mxAutoStyles.Is() )
1924cdf0e10cSrcweir 		((SvXMLStylesContext *)&mxAutoStyles)->Clear();
1925cdf0e10cSrcweir 	if( mxMasterStyles.Is() )
1926cdf0e10cSrcweir 		((SvXMLStylesContext *)&mxMasterStyles)->Clear();
1927cdf0e10cSrcweir 
1928cdf0e10cSrcweir 	mxModel.set(0);
1929cdf0e10cSrcweir 	mxEventListener.set(NULL);
1930cdf0e10cSrcweir }
1931cdf0e10cSrcweir 
1932cdf0e10cSrcweir ::comphelper::UnoInterfaceToUniqueIdentifierMapper& SvXMLImport::getInterfaceToIdentifierMapper()
1933cdf0e10cSrcweir {
1934cdf0e10cSrcweir 	return mpImpl->maInterfaceToIdentifierMapper;
1935cdf0e10cSrcweir }
1936cdf0e10cSrcweir 
1937cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SvXMLImport::getServiceFactory()
1938cdf0e10cSrcweir {
1939cdf0e10cSrcweir 	// #110680#
1940cdf0e10cSrcweir 	return mxServiceFactory;
1941cdf0e10cSrcweir }
1942cdf0e10cSrcweir 
1943cdf0e10cSrcweir uno::Reference< uno::XComponentContext >
1944cdf0e10cSrcweir SvXMLImport::GetComponentContext() const
1945cdf0e10cSrcweir {
1946cdf0e10cSrcweir     return mpImpl->mxComponentContext;
1947cdf0e10cSrcweir }
1948cdf0e10cSrcweir 
1949cdf0e10cSrcweir String SvXMLImport::GetBaseURL() const
1950cdf0e10cSrcweir {
1951cdf0e10cSrcweir     return mpImpl->aBaseURL.GetMainURL( INetURLObject::NO_DECODE );
1952cdf0e10cSrcweir }
1953cdf0e10cSrcweir 
1954cdf0e10cSrcweir String SvXMLImport::GetDocumentBase() const
1955cdf0e10cSrcweir {
1956cdf0e10cSrcweir     return mpImpl->aDocBase.GetMainURL( INetURLObject::NO_DECODE );
1957cdf0e10cSrcweir }
1958cdf0e10cSrcweir 
1959cdf0e10cSrcweir ::rtl::OUString SvXMLImport::GetStreamName() const
1960cdf0e10cSrcweir {
1961cdf0e10cSrcweir     return mpImpl->mStreamName;
1962cdf0e10cSrcweir }
1963cdf0e10cSrcweir 
1964cdf0e10cSrcweir // --> OD 2004-08-10 #i28749#
1965cdf0e10cSrcweir sal_Bool SvXMLImport::IsShapePositionInHoriL2R() const
1966cdf0e10cSrcweir {
1967cdf0e10cSrcweir     return mpImpl->mbShapePositionInHoriL2R;
1968cdf0e10cSrcweir }
1969cdf0e10cSrcweir // <--
1970cdf0e10cSrcweir 
1971cdf0e10cSrcweir // --> OD 2007-12-19 #152540#
1972cdf0e10cSrcweir sal_Bool SvXMLImport::IsTextDocInOOoFileFormat() const
1973cdf0e10cSrcweir {
1974cdf0e10cSrcweir     return mpImpl->mbTextDocInOOoFileFormat;
1975cdf0e10cSrcweir }
1976cdf0e10cSrcweir 
1977cdf0e10cSrcweir // <--
1978cdf0e10cSrcweir 
1979cdf0e10cSrcweir void SvXMLImport::initXForms()
1980cdf0e10cSrcweir {
1981cdf0e10cSrcweir     // dummy method; to be implemented by derived classes supporting XForms
1982cdf0e10cSrcweir }
1983cdf0e10cSrcweir 
1984cdf0e10cSrcweir bool SvXMLImport::getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild ) const
1985cdf0e10cSrcweir {
1986cdf0e10cSrcweir 	bool bRet = false;
1987cdf0e10cSrcweir 	if( mxImportInfo.is() ) try
1988cdf0e10cSrcweir 	{
1989cdf0e10cSrcweir 		const OUString aPropName(RTL_CONSTASCII_USTRINGPARAM("BuildId"));
1990cdf0e10cSrcweir 		Reference< XPropertySetInfo > xSetInfo( mxImportInfo->getPropertySetInfo() );
1991cdf0e10cSrcweir 		if( xSetInfo.is() && xSetInfo->hasPropertyByName( aPropName ) )
1992cdf0e10cSrcweir 		{
1993cdf0e10cSrcweir 			OUString aBuildId;
1994cdf0e10cSrcweir 			mxImportInfo->getPropertyValue( aPropName ) >>= aBuildId;
1995cdf0e10cSrcweir 			if( aBuildId.getLength() )
1996cdf0e10cSrcweir 			{
1997cdf0e10cSrcweir 				sal_Int32 nIndex = aBuildId.indexOf('$');
1998cdf0e10cSrcweir 				if( nIndex != -1 )
1999cdf0e10cSrcweir 				{
2000cdf0e10cSrcweir 					rUPD = aBuildId.copy( 0, nIndex ).toInt32();
2001cdf0e10cSrcweir 					rBuild = aBuildId.copy( nIndex+1 ).toInt32();
2002cdf0e10cSrcweir 					bRet = true;
2003cdf0e10cSrcweir 				}
2004cdf0e10cSrcweir 			}
2005cdf0e10cSrcweir 		}
2006cdf0e10cSrcweir 	}
2007cdf0e10cSrcweir 	catch( Exception& )
2008cdf0e10cSrcweir 	{
2009cdf0e10cSrcweir 	}
2010cdf0e10cSrcweir 	return bRet;
2011cdf0e10cSrcweir }
2012cdf0e10cSrcweir 
2013cdf0e10cSrcweir sal_uInt16 SvXMLImport::getGeneratorVersion() const
2014cdf0e10cSrcweir {
2015*a5258243SPedro Giffuni     // --> ORW
2016*a5258243SPedro Giffuni     return mpImpl->getGeneratorVersion( *this );
2017*a5258243SPedro Giffuni     // <--
2018cdf0e10cSrcweir }
2019cdf0e10cSrcweir 
2020cdf0e10cSrcweir bool SvXMLImport::isGraphicLoadOnDemandSupported() const
2021cdf0e10cSrcweir {
2022cdf0e10cSrcweir     return mbIsGraphicLoadOnDemandSupported;
2023cdf0e10cSrcweir }
2024cdf0e10cSrcweir 
2025cdf0e10cSrcweir ::rtl::OUString SvXMLImport::GetODFVersion() const
2026cdf0e10cSrcweir {
2027cdf0e10cSrcweir     return mpImpl->aODFVersion;
2028cdf0e10cSrcweir }
2029cdf0e10cSrcweir 
2030cdf0e10cSrcweir // xml:id for RDF metadata
2031cdf0e10cSrcweir void SvXMLImport::SetXmlId(uno::Reference<uno::XInterface> const & i_xIfc,
2032cdf0e10cSrcweir     ::rtl::OUString const & i_rXmlId)
2033cdf0e10cSrcweir {
2034cdf0e10cSrcweir     if (i_rXmlId.getLength() > 0) {
2035cdf0e10cSrcweir         try {
2036cdf0e10cSrcweir             const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc,
2037cdf0e10cSrcweir                 uno::UNO_QUERY);
2038cdf0e10cSrcweir //FIXME: not yet
2039cdf0e10cSrcweir //            OSL_ENSURE(xMeta.is(), "xml:id: not XMetadatable");
2040cdf0e10cSrcweir             if (xMeta.is()) {
2041cdf0e10cSrcweir                 const beans::StringPair mdref( GetStreamName(), i_rXmlId );
2042cdf0e10cSrcweir                 try {
2043cdf0e10cSrcweir                     xMeta->setMetadataReference(mdref);
2044cdf0e10cSrcweir                 } catch (lang::IllegalArgumentException &) {
2045cdf0e10cSrcweir                     // probably duplicate; ignore
2046cdf0e10cSrcweir                     OSL_TRACE("SvXMLImport::SetXmlId: cannot set xml:id");
2047cdf0e10cSrcweir                 }
2048cdf0e10cSrcweir             }
2049cdf0e10cSrcweir         } catch (uno::Exception &) {
2050cdf0e10cSrcweir             OSL_ENSURE(false, "SvXMLImport::SetXmlId: exception?");
2051cdf0e10cSrcweir         }
2052cdf0e10cSrcweir     }
2053cdf0e10cSrcweir }
2054cdf0e10cSrcweir 
2055cdf0e10cSrcweir SAL_DLLPRIVATE ::xmloff::RDFaImportHelper &
2056cdf0e10cSrcweir SvXMLImport::GetRDFaImportHelper()
2057cdf0e10cSrcweir {
2058cdf0e10cSrcweir     if (!mpImpl->mpRDFaHelper.get())
2059cdf0e10cSrcweir     {
2060cdf0e10cSrcweir         mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaImportHelper(*this) );
2061cdf0e10cSrcweir     }
2062cdf0e10cSrcweir     return *mpImpl->mpRDFaHelper;
2063cdf0e10cSrcweir }
2064cdf0e10cSrcweir 
2065cdf0e10cSrcweir void
2066cdf0e10cSrcweir SvXMLImport::AddRDFa(uno::Reference<rdf::XMetadatable> i_xObject,
2067cdf0e10cSrcweir     ::rtl::OUString const & i_rAbout,
2068cdf0e10cSrcweir     ::rtl::OUString const & i_rProperty,
2069cdf0e10cSrcweir     ::rtl::OUString const & i_rContent,
2070cdf0e10cSrcweir     ::rtl::OUString const & i_rDatatype)
2071cdf0e10cSrcweir {
2072cdf0e10cSrcweir     // N.B.: we only get called if i_xObject had xhtml:about attribute
2073cdf0e10cSrcweir     // (an empty attribute value is valid)
2074cdf0e10cSrcweir     ::xmloff::RDFaImportHelper & rRDFaHelper( GetRDFaImportHelper() );
2075cdf0e10cSrcweir     rRDFaHelper.ParseAndAddRDFa(i_xObject,
2076cdf0e10cSrcweir         i_rAbout, i_rProperty, i_rContent, i_rDatatype);
2077cdf0e10cSrcweir }
2078cdf0e10cSrcweir 
2079