summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/vbahelper/vbahelper.hxx4
-rw-r--r--oovbaapi/ooo/vba/word/XWordBasic.idl1
-rw-r--r--sw/qa/core/data/docm/testVBA.docmbin24779 -> 24218 bytes
-rw-r--r--sw/source/ui/vba/vbawordbasic.cxx13
-rw-r--r--sw/source/ui/vba/vbawordbasic.hxx1
-rw-r--r--vbahelper/source/vbahelper/vbahelper.cxx21
6 files changed, 40 insertions, 0 deletions
diff --git a/include/vbahelper/vbahelper.hxx b/include/vbahelper/vbahelper.hxx
index 533d5e3698b6..9be2b900a019 100644
--- a/include/vbahelper/vbahelper.hxx
+++ b/include/vbahelper/vbahelper.hxx
@@ -26,6 +26,7 @@
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
+#include <basic/sbxmeth.hxx>
#include <rtl/ustring.hxx>
#include <sal/types.h>
#include <tools/color.hxx>
@@ -131,6 +132,9 @@ namespace ooo::vba
VBAHELPER_DLLPUBLIC bool setPropertyValue( css::uno::Sequence< css::beans::PropertyValue >& aProp, const OUString& aName, const css::uno::Any& aValue );
VBAHELPER_DLLPUBLIC void setOrAppendPropertyValue( css::uno::Sequence< css::beans::PropertyValue >& aProp, const OUString& aName, const css::uno::Any& aValue );
+ VBAHELPER_DLLPUBLIC bool executeRunTimeLibrary(const std::u16string_view& rSbRtl_command,
+ SbxArray* pParameters);
+
class VBAHELPER_DLLPUBLIC Millimeter
{
//Factor to translate between points and hundredths of millimeters:
diff --git a/oovbaapi/ooo/vba/word/XWordBasic.idl b/oovbaapi/ooo/vba/word/XWordBasic.idl
index 66c867f09364..7cc1efe8bd56 100644
--- a/oovbaapi/ooo/vba/word/XWordBasic.idl
+++ b/oovbaapi/ooo/vba/word/XWordBasic.idl
@@ -42,6 +42,7 @@ interface XWordBasic
any DocMaximize( [in] any State );
void AppShow( [in] any WindowName );
any AppCount();
+ void MsgBox( [in] string Prompt );
void ScreenUpdating( [in] /*optional*/ any On );
};
diff --git a/sw/qa/core/data/docm/testVBA.docm b/sw/qa/core/data/docm/testVBA.docm
index c02e353c3c3e..a2609feb6cd0 100644
--- a/sw/qa/core/data/docm/testVBA.docm
+++ b/sw/qa/core/data/docm/testVBA.docm
Binary files differ
diff --git a/sw/source/ui/vba/vbawordbasic.cxx b/sw/source/ui/vba/vbawordbasic.cxx
index ae59cf245f55..f08ed4e0daa8 100644
--- a/sw/source/ui/vba/vbawordbasic.cxx
+++ b/sw/source/ui/vba/vbawordbasic.cxx
@@ -22,6 +22,8 @@
#include "vbamailmerge.hxx"
#include "vbawordbasic.hxx"
+#include <basic/sbx.hxx>
+#include <basic/sbxvar.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertyvalue.hxx>
#include <osl/file.hxx>
@@ -242,6 +244,17 @@ css::uno::Any SAL_CALL SwWordBasic::AppCount()
return css::uno::Any(sal_Int32(2));
}
+void SAL_CALL SwWordBasic::MsgBox(const OUString& sPrompt)
+{
+ SbxArrayRef pArgs = new SbxArray;
+ SbxVariable* pVar = new SbxVariable();
+ pVar->PutString(sPrompt);
+ pArgs->Put(pVar, 1);
+
+ if (!executeRunTimeLibrary(u"MsgBox", pArgs.get()))
+ SAL_WARN("sw.vba", "failed to execute runtime library function MsgBox (" << sPrompt << ")");
+}
+
void SAL_CALL SwWordBasic::ScreenUpdating(const uno::Any& On)
{
sal_Int32 nOn;
diff --git a/sw/source/ui/vba/vbawordbasic.hxx b/sw/source/ui/vba/vbawordbasic.hxx
index 75f8a05a3210..05589f0c58c5 100644
--- a/sw/source/ui/vba/vbawordbasic.hxx
+++ b/sw/source/ui/vba/vbawordbasic.hxx
@@ -86,6 +86,7 @@ public:
virtual css::uno::Any SAL_CALL DocMaximize(const css::uno::Any& State) override;
virtual void SAL_CALL AppShow(const css::uno::Any& WindowName) override;
virtual css::uno::Any SAL_CALL AppCount() override;
+ virtual void SAL_CALL MsgBox(const OUString& sPrompt) override;
virtual void SAL_CALL ScreenUpdating(const css::uno::Any& On) override;
};
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx
index 4e71cb582565..2722f627e9ba 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -746,6 +746,27 @@ void setOrAppendPropertyValue( uno::Sequence< beans::PropertyValue >& aProp, con
pProp[ nLength ].Value = aValue;
}
+bool executeRunTimeLibrary(const std::u16string_view& rSbRtl_command, SbxArray* pParameters)
+{
+ StarBASIC* pBasic = dynamic_cast< StarBASIC* >(StarBASIC::GetActiveModule()->GetParent());
+ if (!pBasic)
+ return false;
+
+ SbxObject* pRunTimeLibrary = pBasic->GetRtl();
+ if (!pRunTimeLibrary)
+ return false;
+
+ SbxVariable* pFound = pRunTimeLibrary->Find(OUString(rSbRtl_command), SbxClassType::Method);
+ SbxMethod* pMethod = dynamic_cast<SbxMethod*>(pFound);
+ if (!pMethod)
+ return false;
+
+ pMethod->SetParameters(pParameters);
+ // Believe it or not, this actually runs the command
+ pMethod->Broadcast(SfxHintId::BasicDataWanted);
+ return true;
+}
+
// ====UserFormGeomentryHelper====
UserFormGeometryHelper::UserFormGeometryHelper(