[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sw/CppunitTest_sw_core_doc.mk sw/inc sw/Module_sw.mk sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 5 08:07:09 UTC 2020


 sw/CppunitTest_sw_core_doc.mk                           |   72 ++++++++++++++++
 sw/Module_sw.mk                                         |    1 
 sw/inc/IDocumentContentOperations.hxx                   |    2 
 sw/inc/fesh.hxx                                         |    2 
 sw/qa/core/doc/doc.cxx                                  |   65 ++++++++++++++
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   10 ++
 sw/source/core/frmedt/fefly1.cxx                        |    2 
 sw/source/core/inc/DocumentContentOperationsManager.hxx |    2 
 8 files changed, 151 insertions(+), 5 deletions(-)

New commits:
commit 80a85b950aa044ac77cdf6d0b9379c56ffb0b915
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Feb 4 14:33:37 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Feb 5 09:06:39 2020 +0100

    tdf#130362 sw: fix anchoring of inline math objects
    
    Regression from a7528cd6f17ea5c5b29e7d607e54c62de0d9e7db (sw: insert
    image: set anchor to at-char by default, 2019-11-18), that defaulted to
    at-char anchoring for charts and images.
    
    What was not considered is that math objects had a previous as-char
    default (not to-para), and that is supposed to be unchanged.
    
    (cherry picked from commit a2f85c062aafb3fd9dfb1c6c6e87e1e73e7545a3)
    
    Conflicts:
            sw/Module_sw.mk
    
    Change-Id: I2a91af6425035b48a0e47ad9b10939945855cd16
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87986
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/CppunitTest_sw_core_doc.mk b/sw/CppunitTest_sw_core_doc.mk
new file mode 100644
index 000000000000..cd4b9bcd1559
--- /dev/null
+++ b/sw/CppunitTest_sw_core_doc.mk
@@ -0,0 +1,72 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sw_core_doc))
+
+$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_core_doc))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_core_doc, \
+    sw/qa/core/doc/doc \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_core_doc, \
+    comphelper \
+    cppu \
+    cppuhelper \
+    sal \
+    sfx \
+    sw \
+    test \
+    unotest \
+    utl \
+    vcl \
+    svt \
+    tl \
+    svl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_core_doc,\
+    boost_headers \
+    libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_core_doc,\
+    -I$(SRCDIR)/sw/inc \
+    -I$(SRCDIR)/sw/source/core/inc \
+    -I$(SRCDIR)/sw/source/uibase/inc \
+    -I$(SRCDIR)/sw/qa/extras/inc \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sw_core_doc,\
+	udkapi \
+	offapi \
+	oovbaapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_core_doc))
+$(eval $(call gb_CppunitTest_use_vcl,sw_core_doc))
+
+$(eval $(call gb_CppunitTest_use_rdb,sw_core_doc,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,sw_core_doc,\
+    officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sw_core_doc))
+
+$(eval $(call gb_CppunitTest_use_uiconfigs,sw_core_doc, \
+    modules/swriter \
+))
+
+$(eval $(call gb_CppunitTest_use_more_fonts,sw_core_doc))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index cbc048377e98..67cfa7792f0d 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -98,6 +98,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
     CppunitTest_sw_accessible_relation_set \
     CppunitTest_sw_apitests \
     CppunitTest_sw_unowriter \
+    CppunitTest_sw_core_doc \
     CppunitTest_sw_uibase_shells \
 ))
 
diff --git a/sw/inc/IDocumentContentOperations.hxx b/sw/inc/IDocumentContentOperations.hxx
index f761b27aa331..161682891429 100644
--- a/sw/inc/IDocumentContentOperations.hxx
+++ b/sw/inc/IDocumentContentOperations.hxx
@@ -179,7 +179,7 @@ public:
     */
     virtual SwFlyFrameFormat* InsertEmbObject(
         const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj,
-        const SfxItemSet* pFlyAttrSet) = 0;
+        SfxItemSet* pFlyAttrSet) = 0;
 
     virtual SwFlyFrameFormat* InsertOLE(
         const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect,
diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx
index d4f2f0732983..c16744381ffe 100644
--- a/sw/inc/fesh.hxx
+++ b/sw/inc/fesh.hxx
@@ -618,7 +618,7 @@ public:
     bool GetPageNumber( long nYPos, bool bAtCursorPos, sal_uInt16& rPhyNum, sal_uInt16& rVirtNum, OUString &rDisplay ) const;
 
     SwFlyFrameFormat* InsertObject( const svt::EmbeddedObjectRef&,
-                const SfxItemSet* pFlyAttrSet );
+                SfxItemSet* pFlyAttrSet );
     bool    FinishOLEObj(); ///< Shutdown server.
 
     void GetTableAttr( SfxItemSet & ) const;
diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx
new file mode 100644
index 000000000000..3141c12011cc
--- /dev/null
+++ b/sw/qa/core/doc/doc.cxx
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <swmodeltestbase.hxx>
+
+#include <vcl/gdimtf.hxx>
+#include <comphelper/classids.hxx>
+#include <tools/globname.hxx>
+#include <svtools/embedhlp.hxx>
+
+#include <wrtsh.hxx>
+#include <fmtanchr.hxx>
+
+static char const DATA_DIRECTORY[] = "/sw/qa/core/doc/data/";
+
+/// Covers sw/source/core/doc/ fixes.
+class SwCoreDocTest : public SwModelTestBase
+{
+public:
+    SwDoc* createDoc(const char* pName = nullptr);
+};
+
+SwDoc* SwCoreDocTest::createDoc(const char* pName)
+{
+    if (!pName)
+        loadURL("private:factory/swriter", nullptr);
+    else
+        load(DATA_DIRECTORY, pName);
+
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+    return pTextDoc->GetDocShell()->GetDoc();
+}
+
+CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testMathInsertAnchorType)
+{
+    // Given an empty document.
+    SwDoc* pDoc = createDoc();
+
+    // When inserting an a math object.
+    SwWrtShell* pShell = pDoc->GetDocShell()->GetWrtShell();
+    SvGlobalName aGlobalName(SO3_SM_CLASSID);
+    pShell->InsertObject(svt::EmbeddedObjectRef(), &aGlobalName);
+
+    // Then the anchor type should be as-char.
+    SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rFormats.size());
+    const SwFrameFormat& rFormat = *rFormats[0];
+    const SwFormatAnchor& rAnchor = rFormat.GetAnchor();
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 1
+    // - Actual  : 4
+    // i.e. the anchor type was at-char, not as-char.
+    CPPUNIT_ASSERT_EQUAL(RndStdIds::FLY_AS_CHAR, rAnchor.GetAnchorId());
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index e1e53411115a..dcb298ac226b 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -2780,14 +2780,22 @@ SwFlyFrameFormat* DocumentContentOperationsManager::InsertGraphicObject(
 
 SwFlyFrameFormat* DocumentContentOperationsManager::InsertEmbObject(
         const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj,
-                        const SfxItemSet* pFlyAttrSet)
+                        SfxItemSet* pFlyAttrSet)
 {
     sal_uInt16 nId = RES_POOLFRM_OLE;
     if (xObj.is())
     {
         SvGlobalName aClassName( xObj->getClassID() );
         if (SotExchange::IsMath(aClassName))
+        {
             nId = RES_POOLFRM_FORMEL;
+            if (pFlyAttrSet && pFlyAttrSet->HasItem(RES_ANCHOR))
+            {
+                // Clear the at-char anchor set in the SwFlyFrameAttrMgr ctor, so the as-char one
+                // set later in pFrameFormat is considered.
+                pFlyAttrSet->ClearItem(RES_ANCHOR);
+            }
+        }
     }
 
     SwFrameFormat* pFrameFormat = m_rDoc.getIDocumentStylePoolAccess().GetFrameFormatFromPool( nId );
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index 65a19bc00487..eb4ec7349f94 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -889,7 +889,7 @@ void SwFEShell::Insert( const OUString& rGrfName, const OUString& rFltName,
 }
 
 SwFlyFrameFormat* SwFEShell::InsertObject( const svt::EmbeddedObjectRef&  xObj,
-                        const SfxItemSet* pFlyAttrSet )
+                        SfxItemSet* pFlyAttrSet )
 {
     SwFlyFrameFormat* pFormat = nullptr;
     SET_CURR_SHELL( this );
diff --git a/sw/source/core/inc/DocumentContentOperationsManager.hxx b/sw/source/core/inc/DocumentContentOperationsManager.hxx
index e276d4e61238..3ed457bd3f33 100644
--- a/sw/source/core/inc/DocumentContentOperationsManager.hxx
+++ b/sw/source/core/inc/DocumentContentOperationsManager.hxx
@@ -73,7 +73,7 @@ public:
 
     SwDrawFrameFormat* InsertDrawObj( const SwPaM &rRg, SdrObject& rDrawObj, const SfxItemSet& rFlyAttrSet ) override;
 
-    SwFlyFrameFormat* InsertEmbObject(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj, const SfxItemSet* pFlyAttrSet) override;
+    SwFlyFrameFormat* InsertEmbObject(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj, SfxItemSet* pFlyAttrSet) override;
 
     SwFlyFrameFormat* InsertOLE(const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect, const SfxItemSet* pFlyAttrSet,
                            const SfxItemSet* pGrfAttrSet) override;


More information about the Libreoffice-commits mailing list