[Libreoffice-commits] core.git: include/editeng svx/source

Armin Le Grand Armin.Le.Grand at cib.de
Fri Aug 11 06:52:41 UTC 2017


 include/editeng/editview.hxx  |    7 +++++++
 svx/source/svdraw/svdedxv.cxx |   39 ++++++++++++++++++++++-----------------
 2 files changed, 29 insertions(+), 17 deletions(-)

New commits:
commit 5131f5ba19ebc5de17139dbcf373866a9b155b2b
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date:   Thu Aug 10 20:08:56 2017 +0200

    editviewoverlay: corrected AttributeChange
    
    EditView on Overlay visualization needs to handle
    selection change when e.g. FontSize attribute of
    a selected text portion changes. Changed handling
    so that selection overlay is an integral part of
    text visualization overlay and refreshing text
    visualization always refreshes selection visuals,
    but not the other way around. Both anyways check
    for real change, so just extra testing is avoided
    which is still the better solution
    
    Change-Id: I3ce6570fd9a18a7c1d7ced4bc4ca9aeda57538e0
    Reviewed-on: https://gerrit.libreoffice.org/40993
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Armin Le Grand <Armin.Le.Grand at cib.de>

diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index 8b98d1f28360..84e41d4af2f2 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -92,7 +92,14 @@ public:
     EditViewCallbacks() {}
     virtual ~EditViewCallbacks();
 
+    // call this when text visualization changed in any way. It
+    // will also update selection, so no need to call this self
+    // additionally (but will also do no harm)
     virtual void EditViewInvalidate() const = 0;
+
+    // call this when only selection is changed. Text change will
+    // then *not* be checked and not be reacted on. Still, when
+    // only the selection is changed, this is useful and faster
     virtual void EditViewSelectionChange() const = 0;
 };
 
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index aa369a9e61d4..7cd8dc363b4b 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -395,7 +395,6 @@ namespace
 
     public:
         TextEditOverlayObject(
-            sdr::overlay::OverlaySelection* pOverlaySelection,
             const Color& rColor,
             OutlinerView& rOutlinerView,
             bool bVisualizeSurroundingFrame);
@@ -443,12 +442,11 @@ namespace
     }
 
     TextEditOverlayObject::TextEditOverlayObject(
-        sdr::overlay::OverlaySelection* pOverlaySelection,
         const Color& rColor,
         OutlinerView& rOutlinerView,
         bool bVisualizeSurroundingFrame)
     :   OverlayObject(rColor),
-        mpOverlaySelection(pOverlaySelection),
+        mpOverlaySelection(nullptr),
         mrOutlinerView(rOutlinerView),
         maLastRange(),
         maRange(),
@@ -458,6 +456,15 @@ namespace
     {
         // no AA for TextEdit overlay
         allowAntiAliase(false);
+
+        // create local OverlaySelection - this is an integral part of EditText
+        // visualization
+        const std::vector< basegfx::B2DRange > aEmptySelection;
+        mpOverlaySelection = new sdr::overlay::OverlaySelection(
+            sdr::overlay::OverlayType::Transparent,
+            rColor,
+            aEmptySelection,
+            true);
     }
 
     TextEditOverlayObject::~TextEditOverlayObject()
@@ -564,6 +571,10 @@ namespace
             // if there really *was* a change signal the OverlayManager to
             // refresh this object's visualization
             objectChange();
+
+            // on data change, always do a SelectionChange, too
+            // since the selection is an integral part of text visualization
+            checkSelectionChange();
         }
     }
 
@@ -596,7 +607,8 @@ namespace
 // TextEdit
 
 // callback from the active EditView, forward to evtl. existing instances of the
-// TextEditOverlayObject(s)
+// TextEditOverlayObject(s). This will additionally update the selection which
+// is an integral part of the text visualization
 void SdrObjEditView::EditViewInvalidate() const
 {
     if (IsTextEdit())
@@ -618,6 +630,9 @@ void SdrObjEditView::EditViewInvalidate() const
     }
 }
 
+// callback from the active EditView, forward to evtl. existing instances of the
+// TextEditOverlayObject(s). This cvall *only* updates the selection visualization
+// which is e.g. used when only the selection is changed, but not the text
 void SdrObjEditView::EditViewSelectionChange() const
 {
     if (IsTextEdit())
@@ -639,10 +654,9 @@ void SdrObjEditView::TextEditDrawing(SdrPaintWindow& rPaintWindow) const
     if (!comphelper::LibreOfficeKit::isActive())
     {
         // adapt all TextEditOverlayObject(s), so call EditViewInvalidate()
-        // and EditViewSelectionChange() to update accordingly. Suppress new
+        // to update accordingly (will update selection, too). Suppress new
         // stuff when LibreOficeKit is active
         EditViewInvalidate();
-        EditViewSelectionChange();
     }
     else
     {
@@ -1180,22 +1194,13 @@ bool SdrObjEditView::SdrBeginTextEdit(
                             rtl::Reference< sdr::overlay::OverlayManager > xManager = rPageWindow.GetOverlayManager();
                             if (xManager.is())
                             {
-                                const std::vector< basegfx::B2DRange > aEmptySelection;
-
-                                sdr::overlay::OverlaySelection* pNewOverlaySelection = new sdr::overlay::OverlaySelection(
-                                    sdr::overlay::OverlayType::Transparent,
-                                    aHilightColor,
-                                    aEmptySelection,
-                                    true);
-
-                                sdr::overlay::OverlayObject* pNewTextEditOverlayObject = new TextEditOverlayObject(
-                                    pNewOverlaySelection,
+                                TextEditOverlayObject* pNewTextEditOverlayObject = new TextEditOverlayObject(
                                     aHilightColor,
                                     *pTextEditOutlinerView,
                                     bVisualizeSurroundingFrame);
 
                                 xManager->add(*pNewTextEditOverlayObject);
-                                xManager->add(*pNewOverlaySelection);
+                                xManager->add(const_cast<sdr::overlay::OverlaySelection&>(*pNewTextEditOverlayObject->getOverlaySelection()));
 
                                 maTEOverlayGroup.append(pNewTextEditOverlayObject);
                             }


More information about the Libreoffice-commits mailing list