sw/qa/core/data/docm/testFind.docm |binary
 sw/qa/core/macros-test.cxx         |    4 ++--
 sw/source/ui/vba/vbaselection.cxx  |    9 +++++++++
 3 files changed, 11 insertions(+), 2 deletions(-)

New commits:
commit f6d45f07fcbb33ce542f128caf90064a85a91d31
Author:     Hannah Meeks <hmeeks4...@gmail.com>
AuthorDate: Mon Jul 18 16:35:28 2022 +0100
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Wed Jul 20 22:44:28 2022 +0200

    VBA: Selection.Find should select whole doc if no prior selection.
    
    Change-Id: I8b77ae982a772a95290aea186f4fe6556f2a2e1b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137202
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sw/qa/core/data/docm/testFind.docm 
b/sw/qa/core/data/docm/testFind.docm
index a0a316685b79..115fb95b3259 100644
Binary files a/sw/qa/core/data/docm/testFind.docm and 
b/sw/qa/core/data/docm/testFind.docm differ
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index e412cdd03430..147e10dda222 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -107,8 +107,8 @@ void SwMacrosTest::testVba()
 {
     TestMacroInfo testInfo[] = {
         {
-           OUString("testFind.docm"),
-            
OUString("vnd.sun.Star.script:Project.Module1.testFind?language=Basic&location=document")
+            OUString("testFind.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/vbaselection.cxx 
b/sw/source/ui/vba/vbaselection.cxx
index 43da7dc6af48..18554fad1b5c 100644
--- a/sw/source/ui/vba/vbaselection.cxx
+++ b/sw/source/ui/vba/vbaselection.cxx
@@ -519,6 +519,15 @@ uno::Reference< word::XFind > SAL_CALL
 SwVbaSelection::getFind()
 {
     uno::Reference< text::XTextRange > xTextRange = GetSelectedRange();
+    uno::Reference< text::XTextRange > xStart = xTextRange->getStart();
+    uno::Reference< text::XTextRange > xEnd = xTextRange->getEnd();
+    uno::Reference< text::XTextRangeCompare > xTRC( xTextRange->getText(), 
uno::UNO_QUERY_THROW );
+    int n = xTRC->compareRegionStarts( xStart, xEnd);
+    if( n == 0 )
+    {
+        WholeStory();
+        xTextRange = GetSelectedRange();
+    }
     return SwVbaFind::GetOrCreateFind(this, mxContext, mxModel, xTextRange);
 }
 

Reply via email to