diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-04-29 15:49:46 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-04-29 16:13:10 +0200 |
commit | 7368b6ca3f61e750765f42e97d0a00e10fcac516 (patch) | |
tree | ae6b24d1f38df9bab905289b557321e16c7e45a3 /connectivity | |
parent | 7259901b25974c00c8f0ce8acb91096858cfff53 (diff) |
rhbz#1213173: connectivity: Calc driver: prevent document being disposed
... by adding a XCloseListener that vetoes any attempt to close it.
The Calc document can be opened by the user in the UI and closed again.
Change-Id: Ied427b67274d925c911e516c0a50a4c0b2b18db9
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/calc/CConnection.cxx | 10 | ||||
-rw-r--r-- | connectivity/source/inc/calc/CConnection.hxx | 10 |
2 files changed, 15 insertions, 5 deletions
diff --git a/connectivity/source/drivers/calc/CConnection.cxx b/connectivity/source/drivers/calc/CConnection.cxx index eb94e10ef6d8..71a3c9748ffa 100644 --- a/connectivity/source/drivers/calc/CConnection.cxx +++ b/connectivity/source/drivers/calc/CConnection.cxx @@ -31,6 +31,7 @@ #include "calc/CPreparedStatement.hxx" #include "calc/CStatement.hxx" #include <unotools/pathoptions.hxx> +#include <unotools/closeveto.hxx> #include <connectivity/dbexception.hxx> #include <cppuhelper/exc_hlp.hxx> #include <comphelper/processfactory.hxx> @@ -165,13 +166,17 @@ Reference< XSpreadsheetDocument> OCalcConnection::acquireDoc() ::dbtools::throwGenericSQLException( sError, *this, aErrorDetails ); } osl_atomic_increment(&m_nDocCount); + m_pCloseListener.reset(new utl::CloseVeto(m_xDoc, true)); return m_xDoc; } void OCalcConnection::releaseDoc() { if ( osl_atomic_decrement(&m_nDocCount) == 0 ) - ::comphelper::disposeComponent( m_xDoc ); + { + m_pCloseListener.reset(); // dispose m_xDoc + m_xDoc.clear(); + } } void OCalcConnection::disposing() @@ -179,7 +184,8 @@ void OCalcConnection::disposing() ::osl::MutexGuard aGuard(m_aMutex); m_nDocCount = 0; - ::comphelper::disposeComponent( m_xDoc ); + m_pCloseListener.reset(); // dispose m_xDoc + m_xDoc.clear(); OConnection::disposing(); } diff --git a/connectivity/source/inc/calc/CConnection.hxx b/connectivity/source/inc/calc/CConnection.hxx index cda44ef9ccee..0171ac4b0098 100644 --- a/connectivity/source/inc/calc/CConnection.hxx +++ b/connectivity/source/inc/calc/CConnection.hxx @@ -23,9 +23,11 @@ #include "file/FConnection.hxx" #include <com/sun/star/uno/DeploymentException.hpp> -namespace com { namespace sun { namespace star { namespace sheet { - class XSpreadsheetDocument; -} } } } +namespace com { namespace sun { namespace star { + namespace sheet { class XSpreadsheetDocument; } +} } } + +namespace utl { class CloseVeto; } namespace connectivity @@ -37,6 +39,8 @@ namespace connectivity { // the spreadsheet document: ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument > m_xDoc; + /// close listener that vetoes so nobody disposes m_xDoc + ::std::unique_ptr< ::utl::CloseVeto> m_pCloseListener; OUString m_sPassword; OUString m_aFileName; oslInterlockedCount m_nDocCount; |