1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <test/unoapi_test.hxx>
12 #include <com/sun/star/text/XTextTablesSupplier.hpp>
13 #include <com/sun/star/text/XTextDocument.hpp>
15 using namespace ::com::sun::star
;
19 /// Tests for writerfilter/source/ooxml/.
20 class Test
: public UnoApiTest
24 : UnoApiTest("/writerfilter/qa/cppunittests/ooxml/data/")
29 CPPUNIT_TEST_FIXTURE(Test
, testFloatingTablesLost
)
31 // Given a document with 2 floating tables, the 2nd has an inner floating table as well:
32 loadFromFile(u
"floattable-tables-lost.docx");
34 // When counting the created Writer tables:
35 uno::Reference
<text::XTextTablesSupplier
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
36 uno::Reference
<container::XIndexAccess
> xTables(xTextDocument
->getTextTables(), uno::UNO_QUERY
);
38 // Then make sure that all 3 tables are imported:
39 // Without the accompanying fix in place, this test would have failed with:
42 // i.e. only the inner table was imported, the 2 others were lost.
43 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xTables
->getCount());
46 CPPUNIT_TEST_FIXTURE(Test
, testFloatingTableLeak
)
48 // Given an outer table and 2 inner tables at B1 start:
49 // When importing that document:
50 loadFromFile(u
"floattable-leak.docx");
52 // Then make sure the body text only contains a table and an empty final paragraph:
53 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
54 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xTextDocument
->getText(),
56 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
57 uno::Reference
<lang::XServiceInfo
> xTable(xParaEnum
->nextElement(), uno::UNO_QUERY
);
58 // Without the accompanying fix in place, this test would have failed, the document started with
59 // a paragraph instead of a table.
60 CPPUNIT_ASSERT(xTable
->supportsService("com.sun.star.text.TextTable"));
61 uno::Reference
<lang::XServiceInfo
> xParagraph(xParaEnum
->nextElement(), uno::UNO_QUERY
);
62 CPPUNIT_ASSERT(xParagraph
->supportsService("com.sun.star.text.Paragraph"));
63 CPPUNIT_ASSERT(!xParaEnum
->hasMoreElements());
66 CPPUNIT_TEST_FIXTURE(Test
, testRecursiveHeaderRels
)
68 // Given a document with self-referencing rels in a header/footer:
69 loadFromFile(u
"recursive_header_rels.docx");
70 // It should not crash/hang on load
74 CPPUNIT_PLUGIN_IMPLEMENT();
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */