diff options
author | Justin Luth <justin_luth@sil.org> | 2015-04-06 19:04:52 +0300 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-04-08 13:37:12 +0000 |
commit | 15e758d199e0d7305e9587cd609f494f9ad55285 (patch) | |
tree | 1d2f4a01ef5d7ef3c1b6f8458aa0804603b11887 /sc | |
parent | d82e94307f1e073a0ccddb506ba5fff3da042b42 (diff) |
tdf#90447 vba end() needed to restore activesheet too.
Change-Id: I650a5112511fd57099be3f0a84314d0577deae22
Reviewed-on: https://gerrit.libreoffice.org/15175
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/extras/macros-test.cxx | 4 | ||||
-rw-r--r-- | sc/qa/extras/testdocuments/vba_endFunction.xls | bin | 0 -> 2286592 bytes | |||
-rw-r--r-- | sc/source/ui/vba/vbarange.cxx | 15 |
3 files changed, 12 insertions, 7 deletions
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index 2c6ac2b200a1..2c7f5b8da51e 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 Binary files differnew file mode 100644 index 000000000000..af7fa86256b5 --- /dev/null +++ b/sc/qa/extras/testdocuments/vba_endFunction.xls diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 1e249a7e7d48..d312d3ae46e1 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; |