summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2009-04-15 06:09:22 +0000
committerOliver Bolte <obo@openoffice.org>2009-04-15 06:09:22 +0000
commitf261416fd9ea8a3368f323a8d93120ce29da79b7 (patch)
treed457432d066e6660f2d108091f391a12ea49590f
parentef6d95c39dc2fee3c2e12a1572cc8635758c1f64 (diff)
CWS-TOOLING: integrate CWS dba31m
2009-04-08 21:06:02 +0200 fs r270660 : #i100956# hold the assigned events in the ModelImpl, not in the DatabaseDocument, so they survive the model being destroyed 2009-04-08 12:40:13 +0200 b_michaelsen r270635 : #i100928# Opening the Tools->Options->Improvement Program Tabpage on first start accidently activates Usage Tracking 2009-04-07 12:56:29 +0200 fs r270594 : #i100866# don't call into the StatusIndicator with our mutex locked 2009-04-07 10:31:02 +0200 fs r270581 : #i100866# impl_import_throw -> impl_import_nolck_throw 2009-04-06 22:53:10 +0200 fs r270575 : #i100866# some more mutex lock tweaking 2009-04-06 22:01:51 +0200 fs r270573 : #i100861# load the Show/Hide strings from the proper (an existing, in particular) resource 2009-04-06 12:43:16 +0200 fs r270537 : #i100866# notifyEvent: instantiate the ScriptDocument only when required. 2009-04-06 12:42:03 +0200 fs r270536 : #i100866# rework how and when it is determined whether the DBDoc or sub documents contain scripts/macros. In particular, cache this information in the ODatabaseDocument implementation, so that queryInterface does not need to lock the mutex 2009-04-03 10:21:02 +0200 oj r270465 : #i100789# surround uno call with try catch 2009-04-03 09:18:37 +0200 oj r270453 : #i100789# check token is not null
-rw-r--r--dbaccess/qa/complex/dbaccess/DatabaseDocument.java1
-rw-r--r--dbaccess/source/core/dataaccess/ModelImpl.cxx41
-rw-r--r--dbaccess/source/core/dataaccess/ModelImpl.hxx24
-rw-r--r--dbaccess/source/core/dataaccess/databasedocument.cxx139
-rw-r--r--dbaccess/source/core/dataaccess/databasedocument.hxx51
-rw-r--r--dbaccess/source/core/dataaccess/documentdefinition.cxx7
-rw-r--r--dbaccess/source/core/dataaccess/documentevents.cxx38
-rw-r--r--dbaccess/source/core/dataaccess/documentevents.hxx12
8 files changed, 204 insertions, 109 deletions
diff --git a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java
index 13dd1eae1..30ebf8e2d 100644
--- a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java
+++ b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java
@@ -334,7 +334,6 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
new UnoMethodDescriptor( XStorable.class, "store" ),
new UnoMethodDescriptor( XFormDocumentsSupplier.class, "getFormDocuments" ),
new UnoMethodDescriptor( XReportDocumentsSupplier.class, "getReportDocuments" ),
- new UnoMethodDescriptor( XScriptInvocationContext.class, "getScriptContainer" ),
new UnoMethodDescriptor( XScriptProviderSupplier.class, "getScriptProvider" ),
new UnoMethodDescriptor( XEventsSupplier.class, "getEvents" ),
new UnoMethodDescriptor( XTitle.class, "getTitle" ),
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx
index bb75e669d..567c6a475 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -323,7 +323,7 @@ ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XMultiServiceFactory >&
,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE )
,m_pDBContext( &_rDBContext )
,m_refCount(0)
- ,m_bHasAnyObjectWithMacros( false )
+ ,m_aEmbeddedMacros()
,m_bModificationLock( false )
,m_bDocumentInitialized( false )
,m_aContext( _rxFactory )
@@ -362,7 +362,7 @@ ODatabaseModelImpl::ODatabaseModelImpl(
,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE )
,m_pDBContext( &_rDBContext )
,m_refCount(0)
- ,m_bHasAnyObjectWithMacros( false )
+ ,m_aEmbeddedMacros()
,m_bModificationLock( false )
,m_bDocumentInitialized( false )
,m_aContext( _rxFactory )
@@ -1386,24 +1386,33 @@ Reference< XStorage > ODatabaseModelImpl::getLastCommitDocumentStorage()
}
// -----------------------------------------------------------------------------
-sal_Bool ODatabaseModelImpl::documentStorageHasMacros() const
+ODatabaseModelImpl::EmbeddedMacros ODatabaseModelImpl::determineEmbeddedMacros()
{
- // does our root storage contain macros?
- if ( ::sfx2::DocumentMacroMode::storageHasMacros( const_cast< ODatabaseModelImpl* >( this )->getOrCreateRootStorage() ) )
- {
- return true;
- }
-
- // do we have forms or reports with macros?
- if ( lcl_hasObjectsWithMacros_nothrow( const_cast< ODatabaseModelImpl& >( *this ), E_FORM )
- || lcl_hasObjectsWithMacros_nothrow( const_cast< ODatabaseModelImpl& >( *this ), E_REPORT )
- )
+ if ( !m_aEmbeddedMacros )
{
- const_cast< ODatabaseModelImpl* >( this )->m_bHasAnyObjectWithMacros = true;
- return true;
+ if ( ::sfx2::DocumentMacroMode::storageHasMacros( const_cast< ODatabaseModelImpl* >( this )->getOrCreateRootStorage() ) )
+ {
+ m_aEmbeddedMacros.reset( eDocumentWideMacros );
+ }
+ else if ( lcl_hasObjectsWithMacros_nothrow( const_cast< ODatabaseModelImpl& >( *this ), E_FORM )
+ || lcl_hasObjectsWithMacros_nothrow( const_cast< ODatabaseModelImpl& >( *this ), E_REPORT )
+ )
+ {
+ m_aEmbeddedMacros.reset( eSubDocumentMacros );
+ }
+ else
+ {
+ m_aEmbeddedMacros.reset( eNoMacros );
+ }
}
+ return *m_aEmbeddedMacros;
+}
- return false;
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseModelImpl::documentStorageHasMacros() const
+{
+ const_cast< ODatabaseModelImpl* >( this )->determineEmbeddedMacros();
+ return ( *m_aEmbeddedMacros != eNoMacros );
}
// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.hxx b/dbaccess/source/core/dataaccess/ModelImpl.hxx
index 5be51dbad..de30a2ed2 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.hxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.hxx
@@ -35,6 +35,7 @@
#include "bookmarkcontainer.hxx"
#include "ContentHelper.hxx"
#include "core_resource.hxx"
+#include "documentevents.hxx"
/** === begin UNO includes === **/
#include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -162,6 +163,16 @@ public:
E_TABLE = 3
};
+ enum EmbeddedMacros
+ {
+ // the database document (storage) itself contains macros
+ eDocumentWideMacros,
+ // there are sub document( storage)s containing macros
+ eSubDocumentMacros,
+ // there are no known macro( storage)s
+ eNoMacros
+ };
+
private:
OModuleClient m_aModuleClient;
::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_xModel;
@@ -181,6 +192,7 @@ private:
SharedStorage m_xDocumentStorage;
::rtl::Reference< ::sfx2::DocumentStorageModifyListener > m_pStorageModifyListener;
ODatabaseContext* m_pDBContext;
+ DocumentEventsData m_aDocumentEvents;
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aArgs;
/// the URL the document was loaded from
@@ -189,7 +201,7 @@ private:
oslInterlockedCount m_refCount;
/// do we have any object (forms/reports) which contains macros?
- bool m_bHasAnyObjectWithMacros;
+ ::boost::optional< EmbeddedMacros > m_aEmbeddedMacros;
/// true if setting the Modified flag of the document is currently locked
bool m_bModificationLock;
@@ -289,6 +301,9 @@ public:
const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >&
getNumberFormatsSupplier();
+ DocumentEventsData&
+ getDocumentEvents() { return m_aDocumentEvents; }
+
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >&
getResource() const { return m_aArgs; }
@@ -408,12 +423,9 @@ public:
const ::rtl::OUString& _rPersistentName
);
- /** determines whether the database document has any object (form/report) which contains macros
-
- In such a case, *all* objects in the document keep the macro capability, and the database document
- itself does *not* allow embedding macros.
+ /** determines which kind of embedded macros are present in the document
*/
- bool hasAnyObjectWithMacros() const { return m_bHasAnyObjectWithMacros; }
+ EmbeddedMacros determineEmbeddedMacros();
/** checks our document's macro execution mode, using the interaction handler as supplied with our
load arguments
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx
index a3c0174b9..73de7893f 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -35,7 +35,6 @@
#include "databasedocument.hxx"
#include "dbastrings.hrc"
#include "module_dba.hxx"
-#include "documentevents.hxx"
#include "documenteventexecutor.hxx"
#include "databasecontext.hxx"
#include "documentcontainer.hxx"
@@ -165,12 +164,13 @@ ODatabaseDocument::ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>&
,m_aModifyListeners( getMutex() )
,m_aCloseListener( getMutex() )
,m_aStorageListeners( getMutex() )
- ,m_pEventContainer( new DocumentEvents( *this, getMutex() ) )
+ ,m_pEventContainer( new DocumentEvents( *this, getMutex(), _pImpl->getDocumentEvents() ) )
,m_pEventExecutor( NULL ) // initialized below, ref-count-protected
,m_aEventNotifier( *this, getMutex() )
,m_aViewMonitor( m_aEventNotifier )
,m_eInitState( NotInitialized )
,m_bClosing( false )
+ ,m_bAllowDocumentScripting( false )
{
DBG_CTOR(ODatabaseDocument,NULL);
@@ -189,7 +189,10 @@ ODatabaseDocument::ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>&
// then consider ourself initialized, too.
// #i94840#
if ( m_pImpl->hadInitializedDocument() )
+ {
impl_setInitialized();
+ m_bAllowDocumentScripting = ( m_pImpl->determineEmbeddedMacros() != ODatabaseModelImpl::eSubDocumentMacros );
+ }
}
//--------------------------------------------------------------------------
@@ -210,7 +213,7 @@ Any SAL_CALL ODatabaseDocument::queryInterface( const Type& _rType ) throw (Runt
// strip XEmbeddedScripts and XScriptInvocationContext if we have any form/report
// which already contains macros. In this case, the database document itself is not
// allowed to contain macros, too.
- if ( impl_shouldDisallowScripting_nolck_nothrow()
+ if ( !m_bAllowDocumentScripting
&& ( _rType.equals( XEmbeddedScripts::static_type() )
|| _rType.equals( XScriptInvocationContext::static_type() )
)
@@ -244,7 +247,7 @@ Sequence< Type > SAL_CALL ODatabaseDocument::getTypes( ) throw (RuntimeException
// strip XEmbeddedScripts and XScriptInvocationContext if we have any form/report
// which already contains macros. In this case, the database document itself is not
// allowed to contain macros, too.
- if ( impl_shouldDisallowScripting_nolck_nothrow() )
+ if ( !m_bAllowDocumentScripting )
{
Sequence< Type > aStrippedTypes( aTypes.getLength() );
Type* pStripTo( aStrippedTypes.getArray() );
@@ -291,34 +294,67 @@ Sequence< sal_Int8 > SAL_CALL ODatabaseDocument::getImplementationId( ) throw (
}
// -----------------------------------------------------------------------------
-bool ODatabaseDocument::impl_shouldDisallowScripting_nolck_nothrow() const
-{
- ::osl::MutexGuard aGuard( getMutex() );
- if ( m_pImpl.is() && m_pImpl->hasAnyObjectWithMacros() )
- return true;
- return false;
-}
-
-// -----------------------------------------------------------------------------
// local functions
// -----------------------------------------------------------------------------
namespace
{
// -----------------------------------------------------------------------------
+ Reference< XStatusIndicator > lcl_extractStatusIndicator( const ::comphelper::NamedValueCollection& _rArguments )
+ {
+ Reference< XStatusIndicator > xStatusIndicator;
+ return _rArguments.getOrDefault( "StatusIndicator", xStatusIndicator );
+ }
+
+ // -----------------------------------------------------------------------------
+ static void lcl_triggerStatusIndicator_throw( const ::comphelper::NamedValueCollection& _rArguments, DocumentGuard& _rGuard, const bool _bStart )
+ {
+ Reference< XStatusIndicator > xStatusIndicator( lcl_extractStatusIndicator( _rArguments ) );
+ if ( !xStatusIndicator.is() )
+ return;
+
+ _rGuard.clear();
+ try
+ {
+ if ( _bStart )
+ xStatusIndicator->start( ::rtl::OUString(), (sal_Int32)1000000 );
+ else
+ xStatusIndicator->end();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ _rGuard.reset();
+ // note that |reset| can throw a DisposedException
+ }
+
+ // -----------------------------------------------------------------------------
+ static void lcl_extractStatusIndicator( const ::comphelper::NamedValueCollection& _rArguments, Sequence< Any >& _rCallArgs )
+ {
+ Reference< XStatusIndicator > xStatusIndicator( lcl_extractStatusIndicator( _rArguments ) );
+ if ( !xStatusIndicator.is() )
+ return;
+
+ sal_Int32 nLength = _rCallArgs.getLength();
+ _rCallArgs.realloc( nLength + 1 );
+ _rCallArgs[ nLength ] <<= xStatusIndicator;
+ }
+
+ // -----------------------------------------------------------------------------
static void lcl_extractAndStartStatusIndicator( const ::comphelper::NamedValueCollection& _rArguments, Reference< XStatusIndicator >& _rxStatusIndicator,
Sequence< Any >& _rCallArgs )
{
+ _rxStatusIndicator = lcl_extractStatusIndicator( _rArguments );
+ if ( !_rxStatusIndicator.is() )
+ return;
+
try
{
- _rxStatusIndicator = _rArguments.getOrDefault( "StatusIndicator", _rxStatusIndicator );
- if ( _rxStatusIndicator.is() )
- {
- _rxStatusIndicator->start( ::rtl::OUString(), (sal_Int32)1000000 );
+ _rxStatusIndicator->start( ::rtl::OUString(), (sal_Int32)1000000 );
- sal_Int32 nLength = _rCallArgs.getLength();
- _rCallArgs.realloc( nLength + 1 );
- _rCallArgs[ nLength ] <<= _rxStatusIndicator;
- }
+ sal_Int32 nLength = _rCallArgs.getLength();
+ _rCallArgs.realloc( nLength + 1 );
+ _rCallArgs[ nLength ] <<= _rxStatusIndicator;
}
catch( const Exception& )
{
@@ -326,6 +362,7 @@ namespace
}
}
+ // -----------------------------------------------------------------------------
static Sequence< PropertyValue > lcl_appendFileNameToDescriptor( const Sequence< PropertyValue >& _rDescriptor, const ::rtl::OUString _rURL )
{
::comphelper::NamedValueCollection aMediaDescriptor( _rDescriptor );
@@ -373,7 +410,8 @@ void ODatabaseDocument::impl_reset_nothrow()
}
// -----------------------------------------------------------------------------
-void ODatabaseDocument::impl_import_throw( const ::comphelper::NamedValueCollection& _rResource )
+void ODatabaseDocument::impl_import_nolck_throw( const ::comphelper::ComponentContext _rContext, const Reference< XInterface >& _rxTargetComponent,
+ const ::comphelper::NamedValueCollection& _rResource )
{
Sequence< Any > aFilterArgs;
Reference< XStatusIndicator > xStatusIndicator;
@@ -395,10 +433,10 @@ void ODatabaseDocument::impl_import_throw( const ::comphelper::NamedValueCollect
aFilterArgs[nCount] <<= xInfoSet;
Reference< XImporter > xImporter(
- m_pImpl->m_aContext.createComponentWithArguments( "com.sun.star.comp.sdb.DBFilter", aFilterArgs ),
- UNO_QUERY_THROW );
+ _rContext.createComponentWithArguments( "com.sun.star.comp.sdb.DBFilter", aFilterArgs ),
+ UNO_QUERY_THROW );
- Reference< XComponent > xComponent( *this, UNO_QUERY_THROW );
+ Reference< XComponent > xComponent( _rxTargetComponent, UNO_QUERY_THROW );
xImporter->setTargetDocument( xComponent );
Reference< XFilter > xFilter( xImporter, UNO_QUERY_THROW );
@@ -423,11 +461,14 @@ void SAL_CALL ODatabaseDocument::initNew( ) throw (DoubleInitializationExceptio
m_pImpl->m_aContext.getLegacyServiceFactory() ) );
// store therein
- impl_storeToStorage_throw( xTempStor, Sequence< PropertyValue >() );
+ impl_storeToStorage_throw( xTempStor, Sequence< PropertyValue >(), aGuard );
// let the impl know we're now based on this storage
m_pImpl->switchToStorage( xTempStor );
+ // for the newly created document, allow document-wide scripting
+ m_bAllowDocumentScripting = true;
+
impl_setInitialized();
m_aEventNotifier.notifyDocumentEventAsync( "OnTitleChanged" );
@@ -466,7 +507,9 @@ void SAL_CALL ODatabaseDocument::load( const Sequence< PropertyValue >& _Argumen
impl_setInitializing();
try
{
- impl_import_throw( aResource );
+ aGuard.clear();
+ impl_import_nolck_throw( m_pImpl->m_aContext, *this, aResource );
+ aGuard.reset();
}
catch( const Exception& )
{
@@ -474,7 +517,7 @@ void SAL_CALL ODatabaseDocument::load( const Sequence< PropertyValue >& _Argumen
throw;
}
// tell our view monitor that the document has been loaded - this way it will fire the proper
- // even (OnLoad instead of OnCreate) later on
+ // event (OnLoad instead of OnCreate) later on
m_aViewMonitor.onLoadedDocument();
// note that we do *not* call impl_setInitialized() here: The initialization is only complete
@@ -507,6 +550,12 @@ sal_Bool SAL_CALL ODatabaseDocument::attachResource( const ::rtl::OUString& _rUR
{ // this means we've just been loaded, and this is the attachResource call which follows
// the load call.
impl_setInitialized();
+
+ // 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_aEventNotifier.notifyDocumentEvent( "OnLoadFinished" );
}
@@ -728,7 +777,7 @@ void ODatabaseDocument::impl_storeAs_throw( const ::rtl::OUString& _rURL, const
// store to current storage
Reference< XStorage > xCurrentStorage( m_pImpl->getOrCreateRootStorage(), UNO_QUERY_THROW );
Sequence< PropertyValue > aMediaDescriptor( lcl_appendFileNameToDescriptor( _rArguments, _rURL ) );
- impl_storeToStorage_throw( xCurrentStorage, aMediaDescriptor );
+ impl_storeToStorage_throw( xCurrentStorage, aMediaDescriptor, _rGuard );
// success - tell our impl
m_pImpl->attachResource( _rURL, aMediaDescriptor );
@@ -807,6 +856,10 @@ void SAL_CALL ODatabaseDocument::storeAsURL( const ::rtl::OUString& _rURL, const
impl_reset_nothrow();
throw;
}
+
+ if ( bImplicitInitialization )
+ m_bAllowDocumentScripting = true;
+
aGuard.clear();
// <- SYNCHRONIZED
@@ -815,7 +868,8 @@ void SAL_CALL ODatabaseDocument::storeAsURL( const ::rtl::OUString& _rURL, const
}
// -----------------------------------------------------------------------------
-void ODatabaseDocument::impl_storeToStorage_throw( const Reference< XStorage >& _rxTargetStorage, const Sequence< PropertyValue >& _rMediaDescriptor ) const
+void ODatabaseDocument::impl_storeToStorage_throw( const Reference< XStorage >& _rxTargetStorage, const Sequence< PropertyValue >& _rMediaDescriptor,
+ DocumentGuard& _rDocGuard ) const
{
if ( !_rxTargetStorage.is() )
throw IllegalArgumentException( ::rtl::OUString(), *const_cast< ODatabaseDocument* >( this ), 1 );
@@ -839,10 +893,12 @@ void ODatabaseDocument::impl_storeToStorage_throw( const Reference< XStorage >&
// write into target storage
::comphelper::NamedValueCollection aWriteArgs( _rMediaDescriptor );
- writeStorage( _rxTargetStorage, aWriteArgs );
+ lcl_triggerStatusIndicator_throw( aWriteArgs, _rDocGuard, true );
+ impl_writeStorage_throw( _rxTargetStorage, aWriteArgs );
+ lcl_triggerStatusIndicator_throw( aWriteArgs, _rDocGuard, false );
// commit target storage
- OSL_VERIFY( m_pImpl->commitStorageIfWriteable( _rxTargetStorage ) );
+ OSL_VERIFY( ODatabaseModelImpl::commitStorageIfWriteable( _rxTargetStorage ) );
}
catch( const IOException& ) { throw; }
catch( const RuntimeException& ) { throw; }
@@ -873,7 +929,7 @@ void SAL_CALL ODatabaseDocument::storeToURL( const ::rtl::OUString& _rURL, const
Sequence< PropertyValue > aMediaDescriptor( lcl_appendFileNameToDescriptor( _rArguments, _rURL ) );
// store to this storage
- impl_storeToStorage_throw( xTargetStorage, aMediaDescriptor );
+ impl_storeToStorage_throw( xTargetStorage, aMediaDescriptor, aGuard );
}
catch( const Exception& )
{
@@ -944,28 +1000,24 @@ void ODatabaseDocument::impl_setModified_nothrow( sal_Bool _bModified, DocumentG
// ::com::sun::star::document::XEventBroadcaster
void SAL_CALL ODatabaseDocument::addEventListener(const uno::Reference< document::XEventListener >& _Listener ) throw (uno::RuntimeException)
{
- DocumentGuard aGuard( *this, DocumentGuard::MethodWithoutInit );
m_aEventNotifier.addLegacyEventListener( _Listener );
}
// -----------------------------------------------------------------------------
void SAL_CALL ODatabaseDocument::removeEventListener( const uno::Reference< document::XEventListener >& _Listener ) throw (uno::RuntimeException)
{
- DocumentGuard aGuard( *this, DocumentGuard::MethodWithoutInit );
m_aEventNotifier.removeLegacyEventListener( _Listener );
}
// -----------------------------------------------------------------------------
void SAL_CALL ODatabaseDocument::addDocumentEventListener( const Reference< XDocumentEventListener >& _Listener ) throw (RuntimeException)
{
- DocumentGuard aGuard( *this, DocumentGuard::MethodWithoutInit );
m_aEventNotifier.addDocumentEventListener( _Listener );
}
// -----------------------------------------------------------------------------
void SAL_CALL ODatabaseDocument::removeDocumentEventListener( const Reference< XDocumentEventListener >& _Listener ) throw (RuntimeException)
{
- DocumentGuard aGuard( *this, DocumentGuard::MethodWithoutInit );
m_aEventNotifier.removeDocumentEventListener( _Listener );
}
@@ -1232,12 +1284,11 @@ void ODatabaseDocument::WriteThroughComponent( const Reference< XOutputStream >&
}
// -----------------------------------------------------------------------------
-void ODatabaseDocument::writeStorage( const Reference< XStorage >& _rxTargetStorage, const ::comphelper::NamedValueCollection& _rMediaDescriptor ) const
+void ODatabaseDocument::impl_writeStorage_throw( const Reference< XStorage >& _rxTargetStorage, const ::comphelper::NamedValueCollection& _rMediaDescriptor ) const
{
// extract status indicator
Sequence< Any > aDelegatorArguments;
- Reference< XStatusIndicator > xStatusIndicator;
- lcl_extractAndStartStatusIndicator( _rMediaDescriptor, xStatusIndicator, aDelegatorArguments );
+ lcl_extractStatusIndicator( _rMediaDescriptor, aDelegatorArguments );
/** property map for export info set */
comphelper::PropertyMapEntry aExportInfoMap[] =
@@ -1275,9 +1326,6 @@ void ODatabaseDocument::writeStorage( const Reference< XStorage >& _rxTargetStor
aDelegatorArguments, aMediaDescriptor, _rxTargetStorage );
m_pImpl->storeLibraryContainersTo( _rxTargetStorage );
-
- if ( xStatusIndicator.is() )
- xStatusIndicator->end();
}
// -----------------------------------------------------------------------------
@@ -1497,8 +1545,7 @@ void SAL_CALL ODatabaseDocument::loadFromStorage( const Reference< XStorage >& /
void SAL_CALL ODatabaseDocument::storeToStorage( const Reference< XStorage >& _rxStorage, const Sequence< PropertyValue >& _rMediaDescriptor ) throw (IllegalArgumentException, IOException, Exception, RuntimeException)
{
DocumentGuard aGuard( *this );
-
- impl_storeToStorage_throw( _rxStorage, _rMediaDescriptor );
+ impl_storeToStorage_throw( _rxStorage, _rMediaDescriptor, aGuard );
}
// -----------------------------------------------------------------------------
@@ -1573,7 +1620,7 @@ Reference< provider::XScriptProvider > SAL_CALL ODatabaseDocument::getScriptProv
m_pImpl->m_aContext.getSingleton( "com.sun.star.script.provider.theMasterScriptProviderFactory" ), UNO_QUERY_THROW );
Any aScriptProviderContext;
- if ( !impl_shouldDisallowScripting_nolck_nothrow() )
+ if ( m_bAllowDocumentScripting )
aScriptProviderContext <<= Reference< XModel >( this );
xScriptProvider.set( xFactory->createScriptProvider( aScriptProviderContext ), UNO_SET_THROW );
diff --git a/dbaccess/source/core/dataaccess/databasedocument.hxx b/dbaccess/source/core/dataaccess/databasedocument.hxx
index 2ab142124..133b229d5 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.hxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.hxx
@@ -206,6 +206,7 @@ class ODatabaseDocument :public ModelDependentComponent // ModelDepe
*/
InitState m_eInitState;
bool m_bClosing;
+ bool m_bAllowDocumentScripting;
enum StoreType { SAVE, SAVE_AS };
/** stores the document to the given URL, rebases it to the respective new storage, if necessary, resets
@@ -267,7 +268,7 @@ class ODatabaseDocument :public ModelDependentComponent // ModelDepe
@param _xStorageToSaveTo
The storage which should be used for saving
*/
- void writeStorage(
+ void impl_writeStorage_throw(
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxTargetStorage,
const ::comphelper::NamedValueCollection& _rMediaDescriptor
) const;
@@ -534,7 +535,12 @@ private:
/** imports the document from the given resource.
*/
- void impl_import_throw( const ::comphelper::NamedValueCollection& _rResource );
+ static void
+ impl_import_nolck_throw(
+ const ::comphelper::ComponentContext _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxTargetComponent,
+ const ::comphelper::NamedValueCollection& _rResource
+ );
/** creates a storage for the given URL, truncating it if a file with this name already exists
@@ -570,6 +576,14 @@ private:
Note that the document is actually not rebased to this storage, it just stores a copy of itself
to the given target storage.
+ @param _rxTargetStorage
+ denotes the storage to store the document into
+ @param _rMediaDescriptor
+ contains additional parameters for storing the document
+ @param _rDocGuard
+ a guard which holds the (only) lock to the document, and which will be temporarily
+ released where necessary (e.g. for notifications, or calling into other components)
+
@throws ::com::sun::star::uno::IllegalArgumentException
if the given storage is <NULL/>.
@@ -582,21 +596,15 @@ private:
*/
void impl_storeToStorage_throw(
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxTargetStorage,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rMediaDescriptor
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rMediaDescriptor,
+ DocumentGuard& _rDocGuard
) const;
-
- /// determines whether we should disable the scripting related interfaces
- bool impl_shouldDisallowScripting_nolck_nothrow() const;
-
- /** checks whether we need to implicitly initialize the document
-
- */
};
/** an extended version of the ModelMethodGuard, which also cares for the initialization state
of the document
*/
-class DocumentGuard : public ModelMethodGuard
+class DocumentGuard : private ModelMethodGuard
{
public:
enum MethodType
@@ -629,12 +637,13 @@ public:
*/
DocumentGuard( const ODatabaseDocument& _document, MethodType _eType = DefaultMethod )
:ModelMethodGuard( _document )
+ ,m_document( _document )
{
switch ( _eType )
{
- case InitMethod: _document.checkNotInitialized(); break;
- case DefaultMethod: _document.checkInitialized(); break;
- case MethodUsedDuringInit: _document.checkNotUninitilized(); break;
+ case InitMethod: m_document.checkNotInitialized(); break;
+ case DefaultMethod: m_document.checkInitialized(); break;
+ case MethodUsedDuringInit: m_document.checkNotUninitilized(); break;
case MethodWithoutInit: break;
}
}
@@ -642,6 +651,20 @@ public:
~DocumentGuard()
{
}
+
+ void clear()
+ {
+ ModelMethodGuard::clear();
+ }
+ void reset()
+ {
+ ModelMethodGuard::reset();
+ m_document.checkDisposed();
+ }
+
+private:
+
+ const ODatabaseDocument& m_document;
};
//........................................................................
diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx
index 7bf0f9f3b..ab30e42c0 100644
--- a/dbaccess/source/core/dataaccess/documentdefinition.cxx
+++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx
@@ -948,9 +948,9 @@ void ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, con
// So, in such a case, and with 2. above, we would silently execute those macros,
// regardless of the global security settings - which would be a security issue, of
// course.
- if ( !m_pImpl->m_pDataSource->hasAnyObjectWithMacros() )
+ if ( m_pImpl->m_pDataSource->determineEmbeddedMacros() == ODatabaseModelImpl::eNoMacros )
{
- // this is case 2. from above (not *exactly*, but sufficiently)
+ // this is case 2. from above
// So, pass a USE_CONFIG to the to-be-loaded document. This means that
// the user will be prompted with a security message upon opening this
// sub document, in case the settings require this, *and* the document
@@ -1555,7 +1555,8 @@ namespace
// -----------------------------------------------------------------------------
sal_Bool ODocumentDefinition::objectSupportsEmbeddedScripts() const
{
- bool bAllowDocumentMacros = !m_pImpl->m_pDataSource || m_pImpl->m_pDataSource->hasAnyObjectWithMacros();
+ bool bAllowDocumentMacros = !m_pImpl->m_pDataSource
+ || ( m_pImpl->m_pDataSource->determineEmbeddedMacros() == ODatabaseModelImpl::eSubDocumentMacros );
// if *any* of the objects of the database document already has macros, we continue to allow it
// to have them, until the user did a migration.
diff --git a/dbaccess/source/core/dataaccess/documentevents.cxx b/dbaccess/source/core/dataaccess/documentevents.cxx
index 723b14e79..bbba99bb7 100644
--- a/dbaccess/source/core/dataaccess/documentevents.cxx
+++ b/dbaccess/source/core/dataaccess/documentevents.cxx
@@ -38,7 +38,6 @@
#include <comphelper/namedvaluecollection.hxx>
-#include <map>
#include <algorithm>
#include <functional>
@@ -68,17 +67,16 @@ namespace dbaccess
//====================================================================
//= DocumentEvents_Data
//====================================================================
- typedef ::std::map< ::rtl::OUString, Sequence< PropertyValue > > NamedEventDescriptors;
-
struct DocumentEvents_Data : public ::boost::noncopyable
{
::cppu::OWeakObject& rParent;
::osl::Mutex& rMutex;
- NamedEventDescriptors aEventDescs;
+ DocumentEventsData& rEventsData;
- DocumentEvents_Data( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex )
+ DocumentEvents_Data( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, DocumentEventsData& _rEventsData )
:rParent( _rParent )
,rMutex( _rMutex )
+ ,rEventsData( _rEventsData )
{
}
};
@@ -132,14 +130,16 @@ namespace dbaccess
//= DocumentEvents
//====================================================================
//--------------------------------------------------------------------
- DocumentEvents::DocumentEvents( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex )
- :m_pData( new DocumentEvents_Data( _rParent, _rMutex ) )
+ DocumentEvents::DocumentEvents( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, DocumentEventsData& _rEventsData )
+ :m_pData( new DocumentEvents_Data( _rParent, _rMutex, _rEventsData ) )
{
const DocumentEventData* pEventData = lcl_getDocumentEventData();
while ( pEventData->pAsciiEventName )
{
- m_pData->aEventDescs[ ::rtl::OUString::createFromAscii( pEventData->pAsciiEventName ) ] =
- Sequence< PropertyValue >();
+ ::rtl::OUString sEventName = ::rtl::OUString::createFromAscii( pEventData->pAsciiEventName );
+ DocumentEventsData::iterator existingPos = m_pData->rEventsData.find( sEventName );
+ if ( existingPos == m_pData->rEventsData.end() )
+ m_pData->rEventsData[ sEventName ] = Sequence< PropertyValue >();
++pEventData;
}
}
@@ -181,8 +181,8 @@ namespace dbaccess
{
::osl::MutexGuard aGuard( m_pData->rMutex );
- NamedEventDescriptors::iterator elementPos = m_pData->aEventDescs.find( _Name );
- if ( elementPos == m_pData->aEventDescs.end() )
+ DocumentEventsData::iterator elementPos = m_pData->rEventsData.find( _Name );
+ if ( elementPos == m_pData->rEventsData.end() )
throw NoSuchElementException( _Name, *this );
Sequence< PropertyValue > aEventDescriptor;
@@ -215,8 +215,8 @@ namespace dbaccess
{
::osl::MutexGuard aGuard( m_pData->rMutex );
- NamedEventDescriptors::const_iterator elementPos = m_pData->aEventDescs.find( _Name );
- if ( elementPos == m_pData->aEventDescs.end() )
+ DocumentEventsData::const_iterator elementPos = m_pData->rEventsData.find( _Name );
+ if ( elementPos == m_pData->rEventsData.end() )
throw NoSuchElementException( _Name, *this );
Any aReturn;
@@ -231,12 +231,12 @@ namespace dbaccess
{
::osl::MutexGuard aGuard( m_pData->rMutex );
- Sequence< ::rtl::OUString > aNames( m_pData->aEventDescs.size() );
+ Sequence< ::rtl::OUString > aNames( m_pData->rEventsData.size() );
::std::transform(
- m_pData->aEventDescs.begin(),
- m_pData->aEventDescs.end(),
+ m_pData->rEventsData.begin(),
+ m_pData->rEventsData.end(),
aNames.getArray(),
- ::std::select1st< NamedEventDescriptors::value_type >()
+ ::std::select1st< DocumentEventsData::value_type >()
);
return aNames;
}
@@ -246,7 +246,7 @@ namespace dbaccess
{
::osl::MutexGuard aGuard( m_pData->rMutex );
- return m_pData->aEventDescs.find( _Name ) != m_pData->aEventDescs.end();
+ return m_pData->rEventsData.find( _Name ) != m_pData->rEventsData.end();
}
//--------------------------------------------------------------------
@@ -259,7 +259,7 @@ namespace dbaccess
::sal_Bool SAL_CALL DocumentEvents::hasElements( ) throw (RuntimeException)
{
::osl::MutexGuard aGuard( m_pData->rMutex );
- return !m_pData->aEventDescs.empty();
+ return !m_pData->rEventsData.empty();
}
diff --git a/dbaccess/source/core/dataaccess/documentevents.hxx b/dbaccess/source/core/dataaccess/documentevents.hxx
index a4485e582..4337f2e17 100644
--- a/dbaccess/source/core/dataaccess/documentevents.hxx
+++ b/dbaccess/source/core/dataaccess/documentevents.hxx
@@ -32,11 +32,13 @@
/** === begin UNO includes === **/
#include <com/sun/star/container/XNameReplace.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
/** === end UNO includes === **/
#include <cppuhelper/implbase1.hxx>
#include <memory>
+#include <map>
#include <boost/noncopyable.hpp>
//........................................................................
@@ -44,6 +46,9 @@ namespace dbaccess
{
//........................................................................
+ typedef ::std::map< ::rtl::OUString, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >
+ DocumentEventsData;
+
//====================================================================
//= DocumentEvents
//====================================================================
@@ -52,12 +57,11 @@ namespace dbaccess
typedef ::cppu::WeakImplHelper1 < ::com::sun::star::container::XNameReplace
> DocumentEvents_Base;
- class DocumentEvents
- :public DocumentEvents_Base
- ,public ::boost::noncopyable
+ class DocumentEvents :public DocumentEvents_Base
+ ,public ::boost::noncopyable
{
public:
- DocumentEvents( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex );
+ DocumentEvents( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, DocumentEventsData& _rEventsData );
~DocumentEvents();
static bool needsSynchronousNotification( const ::rtl::OUString& _rEventName );