summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-08-07 17:37:11 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-08-15 21:36:42 +0200
commita661549b70d30d8925e9839ca97e832111f289b5 (patch)
tree954873a9ccf5a717ab4a157a09437c48d6144151 /dbaccess
parent3104eaa53593fd512d750ebbbd48314576c5c064 (diff)
warn on load when a document binds an event to a macro
a) treat shared/Scripts equivalently to document scripts This doesn't automatically warn/block running those scripts when used in a freshly loaded document on its own however because DocumentMacroMode::checkMacrosOnLoading will see at... if ( m_xData->m_rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() ) that the document contains no macros and flip the allow macros flag to true so that potentially new uses of macros added by the user during the edit are allowed to run b) so, add an additional flag to indicate existence of use of macros in a document c) for odf import, set it when a script:event-listener tag is encountered d) for html import when registerScriptEvents or SwFormatINetFormat::SetMacroTable is called e) for doc import when Read_F_Macro or StoreMacroCmds is called as well for good measure f) for xls import when registerScriptEvent or ScMacroInfo::SetMacro is called g) for oox import when VbaProject::attachMacros is called Change-Id: Ic1203d8ec7dfc217aa217135033ae9db2888e19b Reviewed-on: https://gerrit.libreoffice.org/77386 Tested-by: Jenkins Reviewed-by: Michael Stahl <Michael.Stahl@cib.de> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/core/dataaccess/ModelImpl.cxx7
-rw-r--r--dbaccess/source/core/dataaccess/databasedocument.cxx25
-rw-r--r--dbaccess/source/core/inc/ModelImpl.hxx2
3 files changed, 26 insertions, 8 deletions
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx
index e27dc8d4a292..9958b6c0e995 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -370,6 +370,7 @@ ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XComponentContext >& _r
,m_bSuppressVersionColumns(true)
,m_bModified(false)
,m_bDocumentReadOnly(false)
+ ,m_bMacroCallsSeenWhileLoading(false)
,m_pSharedConnectionManager(nullptr)
,m_nControllerLockCount(0)
{
@@ -403,6 +404,7 @@ ODatabaseModelImpl::ODatabaseModelImpl(
,m_bSuppressVersionColumns(true)
,m_bModified(false)
,m_bDocumentReadOnly(false)
+ ,m_bMacroCallsSeenWhileLoading(false)
,m_pSharedConnectionManager(nullptr)
,m_nControllerLockCount(0)
{
@@ -1266,6 +1268,11 @@ bool ODatabaseModelImpl::documentStorageHasMacros() const
return ( *m_aEmbeddedMacros != eNoMacros );
}
+bool ODatabaseModelImpl::macroCallsSeenWhileLoading() const
+{
+ return m_bMacroCallsSeenWhileLoading;
+}
+
Reference< XEmbeddedScripts > ODatabaseModelImpl::getEmbeddedDocumentScripts() const
{
return Reference< XEmbeddedScripts >( getModel_noCreate(), UNO_QUERY );
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx
index 24db02fc6be0..9f72c08fe95a 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -748,15 +748,24 @@ sal_Bool SAL_CALL ODatabaseDocument::attachResource( const OUString& _rURL, cons
bool ODatabaseDocument::impl_attachResource( const OUString& i_rLogicalDocumentURL,
const Sequence< PropertyValue >& i_rMediaDescriptor, DocumentGuard& _rDocGuard )
{
- if ( ( i_rLogicalDocumentURL == getURL() )
- && ( i_rMediaDescriptor.getLength() == 1 )
- && ( i_rMediaDescriptor[0].Name == "BreakMacroSignature" )
- )
+ if (i_rLogicalDocumentURL == getURL())
{
- // this is a BAD hack of the Basic importer code ... there should be a dedicated API for this,
- // not this bad mis-using of existing interfaces
- return false;
- // (we do not support macro signatures, so we can ignore this call)
+ ::comphelper::NamedValueCollection aArgs(i_rMediaDescriptor);
+
+ // this misuse of attachresource is a hack of the Basic importer code
+ // repurposing existing interfaces for uses it probably wasn't intended
+ // for
+
+ // we do not support macro signatures, so we can ignore that request
+ aArgs.remove("BreakMacroSignature");
+
+ bool bMacroEventRead = false;
+ if ((aArgs.get( "MacroEventRead" ) >>= bMacroEventRead) && bMacroEventRead)
+ m_pImpl->m_bMacroCallsSeenWhileLoading = true;
+ aArgs.remove( "MacroEventRead" );
+
+ if (aArgs.empty())
+ return false;
}
// if no URL has been provided, the caller was lazy enough to not call our getURL - which is not allowed anymore,
diff --git a/dbaccess/source/core/inc/ModelImpl.hxx b/dbaccess/source/core/inc/ModelImpl.hxx
index 15cda7443bbd..0ed9c8dfeece 100644
--- a/dbaccess/source/core/inc/ModelImpl.hxx
+++ b/dbaccess/source/core/inc/ModelImpl.hxx
@@ -207,6 +207,7 @@ public:
bool m_bSuppressVersionColumns : 1;
bool m_bModified : 1;
bool m_bDocumentReadOnly : 1;
+ bool m_bMacroCallsSeenWhileLoading : 1;
css::uno::Reference< css::beans::XPropertyBag >
m_xSettings;
css::uno::Sequence< OUString > m_aTableFilter;
@@ -435,6 +436,7 @@ public:
virtual void setCurrentMacroExecMode( sal_uInt16 ) override;
virtual OUString getDocumentLocation() const override;
virtual bool documentStorageHasMacros() const override;
+ virtual bool macroCallsSeenWhileLoading() const override;
virtual css::uno::Reference< css::document::XEmbeddedScripts > getEmbeddedDocumentScripts() const override;
virtual SignatureState getScriptingSignatureState() override;
virtual bool hasTrustedScriptingSignature( bool bAllowUIToAddAuthor ) override;