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>
14 #include <IDocumentLayoutAccess.hxx>
18 #include <pagefrm.hxx>
19 #include <rootfrm.hxx>
23 #include <viewopt.hxx>
27 /// Covers sw/source/core/text/widorp.cxx fixes.
28 class Test
: public SwModelTestBase
32 : SwModelTestBase(u
"/sw/qa/core/text/data/"_ustr
)
37 CPPUNIT_TEST_FIXTURE(Test
, testHideWhitespaceWidorp
)
39 // Given a document with 3 paragraphs: 1.5 on page 1, 1.5 on page 2:
40 createSwDoc("hide-whitespace-widorp.odt");
42 // When hiding whitespace:
43 SwDocShell
* pDocShell
= getSwDocShell();
44 SwWrtShell
* pWrtShell
= pDocShell
->GetWrtShell();
45 SwViewOption
aViewOptions(*pWrtShell
->GetViewOptions());
46 aViewOptions
.SetHideWhitespaceMode(true);
47 pWrtShell
->ApplyViewOptions(aViewOptions
);
50 // Then make sure that paragraph 2 is still split:
51 SwDoc
* pDoc
= pDocShell
->GetDoc();
52 SwRootFrame
* pLayout
= pDoc
->getIDocumentLayoutAccess().GetCurrentLayout();
53 auto pPage
= pLayout
->Lower()->DynCastPageFrame();
54 CPPUNIT_ASSERT(pPage
);
55 SwFrame
* pBody
= pPage
->FindBodyCont();
56 SwFrame
* pPara1
= pBody
->GetLower();
57 auto pPara2
= pPara1
->GetNext()->DynCastTextFrame();
58 CPPUNIT_ASSERT(pPara2
);
59 // Without the accompanying fix in place, this test would have failed, the entire paragraph 2
60 // went to page 1, so it was not split anymore.
61 CPPUNIT_ASSERT(pPara2
->HasFollow());
65 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */