[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 12 commits - desktop/CppunitTest_desktop_lib.mk desktop/Library_sofficeapp.mk desktop/qa desktop/source include/LibreOfficeKit include/vcl sc/inc sc/source sd/source sw/inc sw/source vcl/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Oct 27 09:17:37 UTC 2015
desktop/CppunitTest_desktop_lib.mk | 1
desktop/Library_sofficeapp.mk | 2
desktop/qa/desktop_lib/test_desktop_lib.cxx | 30 +++++++--
desktop/source/lib/init.cxx | 45 ++++++++++++++
desktop/source/lib/lokclipboard.cxx | 88 ++++++++++++++++++++++++++++
desktop/source/lib/lokclipboard.hxx | 58 ++++++++++++++++++
include/LibreOfficeKit/LibreOfficeKit.h | 6 +
include/LibreOfficeKit/LibreOfficeKit.hxx | 12 +++
include/vcl/ITiledRenderable.hxx | 6 +
include/vcl/window.hxx | 2
sc/inc/docuno.hxx | 6 +
sc/source/ui/unoobj/docuno.cxx | 24 +++++++
sd/source/ui/inc/unomodel.hxx | 4 +
sd/source/ui/unoidl/unomodel.cxx | 22 +++++++
sw/inc/unotxdoc.hxx | 4 +
sw/source/uibase/uno/unotxdoc.cxx | 26 ++++++++
vcl/source/window/window.cxx | 6 +
17 files changed, 335 insertions(+), 7 deletions(-)
New commits:
commit 645dfae3a882f2ac327a4a5875594a0d799c8247
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
(cherry picked from commit c791bef561dcf38a4b47dd06534914f7c28ae67e)
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 578feda..2a3c894 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3204,6 +3204,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 5a2184ff317906b1b4b2c5b8b608c92aa18399ed
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
(cherry picked from commit faa316e670414363dcfb6db6001fdb209f4a48c1)
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 26b96ec..71f50ec 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();
commit 2c6a58d71ca74ea3147dcfd18097142806eaf6ed
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Oct 26 13:42:02 2015 +0100
sc: implement vcl::ITiledRenderable::isMimeTypeSupported()
(cherry picked from commit 5b4c29b1b15dcebfe4e76aaa8bdb2dd45e2b67f3)
Conflicts:
sc/inc/docuno.hxx
Change-Id: I0b9de068ddf0f4ff92d8fbf003b7529516f1f80a
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index dcd3b5e..2a42f19 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -151,10 +151,8 @@ public:
/// Returns the current vcl::Window of the component.
virtual vcl::Window* getWindow() = 0;
- virtual bool isMimeTypeSupported()
- {
- return false;
- }
+ /// If the current contents of the clipboard is something we can paste.
+ virtual bool isMimeTypeSupported() = 0;
};
} // namespace vcl
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 557c1d3..56fc762 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -418,6 +418,9 @@ public:
/// @see vcl::ITiledRenderable::getWindow().
virtual vcl::Window* getWindow() SAL_OVERRIDE;
+
+ /// @see vcl::ITiledRenderable::isMimeTypeSupported().
+ virtual bool isMimeTypeSupported() SAL_OVERRIDE;
};
class ScDrawPagesObj : public cppu::WeakImplHelper2<
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index fa33533..9489a07 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -842,6 +842,19 @@ vcl::Window* ScModelObj::getWindow()
return pViewData->GetActiveWin();
}
+bool ScModelObj::isMimeTypeSupported()
+{
+ SolarMutexGuard aGuard;
+
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ if (!pViewData)
+ return 0;
+
+
+ TransferableDataHelper aDataHelper(TransferableDataHelper::CreateFromSystemClipboard(pViewData->GetActiveWin()));
+ return EditEngine::HasValidData(aDataHelper.GetTransferable());
+}
+
void ScModelObj::initializeForTiledRendering()
{
SolarMutexGuard aGuard;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 94cd065..578feda 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3197,6 +3197,8 @@ vcl::Window* SwXTextDocument::getWindow()
bool SwXTextDocument::isMimeTypeSupported()
{
+ SolarMutexGuard aGuard;
+
SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
if (!pWrtShell)
return false;
commit 578704afac3c767a3eea2df3212b52a2006e7027
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Oct 26 11:41:54 2015 +0100
sd: implement vcl::ITiledRenderable::isMimeTypeSupported()
(cherry picked from commit b08546eb23aa8dfc2f139731f800031f147e32d7)
Conflicts:
sd/source/ui/inc/unomodel.hxx
Change-Id: I528ac9f9f687d2940c6477b1d33264f1e523051f
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 5f04474..107069e 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -260,6 +260,8 @@ public:
virtual void resetSelection() SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::getWindow().
virtual vcl::Window* getWindow() SAL_OVERRIDE;
+ /// @see vcl::ITiledRenderable::isMimeTypeSupported().
+ virtual bool isMimeTypeSupported() SAL_OVERRIDE;
// XComponent
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 1628a18..31954b6 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2550,6 +2550,17 @@ vcl::Window* SdXImpressDocument::getWindow()
return pViewShell->GetActiveWindow();
}
+bool SdXImpressDocument::isMimeTypeSupported()
+{
+ SolarMutexGuard aGuard;
+ DrawViewShell* pViewShell = GetViewShell();
+ if (!pViewShell)
+ return false;
+
+ TransferableDataHelper aDataHelper(TransferableDataHelper::CreateFromSystemClipboard(pViewShell->GetActiveWindow()));
+ return EditEngine::HasValidData(aDataHelper.GetTransferable());
+}
+
uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable()
{
uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbidenCharacters);
commit 981eafbb347f2e5aed8e7a4953891f439a4ffffd
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Oct 26 11:28:55 2015 +0100
lok::Document::paste: check if the given mime type is supported
(cherry picked from commit 7efbbe98d7fe951909234dcacd37f67975f00da2)
Conflicts:
sw/inc/unotxdoc.hxx
Change-Id: Ib59ea43700815c53cdd4be819e2e9cf35c6f89e9
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 9f01249..26b96ec 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -331,12 +331,15 @@ void DesktopLOKTest::testPasteWriter()
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
OString aText("hello");
- pDocument->pClass->paste(pDocument, "text/plain;charset=utf-8", aText.getStr(), aText.getLength());
+ CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "text/plain;charset=utf-8", aText.getStr(), aText.getLength()));
pDocument->pClass->postUnoCommand(pDocument, ".uno:SelectAll", 0);
char* pText = pDocument->pClass->getTextSelection(pDocument, "text/plain;charset=utf-8", 0);
CPPUNIT_ASSERT_EQUAL(OString("hello"), OString(pText));
free(pText);
+
+ CPPUNIT_ASSERT(!pDocument->pClass->paste(pDocument, "textt/plain;charset=utf-8", aText.getStr(), aText.getLength()));
+
comphelper::LibreOfficeKit::setActive(false);
}
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 039489f..9962b11 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1019,6 +1019,13 @@ static bool doc_paste(LibreOfficeKitDocument* pThis, const char* pMimeType, cons
}
pWindow->SetClipboard(xClipboard);
+ if (!pDoc->isMimeTypeSupported())
+ {
+ if (gImpl)
+ gImpl->maLastExceptionMsg = "Document doesn't support this mime type";
+ return false;
+ }
+
OUString aCommand(".uno:Paste");
uno::Sequence<beans::PropertyValue> aPropertyValues;
if (!comphelper::dispatchCommand(aCommand, aPropertyValues))
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 36156c2..dcd3b5e 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -150,6 +150,11 @@ public:
/// Returns the current vcl::Window of the component.
virtual vcl::Window* getWindow() = 0;
+
+ virtual bool isMimeTypeSupported()
+ {
+ return false;
+ }
};
} // namespace vcl
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index f8af2cc..e590e2d 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -436,6 +436,8 @@ public:
virtual OUString getPartPageRectangles() SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::getWindow().
virtual vcl::Window* getWindow() SAL_OVERRIDE;
+ /// @see vcl::ITiledRenderable::isMimeTypeSupported().
+ virtual bool isMimeTypeSupported() SAL_OVERRIDE;
// ::com::sun::star::tiledrendering::XTiledRenderable
virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) throw (::css::uno::RuntimeException, ::std::exception) SAL_OVERRIDE;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 6b18213..94cd065 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3195,6 +3195,16 @@ vcl::Window* SwXTextDocument::getWindow()
return &pDocShell->GetView()->GetEditWin();
}
+bool SwXTextDocument::isMimeTypeSupported()
+{
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+ if (!pWrtShell)
+ return false;
+
+ TransferableDataHelper aDataHelper(TransferableDataHelper::CreateFromSystemClipboard(&pWrtShell->GetView().GetEditWin()));
+ return aDataHelper.GetXTransferable().is() && SwTransferable::IsPaste(*pWrtShell, aDataHelper);
+}
+
int SwXTextDocument::getPart()
{
SolarMutexGuard aGuard;
commit eb1ef5b12eb6fb01bf1c2b929fe836bbb8b2c697
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Oct 26 10:26:37 2015 +0100
vcl: ITiledRenderable::getWindow() can be pure-virtual now
Change-Id: I393ec4427674cd5d77d0e9a069ffe159d14e38b1
(cherry picked from commit e531f846d798e1b9097fcb2a5f4e58d5e3d423de)
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 6e8280f..36156c2 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -149,10 +149,7 @@ public:
}
/// Returns the current vcl::Window of the component.
- virtual vcl::Window* getWindow()
- {
- return 0;
- }
+ virtual vcl::Window* getWindow() = 0;
};
} // namespace vcl
commit a8ea266cba4864be8dd27cc7d0f3c497241724fa
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Oct 22 15:51:41 2015 +0200
desktop: add lok::Document::paste() testcase
Also, closeDoc() is called by tearDown(), so no need to call it manually
at the end of tests.
Change-Id: Ib8f61a09fa3fc0885d7ea90ce96210bff4cc9f98
(cherry picked from commit d491ae5692f0b1fb4653510e694bbf5227375858)
diff --git a/desktop/CppunitTest_desktop_lib.mk b/desktop/CppunitTest_desktop_lib.mk
index a1f7125..ca9d8db 100644
--- a/desktop/CppunitTest_desktop_lib.mk
+++ b/desktop/CppunitTest_desktop_lib.mk
@@ -45,6 +45,7 @@ $(eval $(call gb_CppunitTest_use_vcl,desktop_lib))
$(eval $(call gb_CppunitTest_use_components,desktop_lib,\
comphelper/util/comphelp \
configmgr/source/configmgr \
+ dtrans/util/mcnttype \
filter/source/config/cache/filterconfig1 \
filter/source/storagefilterdetect/storagefd \
framework/util/fwk \
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 3730fd1..9f01249 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -65,6 +65,7 @@ public:
void testPaintTile();
void testSaveAs();
void testSaveAsCalc();
+ void testPasteWriter();
CPPUNIT_TEST_SUITE(DesktopLOKTest);
CPPUNIT_TEST(testGetStyles);
@@ -76,6 +77,7 @@ public:
CPPUNIT_TEST(testPaintTile);
CPPUNIT_TEST(testSaveAs);
CPPUNIT_TEST(testSaveAsCalc);
+ CPPUNIT_TEST(testPasteWriter);
CPPUNIT_TEST_SUITE_END();
uno::Reference<lang::XComponent> mxComponent;
@@ -174,7 +176,6 @@ void DesktopLOKTest::testGetStyles()
CPPUNIT_FAIL("Unknown style family: " + rPair.first);
}
}
- closeDoc();
}
void DesktopLOKTest::testGetFonts()
@@ -194,7 +195,6 @@ void DesktopLOKTest::testGetFonts()
// check that we have font sizes available for each font
CPPUNIT_ASSERT( rPair.second.size() > 0);
}
- closeDoc();
}
void DesktopLOKTest::testCreateView()
@@ -213,7 +213,6 @@ void DesktopLOKTest::testCreateView()
pDocument->m_pDocumentClass->destroyView(pDocument, nId);
CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViews(pDocument));
- closeDoc();
}
void DesktopLOKTest::testGetPartPageRectangles()
@@ -236,7 +235,6 @@ void DesktopLOKTest::testGetPartPageRectangles()
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aRectangles.size());
free(pRectangles);
- closeDoc();
}
void DesktopLOKTest::testGetFilterTypes()
@@ -283,7 +281,6 @@ void DesktopLOKTest::testSearchCalc()
// Result is on the first sheet.
CPPUNIT_ASSERT_EQUAL(0, m_aSearchResultPart[0]);
- closeDoc();
comphelper::LibreOfficeKit::setActive(false);
}
@@ -310,8 +307,6 @@ void DesktopLOKTest::testPaintTile()
nTileHeight = 4000;
aBuffer.resize(nCanvasWidth * nCanvasHeight * 4);
pDocument->pClass->paintTile(pDocument, aBuffer.data(), nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
-
- closeDoc();
}
void DesktopLOKTest::testSaveAs()
@@ -330,6 +325,21 @@ void DesktopLOKTest::testSaveAsCalc()
CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "png", 0));
}
+void DesktopLOKTest::testPasteWriter()
+{
+ comphelper::LibreOfficeKit::setActive(true);
+ LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+ OString aText("hello");
+
+ pDocument->pClass->paste(pDocument, "text/plain;charset=utf-8", aText.getStr(), aText.getLength());
+
+ pDocument->pClass->postUnoCommand(pDocument, ".uno:SelectAll", 0);
+ char* pText = pDocument->pClass->getTextSelection(pDocument, "text/plain;charset=utf-8", 0);
+ CPPUNIT_ASSERT_EQUAL(OString("hello"), OString(pText));
+ free(pText);
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
CPPUNIT_PLUGIN_IMPLEMENT();
commit 22fe9c37f3f5e3f55e814178a85baefade033e11
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Oct 22 14:42:38 2015 +0200
sc: implement vcl::ITiledRenderable::getWindow()
(cherry picked from commit 4c6db362dc31edaefd553860d1e0ef0be55c4862)
Conflicts:
sc/inc/docuno.hxx
Change-Id: If50b4b5baea36e161675afd368fc54bdec01d9a5
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index cc13227..557c1d3 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -415,6 +415,9 @@ public:
/// @see lok::Document::resetSelection().
virtual void resetSelection() SAL_OVERRIDE;
+
+ /// @see vcl::ITiledRenderable::getWindow().
+ virtual vcl::Window* getWindow() SAL_OVERRIDE;
};
class ScDrawPagesObj : public cppu::WeakImplHelper2<
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 26ce45b..fa33533 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -831,6 +831,17 @@ void ScModelObj::resetSelection()
pDocShell->GetDocument().GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, "");
}
+vcl::Window* ScModelObj::getWindow()
+{
+ SolarMutexGuard aGuard;
+
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ if (!pViewData)
+ return 0;
+
+ return pViewData->GetActiveWin();
+}
+
void ScModelObj::initializeForTiledRendering()
{
SolarMutexGuard aGuard;
commit 657dc1004e558eb74c69c6a804c40e5d58c6d581
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Oct 22 14:15:14 2015 +0200
sd: implement vcl::ITiledRenderable::getWindow()
(cherry picked from commit 8522948ba2f30fb703d4725086d30d9aa2a0cf4c)
Conflicts:
sd/source/ui/inc/unomodel.hxx
Change-Id: I8bc7316d9304d9e764ee846fe3af34599bf6fc35
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 4d73148..5f04474 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -258,6 +258,8 @@ public:
virtual void setGraphicSelection(int nType, int nX, int nY) SAL_OVERRIDE;
/// @see lok::Document::resetSelection().
virtual void resetSelection() SAL_OVERRIDE;
+ /// @see vcl::ITiledRenderable::getWindow().
+ virtual vcl::Window* getWindow() SAL_OVERRIDE;
// XComponent
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 6ae01a2..1628a18 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2539,6 +2539,17 @@ void SdXImpressDocument::resetSelection()
pSdrView->UnmarkAll();
}
+vcl::Window* SdXImpressDocument::getWindow()
+{
+ SolarMutexGuard aGuard;
+
+ DrawViewShell* pViewShell = GetViewShell();
+ if (!pViewShell)
+ return 0;
+
+ return pViewShell->GetActiveWindow();
+}
+
uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable()
{
uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbidenCharacters);
commit 03a965280caf3665c0abb01c7b46debdd3dbeac1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Oct 22 11:26:13 2015 +0200
LOK: add Document::paste()
Change-Id: I34998229e7f5cac4c62c859861783be3c161f9bf
(cherry picked from commit 6552767aa5ed61215eb64dac0cc026a5f7a9aad1)
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index ccad5a7..f0faf21 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -124,6 +124,7 @@ ifneq ($(filter $(OS),ANDROID IOS),)
$(eval $(call gb_Library_add_exception_objects,sofficeapp,\
desktop/source/lib/init \
desktop/source/lib/lokinteractionhandler \
+ desktop/source/lib/lokclipboard \
$(if $(filter $(OS),ANDROID), \
desktop/source/lib/lokandroid) \
))
@@ -132,6 +133,7 @@ ifeq ($(GUIBASE),unx)
$(eval $(call gb_Library_add_exception_objects,sofficeapp,\
desktop/source/lib/init \
desktop/source/lib/lokinteractionhandler \
+ desktop/source/lib/lokclipboard \
))
endif
endif
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b7a4252..039489f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -45,6 +45,7 @@
#include <com/sun/star/ucb/XContentProvider.hpp>
#include <com/sun/star/ucb/XUniversalContentBroker.hpp>
#include <com/sun/star/util/URLTransformer.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
#include <editeng/fontitem.hxx>
#include <editeng/flstitem.hxx>
@@ -80,6 +81,7 @@
#include "../../inc/lib/init.hxx"
#include "lokinteractionhandler.hxx"
+#include <lokclipboard.hxx>
using namespace css;
using namespace vcl;
@@ -250,6 +252,10 @@ static void doc_setTextSelection (LibreOfficeKitDocument* pThis,
static char* doc_getTextSelection(LibreOfficeKitDocument* pThis,
const char* pMimeType,
char** pUsedMimeType);
+static bool doc_paste(LibreOfficeKitDocument* pThis,
+ const char* pMimeType,
+ const char* pData,
+ size_t nSize);
static void doc_setGraphicSelection (LibreOfficeKitDocument* pThis,
int nType,
int nX,
@@ -290,6 +296,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->postUnoCommand = doc_postUnoCommand;
m_pDocumentClass->setTextSelection = doc_setTextSelection;
m_pDocumentClass->getTextSelection = doc_getTextSelection;
+ m_pDocumentClass->paste = doc_paste;
m_pDocumentClass->setGraphicSelection = doc_setGraphicSelection;
m_pDocumentClass->resetSelection = doc_resetSelection;
m_pDocumentClass->getCommandValues = doc_getCommandValues;
@@ -992,6 +999,37 @@ static char* doc_getTextSelection(LibreOfficeKitDocument* pThis, const char* pMi
return pMemory;
}
+static bool doc_paste(LibreOfficeKitDocument* pThis, const char* pMimeType, const char* pData, size_t nSize)
+{
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return false;
+ }
+
+ uno::Reference<datatransfer::XTransferable> xTransferable(new LOKTransferable(pMimeType, pData, nSize));
+ uno::Reference<datatransfer::clipboard::XClipboard> xClipboard(new LOKClipboard());
+ xClipboard->setContents(xTransferable, uno::Reference<datatransfer::clipboard::XClipboardOwner>());
+ vcl::Window* pWindow = pDoc->getWindow();
+ if (!pWindow)
+ {
+ gImpl->maLastExceptionMsg = "Document did not provide a window";
+ return false;
+ }
+
+ pWindow->SetClipboard(xClipboard);
+ OUString aCommand(".uno:Paste");
+ uno::Sequence<beans::PropertyValue> aPropertyValues;
+ if (!comphelper::dispatchCommand(aCommand, aPropertyValues))
+ {
+ gImpl->maLastExceptionMsg = "Failed to dispatch the .uno: command";
+ return false;
+ }
+
+ return true;
+}
+
static void doc_setGraphicSelection(LibreOfficeKitDocument* pThis, int nType, int nX, int nY)
{
ITiledRenderable* pDoc = getTiledRenderable(pThis);
diff --git a/desktop/source/lib/lokclipboard.cxx b/desktop/source/lib/lokclipboard.cxx
new file mode 100644
index 0000000..a81902b
--- /dev/null
+++ b/desktop/source/lib/lokclipboard.cxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <lokclipboard.hxx>
+#include <comphelper/sequence.hxx>
+
+using namespace com::sun::star;
+
+uno::Reference<datatransfer::XTransferable> SAL_CALL LOKClipboard::getContents()
+throw (uno::RuntimeException, std::exception)
+{
+ return m_xTransferable;
+}
+
+void SAL_CALL LOKClipboard::setContents(const uno::Reference<datatransfer::XTransferable>& xTransferable,
+ const uno::Reference<datatransfer::clipboard::XClipboardOwner>& /*xClipboardOwner*/)
+throw (uno::RuntimeException, std::exception)
+{
+ m_xTransferable = xTransferable;
+}
+
+OUString SAL_CALL LOKClipboard::getName() throw (uno::RuntimeException, std::exception)
+{
+ return OUString();
+}
+
+LOKTransferable::LOKTransferable(const char* pMimeType, const char* pData, size_t nSize)
+ : m_aMimeType(pMimeType),
+ m_aText(pData, nSize)
+{
+}
+
+uno::Any SAL_CALL LOKTransferable::getTransferData(const datatransfer::DataFlavor& rFlavor)
+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);
+ return aRet;
+}
+
+std::vector<datatransfer::DataFlavor> LOKTransferable::getTransferDataFlavorsAsVector()
+{
+ std::vector<datatransfer::DataFlavor> aRet;
+ datatransfer::DataFlavor aFlavor;
+ aFlavor.MimeType = OUString::fromUtf8(m_aMimeType.getStr());
+ aFlavor.DataType = cppu::UnoType< uno::Sequence<sal_Int8> >::get();
+
+ sal_Int32 nIndex(0);
+ if (m_aMimeType.getToken(0, ';', nIndex) == "text/plain")
+ {
+ if (m_aMimeType.getToken(0, ';', nIndex) != "charset=utf-16")
+ aFlavor.MimeType = "text/plain;charset=utf-16";
+ aFlavor.DataType = cppu::UnoType<OUString>::get();
+ }
+ aRet.push_back(aFlavor);
+
+ return aRet;
+}
+
+uno::Sequence<datatransfer::DataFlavor> SAL_CALL LOKTransferable::getTransferDataFlavors()
+throw(uno::RuntimeException, std::exception)
+{
+ return comphelper::containerToSequence(getTransferDataFlavorsAsVector());
+}
+
+sal_Bool SAL_CALL LOKTransferable::isDataFlavorSupported(const datatransfer::DataFlavor& rFlavor)
+throw(uno::RuntimeException, std::exception)
+{
+ const std::vector<datatransfer::DataFlavor> aFlavors = getTransferDataFlavorsAsVector();
+ return std::find_if(aFlavors.begin(), aFlavors.end(), [&rFlavor](const datatransfer::DataFlavor& i)
+ {
+ return i.MimeType == rFlavor.MimeType && i.DataType == rFlavor.DataType;
+ }) != aFlavors.end();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/lib/lokclipboard.hxx b/desktop/source/lib/lokclipboard.hxx
new file mode 100644
index 0000000..b982e1c
--- /dev/null
+++ b/desktop/source/lib/lokclipboard.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_DESKTOP_SOURCE_LIB_LOKCLIPBOARD_HXX
+#define INCLUDED_DESKTOP_SOURCE_LIB_LOKCLIPBOARD_HXX
+
+#include <vector>
+
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+
+/// A clipboard implementation for LibreOfficeKit.
+class LOKClipboard : public cppu::WeakImplHelper<css::datatransfer::clipboard::XClipboard>
+{
+ css::uno::Reference<css::datatransfer::XTransferable> m_xTransferable;
+
+public:
+ virtual css::uno::Reference<css::datatransfer::XTransferable> SAL_CALL getContents()
+ throw(css::uno::RuntimeException, std::exception) override;
+
+ virtual void SAL_CALL setContents(const css::uno::Reference<css::datatransfer::XTransferable>& xTransferable,
+ const css::uno::Reference<css::datatransfer::clipboard::XClipboardOwner>& xClipboardOwner)
+ throw(css::uno::RuntimeException, std::exception) override;
+
+ virtual OUString SAL_CALL getName() throw(css::uno::RuntimeException, std::exception) override;
+};
+
+/// Represents the contents of LOKClipboard.
+class LOKTransferable : public cppu::WeakImplHelper<css::datatransfer::XTransferable>
+{
+ OString m_aMimeType;
+ OString m_aText;
+
+ /// Provides a list of flavors, used by getTransferDataFlavors() and isDataFlavorSupported().
+ std::vector<css::datatransfer::DataFlavor> getTransferDataFlavorsAsVector();
+
+public:
+ LOKTransferable(const char* pMimeType, const char* pData, size_t nSize);
+
+ virtual css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor& rFlavor)
+ throw(css::datatransfer::UnsupportedFlavorException, css::io::IOException, css::uno::RuntimeException, std::exception) override;
+
+ virtual css::uno::Sequence<css::datatransfer::DataFlavor> SAL_CALL getTransferDataFlavors()
+ throw(css::uno::RuntimeException, std::exception) override;
+
+ virtual sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor& rFlavor)
+ throw(css::uno::RuntimeException, std::exception) override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 83dcc98..d83717b 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -157,6 +157,12 @@ struct _LibreOfficeKitDocumentClass
const char* pMimeType,
char** pUsedMimeType);
+ /// @see lok::Document::paste().
+ bool (*paste) (LibreOfficeKitDocument* pThis,
+ const char* pMimeType,
+ const char* pData,
+ size_t nSize);
+
/// @see lok::Document::setGraphicSelection
void (*setGraphicSelection) (LibreOfficeKitDocument* pThis,
int nType,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 72231ad..4055250 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -247,6 +247,18 @@ public:
}
/**
+ * Pastes content at the current cursor position.
+ *
+ * @param pMimeType format of pData, for example text/plain;charset=utf-8.
+ * @param pData the actual data to be pasted.
+ * @return if the supplied data was pasted successfully.
+ */
+ inline bool paste(const char* pMimeType, const char* pData, size_t nSize)
+ {
+ return mpDoc->pClass->paste(mpDoc, pMimeType, pData, nSize);
+ }
+
+ /**
* Adjusts the graphic selection.
*
* @param nType @see LibreOfficeKitSetGraphicSelectionType
commit d2536987cd64451505c2d93f8baa1a25825eefc2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Oct 22 10:15:34 2015 +0200
vcl: add ITiledRenderable::getWindow() and implement in sw
(cherry picked from commit 981a974824642a81f86c526dea682cd27cd437db)
Conflicts:
sw/inc/unotxdoc.hxx
Change-Id: I9d0fad3904e74b44b0b126974ace4025f7a4fc5b
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 0014f4d..6e8280f 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -147,6 +147,12 @@ public:
{
return OUString();
}
+
+ /// Returns the current vcl::Window of the component.
+ virtual vcl::Window* getWindow()
+ {
+ return 0;
+ }
};
} // namespace vcl
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 346cab6..f8af2cc 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -434,6 +434,8 @@ public:
virtual void resetSelection() SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::getPartPageRectangles().
virtual OUString getPartPageRectangles() SAL_OVERRIDE;
+ /// @see vcl::ITiledRenderable::getWindow().
+ virtual vcl::Window* getWindow() SAL_OVERRIDE;
// ::com::sun::star::tiledrendering::XTiledRenderable
virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) throw (::css::uno::RuntimeException, ::std::exception) SAL_OVERRIDE;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 7cb32fc..6b18213 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3188,6 +3188,13 @@ OUString SwXTextDocument::getPartPageRectangles()
return pWrtShell->getPageRectangles();
}
+vcl::Window* SwXTextDocument::getWindow()
+{
+ SolarMutexGuard aGuard;
+
+ return &pDocShell->GetView()->GetEditWin();
+}
+
int SwXTextDocument::getPart()
{
SolarMutexGuard aGuard;
commit 3dd0edb05639c36abc262f02dd3e0d19c8fb0526
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Oct 22 09:41:29 2015 +0200
vcl: add Window::SetClipboard()
Change-Id: I385f64b7d5015c9a34f34a436b0ee2ce6b3a83d3
(cherry picked from commit 98cdb563c1c63e93b4722721354d86848d2cd2c2)
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index ae28940..eb8cf4b 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1298,6 +1298,8 @@ public:
// Clipboard/Selection interfaces
::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > GetClipboard();
+ /// Sets a custom clipboard for the window's frame, instead of creating it on-demand using css::datatransfer::clipboard::SystemClipboard.
+ void SetClipboard(css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard);
::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > GetPrimarySelection();
/*
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index e8d2b96..0a01a14 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3355,6 +3355,12 @@ void Window::ImplCallActivateListeners( vcl::Window *pOld )
}
}
+void Window::SetClipboard(Reference<XClipboard> xClipboard)
+{
+ if (mpWindowImpl->mpFrameData)
+ mpWindowImpl->mpFrameData->mxClipboard = xClipboard;
+}
+
Reference< XClipboard > Window::GetClipboard()
{
More information about the Libreoffice-commits
mailing list