diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-04-29 15:49:46 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-04-30 08:08:54 +0000 |
commit | e8777783db81279a6b0e9cc7b308f10719bd8a7b (patch) | |
tree | 406311c43502f1d4f46313abd1dbe1d4d24359ac /connectivity | |
parent | 121a2c44c90004300b41bee1492c614dc0fe57aa (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.
(cherry picked from commit 7368b6ca3f61e750765f42e97d0a00e10fcac516)
Conflicts:
unotools/source/misc/closeveto.cxx
Change-Id: Ied427b67274d925c911e516c0a50a4c0b2b18db9
Reviewed-on: https://gerrit.libreoffice.org/15567
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
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 c71f345ca40a..2e739d28324d 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 b66d892570ac..14e85808451d 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; |