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