summaryrefslogtreecommitdiff
path: root/dbaccess/source/core/dataaccess
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-08-07 17:37:11 +0100
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2019-08-28 22:25:40 +0200
commit35fe064a67b54b0680b4845477c9b8751edda160 (patch)
tree32f344c90c4cd7b8cc4b9fdd5135ddea88617eee /dbaccess/source/core/dataaccess
parent4a4e0cb67eab422dffda6f3339031db5b62be77a (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/77387 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'dbaccess/source/core/dataaccess')
-rw-r--r--dbaccess/source/core/dataaccess/ModelImpl.cxx7
-rw-r--r--dbaccess/source/core/dataaccess/databasedocument.cxx25
2 files changed, 24 insertions, 8 deletions
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx
index 4f360bfc1ee9..7c175ab5eeb5 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -374,6 +374,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)
{
@@ -407,6 +408,7 @@ ODatabaseModelImpl::ODatabaseModelImpl(
,m_bSuppressVersionColumns(true)
,m_bModified(false)
,m_bDocumentReadOnly(false)
+ ,m_bMacroCallsSeenWhileLoading(false)
,m_pSharedConnectionManager(nullptr)
,m_nControllerLockCount(0)
{
@@ -1271,6 +1273,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 e84af4dfe653..cf133627ef37 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -747,15 +747,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,