summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx11
-rw-r--r--desktop/source/lib/init.cxx7
-rw-r--r--sfx2/sdi/sfx.sdi2
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx12
-rw-r--r--sw/source/uibase/inc/swdtflvr.hxx6
-rw-r--r--sw/source/uibase/inc/wrtsh.hxx2
-rw-r--r--sw/source/uibase/shells/basesh.cxx8
-rw-r--r--sw/source/uibase/wrtsh/wrtsh1.cxx8
8 files changed, 39 insertions, 17 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a83ed3994e9a..d6b18e1743f8 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -467,6 +467,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 7d078a30126c..410081b3d611 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -33,6 +33,7 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
#include <comphelper/scopeguard.hxx>
+#include <comphelper/propertysequence.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
@@ -50,6 +51,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>
@@ -1330,7 +1332,10 @@ static bool doc_paste(LibreOfficeKitDocument* pThis, const char* pMimeType, cons
return false;
}
- uno::Sequence<beans::PropertyValue> 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";
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 8c3bad63bab4..e1753da8c455 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 15d6fcddaaf8..89214109f81b 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -1133,7 +1133,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 );
@@ -1174,7 +1174,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,
@@ -1182,7 +1182,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 );
std::unique_ptr<SwTrnsfrActionAndUndo> pAction;
@@ -1515,7 +1515,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
case EXCHG_OUT_ACTION_INSERT_GRAPH:
bRet = SwTransferable::_PasteGrf( rData, rSh, nFormat,
SwPasteSdr::Insert, pPt,
- nActionFlags, nDropAction, bNeedToSelectBeforePaste);
+ nActionFlags, nDropAction, bNeedToSelectBeforePaste, nAnchorType );
break;
case EXCHG_OUT_ACTION_REPLACE_DRAWOBJ:
@@ -2258,7 +2258,7 @@ bool SwTransferable::_PasteSdrFormat( TransferableDataHelper& rData,
bool SwTransferable::_PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh,
SotClipboardFormatId nFormat, SwPasteSdr nAction, const Point* pPt,
- sal_uInt8 nActionFlags, sal_Int8 nDropAction, bool bNeedToSelectBeforePaste)
+ sal_uInt8 nActionFlags, sal_Int8 nDropAction, bool bNeedToSelectBeforePaste, sal_uInt16 nAnchorType )
{
bool bRet = false;
@@ -2366,7 +2366,7 @@ bool SwTransferable::_PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh,
case SwPasteSdr::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 73452d9e61b5..76c3709a2f08 100644
--- a/sw/source/uibase/inc/swdtflvr.hxx
+++ b/sw/source/uibase/inc/swdtflvr.hxx
@@ -105,7 +105,7 @@ class SW_DLLPUBLIC SwTransferable : public TransferableHelper
static bool _PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh,
SotClipboardFormatId nFormat, SwPasteSdr 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 );
@@ -168,13 +168,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 = nullptr, sal_Int8 nDropAction = 0,
- bool bPasteSelection = false );
+ 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 d5fd8817bb34..1b98bd6bbee2 100644
--- a/sw/source/uibase/inc/wrtsh.hxx
+++ b/sw/source/uibase/inc/wrtsh.hxx
@@ -291,7 +291,7 @@ typedef bool (SwWrtShell:: *FNSimpleMove)();
// graphic
void Insert( const OUString &rPath, const OUString &rFilter,
const Graphic &, SwFlyFrameAttrMgr * = nullptr,
- bool bRule = false );
+ bool bRule = false, sal_uInt16 nAnchorType = 0 );
void InsertByWord( const OUString & );
void InsertPageBreak(const OUString *pPageDesc = nullptr, 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 f6d6b75fad0c..06e3f8876796 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -284,7 +284,13 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
// Temporary variables, because the shell could already be
// destroyed after the paste.
SwView* pView = &rView;
- SwTransferable::Paste( rSh, aDataHelper );
+
+ const SfxUInt16Item* pAnchorType = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
+ if (pAnchorType)
+ SwTransferable::Paste(rSh, aDataHelper, pAnchorType->GetValue());
+ else
+ SwTransferable::Paste(rSh, aDataHelper);
+
if( rSh.IsFrameSelected() || rSh.IsObjSelected() )
rSh.EnterSelFrameMode();
pView->AttrChangedNotify( &rSh );
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index c10e6ffd5d42..90ce1e13e170 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -241,7 +241,7 @@ void SwWrtShell::Insert( const OUString &rStr )
void SwWrtShell::Insert( const OUString &rPath, const OUString &rFilter,
const Graphic &rGrf, SwFlyFrameAttrMgr *pFrameMgr,
- bool bRule )
+ bool bRule, sal_uInt16 nAnchorType )
{
ResetCursorStack();
if ( !CanInsert() )
@@ -277,9 +277,9 @@ void SwWrtShell::Insert( const OUString &rPath, const OUString &rFilter,
// These must be removed explicitly for the optimal size.
pFrameMgr->DelAttr(RES_FRM_SIZE);
- if (comphelper::LibreOfficeKit::isActive())
- // LOK: anchor inserted images as-char by default.
- pFrameMgr->SetAnchor(FLY_AS_CHAR);
+ if (nAnchorType != 0)
+ // Something other than at-para was requested.
+ pFrameMgr->SetAnchor(static_cast<RndStdIds>(nAnchorType));
}
else
{