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>
15 #include <unotxdoc.hxx>
19 /// Covers sw/source/core/edit/ fixes.
20 class Test
: public SwModelTestBase
24 : SwModelTestBase("/sw/qa/core/edit/data/")
30 CPPUNIT_TEST_FIXTURE(Test
, testRedlineHidden
)
32 // Given a document with ShowRedlineChanges=false:
33 createSwDoc("redline-hidden.fodt");
34 SwDoc
* pDoc
= getSwDoc();
36 // When formatting a paragraph by setting the para adjust to center, then make sure setting the
37 // new item set on the paragraph doesn't crash:
38 SwView
* pView
= pDoc
->GetDocShell()->GetView();
39 SfxItemSet
aSet(pView
->GetPool(), svl::Items
<RES_PARATR_ADJUST
, RES_PARATR_ADJUST
>);
40 SvxAdjustItem
aItem(SvxAdjust::Center
, RES_PARATR_ADJUST
);
42 SwWrtShell
* pWrtShell
= pDoc
->GetDocShell()->GetWrtShell();
43 pWrtShell
->SetAttrSet(aSet
, SetAttrMode::DEFAULT
, nullptr, true);
46 CPPUNIT_TEST_FIXTURE(Test
, testAutocorrect
)
48 // Given an empty document:
51 // When typing a string, which contains a "-", then make sure no memory corruption happens when
52 // it gets auto-corrected to "–":
53 auto pTextDoc
= dynamic_cast<SwXTextDocument
*>(mxComponent
.get());
54 // Without the accompanying fix in place, this test would have failed with a
55 // heap-use-after-free:
56 emulateTyping(*pTextDoc
, u
"But not now - with ");
59 CPPUNIT_PLUGIN_IMPLEMENT();
61 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */