summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-09-20 15:23:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-09-24 08:18:18 +0200
commit5ceff2c65cc2ae80a11a1787400ca22dea9c3500 (patch)
tree72825c237f1f9c74594980c867fef4ed71f387d8
parentc2017f839162a5236afcd73636ecfa73349b9ea9 (diff)
use more concrete UNO types in dbaccess
Change-Id: If34294e2db4dc3365a7308c90658d5fa0c0e6532 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173817 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--dbaccess/source/core/dataaccess/ModelImpl.cxx32
-rw-r--r--dbaccess/source/core/dataaccess/databasecontext.cxx12
-rw-r--r--dbaccess/source/core/dataaccess/databasedocument.cxx4
-rw-r--r--dbaccess/source/core/dataaccess/documentdefinition.cxx9
-rw-r--r--dbaccess/source/core/inc/ModelImpl.hxx7
5 files changed, 35 insertions, 29 deletions
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx
index 7c566fc8286d..49503a9d7b56 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -631,15 +631,19 @@ void ODatabaseModelImpl::dispose()
m_xDataSource.clear();
}
- Reference< XModel > xModel( m_xModel );
- ::comphelper::disposeComponent( xModel );
+ rtl::Reference< ODatabaseDocument > xModel( m_xModel );
+ if (xModel)
+ {
+ xModel->dispose();
+ m_xModel.clear();
+ }
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("dbaccess");
}
m_xDataSource.clear();
- m_xModel = WeakReference< XModel >();
+ m_xModel.clear();
for (auto const& elem : m_aContainer)
{
@@ -932,7 +936,7 @@ void ODatabaseModelImpl::setModified( bool _bModified )
try
{
- Reference< XModifiable > xModi( m_xModel.get(), UNO_QUERY );
+ rtl::Reference< ODatabaseDocument > xModi( m_xModel );
if ( xModi.is() )
xModi->setModified( _bModified );
else
@@ -955,26 +959,26 @@ Reference<XDataSource> ODatabaseModelImpl::getOrCreateDataSource()
return xDs;
}
-Reference< XModel> ODatabaseModelImpl::getModel_noCreate() const
+rtl::Reference<ODatabaseDocument> ODatabaseModelImpl::getModel_noCreate() const
{
- return m_xModel;
+ return m_xModel.get();
}
-Reference< XModel > ODatabaseModelImpl::createNewModel_deliverOwnership()
+rtl::Reference< ODatabaseDocument > ODatabaseModelImpl::createNewModel_deliverOwnership()
{
- Reference< XModel > xModel( m_xModel );
+ rtl::Reference< ODatabaseDocument > xModel( m_xModel );
OSL_PRECOND( !xModel.is(), "ODatabaseModelImpl::createNewModel_deliverOwnership: not to be called if there already is a model!" );
if ( !xModel.is() )
{
bool bHadModelBefore = m_bDocumentInitialized;
xModel = ODatabaseDocument::createDatabaseDocument( this, ODatabaseDocument::FactoryAccess() );
- m_xModel = xModel;
+ m_xModel = xModel.get();
try
{
Reference< XGlobalEventBroadcaster > xModelCollection = theGlobalEventBroadcaster::get( m_aContext );
- xModelCollection->insert( Any( xModel ) );
+ xModelCollection->insert( Any( Reference< XModel >(xModel) ) );
}
catch( const Exception& )
{
@@ -1134,7 +1138,9 @@ Reference< XStorageBasedLibraryContainer > ODatabaseModelImpl::getLibraryContain
if ( rxContainer.is() )
return rxContainer;
- Reference< XStorageBasedDocument > xDocument( getModel_noCreate(), UNO_QUERY_THROW );
+ rtl::Reference< ODatabaseDocument > xDocument( getModel_noCreate() );
+ if (!xDocument)
+ throw uno::RuntimeException();
// this is only to be called if there already exists a document model - in fact, it is
// to be called by the document model only
@@ -1156,7 +1162,7 @@ Reference< XStorageBasedLibraryContainer > ODatabaseModelImpl::getLibraryContain
{
throw WrappedTargetRuntimeException(
OUString(),
- xDocument,
+ cppu::getXWeak(xDocument.get()),
::cppu::getCaughtException()
);
}
@@ -1347,7 +1353,7 @@ bool ODatabaseModelImpl::macroCallsSeenWhileLoading() const
Reference< XEmbeddedScripts > ODatabaseModelImpl::getEmbeddedDocumentScripts() const
{
- return Reference< XEmbeddedScripts >( getModel_noCreate(), UNO_QUERY );
+ return getModel_noCreate();
}
SignatureState ODatabaseModelImpl::getScriptingSignatureState()
diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx
index a63ca5af6031..fc5dc5f0907e 100644
--- a/dbaccess/source/core/dataaccess/databasecontext.cxx
+++ b/dbaccess/source/core/dataaccess/databasecontext.cxx
@@ -25,6 +25,7 @@
#include <databasecontext.hxx>
#include "databaseregistrations.hxx"
#include "datasource.hxx"
+#include "databasedocument.hxx"
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -138,14 +139,11 @@ namespace dbaccess
{
try
{
- const Reference< XModel2 > xMod( pCopy->getModel_noCreate(),
- UNO_QUERY_THROW );
+ const rtl::Reference< ODatabaseDocument > xMod( pCopy->getModel_noCreate() );
+ if (!xMod)
+ throw uno::RuntimeException();
if( !xMod->getControllers()->hasMoreElements() )
- {
- Reference< util::XCloseable > xClose( xMod,
- UNO_QUERY_THROW );
- xClose->close( false );
- }
+ xMod->close( false );
}
catch( const CloseVetoException& )
{
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx
index 8ab876fef99b..ae4410d1ee3e 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -2200,9 +2200,9 @@ com_sun_star_comp_dba_ODatabaseDocument(css::uno::XComponentContext* context,
rtl::Reference pImpl(
new dbaccess::ODatabaseModelImpl(context, *pContext));
- css::uno::Reference<XInterface> inst(pImpl->createNewModel_deliverOwnership());
+ rtl::Reference<dbaccess::ODatabaseDocument> inst(pImpl->createNewModel_deliverOwnership());
inst->acquire();
- return inst.get();
+ return cppu::getXWeak(inst.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx
index 9c17ea97764c..6d3ea6204fee 100644
--- a/dbaccess/source/core/dataaccess/documentdefinition.cxx
+++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx
@@ -18,6 +18,7 @@
*/
#include "documentdefinition.hxx"
+#include "databasedocument.hxx"
#include <ModelImpl.hxx>
#include <stringconstants.hxx>
#include <sdbcoretools.hxx>
@@ -461,7 +462,7 @@ void SAL_CALL ODocumentDefinition::disposing()
::comphelper::disposeComponent(m_xListener);
if ( m_bRemoveListener )
{
- Reference<util::XCloseable> xCloseable(m_pImpl->m_pDataSource->getModel_noCreate(),UNO_QUERY);
+ rtl::Reference<ODatabaseDocument> xCloseable(m_pImpl->m_pDataSource->getModel_noCreate());
if ( xCloseable.is() )
xCloseable->removeCloseListener(this);
}
@@ -1488,7 +1489,7 @@ Sequence< PropertyValue > ODocumentDefinition::fillLoadArgs( const Reference< XC
{ // i87957 we need a parent frame
Reference< XDesktop2 > xDesktop = Desktop::create( m_aContext );
xParentFrame.set( xDesktop, UNO_QUERY_THROW );
- Reference<util::XCloseable> xCloseable(m_pImpl->m_pDataSource->getModel_noCreate(),UNO_QUERY);
+ rtl::Reference<ODatabaseDocument> xCloseable(m_pImpl->m_pDataSource->getModel_noCreate());
if ( xCloseable.is() )
{
xCloseable->addCloseListener(this);
@@ -2023,12 +2024,12 @@ void ODocumentDefinition::updateDocumentTitle()
sName = DBA_RES( RID_STR_FORM );
else
sName = DBA_RES( RID_STR_REPORT );
- Reference< XUntitledNumbers > xUntitledProvider(m_pImpl->m_pDataSource->getModel_noCreate(), UNO_QUERY );
+ rtl::Reference< ODatabaseDocument > xUntitledProvider(m_pImpl->m_pDataSource->getModel_noCreate() );
if ( xUntitledProvider.is() )
sName += OUString::number( xUntitledProvider->leaseNumber(getComponent()) );
}
- Reference< XTitle > xDatabaseDocumentModel(m_pImpl->m_pDataSource->getModel_noCreate(),uno::UNO_QUERY);
+ rtl::Reference< ODatabaseDocument > xDatabaseDocumentModel(m_pImpl->m_pDataSource->getModel_noCreate());
if ( xDatabaseDocumentModel.is() )
sName = xDatabaseDocumentModel->getTitle() + " : " + sName;
}
diff --git a/dbaccess/source/core/inc/ModelImpl.hxx b/dbaccess/source/core/inc/ModelImpl.hxx
index 92165ea956a9..9f88829519e2 100644
--- a/dbaccess/source/core/inc/ModelImpl.hxx
+++ b/dbaccess/source/core/inc/ModelImpl.hxx
@@ -88,6 +88,7 @@ typedef ::utl::SharedUNOComponent< css::embed::XStorage > SharedStorage;
class ODatabaseContext;
class DocumentStorageAccess;
class ODatabaseSource;
+class ODatabaseDocument;
/** The class OSharedConnectionManager implements a structure to share connections.
@@ -174,7 +175,7 @@ public:
};
private:
- css::uno::WeakReference< css::frame::XModel > m_xModel;
+ unotools::WeakReference< ODatabaseDocument > m_xModel;
unotools::WeakReference< ODatabaseSource > m_xDataSource;
rtl::Reference<DocumentStorageAccess> m_pStorageAccess;
@@ -346,7 +347,7 @@ public:
/** returns the model, if there already exists one
*/
- css::uno::Reference< css::frame::XModel > getModel_noCreate() const;
+ rtl::Reference< ODatabaseDocument > getModel_noCreate() const;
/** returns a new ->ODatabaseDocument
@@ -356,7 +357,7 @@ public:
@seealso
getModel_noCreate
*/
- css::uno::Reference< css::frame::XModel > createNewModel_deliverOwnership();
+ rtl::Reference< ODatabaseDocument > createNewModel_deliverOwnership();
struct ResetModelAccess { friend class ODatabaseDocument; private: ResetModelAccess() { } };