[Libreoffice-commits] core.git: 3 commits - desktop/qa desktop/source libreofficekit/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Mon Oct 26 14:40:57 UTC 2015
desktop/qa/desktop_lib/test_desktop_lib.cxx | 3 ++
desktop/source/lib/lokclipboard.cxx | 11 +++++--
desktop/source/lib/lokclipboard.hxx | 2 -
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 28 ++++++++++++++++++++
sw/source/uibase/uno/unotxdoc.cxx | 7 +++++
5 files changed, 47 insertions(+), 4 deletions(-)
New commits:
commit c791bef561dcf38a4b47dd06534914f7c28ae67e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Oct 26 15:39:28 2015 +0100
sw tiled rendering: don't offer HTML paste for shape text
Change-Id: Icd6df15347c48a5e42860092f4ee664e3a3d5699
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index d414582..52dfcc7 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3198,6 +3198,13 @@ bool SwXTextDocument::isMimeTypeSupported()
return false;
TransferableDataHelper aDataHelper(TransferableDataHelper::CreateFromSystemClipboard(&pWrtShell->GetView().GetEditWin()));
+ if (SdrView* pSdrView = pWrtShell->GetDrawView())
+ {
+ if (pSdrView->GetTextEditObject())
+ // Editing shape text
+ return EditEngine::HasValidData(aDataHelper.GetTransferable());
+ }
+
return aDataHelper.GetXTransferable().is() && SwTransferable::IsPaste(*pWrtShell, aDataHelper);
}
commit 080bd44f0b0300075ff18d377f31deebbc4009ed
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Oct 26 14:25:26 2015 +0100
gtktiledviwer: try to paste as html, then as plain text
Change-Id: I8e1c93fd36fb903c0625b29f9f73825438c9e113
diff --git a/desktop/source/lib/lokclipboard.cxx b/desktop/source/lib/lokclipboard.cxx
index 50d5705..376bcd7 100644
--- a/desktop/source/lib/lokclipboard.cxx
+++ b/desktop/source/lib/lokclipboard.cxx
@@ -43,7 +43,7 @@ throw(datatransfer::UnsupportedFlavorException, io::IOException, uno::RuntimeExc
if (rFlavor.DataType == cppu::UnoType<OUString>::get())
{
sal_Char* pText = reinterpret_cast<sal_Char*>(m_aSequence.getArray());
- aRet <<= OUString(pText, rtl_str_getLength(pText), RTL_TEXTENCODING_UTF8);
+ aRet <<= OUString(pText, m_aSequence.getLength(), RTL_TEXTENCODING_UTF8);
}
else
aRet <<= m_aSequence;
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index f7c4d5c..8b81c73 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -15,6 +15,7 @@
#include <iostream>
#include <boost/property_tree/json_parser.hpp>
+#include <boost/optional.hpp>
#include <gdk/gdkkeysyms.h>
#define LOK_USE_UNSTABLE_API
@@ -288,6 +289,33 @@ static void doPaste(GtkWidget* pButton, gpointer /*pItem*/)
LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(pLOKDocView);
GtkClipboard* pClipboard = gtk_clipboard_get_for_display(gtk_widget_get_display(rWindow.m_pDocView), GDK_SELECTION_CLIPBOARD);
+
+ GdkAtom* pTargets;
+ gint nTargets;
+ boost::optional<GdkAtom> oTarget;
+ if (gtk_clipboard_wait_for_targets(pClipboard, &pTargets, &nTargets))
+ {
+ for (gint i = 0; i < nTargets; ++i)
+ {
+ gchar* pName = gdk_atom_name(pTargets[i]);
+ if (std::string(pName) == "text/html")
+ oTarget = pTargets[i];
+ g_free(pName);
+ }
+ g_free(pTargets);
+ }
+
+ if (oTarget)
+ {
+ GtkSelectionData* pSelectionData = gtk_clipboard_wait_for_contents(pClipboard, *oTarget);
+ gint nLength;
+ const guchar* pData = gtk_selection_data_get_data_with_length(pSelectionData, &nLength);
+ bool bSuccess = pDocument->pClass->paste(pDocument, "text/html", reinterpret_cast<const char*>(pData), nLength);
+ gtk_selection_data_free(pSelectionData);
+ if (bSuccess)
+ return;
+ }
+
gchar* pText = gtk_clipboard_wait_for_text(pClipboard);
if (pText)
pDocument->pClass->paste(pDocument, "text/plain;charset=utf-8", pText, strlen(pText));
commit faa316e670414363dcfb6db6001fdb209f4a48c1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Oct 26 14:20:26 2015 +0100
lok clipboard: support rich text paste
Change-Id: Ida5028969782be792b32b952d3adba0c30dd8bae
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 4d13bb33..eb9a852 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -338,7 +338,10 @@ void DesktopLOKTest::testPasteWriter()
CPPUNIT_ASSERT_EQUAL(OString("hello"), OString(pText));
free(pText);
+ // textt/plain should be rejected.
CPPUNIT_ASSERT(!pDocument->pClass->paste(pDocument, "textt/plain;charset=utf-8", aText.getStr(), aText.getLength()));
+ // Writer is expected to support text/html.
+ CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "text/html", aText.getStr(), aText.getLength()));
comphelper::LibreOfficeKit::setActive(false);
}
diff --git a/desktop/source/lib/lokclipboard.cxx b/desktop/source/lib/lokclipboard.cxx
index a81902b..50d5705 100644
--- a/desktop/source/lib/lokclipboard.cxx
+++ b/desktop/source/lib/lokclipboard.cxx
@@ -32,7 +32,7 @@ OUString SAL_CALL LOKClipboard::getName() throw (uno::RuntimeException, std::exc
LOKTransferable::LOKTransferable(const char* pMimeType, const char* pData, size_t nSize)
: m_aMimeType(pMimeType),
- m_aText(pData, nSize)
+ m_aSequence(reinterpret_cast<const sal_Int8*>(pData), nSize)
{
}
@@ -40,8 +40,13 @@ uno::Any SAL_CALL LOKTransferable::getTransferData(const datatransfer::DataFlavo
throw(datatransfer::UnsupportedFlavorException, io::IOException, uno::RuntimeException, std::exception)
{
uno::Any aRet;
- if (m_aMimeType == "text/plain;charset=utf-8" && rFlavor.MimeType == "text/plain;charset=utf-16")
- aRet <<= OStringToOUString(m_aText, RTL_TEXTENCODING_UTF8);
+ if (rFlavor.DataType == cppu::UnoType<OUString>::get())
+ {
+ sal_Char* pText = reinterpret_cast<sal_Char*>(m_aSequence.getArray());
+ aRet <<= OUString(pText, rtl_str_getLength(pText), RTL_TEXTENCODING_UTF8);
+ }
+ else
+ aRet <<= m_aSequence;
return aRet;
}
diff --git a/desktop/source/lib/lokclipboard.hxx b/desktop/source/lib/lokclipboard.hxx
index b982e1c..a0ab645 100644
--- a/desktop/source/lib/lokclipboard.hxx
+++ b/desktop/source/lib/lokclipboard.hxx
@@ -35,7 +35,7 @@ public:
class LOKTransferable : public cppu::WeakImplHelper<css::datatransfer::XTransferable>
{
OString m_aMimeType;
- OString m_aText;
+ css::uno::Sequence<sal_Int8> m_aSequence;
/// Provides a list of flavors, used by getTransferDataFlavors() and isDataFlavorSupported().
std::vector<css::datatransfer::DataFlavor> getTransferDataFlavorsAsVector();
More information about the Libreoffice-commits
mailing list