Blame SOURCES/0154-sw-implement-per-view-LOK_CALLBACK_TEXT_SELECTION.patch

135360
From 4cb2a43c66b393ffd28d91e5fb27d782eaf7acb0 Mon Sep 17 00:00:00 2001
135360
From: Miklos Vajna <vmiklos@collabora.co.uk>
135360
Date: Fri, 18 Sep 2015 14:29:18 +0200
135360
Subject: [PATCH 154/398] sw: implement per-view LOK_CALLBACK_TEXT_SELECTION
135360
135360
Also:
135360
135360
- let the unit test set the global LOK flag, as sw code now depends on
135360
  that
135360
- in framework, don't return early after emitting the LOK status
135360
  indicator callback, otherwise CppunitTest_sw_tiledrendering shows how
135360
  sw LOK callbacks are missing
135360
135360
Change-Id: I0c4ac12f2ef5118d29afd131676bcb27d5db7746
135360
(cherry picked from commit 1a83f30ebe2c56b00804ce774537b34f1049be84)
135360
---
135360
 framework/source/helper/statusindicator.cxx    |  2 --
135360
 sw/qa/extras/tiledrendering/tiledrendering.cxx |  4 ++++
135360
 sw/source/core/crsr/viscrs.cxx                 | 26 ++++++++++++++++++++------
135360
 3 files changed, 24 insertions(+), 8 deletions(-)
135360
135360
diff --git a/framework/source/helper/statusindicator.cxx b/framework/source/helper/statusindicator.cxx
135360
index 5c9dafc5ba81..ce8310a07cf5 100644
135360
--- a/framework/source/helper/statusindicator.cxx
135360
+++ b/framework/source/helper/statusindicator.cxx
135360
@@ -43,7 +43,6 @@ void SAL_CALL StatusIndicator::start(const OUString& sText ,
135360
         m_nLastCallbackPercent = -1;
135360
 
135360
         comphelper::LibreOfficeKit::statusIndicatorStart();
135360
-        return;
135360
     }
135360
 
135360
     css::uno::Reference< css::task::XStatusIndicatorFactory > xFactory(m_xFactory);
135360
@@ -60,7 +59,6 @@ void SAL_CALL StatusIndicator::end()
135360
     if (comphelper::LibreOfficeKit::isActive())
135360
     {
135360
         comphelper::LibreOfficeKit::statusIndicatorFinish();
135360
-        return;
135360
     }
135360
 
135360
     css::uno::Reference< css::task::XStatusIndicatorFactory > xFactory(m_xFactory);
135360
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
135360
index 07dd7e34b29c..e7ab14942f79 100644
135360
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
135360
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
135360
@@ -383,6 +383,8 @@ void SwTiledRenderingTest::testSearchViewArea()
135360
 void SwTiledRenderingTest::testSearchTextFrame()
135360
 {
135360
 #if !defined(WNT) && !defined(MACOSX)
135360
+    comphelper::LibreOfficeKit::setActive();
135360
+
135360
     SwXTextDocument* pXTextDocument = createDoc("search.odt");
135360
     pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this);
135360
     uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
135360
@@ -393,6 +395,8 @@ void SwTiledRenderingTest::testSearchTextFrame()
135360
     comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
135360
     // This was empty: nothing was highlighted after searching for 'TextFrame'.
135360
     CPPUNIT_ASSERT(!m_aTextSelection.isEmpty());
135360
+
135360
+    comphelper::LibreOfficeKit::setActive(false);
135360
 #endif
135360
 }
135360
 
135360
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
135360
index 13cfcd89b22b..808756159545 100644
135360
--- a/sw/source/core/crsr/viscrs.cxx
135360
+++ b/sw/source/core/crsr/viscrs.cxx
135360
@@ -361,7 +361,7 @@ void SwSelPaintRects::Show(std::vector<OString>* pSelectionRectangles)
135360
         // talks about "the" cursor at the moment. As long as that's true,
135360
         // don't say anything about the Writer cursor till a draw object is
135360
         // being edited.
135360
-        if (GetShell()->isTiledRendering() && !pView->GetTextEditObject())
135360
+        if (comphelper::LibreOfficeKit::isActive() && !pView->GetTextEditObject())
135360
         {
135360
             if (!empty())
135360
             {
135360
@@ -377,12 +377,18 @@ void SwSelPaintRects::Show(std::vector<OString>* pSelectionRectangles)
135360
                 if (aStartRect.HasArea())
135360
                 {
135360
                     OString sRect = aStartRect.SVRect().toString();
135360
-                    GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_START, sRect.getStr());
135360
+                    if (comphelper::LibreOfficeKit::isViewCallback())
135360
+                        GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_START, sRect.getStr());
135360
+                    else
135360
+                        GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_START, sRect.getStr());
135360
                 }
135360
                 if (aEndRect.HasArea())
135360
                 {
135360
                     OString sRect = aEndRect.SVRect().toString();
135360
-                    GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_END, sRect.getStr());
135360
+                    if (comphelper::LibreOfficeKit::isViewCallback())
135360
+                        GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_END, sRect.getStr());
135360
+                    else
135360
+                        GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_END, sRect.getStr());
135360
                 }
135360
             }
135360
 
135360
@@ -396,7 +402,12 @@ void SwSelPaintRects::Show(std::vector<OString>* pSelectionRectangles)
135360
             }
135360
             OString sRect = ss.str().c_str();
135360
             if (!pSelectionRectangles)
135360
-                GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
135360
+            {
135360
+                if (comphelper::LibreOfficeKit::isViewCallback())
135360
+                    GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
135360
+                else
135360
+                    GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
135360
+            }
135360
             else
135360
                 pSelectionRectangles->push_back(sRect);
135360
         }
135360
@@ -593,7 +604,7 @@ void SwShellCrsr::Show()
135360
             pShCrsr->SwSelPaintRects::Show(&aSelectionRectangles);
135360
     }
135360
 
135360
-    if (GetShell()->isTiledRendering())
135360
+    if (comphelper::LibreOfficeKit::isActive())
135360
     {
135360
         std::stringstream ss;
135360
         bool bFirst = true;
135360
@@ -609,7 +620,10 @@ void SwShellCrsr::Show()
135360
             ss << rSelectionRectangle.getStr();
135360
         }
135360
         OString sRect = ss.str().c_str();
135360
-        GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
135360
+        if (comphelper::LibreOfficeKit::isViewCallback())
135360
+            GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
135360
+        else
135360
+            GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
135360
     }
135360
 }
135360
 
135360
-- 
135360
2.12.0
135360