summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-01-06 15:02:17 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-01-07 08:55:55 +0100
commit85b400482dee5c9da2cf83a755ec37ab149b5b20 (patch)
tree30f301df3cb487cab431d1c60bcff907dff625fb /sc/source
parent41cfe181e3eb4502847fb56955635852e3928d92 (diff)
ScTable::GetProtection and ScDocument::GetTabProtection can be const
Change-Id: Ic30a3fe10ae6206e876a05bed5dc189a9516b452 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108851 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/documen3.cxx2
-rw-r--r--sc/source/core/data/table5.cxx2
-rw-r--r--sc/source/filter/xcl97/xcl97rec.cxx2
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx2
-rw-r--r--sc/source/ui/docshell/docfunc.cxx4
-rw-r--r--sc/source/ui/vba/vbaworksheet.cxx12
-rw-r--r--sc/source/ui/view/gridwin.cxx2
-rw-r--r--sc/source/ui/view/select.cxx2
-rw-r--r--sc/source/ui/view/tabview2.cxx10
-rw-r--r--sc/source/ui/view/tabview3.cxx2
-rw-r--r--sc/source/ui/view/tabvwsh3.cxx4
11 files changed, 23 insertions, 21 deletions
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 4b9e06130f38..b7ece0dfbc0a 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1895,7 +1895,7 @@ bool ScDocument::IsTabProtected( SCTAB nTab ) const
return false;
}
-ScTableProtection* ScDocument::GetTabProtection( SCTAB nTab ) const
+const ScTableProtection* ScDocument::GetTabProtection(SCTAB nTab) const
{
if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
return maTabs[nTab]->GetProtection();
diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx
index 31171f72e4ce..21d2b11d8c6e 100644
--- a/sc/source/core/data/table5.cxx
+++ b/sc/source/core/data/table5.cxx
@@ -1095,7 +1095,7 @@ void ScTable::SetProtection(const ScTableProtection* pProtect)
SetStreamValid(false);
}
-ScTableProtection* ScTable::GetProtection() { return pTabProtection.get(); }
+const ScTableProtection* ScTable::GetProtection() const { return pTabProtection.get(); }
Size ScTable::GetPageSize() const
{
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx
index fa374c486ac2..24adafbae8a4 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -1680,7 +1680,7 @@ XclExpSheetProtectOptions::XclExpSheetProtectOptions( const XclExpRoot& rRoot, S
};
mnOptions = 0x0000;
- ScTableProtection* pProtect = rRoot.GetDoc().GetTabProtection(nTab);
+ const ScTableProtection* pProtect = rRoot.GetDoc().GetTabProtection(nTab);
if (!pProtect)
return;
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 768e42d4e279..d69fdd784ef7 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -2798,7 +2798,7 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const uno::Reference<sheet::XSpre
AddAttribute(sAttrStyleName, aTableStyles[nTable]);
uno::Reference<util::XProtectable> xProtectable (xTable, uno::UNO_QUERY);
- ScTableProtection* pProtect = nullptr;
+ const ScTableProtection* pProtect = nullptr;
if (xProtectable.is() && xProtectable->isProtected())
{
AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTED, XML_TRUE);
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index e3f914620b35..98e07e22df5e 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -3948,7 +3948,7 @@ void ScDocFunc::ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect )
if (!p)
{
// For protection case, use a copy of resulting ScTableProtection for undo
- ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
+ const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
p = std::make_unique<ScTableProtection>(*pProtect);
}
rDocShell.GetUndoManager()->AddUndoAction(
@@ -4051,7 +4051,7 @@ bool ScDocFunc::Unprotect( SCTAB nTab, const OUString& rPassword, bool bApi )
{
// sheet protection
- ScTableProtection* pTabProtect = rDoc.GetTabProtection(nTab);
+ const ScTableProtection* pTabProtect = rDoc.GetTabProtection(nTab);
if (!pTabProtect || !pTabProtect->isProtected())
// already unprotected (should not happen)!
return true;
diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx
index 8fb72057298e..ff626f86d591 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -314,7 +314,7 @@ ScVbaWorksheet::getEnableSelection()
uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_SET_THROW );
ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument();
- ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
+ const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
bool bLockedCells = false;
bool bUnlockedCells = false;
if( pProtect )
@@ -347,7 +347,7 @@ ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection )
uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_SET_THROW );
ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument();
- ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
+ const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
// default is xlNoSelection
bool bLockedCells = false;
bool bUnlockedCells = false;
@@ -362,8 +362,10 @@ ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection )
}
if( pProtect )
{
- pProtect->setOption( ScTableProtection::SELECT_LOCKED_CELLS, bLockedCells );
- pProtect->setOption( ScTableProtection::SELECT_UNLOCKED_CELLS, bUnlockedCells );
+ ScTableProtection aNewProtect(*pProtect);
+ aNewProtect.setOption(ScTableProtection::SELECT_LOCKED_CELLS, bLockedCells);
+ aNewProtect.setOption(ScTableProtection::SELECT_UNLOCKED_CELLS, bUnlockedCells);
+ rDoc.SetTabProtection(nTab, &aNewProtect);
}
@@ -484,7 +486,7 @@ ScVbaWorksheet::getProtectDrawingObjects()
{
uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_SET_THROW );
ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument();
- ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
+ const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
if ( pProtect )
return pProtect->isOptionEnabled( ScTableProtection::OBJECTS );
}
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 9dadd10d5927..b4cc7e3cf84a 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2150,7 +2150,7 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
}
// Check for cell protection attribute.
- ScTableProtection* pProtect = rDoc.GetTabProtection( nTab );
+ const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
bool bEditAllowed = true;
if ( pProtect && pProtect->isProtected() )
{
diff --git a/sc/source/ui/view/select.cxx b/sc/source/ui/view/select.cxx
index 0ef0e2059b2b..6e34ff86a6e8 100644
--- a/sc/source/ui/view/select.cxx
+++ b/sc/source/ui/view/select.cxx
@@ -425,7 +425,7 @@ bool ScViewFunctionSet::SetCursorAtCell( SCCOL nPosX, SCROW nPosY, bool bScroll
if (nPosX < 0 || nPosY < 0)
return false;
- ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
+ const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
if (!pProtect)
return false;
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index ee7be2a2f65c..787aa64fea71 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -62,7 +62,7 @@ void moveCursorByProtRule(
{
bool bSelectLocked = true;
bool bSelectUnlocked = true;
- ScTableProtection* pTabProtection = pDoc->GetTabProtection(nTab);
+ const ScTableProtection* pTabProtection = pDoc->GetTabProtection(nTab);
if (pTabProtection && pTabProtection->isProtected())
{
bSelectLocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
@@ -186,7 +186,7 @@ void moveCursorByMergedCell(
SCCOL nOrigX = rViewData.GetCurX();
SCROW nOrigY = rViewData.GetCurY();
- ScTableProtection* pTabProtection = pDoc->GetTabProtection(nTab);
+ const ScTableProtection* pTabProtection = pDoc->GetTabProtection(nTab);
bool bSelectLocked = true;
bool bSelectUnlocked = true;
if (pTabProtection && pTabProtection->isProtected())
@@ -730,7 +730,7 @@ void ScTabView::SkipCursorHorizontal(SCCOL& rCurX, SCROW& rCurY, SCCOL nOldX, SC
SCTAB nTab = aViewData.GetTabNo();
bool bSkipProtected = false, bSkipUnprotected = false;
- ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
+ const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
if (pProtect && pProtect->isProtected())
{
bSkipProtected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
@@ -790,7 +790,7 @@ void ScTabView::SkipCursorVertical(SCCOL& rCurX, SCROW& rCurY, SCROW nOldY, SCRO
SCTAB nTab = aViewData.GetTabNo();
bool bSkipProtected = false, bSkipUnprotected = false;
- ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
+ const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
if (pProtect && pProtect->isProtected())
{
bSkipProtected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
@@ -868,7 +868,7 @@ void ScTabView::ExpandBlock(SCCOL nMovX, SCROW nMovY, ScFollowMode eMode)
bool bSelectLocked = true;
bool bSelectUnlocked = true;
- ScTableProtection* pTabProtection = rDoc.GetTabProtection(nRefTab);
+ const ScTableProtection* pTabProtection = rDoc.GetTabProtection(nRefTab);
if (pTabProtection && pTabProtection->isProtected())
{
bSelectLocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 4f3d2eaec6b0..29b699a96eb6 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -1265,7 +1265,7 @@ void ScTabView::MoveCursorRel( SCCOL nMovX, SCROW nMovY, ScFollowMode eMode,
SCTAB nTab = aViewData.GetTabNo();
bool bSkipProtected = false, bSkipUnprotected = false;
- ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
+ const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
if ( pProtect && pProtect->isProtected() )
{
bSkipProtected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx
index b6e401991684..e4c85491b442 100644
--- a/sc/source/ui/view/tabvwsh3.cxx
+++ b/sc/source/ui/view/tabvwsh3.cxx
@@ -1228,7 +1228,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
{
// Unprotect a protected sheet.
- ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
+ const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
if (pProtect && pProtect->isProtectedWithPass())
{
OUString aText( ScResId(SCSTR_PASSWORDOPT) );
@@ -1260,7 +1260,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
ScTableProtectionDlg aDlg(GetFrameWeld());
- ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
+ const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
if (pProtect)
aDlg.SetDialogData(*pProtect);