[Libreoffice-commits] core.git: sc/qa sc/source

Justin Luth justin_luth at sil.org
Wed Apr 8 06:37:34 PDT 2015


 sc/qa/extras/macros-test.cxx                   |    4 ++++
 sc/qa/extras/testdocuments/vba_endFunction.xls |binary
 sc/source/ui/vba/vbarange.cxx                  |   15 ++++++++-------
 3 files changed, 12 insertions(+), 7 deletions(-)

New commits:
commit 15e758d199e0d7305e9587cd609f494f9ad55285
Author: Justin Luth <justin_luth at sil.org>
Date:   Mon Apr 6 19:04:52 2015 +0300

    tdf#90447 vba end() needed to restore activesheet too.
    
    Change-Id: I650a5112511fd57099be3f0a84314d0577deae22
    Reviewed-on: https://gerrit.libreoffice.org/15175
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index 2c6ac2b..2c7f5b8 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -225,6 +225,10 @@ void ScMacrosTest::testVba()
             OUString("Names."),
             OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
         },
+        {
+            OUString("vba_endFunction."),
+            OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
+        },
     };
     OUString sTempDir;
     OUString sTempDirURL;
diff --git a/sc/qa/extras/testdocuments/vba_endFunction.xls b/sc/qa/extras/testdocuments/vba_endFunction.xls
new file mode 100644
index 0000000..af7fa86
Binary files /dev/null and b/sc/qa/extras/testdocuments/vba_endFunction.xls differ
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 1e249a7..d312d3a 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -3557,17 +3557,18 @@ ScVbaRange::End( ::sal_Int32 Direction )  throw (uno::RuntimeException, std::exc
     // around  ScTabView::MoveCursorArea(), thats the bit that calcutes
     // where the cursor should go )
     // Main problem with this method is the ultra hacky attempt to preserve
-    // the ActiveCell, there should be no need to go to these extreems
+    // the ActiveCell, there should be no need to go to these extremes
 
-    // Save ActiveCell pos ( to restore later )
+    // Save ActiveSheet/ActiveCell pos ( to restore later )
     uno::Any aDft;
     uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
+    uno::Reference< excel::XWorksheet > sActiveSheet = xApplication->getActiveSheet();
     OUString sActiveCell = xApplication->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft );
 
     // position current cell upper left of this range
     Cells( uno::makeAny( (sal_Int32) 1 ), uno::makeAny( (sal_Int32) 1 ) )->Select();
 
-        uno::Reference< frame::XModel > xModel = getModelFromRange( mxRange );
+    uno::Reference< frame::XModel > xModel = getModelFromRange( mxRange );
 
     SfxViewFrame* pViewFrame = excel::getViewFrame( xModel );
     if ( pViewFrame )
@@ -3607,14 +3608,14 @@ ScVbaRange::End( ::sal_Int32 Direction )  throw (uno::RuntimeException, std::exc
     // result is the ActiveCell
     OUString sMoved =    xApplication->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft );
 
-    // restore old ActiveCell
     uno::Any aVoid;
+    uno::Reference< excel::XRange > resultCell;
+    resultCell.set( xApplication->getActiveSheet()->Range( uno::makeAny( sMoved ), aVoid ), uno::UNO_QUERY_THROW );
 
-    uno::Reference< excel::XRange > xOldActiveCell( xApplication->getActiveSheet()->Range( uno::makeAny( sActiveCell ), aVoid ), uno::UNO_QUERY_THROW );
+    // restore old ActiveCell
+    uno::Reference< excel::XRange > xOldActiveCell( sActiveSheet->Range( uno::makeAny( sActiveCell ), aVoid ), uno::UNO_QUERY_THROW );
     xOldActiveCell->Select();
 
-    uno::Reference< excel::XRange > resultCell;
-    resultCell.set( xApplication->getActiveSheet()->Range( uno::makeAny( sMoved ), aVoid ), uno::UNO_QUERY_THROW );
 
     // return result
     return resultCell;


More information about the Libreoffice-commits mailing list