sc/source/ui/inc/viewfunc.hxx | 2 +- sc/source/ui/view/tabvwsh3.cxx | 2 +- sc/source/ui/view/viewfunc.cxx | 24 ++---------------------- 3 files changed, 4 insertions(+), 24 deletions(-)
New commits: commit c1815873e0d964fd0892002664307ac518cf1f17 Author: Anshu <anshukhar...@gmail.com> AuthorDate: Sun Jan 31 21:33:12 2021 +0530 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Wed Feb 17 01:36:28 2021 +0100 Improve code for Protect in viewfunc.cxx Change-Id: If197f74945b54675c304d23cac802e3769599554 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110205 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index e5e6157e91d3..2e90c8b5cc4e 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -198,7 +198,7 @@ public: void ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect ); - void Protect( SCTAB nTab, const OUString& rPassword ); + void ProtectDoc( const OUString& rPassword ); bool Unprotect( SCTAB nTab, const OUString& rPassword ); void DeleteCells( DelCellCmd eCmd ); diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx index e4c85491b442..ba53e099f539 100644 --- a/sc/source/ui/view/tabvwsh3.cxx +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -1196,7 +1196,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) if (aDlg.run() == RET_OK) { OUString aPassword = aDlg.GetPassword(); - Protect( TABLEID_DOC, aPassword ); + ProtectDoc( aPassword ); rReq.AppendItem( SfxBoolItem( FID_PROTECT_DOC, true ) ); rReq.Done(); } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 29ed15854e04..36abc6a0a665 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -2523,32 +2523,12 @@ void ScViewFunc::ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect ) UpdateLayerLocks(); //! broadcast to all views } -void ScViewFunc::Protect( SCTAB nTab, const OUString& rPassword ) +void ScViewFunc::ProtectDoc( const OUString& rPassword ) { - ScMarkData& rMark = GetViewData().GetMarkData(); ScDocShell* pDocSh = GetViewData().GetDocShell(); - ScDocument& rDoc = pDocSh->GetDocument(); ScDocFunc &rFunc = pDocSh->GetDocFunc(); - bool bUndo(rDoc.IsUndoEnabled()); - - if ( nTab == TABLEID_DOC || rMark.GetSelectCount() <= 1 ) - rFunc.Protect( nTab, rPassword ); - else - { - // modifying several tabs is handled here - - if (bUndo) - { - OUString aUndo = ScResId( STR_UNDO_PROTECT_TAB ); - pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, GetViewData().GetViewShell()->GetViewShellId() ); - } - for (const auto& rTab : rMark) - rFunc.Protect( rTab, rPassword ); - - if (bUndo) - pDocSh->GetUndoManager()->LeaveListAction(); - } + rFunc.Protect( TABLEID_DOC, rPassword ); UpdateLayerLocks(); //! broadcast to all views } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits