1*96de5490SAndrew Rist /************************************************************** 2*96de5490SAndrew Rist * 3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*96de5490SAndrew Rist * distributed with this work for additional information 6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance 9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at 10*96de5490SAndrew Rist * 11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*96de5490SAndrew Rist * 13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*96de5490SAndrew Rist * software distributed under the License is distributed on an 15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the 17*96de5490SAndrew Rist * specific language governing permissions and limitations 18*96de5490SAndrew Rist * under the License. 19*96de5490SAndrew Rist * 20*96de5490SAndrew Rist *************************************************************/ 21*96de5490SAndrew Rist 22*96de5490SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "subcomponentrecovery.hxx" 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include "sdbcoretools.hxx" 29cdf0e10cSrcweir #include "storagexmlstream.hxx" 30cdf0e10cSrcweir #include "subcomponentloader.hxx" 31cdf0e10cSrcweir #include "settingsimport.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir /** === begin UNO includes === **/ 34cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp> 35cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp> 36cdf0e10cSrcweir #include <com/sun/star/document/XStorageBasedDocument.hpp> 37cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandProcessor.hpp> 38cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp> 39cdf0e10cSrcweir #include <com/sun/star/sdb/XFormDocumentsSupplier.hpp> 40cdf0e10cSrcweir #include <com/sun/star/sdb/XReportDocumentsSupplier.hpp> 41cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 42cdf0e10cSrcweir /** === end UNO includes === **/ 43cdf0e10cSrcweir 44cdf0e10cSrcweir #include <comphelper/namedvaluecollection.hxx> 45cdf0e10cSrcweir #include <connectivity/dbtools.hxx> 46cdf0e10cSrcweir #include <tools/diagnose_ex.h> 47cdf0e10cSrcweir #include <xmloff/XMLSettingsExportContext.hxx> 48cdf0e10cSrcweir #include <xmloff/SettingsExportHelper.hxx> 49cdf0e10cSrcweir 50cdf0e10cSrcweir //........................................................................ 51cdf0e10cSrcweir namespace dbaccess 52cdf0e10cSrcweir { 53cdf0e10cSrcweir //........................................................................ 54cdf0e10cSrcweir 55cdf0e10cSrcweir /** === begin UNO using === **/ 56cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 57cdf0e10cSrcweir using ::com::sun::star::uno::XInterface; 58cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 59cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY_THROW; 60cdf0e10cSrcweir using ::com::sun::star::uno::UNO_SET_THROW; 61cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 62cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 63cdf0e10cSrcweir using ::com::sun::star::uno::Any; 64cdf0e10cSrcweir using ::com::sun::star::uno::makeAny; 65cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 66cdf0e10cSrcweir using ::com::sun::star::uno::Type; 67cdf0e10cSrcweir using ::com::sun::star::lang::XMultiServiceFactory; 68cdf0e10cSrcweir using ::com::sun::star::embed::XStorage; 69cdf0e10cSrcweir using ::com::sun::star::sdb::application::XDatabaseDocumentUI; 70cdf0e10cSrcweir using ::com::sun::star::beans::Pair; 71cdf0e10cSrcweir using ::com::sun::star::frame::XModuleManager; 72cdf0e10cSrcweir using ::com::sun::star::lang::XComponent; 73cdf0e10cSrcweir using ::com::sun::star::frame::XModel; 74cdf0e10cSrcweir using ::com::sun::star::frame::XController; 75cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet; 76cdf0e10cSrcweir using ::com::sun::star::beans::PropertyValue; 77cdf0e10cSrcweir using ::com::sun::star::document::XStorageBasedDocument; 78cdf0e10cSrcweir using ::com::sun::star::ucb::XCommandProcessor; 79cdf0e10cSrcweir using ::com::sun::star::container::XHierarchicalNameAccess; 80cdf0e10cSrcweir using ::com::sun::star::sdb::XFormDocumentsSupplier; 81cdf0e10cSrcweir using ::com::sun::star::sdb::XReportDocumentsSupplier; 82cdf0e10cSrcweir using ::com::sun::star::xml::sax::SAXException; 83cdf0e10cSrcweir using ::com::sun::star::xml::sax::XLocator; 84cdf0e10cSrcweir using ::com::sun::star::xml::sax::XDocumentHandler; 85cdf0e10cSrcweir using ::com::sun::star::xml::sax::XAttributeList; 86cdf0e10cSrcweir /** === end UNO using === **/ 87cdf0e10cSrcweir 88cdf0e10cSrcweir namespace ElementModes = ::com::sun::star::embed::ElementModes; 89cdf0e10cSrcweir 90cdf0e10cSrcweir 91cdf0e10cSrcweir //==================================================================== 92cdf0e10cSrcweir //= helper 93cdf0e10cSrcweir //==================================================================== 94cdf0e10cSrcweir namespace 95cdf0e10cSrcweir { 96cdf0e10cSrcweir // ......................................................................... lcl_getComponentStorageBaseName(const SubComponentType i_eType)97cdf0e10cSrcweir static const ::rtl::OUString& lcl_getComponentStorageBaseName( const SubComponentType i_eType ) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir static const ::rtl::OUString s_sFormBaseName( RTL_CONSTASCII_USTRINGPARAM( "form" ) ); 100cdf0e10cSrcweir static const ::rtl::OUString s_sReportBaseName( RTL_CONSTASCII_USTRINGPARAM( "report" ) ); 101cdf0e10cSrcweir static const ::rtl::OUString s_sTableBaseName( RTL_CONSTASCII_USTRINGPARAM( "table" ) ); 102cdf0e10cSrcweir static const ::rtl::OUString s_sQueryBaseName( RTL_CONSTASCII_USTRINGPARAM( "query" ) ); 103cdf0e10cSrcweir 104cdf0e10cSrcweir switch ( i_eType ) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir case FORM: 107cdf0e10cSrcweir return s_sFormBaseName; 108cdf0e10cSrcweir case REPORT: 109cdf0e10cSrcweir return s_sReportBaseName; 110cdf0e10cSrcweir case TABLE: 111cdf0e10cSrcweir return s_sTableBaseName; 112cdf0e10cSrcweir case QUERY: 113cdf0e10cSrcweir return s_sQueryBaseName; 114cdf0e10cSrcweir default: 115cdf0e10cSrcweir break; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir OSL_ENSURE( false, "lcl_getComponentStorageBaseName: unimplemented case!" ); 119cdf0e10cSrcweir static const ::rtl::OUString s_sFallback; 120cdf0e10cSrcweir return s_sFallback; 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir // ......................................................................... lcl_databaseObjectToSubComponentType(const sal_Int32 i_nObjectType)124cdf0e10cSrcweir static SubComponentType lcl_databaseObjectToSubComponentType( const sal_Int32 i_nObjectType ) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir switch ( i_nObjectType ) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir case DatabaseObject::TABLE: return TABLE; 129cdf0e10cSrcweir case DatabaseObject::QUERY: return QUERY; 130cdf0e10cSrcweir case DatabaseObject::FORM: return FORM; 131cdf0e10cSrcweir case DatabaseObject::REPORT:return REPORT; 132cdf0e10cSrcweir default: 133cdf0e10cSrcweir break; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir return UNKNOWN; 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir // ......................................................................... lcl_determineReadOnly(const Reference<XComponent> & i_rComponent)139cdf0e10cSrcweir static bool lcl_determineReadOnly( const Reference< XComponent >& i_rComponent ) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir Reference< XModel > xDocument( i_rComponent, UNO_QUERY ); 142cdf0e10cSrcweir if ( !xDocument.is() ) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir Reference< XController > xController( i_rComponent, UNO_QUERY_THROW ); 145cdf0e10cSrcweir xDocument = xController->getModel(); 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148cdf0e10cSrcweir if ( !xDocument.is() ) 149cdf0e10cSrcweir return false; 150cdf0e10cSrcweir 151cdf0e10cSrcweir ::comphelper::NamedValueCollection aDocArgs( xDocument->getArgs() ); 152cdf0e10cSrcweir return aDocArgs.getOrDefault( "ReadOnly", false ); 153cdf0e10cSrcweir } 154cdf0e10cSrcweir 155cdf0e10cSrcweir // ......................................................................... lcl_getSubComponentDef_nothrow(const Reference<XDatabaseDocumentUI> & i_rAppUI,const SubComponentType i_eType,const::rtl::OUString & i_rName)156cdf0e10cSrcweir static Reference< XCommandProcessor > lcl_getSubComponentDef_nothrow( const Reference< XDatabaseDocumentUI >& i_rAppUI, 157cdf0e10cSrcweir const SubComponentType i_eType, const ::rtl::OUString& i_rName ) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir Reference< XController > xController( i_rAppUI, UNO_QUERY_THROW ); 160cdf0e10cSrcweir ENSURE_OR_RETURN( ( i_eType == FORM ) || ( i_eType == REPORT ), "lcl_getSubComponentDef_nothrow: illegal controller", NULL ); 161cdf0e10cSrcweir 162cdf0e10cSrcweir Reference< XCommandProcessor > xCommandProcessor; 163cdf0e10cSrcweir try 164cdf0e10cSrcweir { 165cdf0e10cSrcweir Reference< XHierarchicalNameAccess > xDefinitionContainer; 166cdf0e10cSrcweir if ( i_eType == FORM ) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir Reference< XFormDocumentsSupplier > xSuppForms( xController->getModel(), UNO_QUERY_THROW ); 169cdf0e10cSrcweir xDefinitionContainer.set( xSuppForms->getFormDocuments(), UNO_QUERY_THROW ); 170cdf0e10cSrcweir } 171cdf0e10cSrcweir else 172cdf0e10cSrcweir { 173cdf0e10cSrcweir Reference< XReportDocumentsSupplier > xSuppReports( xController->getModel(), UNO_QUERY_THROW ); 174cdf0e10cSrcweir xDefinitionContainer.set( xSuppReports->getReportDocuments(), UNO_QUERY_THROW ); 175cdf0e10cSrcweir } 176cdf0e10cSrcweir xCommandProcessor.set( xDefinitionContainer->getByHierarchicalName( i_rName ), UNO_QUERY_THROW ); 177cdf0e10cSrcweir } 178cdf0e10cSrcweir catch( const Exception& ) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir return xCommandProcessor; 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir // ......................................................................... lcl_getSettingsStreamName()186cdf0e10cSrcweir static const ::rtl::OUString& lcl_getSettingsStreamName() 187cdf0e10cSrcweir { 188cdf0e10cSrcweir static const ::rtl::OUString s_sStatementStreamName( RTL_CONSTASCII_USTRINGPARAM( "settings.xml" ) ); 189cdf0e10cSrcweir return s_sStatementStreamName; 190cdf0e10cSrcweir } 191cdf0e10cSrcweir 192cdf0e10cSrcweir // ......................................................................... lcl_getCurrentQueryDesignName()193cdf0e10cSrcweir static const ::rtl::OUString& lcl_getCurrentQueryDesignName() 194cdf0e10cSrcweir { 195cdf0e10cSrcweir static const ::rtl::OUString s_sQuerySettingsName( RTL_CONSTASCII_USTRINGPARAM( "ooo:current-query-design" ) ); 196cdf0e10cSrcweir return s_sQuerySettingsName; 197cdf0e10cSrcweir } 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir //==================================================================== 201cdf0e10cSrcweir //= SettingsExportContext 202cdf0e10cSrcweir //==================================================================== 203cdf0e10cSrcweir class DBACCESS_DLLPRIVATE SettingsExportContext : public ::xmloff::XMLSettingsExportContext 204cdf0e10cSrcweir { 205cdf0e10cSrcweir public: SettingsExportContext(const::comphelper::ComponentContext & i_rContext,const StorageXMLOutputStream & i_rDelegator)206cdf0e10cSrcweir SettingsExportContext( const ::comphelper::ComponentContext& i_rContext, const StorageXMLOutputStream& i_rDelegator ) 207cdf0e10cSrcweir :m_rContext( i_rContext ) 208cdf0e10cSrcweir ,m_rDelegator( i_rDelegator ) 209cdf0e10cSrcweir ,m_aNamespace( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_NP_CONFIG ) ) 210cdf0e10cSrcweir { 211cdf0e10cSrcweir } 212cdf0e10cSrcweir ~SettingsExportContext()213cdf0e10cSrcweir virtual ~SettingsExportContext() 214cdf0e10cSrcweir { 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir public: 218cdf0e10cSrcweir virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, const ::rtl::OUString& i_rValue ); 219cdf0e10cSrcweir virtual void AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, enum ::xmloff::token::XMLTokenEnum i_eValue ); 220cdf0e10cSrcweir virtual void StartElement( enum ::xmloff::token::XMLTokenEnum i_eName, const sal_Bool i_bIgnoreWhitespace ); 221cdf0e10cSrcweir virtual void EndElement ( const sal_Bool i_bIgnoreWhitespace ); 222cdf0e10cSrcweir virtual void Characters( const ::rtl::OUString& i_rCharacters ); 223cdf0e10cSrcweir 224cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > 225cdf0e10cSrcweir GetServiceFactory() const; 226cdf0e10cSrcweir 227cdf0e10cSrcweir private: impl_prefix(const::xmloff::token::XMLTokenEnum i_eToken)228cdf0e10cSrcweir ::rtl::OUString impl_prefix( const ::xmloff::token::XMLTokenEnum i_eToken ) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir ::rtl::OUStringBuffer aQualifiedName( m_aNamespace ); 231cdf0e10cSrcweir aQualifiedName.append( sal_Unicode( ':' ) ); 232cdf0e10cSrcweir aQualifiedName.append( ::xmloff::token::GetXMLToken( i_eToken ) ); 233cdf0e10cSrcweir return aQualifiedName.makeStringAndClear(); 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir private: 237cdf0e10cSrcweir const ::comphelper::ComponentContext& m_rContext; 238cdf0e10cSrcweir const StorageXMLOutputStream& m_rDelegator; 239cdf0e10cSrcweir const ::rtl::OUStringBuffer m_aNamespace; 240cdf0e10cSrcweir }; 241cdf0e10cSrcweir 242cdf0e10cSrcweir //-------------------------------------------------------------------- AddAttribute(enum::xmloff::token::XMLTokenEnum i_eName,const::rtl::OUString & i_rValue)243cdf0e10cSrcweir void SettingsExportContext::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, const ::rtl::OUString& i_rValue ) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir m_rDelegator.addAttribute( impl_prefix( i_eName ), i_rValue ); 246cdf0e10cSrcweir } 247cdf0e10cSrcweir 248cdf0e10cSrcweir //-------------------------------------------------------------------- AddAttribute(enum::xmloff::token::XMLTokenEnum i_eName,enum::xmloff::token::XMLTokenEnum i_eValue)249cdf0e10cSrcweir void SettingsExportContext::AddAttribute( enum ::xmloff::token::XMLTokenEnum i_eName, enum ::xmloff::token::XMLTokenEnum i_eValue ) 250cdf0e10cSrcweir { 251cdf0e10cSrcweir m_rDelegator.addAttribute( impl_prefix( i_eName ), ::xmloff::token::GetXMLToken( i_eValue ) ); 252cdf0e10cSrcweir } 253cdf0e10cSrcweir 254cdf0e10cSrcweir //-------------------------------------------------------------------- StartElement(enum::xmloff::token::XMLTokenEnum i_eName,const sal_Bool i_bIgnoreWhitespace)255cdf0e10cSrcweir void SettingsExportContext::StartElement( enum ::xmloff::token::XMLTokenEnum i_eName, const sal_Bool i_bIgnoreWhitespace ) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir if ( i_bIgnoreWhitespace ) 258cdf0e10cSrcweir m_rDelegator.ignorableWhitespace( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " " ) ) ); 259cdf0e10cSrcweir 260cdf0e10cSrcweir m_rDelegator.startElement( impl_prefix( i_eName ) ); 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir //-------------------------------------------------------------------- EndElement(const sal_Bool i_bIgnoreWhitespace)264cdf0e10cSrcweir void SettingsExportContext::EndElement( const sal_Bool i_bIgnoreWhitespace ) 265cdf0e10cSrcweir { 266cdf0e10cSrcweir if ( i_bIgnoreWhitespace ) 267cdf0e10cSrcweir m_rDelegator.ignorableWhitespace( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " " ) ) ); 268cdf0e10cSrcweir m_rDelegator.endElement(); 269cdf0e10cSrcweir } 270cdf0e10cSrcweir 271cdf0e10cSrcweir //-------------------------------------------------------------------- Characters(const::rtl::OUString & i_rCharacters)272cdf0e10cSrcweir void SettingsExportContext::Characters( const ::rtl::OUString& i_rCharacters ) 273cdf0e10cSrcweir { 274cdf0e10cSrcweir m_rDelegator.characters( i_rCharacters ); 275cdf0e10cSrcweir } 276cdf0e10cSrcweir 277cdf0e10cSrcweir //-------------------------------------------------------------------- GetServiceFactory() const278cdf0e10cSrcweir Reference< XMultiServiceFactory > SettingsExportContext::GetServiceFactory() const 279cdf0e10cSrcweir { 280cdf0e10cSrcweir return m_rContext.getLegacyServiceFactory(); 281cdf0e10cSrcweir } 282cdf0e10cSrcweir 283cdf0e10cSrcweir //================================================================================================================== 284cdf0e10cSrcweir //= SettingsDocumentHandler 285cdf0e10cSrcweir //================================================================================================================== 286cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1 < XDocumentHandler 287cdf0e10cSrcweir > SettingsDocumentHandler_Base; 288cdf0e10cSrcweir class DBACCESS_DLLPRIVATE SettingsDocumentHandler : public SettingsDocumentHandler_Base 289cdf0e10cSrcweir { 290cdf0e10cSrcweir public: SettingsDocumentHandler()291cdf0e10cSrcweir SettingsDocumentHandler() 292cdf0e10cSrcweir { 293cdf0e10cSrcweir } 294cdf0e10cSrcweir 295cdf0e10cSrcweir protected: ~SettingsDocumentHandler()296cdf0e10cSrcweir virtual ~SettingsDocumentHandler() 297cdf0e10cSrcweir { 298cdf0e10cSrcweir } 299cdf0e10cSrcweir 300cdf0e10cSrcweir public: 301cdf0e10cSrcweir // XDocumentHandler 302cdf0e10cSrcweir virtual void SAL_CALL startDocument( ) throw (SAXException, RuntimeException); 303cdf0e10cSrcweir virtual void SAL_CALL endDocument( ) throw (SAXException, RuntimeException); 304cdf0e10cSrcweir virtual void SAL_CALL startElement( const ::rtl::OUString& aName, const Reference< XAttributeList >& xAttribs ) throw (SAXException, RuntimeException); 305cdf0e10cSrcweir virtual void SAL_CALL endElement( const ::rtl::OUString& aName ) throw (SAXException, RuntimeException); 306cdf0e10cSrcweir virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) throw (SAXException, RuntimeException); 307cdf0e10cSrcweir virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (SAXException, RuntimeException); 308cdf0e10cSrcweir virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw (SAXException, RuntimeException); 309cdf0e10cSrcweir virtual void SAL_CALL setDocumentLocator( const Reference< XLocator >& xLocator ) throw (SAXException, RuntimeException); 310cdf0e10cSrcweir getSettings() const311cdf0e10cSrcweir const ::comphelper::NamedValueCollection& getSettings() const { return m_aSettings; } 312cdf0e10cSrcweir 313cdf0e10cSrcweir private: 314cdf0e10cSrcweir ::std::stack< ::rtl::Reference< SettingsImport > > m_aStates; 315cdf0e10cSrcweir ::comphelper::NamedValueCollection m_aSettings; 316cdf0e10cSrcweir }; 317cdf0e10cSrcweir 318cdf0e10cSrcweir //-------------------------------------------------------------------- startDocument()319cdf0e10cSrcweir void SAL_CALL SettingsDocumentHandler::startDocument( ) throw (SAXException, RuntimeException) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir } 322cdf0e10cSrcweir 323cdf0e10cSrcweir //-------------------------------------------------------------------- endDocument()324cdf0e10cSrcweir void SAL_CALL SettingsDocumentHandler::endDocument( ) throw (SAXException, RuntimeException) 325cdf0e10cSrcweir { 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir //-------------------------------------------------------------------- startElement(const::rtl::OUString & i_Name,const Reference<XAttributeList> & i_Attribs)329cdf0e10cSrcweir void SAL_CALL SettingsDocumentHandler::startElement( const ::rtl::OUString& i_Name, const Reference< XAttributeList >& i_Attribs ) throw (SAXException, RuntimeException) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir ::rtl::Reference< SettingsImport > pNewState; 332cdf0e10cSrcweir 333cdf0e10cSrcweir if ( m_aStates.empty() ) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir if ( i_Name.equalsAscii( "office:settings" ) ) 336cdf0e10cSrcweir { 337cdf0e10cSrcweir pNewState = new OfficeSettingsImport( m_aSettings ); 338cdf0e10cSrcweir } 339cdf0e10cSrcweir else 340cdf0e10cSrcweir { 341cdf0e10cSrcweir OSL_ENSURE( false, "SettingsDocumentHandler::startElement: invalid settings file!" ); 342cdf0e10cSrcweir // Yes, that's not correct. Somebody could, in theory, give us a document which starts with "foo:settings", 343cdf0e10cSrcweir // where "foo" is mapped to the proper namespace URL. 344cdf0e10cSrcweir // However, there's no need to bother with this. The "recovery" sub storage we're recovering from is 345cdf0e10cSrcweir // not part of ODF, so we can impose any format restrictions on it ... 346cdf0e10cSrcweir } 347cdf0e10cSrcweir } 348cdf0e10cSrcweir else 349cdf0e10cSrcweir { 350cdf0e10cSrcweir ::rtl::Reference< SettingsImport > pCurrentState( m_aStates.top() ); 351cdf0e10cSrcweir pNewState = pCurrentState->nextState( i_Name ); 352cdf0e10cSrcweir } 353cdf0e10cSrcweir 354cdf0e10cSrcweir ENSURE_OR_THROW( pNewState.is(), "no new state - aborting import" ); 355cdf0e10cSrcweir pNewState->startElement( i_Attribs ); 356cdf0e10cSrcweir 357cdf0e10cSrcweir m_aStates.push( pNewState ); 358cdf0e10cSrcweir } 359cdf0e10cSrcweir 360cdf0e10cSrcweir //-------------------------------------------------------------------- endElement(const::rtl::OUString & i_Name)361cdf0e10cSrcweir void SAL_CALL SettingsDocumentHandler::endElement( const ::rtl::OUString& i_Name ) throw (SAXException, RuntimeException) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir ENSURE_OR_THROW( !m_aStates.empty(), "no active element" ); 364cdf0e10cSrcweir (void)i_Name; 365cdf0e10cSrcweir 366cdf0e10cSrcweir ::rtl::Reference< SettingsImport > pCurrentState( m_aStates.top() ); 367cdf0e10cSrcweir pCurrentState->endElement(); 368cdf0e10cSrcweir m_aStates.pop(); 369cdf0e10cSrcweir } 370cdf0e10cSrcweir 371cdf0e10cSrcweir //-------------------------------------------------------------------- characters(const::rtl::OUString & i_Chars)372cdf0e10cSrcweir void SAL_CALL SettingsDocumentHandler::characters( const ::rtl::OUString& i_Chars ) throw (SAXException, RuntimeException) 373cdf0e10cSrcweir { 374cdf0e10cSrcweir ENSURE_OR_THROW( !m_aStates.empty(), "no active element" ); 375cdf0e10cSrcweir 376cdf0e10cSrcweir ::rtl::Reference< SettingsImport > pCurrentState( m_aStates.top() ); 377cdf0e10cSrcweir pCurrentState->characters( i_Chars ); 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir //-------------------------------------------------------------------- ignorableWhitespace(const::rtl::OUString & aWhitespaces)381cdf0e10cSrcweir void SAL_CALL SettingsDocumentHandler::ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (SAXException, RuntimeException) 382cdf0e10cSrcweir { 383cdf0e10cSrcweir // ignore them - that's why they're called "ignorable" 384cdf0e10cSrcweir (void)aWhitespaces; 385cdf0e10cSrcweir } 386cdf0e10cSrcweir 387cdf0e10cSrcweir //-------------------------------------------------------------------- processingInstruction(const::rtl::OUString & i_Target,const::rtl::OUString & i_Data)388cdf0e10cSrcweir void SAL_CALL SettingsDocumentHandler::processingInstruction( const ::rtl::OUString& i_Target, const ::rtl::OUString& i_Data ) throw (SAXException, RuntimeException) 389cdf0e10cSrcweir { 390cdf0e10cSrcweir OSL_ENSURE( false, "SettingsDocumentHandler::processingInstruction: unexpected ..." ); 391cdf0e10cSrcweir (void)i_Target; 392cdf0e10cSrcweir (void)i_Data; 393cdf0e10cSrcweir } 394cdf0e10cSrcweir 395cdf0e10cSrcweir //-------------------------------------------------------------------- setDocumentLocator(const Reference<XLocator> & i_Locator)396cdf0e10cSrcweir void SAL_CALL SettingsDocumentHandler::setDocumentLocator( const Reference< XLocator >& i_Locator ) throw (SAXException, RuntimeException) 397cdf0e10cSrcweir { 398cdf0e10cSrcweir (void)i_Locator; 399cdf0e10cSrcweir } 400cdf0e10cSrcweir 401cdf0e10cSrcweir //==================================================================== 402cdf0e10cSrcweir //= SubComponentRecovery 403cdf0e10cSrcweir //==================================================================== 404cdf0e10cSrcweir //-------------------------------------------------------------------- getComponentsStorageName(const SubComponentType i_eType)405cdf0e10cSrcweir const ::rtl::OUString SubComponentRecovery::getComponentsStorageName( const SubComponentType i_eType ) 406cdf0e10cSrcweir { 407cdf0e10cSrcweir static const ::rtl::OUString s_sFormsStorageName( RTL_CONSTASCII_USTRINGPARAM( "forms" ) ); 408cdf0e10cSrcweir static const ::rtl::OUString s_sReportsStorageName( RTL_CONSTASCII_USTRINGPARAM( "reports" ) ); 409cdf0e10cSrcweir static const ::rtl::OUString s_sTablesStorageName( RTL_CONSTASCII_USTRINGPARAM( "tables" ) ); 410cdf0e10cSrcweir static const ::rtl::OUString s_sQueriesStorageName( RTL_CONSTASCII_USTRINGPARAM( "queries" ) ); 411cdf0e10cSrcweir static const ::rtl::OUString s_sRelationsStorageName( RTL_CONSTASCII_USTRINGPARAM( "relations" ) ); 412cdf0e10cSrcweir 413cdf0e10cSrcweir switch ( i_eType ) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir case FORM: 416cdf0e10cSrcweir return s_sFormsStorageName; 417cdf0e10cSrcweir case REPORT: 418cdf0e10cSrcweir return s_sReportsStorageName; 419cdf0e10cSrcweir case TABLE: 420cdf0e10cSrcweir return s_sTablesStorageName; 421cdf0e10cSrcweir case QUERY: 422cdf0e10cSrcweir return s_sQueriesStorageName; 423cdf0e10cSrcweir case RELATION_DESIGN: 424cdf0e10cSrcweir return s_sRelationsStorageName; 425cdf0e10cSrcweir default: 426cdf0e10cSrcweir break; 427cdf0e10cSrcweir } 428cdf0e10cSrcweir 429cdf0e10cSrcweir OSL_ENSURE( false, "SubComponentRecovery::getComponentsStorageName: unimplemented case!" ); 430cdf0e10cSrcweir static const ::rtl::OUString s_sFallback; 431cdf0e10cSrcweir return s_sFallback; 432cdf0e10cSrcweir } 433cdf0e10cSrcweir 434cdf0e10cSrcweir //-------------------------------------------------------------------- saveToRecoveryStorage(const Reference<XStorage> & i_rRecoveryStorage,MapCompTypeToCompDescs & io_mapCompDescs)435cdf0e10cSrcweir void SubComponentRecovery::saveToRecoveryStorage( const Reference< XStorage >& i_rRecoveryStorage, 436cdf0e10cSrcweir MapCompTypeToCompDescs& io_mapCompDescs ) 437cdf0e10cSrcweir { 438cdf0e10cSrcweir if ( m_eType == UNKNOWN ) 439cdf0e10cSrcweir // quite fatal, but has already been reported (as assertion) before 440cdf0e10cSrcweir return; 441cdf0e10cSrcweir 442cdf0e10cSrcweir // open the sub storage for the given kind of components 443cdf0e10cSrcweir const ::rtl::OUString& rStorageName( getComponentsStorageName( m_eType ) ); 444cdf0e10cSrcweir const Reference< XStorage > xComponentsStorage( i_rRecoveryStorage->openStorageElement( 445cdf0e10cSrcweir rStorageName, ElementModes::READWRITE ), UNO_QUERY_THROW ); 446cdf0e10cSrcweir 447cdf0e10cSrcweir // find a free sub storage name, and create Yet Another Sub Storage 448cdf0e10cSrcweir const ::rtl::OUString& rBaseName( lcl_getComponentStorageBaseName( m_eType ) ); 449cdf0e10cSrcweir const ::rtl::OUString sStorName = ::dbtools::createUniqueName( xComponentsStorage.get(), rBaseName, true ); 450cdf0e10cSrcweir const Reference< XStorage > xObjectStor( xComponentsStorage->openStorageElement( 451cdf0e10cSrcweir sStorName, ElementModes::READWRITE ), UNO_QUERY_THROW ); 452cdf0e10cSrcweir 453cdf0e10cSrcweir switch ( m_eType ) 454cdf0e10cSrcweir { 455cdf0e10cSrcweir case FORM: 456cdf0e10cSrcweir case REPORT: 457cdf0e10cSrcweir impl_saveSubDocument_throw( xObjectStor ); 458cdf0e10cSrcweir break; 459cdf0e10cSrcweir 460cdf0e10cSrcweir case QUERY: 461cdf0e10cSrcweir impl_saveQueryDesign_throw( xObjectStor ); 462cdf0e10cSrcweir break; 463cdf0e10cSrcweir 464cdf0e10cSrcweir default: 465cdf0e10cSrcweir // TODO 466cdf0e10cSrcweir OSL_ENSURE( false, "SubComponentRecoverys::saveToRecoveryStorage: unimplemented case!" ); 467cdf0e10cSrcweir break; 468cdf0e10cSrcweir } 469cdf0e10cSrcweir 470cdf0e10cSrcweir // commit the storage(s) 471cdf0e10cSrcweir tools::stor::commitStorageIfWriteable( xObjectStor ); 472cdf0e10cSrcweir tools::stor::commitStorageIfWriteable( xComponentsStorage ); 473cdf0e10cSrcweir 474cdf0e10cSrcweir // remember the relationship from the component name to the storage name 475cdf0e10cSrcweir MapStringToCompDesc& rMapCompDescs = io_mapCompDescs[ m_eType ]; 476cdf0e10cSrcweir OSL_ENSURE( rMapCompDescs.find( sStorName ) == rMapCompDescs.end(), 477cdf0e10cSrcweir "SubComponentRecoverys::saveToRecoveryStorage: object name already used!" ); 478cdf0e10cSrcweir rMapCompDescs[ sStorName ] = m_aCompDesc; 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir //-------------------------------------------------------------------- impl_identifyComponent_throw()482cdf0e10cSrcweir void SubComponentRecovery::impl_identifyComponent_throw() 483cdf0e10cSrcweir { 484cdf0e10cSrcweir // ask the controller 485cdf0e10cSrcweir Pair< sal_Int32, ::rtl::OUString > aComponentIdentity = m_xDocumentUI->identifySubComponent( m_xComponent ); 486cdf0e10cSrcweir m_eType = lcl_databaseObjectToSubComponentType( aComponentIdentity.First ); 487cdf0e10cSrcweir m_aCompDesc.sName = aComponentIdentity.Second; 488cdf0e10cSrcweir 489cdf0e10cSrcweir // what the controller didn't give us is the information whether this is in edit mode or not ... 490cdf0e10cSrcweir Reference< XModuleManager > xModuleManager( m_rContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW ); 491cdf0e10cSrcweir const ::rtl::OUString sModuleIdentifier = xModuleManager->identify( m_xComponent ); 492cdf0e10cSrcweir 493cdf0e10cSrcweir switch ( m_eType ) 494cdf0e10cSrcweir { 495cdf0e10cSrcweir case TABLE: 496cdf0e10cSrcweir m_aCompDesc.bForEditing = sModuleIdentifier.equalsAscii( "com.sun.star.sdb.TableDesign" ); 497cdf0e10cSrcweir break; 498cdf0e10cSrcweir 499cdf0e10cSrcweir case QUERY: 500cdf0e10cSrcweir m_aCompDesc.bForEditing = sModuleIdentifier.equalsAscii( "com.sun.star.sdb.QueryDesign" ); 501cdf0e10cSrcweir break; 502cdf0e10cSrcweir 503cdf0e10cSrcweir case REPORT: 504cdf0e10cSrcweir if ( sModuleIdentifier.equalsAscii( "com.sun.star.report.ReportDefinition" ) ) 505cdf0e10cSrcweir { 506cdf0e10cSrcweir // it's an SRB report desginer 507cdf0e10cSrcweir m_aCompDesc.bForEditing = true; 508cdf0e10cSrcweir break; 509cdf0e10cSrcweir } 510cdf0e10cSrcweir // fall through 511cdf0e10cSrcweir 512cdf0e10cSrcweir case FORM: 513cdf0e10cSrcweir m_aCompDesc.bForEditing = !lcl_determineReadOnly( m_xComponent ); 514cdf0e10cSrcweir break; 515cdf0e10cSrcweir 516cdf0e10cSrcweir default: 517cdf0e10cSrcweir if ( sModuleIdentifier.equalsAscii( "com.sun.star.sdb.RelationDesign" ) ) 518cdf0e10cSrcweir { 519cdf0e10cSrcweir m_eType = RELATION_DESIGN; 520cdf0e10cSrcweir m_aCompDesc.bForEditing = true; 521cdf0e10cSrcweir } 522cdf0e10cSrcweir else 523cdf0e10cSrcweir { 524cdf0e10cSrcweir OSL_ENSURE( false, "SubComponentRecovery::impl_identifyComponent_throw: couldn't classify the given sub component!" ); 525cdf0e10cSrcweir } 526cdf0e10cSrcweir break; 527cdf0e10cSrcweir } 528cdf0e10cSrcweir 529cdf0e10cSrcweir OSL_POSTCOND( m_eType != UNKNOWN, 530cdf0e10cSrcweir "SubComponentRecovery::impl_identifyComponent_throw: couldn't classify the component!" ); 531cdf0e10cSrcweir } 532cdf0e10cSrcweir 533cdf0e10cSrcweir //-------------------------------------------------------------------- impl_saveQueryDesign_throw(const Reference<XStorage> & i_rObjectStorage)534cdf0e10cSrcweir void SubComponentRecovery::impl_saveQueryDesign_throw( const Reference< XStorage >& i_rObjectStorage ) 535cdf0e10cSrcweir { 536cdf0e10cSrcweir ENSURE_OR_THROW( m_eType == QUERY, "illegal sub component type" ); 537cdf0e10cSrcweir ENSURE_OR_THROW( i_rObjectStorage.is(), "illegal storage" ); 538cdf0e10cSrcweir 539cdf0e10cSrcweir // retrieve the current query design (which might differ from what we can retrieve as ActiveCommand property, since 540cdf0e10cSrcweir // the latter is updated only upon successful save of the design) 541cdf0e10cSrcweir Reference< XPropertySet > xDesignerProps( m_xComponent, UNO_QUERY_THROW ); 542cdf0e10cSrcweir Sequence< PropertyValue > aCurrentQueryDesign; 543cdf0e10cSrcweir OSL_VERIFY( xDesignerProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CurrentQueryDesign" ) ) ) >>= aCurrentQueryDesign ); 544cdf0e10cSrcweir 545cdf0e10cSrcweir // write the query design 546cdf0e10cSrcweir StorageXMLOutputStream aDesignOutput( m_rContext, i_rObjectStorage, lcl_getSettingsStreamName() ); 547cdf0e10cSrcweir SettingsExportContext aSettingsExportContext( m_rContext, aDesignOutput ); 548cdf0e10cSrcweir 549cdf0e10cSrcweir const ::rtl::OUString sWhitespace( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " " ) ) ); 550cdf0e10cSrcweir 551cdf0e10cSrcweir aDesignOutput.startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "office:settings" ) ) ); 552cdf0e10cSrcweir aDesignOutput.ignorableWhitespace( sWhitespace ); 553cdf0e10cSrcweir 554cdf0e10cSrcweir XMLSettingsExportHelper aSettingsExporter( aSettingsExportContext ); 555cdf0e10cSrcweir aSettingsExporter.exportAllSettings( aCurrentQueryDesign, lcl_getCurrentQueryDesignName() ); 556cdf0e10cSrcweir 557cdf0e10cSrcweir aDesignOutput.ignorableWhitespace( sWhitespace ); 558cdf0e10cSrcweir aDesignOutput.endElement(); 559cdf0e10cSrcweir aDesignOutput.close(); 560cdf0e10cSrcweir } 561cdf0e10cSrcweir 562cdf0e10cSrcweir //-------------------------------------------------------------------- impl_saveSubDocument_throw(const Reference<XStorage> & i_rObjectStorage)563cdf0e10cSrcweir void SubComponentRecovery::impl_saveSubDocument_throw( const Reference< XStorage >& i_rObjectStorage ) 564cdf0e10cSrcweir { 565cdf0e10cSrcweir ENSURE_OR_THROW( ( m_eType == FORM ) || ( m_eType == REPORT ), "illegal sub component type" ); 566cdf0e10cSrcweir ENSURE_OR_THROW( i_rObjectStorage.is(), "illegal storage" ); 567cdf0e10cSrcweir 568cdf0e10cSrcweir // store the document into the storage 569cdf0e10cSrcweir Reference< XStorageBasedDocument > xStorageDocument( m_xComponent, UNO_QUERY_THROW ); 570cdf0e10cSrcweir xStorageDocument->storeToStorage( i_rObjectStorage, Sequence< PropertyValue >() ); 571cdf0e10cSrcweir } 572cdf0e10cSrcweir 573cdf0e10cSrcweir //-------------------------------------------------------------------- impl_recoverSubDocument_throw(const Reference<XStorage> & i_rRecoveryStorage,const::rtl::OUString & i_rComponentName,const bool i_bForEditing)574cdf0e10cSrcweir Reference< XComponent > SubComponentRecovery::impl_recoverSubDocument_throw( const Reference< XStorage >& i_rRecoveryStorage, 575cdf0e10cSrcweir const ::rtl::OUString& i_rComponentName, const bool i_bForEditing ) 576cdf0e10cSrcweir { 577cdf0e10cSrcweir Reference< XComponent > xSubComponent; 578cdf0e10cSrcweir Reference< XCommandProcessor > xDocDefinition; 579cdf0e10cSrcweir 580cdf0e10cSrcweir ::comphelper::NamedValueCollection aLoadArgs; 581cdf0e10cSrcweir aLoadArgs.put( "RecoveryStorage", i_rRecoveryStorage ); 582cdf0e10cSrcweir 583cdf0e10cSrcweir // load/create the sub component hidden. We'll show it when the main app window is shown. 584cdf0e10cSrcweir aLoadArgs.put( "Hidden", true ); 585cdf0e10cSrcweir 586cdf0e10cSrcweir if ( i_rComponentName.getLength() ) 587cdf0e10cSrcweir { 588cdf0e10cSrcweir xDocDefinition = lcl_getSubComponentDef_nothrow( m_xDocumentUI, m_eType, i_rComponentName ); 589cdf0e10cSrcweir xSubComponent.set( m_xDocumentUI->loadComponentWithArguments( 590cdf0e10cSrcweir m_eType, 591cdf0e10cSrcweir i_rComponentName, 592cdf0e10cSrcweir i_bForEditing, 593cdf0e10cSrcweir aLoadArgs.getPropertyValues() 594cdf0e10cSrcweir ), 595cdf0e10cSrcweir UNO_SET_THROW 596cdf0e10cSrcweir ); 597cdf0e10cSrcweir } 598cdf0e10cSrcweir else 599cdf0e10cSrcweir { 600cdf0e10cSrcweir Reference< XComponent > xDocDefComponent; 601cdf0e10cSrcweir xSubComponent.set( m_xDocumentUI->createComponentWithArguments( 602cdf0e10cSrcweir m_eType, 603cdf0e10cSrcweir aLoadArgs.getPropertyValues(), 604cdf0e10cSrcweir xDocDefComponent 605cdf0e10cSrcweir ), 606cdf0e10cSrcweir UNO_SET_THROW 607cdf0e10cSrcweir ); 608cdf0e10cSrcweir 609cdf0e10cSrcweir xDocDefinition.set( xDocDefComponent, UNO_QUERY ); 610cdf0e10cSrcweir OSL_ENSURE( xDocDefinition.is(), "DatabaseDocumentRecovery::recoverSubDocuments: loaded a form/report, but don't have a document definition?!" ); 611cdf0e10cSrcweir } 612cdf0e10cSrcweir 613cdf0e10cSrcweir if ( xDocDefinition.is() ) 614cdf0e10cSrcweir { 615cdf0e10cSrcweir Reference< XController > xController( m_xDocumentUI, UNO_QUERY_THROW ); 616cdf0e10cSrcweir Reference< XInterface > xLoader( *new SubComponentLoader( xController, xDocDefinition ) ); 617cdf0e10cSrcweir (void)xLoader; 618cdf0e10cSrcweir } 619cdf0e10cSrcweir 620cdf0e10cSrcweir return xSubComponent; 621cdf0e10cSrcweir } 622cdf0e10cSrcweir 623cdf0e10cSrcweir //-------------------------------------------------------------------- impl_recoverQueryDesign_throw(const Reference<XStorage> & i_rRecoveryStorage,const::rtl::OUString & i_rComponentName,const bool i_bForEditing)624cdf0e10cSrcweir Reference< XComponent > SubComponentRecovery::impl_recoverQueryDesign_throw( const Reference< XStorage >& i_rRecoveryStorage, 625cdf0e10cSrcweir const ::rtl::OUString& i_rComponentName, const bool i_bForEditing ) 626cdf0e10cSrcweir { 627cdf0e10cSrcweir Reference< XComponent > xSubComponent; 628cdf0e10cSrcweir 629cdf0e10cSrcweir // first read the settings query design settings from the storage 630cdf0e10cSrcweir StorageXMLInputStream aDesignInput( m_rContext, i_rRecoveryStorage, lcl_getSettingsStreamName() ); 631cdf0e10cSrcweir 632cdf0e10cSrcweir ::rtl::Reference< SettingsDocumentHandler > pDocHandler( new SettingsDocumentHandler ); 633cdf0e10cSrcweir aDesignInput.import( pDocHandler.get() ); 634cdf0e10cSrcweir 635cdf0e10cSrcweir const ::comphelper::NamedValueCollection& rSettings( pDocHandler->getSettings() ); 636cdf0e10cSrcweir const Any aCurrentQueryDesign = rSettings.get( lcl_getCurrentQueryDesignName() ); 637cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 638cdf0e10cSrcweir Sequence< PropertyValue > aQueryDesignLayout; 639cdf0e10cSrcweir OSL_VERIFY( aCurrentQueryDesign >>= aQueryDesignLayout ); 640cdf0e10cSrcweir #endif 641cdf0e10cSrcweir 642cdf0e10cSrcweir // then load the query designer 643cdf0e10cSrcweir ::comphelper::NamedValueCollection aLoadArgs; 644cdf0e10cSrcweir aLoadArgs.put( "CurrentQueryDesign", aCurrentQueryDesign ); 645cdf0e10cSrcweir aLoadArgs.put( "Hidden", true ); 646cdf0e10cSrcweir 647cdf0e10cSrcweir if ( i_rComponentName.getLength() ) 648cdf0e10cSrcweir { 649cdf0e10cSrcweir xSubComponent.set( m_xDocumentUI->loadComponentWithArguments( 650cdf0e10cSrcweir m_eType, 651cdf0e10cSrcweir i_rComponentName, 652cdf0e10cSrcweir i_bForEditing, 653cdf0e10cSrcweir aLoadArgs.getPropertyValues() 654cdf0e10cSrcweir ), 655cdf0e10cSrcweir UNO_SET_THROW 656cdf0e10cSrcweir ); 657cdf0e10cSrcweir } 658cdf0e10cSrcweir else 659cdf0e10cSrcweir { 660cdf0e10cSrcweir Reference< XComponent > xDummy; 661cdf0e10cSrcweir xSubComponent.set( m_xDocumentUI->createComponentWithArguments( 662cdf0e10cSrcweir m_eType, 663cdf0e10cSrcweir aLoadArgs.getPropertyValues(), 664cdf0e10cSrcweir xDummy 665cdf0e10cSrcweir ), 666cdf0e10cSrcweir UNO_SET_THROW 667cdf0e10cSrcweir ); 668cdf0e10cSrcweir } 669cdf0e10cSrcweir 670cdf0e10cSrcweir Reference< XController > xController( m_xDocumentUI, UNO_QUERY_THROW ); 671cdf0e10cSrcweir Reference< XInterface > xLoader( *new SubComponentLoader( xController, xSubComponent ) ); 672cdf0e10cSrcweir (void)xLoader; 673cdf0e10cSrcweir 674cdf0e10cSrcweir return xSubComponent; 675cdf0e10cSrcweir } 676cdf0e10cSrcweir 677cdf0e10cSrcweir //-------------------------------------------------------------------- recoverFromStorage(const Reference<XStorage> & i_rRecoveryStorage,const::rtl::OUString & i_rComponentName,const bool i_bForEditing)678cdf0e10cSrcweir Reference< XComponent > SubComponentRecovery::recoverFromStorage( const Reference< XStorage >& i_rRecoveryStorage, 679cdf0e10cSrcweir const ::rtl::OUString& i_rComponentName, const bool i_bForEditing ) 680cdf0e10cSrcweir { 681cdf0e10cSrcweir Reference< XComponent > xSubComponent; 682cdf0e10cSrcweir switch ( m_eType ) 683cdf0e10cSrcweir { 684cdf0e10cSrcweir case FORM: 685cdf0e10cSrcweir case REPORT: 686cdf0e10cSrcweir xSubComponent = impl_recoverSubDocument_throw( i_rRecoveryStorage, i_rComponentName, i_bForEditing ); 687cdf0e10cSrcweir break; 688cdf0e10cSrcweir case QUERY: 689cdf0e10cSrcweir xSubComponent = impl_recoverQueryDesign_throw( i_rRecoveryStorage, i_rComponentName, i_bForEditing ); 690cdf0e10cSrcweir break; 691cdf0e10cSrcweir default: 692cdf0e10cSrcweir OSL_ENSURE( false, "SubComponentRecovery::recoverFromStorage: unimplemented case!" ); 693cdf0e10cSrcweir break; 694cdf0e10cSrcweir } 695cdf0e10cSrcweir return xSubComponent; 696cdf0e10cSrcweir } 697cdf0e10cSrcweir 698cdf0e10cSrcweir //........................................................................ 699cdf0e10cSrcweir } // namespace dbaccess 700cdf0e10cSrcweir //........................................................................ 701