[Libreoffice-commits] core.git: sw/CppunitTest_sw_ooxmlimport2.mk sw/Module_sw.mk sw/qa

Mark Hung marklh9 at gmail.com
Sat May 5 10:33:56 UTC 2018


 sw/CppunitTest_sw_ooxmlimport2.mk         |  107 +++++++++++++++
 sw/Module_sw.mk                           |    1 
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx  |  160 -----------------------
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx |  201 ++++++++++++++++++++++++++++++
 4 files changed, 309 insertions(+), 160 deletions(-)

New commits:
commit 266e3fa59a83b17f93765bf517f6db7ee324bdee
Author: Mark Hung <marklh9 at gmail.com>
Date:   Thu May 3 07:36:38 2018 +0800

    sw: move tests in ooxmlimport to ooxmlimport2.
    
    To avoid using -bigobj on Windows.
    
    Change-Id: I3115fc01a0802c4b40219bb6f7ea934df81706ed
    Reviewed-on: https://gerrit.libreoffice.org/53769
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mark Hung <marklh9 at gmail.com>

diff --git a/sw/CppunitTest_sw_ooxmlimport2.mk b/sw/CppunitTest_sw_ooxmlimport2.mk
new file mode 100644
index 000000000000..d170cb822b2e
--- /dev/null
+++ b/sw/CppunitTest_sw_ooxmlimport2.mk
@@ -0,0 +1,107 @@
+# -*- 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_ooxmlimport2))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_ooxmlimport2, \
+    sw/qa/extras/ooxmlimport/ooxmlimport2 \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_ooxmlimport2, \
+    basegfx \
+    comphelper \
+    cppu \
+    cppuhelper \
+    sal \
+    sfx \
+    test \
+    unotest \
+    utl \
+    sw \
+    tl \
+    vcl \
+    svxcore \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_ooxmlimport2,\
+	boost_headers \
+    libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_ooxmlimport2,\
+    -I$(SRCDIR)/sw/inc \
+    -I$(SRCDIR)/sw/source/core/inc \
+    -I$(SRCDIR)/sw/qa/extras/inc \
+    $$(INCLUDE) \
+))
+
+ifeq ($(OS),MACOSX)
+
+$(eval $(call gb_CppunitTest_add_cxxflags,sw_ooxmlimport2,\
+    $(gb_OBJCXXFLAGS) \
+))
+
+$(eval $(call gb_CppunitTest_use_system_darwin_frameworks,sw_ooxmlimport2,\
+	AppKit \
+))
+
+endif
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sw_ooxmlimport2))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_ooxmlimport2))
+$(eval $(call gb_CppunitTest_use_vcl,sw_ooxmlimport2))
+
+$(eval $(call gb_CppunitTest_use_components,sw_ooxmlimport2,\
+	basic/util/sb \
+    chart2/source/controller/chartcontroller \
+    chart2/source/chartcore \
+	canvas/source/factory/canvasfactory \
+    comphelper/util/comphelp \
+    configmgr/source/configmgr \
+    drawinglayer/drawinglayer \
+    embeddedobj/util/embobj \
+    emfio/emfio \
+    filter/source/config/cache/filterconfig1 \
+    forms/util/frm \
+    framework/util/fwk \
+    i18npool/util/i18npool \
+    linguistic/source/lng \
+    oox/util/oox \
+    package/source/xstor/xstor \
+    package/util/package2 \
+    sax/source/expatwrap/expwrap \
+    sw/util/sw \
+    sw/util/swd \
+    sw/util/msword \
+    sfx2/util/sfx \
+    sot/util/sot \
+    starmath/util/sm \
+    svl/source/fsstor/fsstorage \
+    svl/util/svl \
+    svtools/util/svt \
+    svx/util/svx \
+    svx/util/svxcore \
+    toolkit/util/tk \
+    ucb/source/core/ucb1 \
+    ucb/source/ucp/file/ucpfile1 \
+    unotools/util/utl \
+    unoxml/source/service/unoxml \
+    unoxml/source/rdf/unordf \
+    uui/util/uui \
+    vcl/vcl.common \
+    writerfilter/util/writerfilter \
+    xmloff/util/xo \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sw_ooxmlimport2))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 01a67af503a9..87367d05de5c 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -77,6 +77,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
     CppunitTest_sw_ooxmlw14export \
     CppunitTest_sw_ooxmlencryption \
     CppunitTest_sw_ooxmlimport \
+    CppunitTest_sw_ooxmlimport2 \
     CppunitTest_sw_ww8export \
     CppunitTest_sw_ww8export2 \
     CppunitTest_sw_ww8import \
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 7b60b191df67..4743cbc8afed 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1440,166 +1440,6 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108995, "xml_space.docx")
                          paragraph->getString());
 }
 
