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