[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - desktop/qa desktop/source sfx2/sdi sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu May 23 11:43:33 UTC 2019
desktop/qa/desktop_lib/test_desktop_lib.cxx | 18 ++++++++++++++++++
desktop/source/lib/init.cxx | 1 +
sfx2/sdi/sfx.sdi | 2 +-
sw/source/uibase/dochdl/swdtflvr.cxx | 15 ++++++++++-----
sw/source/uibase/inc/swdtflvr.hxx | 7 ++++---
sw/source/uibase/shells/basesh.cxx | 10 +++++++---
6 files changed, 41 insertions(+), 12 deletions(-)
New commits:
commit b3aeddc5eeea30620c63f685910ccb6b0858f2f2
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu May 23 11:53:26 2019 +0200
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Thu May 23 13:42:46 2019 +0200
sw: add IgnoreComments parameter to .uno:Paste
Which allows not hardcoding true for LOK.
Conflicts:
sw/source/uibase/dochdl/swdtflvr.cxx
sw/source/uibase/inc/swdtflvr.hxx
Change-Id: I644763ba052b148fc34283e361aa02f9bba2c5ee
Reviewed-on: https://gerrit.libreoffice.org/72833
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Tested-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a00d59f54743..99b6c9f7806f 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -584,6 +584,24 @@ void DesktopLOKTest::testPasteWriter()
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()));
+
+ // Overwrite doc contents with a HTML paste.
+ pDocument->pClass->postUnoCommand(pDocument, ".uno:SelectAll", nullptr, false);
+ Scheduler::ProcessEventsToIdle();
+ OString aComment("foo <!-- bar --> baz");
+ CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "text/html", aComment.getStr(), aComment.getLength()));
+
+ // Check if we have a comment.
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xParagraphEnumerationAccess(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xParagraphEnumeration = xParagraphEnumerationAccess->createEnumeration();
+ uno::Reference<container::XEnumerationAccess> xParagraph(xParagraphEnumeration->nextElement(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xTextPortionEnumeration = xParagraph->createEnumeration();
+ uno::Reference<beans::XPropertySet> xTextPortion(xTextPortionEnumeration->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Text"), xTextPortion->getPropertyValue("TextPortionType").get<OUString>());
+ // Without the accompanying fix in place, this test would have failed, as we had a comment
+ // between "foo" and "baz".
+ CPPUNIT_ASSERT(!xTextPortionEnumeration->hasMoreElements());
}
void DesktopLOKTest::testPasteWriterJPEG()
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index da372deedda4..3d30f5d637ea 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3391,6 +3391,7 @@ static bool doc_paste(LibreOfficeKitDocument* pThis, const char* pMimeType, cons
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
{
{"AnchorType", uno::makeAny(static_cast<sal_uInt16>(text::TextContentAnchorType_AS_CHARACTER))},
+ {"IgnoreComments", uno::makeAny(true)},
}));
if (!comphelper::dispatchCommand(".uno:Paste", aPropertyValues))
{
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index ecda87bb06be..6332fc042e5a 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -2985,7 +2985,7 @@ SfxTemplateItem ParaStyle SID_STYLE_FAMILY2
SfxVoidItem Paste SID_PASTE
-(SfxUInt16Item AnchorType FN_PARAM_1)
+(SfxUInt16Item AnchorType FN_PARAM_1, SfxBoolItem IgnoreComments FN_PARAM_2)
[
AutoUpdate = FALSE,
FastCall = TRUE,
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 4deb00ac74ae..1a2de3a86a9c 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -1122,7 +1122,7 @@ bool SwTransferable::IsPaste( const SwWrtShell& rSh,
return bIsPaste;
}
-bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndStdIds nAnchorType)
+bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndStdIds nAnchorType, bool bIgnoreComments)
{
sal_uInt8 nEventAction, nAction=0;
SotExchangeDest nDestination = SwTransferable::GetSotDestination( rSh );
@@ -1214,7 +1214,7 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt
return EXCHG_INOUT_ACTION_NONE != nAction &&
SwTransferable::PasteData( rData, rSh, nAction, nActionFlags, nFormat,
- nDestination, false, false, nullptr, 0, false, nAnchorType );
+ nDestination, false, false, nullptr, 0, false, nAnchorType, bIgnoreComments );
}
bool SwTransferable::PasteData( TransferableDataHelper& rData,
@@ -1223,7 +1223,8 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
SotExchangeDest nDestination, bool bIsPasteFormat,
bool bIsDefault,
const Point* pPt, sal_Int8 nDropAction,
- bool bPasteSelection, RndStdIds nAnchorType )
+ bool bPasteSelection, RndStdIds nAnchorType,
+ bool bIgnoreComments)
{
SwWait aWait( *rSh.GetView().GetDocShell(), false );
std::unique_ptr<SwTrnsfrActionAndUndo, o3tl::default_delete<SwTrnsfrActionAndUndo>> pAction;
@@ -1369,7 +1370,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
case SotClipboardFormatId::RICHTEXT:
case SotClipboardFormatId::STRING:
bRet = SwTransferable::PasteFileContent( rData, rSh,
- nFormat, bMsg );
+ nFormat, bMsg, bIgnoreComments );
break;
case SotClipboardFormatId::NETSCAPE_BOOKMARK:
@@ -1649,7 +1650,7 @@ SotExchangeDest SwTransferable::GetSotDestination( const SwWrtShell& rSh )
}
bool SwTransferable::PasteFileContent( TransferableDataHelper& rData,
- SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg )
+ SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg, bool bIgnoreComments )
{
const char* pResId = STR_CLPBRD_FORMAT_ERROR;
bool bRet = false;
@@ -1721,6 +1722,10 @@ bool SwTransferable::PasteFileContent( TransferableDataHelper& rData,
const SwPosition& rInsPos = *rSh.GetCursor()->Start();
SwReader aReader( *pStream, aEmptyOUStr, OUString(), *rSh.GetCursor() );
rSh.SaveTableBoxContent( &rInsPos );
+
+ if (bIgnoreComments)
+ pRead->SetIgnoreHTMLComments(true);
+
if( aReader.Read( *pRead ).IsError() )
pResId = STR_ERROR_CLPBRD_READ;
else
diff --git a/sw/source/uibase/inc/swdtflvr.hxx b/sw/source/uibase/inc/swdtflvr.hxx
index 2ecbd2c2f9d6..640d972cc631 100644
--- a/sw/source/uibase/inc/swdtflvr.hxx
+++ b/sw/source/uibase/inc/swdtflvr.hxx
@@ -94,7 +94,7 @@ class SW_DLLPUBLIC SwTransferable : public TransferableHelper
SotClipboardFormatId nFormat, SotExchangeDest nDestination );
static bool PasteFileContent( TransferableDataHelper&,
- SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg );
+ SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg, bool bIgnoreComments = false );
static bool PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh,
SotClipboardFormatId nFormat, SotExchangeActionFlags nActionFlags, bool bMsg );
static bool PasteTargetURL( TransferableDataHelper& rData, SwWrtShell& rSh,
@@ -172,14 +172,15 @@ public:
// paste - methods and helper methods for the paste
static bool IsPaste( const SwWrtShell&, const TransferableDataHelper& );
- static bool Paste( SwWrtShell&, TransferableDataHelper&, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA );
+ static bool Paste( SwWrtShell&, TransferableDataHelper&, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA, bool bIgnoreComments = false );
static bool PasteData( TransferableDataHelper& rData,
SwWrtShell& rSh, sal_uInt8 nAction, SotExchangeActionFlags nActionFlags,
SotClipboardFormatId nFormat,
SotExchangeDest nDestination, bool bIsPasteFormat,
bool bIsDefault,
const Point* pDDPos = nullptr, sal_Int8 nDropAction = 0,
- bool bPasteSelection = false, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA );
+ bool bPasteSelection = false, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA,
+ bool bIgnoreComments = false );
static bool IsPasteSpecial( const SwWrtShell& rWrtShell,
const TransferableDataHelper& );
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index d59379e2c856..3d418e58070b 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -285,11 +285,15 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
// destroyed after the paste.
SwView* pView = &rView;
+ RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA;
const SfxUInt16Item* pAnchorType = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
if (pAnchorType)
- SwTransferable::Paste(rSh, aDataHelper, static_cast<RndStdIds>(pAnchorType->GetValue()));
- else
- SwTransferable::Paste(rSh, aDataHelper);
+ nAnchorType = static_cast<RndStdIds>(pAnchorType->GetValue());
+ bool bIgnoreComments = false;
+ const SfxBoolItem* pIgnoreComments = rReq.GetArg<SfxBoolItem>(FN_PARAM_2);
+ if (pIgnoreComments)
+ bIgnoreComments = pIgnoreComments->GetValue();
+ SwTransferable::Paste(rSh, aDataHelper, nAnchorType, bIgnoreComments);
if( rSh.IsFrameSelected() || rSh.IsObjSelected() )
rSh.EnterSelFrameMode();
More information about the Libreoffice-commits
mailing list