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 <swmodeltestbase.hxx>
12 #include <IDocumentLayoutAccess.hxx>
13 #include <rootfrm.hxx>
14 #include <pagefrm.hxx>
19 /// Covers sw/source/core/layout/tabfrm.cxx fixes.
20 class Test
: public SwModelTestBase
24 : SwModelTestBase("/sw/qa/core/layout/data/")
29 CPPUNIT_TEST_FIXTURE(Test
, testTablePrintAreaLeft
)
31 // Given a document with a header containing an image, and also with an overlapping table:
32 createSwDoc("table-print-area-left.docx");
34 // When laying out that document & parsing the left margin of the table:
35 SwTwips nTablePrintLeft
= parseDump("//tab/infos/prtBounds", "left").toInt32();
37 // Then make sure it has ~no left margin:
38 // Without the accompanying fix in place, this test would have failed with:
41 // i.e. the table was shifted outside the page, was invisible.
42 CPPUNIT_ASSERT_EQUAL(static_cast<SwTwips
>(5), nTablePrintLeft
);
45 CPPUNIT_TEST_FIXTURE(Test
, testTableMissingJoin
)
47 // Given a document with a table on page 2:
48 // When laying out that document:
49 createSwDoc("table-missing-join.docx");
51 // Then make sure that the table fits page 2:
52 SwDoc
* pDoc
= getSwDoc();
53 SwRootFrame
* pLayout
= pDoc
->getIDocumentLayoutAccess().GetCurrentLayout();
54 auto pPage1
= pLayout
->Lower()->DynCastPageFrame();
55 CPPUNIT_ASSERT(pPage1
);
56 auto pPage2
= pPage1
->GetNext()->DynCastPageFrame();
57 CPPUNIT_ASSERT(pPage2
);
58 SwFrame
* pBody
= pPage2
->FindBodyCont();
59 auto pTab
= pBody
->GetLower()->DynCastTabFrame();
60 // Without the accompanying fix in place, this test would have failed, the table continued on
62 CPPUNIT_ASSERT(!pTab
->HasFollow());
65 CPPUNIT_TEST_FIXTURE(Test
, testSplitFlyInInlineTable
)
67 // Outer inline table on pages 1 -> 2 -> 3, inner floating table on pages 2 -> 3:
68 // When laying out that document:
69 createSwDoc("floattable-in-inlinetable.docx");
71 // Then make sure that the outer table is not missing on page 3:
72 SwDoc
* pDoc
= getSwDoc();
73 SwRootFrame
* pLayout
= pDoc
->getIDocumentLayoutAccess().GetCurrentLayout();
74 auto pPage1
= pLayout
->Lower()->DynCastPageFrame();
75 CPPUNIT_ASSERT(pPage1
);
77 SwFrame
* pBody
= pPage1
->FindBodyCont();
78 auto pTab
= pBody
->GetLower()->DynCastTabFrame();
79 CPPUNIT_ASSERT(!pTab
->GetPrecede());
80 CPPUNIT_ASSERT(pTab
->GetFollow());
82 auto pPage2
= pPage1
->GetNext()->DynCastPageFrame();
83 CPPUNIT_ASSERT(pPage2
);
85 SwFrame
* pBody
= pPage2
->FindBodyCont();
86 auto pTab
= pBody
->GetLower()->DynCastTabFrame();
87 CPPUNIT_ASSERT(pTab
->GetPrecede());
88 // Without the accompanying fix in place, this test would have failed, the outer table was
90 CPPUNIT_ASSERT(pTab
->GetFollow());
92 auto pPage3
= pPage2
->GetNext()->DynCastPageFrame();
93 CPPUNIT_ASSERT(pPage3
);
95 SwFrame
* pBody
= pPage3
->FindBodyCont();
96 auto pTab
= pBody
->GetLower()->DynCastTabFrame();
97 CPPUNIT_ASSERT(pTab
->GetPrecede());
98 CPPUNIT_ASSERT(!pTab
->GetFollow());
102 CPPUNIT_TEST_FIXTURE(Test
, testSplitFlyNestedRowSpan
)
104 // Given a document with nested floating tables and a row with rowspan cells at page boundary:
105 // When loading that document:
106 // Without the accompanying fix in place, this test would have resulted in a layout loop.
107 createSwDoc("floattable-nested-rowspan.docx");
109 // Then make sure the resulting page count matches Word:
110 CPPUNIT_ASSERT_EQUAL(6, getPages());
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */