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

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