Kaydet (Commit) 15e758d1 authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Markus Mohrhard

tdf#90447 vba end() needed to restore activesheet too.

Change-Id: I650a5112511fd57099be3f0a84314d0577deae22
Reviewed-on: https://gerrit.libreoffice.org/15175Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst d82e9430
...@@ -225,6 +225,10 @@ void ScMacrosTest::testVba() ...@@ -225,6 +225,10 @@ void ScMacrosTest::testVba()
OUString("Names."), OUString("Names."),
OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document") 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 sTempDir;
OUString sTempDirURL; OUString sTempDirURL;
......
...@@ -3557,17 +3557,18 @@ ScVbaRange::End( ::sal_Int32 Direction ) throw (uno::RuntimeException, std::exc ...@@ -3557,17 +3557,18 @@ ScVbaRange::End( ::sal_Int32 Direction ) throw (uno::RuntimeException, std::exc
// around ScTabView::MoveCursorArea(), thats the bit that calcutes // around ScTabView::MoveCursorArea(), thats the bit that calcutes
// where the cursor should go ) // where the cursor should go )
// Main problem with this method is the ultra hacky attempt to preserve // 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::Any aDft;
uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW ); 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 ); OUString sActiveCell = xApplication->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft );
// position current cell upper left of this range // position current cell upper left of this range
Cells( uno::makeAny( (sal_Int32) 1 ), uno::makeAny( (sal_Int32) 1 ) )->Select(); 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 ); SfxViewFrame* pViewFrame = excel::getViewFrame( xModel );
if ( pViewFrame ) if ( pViewFrame )
...@@ -3607,14 +3608,14 @@ ScVbaRange::End( ::sal_Int32 Direction ) throw (uno::RuntimeException, std::exc ...@@ -3607,14 +3608,14 @@ ScVbaRange::End( ::sal_Int32 Direction ) throw (uno::RuntimeException, std::exc
// result is the ActiveCell // result is the ActiveCell
OUString sMoved = xApplication->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft ); OUString sMoved = xApplication->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft );
// restore old ActiveCell
uno::Any aVoid; 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(); xOldActiveCell->Select();
uno::Reference< excel::XRange > resultCell;
resultCell.set( xApplication->getActiveSheet()->Range( uno::makeAny( sMoved ), aVoid ), uno::UNO_QUERY_THROW );
// return result // return result
return resultCell; return resultCell;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment