diff options
Diffstat (limited to 'dbaccess/source/core/dataaccess/databasedocument.cxx')
-rw-r--r-- | dbaccess/source/core/dataaccess/databasedocument.cxx | 167 |
1 files changed, 76 insertions, 91 deletions
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index c38dc9429cfc..204bad556e5d 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -24,9 +24,11 @@ #include <databasecontext.hxx> #include "documentcontainer.hxx" #include <sdbcoretools.hxx> +#include <strings.hxx> #include <recovery/dbdocrecovery.hxx> #include <officecfg/Office/Common.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/document/XExporter.hpp> #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/document/XImporter.hpp> @@ -71,7 +73,7 @@ #include <cppuhelper/supportsservice.hxx> #include <framework/titlehelper.hxx> #include <unotools/saveopt.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> #include <vcl/GraphicObject.hxx> @@ -195,28 +197,12 @@ Any SAL_CALL ODatabaseDocument::queryInterface( const Type& _rType ) ) return Any(); - Any aReturn = ODatabaseDocument_OfficeDocument::queryInterface(_rType); - if (!aReturn.hasValue()) - aReturn = ODatabaseDocument_Title::queryInterface(_rType); - return aReturn; -} - -void SAL_CALL ODatabaseDocument::acquire( ) noexcept -{ - ODatabaseDocument_OfficeDocument::acquire(); -} - -void SAL_CALL ODatabaseDocument::release( ) noexcept -{ - ODatabaseDocument_OfficeDocument::release(); + return ODatabaseDocument_OfficeDocument::queryInterface(_rType); } Sequence< Type > SAL_CALL ODatabaseDocument::getTypes( ) { - Sequence< Type > aTypes = ::comphelper::concatSequences( - ODatabaseDocument_OfficeDocument::getTypes(), - ODatabaseDocument_Title::getTypes() - ); + Sequence< Type > aTypes = ODatabaseDocument_OfficeDocument::getTypes(); // strip XEmbeddedScripts and XScriptInvocationContext if we have any form/report // which already contains macros. In this case, the database document itself is not @@ -278,7 +264,7 @@ namespace sal_Int32 nLength = _rCallArgs.getLength(); _rCallArgs.realloc( nLength + 1 ); - _rCallArgs[ nLength ] <<= xStatusIndicator; + _rCallArgs.getArray()[ nLength ] <<= xStatusIndicator; } void lcl_extractAndStartStatusIndicator( const ::comphelper::NamedValueCollection& _rArguments, Reference< XStatusIndicator >& _rxStatusIndicator, @@ -294,7 +280,7 @@ namespace sal_Int32 nLength = _rCallArgs.getLength(); _rCallArgs.realloc( nLength + 1 ); - _rCallArgs[ nLength ] <<= _rxStatusIndicator; + _rCallArgs.getArray()[ nLength ] <<= _rxStatusIndicator; } catch( const Exception& ) { @@ -304,17 +290,17 @@ namespace Sequence< PropertyValue > lcl_appendFileNameToDescriptor( const ::comphelper::NamedValueCollection& _rDescriptor, const OUString& _rURL ) { + if ( _rURL.isEmpty() ) + return _rDescriptor.getPropertyValues(); + ::comphelper::NamedValueCollection aMutableDescriptor( _rDescriptor ); - if ( !_rURL.isEmpty() ) - { - aMutableDescriptor.put( "FileName", _rURL ); - aMutableDescriptor.put( "URL", _rURL ); - } + aMutableDescriptor.put( "FileName", _rURL ); + aMutableDescriptor.put( "URL", _rURL ); return aMutableDescriptor.getPropertyValues(); } } -constexpr OUStringLiteral sPictures = u"Pictures"; +constexpr OUString sPictures = u"Pictures"_ustr; // base documents seem to have a different behaviour to other documents, the // root storage contents at least seem to be re-used over different saves, thus if there is a @@ -432,9 +418,8 @@ namespace { OUString("BaseURI"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 }, { OUString("StreamName"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 }, { OUString("UsePrettyPrinting"), 0, ::cppu::UnoType<sal_Bool>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, - {OUString("TargetStorage"), 0, cppu::UnoType<embed::XStorage>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, - {OUString("StreamRelPath"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, - { OUString(), 0, css::uno::Type(), 0, 0 } + { OUString("TargetStorage"), 0, cppu::UnoType<embed::XStorage>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, + { OUString("StreamRelPath"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, }; } @@ -450,12 +435,12 @@ void ODatabaseDocument::impl_import_nolck_throw( const Reference< XComponentCont if (sBaseURI.isEmpty()) sBaseURI = _rResource.getOrDefault("URL",OUString()); assert(!sBaseURI.isEmpty()); // needed for relative URLs - xInfoSet->setPropertyValue("BaseURI", uno::makeAny(sBaseURI)); - xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("content.xml"))); + xInfoSet->setPropertyValue("BaseURI", uno::Any(sBaseURI)); + xInfoSet->setPropertyValue("StreamName", uno::Any(OUString("content.xml"))); const sal_Int32 nCount = aFilterCreationArgs.getLength(); aFilterCreationArgs.realloc(nCount + 1); - aFilterCreationArgs[nCount] <<= xInfoSet; + aFilterCreationArgs.getArray()[nCount] <<= xInfoSet; Reference< XImporter > xImporter( _rContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.comp.sdb.DBFilter", aFilterCreationArgs, _rContext), @@ -774,7 +759,7 @@ bool ODatabaseDocument::impl_attachResource( const OUString& i_rLogicalDocumentU // determine whether the document as a whole, or sub documents, have macros. Especially the latter // controls the availability of our XEmbeddedScripts and XScriptInvocationContext interfaces, and we // should know this before anybody actually uses the object. - m_bAllowDocumentScripting = ( m_pImpl->determineEmbeddedMacros() != ODatabaseModelImpl::eSubDocumentMacros ); + m_bAllowDocumentScripting = ( m_pImpl->determineEmbeddedMacros() != ODatabaseModelImpl::EmbeddedMacros::SubDocument ); _rDocGuard.clear(); // <- SYNCHRONIZED @@ -796,6 +781,15 @@ Sequence< PropertyValue > SAL_CALL ODatabaseDocument::getArgs( ) return m_pImpl->getMediaDescriptor().getPropertyValues(); } +Sequence< PropertyValue > SAL_CALL ODatabaseDocument::getArgs2( const ::css::uno::Sequence< ::rtl::OUString >& requestedArgs ) +{ + DocumentGuard aGuard( *this, DocumentGuard::MethodWithoutInit ); + std::vector<PropertyValue> aRet; + for (const auto & rArgName : requestedArgs) + aRet.push_back(PropertyValue(rArgName, 0, m_pImpl->getMediaDescriptor().get(rArgName), PropertyState_DIRECT_VALUE)); + return comphelper::containerToSequence(aRet); +} + void SAL_CALL ODatabaseDocument::setArgs(const Sequence<beans::PropertyValue>& /* aArgs */) { throw NoSupportException(); @@ -1019,7 +1013,7 @@ void ODatabaseDocument::impl_storeAs_throw( const OUString& _rURL, const ::comph if ( !bIsInitializationProcess ) { _rGuard.clear(); - m_aEventNotifier.notifyDocumentEvent( _eType == SAVE ? "OnSave" : "OnSaveAs", nullptr, makeAny( _rURL ) ); + m_aEventNotifier.notifyDocumentEvent( _eType == SAVE ? "OnSave" : "OnSaveAs", nullptr, Any( _rURL ) ); _rGuard.reset(); } @@ -1079,13 +1073,13 @@ void ODatabaseDocument::impl_storeAs_throw( const OUString& _rURL, const ::comph catch( const IOException& ) { if ( !bIsInitializationProcess ) - m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", nullptr, makeAny( _rURL ) ); + m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", nullptr, Any( _rURL ) ); throw; } catch( const RuntimeException& ) { if ( !bIsInitializationProcess ) - m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", nullptr, makeAny( _rURL ) ); + m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", nullptr, Any( _rURL ) ); throw; } catch( const Exception& ) @@ -1094,14 +1088,14 @@ void ODatabaseDocument::impl_storeAs_throw( const OUString& _rURL, const ::comph // notify the failure if ( !bIsInitializationProcess ) - m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", nullptr, makeAny( _rURL ) ); + m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", nullptr, Any( _rURL ) ); impl_throwIOExceptionCausedBySave_throw( aError, _rURL ); } // notify the document event if ( !bIsInitializationProcess ) - m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveDone" : "OnSaveAsDone", nullptr, makeAny( _rURL ) ); + m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveDone" : "OnSaveAsDone", nullptr, Any( _rURL ) ); // reset our "modified" flag, and clear the guard impl_setModified_nothrow( false, _rGuard ); @@ -1121,9 +1115,7 @@ Reference< XStorage > ODatabaseDocument::impl_createStorageFor_throw( const OUSt { xTruncate->truncate(); } - Sequence<Any> aParam(2); - aParam[0] <<= xStream; - aParam[1] <<= ElementModes::READWRITE | ElementModes::TRUNCATE; + Sequence<Any> aParam{ Any(xStream), Any(ElementModes::READWRITE | ElementModes::TRUNCATE) }; Reference< XSingleServiceFactory > xStorageFactory( m_pImpl->createStorageFactory(), UNO_SET_THROW ); return Reference< XStorage >( xStorageFactory->createInstanceWithArguments( aParam ), UNO_QUERY_THROW ); @@ -1243,7 +1235,7 @@ void SAL_CALL ODatabaseDocument::storeToURL( const OUString& _rURL, const Sequen { aGuard.clear(); - m_aEventNotifier.notifyDocumentEvent( "OnSaveTo", nullptr, makeAny( _rURL ) ); + m_aEventNotifier.notifyDocumentEvent( "OnSaveTo", nullptr, Any( _rURL ) ); aGuard.reset(); } @@ -1275,7 +1267,7 @@ void SAL_CALL ODatabaseDocument::storeToURL( const OUString& _rURL, const Sequen impl_throwIOExceptionCausedBySave_throw( aError, _rURL ); } - m_aEventNotifier.notifyDocumentEventAsync( "OnSaveToDone", nullptr, makeAny( _rURL ) ); + m_aEventNotifier.notifyDocumentEventAsync( "OnSaveToDone", nullptr, Any( _rURL ) ); } // XModifyBroadcaster @@ -1405,10 +1397,10 @@ void ODatabaseDocument::clearObjectContainer( WeakReference< XNameAccess >& _rxC Reference< XNameAccess > ODatabaseDocument::impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType _eType ) { - if ( ( _eType != ODatabaseModelImpl::E_FORM ) && ( _eType != ODatabaseModelImpl::E_REPORT ) ) + if ( ( _eType != ODatabaseModelImpl::ObjectType::Form ) && ( _eType != ODatabaseModelImpl::ObjectType::Report ) ) throw IllegalArgumentException(); - bool bFormsContainer = _eType == ODatabaseModelImpl::E_FORM; + bool bFormsContainer = _eType == ODatabaseModelImpl::ObjectType::Form; WeakReference< XNameAccess >& rContainerRef( bFormsContainer ? m_xForms : m_xReports ); Reference< XNameAccess > xContainer = rContainerRef; @@ -1422,8 +1414,7 @@ Reference< XNameAccess > ODatabaseDocument::impl_getDocumentContainer_throw( ODa aValue >>= sSupportService; if ( !sSupportService.isEmpty() ) { - Sequence<Any> aArgs(1); - aArgs[0] <<= NamedValue("DatabaseDocument",makeAny(xMy)); + Sequence<Any> aArgs{ Any(NamedValue("DatabaseDocument",Any(xMy))) }; xContainer.set( m_pImpl->m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext(sSupportService, aArgs, m_pImpl->m_aContext), UNO_QUERY); @@ -1500,7 +1491,7 @@ void SAL_CALL ODatabaseDocument::close(sal_Bool bDeliverOwnership) { // allow listeners to veto lang::EventObject aEvent( *this ); - m_aCloseListener.forEach< XCloseListener >( + m_aCloseListener.forEach( [&aEvent, &bDeliverOwnership] (uno::Reference<XCloseListener> const& xListener) { return xListener->queryClosing(aEvent, bDeliverOwnership); }); @@ -1542,13 +1533,13 @@ void SAL_CALL ODatabaseDocument::removeCloseListener( const Reference< css::util Reference< XNameAccess > SAL_CALL ODatabaseDocument::getFormDocuments( ) { DocumentGuard aGuard( *this, DocumentGuard::MethodUsedDuringInit ); - return impl_getDocumentContainer_throw( ODatabaseModelImpl::E_FORM ); + return impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType::Form ); } Reference< XNameAccess > SAL_CALL ODatabaseDocument::getReportDocuments( ) { DocumentGuard aGuard( *this, DocumentGuard::MethodUsedDuringInit ); - return impl_getDocumentContainer_throw( ODatabaseModelImpl::E_REPORT ); + return impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType::Report ); } void ODatabaseDocument::WriteThroughComponent( const Reference< XComponent >& xComponent, const char* pStreamName, @@ -1574,8 +1565,8 @@ void ODatabaseDocument::WriteThroughComponent( const Reference< XComponent >& xC xSeek->seek(0); Reference< XPropertySet > xStreamProp( xOutputStream, UNO_QUERY_THROW ); - xStreamProp->setPropertyValue( INFO_MEDIATYPE, makeAny( OUString( "text/xml" ) ) ); - xStreamProp->setPropertyValue( "Compressed", makeAny( true ) ); + xStreamProp->setPropertyValue( INFO_MEDIATYPE, Any( OUString( "text/xml" ) ) ); + xStreamProp->setPropertyValue( "Compressed", Any( true ) ); // write the stuff WriteThroughComponent( xOutputStream, xComponent, pServiceName, _rArguments, rMediaDesc ); @@ -1597,9 +1588,10 @@ void ODatabaseDocument::WriteThroughComponent( const Reference< XOutputStream >& // prepare arguments (prepend doc handler to given arguments) Sequence<Any> aArgs( 1 + _rArguments.getLength() ); - aArgs[0] <<= xSaxWriter; + auto pArgs = aArgs.getArray(); + pArgs[0] <<= xSaxWriter; for ( sal_Int32 i = 0; i < _rArguments.getLength(); ++i ) - aArgs[ i+1 ] = _rArguments[i]; + pArgs[ i+1 ] = _rArguments[i]; // get filter component Reference< XExporter > xExporter( m_pImpl->m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext(OUString::createFromAscii(pServiceName), aArgs, m_pImpl->m_aContext), UNO_QUERY_THROW ); @@ -1620,17 +1612,17 @@ void ODatabaseDocument::impl_writeStorage_throw( const Reference< XStorage >& _r uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) ); - xInfoSet->setPropertyValue("UsePrettyPrinting", uno::makeAny(officecfg::Office::Common::Save::Document::PrettyPrinting::get())); + xInfoSet->setPropertyValue("UsePrettyPrinting", uno::Any(officecfg::Office::Common::Save::Document::PrettyPrinting::get())); if ( officecfg::Office::Common::Save::URL::FileSystem::get() ) { OUString sBaseURI = _rMediaDescriptor.getOrDefault("BaseURI", OUString()); if (sBaseURI.isEmpty()) sBaseURI = _rMediaDescriptor.getOrDefault("URL",OUString()); - xInfoSet->setPropertyValue("BaseURI", uno::makeAny(sBaseURI)); + xInfoSet->setPropertyValue("BaseURI", uno::Any(sBaseURI)); } // Set TargetStorage, so it doesn't have to be re-constructed based on possibly empty URL. - xInfoSet->setPropertyValue("TargetStorage", uno::makeAny(m_pImpl->getRootStorage())); + xInfoSet->setPropertyValue("TargetStorage", uno::Any(m_pImpl->getRootStorage())); // Set StreamRelPath, in case this document is an embedded one. OUString sStreamRelPath; @@ -1644,14 +1636,14 @@ void ODatabaseDocument::impl_writeStorage_throw( const Reference< XStorage >& _r sStreamRelPath = sStreamRelPath.copy(1); } if (!sStreamRelPath.isEmpty()) - xInfoSet->setPropertyValue("StreamRelPath", uno::makeAny(sStreamRelPath)); + xInfoSet->setPropertyValue("StreamRelPath", uno::Any(sStreamRelPath)); sal_Int32 nArgsLen = aDelegatorArguments.getLength(); aDelegatorArguments.realloc(nArgsLen+1); - aDelegatorArguments[nArgsLen++] <<= xInfoSet; + aDelegatorArguments.getArray()[nArgsLen++] <<= xInfoSet; Reference< XPropertySet > xProp( _rxTargetStorage, UNO_QUERY_THROW ); - xProp->setPropertyValue( INFO_MEDIATYPE, makeAny( OUString(MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII) ) ); + xProp->setPropertyValue( INFO_MEDIATYPE, Any( MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII ) ); OUString aVersion; SvtSaveOptions::ODFSaneDefaultVersion const nDefVersion = @@ -1671,7 +1663,7 @@ void ODatabaseDocument::impl_writeStorage_throw( const Reference< XStorage >& _r { try { - xProp->setPropertyValue("Version" , uno::makeAny(aVersion)); + xProp->setPropertyValue("Version" , uno::Any(aVersion)); } catch (const uno::Exception&) { @@ -1684,11 +1676,11 @@ void ODatabaseDocument::impl_writeStorage_throw( const Reference< XStorage >& _r Sequence< PropertyValue > aMediaDescriptor; _rMediaDescriptor >>= aMediaDescriptor; - xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("settings.xml"))); + xInfoSet->setPropertyValue("StreamName", uno::Any(OUString("settings.xml"))); WriteThroughComponent( xComponent, "settings.xml", "com.sun.star.comp.sdb.XMLSettingsExporter", aDelegatorArguments, aMediaDescriptor, _rxTargetStorage ); - xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("content.xml"))); + xInfoSet->setPropertyValue("StreamName", uno::Any(OUString("content.xml"))); WriteThroughComponent( xComponent, "content.xml", "com.sun.star.comp.sdb.DBExportFilter", aDelegatorArguments, aMediaDescriptor, _rxTargetStorage ); @@ -1769,7 +1761,7 @@ void ODatabaseDocument::impl_notifyStorageChange_nolck_nothrow( const Reference< { Reference< XInterface > xMe( *this ); - m_aStorageListeners.forEach< XStorageChangeListener >( + m_aStorageListeners.forEach( [&xMe, &xNewRootStorage] (uno::Reference<XStorageChangeListener> const& xListener) { return xListener->notifyStorageChange(xMe, xNewRootStorage); }); @@ -1861,6 +1853,11 @@ void ODatabaseDocument::disposing() void SAL_CALL ODatabaseDocument::dispose( ) { ::cppu::WeakComponentImplHelperBase::dispose(); + m_xTitleHelper.clear(); + m_xModuleManager.clear(); + m_pEventExecutor.clear(); + m_xCurrentController.clear(); + m_xUIConfigurationManager.clear(); } void SAL_CALL ODatabaseDocument::addEventListener( const Reference< lang::XEventListener >& _xListener ) @@ -1903,7 +1900,6 @@ comphelper::PropertyMapEntry const aEmbeddedImportInfoMap[] = {OUString("StreamRelPath"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, {OUString("StreamName"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, {OUString("SourceStorage"), 0, cppu::UnoType<embed::XStorage>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, - {OUString(), 0, css::uno::Type(), 0, 0} }; } @@ -1912,13 +1908,11 @@ void SAL_CALL ODatabaseDocument::loadFromStorage(const Reference<XStorage>& xSto DocumentGuard aGuard(*this, DocumentGuard::InitMethod); uno::Reference<beans::XPropertySet> xInfoSet(comphelper::GenericPropertySet_CreateInstance(new comphelper::PropertySetInfo(aEmbeddedImportInfoMap))); - comphelper::NamedValueCollection aDescriptor(rMediaDescriptor); - xInfoSet->setPropertyValue("StreamRelPath", uno::makeAny(aDescriptor.getOrDefault("HierarchicalDocumentName", OUString()))); - xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("content.xml"))); - xInfoSet->setPropertyValue("SourceStorage", uno::makeAny(xStorage)); + xInfoSet->setPropertyValue("StreamRelPath", uno::Any(comphelper::NamedValueCollection::getOrDefault(rMediaDescriptor, u"HierarchicalDocumentName", OUString()))); + xInfoSet->setPropertyValue("StreamName", uno::Any(OUString("content.xml"))); + xInfoSet->setPropertyValue("SourceStorage", uno::Any(xStorage)); - uno::Sequence<uno::Any> aFilterCreationArgs(1); - aFilterCreationArgs[0] <<= xInfoSet; + uno::Sequence<uno::Any> aFilterCreationArgs{ Any(xInfoSet) }; uno::Reference<document::XImporter> xImporter(m_pImpl->m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.comp.sdb.DBFilter", aFilterCreationArgs, m_pImpl->m_aContext), uno::UNO_QUERY_THROW); @@ -2031,7 +2025,7 @@ struct CreateAny { Any operator() (const Reference<XController>& lhs) const { - return makeAny(lhs); + return Any(lhs); } }; @@ -2088,10 +2082,7 @@ Reference< XTitle > const & ODatabaseDocument::impl_getTitleHelper_throw() Reference< XUntitledNumbers > xDesktop(Desktop::create(m_pImpl->m_aContext), uno::UNO_QUERY_THROW); Reference< frame::XModel > xThis (getThis(), uno::UNO_QUERY_THROW); - rtl::Reference<::framework::TitleHelper> pHelper = new ::framework::TitleHelper(m_pImpl->m_aContext); - m_xTitleHelper = pHelper; - pHelper->setOwner (xThis ); - pHelper->connectWithUntitledNumbers (xDesktop); + m_xTitleHelper = new ::framework::TitleHelper(m_pImpl->m_aContext, xThis, xDesktop); } return m_xTitleHelper; @@ -2103,23 +2094,17 @@ uno::Reference< frame::XUntitledNumbers > ODatabaseDocument::impl_getUntitledHel m_xModuleManager.set( ModuleManager::create(m_pImpl->m_aContext) ); OUString sModuleId; - try - { - sModuleId = m_xModuleManager->identify( _xComponent ); - } - catch(const uno::Exception&) - { - } + if (_xComponent.is()) + sModuleId = m_xModuleManager->identify(_xComponent); + uno::Reference< frame::XUntitledNumbers > xNumberedControllers; TNumberedController::const_iterator aFind = m_aNumberedControllers.find(sModuleId); if ( aFind == m_aNumberedControllers.end() ) { - uno::Reference< frame::XModel > xThis(static_cast< frame::XModel* >(this), uno::UNO_QUERY_THROW); rtl::Reference<::comphelper::NumberedCollection> pHelper = new ::comphelper::NumberedCollection(); xNumberedControllers = pHelper; - - pHelper->setOwner (xThis); + pHelper->setOwner(uno::Reference< frame::XModel >(this)); m_aNumberedControllers.emplace( sModuleId,xNumberedControllers ); } @@ -2200,11 +2185,11 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_dba_ODatabaseDocument(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &) { - Reference<XUnoTunnel> xDBContextTunnel(DatabaseContext::create(context), UNO_QUERY_THROW); - dbaccess::ODatabaseContext* pContext - = comphelper::getFromUnoTunnel<dbaccess::ODatabaseContext>(xDBContextTunnel); + Reference<XInterface> xDBContextTunnel(DatabaseContext::create(context), UNO_QUERY_THROW); + rtl::Reference<dbaccess::ODatabaseContext> pContext + = dynamic_cast<dbaccess::ODatabaseContext*>(xDBContextTunnel.get()); assert(pContext); - + rtl::Reference pImpl( new dbaccess::ODatabaseModelImpl(context, *pContext)); css::uno::Reference<XInterface> inst(pImpl->createNewModel_deliverOwnership()); |