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