kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0215-editeng-add-EditView-GetSelectionRectangles.patch

f325b2
From f33f59871bc268dbfef6843a8196fe03d7419874 Mon Sep 17 00:00:00 2001
f325b2
From: Miklos Vajna <vmiklos@collabora.co.uk>
f325b2
Date: Tue, 13 Oct 2015 15:54:56 +0200
f325b2
Subject: [PATCH 215/398] editeng: add EditView::GetSelectionRectangles()
f325b2
f325b2
This gives sd access to the selection rectangles as well (as opposed
f325b2
only to the document model positions of selections).
f325b2
f325b2
Change-Id: Icb903e91f9e868573403b360bbe839705ddf2916
f325b2
(cherry picked from commit f7764214f2ab8aff030aaeb29efd693275822761)
f325b2
---
f325b2
 editeng/source/editeng/editview.cxx |  5 +++++
f325b2
 editeng/source/editeng/impedit.cxx  | 22 +++++++++++++++++-----
f325b2
 editeng/source/editeng/impedit.hxx  |  1 +
f325b2
 editeng/source/outliner/outlvw.cxx  |  5 +++++
f325b2
 include/editeng/editview.hxx        |  2 ++
f325b2
 include/editeng/outliner.hxx        |  1 +
f325b2
 6 files changed, 31 insertions(+), 5 deletions(-)
f325b2
f325b2
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
f325b2
index 049c5a1eb256..66a49ed925de 100644
f325b2
--- a/editeng/source/editeng/editview.cxx
f325b2
+++ b/editeng/source/editeng/editview.cxx
f325b2
@@ -264,6 +264,11 @@ SvtScriptType EditView::GetSelectedScriptType() const
f325b2
     return pImpEditView->pEditEngine->GetScriptType( pImpEditView->GetEditSelection() );
f325b2
 }
f325b2
 
f325b2
+void EditView::GetSelectionRectangles(std::vector<Rectangle>& rLogicRects) const
f325b2
+{
f325b2
+    return pImpEditView->GetSelectionRectangles(rLogicRects);
f325b2
+}
f325b2
+
f325b2
 void EditView::Paint( const Rectangle& rRect, OutputDevice* pTargetDevice )