-DECLARE_OOXMLIMPORT_TEST(testTdf108545_embeddedDocxIcon, "tdf108545_embeddedDocxIcon.docx")
-{
-    uno::Reference<document::XEmbeddedObjectSupplier2> xSupplier(getShape(1), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(embed::Aspects::MSOLE_ICON, xSupplier->getAspect());
-}
-
-
-DECLARE_OOXMLIMPORT_TEST(testTdf109053, "tdf109053.docx")
-{
-    // Table was imported into a text frame which led to a one page document
-    // Originally the table takes two pages, so Writer should import it accordingly.
-    CPPUNIT_ASSERT_EQUAL(getPages(), 2);
-}
-
-DECLARE_OOXMLIMPORT_TEST(testTdf108849, "tdf108849.docx")
-{
-    // sectPr element that is child element of body must be the last child. However, Word accepts it
-    // in wrong places, and we should do the same (bug-to-bug compatibility) without creating extra sections.
-    CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Misplaced body-level sectPr's create extra sections!", 2, getPages());
-}
-
-DECLARE_OOXMLIMPORT_TEST(testTdf109524, "tdf109524.docx")
-{
-    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
-    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
-    // The table should have a small width (just to hold the short text in its single cell).
-    // Until it's correctly implemented, we assign it 100% relative width.
-    // Previously, the table (without explicitly set width) had huge actual width
-    // and extended far outside of page's right border.
-    CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTables->getByIndex(0), "IsWidthRelative"));
-    CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xTables->getByIndex(0), "RelativeWidth"));
-}
-
-DECLARE_OOXMLIMPORT_TEST(testGroupShapeFontName, "groupshape-fontname.docx")
-{
-    // Font names inside a group shape were not imported
-    uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
-    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText();
-
-    CPPUNIT_ASSERT_EQUAL(OUString("Calibri"), getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "CharFontName"));
-    CPPUNIT_ASSERT_EQUAL(OUString("Calibri"), getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "CharFontNameComplex"));
-    CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "CharFontNameAsian"));
-}
-
-DECLARE_OOXMLIMPORT_TEST(testTdf111550, "tdf111550.docx")
-{
-    // The test document has following ill-formed structure:
-    //
-    //    <w:tbl>
-    //        ...
-    //        <w:tr>
-    //            <w:tc>
-    //                <w:p>
-    //                    <w:r>
-    //                        <w:t>[outer:A2]</w:t>
-    //                        <w:br w:type="textWrapping"/>
-    //                    </w:r>
-    //                    <w:tbl>
-    //                        <w:tr>
-    //                            <w:tc>
-    //                                <w:p>
-    //                                    <w:r>
-    //                                        <w:t>[inner:A1]</w:t>
-    //                                    </w:r>
-    //                                </w:p>
-    //                            </w:tc>
-    //                        </w:tr>
-    //                    </w:tbl>
-    //                </w:p>
-    //            </w:tc>
-    //        </w:tr>
-    //    </w:tbl>
-    //
-    // i.e., a <w:tbl> as direct child of <w:p> inside another table.
-    // Word accepts that illegal OOXML, and treats it as equal to
-    //
-    //    <w:tbl>
-    //        ...
-    //        <w:tr>
-    //            <w:tc>
-    //                <w:tbl>
-    //                    <w:tr>
-    //                        <w:tc>
-    //                            <w:p>
-    //                                <w:r>
-    //                                    <w:t>[outer:A2]</w:t>
-    //                                    <w:br w:type="textWrapping"/>
-    //                                </w:r>
-    //                                <w:r>
-    //                                    <w:t>[inner:A1]</w:t>
-    //                                </w:r>
-    //                            </w:p>
-    //                        </w:tc>
-    //                    </w:tr>
-    //                </w:tbl>
-    //            </w:tc>
-    //        </w:tr>
-    //    </w:tbl>
-    //
-    // i.e., moves all contents of the outer paragraph into the inner table's first paragraph.
-
-    CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
-
-    uno::Reference<text::XTextContent> outerTable = getParagraphOrTable(1);
-    getCell(outerTable, "A1", "[outer:A1]");
-    uno::Reference<text::XText> cellA2(getCell(outerTable, "A2"), uno::UNO_QUERY_THROW);
-    uno::Reference<text::XTextContent> innerTable = getParagraphOrTable(1, cellA2);
-    getCell(innerTable, "A1", "[outer:A2]\n[inner:A1]");
-}
-
-
-DECLARE_OOXMLIMPORT_TEST(testTdf43017, "tdf43017.docx")
-{
-    uno::Reference<text::XTextRange> xParagraph = getParagraph(1);
-    uno::Reference<text::XTextRange> xText = getRun(xParagraph, 2, "kick the bucket");
-
-    // Ensure that hyperlink text color is not blue (0x0000ff), but default (-1)
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Hyperlink color should be black!",
-        sal_Int32(-1), getProperty<sal_Int32>(xText, "CharColor"));
-}
-
-
-DECLARE_OOXMLIMPORT_TEST(testTdf112443, "tdf112443.docx")
-{
-    // the position of the flying text frame should be off page
-    // 30624 below its anchor
-    OUString aTop = parseDump("//fly[1]/infos/bounds", "top");
-    CPPUNIT_ASSERT_EQUAL( OUString("30624"), aTop );
-
-}
-
-// DOCX: Textbox wrap differs in MSO and LO
-// Both should layout text regardless of existing text box
-// and as result only one page should be generated.
-DECLARE_OOXMLIMPORT_TEST(testTdf113182, "tdf113182.docx")
-{
-    CPPUNIT_ASSERT_EQUAL(getPages(), 1);
-}
-
-DECLARE_OOXMLIMPORT_TEST(testTdf113946, "tdf113946.docx")
-{
-    OUString aTop = parseDump("/root/page/body/txt/anchored/SwAnchoredDrawObject/bounds", "top");
-    CPPUNIT_ASSERT_EQUAL( OUString("1696"), aTop );
-}
-
-DECLARE_OOXMLIMPORT_TEST(testTdf114217, "tdf114217.docx")
-{
-    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
-    uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
-    // This was 1, multi-page table was imported as a floating one.
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount());
-}
-
-DECLARE_OOXMLIMPORT_TEST(testTdf116486, "tdf116486.docx")
-{
-    OUString aTop = parseDump("/root/page/body/txt/Special", "nHeight");
-    CPPUNIT_ASSERT_EQUAL( OUString("4006"), aTop );
-}
-
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
new file mode 100644
index 000000000000..eb3b42a31387
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -0,0 +1,201 @@
+/* -*- 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 <memory>
+#include <config_test.h>
+
+#ifdef MACOSX
+#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
+#include <premac.h>
+#include <AppKit/AppKit.h>
+#include <postmac.h>
+#endif
+
+#include <swmodeltestbase.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
+#include <com/sun/star/embed/Aspects.hpp>
+
+class Test : public SwModelTestBase
+{
+public:
+    Test()
+        : SwModelTestBase("/sw/qa/extras/ooxmlimport/data/", "Office Open XML Text")
+    {
+    }
+};
+
+DECLARE_OOXMLIMPORT_TEST(testTdf108545_embeddedDocxIcon, "tdf108545_embeddedDocxIcon.docx")
+{
+    uno::Reference<document::XEmbeddedObjectSupplier2> xSupplier(getShape(1), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(embed::Aspects::MSOLE_ICON, xSupplier->getAspect());
+}
+
+DECLARE_OOXMLIMPORT_TEST(testTdf109053, "tdf109053.docx")
+{
+    // Table was imported into a text frame which led to a one page document
+    // Originally the table takes two pages, so Writer should import it accordingly.
+    CPPUNIT_ASSERT_EQUAL(getPages(), 2);
+}
+
+DECLARE_OOXMLIMPORT_TEST(testTdf108849, "tdf108849.docx")
+{
+    // sectPr element that is child element of body must be the last child. However, Word accepts it
+    // in wrong places, and we should do the same (bug-to-bug compatibility) without creating extra sections.
+    CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Misplaced body-level sectPr's create extra sections!", 2,
+                                 getPages());
+}
+
+DECLARE_OOXMLIMPORT_TEST(testTdf109524, "tdf109524.docx")
+{
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(),
+                                                    uno::UNO_QUERY);
+    // The table should have a small width (just to hold the short text in its single cell).
+    // Until it's correctly implemented, we assign it 100% relative width.
+    // Previously, the table (without explicitly set width) had huge actual width
+    // and extended far outside of page's right border.
+    CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTables->getByIndex(0), "IsWidthRelative"));
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(100),
+                         getProperty<sal_Int16>(xTables->getByIndex(0), "RelativeWidth"));
+}
+
+DECLARE_OOXMLIMPORT_TEST(testGroupShapeFontName, "groupshape-fontname.docx")
+{
+    // Font names inside a group shape were not imported
+    uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
+    uno::Reference<text::XText> xText
+        = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText();
+
+    CPPUNIT_ASSERT_EQUAL(
+        OUString("Calibri"),
+        getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "CharFontName"));
+    CPPUNIT_ASSERT_EQUAL(
+        OUString("Calibri"),
+        getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "CharFontNameComplex"));
+    CPPUNIT_ASSERT_EQUAL(
+        OUString(""),
+        getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "CharFontNameAsian"));
+}
+
+DECLARE_OOXMLIMPORT_TEST(testTdf111550, "tdf111550.docx")
+{
+    // The test document has following ill-formed structure:
+    //
+    //    <w:tbl>
+    //        ...
+    //        <w:tr>
+    //            <w:tc>
+    //                <w:p>
+    //                    <w:r>
+    //                        <w:t>[outer:A2]</w:t>
+    //                        <w:br w:type="textWrapping"/>
+    //                    </w:r>
+    //                    <w:tbl>
+    //                        <w:tr>
+    //                            <w:tc>
+    //                                <w:p>
+    //                                    <w:r>
+    //                                        <w:t>[inner:A1]</w:t>
+    //                                    </w:r>
+    //                                </w:p>
+    //                            </w:tc>
+    //                        </w:tr>
+    //                    </w:tbl>
+    //                </w:p>
+    //            </w:tc>
+    //        </w:tr>
+    //    </w:tbl>
+    //
+    // i.e., a <w:tbl> as direct child of <w:p> inside another table.
+    // Word accepts that illegal OOXML, and treats it as equal to
+    //
+    //    <w:tbl>
+    //        ...
+    //        <w:tr>
+    //            <w:tc>
+    //                <w:tbl>
+    //                    <w:tr>
+    //                        <w:tc>
+    //                            <w:p>
+    //                                <w:r>
+    //                                    <w:t>[outer:A2]</w:t>
+    //                                    <w:br w:type="textWrapping"/>
+    //                                </w:r>
+    //                                <w:r>
+    //                                    <w:t>[inner:A1]</w:t>
+    //                                </w:r>
+    //                            </w:p>
+    //                        </w:tc>
+    //                    </w:tr>
+    //                </w:tbl>
+    //            </w:tc>
+    //        </w:tr>
+    //    </w:tbl>
+    //
+    // i.e., moves all contents of the outer paragraph into the inner table's first paragraph.
+
+    CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
+
+    uno::Reference<text::XTextContent> outerTable = getParagraphOrTable(1);
+    getCell(outerTable, "A1", "[outer:A1]");
+    uno::Reference<text::XText> cellA2(getCell(outerTable, "A2"), uno::UNO_QUERY_THROW);
+    uno::Reference<text::XTextContent> innerTable = getParagraphOrTable(1, cellA2);
+    getCell(innerTable, "A1", "[outer:A2]\n[inner:A1]");
+}
+
+DECLARE_OOXMLIMPORT_TEST(testTdf43017, "tdf43017.docx")
+{
+    uno::Reference<text::XTextRange> xParagraph = getParagraph(1);
+    uno::Reference<text::XTextRange> xText = getRun(xParagraph, 2, "kick the bucket");
+
+    // Ensure that hyperlink text color is not blue (0x0000ff), but default (-1)
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Hyperlink color should be black!", sal_Int32(-1),
+                                 getProperty<sal_Int32>(xText, "CharColor"));
+}
+
+DECLARE_OOXMLIMPORT_TEST(testTdf112443, "tdf112443.docx")
+{
+    // the position of the flying text frame should be off page
+    // 30624 below its anchor
+    OUString aTop = parseDump("//fly[1]/infos/bounds", "top");
+    CPPUNIT_ASSERT_EQUAL(OUString("30624"), aTop);
+}
+
+// DOCX: Textbox wrap differs in MSO and LO
+// Both should layout text regardless of existing text box
+// and as result only one page should be generated.
+DECLARE_OOXMLIMPORT_TEST(testTdf113182, "tdf113182.docx") { CPPUNIT_ASSERT_EQUAL(getPages(), 1); }
+
+DECLARE_OOXMLIMPORT_TEST(testTdf113946, "tdf113946.docx")
+{
+    OUString aTop = parseDump("/root/page/body/txt/anchored/SwAnchoredDrawObject/bounds", "top");
+    CPPUNIT_ASSERT_EQUAL(OUString("1696"), aTop);
+}
+
+DECLARE_OOXMLIMPORT_TEST(testTdf114217, "tdf114217.docx")
+{
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+    // This was 1, multi-page table was imported as a floating one.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount());
+}
+
+DECLARE_OOXMLIMPORT_TEST(testTdf116486, "tdf116486.docx")
+{
+    OUString aTop = parseDump("/root/page/body/txt/Special", "nHeight");
+    CPPUNIT_ASSERT_EQUAL(OUString("4006"), aTop);
+}
+
+// tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list