[Libreoffice-commits] core.git: sc/source

Jochen Nitschke j.nitschke+logerrit at ok.de
Wed Aug 3 12:15:46 UTC 2016


 sc/source/ui/vba/vbaeventshelper.cxx |   69 ++++++++++++++++-------------------
 1 file changed, 33 insertions(+), 36 deletions(-)

New commits:
commit 700bcdbd467e5f116e967f7ab6657fdbc7933e56
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Wed Jul 27 17:58:35 2016 +0200

    sc: replace REGISTER_..._EVENT macros with lambdas
    
    Change-Id: Ie4aef0c2e5cb89626e3549599b055a1d3ce4054b
    Reviewed-on: https://gerrit.libreoffice.org/27506
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jochen Nitschke <j.nitschke+logerrit at ok.de>

diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx
index da68267..8778b33 100644
--- a/sc/source/ui/vba/vbaeventshelper.cxx
+++ b/sc/source/ui/vba/vbaeventshelper.cxx
@@ -528,47 +528,44 @@ ScVbaEventsHelper::ScVbaEventsHelper( const uno::Sequence< uno::Any >& rArgs, co
     if( !mxModel.is() || !mpDocShell || !mpDoc )
         return;
 
-#define REGISTER_EVENT( eventid, moduletype, classname, eventname, cancelindex, worksheet ) \
-    registerEventHandler( eventid, moduletype, classname "_" eventname, cancelindex, uno::Any( worksheet ) )
-#define REGISTER_AUTO_EVENT( eventid, eventname ) \
-    REGISTER_EVENT( AUTO_##eventid, script::ModuleType::NORMAL, "Auto", eventname, -1, false )
-#define REGISTER_WORKBOOK_EVENT( eventid, eventname, cancelindex ) \
-    REGISTER_EVENT( WORKBOOK_##eventid, script::ModuleType::DOCUMENT, "Workbook", eventname, cancelindex, false )
-#define REGISTER_WORKSHEET_EVENT( eventid, eventname, cancelindex ) \
-    REGISTER_EVENT( WORKSHEET_##eventid, script::ModuleType::DOCUMENT, "Worksheet", eventname, cancelindex, true ); \
-    REGISTER_EVENT( (USERDEFINED_START + WORKSHEET_##eventid), script::ModuleType::DOCUMENT, "Workbook", "Sheet" eventname, (((cancelindex) >= 0) ? ((cancelindex) + 1) : -1), false )
-
     // global
-    REGISTER_AUTO_EVENT( OPEN,  "Open" );
-    REGISTER_AUTO_EVENT( CLOSE, "Close" );
+    auto registerAutoEvent = [this](sal_Int32 nID, const sal_Char* sName)
+    { registerEventHandler(nID, script::ModuleType::NORMAL, (OString("Auto_").concat(sName)).getStr(), -1, uno::Any(false)); };
+    registerAutoEvent(AUTO_OPEN,  "Open");
+    registerAutoEvent(AUTO_CLOSE, "Close");
 
     // Workbook
-    REGISTER_WORKBOOK_EVENT( ACTIVATE,            "Activate",           -1 );
-    REGISTER_WORKBOOK_EVENT( DEACTIVATE,          "Deactivate",         -1 );
-    REGISTER_WORKBOOK_EVENT( OPEN,                "Open",               -1 );
-    REGISTER_WORKBOOK_EVENT( BEFORECLOSE,         "BeforeClose",        0 );
-    REGISTER_WORKBOOK_EVENT( BEFOREPRINT,         "BeforePrint",        0 );
-    REGISTER_WORKBOOK_EVENT( BEFORESAVE,          "BeforeSave",         1 );
-    REGISTER_WORKBOOK_EVENT( AFTERSAVE,           "AfterSave",          -1 );
-    REGISTER_WORKBOOK_EVENT( NEWSHEET,            "NewSheet",           -1 );
-    REGISTER_WORKBOOK_EVENT( WINDOWACTIVATE,      "WindowActivate",     -1 );
-    REGISTER_WORKBOOK_EVENT( WINDOWDEACTIVATE,    "WindowDeactivate",   -1 );
-    REGISTER_WORKBOOK_EVENT( WINDOWRESIZE,        "WindowResize",       -1 );
+    auto registerWorkbookEvent = [this](sal_Int32 nID, const sal_Char* sName, sal_Int32 nCancelIndex)
+    { registerEventHandler(nID, script::ModuleType::DOCUMENT, (OString("Workbook_").concat(sName)).getStr(), nCancelIndex, uno::Any(false)); };
+    registerWorkbookEvent( WORKBOOK_ACTIVATE,            "Activate",           -1 );
+    registerWorkbookEvent( WORKBOOK_DEACTIVATE,          "Deactivate",         -1 );
+    registerWorkbookEvent( WORKBOOK_OPEN,                "Open",               -1 );
+    registerWorkbookEvent( WORKBOOK_BEFORECLOSE,         "BeforeClose",         0 );
+    registerWorkbookEvent( WORKBOOK_BEFOREPRINT,         "BeforePrint",         0 );
+    registerWorkbookEvent( WORKBOOK_BEFORESAVE,          "BeforeSave",          1 );
+    registerWorkbookEvent( WORKBOOK_AFTERSAVE,           "AfterSave",          -1 );
+    registerWorkbookEvent( WORKBOOK_NEWSHEET,            "NewSheet",           -1 );
+    registerWorkbookEvent( WORKBOOK_WINDOWACTIVATE,      "WindowActivate",     -1 );
+    registerWorkbookEvent( WORKBOOK_WINDOWDEACTIVATE,    "WindowDeactivate",   -1 );
+    registerWorkbookEvent( WORKBOOK_WINDOWRESIZE,        "WindowResize",       -1 );
 
     // Worksheet events. All events have a corresponding workbook event.
-    REGISTER_WORKSHEET_EVENT( ACTIVATE,           "Activate",           -1 );
-    REGISTER_WORKSHEET_EVENT( DEACTIVATE,         "Deactivate",         -1 );
-    REGISTER_WORKSHEET_EVENT( BEFOREDOUBLECLICK,  "BeforeDoubleClick",  1 );
-    REGISTER_WORKSHEET_EVENT( BEFORERIGHTCLICK,   "BeforeRightClick",   1 );
-    REGISTER_WORKSHEET_EVENT( CALCULATE,          "Calculate",          -1 );
-    REGISTER_WORKSHEET_EVENT( CHANGE,             "Change",             -1 );
-    REGISTER_WORKSHEET_EVENT( SELECTIONCHANGE,    "SelectionChange",    -1 );
-    REGISTER_WORKSHEET_EVENT( FOLLOWHYPERLINK,    "FollowHyperlink",    -1 );
-
-#undef REGISTER_WORKSHEET_EVENT
-#undef REGISTER_WORKBOOK_EVENT
-#undef REGISTER_AUTO_EVENT
-#undef REGISTER_EVENT
+    auto registerWorksheetEvent = [this](sal_Int32 nID, const sal_Char* sName, sal_Int32 nCancelIndex)
+    {
+        registerEventHandler(nID, script::ModuleType::DOCUMENT, (OString("Worksheet_").concat(sName)).getStr(),
+                             nCancelIndex, uno::Any(true));
+        registerEventHandler(USERDEFINED_START + nID, script::ModuleType::DOCUMENT,
+                             (OString("Workbook_Worksheet").concat(sName)).getStr(),
+                             ((nCancelIndex >= 0) ? (nCancelIndex + 1) : -1), uno::Any(false));
+    };
+    registerWorksheetEvent( WORKSHEET_ACTIVATE,           "Activate",           -1 );
+    registerWorksheetEvent( WORKSHEET_DEACTIVATE,         "Deactivate",         -1 );
+    registerWorksheetEvent( WORKSHEET_BEFOREDOUBLECLICK,  "BeforeDoubleClick",   1 );
+    registerWorksheetEvent( WORKSHEET_BEFORERIGHTCLICK,   "BeforeRightClick",    1 );
+    registerWorksheetEvent( WORKSHEET_CALCULATE,          "Calculate",          -1 );
+    registerWorksheetEvent( WORKSHEET_CHANGE,             "Change",             -1 );
+    registerWorksheetEvent( WORKSHEET_SELECTIONCHANGE,    "SelectionChange",    -1 );
+    registerWorksheetEvent( WORKSHEET_FOLLOWHYPERLINK,    "FollowHyperlink",    -1 );
 }
 
 ScVbaEventsHelper::~ScVbaEventsHelper()


More information about the Libreoffice-commits mailing list