f325b2
 {
f325b2
     pImpEditView->pEditEngine->pImpEditEngine->Paint( pImpEditView, rRect, pTargetDevice );
f325b2
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
f325b2
index 08d990b2d2ef..f7e2886c0524 100644
f325b2
--- a/editeng/source/editeng/impedit.cxx
f325b2
+++ b/editeng/source/editeng/impedit.cxx
f325b2
@@ -184,12 +184,10 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
f325b2
 
f325b2
     // pRegion: When not NULL, then only calculate Region.
f325b2
 
f325b2
+    vcl::Region* pOldRegion = pRegion;
f325b2
     vcl::Region aRegion;
f325b2
-    if (isTiledRendering())
f325b2
-    {
f325b2
-        assert(!pRegion);
f325b2
+    if (isTiledRendering() && !pRegion)
f325b2
         pRegion = &aRegion;
f325b2
-    }
f325b2
 
f325b2
     tools::PolyPolygon* pPolyPoly = NULL;
f325b2
     if ( pRegion )
f325b2
@@ -326,7 +324,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
f325b2
     {
f325b2
         *pRegion = vcl::Region( *pPolyPoly );
f325b2
 
f325b2
-        if (isTiledRendering())
f325b2
+        if (isTiledRendering() && !pOldRegion)
f325b2
         {
f325b2
             bool bMm100ToTwip = pOutWin->GetMapMode().GetMapUnit() == MAP_100TH_MM;
f325b2
             OString sRectangle;
f325b2
@@ -380,6 +378,20 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
f325b2
     }
f325b2
 }
f325b2
 
f325b2
+void ImpEditView::GetSelectionRectangles(std::vector<Rectangle>& rLogicRects)
f325b2
+{
f325b2
+    bool bMm100ToTwip = pOutWin->GetMapMode().GetMapUnit() == MAP_100TH_MM;
f325b2
+    vcl::Region aRegion;
f325b2
+    DrawSelection(aEditSelection, &aRegion);
f325b2
+    aRegion.GetRegionRectangles(rLogicRects);
f325b2
+
f325b2
+    for (Rectangle& rRectangle : rLogicRects)
f325b2
+    {
f325b2
+        if (bMm100ToTwip)
f325b2
+            rRectangle = OutputDevice::LogicToLogic(rRectangle, MAP_100TH_MM, MAP_TWIP);
f325b2
+    }
f325b2
+}
f325b2
+
f325b2
 void ImpEditView::ImplDrawHighlightRect( OutputDevice* _pTarget, const Point& rDocPosTopLeft, const Point& rDocPosBottomRight, tools::PolyPolygon* pPolyPoly )
f325b2
 {
f325b2
     if ( rDocPosTopLeft.X() != rDocPosBottomRight.X() )
f325b2
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
f325b2
index 4866523f5171..7b24e6e790b7 100644
f325b2
--- a/editeng/source/editeng/impedit.hxx
f325b2
+++ b/editeng/source/editeng/impedit.hxx
f325b2
@@ -319,6 +319,7 @@ public:
f325b2
 
f325b2
     void            DrawSelection() { DrawSelection( aEditSelection ); }
f325b2
     void            DrawSelection( EditSelection, vcl::Region* pRegion = NULL, OutputDevice* pTargetDevice = NULL );
f325b2
+    void GetSelectionRectangles(std::vector<Rectangle>& rLogicRects);
f325b2
 
f325b2
     vcl::Window*         GetWindow() const           { return pOutWin; }
f325b2
 
f325b2
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
f325b2
index 92f967877e24..329b5f3c0ed4 100644
f325b2
--- a/editeng/source/outliner/outlvw.cxx
f325b2
+++ b/editeng/source/outliner/outlvw.cxx
f325b2
@@ -1213,6 +1213,11 @@ void OutlinerView::SetSelection( const ESelection& rSel )
f325b2
     pEditView->SetSelection( rSel );
f325b2
 }
f325b2
 
f325b2
+void OutlinerView::GetSelectionRectangles(std::vector<Rectangle>& rLogicRects) const
f325b2
+{
f325b2
+    pEditView->GetSelectionRectangles(rLogicRects);
f325b2
+}
f325b2
+
f325b2
 void OutlinerView::SetReadOnly( bool bReadOnly )
f325b2
 {
f325b2
     pEditView->SetReadOnly( bReadOnly );
f325b2
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
f325b2
index bb091172c9ba..41146fac63a5 100644
f325b2
--- a/include/editeng/editview.hxx
f325b2
+++ b/include/editeng/editview.hxx
f325b2
@@ -114,6 +114,8 @@ public:
f325b2
     ESelection      GetSelection() const;
f325b2
     void            SetSelection( const ESelection& rNewSel );
f325b2
     bool            SelectCurrentWord( sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
f325b2
+    /// Returns the rectangles of the current selection in TWIPs.
f325b2
+    void GetSelectionRectangles(std::vector<Rectangle>& rLogicRects) const;
f325b2
 
f325b2
     bool            IsInsertMode() const;
f325b2
     void            SetInsertMode( bool bInsert );
f325b2
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
f325b2
index 5a2dbe9f8cf9..dddb221ec9cc 100644
f325b2
--- a/include/editeng/outliner.hxx
f325b2
+++ b/include/editeng/outliner.hxx
f325b2
@@ -310,6 +310,7 @@ public:
f325b2
 
f325b2
     void        SetVisArea( const Rectangle& rRect );
f325b2
     void        SetSelection( const ESelection& );
f325b2
+    void GetSelectionRectangles(std::vector<Rectangle>& rLogicRects) const;
f325b2
 
f325b2
     void        RemoveAttribs( bool bRemoveParaAttribs = false, sal_uInt16 nWhich = 0, bool bKeepLanguages = false );
f325b2
     void        RemoveAttribsKeepLanguages( bool bRemoveParaAttribs );
f325b2
-- 
f325b2
2.12.0
f325b2