summaryrefslogtreecommitdiff
path: root/sc/source/ui/vba/vbaworksheet.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/vba/vbaworksheet.cxx')
-rw-r--r--sc/source/ui/vba/vbaworksheet.cxx80
1 files changed, 39 insertions, 41 deletions
diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx
index 265f3c46ad6b..4ded2493209a 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -335,26 +335,25 @@ ScVbaWorksheet::getEnableSelection()
{
uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
SCTAB nTab = 0;
- if ( ScVbaWorksheets::nameExists(xSpreadDoc, getName(), nTab) )
+ if ( !ScVbaWorksheets::nameExists(xSpreadDoc, getName(), nTab) )
+ throw uno::RuntimeException("Sheet Name does not exist." );
+
+ uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
+ ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument();
+ ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
+ bool bLockedCells = false;
+ bool bUnlockedCells = false;
+ if( pProtect )
{
- uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
- ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument();
- ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
- bool bLockedCells = false;
- bool bUnlockedCells = false;
- if( pProtect )
- {
- bLockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
- bUnlockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
- }
- if( bLockedCells )
- return excel::XlEnableSelection::xlNoRestrictions;
- if( bUnlockedCells )
- return excel::XlEnableSelection::xlUnlockedCells;
- return excel::XlEnableSelection::xlNoSelection;
+ bLockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bUnlockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
}
- else
- throw uno::RuntimeException("Sheet Name does not exist." );
+ if( bLockedCells )
+ return excel::XlEnableSelection::xlNoRestrictions;
+ if( bUnlockedCells )
+ return excel::XlEnableSelection::xlUnlockedCells;
+ return excel::XlEnableSelection::xlNoSelection;
+
}
void
@@ -369,31 +368,30 @@ ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection )
uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
SCTAB nTab = 0;
- if ( ScVbaWorksheets::nameExists(xSpreadDoc, getName(), nTab) )
+ if ( !ScVbaWorksheets::nameExists(xSpreadDoc, getName(), nTab) )
+ throw uno::RuntimeException("Sheet Name does not exist." );
+
+ uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
+ ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument();
+ ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
+ // default is xlNoSelection
+ bool bLockedCells = false;
+ bool bUnlockedCells = false;
+ if( nSelection == excel::XlEnableSelection::xlNoRestrictions )
{
- uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
- ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument();
- ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
- // default is xlNoSelection
- bool bLockedCells = false;
- bool bUnlockedCells = false;
- if( nSelection == excel::XlEnableSelection::xlNoRestrictions )
- {
- bLockedCells = true;
- bUnlockedCells = true;
- }
- else if( nSelection == excel::XlEnableSelection::xlUnlockedCells )
- {
- bUnlockedCells = true;
- }
- if( pProtect )
- {
- pProtect->setOption( ScTableProtection::SELECT_LOCKED_CELLS, bLockedCells );
- pProtect->setOption( ScTableProtection::SELECT_UNLOCKED_CELLS, bUnlockedCells );
- }
+ bLockedCells = true;
+ bUnlockedCells = true;
}
- else
- throw uno::RuntimeException("Sheet Name does not exist." );
+ else if( nSelection == excel::XlEnableSelection::xlUnlockedCells )
+ {
+ bUnlockedCells = true;
+ }
+ if( pProtect )
+ {
+ pProtect->setOption( ScTableProtection::SELECT_LOCKED_CELLS, bLockedCells );
+ pProtect->setOption( ScTableProtection::SELECT_UNLOCKED_CELLS, bUnlockedCells );
+ }
+
}