sc/source/ui/view/tabvwshb.cxx |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

New commits:
commit 26030f92629b310e66b2335c2cec0413bb7ec828
Author: Bernhard Widl <bernhard.w...@cib.de>
Date:   Wed Apr 5 18:29:52 2017 +0200

    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 <thorsten.behr...@cib.de>
    Tested-by: Thorsten Behrens <thorsten.behr...@cib.de>

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())
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to