diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2022-11-05 21:16:29 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-11-05 23:37:35 +0100 |
commit | 1b1a066b935158dc029939520c8fe70b029cb311 (patch) | |
tree | 037c031d6bda8dc59cd2fce809277ab72bca3d07 /starmath/inc | |
parent | d90bf6f8c19d7c43ec83656a3a6f85a81aee573c (diff) |
lok: show Math selection
Change-Id: I950ae3e5fb000d6acec4c26ff143b918a4e48a27
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142342
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'starmath/inc')
-rw-r--r-- | starmath/inc/cursor.hxx | 3 | ||||
-rw-r--r-- | starmath/inc/visitors.hxx | 25 |
2 files changed, 19 insertions, 9 deletions
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<SmNodeList> 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 */ |