summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsw/qa/core/data/docm/testDocumentRange.docmbin0 -> 24459 bytes
-rwxr-xr-x[-rw-r--r--]sw/qa/core/data/docm/testFind.docmbin21380 -> 25510 bytes
-rw-r--r--sw/qa/core/macros-test.cxx4
-rw-r--r--sw/source/ui/vba/vbadocument.cxx30
4 files changed, 25 insertions, 9 deletions
diff --git a/sw/qa/core/data/docm/testDocumentRange.docm b/sw/qa/core/data/docm/testDocumentRange.docm
new file mode 100755
index 000000000000..f1d5b328c383
--- /dev/null
+++ b/sw/qa/core/data/docm/testDocumentRange.docm
Binary files differ
diff --git a/sw/qa/core/data/docm/testFind.docm b/sw/qa/core/data/docm/testFind.docm
index 115fb95b3259..afcba6f0e5d0 100644..100755
--- a/sw/qa/core/data/docm/testFind.docm
+++ b/sw/qa/core/data/docm/testFind.docm
Binary files differ
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index 147e10dda222..dd612ae509d8 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -109,6 +109,10 @@ void SwMacrosTest::testVba()
{
OUString("testFind.docm"),
OUString("vnd.sun.Star.script:Project.Module1.testAll?language=Basic&location=document")
+ },
+ {
+ OUString("testDocumentRange.docm"),
+ OUString("vnd.sun.Star.script:Project.Module1.testAll?language=Basic&location=document")
}
/* TODO - make these pass in Writer
{
diff --git a/sw/source/ui/vba/vbadocument.cxx b/sw/source/ui/vba/vbadocument.cxx
index 4a1a8dd8a2ae..79faf58fe4ab 100644
--- a/sw/source/ui/vba/vbadocument.cxx
+++ b/sw/source/ui/vba/vbadocument.cxx
@@ -137,22 +137,34 @@ SwVbaDocument::Range( const uno::Any& rStart, const uno::Any& rEnd )
sal_Int32 nEnd = 0;
rStart >>= nStart;
rEnd >>= nEnd;
- nStart--;
- nEnd--;
uno::Reference< text::XTextRange > xStart;
uno::Reference< text::XTextRange > xEnd;
- if( nStart != -1 || nEnd != -1 )
- {
- if( nStart == -1 )
- xStart = mxTextDocument->getText()->getStart();
- else
- xStart = SwVbaRangeHelper::getRangeByPosition( mxTextDocument->getText(), nStart );
- if( nEnd == -1 )
+ if( nStart > nEnd)
+ throw uno::RuntimeException();
+
+ if( nEnd != 0)
+ {
+ if( nEnd == nStart )
+ {
+ xStart = mxTextDocument->getText()->getEnd();
xEnd = mxTextDocument->getText()->getEnd();
+ }
else
+ {
xEnd = SwVbaRangeHelper::getRangeByPosition( mxTextDocument->getText(), nEnd );
+
+ if( nStart != 0 )
+ xStart = SwVbaRangeHelper::getRangeByPosition( mxTextDocument->getText(), nStart );
+ else
+ xStart = mxTextDocument->getText()->getStart();
+ }
+ }
+ else
+ {
+ xStart = mxTextDocument->getText()->getEnd();
+ xEnd = mxTextDocument->getText()->getEnd();
}
if( !xStart.is() && !xEnd.is() )