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

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