update dev300-m58
[ooovba.git] / xmloff / source / core / xmlimp.cxx
blobaf98fba4ed37fb4f880b89012ce5d5f9cc3439a1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlimp.cxx,v $
10 * $Revision: 1.112.2.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include <com/sun/star/beans/XPropertySetInfo.hpp>
34 #include <tools/debug.hxx>
35 #include <tools/urlobj.hxx>
36 #include <osl/mutex.hxx>
37 #include <rtl/uuid.h>
38 #include <rtl/memory.h>
39 #include <svtools/svarray.hxx>
40 #include "unointerfacetouniqueidentifiermapper.hxx"
41 #include <xmloff/nmspmap.hxx>
42 #include <xmloff/xmluconv.hxx>
43 #include "xmlnmspe.hxx"
44 #include "xmlkywd.hxx"
45 #include <xmloff/xmltoken.hxx>
46 #include <xmloff/XMLFontStylesContext.hxx>
47 #include <xmloff/xmlictxt.hxx>
48 #include <xmloff/xmlimp.hxx>
49 #include <xmloff/xmlnumfi.hxx>
50 #include "XMLEventImportHelper.hxx"
51 #include "XMLStarBasicContextFactory.hxx"
52 #include "XMLScriptContextFactory.hxx"
53 #include "StyleMap.hxx"
54 #include <xmloff/ProgressBarHelper.hxx>
55 #include <xmloff/xmltoken.hxx>
56 #include "xmlerror.hxx"
57 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
58 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
59 #include <com/sun/star/io/XOutputStream.hpp>
60 #include <com/sun/star/document/XBinaryStreamResolver.hpp>
61 #include <com/sun/star/xml/sax/XLocator.hpp>
62 #include <comphelper/namecontainer.hxx>
63 #include <rtl/logfile.hxx>
64 #include <tools/string.hxx> // used in StartElement for logging
65 #include <cppuhelper/implbase1.hxx>
66 #include <comphelper/extract.hxx>
67 #include <comphelper/processfactory.hxx>
68 #include <vcl/fontcvt.hxx>
70 #include <com/sun/star/rdf/XMetadatable.hpp>
71 #include <com/sun/star/rdf/XRepositorySupplier.hpp>
72 #include "RDFaImportHelper.hxx"
74 #define LOGFILE_AUTHOR "unknown"
76 using ::com::sun::star::beans::XPropertySetInfo;
78 using ::rtl::OUString;
79 using ::rtl::OUStringBuffer;
81 using namespace ::osl;
82 using namespace ::com::sun::star;
83 using namespace ::com::sun::star::frame;
84 using namespace ::com::sun::star::uno;
85 using namespace ::com::sun::star::util;
86 using namespace ::com::sun::star::io;
87 using namespace ::com::sun::star::container;
88 using namespace ::com::sun::star::document;
89 using namespace ::xmloff::token;
91 sal_Char __READONLY_DATA sXML_np__office[] = "_office";
92 sal_Char __READONLY_DATA sXML_np__ooo[] = "_ooo";
93 sal_Char __READONLY_DATA sXML_np__ooow[] = "_ooow";
94 sal_Char __READONLY_DATA sXML_np__oooc[] = "_oooc";
95 sal_Char __READONLY_DATA sXML_np__of[] = "_of";
96 sal_Char __READONLY_DATA sXML_np__style[] = "_style";
97 sal_Char __READONLY_DATA sXML_np__text[] = "_text";
98 sal_Char __READONLY_DATA sXML_np__table[] = "_table";
99 sal_Char __READONLY_DATA sXML_np__draw[] = "_draw";
100 sal_Char __READONLY_DATA sXML_np__dr3d[] = "_dr3d";
101 sal_Char __READONLY_DATA sXML_np__fo[] = "_fo";
102 sal_Char __READONLY_DATA sXML_np__xlink[] = "_xlink";
103 sal_Char __READONLY_DATA sXML_np__dc[] = "_dc";
104 sal_Char __READONLY_DATA sXML_np__dom[] = "_dom";
105 sal_Char __READONLY_DATA sXML_np__meta[] = "_meta";
106 sal_Char __READONLY_DATA sXML_np__number[] = "_number";
107 sal_Char __READONLY_DATA sXML_np__svg[] = "_svg";
108 sal_Char __READONLY_DATA sXML_np__chart[] = "_chart";
109 sal_Char __READONLY_DATA sXML_np__math[] = "_math";
110 sal_Char __READONLY_DATA sXML_np__script[] = "_script";
111 sal_Char __READONLY_DATA sXML_np__config[] = "_config";
112 sal_Char __READONLY_DATA sXML_np__db[] = "_db";
113 sal_Char __READONLY_DATA sXML_np__xforms[] = "_xforms";
114 sal_Char __READONLY_DATA sXML_np__formx[] = "_formx";
115 sal_Char __READONLY_DATA sXML_np__xsd[] = "_xsd";
116 sal_Char __READONLY_DATA sXML_np__xsi[] = "_xsi";
117 sal_Char __READONLY_DATA sXML_np__field[] = "_field";
118 sal_Char __READONLY_DATA sXML_np__xhtml[] = "_xhtml";
120 sal_Char __READONLY_DATA sXML_np__fo_old[] = "__fo";
121 sal_Char __READONLY_DATA sXML_np__xlink_old[] = "__xlink";
122 sal_Char __READONLY_DATA sXML_np__office_old[] = "__office";
123 sal_Char __READONLY_DATA sXML_np__style_old[] = "__style";
124 sal_Char __READONLY_DATA sXML_np__text_old[] = "__text";
125 sal_Char __READONLY_DATA sXML_np__table_old[] = "__table";
126 sal_Char __READONLY_DATA sXML_np__meta_old[] = "__meta";
130 class SvXMLImportEventListener : public cppu::WeakImplHelper1<
131 com::sun::star::lang::XEventListener >
133 private:
134 SvXMLImport* pImport;
136 public:
137 SvXMLImportEventListener(SvXMLImport* pImport);
138 virtual ~SvXMLImportEventListener();
140 // XEventListener
141 virtual void SAL_CALL disposing(const lang::EventObject& rEventObject) throw(::com::sun::star::uno::RuntimeException);
144 SvXMLImportEventListener::SvXMLImportEventListener(SvXMLImport* pTempImport)
145 : pImport(pTempImport)
149 SvXMLImportEventListener::~SvXMLImportEventListener()
153 // XEventListener
154 void SAL_CALL SvXMLImportEventListener::disposing( const lang::EventObject& )
155 throw(uno::RuntimeException)
157 if (pImport)
159 pImport->DisposingModel();
160 pImport = NULL;
164 //==============================================================================
166 class SvXMLImport_Impl
168 public:
169 FontToSubsFontConverter hBatsFontConv;
170 FontToSubsFontConverter hMathFontConv;
172 bool mbOwnGraphicResolver;
173 bool mbOwnEmbeddedResolver;
174 INetURLObject aBaseURL;
175 INetURLObject aDocBase;
177 /// name of stream in package, e.g., "content.xml"
178 ::rtl::OUString mStreamName;
180 ::rtl::OUString aODFVersion;
182 // --> OD 2004-08-10 #i28749# - boolean, indicating that position attributes
183 // of shapes are given in horizontal left-to-right layout. This is the case
184 // for the OpenOffice.org file format.
185 sal_Bool mbShapePositionInHoriL2R;
186 // <--
187 // --> OD 2007-12-19 #152540#
188 sal_Bool mbTextDocInOOoFileFormat;
189 // <--
191 const uno::Reference< uno::XComponentContext > mxComponentContext;
193 std::auto_ptr< xmloff::RDFaImportHelper > mpRDFaHelper;
195 SvXMLImport_Impl() :
196 hBatsFontConv( 0 ), hMathFontConv( 0 ),
197 mbOwnGraphicResolver( false ),
198 mbOwnEmbeddedResolver( false ),
199 mStreamName(),
200 // --> OD 2004-08-11 #i28749#
201 mbShapePositionInHoriL2R( sal_False ),
202 // <--
203 // --> OD 2007-12-19 #152540#
204 mbTextDocInOOoFileFormat( sal_False ),
205 // <--
206 mxComponentContext( ::comphelper::getProcessComponentContext() ),
207 mpRDFaHelper() // lazy
209 OSL_ENSURE(mxComponentContext.is(), "SvXMLImport: no ComponentContext");
210 if (!mxComponentContext.is()) throw uno::RuntimeException();
213 ~SvXMLImport_Impl()
215 if( hBatsFontConv )
216 DestroyFontToSubsFontConverter( hBatsFontConv );
217 if( hMathFontConv )
218 DestroyFontToSubsFontConverter( hMathFontConv );
221 ::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper;
224 typedef SvXMLImportContext *SvXMLImportContextPtr;
225 SV_DECL_PTRARR( SvXMLImportContexts_Impl, SvXMLImportContextPtr, 20, 5 )
226 SV_IMPL_PTRARR( SvXMLImportContexts_Impl, SvXMLImportContextPtr )
228 SvXMLImportContext *SvXMLImport::CreateContext( USHORT nPrefix,
229 const OUString& rLocalName,
230 const uno::Reference< xml::sax::XAttributeList >& )
232 return new SvXMLImportContext( *this, nPrefix, rLocalName );
235 void SvXMLImport::_InitCtor()
237 if( mnImportFlags != 0 )
239 // implicit "xml" namespace prefix
240 mpNamespaceMap->Add( GetXMLToken(XML_XML), GetXMLToken(XML_N_XML),
241 XML_NAMESPACE_XML );
242 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office ) ),
243 GetXMLToken(XML_N_OFFICE),
244 XML_NAMESPACE_OFFICE );
245 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__ooo ) ), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
246 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__style) ),
247 GetXMLToken(XML_N_STYLE),
248 XML_NAMESPACE_STYLE );
249 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__text) ),
250 GetXMLToken(XML_N_TEXT),
251 XML_NAMESPACE_TEXT );
252 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__table ) ),
253 GetXMLToken(XML_N_TABLE),
254 XML_NAMESPACE_TABLE );
255 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__draw ) ),
256 GetXMLToken(XML_N_DRAW),
257 XML_NAMESPACE_DRAW );
258 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM (sXML_np__dr3d ) ),
259 GetXMLToken(XML_N_DR3D),
260 XML_NAMESPACE_DR3D );
261 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__fo) ),
262 GetXMLToken(XML_N_FO_COMPAT),
263 XML_NAMESPACE_FO );
264 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xlink) ),
265 GetXMLToken(XML_N_XLINK),
266 XML_NAMESPACE_XLINK );
267 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__dc) ),
268 GetXMLToken(XML_N_DC),
269 XML_NAMESPACE_DC );
270 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__dom ) ),
271 GetXMLToken(XML_N_DOM),
272 XML_NAMESPACE_DOM );
273 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__meta) ),
274 GetXMLToken(XML_N_META),
275 XML_NAMESPACE_META );
276 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__number) ),
277 GetXMLToken(XML_N_NUMBER),
278 XML_NAMESPACE_NUMBER );
279 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__svg) ),
280 GetXMLToken(XML_N_SVG_COMPAT),
281 XML_NAMESPACE_SVG );
282 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__chart) ),
283 GetXMLToken(XML_N_CHART),
284 XML_NAMESPACE_CHART );
285 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__math) ),
286 GetXMLToken(XML_N_MATH),
287 XML_NAMESPACE_MATH );
288 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_namespace_form) ),
289 GetXMLToken(XML_N_FORM),
290 XML_NAMESPACE_FORM );
291 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__script) ),
292 GetXMLToken(XML_N_SCRIPT),
293 XML_NAMESPACE_SCRIPT );
294 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__config) ),
295 GetXMLToken(XML_N_CONFIG),
296 XML_NAMESPACE_CONFIG );
297 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xforms) ),
298 GetXMLToken(XML_N_XFORMS_1_0),
299 XML_NAMESPACE_XFORMS );
300 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__formx) ),
301 GetXMLToken( XML_N_FORMX ),
302 XML_NAMESPACE_FORMX );
303 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xsd) ),
304 GetXMLToken(XML_N_XSD),
305 XML_NAMESPACE_XSD );
306 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xsi) ),
307 GetXMLToken(XML_N_XSI),
308 XML_NAMESPACE_XFORMS );
309 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__ooow ) ), GetXMLToken(XML_N_OOOW), XML_NAMESPACE_OOOW );
310 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__oooc ) ), GetXMLToken(XML_N_OOOC), XML_NAMESPACE_OOOC );
311 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__field ) ), GetXMLToken(XML_N_FIELD), XML_NAMESPACE_FIELD );
312 mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__of ) ),
313 GetXMLToken(XML_N_OF), XML_NAMESPACE_OF );
314 mpNamespaceMap->Add(
315 OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xhtml ) ),
316 GetXMLToken(XML_N_XHTML), XML_NAMESPACE_XHTML );
319 msPackageProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) );
321 if (mxNumberFormatsSupplier.is())
322 mpNumImport = new SvXMLNumFmtHelper(mxNumberFormatsSupplier, getServiceFactory());
324 if (mxModel.is() && !mxEventListener.is())
326 mxEventListener.set(new SvXMLImportEventListener(this));
327 mxModel->addEventListener(mxEventListener);
330 ::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper;
334 // #110680#
335 SvXMLImport::SvXMLImport(
336 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
337 sal_uInt16 nImportFlags ) throw ()
338 : mpImpl( new SvXMLImport_Impl() ),
339 mpNamespaceMap( new SvXMLNamespaceMap ),
341 // #110680#
342 // pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM ) ),
343 mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM, xServiceFactory ) ),
345 mpContexts( new SvXMLImportContexts_Impl ),
346 mpNumImport( NULL ),
347 mpProgressBarHelper( NULL ),
348 mpEventImportHelper( NULL ),
349 mpXMLErrors( NULL ),
350 mpStyleMap(0),
351 mnImportFlags( nImportFlags ),
352 mnErrorFlags(0),
353 // #110680#
354 mxServiceFactory(xServiceFactory),
355 mbIsFormsSupported( sal_True ),
356 mbIsTableShapeSupported( false ),
357 mbIsGraphicLoadOnDemandSupported( true )
359 DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
360 _InitCtor();
363 // #110680#
364 SvXMLImport::SvXMLImport(
365 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
366 const Reference< XModel > & rModel ) throw ()
367 : mxModel( rModel ),
368 mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
369 mpImpl( new SvXMLImport_Impl() ),
370 mpNamespaceMap( new SvXMLNamespaceMap ),
371 // #110680#
372 // pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM ) ),
373 mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM, xServiceFactory ) ),
374 mpContexts( new SvXMLImportContexts_Impl ),
375 mpNumImport( NULL ),
376 mpProgressBarHelper( NULL ),
377 mpEventImportHelper( NULL ),
378 mpXMLErrors( NULL ),
379 mpStyleMap(0),
380 mnImportFlags( IMPORT_ALL ),
381 mnErrorFlags(0),
382 // #110680#
383 mxServiceFactory(xServiceFactory),
384 mbIsFormsSupported( sal_True ),
385 mbIsTableShapeSupported( false ),
386 mbIsGraphicLoadOnDemandSupported( true )
388 DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
389 _InitCtor();
392 // #110680#
393 SvXMLImport::SvXMLImport(
394 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
395 const Reference< XModel > & rModel,
396 const ::com::sun::star::uno::Reference< ::com::sun::star::document::XGraphicObjectResolver > & rGraphicObjects ) throw ()
397 : mxModel( rModel ),
398 mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
399 mxGraphicResolver( rGraphicObjects ),
400 mpImpl( new SvXMLImport_Impl() ),
401 mpNamespaceMap( new SvXMLNamespaceMap ),
402 // #110680#
403 // pUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM ) ),
404 mpUnitConv( new SvXMLUnitConverter( MAP_100TH_MM, MAP_100TH_MM, xServiceFactory ) ),
405 mpContexts( new SvXMLImportContexts_Impl ),
406 mpNumImport( NULL ),
407 mpProgressBarHelper( NULL ),
408 mpEventImportHelper( NULL ),
409 mpXMLErrors( NULL ),
410 mpStyleMap(0),
411 mnImportFlags( IMPORT_ALL ),
412 mnErrorFlags(0),
413 // #110680#
414 mxServiceFactory(xServiceFactory),
415 mbIsFormsSupported( sal_True ),
416 mbIsGraphicLoadOnDemandSupported( true )
418 DBG_ASSERT( mxServiceFactory.is(), "got no service manager" );
419 _InitCtor();
422 SvXMLImport::~SvXMLImport() throw ()
424 delete mpXMLErrors;
425 delete mpNamespaceMap;
426 delete mpUnitConv;
427 delete mpEventImportHelper;
428 if( mpContexts )
430 while( mpContexts->Count() )
432 sal_uInt16 n = mpContexts->Count() - 1;
433 SvXMLImportContext *pContext = (*mpContexts)[n];
434 mpContexts->Remove( n, 1 );
435 if( pContext )
436 pContext->ReleaseRef();
438 delete mpContexts;
441 // delete pImageMapImportHelper;
443 // #i9518# the import component might not be deleted until after the document has been closed,
444 // so the stuff that accesses the document has been moved to endDocument.
446 // pNumImport is allocated in the ctor, so it must also be deleted here in case the component
447 // is created and deleted without actually importing.
448 delete mpNumImport;
449 delete mpProgressBarHelper;
451 xmloff::token::ResetTokens();
453 if( mpImpl )
454 delete mpImpl;
456 if (mxEventListener.is() && mxModel.is())
457 mxModel->removeEventListener(mxEventListener);
460 // XUnoTunnel & co
461 const uno::Sequence< sal_Int8 > & SvXMLImport::getUnoTunnelId() throw()
463 static uno::Sequence< sal_Int8 > * pSeq = 0;
464 if( !pSeq )
466 Guard< Mutex > aGuard( Mutex::getGlobalMutex() );
467 if( !pSeq )
469 static uno::Sequence< sal_Int8 > aSeq( 16 );
470 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
471 pSeq = &aSeq;
474 return *pSeq;
477 SvXMLImport* SvXMLImport::getImplementation( uno::Reference< uno::XInterface > xInt ) throw()
479 uno::Reference< lang::XUnoTunnel > xUT( xInt, uno::UNO_QUERY );
480 if( xUT.is() )
482 return
483 reinterpret_cast<SvXMLImport*>(
484 sal::static_int_cast<sal_IntPtr>(
485 xUT->getSomething( SvXMLImport::getUnoTunnelId())));
487 else
488 return NULL;
491 // XUnoTunnel
492 sal_Int64 SAL_CALL SvXMLImport::getSomething( const uno::Sequence< sal_Int8 >& rId )
493 throw( uno::RuntimeException )
495 if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
496 rId.getConstArray(), 16 ) )
498 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
500 return 0;
503 void SAL_CALL SvXMLImport::startDocument( void )
504 throw( xml::sax::SAXException, uno::RuntimeException )
506 RTL_LOGFILE_TRACE_AUTHOR( "xmloff", LOGFILE_AUTHOR, "{ SvXMLImport::startDocument" );
508 if( !mxGraphicResolver.is() || !mxEmbeddedResolver.is() )
510 Reference< lang::XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
511 if( xFactory.is() )
515 if( !mxGraphicResolver.is() )
517 mxGraphicResolver = Reference< XGraphicObjectResolver >::query(
518 xFactory->createInstance(
519 OUString(RTL_CONSTASCII_USTRINGPARAM(
520 // #99870# Import... instead of Export...
521 "com.sun.star.document.ImportGraphicObjectResolver"))));
522 mpImpl->mbOwnGraphicResolver = mxGraphicResolver.is();
525 if( !mxEmbeddedResolver.is() )
527 mxEmbeddedResolver = Reference< XEmbeddedObjectResolver >::query(
528 xFactory->createInstance(
529 OUString(RTL_CONSTASCII_USTRINGPARAM(
530 // #99870# Import... instead of Export...
531 "com.sun.star.document.ImportEmbeddedObjectResolver"))));
532 mpImpl->mbOwnEmbeddedResolver = mxEmbeddedResolver.is();
535 catch( com::sun::star::uno::Exception& )
542 void SAL_CALL SvXMLImport::endDocument( void )
543 throw( xml::sax::SAXException, uno::RuntimeException)
545 RTL_LOGFILE_TRACE_AUTHOR( "xmloff", LOGFILE_AUTHOR, "} SvXMLImport::startDocument" );
547 // #i9518# All the stuff that accesses the document has to be done here, not in the dtor,
548 // because the SvXMLImport dtor might not be called until after the document has been closed.
550 if (mpImpl->mpRDFaHelper.get())
552 const uno::Reference<rdf::XRepositorySupplier> xRS(mxModel,
553 uno::UNO_QUERY);
554 if (xRS.is())
556 mpImpl->mpRDFaHelper->InsertRDFa( xRS );
560 if (mpNumImport)
562 delete mpNumImport;
563 mpNumImport = NULL;
565 if (mxImportInfo.is())
567 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
568 if (xPropertySetInfo.is())
570 if (mpProgressBarHelper)
572 OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSMAX));
573 OUString sProgressCurrent(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSCURRENT));
574 OUString sRepeat(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSREPEAT));
575 if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
576 xPropertySetInfo->hasPropertyByName(sProgressCurrent))
578 sal_Int32 nProgressMax(mpProgressBarHelper->GetReference());
579 sal_Int32 nProgressCurrent(mpProgressBarHelper->GetValue());
580 uno::Any aAny;
581 aAny <<= nProgressMax;
582 mxImportInfo->setPropertyValue(sProgressMax, aAny);
583 aAny <<= nProgressCurrent;
584 mxImportInfo->setPropertyValue(sProgressCurrent, aAny);
586 if (xPropertySetInfo->hasPropertyByName(sRepeat))
587 mxImportInfo->setPropertyValue(sRepeat, cppu::bool2any(mpProgressBarHelper->GetRepeat()));
588 // pProgressBarHelper is deleted in dtor
590 OUString sNumberStyles(RTL_CONSTASCII_USTRINGPARAM(XML_NUMBERSTYLES));
591 if (mxNumberStyles.is() && xPropertySetInfo->hasPropertyByName(sNumberStyles))
593 uno::Any aAny;
594 aAny <<= mxNumberStyles;
595 mxImportInfo->setPropertyValue(sNumberStyles, aAny);
600 if( mxFontDecls.Is() )
601 ((SvXMLStylesContext *)&mxFontDecls)->Clear();
602 if( mxStyles.Is() )
603 ((SvXMLStylesContext *)&mxStyles)->Clear();
604 if( mxAutoStyles.Is() )
605 ((SvXMLStylesContext *)&mxAutoStyles)->Clear();
606 if( mxMasterStyles.Is() )
607 ((SvXMLStylesContext *)&mxMasterStyles)->Clear();
609 // possible form-layer related knittings which can only be done when
610 // the whole document exists
611 if ( mxFormImport.is() )
612 mxFormImport->documentDone();
614 // The shape import helper does the z-order sorting in the dtor,
615 // so it must be deleted here, too.
616 mxShapeImport = NULL;
618 if( mpImpl->mbOwnGraphicResolver )
620 Reference< lang::XComponent > xComp( mxGraphicResolver, UNO_QUERY );
621 xComp->dispose();
624 if( mpImpl->mbOwnEmbeddedResolver )
626 Reference< lang::XComponent > xComp( mxEmbeddedResolver, UNO_QUERY );
627 xComp->dispose();
629 if( mpStyleMap )
631 mpStyleMap->release();
632 mpStyleMap = 0;
635 if ( mpXMLErrors != NULL )
637 mpXMLErrors->ThrowErrorAsSAXException( XMLERROR_FLAG_SEVERE );
641 void SAL_CALL SvXMLImport::startElement( const OUString& rName,
642 const uno::Reference< xml::sax::XAttributeList >& xAttrList )
643 throw(xml::sax::SAXException, uno::RuntimeException)
645 SvXMLNamespaceMap *pRewindMap = 0;
647 // Process namespace attributes. This must happen before creating the
648 // context, because namespace decaration apply to the element name itself.
649 INT16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
650 for( INT16 i=0; i < nAttrCount; i++ )
652 const OUString& rAttrName = xAttrList->getNameByIndex( i );
653 if ( rAttrName.equalsAscii("office:version") )
655 mpImpl->aODFVersion = xAttrList->getValueByIndex( i );
657 else if( ( rAttrName.getLength() >= 5 ) &&
658 ( rAttrName.compareToAscii( sXML_xmlns, 5 ) == 0 ) &&
659 ( rAttrName.getLength() == 5 || ':' == rAttrName[5] ) )
661 if( !pRewindMap )
663 pRewindMap = mpNamespaceMap;
664 mpNamespaceMap = new SvXMLNamespaceMap( *mpNamespaceMap );
666 const OUString& rAttrValue = xAttrList->getValueByIndex( i );
668 OUString aPrefix( ( rAttrName.getLength() == 5 )
669 ? OUString()
670 : rAttrName.copy( 6 ) );
671 // Add namespace, but only if it is known.
672 sal_uInt16 nKey = mpNamespaceMap->AddIfKnown( aPrefix, rAttrValue );
673 // If namespace is unknwon, try to match a name with similar
674 // TC Id an version
675 if( XML_NAMESPACE_UNKNOWN == nKey )
677 OUString aTestName( rAttrValue );
678 if( SvXMLNamespaceMap::NormalizeURI( aTestName ) )
679 nKey = mpNamespaceMap->AddIfKnown( aPrefix, aTestName );
681 // If that namespace is not known, too, add it as unknown
682 if( XML_NAMESPACE_UNKNOWN == nKey )
683 mpNamespaceMap->Add( aPrefix, rAttrValue );
688 // Get element's namespace and local name.
689 OUString aLocalName;
690 USHORT nPrefix =
691 mpNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
693 // If there are contexts already, call a CreateChildContext at the topmost
694 // context. Otherwise, create a default context.
695 SvXMLImportContext *pContext;
696 USHORT nCount = mpContexts->Count();
697 if( nCount > 0 )
699 pContext = (*mpContexts)[nCount - 1]->CreateChildContext( nPrefix,
700 aLocalName,
701 xAttrList );
702 DBG_ASSERT( pContext && pContext->GetPrefix() == nPrefix,
703 "SvXMLImport::startElement: created context has wrong prefix" );
705 else
707 #ifdef TIMELOG
708 // If we do profiling, we want a trace message for the first element
709 // in order to identify the stream.
710 ByteString aString( (String)rName, RTL_TEXTENCODING_ASCII_US );
711 RTL_LOGFILE_TRACE_AUTHOR1( "xmloff", LOGFILE_AUTHOR,
712 "SvXMLImport::StartElement( \"%s\", ... )",
713 aString.GetBuffer() );
714 #endif
716 pContext = CreateContext( nPrefix, aLocalName, xAttrList );
717 if( (nPrefix & XML_NAMESPACE_UNKNOWN_FLAG) != 0 &&
718 IS_TYPE( SvXMLImportContext, pContext ) )
720 OUString aMsg( RTL_CONSTASCII_USTRINGPARAM( "Root element unknown" ) );
721 Reference<xml::sax::XLocator> xDummyLocator;
722 Sequence < OUString > aParams(1);
723 aParams.getArray()[0] = rName;
725 SetError( XMLERROR_FLAG_SEVERE|XMLERROR_UNKNWON_ROOT,
726 aParams, aMsg, xDummyLocator );
730 DBG_ASSERT( pContext, "SvXMLImport::startElement: missing context" );
731 if( !pContext )
732 pContext = new SvXMLImportContext( *this, nPrefix, aLocalName );
734 pContext->AddRef();
736 // Remeber old namespace map.
737 if( pRewindMap )
738 pContext->SetRewindMap( pRewindMap );
740 // Call a startElement at the new context.
741 pContext->StartElement( xAttrList );
743 // Push context on stack.
744 mpContexts->Insert( pContext, nCount );
747 SvXMLImportContext *SvXMLImport::getTopContext() {
748 USHORT nCount = mpContexts->Count();
749 if (nCount>0) {
750 SvXMLImportContext *pContext = (*mpContexts)[nCount-1];
751 return pContext;
752 } else {
753 return NULL;
757 SvXMLImportContext *SvXMLImport::createUnknownContext( USHORT nPrefix,
758 const ::rtl::OUString& rLocalName,
759 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList )
761 bool bProcessContent=true;
762 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
763 for(sal_Int16 a=0; a < nAttrCount; a++)
765 const OUString& rAttrName = xAttrList->getNameByIndex(a);
766 OUString aLocalName;
767 sal_uInt16 _nPrefix = GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
768 const OUString aValue( xAttrList->getValueByIndex(a) );
769 if (_nPrefix==XML_NAMESPACE_OFFICE && IsXMLToken( aLocalName, XML_PROCESS_CONTENT ) ) {
770 bProcessContent=!aValue.equalsIgnoreAsciiCaseAscii("false");
773 SvXMLImportContext *ret=NULL;
774 if (bProcessContent) {
775 ret=getTopContext();
777 if (ret==NULL) {
778 ret=new SvXMLImportContext( *this, nPrefix, rLocalName );
780 return ret;
783 void SAL_CALL SvXMLImport::endElement( const OUString&
784 #ifndef PRODUCT
785 rName
786 #endif
788 throw(xml::sax::SAXException, uno::RuntimeException)
790 USHORT nCount = mpContexts->Count();
791 DBG_ASSERT( nCount, "SvXMLImport::endElement: no context left" );
792 if( nCount > 0 )
794 // Get topmost context and remove it from the stack.
795 SvXMLImportContext *pContext = (*mpContexts)[nCount-1];
796 mpContexts->Remove( nCount-1, 1 );
798 #ifndef PRODUCT
799 // Non product only: check if endElement call matches startELement call.
800 OUString aLocalName;
801 USHORT nPrefix =
802 mpNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
803 DBG_ASSERT( pContext->GetPrefix() == nPrefix,
804 "SvXMLImport::endElement: popped context has wrong prefix" );
805 DBG_ASSERT( pContext->GetLocalName() == aLocalName,
806 "SvXMLImport::endElement: popped context has wrong lname" );
807 #endif
809 // Call a EndElement at the current context.
810 pContext->EndElement();
812 // Get a namespace map to rewind.
813 SvXMLNamespaceMap *pRewindMap = pContext->GetRewindMap();
815 // Delete the current context.
816 pContext->ReleaseRef();
817 pContext = 0;
819 // Rewind a namespace map.
820 if( pRewindMap )
822 delete mpNamespaceMap;
823 mpNamespaceMap = pRewindMap;
828 void SAL_CALL SvXMLImport::characters( const OUString& rChars )
829 throw(xml::sax::SAXException, uno::RuntimeException)
831 USHORT nCount = mpContexts->Count();
832 if( nCount > 0 )
834 (*mpContexts)[nCount - 1]->Characters( rChars );
838 void SAL_CALL SvXMLImport::ignorableWhitespace( const OUString& )
839 throw(xml::sax::SAXException, uno::RuntimeException)
843 void SAL_CALL SvXMLImport::processingInstruction( const OUString&,
844 const OUString& )
845 throw(xml::sax::SAXException, uno::RuntimeException)
849 void SAL_CALL SvXMLImport::setDocumentLocator( const uno::Reference< xml::sax::XLocator >& rLocator )
850 throw(xml::sax::SAXException, uno::RuntimeException)
852 mxLocator = rLocator;
855 // XExtendedDocumentHandler
856 void SAL_CALL SvXMLImport::startCDATA( void ) throw(xml::sax::SAXException, uno::RuntimeException)
860 void SAL_CALL SvXMLImport::endCDATA( void ) throw(uno::RuntimeException)
864 void SAL_CALL SvXMLImport::comment( const OUString& )
865 throw(xml::sax::SAXException, uno::RuntimeException)
869 void SAL_CALL SvXMLImport::allowLineBreak( void )
870 throw(xml::sax::SAXException, uno::RuntimeException)
874 void SAL_CALL SvXMLImport::unknown( const OUString& )
875 throw(xml::sax::SAXException, uno::RuntimeException)
879 void SvXMLImport::SetStatistics(const uno::Sequence< beans::NamedValue> &)
881 GetProgressBarHelper()->SetRepeat(sal_False);
882 GetProgressBarHelper()->SetReference(0);
885 ///////////////////////////////////////////////////////////////////////
887 // XImporter
888 void SAL_CALL SvXMLImport::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc )
889 throw(lang::IllegalArgumentException, uno::RuntimeException)
891 mxModel = uno::Reference< frame::XModel >::query( xDoc );
892 if( !mxModel.is() )
893 throw lang::IllegalArgumentException();
894 if (mxModel.is() && !mxEventListener.is())
896 mxEventListener.set(new SvXMLImportEventListener(this));
897 mxModel->addEventListener(mxEventListener);
900 DBG_ASSERT( !mpNumImport, "number format import already exists." );
901 if( mpNumImport )
903 delete mpNumImport;
904 mpNumImport = 0;
908 // XFilter
909 sal_Bool SAL_CALL SvXMLImport::filter( const uno::Sequence< beans::PropertyValue >& )
910 throw (uno::RuntimeException)
912 return sal_False;
915 void SAL_CALL SvXMLImport::cancel( )
916 throw (uno::RuntimeException)
920 // XInitialize
921 void SAL_CALL SvXMLImport::initialize( const uno::Sequence< uno::Any >& aArguments )
922 throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
924 const sal_Int32 nAnyCount = aArguments.getLength();
925 const uno::Any* pAny = aArguments.getConstArray();
927 for( sal_Int32 nIndex = 0; nIndex < nAnyCount; nIndex++, pAny++ )
929 Reference<XInterface> xValue;
930 *pAny >>= xValue;
932 uno::Reference<task::XStatusIndicator> xTmpStatusIndicator(
933 xValue, UNO_QUERY );
934 if( xTmpStatusIndicator.is() )
935 mxStatusIndicator = xTmpStatusIndicator;
937 uno::Reference<document::XGraphicObjectResolver> xTmpGraphicResolver(
938 xValue, UNO_QUERY );
939 if( xTmpGraphicResolver.is() )
940 mxGraphicResolver = xTmpGraphicResolver;
942 uno::Reference<document::XEmbeddedObjectResolver> xTmpObjectResolver(
943 xValue, UNO_QUERY );
944 if( xTmpObjectResolver.is() )
945 mxEmbeddedResolver = xTmpObjectResolver;
947 uno::Reference<beans::XPropertySet> xTmpPropSet( xValue, UNO_QUERY );
948 if( xTmpPropSet.is() )
950 mxImportInfo = xTmpPropSet;
951 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
952 if (xPropertySetInfo.is())
954 OUString sPropName(RTL_CONSTASCII_USTRINGPARAM(XML_NUMBERSTYLES));
955 if (xPropertySetInfo->hasPropertyByName(sPropName))
957 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
958 aAny >>= mxNumberStyles;
961 sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("PrivateData" ) );
962 if (xPropertySetInfo->hasPropertyByName(sPropName))
964 Reference < XInterface > xIfc;
965 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
966 aAny >>= xIfc;
968 StyleMap *pSMap = StyleMap::getImplementation( xIfc );
969 if( pSMap )
971 mpStyleMap = pSMap;
972 mpStyleMap->acquire();
975 OUString sBaseURI;
976 sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("BaseURI" ) );
977 if (xPropertySetInfo->hasPropertyByName(sPropName))
979 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
980 aAny >>= sBaseURI;
981 mpImpl->aBaseURL.SetURL( sBaseURI );
982 mpImpl->aDocBase.SetURL( sBaseURI );
984 OUString sRelPath;
985 sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamRelPath" ) );
986 if( xPropertySetInfo->hasPropertyByName(sPropName) )
988 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
989 aAny >>= sRelPath;
991 OUString sName;
992 sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamName" ) );
993 if( xPropertySetInfo->hasPropertyByName(sPropName) )
995 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
996 aAny >>= sName;
998 if( sBaseURI.getLength() && sName.getLength() )
1000 if( sRelPath.getLength() )
1001 mpImpl->aBaseURL.insertName( sRelPath );
1002 mpImpl->aBaseURL.insertName( sName );
1004 mpImpl->mStreamName = sName; // Note: may be empty (XSLT)
1005 // --> OD 2004-08-10 #i28749# - retrieve property <ShapePositionInHoriL2R>
1006 sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("ShapePositionInHoriL2R" ) );
1007 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1009 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1010 aAny >>= (mpImpl->mbShapePositionInHoriL2R);
1012 // <--
1013 // --> OD 2007-12-19 #152540#
1014 sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("TextDocInOOoFileFormat" ) );
1015 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1017 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1018 aAny >>= (mpImpl->mbTextDocInOOoFileFormat);
1020 // <--
1026 // XServiceInfo
1027 OUString SAL_CALL SvXMLImport::getImplementationName()
1028 throw(uno::RuntimeException)
1030 OUString aStr;
1031 return aStr;
1034 sal_Bool SAL_CALL SvXMLImport::supportsService( const OUString& rServiceName )
1035 throw(::com::sun::star::uno::RuntimeException)
1037 return
1038 rServiceName.equalsAsciiL(
1039 "com.sun.star.document.ImportFilter",
1040 sizeof("com.sun.star.document.ImportFilter")-1 ) ||
1041 rServiceName.equalsAsciiL(
1042 "com.sun.star.xml.XMLImportFilter",
1043 sizeof("com.sun.star.xml.XMLImportFilter")-1);
1046 uno::Sequence< OUString > SAL_CALL SvXMLImport::getSupportedServiceNames( )
1047 throw(uno::RuntimeException)
1049 uno::Sequence<OUString> aSeq(2);
1050 aSeq[0] = OUString(
1051 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportFilter"));
1052 aSeq[1] = OUString(
1053 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLImportFilter"));
1054 return aSeq;
1057 ///////////////////////////////////////////////////////////////////////
1059 XMLTextImportHelper* SvXMLImport::CreateTextImport()
1061 return new XMLTextImportHelper( mxModel, *this );
1064 XMLShapeImportHelper* SvXMLImport::CreateShapeImport()
1066 return new XMLShapeImportHelper( *this, mxModel );
1069 #ifndef SVX_LIGHT
1070 SchXMLImportHelper* SvXMLImport::CreateChartImport()
1072 return new SchXMLImportHelper();
1074 #endif
1076 #ifndef SVX_LIGHT
1077 ::xmloff::OFormLayerXMLImport* SvXMLImport::CreateFormImport()
1079 return new ::xmloff::OFormLayerXMLImport(*this);
1081 #endif // #ifndef SVX_LIGHT
1084 ///////////////////////////////////////////////////////////////////////////////
1086 // Get or create fill/line/lineend-style-helper
1089 const Reference< container::XNameContainer > & SvXMLImport::GetGradientHelper()
1091 if( !mxGradientHelper.is() )
1093 if( mxModel.is() )
1095 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1096 if( xServiceFact.is() )
1100 mxGradientHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
1101 OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GradientTable" ) ) ), UNO_QUERY);
1103 catch( lang::ServiceNotRegisteredException& )
1109 return mxGradientHelper;
1112 const Reference< container::XNameContainer > & SvXMLImport::GetHatchHelper()
1114 if( !mxHatchHelper.is() )
1116 if( mxModel.is() )
1118 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1119 if( xServiceFact.is() )
1123 mxHatchHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
1124 OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.HatchTable" ) ) ), UNO_QUERY);
1126 catch( lang::ServiceNotRegisteredException& )
1132 return mxHatchHelper;
1135 const Reference< container::XNameContainer > & SvXMLImport::GetBitmapHelper()
1137 if( !mxBitmapHelper.is() )
1139 if( mxModel.is() )
1141 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1142 if( xServiceFact.is() )
1146 mxBitmapHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
1147 OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.BitmapTable" ) ) ), UNO_QUERY);
1149 catch( lang::ServiceNotRegisteredException& )
1155 return mxBitmapHelper;
1158 const Reference< container::XNameContainer > & SvXMLImport::GetTransGradientHelper()
1160 if( !mxTransGradientHelper.is() )
1162 if( mxModel.is() )
1164 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1165 if( xServiceFact.is() )
1169 mxTransGradientHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
1170 OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TransparencyGradientTable" ) ) ), UNO_QUERY);
1172 catch( lang::ServiceNotRegisteredException& )
1178 return mxTransGradientHelper;
1181 const Reference< container::XNameContainer > & SvXMLImport::GetMarkerHelper()
1183 if( !mxMarkerHelper.is() )
1185 if( mxModel.is() )
1187 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1188 if( xServiceFact.is() )
1192 mxMarkerHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
1193 OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.MarkerTable" ) ) ), UNO_QUERY);
1195 catch( lang::ServiceNotRegisteredException& )
1201 return mxMarkerHelper;
1204 const Reference< container::XNameContainer > & SvXMLImport::GetDashHelper()
1206 if( !mxDashHelper.is() )
1208 if( mxModel.is() )
1210 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1211 if( xServiceFact.is() )
1215 mxDashHelper = Reference< container::XNameContainer >( xServiceFact->createInstance(
1216 OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DashTable" ) ) ), UNO_QUERY);
1218 catch( lang::ServiceNotRegisteredException& )
1224 return mxDashHelper;
1227 sal_Bool SvXMLImport::IsPackageURL( const ::rtl::OUString& rURL ) const
1230 // if, and only if, only parts are imported, then we're in a package
1231 const sal_uInt32 nTest = IMPORT_META|IMPORT_STYLES|IMPORT_CONTENT|IMPORT_SETTINGS;
1232 if( (mnImportFlags & nTest) == nTest )
1233 return sal_False;
1235 // Some quick tests: Some may rely on the package structure!
1236 sal_Int32 nLen = rURL.getLength();
1237 if( (nLen > 0 && '/' == rURL[0]) )
1238 // RFC2396 net_path or abs_path
1239 return sal_False;
1240 else if( nLen > 1 && '.' == rURL[0] )
1242 if( '.' == rURL[1] )
1243 // ../: We are never going up one level, so we know
1244 // it's not an external URI
1245 return sal_False;
1246 else if( '/' == rURL[1] )
1247 // we are remaining on a level, so it's an package URI
1248 return sal_True;
1251 // Now check for a RFC2396 schema
1252 sal_Int32 nPos = 1;
1253 while( nPos < nLen )
1255 switch( rURL[nPos] )
1257 case '/':
1258 // a relative path segement
1259 return sal_True;
1260 case ':':
1261 // a schema
1262 return sal_False;
1263 default:
1264 break;
1265 // we don't care about any other characters
1267 ++nPos;
1270 return sal_True;
1273 ::rtl::OUString SvXMLImport::ResolveGraphicObjectURL( const ::rtl::OUString& rURL,
1274 sal_Bool bLoadOnDemand )
1276 ::rtl::OUString sRet;
1278 if( IsPackageURL( rURL ) )
1280 if( !bLoadOnDemand && mxGraphicResolver.is() )
1282 ::rtl::OUString aTmp( msPackageProtocol );
1283 aTmp += rURL;
1284 sRet = mxGraphicResolver->resolveGraphicObjectURL( aTmp );
1287 if( !sRet.getLength() )
1289 sRet = msPackageProtocol;
1290 sRet += rURL;
1294 if( !sRet.getLength() )
1295 sRet = GetAbsoluteReference( rURL );
1297 return sRet;
1300 Reference< XOutputStream > SvXMLImport::GetStreamForGraphicObjectURLFromBase64()
1302 Reference< XOutputStream > xOStm;
1303 Reference< document::XBinaryStreamResolver > xStmResolver( mxGraphicResolver, UNO_QUERY );
1305 if( xStmResolver.is() )
1306 xOStm = xStmResolver->createOutputStream();
1308 return xOStm;
1311 ::rtl::OUString SvXMLImport::ResolveGraphicObjectURLFromBase64(
1312 const Reference < XOutputStream >& rOut )
1314 OUString sURL;
1315 Reference< document::XBinaryStreamResolver > xStmResolver( mxGraphicResolver, UNO_QUERY );
1316 if( xStmResolver.is() )
1317 sURL = xStmResolver->resolveOutputStream( rOut );
1319 return sURL;
1322 ::rtl::OUString SvXMLImport::ResolveEmbeddedObjectURL(
1323 const ::rtl::OUString& rURL,
1324 const ::rtl::OUString& rClassId )
1326 ::rtl::OUString sRet;
1328 if( IsPackageURL( rURL ) )
1330 if ( mxEmbeddedResolver.is() )
1332 OUString sURL( rURL );
1333 if( rClassId.getLength() )
1335 sURL += OUString( sal_Unicode('!') );
1336 sURL += rClassId;
1338 sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL( sURL );
1341 else
1342 sRet = GetAbsoluteReference( rURL );
1344 return sRet;
1347 Reference < XOutputStream >
1348 SvXMLImport::GetStreamForEmbeddedObjectURLFromBase64()
1350 Reference < XOutputStream > xOLEStream;
1352 if( mxEmbeddedResolver.is() )
1354 Reference< XNameAccess > xNA( mxEmbeddedResolver, UNO_QUERY );
1355 if( xNA.is() )
1357 OUString aURL( RTL_CONSTASCII_USTRINGPARAM( "Obj12345678" ) );
1358 Any aAny = xNA->getByName( aURL );
1359 aAny >>= xOLEStream;
1363 return xOLEStream;
1366 ::rtl::OUString SvXMLImport::ResolveEmbeddedObjectURLFromBase64()
1368 ::rtl::OUString sRet;
1370 if( mxEmbeddedResolver.is() )
1372 OUString aURL( RTL_CONSTASCII_USTRINGPARAM( "Obj12345678" ) );
1373 sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL( aURL );
1376 return sRet;
1379 void SvXMLImport::AddStyleDisplayName( sal_uInt16 nFamily,
1380 const OUString& rName,
1381 const OUString& rDisplayName )
1383 if( !mpStyleMap )
1385 mpStyleMap = new StyleMap;
1386 mpStyleMap->acquire();
1387 if( mxImportInfo.is() )
1389 OUString sPrivateData(
1390 RTL_CONSTASCII_USTRINGPARAM("PrivateData" ) );
1391 Reference< beans::XPropertySetInfo > xPropertySetInfo =
1392 mxImportInfo->getPropertySetInfo();
1393 if( xPropertySetInfo.is() &&
1394 xPropertySetInfo->hasPropertyByName(sPrivateData) )
1396 Reference < XInterface > xIfc(
1397 static_cast< XUnoTunnel *>( mpStyleMap ) );
1398 Any aAny;
1399 aAny <<= xIfc;
1400 mxImportInfo->setPropertyValue( sPrivateData, aAny );
1405 StyleMap::key_type aKey( nFamily, rName );
1406 StyleMap::value_type aValue( aKey, rDisplayName );
1407 ::std::pair<StyleMap::iterator,bool> aRes( mpStyleMap->insert( aValue ) );
1408 OSL_ENSURE( aRes.second, "duplicate style name" );
1412 OUString SvXMLImport::GetStyleDisplayName( sal_uInt16 nFamily,
1413 const OUString& rName ) const
1415 OUString sName( rName );
1416 if( mpStyleMap && rName.getLength() )
1418 StyleMap::key_type aKey( nFamily, rName );
1419 StyleMap::const_iterator aIter = mpStyleMap->find( aKey );
1420 if( aIter != mpStyleMap->end() )
1421 sName = (*aIter).second;
1423 return sName;
1426 void SvXMLImport::SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&)
1430 void SvXMLImport::SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&)
1434 void SvXMLImport::SetDocumentSpecificSettings(const ::rtl::OUString& _rSettingsGroupName, const uno::Sequence<beans::PropertyValue>& _rSettings)
1436 (void)_rSettingsGroupName;
1437 (void)_rSettings;
1440 ProgressBarHelper* SvXMLImport::GetProgressBarHelper()
1442 if (!mpProgressBarHelper)
1444 mpProgressBarHelper = new ProgressBarHelper(mxStatusIndicator, sal_False);
1446 if (mxImportInfo.is())
1448 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
1449 if (xPropertySetInfo.is())
1451 OUString sProgressRange(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSRANGE));
1452 OUString sProgressMax(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSMAX));
1453 OUString sProgressCurrent(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSCURRENT));
1454 OUString sRepeat(RTL_CONSTASCII_USTRINGPARAM(XML_PROGRESSREPEAT));
1455 if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
1456 xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
1457 xPropertySetInfo->hasPropertyByName(sProgressRange))
1459 uno::Any aAny;
1460 sal_Int32 nProgressMax(0);
1461 sal_Int32 nProgressCurrent(0);
1462 sal_Int32 nProgressRange(0);
1463 aAny = mxImportInfo->getPropertyValue(sProgressRange);
1464 if (aAny >>= nProgressRange)
1465 mpProgressBarHelper->SetRange(nProgressRange);
1466 aAny = mxImportInfo->getPropertyValue(sProgressMax);
1467 if (aAny >>= nProgressMax)
1468 mpProgressBarHelper->SetReference(nProgressMax);
1469 aAny = mxImportInfo->getPropertyValue(sProgressCurrent);
1470 if (aAny >>= nProgressCurrent)
1471 mpProgressBarHelper->SetValue(nProgressCurrent);
1473 if (xPropertySetInfo->hasPropertyByName(sRepeat))
1475 uno::Any aAny = mxImportInfo->getPropertyValue(sRepeat);
1476 if (aAny.getValueType() == getBooleanCppuType())
1477 mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
1478 else {
1479 DBG_ERRORFILE("why is it no boolean?");
1485 return mpProgressBarHelper;
1488 void SvXMLImport::AddNumberStyle(sal_Int32 nKey, const OUString& rName)
1490 if (!mxNumberStyles.is())
1491 mxNumberStyles = uno::Reference< container::XNameContainer >( comphelper::NameContainer_createInstance( ::getCppuType((const sal_Int32*)0)) );
1492 if (mxNumberStyles.is())
1494 uno::Any aAny;
1495 aAny <<= nKey;
1498 mxNumberStyles->insertByName(rName, aAny);
1500 catch ( uno::Exception& )
1502 DBG_ERROR("Numberformat could not be inserted");
1505 else {
1506 DBG_ERROR("not possible to create NameContainer");
1510 XMLEventImportHelper& SvXMLImport::GetEventImport()
1512 #ifndef SVX_LIGHT
1513 if (!mpEventImportHelper)
1515 // construct event helper and register StarBasic handler and standard
1516 // event tables
1517 mpEventImportHelper = new XMLEventImportHelper();
1518 OUString sStarBasic(GetXMLToken(XML_STARBASIC));
1519 mpEventImportHelper->RegisterFactory(sStarBasic,
1520 new XMLStarBasicContextFactory());
1521 OUString sScript(GetXMLToken(XML_SCRIPT));
1522 mpEventImportHelper->RegisterFactory(sScript,
1523 new XMLScriptContextFactory());
1524 mpEventImportHelper->AddTranslationTable(aStandardEventTable);
1526 // register StarBasic event handler with capitalized spelling
1527 OUString sStarBasicCap(RTL_CONSTASCII_USTRINGPARAM("StarBasic"));
1528 mpEventImportHelper->RegisterFactory(sStarBasicCap,
1529 new XMLStarBasicContextFactory());
1531 #endif
1533 return *mpEventImportHelper;
1536 void SvXMLImport::SetFontDecls( XMLFontStylesContext *pFontDecls )
1538 mxFontDecls = pFontDecls;
1539 GetTextImport()->SetFontDecls( pFontDecls );
1542 void SvXMLImport::SetStyles( SvXMLStylesContext *pStyles )
1544 mxStyles = pStyles;
1547 void SvXMLImport::SetAutoStyles( SvXMLStylesContext *pAutoStyles )
1549 if (pAutoStyles && mxNumberStyles.is() && (mnImportFlags & IMPORT_CONTENT) )
1551 uno::Reference<xml::sax::XAttributeList> xAttrList;
1552 uno::Sequence< ::rtl::OUString > aNames = mxNumberStyles->getElementNames();
1553 sal_uInt32 nCount(aNames.getLength());
1554 if (nCount)
1556 const OUString* pNames = aNames.getConstArray();
1557 if ( pNames )
1559 SvXMLStyleContext* pContext;
1560 uno::Any aAny;
1561 sal_Int32 nKey(0);
1562 for (sal_uInt32 i = 0; i < nCount; i++, pNames++)
1564 aAny = mxNumberStyles->getByName(*pNames);
1565 if (aAny >>= nKey)
1567 pContext = new SvXMLNumFormatContext( *this, XML_NAMESPACE_NUMBER,
1568 *pNames, xAttrList, nKey, *pAutoStyles );
1569 pAutoStyles->AddStyle(*pContext);
1575 mxAutoStyles = pAutoStyles;
1576 GetTextImport()->SetAutoStyles( pAutoStyles );
1577 GetShapeImport()->SetAutoStylesContext( pAutoStyles );
1578 #ifndef SVX_LIGHT
1579 GetChartImport()->SetAutoStylesContext( pAutoStyles );
1580 GetFormImport()->setAutoStyleContext( pAutoStyles );
1581 #endif
1584 void SvXMLImport::SetMasterStyles( SvXMLStylesContext *pMasterStyles )
1586 mxMasterStyles = pMasterStyles;
1589 XMLFontStylesContext *SvXMLImport::GetFontDecls()
1591 return (XMLFontStylesContext *)&mxFontDecls;
1594 SvXMLStylesContext *SvXMLImport::GetStyles()
1596 return (SvXMLStylesContext *)&mxStyles;
1599 SvXMLStylesContext *SvXMLImport::GetAutoStyles()
1601 return (SvXMLStylesContext *)&mxAutoStyles;
1604 SvXMLStylesContext *SvXMLImport::GetMasterStyles()
1606 return (SvXMLStylesContext *)&mxMasterStyles;
1609 const XMLFontStylesContext *SvXMLImport::GetFontDecls() const
1611 return (const XMLFontStylesContext *)&mxFontDecls;
1614 const SvXMLStylesContext *SvXMLImport::GetStyles() const
1616 return (const SvXMLStylesContext *)&mxStyles;
1619 const SvXMLStylesContext *SvXMLImport::GetAutoStyles() const
1621 return (const SvXMLStylesContext *)&mxAutoStyles;
1624 const SvXMLStylesContext *SvXMLImport::GetMasterStyles() const
1626 return (const SvXMLStylesContext *)&mxMasterStyles;
1629 OUString SvXMLImport::GetAbsoluteReference(const OUString& rValue) const
1631 if( rValue.getLength() == 0 || rValue[0] == '#' )
1632 return rValue;
1634 INetURLObject aAbsURL;
1635 if( mpImpl->aBaseURL.GetNewAbsURL( rValue, &aAbsURL ) )
1636 return aAbsURL.GetMainURL( INetURLObject::DECODE_TO_IURI );
1637 else
1638 return rValue;
1641 void SvXMLImport::_CreateNumberFormatsSupplier()
1643 DBG_ASSERT( !mxNumberFormatsSupplier.is(),
1644 "number formats supplier already exists!" );
1645 if(mxModel.is())
1646 mxNumberFormatsSupplier =
1647 uno::Reference< util::XNumberFormatsSupplier> (mxModel, uno::UNO_QUERY);
1651 void SvXMLImport::_CreateDataStylesImport()
1653 DBG_ASSERT( mpNumImport == NULL, "data styles import already exists!" );
1654 uno::Reference<util::XNumberFormatsSupplier> xNum =
1655 GetNumberFormatsSupplier();
1656 if ( xNum.is() )
1657 mpNumImport = new SvXMLNumFmtHelper(xNum, getServiceFactory());
1661 sal_Unicode SvXMLImport::ConvStarBatsCharToStarSymbol( sal_Unicode c )
1663 sal_Unicode cNew = c;
1664 if( !mpImpl->hBatsFontConv )
1666 OUString sStarBats( RTL_CONSTASCII_USTRINGPARAM( "StarBats" ) );
1667 mpImpl->hBatsFontConv = CreateFontToSubsFontConverter( sStarBats,
1668 FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS );
1669 OSL_ENSURE( mpImpl->hBatsFontConv, "Got no symbol font converter" );
1671 if( mpImpl->hBatsFontConv )
1673 cNew = ConvertFontToSubsFontChar( mpImpl->hBatsFontConv, c );
1676 return cNew;
1679 sal_Unicode SvXMLImport::ConvStarMathCharToStarSymbol( sal_Unicode c )
1681 sal_Unicode cNew = c;
1682 if( !mpImpl->hMathFontConv )
1684 OUString sStarMath( RTL_CONSTASCII_USTRINGPARAM( "StarMath" ) );
1685 mpImpl->hMathFontConv = CreateFontToSubsFontConverter( sStarMath,
1686 FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS );
1687 OSL_ENSURE( mpImpl->hMathFontConv, "Got no symbol font converter" );
1689 if( mpImpl->hMathFontConv )
1691 cNew = ConvertFontToSubsFontChar( mpImpl->hMathFontConv, c );
1694 return cNew;
1699 void SvXMLImport::SetError(
1700 sal_Int32 nId,
1701 const Sequence<OUString>& rMsgParams,
1702 const OUString& rExceptionMessage,
1703 const Reference<xml::sax::XLocator>& rLocator )
1705 // maintain error flags
1706 if ( ( nId & XMLERROR_FLAG_ERROR ) != 0 )
1707 mnErrorFlags |= ERROR_ERROR_OCCURED;
1708 if ( ( nId & XMLERROR_FLAG_WARNING ) != 0 )
1709 mnErrorFlags |= ERROR_WARNING_OCCURED;
1710 if ( ( nId & XMLERROR_FLAG_SEVERE ) != 0 )
1711 mnErrorFlags |= ERROR_DO_NOTHING;
1713 // create error list on demand
1714 if ( mpXMLErrors == NULL )
1715 mpXMLErrors = new XMLErrors();
1717 // save error information
1718 // use document locator (if none supplied)
1719 mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage,
1720 rLocator.is() ? rLocator : mxLocator );
1723 void SvXMLImport::SetError(
1724 sal_Int32 nId,
1725 const Sequence<OUString>& rMsgParams)
1727 OUString sEmpty;
1728 SetError( nId, rMsgParams, sEmpty, NULL );
1731 void SvXMLImport::SetError(
1732 sal_Int32 nId)
1734 Sequence<OUString> aSeq(0);
1735 SetError( nId, aSeq );
1738 void SvXMLImport::SetError(
1739 sal_Int32 nId,
1740 const OUString& rMsg1)
1742 Sequence<OUString> aSeq(1);
1743 OUString* pSeq = aSeq.getArray();
1744 pSeq[0] = rMsg1;
1745 SetError( nId, aSeq );
1748 void SvXMLImport::SetError(
1749 sal_Int32 nId,
1750 const OUString& rMsg1,
1751 const OUString& rMsg2)
1753 Sequence<OUString> aSeq(2);
1754 OUString* pSeq = aSeq.getArray();
1755 pSeq[0] = rMsg1;
1756 pSeq[1] = rMsg2;
1757 SetError( nId, aSeq );
1760 void SvXMLImport::SetError(
1761 sal_Int32 nId,
1762 const OUString& rMsg1,
1763 const OUString& rMsg2,
1764 const OUString& rMsg3)
1766 Sequence<OUString> aSeq(3);
1767 OUString* pSeq = aSeq.getArray();
1768 pSeq[0] = rMsg1;
1769 pSeq[1] = rMsg2;
1770 pSeq[2] = rMsg3;
1771 SetError( nId, aSeq );
1774 void SvXMLImport::SetError(
1775 sal_Int32 nId,
1776 const OUString& rMsg1,
1777 const OUString& rMsg2,
1778 const OUString& rMsg3,
1779 const OUString& rMsg4)
1781 Sequence<OUString> aSeq(4);
1782 OUString* pSeq = aSeq.getArray();
1783 pSeq[0] = rMsg1;
1784 pSeq[1] = rMsg2;
1785 pSeq[2] = rMsg3;
1786 pSeq[3] = rMsg4;
1787 SetError( nId, aSeq );
1790 XMLErrors* SvXMLImport::GetErrors()
1792 return mpXMLErrors;
1795 void SvXMLImport::DisposingModel()
1797 if( mxFontDecls.Is() )
1798 ((SvXMLStylesContext *)&mxFontDecls)->Clear();
1799 if( mxStyles.Is() )
1800 ((SvXMLStylesContext *)&mxStyles)->Clear();
1801 if( mxAutoStyles.Is() )
1802 ((SvXMLStylesContext *)&mxAutoStyles)->Clear();
1803 if( mxMasterStyles.Is() )
1804 ((SvXMLStylesContext *)&mxMasterStyles)->Clear();
1806 mxModel.set(0);
1807 mxEventListener.set(NULL);
1810 ::comphelper::UnoInterfaceToUniqueIdentifierMapper& SvXMLImport::getInterfaceToIdentifierMapper()
1812 return mpImpl->maInterfaceToIdentifierMapper;
1815 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SvXMLImport::getServiceFactory()
1817 // #110680#
1818 return mxServiceFactory;
1821 uno::Reference< uno::XComponentContext >
1822 SvXMLImport::GetComponentContext() const
1824 return mpImpl->mxComponentContext;
1827 String SvXMLImport::GetBaseURL() const
1829 return mpImpl->aBaseURL.GetMainURL( INetURLObject::NO_DECODE );
1832 String SvXMLImport::GetDocumentBase() const
1834 return mpImpl->aDocBase.GetMainURL( INetURLObject::NO_DECODE );
1837 ::rtl::OUString SvXMLImport::GetStreamName() const
1839 return mpImpl->mStreamName;
1842 // --> OD 2004-08-10 #i28749#
1843 sal_Bool SvXMLImport::IsShapePositionInHoriL2R() const
1845 return mpImpl->mbShapePositionInHoriL2R;
1847 // <--
1849 // --> OD 2007-12-19 #152540#
1850 sal_Bool SvXMLImport::IsTextDocInOOoFileFormat() const
1852 return mpImpl->mbTextDocInOOoFileFormat;
1855 // <--
1857 void SvXMLImport::initXForms()
1859 // dummy method; to be implemented by derived classes supporting XForms
1862 bool SvXMLImport::getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild ) const
1864 bool bRet = false;
1865 if( mxImportInfo.is() ) try
1867 const OUString aPropName(RTL_CONSTASCII_USTRINGPARAM("BuildId"));
1868 Reference< XPropertySetInfo > xSetInfo( mxImportInfo->getPropertySetInfo() );
1869 if( xSetInfo.is() && xSetInfo->hasPropertyByName( aPropName ) )
1871 OUString aBuildId;
1872 mxImportInfo->getPropertyValue( aPropName ) >>= aBuildId;
1873 if( aBuildId.getLength() )
1875 sal_Int32 nIndex = aBuildId.indexOf('$');
1876 if( nIndex != -1 )
1878 rUPD = aBuildId.copy( 0, nIndex ).toInt32();
1879 rBuild = aBuildId.copy( nIndex+1 ).toInt32();
1880 bRet = true;
1885 catch( Exception& )
1888 return bRet;
1891 sal_uInt16 SvXMLImport::getGeneratorVersion() const
1893 sal_Int32 nUPD, nBuild;
1895 if( getBuildIds( nUPD, nBuild ) )
1897 if( nUPD == 680 )
1898 return OOo_2x;
1900 if( nUPD >= 640 && nUPD <= 645 )
1901 return OOo_1x;
1904 return OOo_Current;
1907 bool SvXMLImport::isGraphicLoadOnDemandSupported() const
1909 return mbIsGraphicLoadOnDemandSupported;
1912 ::rtl::OUString SvXMLImport::GetODFVersion() const
1914 return mpImpl->aODFVersion;
1917 // xml:id for RDF metadata
1918 void SvXMLImport::SetXmlId(uno::Reference<uno::XInterface> const & i_xIfc,
1919 ::rtl::OUString const & i_rXmlId)
1921 if (i_rXmlId.getLength() > 0) {
1922 try {
1923 const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc,
1924 uno::UNO_QUERY);
1925 //FIXME: not yet
1926 // OSL_ENSURE(xMeta.is(), "xml:id: not XMetadatable");
1927 if (xMeta.is()) {
1928 const beans::StringPair mdref( GetStreamName(), i_rXmlId );
1929 try {
1930 xMeta->setMetadataReference(mdref);
1931 } catch (lang::IllegalArgumentException &) {
1932 // probably duplicate; ignore
1933 OSL_TRACE("SvXMLImport::SetXmlId: cannot set xml:id");
1936 } catch (uno::Exception &) {
1941 void
1942 SvXMLImport::AddRDFa(uno::Reference<rdf::XMetadatable> i_xObject,
1943 ::rtl::OUString const & i_rAbout,
1944 ::rtl::OUString const & i_rProperty,
1945 ::rtl::OUString const & i_rContent,
1946 ::rtl::OUString const & i_rDatatype)
1948 // N.B.: we only get called if i_xObject had xhtml:about attribute
1949 // (an empty attribute value is valid)
1950 if (!mpImpl->mpRDFaHelper.get())
1952 mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaImportHelper(*this) );
1954 mpImpl->mpRDFaHelper->AddRDFa(i_xObject,
1955 i_rAbout, i_rProperty, i_rContent, i_rDatatype);