Blob Blame History Raw
From 303f6bd02ad4cbaec4caf67682da5aed87b2ccaa Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.co.uk>
Date: Wed, 14 Oct 2015 12:32:12 +0200
Subject: [PATCH 207/398] sd tiled rendering: search rectangle is part-specific

Change-Id: I88865db539779bc401550d7b4a3729b89d7e18b1
(cherry picked from commit dd1fc2242a64a0b9ae8031a5edc7ecfcde4ec3df)
---
 sd/inc/Outliner.hxx            | 16 +++++++++++++++-
 sd/source/ui/view/Outliner.cxx | 16 +++++++++++-----
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/sd/inc/Outliner.hxx b/sd/inc/Outliner.hxx
index f01e244de308..9f1f6aae3e8a 100644
--- a/sd/inc/Outliner.hxx
+++ b/sd/inc/Outliner.hxx
@@ -41,6 +41,20 @@ class View;
 class ViewShell;
 class Window;
 
+/// Describes a single search hit: a set of rectangles on a given page.
+struct SearchSelection
+{
+    /// 0-based index of the page that has the selection.
+    int m_nPage;
+    /**
+     * List of selection rectangles in twips -- multiple rectangles only in
+     * case the selection spans over more layout lines.
+     */
+    OString m_aRectangles;
+
+    SearchSelection(int nPage, const OString& rRectangles);
+};
+
 /** The main purpose of this class is searching and replacing as well as
     spelling of impress documents.  The main part of both tasks lies in
     iterating over the pages and view modes of a document and apply the
@@ -364,7 +378,7 @@ private:
             The return value specifies whether the search ended (</sal_True>) or
             another call to this method is required (</sal_False>).
     */
-    bool SearchAndReplaceOnce(std::vector<OString>* pSelections = 0);
+    bool SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections = 0);
 
     /** Detect changes of the document or view and react accordingly.  Such
         changes may occur because different calls to
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index e02e879494b8..22db187ab7c8 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -83,6 +83,12 @@ class SfxStyleSheetPool;
 
 namespace sd {
 
+SearchSelection::SearchSelection(int nPage, const OString& rRectangles)
+    : m_nPage(nPage),
+    m_aRectangles(rRectangles)
+{
+}
+
 class Outliner::Implementation
 {
 public:
@@ -621,7 +627,7 @@ bool Outliner::SearchAndReplaceAll()
 
         // Search/replace until the end of the document is reached.
         bool bFoundMatch;
-        std::vector<OString> aSelections;
+        std::vector<SearchSelection> aSelections;
         do
         {
             bFoundMatch = ! SearchAndReplaceOnce(&aSelections);
@@ -634,10 +640,10 @@ bool Outliner::SearchAndReplaceAll()
             aTree.put("searchString", mpSearchItem->GetSearchString().toUtf8().getStr());
 
             boost::property_tree::ptree aChildren;
-            for (const OString& rSelection : aSelections)
+            for (const SearchSelection& rSelection : aSelections)
             {
                 boost::property_tree::ptree aChild;
-                aChild.put("", rSelection.getStr());
+                aChild.put("", rSelection.m_aRectangles.getStr());
                 aChildren.push_back(std::make_pair("", aChild));
             }
             aTree.add_child("searchResultSelection", aChildren);
@@ -655,7 +661,7 @@ bool Outliner::SearchAndReplaceAll()
     return true;
 }
 
-bool Outliner::SearchAndReplaceOnce(std::vector<OString>* pSelections)
+bool Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections)
 {
     DetectChange ();
 
@@ -775,7 +781,7 @@ bool Outliner::SearchAndReplaceOnce(std::vector<OString>* pSelections)
         }
         else
         {
-            pSelections->push_back(sRectangles);
+            pSelections->push_back(SearchSelection(maCurrentPosition.mnPageIndex, sRectangles));
         }
     }
 
-- 
2.12.0