include/oox/ole/vbamodule.hxx       |   11 +++++++++--
 oox/source/ole/vbamodule.cxx        |    2 +-
 sc/source/ui/vba/vbaapplication.cxx |    7 ++++++-
 3 files changed, 16 insertions(+), 4 deletions(-)

New commits:
commit 6ed0ffe9177ff6851e1b1e338dd92f81e7987f57
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Wed Feb 2 15:20:13 2022 +0900
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Sun Feb 6 06:49:15 2022 +0100

    vba: small fixes for GetOpenFilename and documenting structs
    
    Check the XFileDialogSelectedItems is using the expected impl.
    after dynamic_casting.
    
    Rename VbaKeyBinding to VbaMacroKeyAndMethodBinding and document
    the struct.
    
    Change-Id: Ica4b24fed3013c5efa97a14e98bf9bdc2c74b68d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129320
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/include/oox/ole/vbamodule.hxx b/include/oox/ole/vbamodule.hxx
index 3028136375bc..4cbb4a41c948 100644
--- a/include/oox/ole/vbamodule.hxx
+++ b/include/oox/ole/vbamodule.hxx
@@ -40,9 +40,14 @@ namespace oox {
 
 namespace oox::ole {
 
-struct VbaKeyBinding
+/** Stores, which key shortcut maps to which VBA macro method. */
+struct VbaMacroKeyAndMethodBinding
 {
+    // This describes a key combinaton in "raw" VBA Macro form, that
+    // still needs translated to a key event that can be used in
+    // LibreOffice.
     OUString msApiKey;
+    // The name of the macro method
     OUString msMethodName;
 };
 
@@ -105,7 +110,9 @@ private:
     bool                mbReadOnly;
     bool                mbPrivate;
     bool                mbExecutable;
-    std::vector<VbaKeyBinding> maKeyBindings;
+
+    /** Keys and VBA macro method bindings */
+    std::vector<VbaMacroKeyAndMethodBinding> maKeyBindings;
 };
 
 
diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx
index 0fc9609653f3..d53e525989e6 100644
--- a/oox/source/ole/vbamodule.cxx
+++ b/oox/source/ole/vbamodule.cxx
@@ -136,7 +136,7 @@ void VbaModule::createAndImportModule( StorageBase& 
rVbaStrg,
 
 void VbaModule::registerShortcutKeys()
 {
-    for (VbaKeyBinding const& rKeyBinding : maKeyBindings)
+    for (VbaMacroKeyAndMethodBinding const& rKeyBinding : maKeyBindings)
     {
         try
         {
diff --git a/sc/source/ui/vba/vbaapplication.cxx 
b/sc/source/ui/vba/vbaapplication.cxx
index f11ee6f21bbe..7b68047d0b80 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -358,7 +358,7 @@ uno::Any SAL_CALL
 ScVbaApplication::GetOpenFilename(const uno::Any& /*aFileFilter*/, const 
uno::Any& /*aFilterIndex*/, const uno::Any& aTitle, const uno::Any& 
/*aButtonText*/, const uno::Any& aMultiSelect)
 {
     // TODO - take all parameters into account
-    auto xDialog = uno::Reference<excel::XFileDialog> (new ScVbaFileDialog( 
this, mxContext, office::MsoFileDialogType::msoFileDialogFilePicker));
+    uno::Reference<excel::XFileDialog> xDialog(new ScVbaFileDialog(this, 
mxContext, office::MsoFileDialogType::msoFileDialogFilePicker));
     xDialog->setTitle(aTitle);
     xDialog->setAllowMultiSelect(aMultiSelect);
 
@@ -373,6 +373,11 @@ ScVbaApplication::GetOpenFilename(const uno::Any& 
/*aFileFilter*/, const uno::An
 
     uno::Reference<excel::XFileDialogSelectedItems> xItems = 
xDialog->getSelectedItems();
     auto* pItems = dynamic_cast<ScVbaFileDialogSelectedItems*>(xItems.get());
+
+    // Check, if the implementation of XFileDialogSelectedItems is what we 
expect
+    if (!pItems)
+        throw uno::RuntimeException("Unexpected XFileDialogSelectedItems 
implementation");
+
     auto const & rItemVector = pItems->getItems();
 
     if (!bMultiSelect) // only 1 selection allowed - return path

Reply via email to