[Libreoffice-commits] core.git: desktop/qa desktop/source sfx2/sdi sw/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Jan 28 07:45:55 PST 2016


 desktop/qa/desktop_lib/test_desktop_lib.cxx |   11 +++++++++++
 desktop/source/lib/init.cxx                 |    7 ++++++-
 sfx2/sdi/sfx.sdi                            |    2 +-
 sw/source/uibase/dochdl/swdtflvr.cxx        |   12 ++++++------
 sw/source/uibase/inc/swdtflvr.hxx           |    6 +++---
 sw/source/uibase/inc/wrtsh.hxx              |    2 +-
 sw/source/uibase/shells/basesh.cxx          |    8 +++++++-
 sw/source/uibase/wrtsh/wrtsh1.cxx           |    8 ++++----
 8 files changed, 39 insertions(+), 17 deletions(-)

New commits:
commit 552361aaad740e55fcfa7993b4111aba354f863f
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.
    
    Change-Id: I3b2987abbaf1f259c614b7b2a8709f15048d362d

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 84fca2b..705fa24 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -455,6 +455,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 eecb16a..dc1a04f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -32,6 +32,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>
@@ -47,6 +48,7 @@
 #include <com/sun/star/ucb/XUniversalContentBroker.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>
@@ -1176,7 +1178,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 0fd4262..08eddfc 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -4133,7 +4133,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 0c4e60e..1aa955a 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -1131,7 +1131,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 );
@@ -1172,7 +1172,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,
@@ -1180,7 +1180,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;
@@ -1513,7 +1513,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:
@@ -2256,7 +2256,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;
 
@@ -2364,7 +2364,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 8f9bd43..852fbe6 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, 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 );
@@ -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 = 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 dae1c2c..ff15930 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 b11d402..be0bc3d 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -285,7 +285,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 aa4324e..b03c892 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
     {


More information about the Libreoffice-commits mailing list