summaryrefslogtreecommitdiff
path: root/sc/source/core/data/sheetevents.cxx
diff options
context:
space:
mode:
authorDaniel Rentz <dr@openoffice.org>2010-07-06 19:34:53 +0200
committerDaniel Rentz <dr@openoffice.org>2010-07-06 19:34:53 +0200
commitd5bbb90b33416ad70987ab6725e41c1ce673ab93 (patch)
treeef4ed55c797fd6ba98c5ef29c36c6ff64dc7ad60 /sc/source/core/data/sheetevents.cxx
parentbee21111f8c0d5974031722236ae52bdb0d65b97 (diff)
mib17: #i112634# add VBA sheet event handling, based on a patch from Noel Power
Diffstat (limited to 'sc/source/core/data/sheetevents.cxx')
-rwxr-xr-xsc/source/core/data/sheetevents.cxx35
1 files changed, 33 insertions, 2 deletions
diff --git a/sc/source/core/data/sheetevents.cxx b/sc/source/core/data/sheetevents.cxx
index e9e430ef85d9..6086eb84dcbb 100755
--- a/sc/source/core/data/sheetevents.cxx
+++ b/sc/source/core/data/sheetevents.cxx
@@ -33,9 +33,9 @@
// INCLUDE ---------------------------------------------------------------
-#include <tools/debug.hxx>
-
#include "sheetevents.hxx"
+#include <com/sun/star/script/vba/EventIdentifier.hpp>
+#include <tools/debug.hxx>
// -----------------------------------------------------------------------
@@ -61,6 +61,37 @@ rtl::OUString ScSheetEvents::GetEventName(sal_Int32 nEvent)
return rtl::OUString::createFromAscii(aEventNames[nEvent]);
}
+// static
+sal_Int32 ScSheetEvents::GetVbaSheetEventId(sal_Int32 nEvent)
+{
+ using namespace ::com::sun::star::script::vba::EventIdentifier;
+ if (nEvent<0 || nEvent>=SC_SHEETEVENT_COUNT)
+ {
+ DBG_ERRORFILE("invalid event number");
+ return NO_EVENT;
+ }
+
+ static const sal_Int32 nVbaEventIds[] =
+ {
+ WORKSHEET_ACTIVATE, // SC_SHEETEVENT_FOCUS
+ WORKSHEET_DEACTIVATE, // SC_SHEETEVENT_UNFOCUS
+ WORKSHEET_SELECTIONCHANGE, // SC_SHEETEVENT_SELECT
+ WORKSHEET_BEFOREDOUBLECLICK, // SC_SHEETEVENT_DOUBLECLICK
+ WORKSHEET_BEFORERIGHTCLICK, // SC_SHEETEVENT_RIGHTCLICK
+ WORKSHEET_CHANGE, // SC_SHEETEVENT_CHANGE
+ WORKSHEET_CALCULATE // SC_SHEETEVENT_CALCULATE
+ };
+ return nVbaEventIds[nEvent];
+}
+
+// static
+sal_Int32 ScSheetEvents::GetVbaDocumentEventId(sal_Int32 nEvent)
+{
+ using namespace ::com::sun::star::script::vba::EventIdentifier;
+ sal_Int32 nSheetEventId = GetVbaSheetEventId(nEvent);
+ return (nSheetEventId != NO_EVENT) ? (nSheetEventId + USERDEFINED_START) : NO_EVENT;
+}
+
// -----------------------------------------------------------------------
ScSheetEvents::ScSheetEvents() :