diff options
Diffstat (limited to 'sw/qa/core/layout')
-rw-r--r-- | sw/qa/core/layout/calcmove.cxx | 87 | ||||
-rw-r--r-- | sw/qa/core/layout/data/bad-split-section.odt | bin | 0 -> 29305 bytes | |||
-rw-r--r-- | sw/qa/core/layout/data/ignore-top-margin-fly.odt | bin | 0 -> 11395 bytes | |||
-rw-r--r-- | sw/qa/core/layout/data/ignore-top-margin-table.docx | bin | 0 -> 12465 bytes | |||
-rw-r--r-- | sw/qa/core/layout/data/ignore-top-margin.docx | bin | 0 -> 14904 bytes | |||
-rw-r--r-- | sw/qa/core/layout/layact.cxx | 22 |
6 files changed, 109 insertions, 0 deletions
diff --git a/sw/qa/core/layout/calcmove.cxx b/sw/qa/core/layout/calcmove.cxx new file mode 100644 index 0000000000..ad53df9bd0 --- /dev/null +++ b/sw/qa/core/layout/calcmove.cxx @@ -0,0 +1,87 @@ +/* -*- 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 <test/xmldocptr.hxx> + +namespace +{ +/// Covers sw/source/core/layout/calcmove.cxx fixes. +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase("/sw/qa/core/layout/data/") + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testIgnoreTopMargin) +{ + // Given a DOCX (>= Word 2013) file, with 2 pages: + // When loading that document: + createSwDoc("ignore-top-margin.docx"); + + // Then make sure that the paragraph on the 2nd page has no top margin: + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 nParaTopMargin + = getXPath(pXmlDoc, "/root/page[2]/body/txt/infos/prtBounds"_ostr, "top"_ostr).toInt32(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 0 + // - Actual : 2400 + // i.e. the top margin in the first para of a non-first page wasn't ignored, like in Word. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), nParaTopMargin); +} + +CPPUNIT_TEST_FIXTURE(Test, testIgnoreTopMarginTable) +{ + // Given a DOCX (>= Word 2013) file, with 2 pages: + // When loading that document: + createSwDoc("ignore-top-margin-table.docx"); + + // Then make sure that the paragraph on the 2nd page in B1 has a top margin: + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 nParaTopMargin + = getXPath(pXmlDoc, "/root/page[2]/body/tab/row/cell[2]/txt/infos/prtBounds"_ostr, + "top"_ostr) + .toInt32(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2000 + // - Actual : 0 + // i.e. the top margin in B1's first paragraph was ignored, but not in Word. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2000), nParaTopMargin); +} + +CPPUNIT_TEST_FIXTURE(Test, testIgnoreTopMarginFly) +{ + // Given a document with compat flags like DOCX (>= Word 2013), 2 pages, multi-col fly frame on + // page 2: + createSwDoc("ignore-top-margin-fly.odt"); + + // When laying out that document: + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + + // Then make sure that the top margin is not ignored inside shape text: + sal_Int32 nParaTopMargin + = getXPath( + pXmlDoc, + "/root/page[2]/body/section/column[2]/body/txt/anchored/fly/column/body/txt/infos/prtBounds"_ostr, + "top"_ostr) + .toInt32(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 4000 + // - Actual : 0 + // i.e. the top margin was ignored inside shape text for Word compat, while multi-col shape text + // is a Writer feature. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4000), nParaTopMargin); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/layout/data/bad-split-section.odt b/sw/qa/core/layout/data/bad-split-section.odt Binary files differnew file mode 100644 index 0000000000..6dbd07802d --- /dev/null +++ b/sw/qa/core/layout/data/bad-split-section.odt diff --git a/sw/qa/core/layout/data/ignore-top-margin-fly.odt b/sw/qa/core/layout/data/ignore-top-margin-fly.odt Binary files differnew file mode 100644 index 0000000000..51bda8fe40 --- /dev/null +++ b/sw/qa/core/layout/data/ignore-top-margin-fly.odt diff --git a/sw/qa/core/layout/data/ignore-top-margin-table.docx b/sw/qa/core/layout/data/ignore-top-margin-table.docx Binary files differnew file mode 100644 index 0000000000..c82f6d63c1 --- /dev/null +++ b/sw/qa/core/layout/data/ignore-top-margin-table.docx diff --git a/sw/qa/core/layout/data/ignore-top-margin.docx b/sw/qa/core/layout/data/ignore-top-margin.docx Binary files differnew file mode 100644 index 0000000000..d05a1358db --- /dev/null +++ b/sw/qa/core/layout/data/ignore-top-margin.docx diff --git a/sw/qa/core/layout/layact.cxx b/sw/qa/core/layout/layact.cxx index 8923d6b0e8..9de0c9ebfa 100644 --- a/sw/qa/core/layout/layact.cxx +++ b/sw/qa/core/layout/layact.cxx @@ -21,6 +21,7 @@ #include <sortedobjs.hxx> #include <tabfrm.hxx> #include <wrtsh.hxx> +#include <sectfrm.hxx> namespace { @@ -108,6 +109,27 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInSection) CPPUNIT_ASSERT(pPage2); CPPUNIT_ASSERT(!pPage2->GetSortedObjs()); } + +CPPUNIT_TEST_FIXTURE(Test, testBadSplitSection) +{ + // Given a document with a section, containing 5 paragraphs: + createSwDoc("bad-split-section.odt"); + + // When laying out that document: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + + // Then make sure the entire section is on page 1: + auto pPage = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage); + auto pBody = pPage->FindBodyCont(); + CPPUNIT_ASSERT(pBody); + auto pSection = dynamic_cast<SwSectionFrame*>(pBody->GetLastLower()); + CPPUNIT_ASSERT(pSection); + // Without the fix in place, it would have failed, the section was split between page 1 and page + // 2. + CPPUNIT_ASSERT(!pSection->GetFollow()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |