diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-08-09 19:10:46 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-08-16 20:40:39 +0200 |
commit | b4d6ecc25162e56546ce52a38803e470023825e0 (patch) | |
tree | 1ca6a0fa2104f13bb05fb86058bab569c042c57f | |
parent | acb4a6dc1fb2b60a66dece73095eab026c9b93f3 (diff) |
editviewoverlay: correct reaction on property change
Do not hand over LogicalSelectionRanges directly on
selection change, better let the visulizer do what
he needs. On AttributeChange, tge resulting repaint
needs to refresh all OverlayObjects, not only text,
but also the selection to make look okay e.g. at
font size change
Change-Id: Ibb9737c33d6f85a9f68df3edbb989c0443cd4a5c
-rw-r--r-- | editeng/source/editeng/impedit.cxx | 20 | ||||
-rw-r--r-- | include/editeng/editview.hxx | 2 | ||||
-rw-r--r-- | include/svx/svdedxv.hxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdedxv.cxx | 36 |
4 files changed, 31 insertions, 29 deletions
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index 858fbc6f7e88..2b0b236696f6 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -175,24 +175,8 @@ void ImpEditView::SelectionChanged() { if (hasEditViewCallbacks()) { - std::vector<Rectangle> aLogicRects; - std::vector<basegfx::B2DRange> aLogicRanges; - const Size aLogicPixel(pOutWin ? pOutWin->PixelToLogic(Size(1, 1)) : Size(1, 1)); - - GetSelectionRectangles(GetEditSelection(), aLogicRects); - - for (const auto& aRect : aLogicRects) - { - // convert from logic Rectangles to logic Ranges, do not forget to add - // one Unit (in this case logical unit, thus calculate first) - aLogicRanges.push_back( - basegfx::B2DRange( - aRect.Left(), aRect.Top(), - aRect.Right() + aLogicPixel.Width(), aRect.Bottom() + aLogicPixel.Height())); - } - // use callback to tell about change in selection visualisation - mpEditViewCallbacks->EditViewSelectionChange(aLogicRanges); + mpEditViewCallbacks->EditViewSelectionChange(); } } @@ -207,7 +191,7 @@ void ImpEditView::SelectionChanged() // the Region*, see GetSelectionRectangles below. void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, OutputDevice* pTargetDevice ) { - if (hasEditViewCallbacks() && !pRegion) + if (hasEditViewCallbacks() && !pRegion && !comphelper::LibreOfficeKit::isActive()) { // we are done, do *not* visualize self // CAUTION: do not use when comphelper::LibreOfficeKit::isActive() diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx index 0fdb6f95be5f..fd9df8c420ce 100644 --- a/include/editeng/editview.hxx +++ b/include/editeng/editview.hxx @@ -93,7 +93,7 @@ public: virtual ~EditViewCallbacks(); virtual void EditViewInvalidate() const = 0; - virtual void EditViewSelectionChange(const std::vector<basegfx::B2DRange>& rLogicRanges) const = 0; + virtual void EditViewSelectionChange() const = 0; }; class EDITENG_DLLPUBLIC EditView diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx index 090f34994f58..037dbfe95219 100644 --- a/include/svx/svdedxv.hxx +++ b/include/svx/svdedxv.hxx @@ -64,7 +64,7 @@ class SVX_DLLPUBLIC SdrObjEditView: public SdrGlueEditView, public EditViewCallb // Now derived from EditViewCallbacks and overriding these callbacks to // allow own EditText visualization virtual void EditViewInvalidate() const override; - virtual void EditViewSelectionChange(const std::vector<basegfx::B2DRange>& rLogicRanges) const override; + virtual void EditViewSelectionChange() const override; // The OverlayObjects used for visualizing active TextEdit (currently // using TextEditOverlayObject, but not limitied to it diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index 7a8ad7cb4ef0..cdf17fad637b 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -346,7 +346,7 @@ namespace // data write access. In this OverlayObject we only have the // callback that triggers detecting if something *has* changed void checkDataChange(const basegfx::B2DRange& rMinTextEditArea); - void checkSelectionChange(const std::vector<basegfx::B2DRange>& rLogicRanges); + void checkSelectionChange(); }; drawinglayer::primitive2d::Primitive2DContainer TextEditOverlayObject::createOverlayObjectPrimitive2DSequence() @@ -501,11 +501,28 @@ namespace } } - void TextEditOverlayObject::checkSelectionChange(const std::vector<basegfx::B2DRange>& rLogicRanges) + void TextEditOverlayObject::checkSelectionChange() { - if (getOverlaySelection()) + if (getOverlaySelection() && getOverlayManager()) { - mpOverlaySelection->setRanges(rLogicRanges); + std::vector<Rectangle> aLogicRects; + std::vector<basegfx::B2DRange> aLogicRanges; + const Size aLogicPixel(getOverlayManager()->getOutputDevice().PixelToLogic(Size(1, 1))); + + // get logic selection + getOutlinerView().GetSelectionRectangles(aLogicRects); + + for (const auto& aRect : aLogicRects) + { + // convert from logic Rectangles to logic Ranges, do not forget to add + // one Unit (in this case logical units for one pixel, pre-calculated) + aLogicRanges.push_back( + basegfx::B2DRange( + aRect.Left() - aLogicPixel.Width(), aRect.Top() - aLogicPixel.Height(), + aRect.Right() + aLogicPixel.Width(), aRect.Bottom() + aLogicPixel.Height())); + } + + mpOverlaySelection->setRanges(aLogicRanges); } } } // end of anonymous namespace @@ -535,7 +552,7 @@ void SdrObjEditView::EditViewInvalidate() const } } -void SdrObjEditView::EditViewSelectionChange(const std::vector<basegfx::B2DRange>& rLogicRanges) const +void SdrObjEditView::EditViewSelectionChange() const { if (IsTextEdit()) { @@ -545,7 +562,7 @@ void SdrObjEditView::EditViewSelectionChange(const std::vector<basegfx::B2DRange if (pCandidate) { - pCandidate->checkSelectionChange(rLogicRanges); + pCandidate->checkSelectionChange(); } } } @@ -555,10 +572,11 @@ void SdrObjEditView::TextEditDrawing(SdrPaintWindow& rPaintWindow) const { if (!comphelper::LibreOfficeKit::isActive()) { - // adapt TextEditOverlayObject(s). Need also to do this here to - // update the current values accordingly. Suppress new stuff when - // LibreOficeKit is active + // adapt all TextEditOverlayObject(s), so call EditViewInvalidate() + // and EditViewSelectionChange() to update accordingly. Suppress new + // stuff when LibreOficeKit is active EditViewInvalidate(); + EditViewSelectionChange(); } else { |