summaryrefslogtreecommitdiffstats
path: root/sc/source/ui
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/vba/vbasheetobject.cxx13
-rw-r--r--sc/source/ui/vba/vbasheetobject.hxx4
2 files changed, 16 insertions, 1 deletions
diff --git a/sc/source/ui/vba/vbasheetobject.cxx b/sc/source/ui/vba/vbasheetobject.cxx
index 28d55a14c4e5..56903e24b468 100644
--- a/sc/source/ui/vba/vbasheetobject.cxx
+++ b/sc/source/ui/vba/vbasheetobject.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/script/ScriptEventDescriptor.hpp>
#include <com/sun/star/script/XEventAttacherManager.hpp>
#include <com/sun/star/style/VerticalAlignment.hpp>
+#include <comphelper/documentinfo.hxx>
#include <ooo/vba/excel/Constants.hpp>
#include <ooo/vba/excel/XlOrientation.hpp>
#include <ooo/vba/excel/XlPlacement.hpp>
@@ -300,7 +301,8 @@ ScVbaControlObjectBase::ScVbaControlObjectBase(
const uno::Reference< drawing::XControlShape >& rxControlShape ) :
ScVbaControlObject_BASE( rxParent, rxContext, rxModel, uno::Reference< drawing::XShape >( rxControlShape, uno::UNO_QUERY_THROW ) ),
mxFormIC( rxFormIC, uno::UNO_SET_THROW ),
- mxControlProps( rxControlShape->getControl(), uno::UNO_QUERY_THROW )
+ mxControlProps( rxControlShape->getControl(), uno::UNO_QUERY_THROW ),
+ mbNotifyMacroEventRead(false)
{
}
@@ -333,6 +335,14 @@ OUString SAL_CALL ScVbaControlObjectBase::getOnAction()
return OUString();
}
+void ScVbaControlObjectBase::NotifyMacroEventRead()
+{
+ if (mbNotifyMacroEventRead)
+ return;
+ comphelper::DocumentInfo::notifyMacroEventRead(mxModel);
+ mbNotifyMacroEventRead = true;
+}
+
void SAL_CALL ScVbaControlObjectBase::setOnAction( const OUString& rMacroName )
{
uno::Reference< script::XEventAttacherManager > xEventMgr( mxFormIC, uno::UNO_QUERY_THROW );
@@ -352,6 +362,7 @@ void SAL_CALL ScVbaControlObjectBase::setOnAction( const OUString& rMacroName )
aDescriptor.EventMethod = gaEventMethod;
aDescriptor.ScriptType = "Script";
aDescriptor.ScriptCode = makeMacroURL( aResolvedMacro.msResolvedMacro );
+ NotifyMacroEventRead();
xEventMgr->registerScriptEvent( nIndex, aDescriptor );
}
}
diff --git a/sc/source/ui/vba/vbasheetobject.hxx b/sc/source/ui/vba/vbasheetobject.hxx
index e53418ab0481..94d88fbb416b 100644
--- a/sc/source/ui/vba/vbasheetobject.hxx
+++ b/sc/source/ui/vba/vbasheetobject.hxx
@@ -153,6 +153,9 @@ public:
virtual sal_Bool SAL_CALL getAutoSize() override;
virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) override;
+ /// Notify that the document contains a macro event handler
+ void NotifyMacroEventRead();
+
protected:
/// @throws css::uno::RuntimeException
sal_Int32 getModelIndexInForm() const;
@@ -160,6 +163,7 @@ protected:
protected:
css::uno::Reference< css::container::XIndexContainer > mxFormIC;
css::uno::Reference< css::beans::XPropertySet > mxControlProps;
+ bool mbNotifyMacroEventRead;
};
typedef ::cppu::ImplInheritanceHelper< ScVbaControlObjectBase, ov::excel::XButton > ScVbaButton_BASE;