sw/sdi/_grfsh.sdi                            |    1 
 sw/source/core/crsr/contentcontrolbutton.cxx |   39 +++++++++++++++------------
 2 files changed, 23 insertions(+), 17 deletions(-)

New commits:
commit c45b788517c9db9f8f3c0294ef3f8fdaae890815
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Fri Jul 1 11:40:10 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Jul 4 08:06:40 2022 +0200

    sw content controls: fix picture placeholders
    
    This went wrong in commit c321498f915f4e8b3f4853232860ce040ab48e46 (sw
    content controls: reject typing inside checkbox or picture content
    controls, 2022-06-10), now a freshly inserted picture content control is
    not replaced with an image on click.
    
    The problem is that we want to forbid typing into a picture content
    control (it should only host a single as-char image), but changing the
    picture's bitmap is meant to be still possible.
    
    Fix the problem by allowing SID_CHANGE_PICTURE even if the cursor is
    protected: this allows changing the picture again, and a real read-only
    document still doesn't show the "change" menu item in its context menu.
    
    If we later find some other corner-case where this command should be
    still disabled, we can extend SwGrfShell::GetAttrState(), similar to how
    e.g. inserting images in input fields is disabled there.
    
    (cherry picked from commit c769c369c87a46ec877b7eefee27988044a2798f)
    
    Change-Id: I8b55e930330b9748ecda950dedae907b86c57e2f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136746
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/sdi/_grfsh.sdi b/sw/sdi/_grfsh.sdi
index 8291745966bb..5475017d448e 100644
--- a/sw/sdi/_grfsh.sdi
+++ b/sw/sdi/_grfsh.sdi
@@ -63,7 +63,6 @@ interface BaseTextGraphic
     [
         ExecMethod = Execute ;
         StateMethod = GetAttrState ;
-        DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
     ]
 
     SID_EXTERNAL_EDIT
commit 40a9a7e15c6131f903ea5ea9ed2fa44323098485
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Fri Jul 1 09:02:27 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Jul 4 08:06:19 2022 +0200

    sw content controls, dropdown: use DecorationView for the button's arrow
    
    Instead of drawing manually, which was the way form field dropdowns did
    it. Also enable anti-aliasing.
    
    (cherry picked from commit 48010539f695bc269034f12cf72aa0665cca10de)
    
    Change-Id: Ia1ab5fe6168e0fb51dba3c760301764cfd1e0514
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136745
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/source/core/crsr/contentcontrolbutton.cxx 
b/sw/source/core/crsr/contentcontrolbutton.cxx
index 00deb260981c..34cbd38e663a 100644
--- a/sw/source/core/crsr/contentcontrolbutton.cxx
+++ b/sw/source/core/crsr/contentcontrolbutton.cxx
@@ -11,8 +11,10 @@
 
 #include <vcl/weldutils.hxx>
 #include <vcl/event.hxx>
+#include <vcl/decoview.hxx>
 
 #include <edtwin.hxx>
+#include <dview.hxx>
 
 SwContentControlButton::SwContentControlButton(
     SwEditWin* pEditWin, const std::shared_ptr<SwContentControl>& 
pContentControl)
@@ -107,7 +109,7 @@ void SwContentControlButton::Paint(vcl::RenderContext& 
rRenderContext, const too
 
     // Draw the button next to the frame
     Point aButtonPos(aFrameRect.TopLeft());
-    aButtonPos.AdjustX(aFrameRect.GetSize().getWidth() - 1);
+    aButtonPos.AdjustX(aFrameRect.GetSize().getWidth() - nPadding * 2);
     Size aButtonSize(aFrameRect.GetSize());
     aButtonSize.setWidth(GetSizePixel().getWidth() - aFrameRect.getWidth() - 
nPadding);
     const tools::Rectangle aButtonRect(tools::Rectangle(aButtonPos, 
aButtonSize));
@@ -118,21 +120,26 @@ void SwContentControlButton::Paint(vcl::RenderContext& 
rRenderContext, const too
     rRenderContext.DrawRect(aButtonRect);
 
     // the arrowhead
-    rRenderContext.SetLineColor(aLineColor);
-    rRenderContext.SetFillColor(aLineColor);
-
-    Point aCenter(aButtonPos.X() + (aButtonSize.Width() / 2),
-                  aButtonPos.Y() + (aButtonSize.Height() / 2));
-    tools::Long nMinWidth = 4;
-    tools::Long nMinHeight = 2;
-    Size aArrowSize(std::max(aButtonSize.Width() / 4, nMinWidth),
-                    std::max(aButtonSize.Height() / 10, nMinHeight));
-
-    tools::Polygon aPoly(3);
-    aPoly.SetPoint(Point(aCenter.X() - aArrowSize.Width(), aCenter.Y() - 
aArrowSize.Height()), 0);
-    aPoly.SetPoint(Point(aCenter.X() + aArrowSize.Width(), aCenter.Y() - 
aArrowSize.Height()), 1);
-    aPoly.SetPoint(Point(aCenter.X(), aCenter.Y() + aArrowSize.Height()), 2);
-    rRenderContext.DrawPolygon(aPoly);
+    DecorationView aDecoView(&rRenderContext);
+    tools::Rectangle aSymbolRect(aButtonRect);
+    // 20% distance to the left and right button border
+    const tools::Long nBorderDistanceLeftAndRight = aSymbolRect.GetWidth() / 4;
+    aSymbolRect.AdjustLeft(nBorderDistanceLeftAndRight);
+    aSymbolRect.AdjustRight(-nBorderDistanceLeftAndRight);
+    // 20% distance to the top and bottom button border
+    const tools::Long nBorderDistanceTopAndBottom = aSymbolRect.GetHeight() / 
4;
+    aSymbolRect.AdjustTop(nBorderDistanceTopAndBottom);
+    aSymbolRect.AdjustBottom(-nBorderDistanceTopAndBottom);
+    AntialiasingFlags eAntialiasing = rRenderContext.GetAntialiasing();
+    if (SwDrawView::IsAntiAliasing())
+    {
+        rRenderContext.SetAntialiasing(eAntialiasing | 
AntialiasingFlags::Enable);
+    }
+    aDecoView.DrawSymbol(aSymbolRect, SymbolType::SPIN_DOWN, GetTextColor(), 
DrawSymbolFlags::NONE);
+    if (SwDrawView::IsAntiAliasing())
+    {
+        rRenderContext.SetAntialiasing(eAntialiasing);
+    }
 }
 
 WindowHitTest SwContentControlButton::ImplHitTest(const Point& rFramePos)

Reply via email to