From 1b1a066b935158dc029939520c8fe70b029cb311 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sat, 5 Nov 2022 21:16:29 +0300 Subject: lok: show Math selection Change-Id: I950ae3e5fb000d6acec4c26ff143b918a4e48a27 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142342 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- starmath/inc/cursor.hxx | 3 ++- starmath/inc/visitors.hxx | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) (limited to 'starmath/inc') diff --git a/starmath/inc/cursor.hxx b/starmath/inc/cursor.hxx index a1491c5decfe..0a8a35071f10 100644 --- a/starmath/inc/cursor.hxx +++ b/starmath/inc/cursor.hxx @@ -187,6 +187,7 @@ public: void Draw(OutputDevice& pDev, Point Offset, bool isCaretVisible); tools::Rectangle GetCaretRectangle(OutputDevice& rOutDev) const; + tools::Rectangle GetSelectionRectangle(OutputDevice& rOutDev) const; bool IsAtTailOfBracket(SmBracketType eBracketType) const; @@ -275,7 +276,7 @@ private: bool SetCaretPosition(SmCaretPos pos); /** Set selected on nodes of the tree */ - void AnnotateSelection(); + void AnnotateSelection() const; /** Clone list of nodes in a clipboard (creates a deep clone) */ static std::unique_ptr CloneList(SmClipboard& rClipboard); diff --git a/starmath/inc/visitors.hxx b/starmath/inc/visitors.hxx index b29bb26fb5b0..eaf329034c7d 100644 --- a/starmath/inc/visitors.hxx +++ b/starmath/inc/visitors.hxx @@ -424,31 +424,40 @@ private: }; -// SmSelectionDrawingVisitor +// SmSelectionRectanglesVisitor: collect selection -class SmSelectionDrawingVisitor final : public SmDefaultingVisitor +class SmSelectionRectanglesVisitor : public SmDefaultingVisitor { public: - /** Draws a selection on rDevice for the selection on pTree */ - SmSelectionDrawingVisitor( OutputDevice& rDevice, SmNode* pTree, const Point& rOffset ); - virtual ~SmSelectionDrawingVisitor() {} + SmSelectionRectanglesVisitor(OutputDevice& rDevice, SmNode* pTree); + virtual ~SmSelectionRectanglesVisitor() = default; void Visit( SmTextNode* pNode ) override; using SmDefaultingVisitor::Visit; + + const tools::Rectangle& GetSelection() { return maSelectionArea; } + private: /** Reference to drawing device */ OutputDevice& mrDev; - /** True if aSelectionArea have been initialized */ - bool mbHasSelectionArea; /** The current area that is selected */ tools::Rectangle maSelectionArea; /** Extend the area that must be selected */ - void ExtendSelectionArea(const tools::Rectangle& rArea); + void ExtendSelectionArea(const tools::Rectangle& rArea) { maSelectionArea.Union(rArea); } /** Default visiting method */ void DefaultVisit( SmNode* pNode ) override; /** Visit the children of a given pNode */ void VisitChildren( SmNode* pNode ); }; +// SmSelectionDrawingVisitor + +class SmSelectionDrawingVisitor final : public SmSelectionRectanglesVisitor +{ +public: + /** Draws a selection on rDevice for the selection on pTree */ + SmSelectionDrawingVisitor( OutputDevice& rDevice, SmNode* pTree, const Point& rOffset ); +}; + // SmNodeToTextVisitor /** Extract command text from pNodes */ -- cgit