sd/source/ui/view/Outliner.cxx |   53 +++++++++++++++++++++++++++++++++++------
 1 file changed, 46 insertions(+), 7 deletions(-)

New commits:
commit de432c0af127cc42a75292ec2288c13cbe0f1a44
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Mon Jun 13 18:11:04 2016 +0200

    sd: implement per-view LOK_CALLBACK_SEARCH_RESULT_SELECTION
    
    This way views can search without disturbing each other.
    
    Change-Id: I40e69b6102a959ef1f1825a7af1438c2f2fcf807
    Reviewed-on: https://gerrit.libreoffice.org/26227
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>
    Tested-by: Jenkins <c...@libreoffice.org>

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index de41df2..12bbfe3 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -670,7 +670,13 @@ bool Outliner::SearchAndReplaceAll()
             std::stringstream aStream;
             boost::property_tree::write_json(aStream, aTree);
             OString aPayload = aStream.str().c_str();
-            
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION,
 aPayload.getStr());
+            if (comphelper::LibreOfficeKit::isViewCallback())
+            {
+                SfxViewShell& rSfxViewShell = pViewShell->GetViewShellBase();
+                
rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, 
aPayload.getStr());
+            }
+            else
+                
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION,
 aPayload.getStr());
         }
     }
 
@@ -680,7 +686,13 @@ bool Outliner::SearchAndReplaceAll()
     {
         // Find-all, tiled rendering and we have at least one match.
         OString aPayload = OString::number(mnStartPageIndex);
-        pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, 
aPayload.getStr());
+        if (comphelper::LibreOfficeKit::isViewCallback())
+        {
+            SfxViewShell& rSfxViewShell = pViewShell->GetViewShellBase();
+            rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SET_PART, 
aPayload.getStr());
+        }
+        else
+            
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, 
aPayload.getStr());
 
         // Emit a selection callback here:
         // 1) The original one is no longer valid, as we there was a SET_PART 
in between
@@ -693,7 +705,13 @@ bool Outliner::SearchAndReplaceAll()
                 aRectangles.push_back(rSelection.m_aRectangles);
         }
         OString sRectangles = comphelper::string::join("; ", aRectangles);
-        
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, 
sRectangles.getStr());
+        if (comphelper::LibreOfficeKit::isViewCallback())
+        {
+            SfxViewShell& rSfxViewShell = pViewShell->GetViewShellBase();
+            
rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, 
sRectangles.getStr());
+        }
+        else
+            
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, 
sRectangles.getStr());
     }
 
     mnStartPageIndex = (sal_uInt16)-1;
@@ -799,7 +817,13 @@ bool 
Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections)
         {
             // notify LibreOfficeKit about changed page
             OString aPayload = OString::number(maCurrentPosition.mnPageIndex);
-            
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, 
aPayload.getStr());
+            if (comphelper::LibreOfficeKit::isViewCallback())
+            {
+                SfxViewShell& rSfxViewShell = pViewShell->GetViewShellBase();
+                
rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SET_PART, 
aPayload.getStr());
+            }
+            else
+                
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, 
aPayload.getStr());
 
             // also about search result selections
             boost::property_tree::ptree aTree;
@@ -816,7 +840,13 @@ bool 
Outliner::SearchAndReplaceOnce(std::vector<SearchSelection>* pSelections)
             std::stringstream aStream;
             boost::property_tree::write_json(aStream, aTree);
             aPayload = aStream.str().c_str();
-            
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION,
 aPayload.getStr());
+            if (comphelper::LibreOfficeKit::isViewCallback())
+            {
+                SfxViewShell& rSfxViewShell = pViewShell->GetViewShellBase();
+                
rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, 
aPayload.getStr());
+            }
+            else
+                
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION,
 aPayload.getStr());
         }
         else
         {
@@ -1164,8 +1194,17 @@ void Outliner::ShowEndOfSearchDialog()
         if (!mbStringFound)
         {
             SvxSearchDialogWrapper::SetSearchLabel(SL_NotFound);
-            
mpDrawDocument->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_NOT_FOUND,
-                    mpSearchItem->GetSearchString().toUtf8().getStr());
+            if (comphelper::LibreOfficeKit::isViewCallback())
+            {
+                std::shared_ptr<ViewShell> pViewShell(mpWeakViewShell.lock());
+                if (pViewShell)
+                {
+                    SfxViewShell& rSfxViewShell = 
pViewShell->GetViewShellBase();
+                    
rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_NOT_FOUND, 
mpSearchItem->GetSearchString().toUtf8().getStr());
+                }
+            }
+            else
+                
mpDrawDocument->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_NOT_FOUND, 
mpSearchItem->GetSearchString().toUtf8().getStr());
         }
 
         // don't do anything else for search
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to