[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - desktop/qa desktop/source sfx2/sdi sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Sat May 7 19:58:49 UTC 2016
desktop/qa/desktop_lib/test_desktop_lib.cxx | 11 +++++++++++
desktop/source/lib/init.cxx | 10 +++++++---
sfx2/sdi/sfx.sdi | 2 +-
sw/source/uibase/dochdl/swdtflvr.cxx | 12 ++++++------
sw/source/uibase/inc/swdtflvr.hxx | 8 ++++----
sw/source/uibase/inc/wrtsh.hxx | 4 ++--
sw/source/uibase/shells/basesh.cxx | 7 ++++++-
sw/source/uibase/wrtsh/wrtsh1.cxx | 8 ++++----
8 files changed, 41 insertions(+), 21 deletions(-)
New commits:
commit abe370afab1d92debbf38d485906d372235a248f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Jan 28 13:31:52 2016 +0100
sw: add AnchorType parameter to .uno:Paste
Which allows not hardcoding as-char for LOK.
(cherry picked from commit 552361aaad740e55fcfa7993b4111aba354f863f)
Change-Id: I3b2987abbaf1f259c614b7b2a8709f15048d362d
Reviewed-on: https://gerrit.libreoffice.org/24727
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index fdd6e41..a7d07af 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -476,6 +476,17 @@ void DesktopLOKTest::testPasteWriterJPEG()
// This was text::TextContentAnchorType_AT_PARAGRAPH.
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, xShape->getPropertyValue("AnchorType").get<text::TextContentAnchorType>());
+ // Delete the pasted picture, and paste again with a custom anchor type.
+ uno::Reference<lang::XComponent>(xShape, uno::UNO_QUERY)->dispose();
+ uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+ {
+ {"AnchorType", uno::makeAny(static_cast<sal_uInt16>(text::TextContentAnchorType_AT_CHARACTER))},
+ }));
+ comphelper::dispatchCommand(".uno:Paste", aPropertyValues);
+ xShape.set(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ // This was text::TextContentAnchorType_AS_CHARACTER, AnchorType argument was ignored.
+ CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, xShape->getPropertyValue("AnchorType").get<text::TextContentAnchorType>());
+
comphelper::LibreOfficeKit::setActive(false);
}
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 1ee6e25..20a40ce 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -39,6 +39,7 @@
#include <comphelper/lok.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
+#include <comphelper/propertysequence.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
@@ -56,6 +57,7 @@
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/util/URLTransformer.hpp>
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <editeng/fontitem.hxx>
#include <editeng/flstitem.hxx>
@@ -1364,9 +1366,11 @@ static bool doc_paste(LibreOfficeKitDocument* pThis, const char* pMimeType, cons
return false;
}
- OUString aCommand(".uno:Paste");
- uno::Sequence<beans::PropertyValue> aPropertyValues;
- if (!comphelper::dispatchCommand(aCommand, aPropertyValues))
+ uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+ {
+ {"AnchorType", uno::makeAny(static_cast<sal_uInt16>(text::TextContentAnchorType_AS_CHARACTER))},
+ }));
+ if (!comphelper::dispatchCommand(".uno:Paste", aPropertyValues))
{
gImpl->maLastExceptionMsg = "Failed to dispatch the .uno: command";
return false;
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 944ca41..0b8f47a 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -4159,7 +4159,7 @@ SfxBoolItem PartWindow SID_PARTWIN
SfxVoidItem Paste SID_PASTE
-()
+(SfxUInt16Item AnchorType FN_PARAM_1)
[
/* flags: */
AutoUpdate = FALSE,
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 8dc91dd1..012f3fb 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -1136,7 +1136,7 @@ bool SwTransferable::IsPaste( const SwWrtShell& rSh,
return bIsPaste;
}
-bool SwTransferable::Paste( SwWrtShell& rSh, TransferableDataHelper& rData )
+bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, sal_uInt16 nAnchorType)
{
sal_uInt16 nEventAction, nAction=0;
SotExchangeDest nDestination = SwTransferable::GetSotDestination( rSh );
@@ -1177,7 +1177,7 @@ bool SwTransferable::Paste( SwWrtShell& rSh, TransferableDataHelper& rData )
return EXCHG_INOUT_ACTION_NONE != nAction &&
SwTransferable::PasteData( rData, rSh, nAction, nFormat,
- nDestination, false, false );
+ nDestination, false, false, nullptr, 0, false, nAnchorType );
}
bool SwTransferable::PasteData( TransferableDataHelper& rData,
@@ -1185,7 +1185,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
SotExchangeDest nDestination, bool bIsPasteFormat,
bool bIsDefault,
const Point* pPt, sal_Int8 nDropAction,
- bool bPasteSelection )
+ bool bPasteSelection, sal_uInt16 nAnchorType )
{
SwWait aWait( *rSh.GetView().GetDocShell(), false );
boost::scoped_ptr<SwTrnsfrActionAndUndo> pAction;
@@ -1517,7 +1517,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
case EXCHG_OUT_ACTION_INSERT_GRAPH:
nRet = SwTransferable::_PasteGrf( rData, rSh, nFormat,
SW_PASTESDR_INSERT, pPt,
- nActionFlags, nDropAction, bNeedToSelectBeforePaste);
+ nActionFlags, nDropAction, bNeedToSelectBeforePaste, nAnchorType);
break;
case EXCHG_OUT_ACTION_REPLACE_DRAWOBJ:
@@ -2262,7 +2262,7 @@ bool SwTransferable::_PasteSdrFormat( TransferableDataHelper& rData,
bool SwTransferable::_PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh,
SotClipboardFormatId nFormat, sal_uInt16 nAction, const Point* pPt,
- sal_uInt8 nActionFlags, sal_Int8 nDropAction, bool bNeedToSelectBeforePaste)
+ sal_uInt8 nActionFlags, sal_Int8 nDropAction, bool bNeedToSelectBeforePaste, sal_uInt16 nAnchorType)
{
bool nRet = false;
@@ -2370,7 +2370,7 @@ bool SwTransferable::_PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh,
case SW_PASTESDR_INSERT:
{
SwTransferable::SetSelInShell( rSh, false, pPt );
- rSh.Insert( sURL, aEmptyOUStr, aGraphic );
+ rSh.Insert( sURL, aEmptyOUStr, aGraphic, nullptr, false, nAnchorType );
break;
}
diff --git a/sw/source/uibase/inc/swdtflvr.hxx b/sw/source/uibase/inc/swdtflvr.hxx
index 039875b..a7072e8 100644
--- a/sw/source/uibase/inc/swdtflvr.hxx
+++ b/sw/source/uibase/inc/swdtflvr.hxx
@@ -104,7 +104,7 @@ class SW_DLLPUBLIC SwTransferable : public TransferableHelper
static bool _PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh,
SotClipboardFormatId nFormat, sal_uInt16 nAction, const Point* pPt,
- sal_uInt8 nActionFlags, sal_Int8 nDropAction, bool bNeedToSelectBeforePaste);
+ sal_uInt8 nActionFlags, sal_Int8 nDropAction, bool bNeedToSelectBeforePaste, sal_uInt16 nAnchorType = 0 );
static bool _PasteImageMap( TransferableDataHelper& rData,
SwWrtShell& rSh );
@@ -167,13 +167,13 @@ public:
// paste - methods and helper methods for the paste
static bool IsPaste( const SwWrtShell&, const TransferableDataHelper& );
- static bool Paste( SwWrtShell&, TransferableDataHelper& );
+ static bool Paste( SwWrtShell&, TransferableDataHelper&, sal_uInt16 nAnchorType = 0 );
static bool PasteData( TransferableDataHelper& rData,
SwWrtShell& rSh, sal_uInt16 nAction, SotClipboardFormatId nFormat,
SotExchangeDest nDestination, bool bIsPasteFormat,
bool bIsDefault,
- const Point* pDDPos = 0, sal_Int8 nDropAction = 0,
- bool bPasteSelection = false );
+ const Point* pDDPos = nullptr, sal_Int8 nDropAction = 0,
+ bool bPasteSelection = false, sal_uInt16 nAnchorType = 0 );
static bool IsPasteSpecial( const SwWrtShell& rWrtShell,
const TransferableDataHelper& );
diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx
index cf8b019..146f5db 100644
--- a/sw/source/uibase/inc/wrtsh.hxx
+++ b/sw/source/uibase/inc/wrtsh.hxx
@@ -292,8 +292,8 @@ typedef bool (SwWrtShell:: *FNSimpleMove)();
void Insert(const OUString &);
// graphic
void Insert( const OUString &rPath, const OUString &rFilter,
- const Graphic &, SwFlyFrmAttrMgr * = 0,
- bool bRule = false );
+ const Graphic &, SwFlyFrmAttrMgr * = nullptr,
+ bool bRule = false, sal_uInt16 nAnchorType = 0 );
void InsertByWord( const OUString & );
void InsertPageBreak(const OUString *pPageDesc = 0, const ::boost::optional<sal_uInt16>& rPgNum = boost::none);
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index 0a9c64f..fa667fe 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -285,7 +285,12 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
// Temporary variables, because the shell could already be
// destroyed after the paste.
SwView* pView = &rView;
- SwTransferable::Paste( rSh, aDataHelper );
+ SFX_REQUEST_ARG(rReq, pAnchorType, SfxUInt16Item, FN_PARAM_1, false);
+ if (pAnchorType)
+ SwTransferable::Paste(rSh, aDataHelper, pAnchorType->GetValue());
+ else
+ SwTransferable::Paste(rSh, aDataHelper);
+
if( rSh.IsFrmSelected() || rSh.IsObjSelected() )
rSh.EnterSelFrmMode();
pView->AttrChangedNotify( &rSh );
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 84a7922..486a525 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -240,7 +240,7 @@ void SwWrtShell::Insert( const OUString &rStr )
void SwWrtShell::Insert( const OUString &rPath, const OUString &rFilter,
const Graphic &rGrf, SwFlyFrmAttrMgr *pFrmMgr,
- bool bRule )
+ bool bRule, sal_uInt16 nAnchorType )
{
ResetCursorStack();
if ( !CanInsert() )
@@ -276,9 +276,9 @@ void SwWrtShell::Insert( const OUString &rPath, const OUString &rFilter,
// These must be removed explicitly for the optimal size.
pFrmMgr->DelAttr(RES_FRM_SIZE);
- if (comphelper::LibreOfficeKit::isActive())
- // LOK: anchor inserted images as-char by default.
- pFrmMgr->SetAnchor(FLY_AS_CHAR);
+ if (nAnchorType != 0)
+ // Something other than at-para was requested.
+ pFrmMgr->SetAnchor(static_cast<RndStdIds>(nAnchorType));
}
else
{
More information about the Libreoffice-commits
mailing list