[Libreoffice-commits] core.git: 2 commits - desktop/qa libreofficekit/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Jan 21 06:39:25 PST 2016


 desktop/qa/desktop_lib/test_desktop_lib.cxx         |    5 +++
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |   26 ++++++++++++++++----
 sw/source/uibase/wrtsh/wrtsh1.cxx                   |    5 +++
 3 files changed, 32 insertions(+), 4 deletions(-)

New commits:
commit e7eca35148204d094dcdb7d8b3e4ec6c9d454159
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 21 15:20:45 2016 +0100

    sw tiled editing: default to anchoring new images as-char
    
    Change-Id: I6aeb06fe1697b7a30e83a3b1b364f44e5822fe95

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index e0f043c..84fca2b 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -16,6 +16,7 @@
 #include <com/sun/star/awt/Toolkit.hpp>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
 #include <boost/property_tree/json_parser.hpp>
 #include <comphelper/processfactory.hxx>
 #include <sfx2/objsh.hxx>
@@ -450,6 +451,10 @@ void DesktopLOKTest::testPasteWriterJPEG()
     // This was 0, JPEG was not handled as a format for clipboard paste.
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xDrawPage->getCount());
 
+    uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+    // This was text::TextContentAnchorType_AT_PARAGRAPH.
+    CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, xShape->getPropertyValue("AnchorType").get<text::TextContentAnchorType>());
+
     comphelper::LibreOfficeKit::setActive(false);
 }
 
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index e82f8aa..aa4324e 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -105,6 +105,7 @@
 #include "FrameControlsManager.hxx"
 
 #include <sfx2/msgpool.hxx>
+#include <comphelper/lok.hxx>
 #include <memory>
 
 using namespace sw::mark;
@@ -275,6 +276,10 @@ void SwWrtShell::Insert( const OUString &rPath, const OUString &rFilter,
         // because of the DEF-Framesize
         // 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);
     }
     else
     {
commit ccb3d6e7ea5fc01ed5233b20ef950aa00e65e80a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 21 15:12:23 2016 +0100

    gtktiledviewer: support pasting PNG images
    
    Change-Id: Ifaf96dee8b6554282f6a19ac6d6e0d14318aa1f4

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 1bc6529..c6dbc7d 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -601,25 +601,43 @@ static void doPaste(GtkWidget* pButton, gpointer /*pItem*/)
 
     GdkAtom* pTargets;
     gint nTargets;
-    boost::optional<GdkAtom> oTarget;
+    std::map<std::string, GdkAtom> aTargets;
     if (gtk_clipboard_wait_for_targets(pClipboard, &pTargets, &nTargets))
     {
         for (gint i = 0; i < nTargets; ++i)
         {
             gchar* pName = gdk_atom_name(pTargets[i]);
-            if (std::string(pName) == "text/html")
-                oTarget = pTargets[i];
+            aTargets[pName] = pTargets[i];
             g_free(pName);
         }
         g_free(pTargets);
     }
 
+    boost::optional<GdkAtom> oTarget;
+    std::string aTargetName;
+
+    std::vector<std::string> aPreferredNames =
+    {
+        std::string("image/png"),
+        std::string("text/html")
+    };
+    for (const std::string& rName : aPreferredNames)
+    {
+        std::map<std::string, GdkAtom>::iterator it = aTargets.find(rName);
+        if (it != aTargets.end())
+        {
+            aTargetName = it->first;
+            oTarget = it->second;
+            break;
+        }
+    }
+
     if (oTarget)
     {
         GtkSelectionData* pSelectionData = gtk_clipboard_wait_for_contents(pClipboard, *oTarget);
         gint nLength;
         const guchar* pData = gtk_selection_data_get_data_with_length(pSelectionData, &nLength);
-        bool bSuccess = lok_doc_view_paste(pLOKDocView, "text/html", reinterpret_cast<const char*>(pData), nLength);
+        bool bSuccess = lok_doc_view_paste(pLOKDocView, aTargetName.c_str(), reinterpret_cast<const char*>(pData), nLength);
         gtk_selection_data_free(pSelectionData);
         if (bSuccess)
             return;


More information about the Libreoffice-commits mailing list