[Libreoffice-commits] core.git: include/LibreOfficeKit include/vcl sc/source sd/source sw/source vcl/source

gokaysatir (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 6 16:48:21 UTC 2020


 include/LibreOfficeKit/LibreOfficeKitEnums.h |    7 +++----
 include/vcl/unohelp2.hxx                     |    6 +++++-
 sc/source/ui/view/editsh.cxx                 |    9 ++++++++-
 sd/source/ui/view/drviews2.cxx               |   13 ++++++++++++-
 sw/source/uibase/shells/textsh1.cxx          |   13 ++++++++++---
 vcl/source/app/unohelp2.cxx                  |   13 ++++++++++++-
 6 files changed, 50 insertions(+), 11 deletions(-)

New commits:
commit 19a0fbf456129e011cb9ab9ab6ab730cba274bbd
Author:     gokaysatir <gokaysatir at collabora.com>
AuthorDate: Tue Sep 22 13:00:44 2020 +0300
Commit:     Gökay ŞATIR <gokaysatir at collabora.com>
CommitDate: Tue Oct 6 18:47:39 2020 +0200

    Online: Copy hyperlink location. / Core side.
    
    Payload format is added to LOK_CALLBACK_CLIPBOARD_CHANGED.
    Clipboard changed event is not fired when "copy hyperlink location" command is issued.
    So i added a call to LOK_CALLBACK_CLIPBOARD_CHANGED inside TextDataObject::CopyStringTo function.
    
    Change-Id: I8157572288da88b5522662e13abe151ef8548b34
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103164
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103872
    Tested-by: Jenkins

diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 750e64f529f9..9a0eb01ca840 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -644,10 +644,9 @@ typedef enum
      * Notification that the clipboard contents have changed.
      * Typically fired in response to copying to clipboard.
      *
-     * The payload currently is empty and it's up to the
-     * client to get the contents, if necessary. However,
-     * in the future the contents might be included for
-     * convenience.
+     * Payload is optional. When payload is empty, Online gets string from selected text.
+     * Payload format is JSON.
+     * Example: { "mimeType": "string", "content": "some content" }
      */
     LOK_CALLBACK_CLIPBOARD_CHANGED = 38,
 
diff --git a/include/vcl/unohelp2.hxx b/include/vcl/unohelp2.hxx
index a95474417cf6..91c4ce6ce0e2 100644
--- a/include/vcl/unohelp2.hxx
+++ b/include/vcl/unohelp2.hxx
@@ -25,6 +25,9 @@
 #include <rtl/ustring.hxx>
 #include <osl/mutex.hxx>
 #include <vcl/dllapi.h>
+#include <comphelper/lok.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <boost/property_tree/json_parser.hpp>
 
 namespace com::sun::star::datatransfer::clipboard {
     class XClipboard;
@@ -56,7 +59,8 @@ namespace vcl::unohelper {
         /// copies a given string to a given clipboard
         static  void    CopyStringTo(
             const OUString& rContent,
-            const css::uno::Reference< css::datatransfer::clipboard::XClipboard >& rxClipboard
+            const css::uno::Reference< css::datatransfer::clipboard::XClipboard >& rxClipboard,
+            std::function<void (int, const char*)> *callback = nullptr
         );
     };
 
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 9e8768fe27d6..83e4adaf815f 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -641,7 +641,14 @@ void ScEditShell::Execute( SfxRequest& rReq )
                 {
                     uno::Reference<datatransfer::clipboard::XClipboard> xClipboard
                         = pEditView->GetWindow()->GetClipboard();
-                    vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard);
+
+                    if (comphelper::LibreOfficeKit::isActive())
+                    {
+                        std::function<void (int, const char*)> callback = [&] (int callbackType, const char* text) { rViewData.GetViewShell()->libreOfficeKitViewCallback(callbackType, text); } ;
+                        vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard, &callback);
+                    }
+                    else
+                        vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard, nullptr);
                 }
             }
         break;
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 8f511aab3922..f32acb5d3182 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -2250,7 +2250,18 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
                 {
                     uno::Reference<datatransfer::clipboard::XClipboard> xClipboard
                         = pOutView->GetWindow()->GetClipboard();
-                    vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard);
+
+                    if (comphelper::LibreOfficeKit::isActive())
+                    {
+                        std::function<void (int, const char*)> callback = [&] (int callbackType, const char* text)
+                        {
+                            SfxViewFrame* pFrame = GetViewFrame();
+                            pFrame->GetViewShell()->libreOfficeKitViewCallback(callbackType, text);
+                        };
+                        vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard, &callback);
+                    }
+                    else
+                        vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard);
                 }
             }
 
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index 8944d9c8e5bc..14844e1134c1 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -100,6 +100,7 @@
 #include <bookmrk.hxx>
 #include <linguistic/misc.hxx>
 #include <editeng/splwrap.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
 using namespace ::com::sun::star;
 using namespace com::sun::star::beans;
@@ -1349,10 +1350,16 @@ void SwTextShell::Execute(SfxRequest &rReq)
             const SwFormatINetFormat& rINetFormat = dynamic_cast<const SwFormatINetFormat&>( aSet.Get(RES_TXTATR_INETFMT) );
             if( nSlot == SID_COPY_HYPERLINK_LOCATION )
             {
+                OUString hyperlinkLocation = rINetFormat.GetValue();
                 ::uno::Reference< datatransfer::clipboard::XClipboard > xClipboard = GetView().GetEditWin().GetClipboard();
-                vcl::unohelper::TextDataObject::CopyStringTo(
-                        rINetFormat.GetValue(),
-                        xClipboard );
+
+                if (comphelper::LibreOfficeKit::isActive())
+                {
+                    std::function<void (int, const char*)> callback = [&] (int callbackType, const char* text) { GetView().libreOfficeKitViewCallback(callbackType, text); } ;
+                    vcl::unohelper::TextDataObject::CopyStringTo(hyperlinkLocation, xClipboard, &callback );
+                }
+                else
+                    vcl::unohelper::TextDataObject::CopyStringTo(hyperlinkLocation, xClipboard, nullptr );
             }
             else
                 rWrtSh.ClickToINetAttr(rINetFormat);
diff --git a/vcl/source/app/unohelp2.cxx b/vcl/source/app/unohelp2.cxx
index 9005467d90e4..8e33aeefc55a 100644
--- a/vcl/source/app/unohelp2.cxx
+++ b/vcl/source/app/unohelp2.cxx
@@ -40,7 +40,8 @@ namespace vcl::unohelper {
     }
 
     void TextDataObject::CopyStringTo( const OUString& rContent,
-        const uno::Reference< datatransfer::clipboard::XClipboard >& rxClipboard )
+        const uno::Reference< datatransfer::clipboard::XClipboard >& rxClipboard,
+        std::function<void (int, const char*)> *callback)
     {
         SAL_WARN_IF( !rxClipboard.is(), "vcl", "TextDataObject::CopyStringTo: invalid clipboard!" );
         if ( !rxClipboard.is() )
@@ -56,6 +57,16 @@ namespace vcl::unohelper {
             uno::Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( rxClipboard, uno::UNO_QUERY );
             if( xFlushableClipboard.is() )
                 xFlushableClipboard->flushClipboard();
+
+            if (callback != nullptr && comphelper::LibreOfficeKit::isActive())
+            {
+                boost::property_tree::ptree aTree;
+                aTree.put("content", rContent);
+                aTree.put("mimeType", "text/plain");
+                std::stringstream aStream;
+                boost::property_tree::write_json(aStream, aTree);
+                (*callback)(LOK_CALLBACK_CLIPBOARD_CHANGED, aStream.str().c_str());
+            }
         }
         catch( const uno::Exception& )
         {


More information about the Libreoffice-commits mailing list