[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - 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
Fri Feb 7 17:03:46 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 282cf1507d51573e5e9a4611b1e775b433168ca7
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Feb 4 14:33:37 2020 +0100
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Fri Feb 7 18:02:50 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)
    
    Change-Id: I2a91af6425035b48a0e47ad9b10939945855cd16
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87997
    Tested-by: Jenkins
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>

diff --git a/sw/CppunitTest_sw_core_doc.mk b/sw/CppunitTest_sw_core_doc.mk
new file mode 100644
index 000000000000..487e02322ef4
--- /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/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 fa571852aea5..06ab4c8f8fa3 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -105,6 +105,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
     CppunitTest_sw_apitests \
     CppunitTest_sw_unowriter \
     CppunitTest_sw_core_text \
+    CppunitTest_sw_core_doc \
     CppunitTest_sw_uibase_shells \
 ))
 
diff --git a/sw/inc/IDocumentContentOperations.hxx b/sw/inc/IDocumentContentOperations.hxx
index 6ba51df9f740..b6857c346a33 100644
--- a/sw/inc/IDocumentContentOperations.hxx
+++ b/sw/inc/IDocumentContentOperations.hxx
@@ -180,7 +180,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 b928420ea824..17348494d6d6 100644
--- a/sw/inc/fesh.hxx
+++ b/sw/inc/fesh.hxx
@@ -622,7 +622,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 c10cd56e93d5..aeafeea3dc2e 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -2855,14 +2855,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 db4c88897024..0a55c4f969dd 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 4f523bec9f3d..2d600b6ff8ba 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