diff options
-rw-r--r-- | sc/source/ui/navipi/navipi.cxx | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/sc/source/ui/navipi/navipi.cxx b/sc/source/ui/navipi/navipi.cxx index 10573c15681f..73ee425b8ada 100644 --- a/sc/source/ui/navipi/navipi.cxx +++ b/sc/source/ui/navipi/navipi.cxx @@ -955,16 +955,32 @@ void ScNavigatorDlg::SetCurrentTableStr( const OUString& rName ) if (!GetViewData()) return; ScDocument* pDoc = pViewData->GetDocument(); - SCTAB nCount = pDoc->GetTableCount(); + SCTAB nCount = pDoc->GetTableCount(); OUString aTabName; + SCTAB nLastSheet = 0; - for ( SCTAB i=0; i<nCount; i++ ) + for (SCTAB i = 0; i<nCount; i++) { - pDoc->GetName( i, aTabName ); - if ( aTabName.equals(rName) ) + pDoc->GetName(i, aTabName); + if (aTabName.equals(rName)) { - SetCurrentTable( i ); - return; + // Check if this is a Scenario sheet and if so select the sheet + // where it belongs to, which is the previous non-Scenario sheet. + if (pDoc->IsScenario(i)) + { + SetCurrentTable(nLastSheet); + return; + } + else + { + SetCurrentTable(i); + return; + } + } + else + { + if (!pDoc->IsScenario(i)) + nLastSheet = i; } } } |