Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / core / edit / edit.cxx
blob444887fbb0df5c83e53ac7ebd3a228cf462f4e4e
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 <docsh.hxx>
13 #include <view.hxx>
14 #include <wrtsh.hxx>
15 #include <unotxdoc.hxx>
17 namespace
19 /// Covers sw/source/core/edit/ fixes.
20 class Test : public SwModelTestBase
22 public:
23 Test()
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);
41 aSet.Put(aItem);
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:
49 createSwDoc();
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: */