From 26030f92629b310e66b2335c2cec0413bb7ec828 Mon Sep 17 00:00:00 2001 From: Bernhard Widl Date: Wed, 5 Apr 2017 18:29:52 +0200 Subject: tdf#97357 allow insert image if sheet is protected but few cells are not - if the currently marked area is fuly unprotected, allow insert image - if there is no currently marked area, check the current cell Change-Id: I46608ae349f91f9f2e81a22dd55a817616ca3d3c Reviewed-on: https://gerrit.libreoffice.org/36160 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens --- sc/source/ui/view/tabvwshb.cxx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'sc/source') diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx index 52990c0f9428..0d5deada9a14 100644 --- a/sc/source/ui/view/tabvwshb.cxx +++ b/sc/source/ui/view/tabvwshb.cxx @@ -507,13 +507,35 @@ void ScTabViewShell::GetDrawInsState(SfxItemSet &rSet) rSet.DisableItem( nWhich ); break; - case SID_INSERT_GRAPHIC: case SID_INSERT_AVMEDIA: case SID_FONTWORK_GALLERY_FLOATER: if ( bTabProt || bShared ) rSet.DisableItem( nWhich ); break; + case SID_INSERT_GRAPHIC: + if (bTabProt || bShared) + { + // do not disable 'insert graphic' item if the currently marked area is editable (not protected) + // if there is no marked area, check the current cell + bool bDisableInsertImage = true; + ScMarkData& rMark = GetViewData().GetMarkData(); + if (!rMark.GetMarkedRanges().empty() && GetViewData().GetDocument()->IsSelectionEditable(rMark)) + bDisableInsertImage = false; + else + { + if (GetViewData().GetDocument()->IsBlockEditable + (GetViewData().GetTabNo(), GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetCurX(), GetViewData().GetCurY())) + { + bDisableInsertImage = false; + } + } + + if (bDisableInsertImage) + rSet.DisableItem(nWhich); + } + break; + case SID_LINKS: { if (GetViewData().GetDocument()->GetLinkManager()->GetLinks().empty()) -- cgit