diff options
Diffstat (limited to 'dbaccess/source/core/dataaccess/databasedocument.cxx')
-rw-r--r-- | dbaccess/source/core/dataaccess/databasedocument.cxx | 122 |
1 files changed, 52 insertions, 70 deletions
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index 4fce39de0b35..204bad556e5d 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -73,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> @@ -197,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 @@ -306,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 @@ -434,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}, }; } @@ -452,8 +435,8 @@ 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); @@ -776,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 @@ -1030,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(); } @@ -1090,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& ) @@ -1105,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 ); @@ -1252,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(); } @@ -1284,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 @@ -1414,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; @@ -1431,7 +1414,7 @@ Reference< XNameAccess > ODatabaseDocument::impl_getDocumentContainer_throw( ODa aValue >>= sSupportService; if ( !sSupportService.isEmpty() ) { - Sequence<Any> aArgs{ Any(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); @@ -1550,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, @@ -1582,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 ); @@ -1629,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; @@ -1653,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.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 = @@ -1680,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&) { @@ -1693,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 ); @@ -1870,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 ) @@ -1912,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} }; } @@ -1921,10 +1908,9 @@ 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{ Any(xInfoSet) }; @@ -2039,7 +2025,7 @@ struct CreateAny { Any operator() (const Reference<XController>& lhs) const { - return makeAny(lhs); + return Any(lhs); } }; @@ -2108,13 +2094,9 @@ 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); @@ -2203,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()); |