Use COMReference to handle COM pointers in CreateShortcut
[LibreOffice.git] / sw / qa / core / text / widorp.cxx
blob54d26aa2db07a525e97e2fd8de218b0650e3381c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <swmodeltestbase.hxx>
12 #include <memory>
14 #include <IDocumentLayoutAccess.hxx>
15 #include <doc.hxx>
16 #include <frame.hxx>
17 #include <layfrm.hxx>
18 #include <pagefrm.hxx>
19 #include <rootfrm.hxx>
20 #include <txtfrm.hxx>
21 #include <docsh.hxx>
22 #include <wrtsh.hxx>
23 #include <viewopt.hxx>
25 namespace
27 /// Covers sw/source/core/text/widorp.cxx fixes.
28 class Test : public SwModelTestBase
30 public:
31 Test()
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);
48 calcLayout();
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: */