summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitEnums.h7
-rw-r--r--include/vcl/unohelp2.hxx6
-rw-r--r--sc/source/ui/view/editsh.cxx9
-rw-r--r--sd/source/ui/view/drviews2.cxx13
-rw-r--r--sw/source/uibase/shells/textsh1.cxx13
-rw-r--r--vcl/source/app/unohelp2.cxx13
6 files changed, 50 insertions, 11 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index cabea69a29be..79cc937e349c 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 27ab0973dd37..219244964eee 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 { namespace sun { namespace star { namespace datatransfer { namespace clipboard {
class XClipboard;
@@ -56,7 +59,8 @@ namespace vcl { namespace 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 61888c663ef4..03b282f942fb 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) { pViewData->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 269eb8ac065e..7bcf623b40df 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -2251,7 +2251,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 2d9ed1994727..a8389f3508ab 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -129,6 +129,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;
@@ -1358,10 +1359,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 832156788215..5cf0744467e5 100644
--- a/vcl/source/app/unohelp2.cxx
+++ b/vcl/source/app/unohelp2.cxx
@@ -40,7 +40,8 @@ namespace vcl { namespace 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 { namespace 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& )
{