summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/source/ui/vba/vbadocument.cxx19
1 files changed, 18 insertions, 1 deletions
diff --git a/sw/source/ui/vba/vbadocument.cxx b/sw/source/ui/vba/vbadocument.cxx
index 4f20311879ad..c8985464501d 100644
--- a/sw/source/ui/vba/vbadocument.cxx
+++ b/sw/source/ui/vba/vbadocument.cxx
@@ -225,7 +225,24 @@ uno::Any SwVbaDocument::ContentControls(const uno::Any& index)
uno::Reference<XCollection> xContentControls(
new SwVbaContentControls(this, mxContext, mxTextDocument, "", ""));
if (index.hasValue())
- return xContentControls->Item(index, uno::Any());
+ {
+ try
+ {
+ return xContentControls->Item(index, uno::Any());
+ }
+ catch (lang::IndexOutOfBoundsException&)
+ {
+ // Hack: Instead of an index, it might be a float that was mistakenly treated as a long,
+ // which can happen with any valid positive integer when specified as a double like
+ // ActiveDocument.ContentControls(1841581653#).
+ if (index.getValueTypeClass() == css::uno::TypeClass_LONG)
+ {
+ sal_Int32 nLong(0);
+ index >>= nLong;
+ return xContentControls->Item(uno::Any(static_cast<double>(nLong)), uno::Any());
+ }
+ }
+ }
return uno::Any(xContentControls);
}