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>
12 #include <comphelper/propertyvalue.hxx>
21 /// Covers sw/source/uibase/shells/textfld.cxx fixes.
22 class Test
: public SwModelTestBase
26 : SwModelTestBase("/sw/qa/uibase/shells/data/")
32 CPPUNIT_TEST_FIXTURE(Test
, testInsertRefmarkFootnote
)
34 // Given an empty document:
37 // When inserting a refmark inside a footnote:
38 uno::Sequence
<css::beans::PropertyValue
> aArgs
= {
39 comphelper::makePropertyValue("TypeName", uno::Any(OUString("SetRef"))),
40 comphelper::makePropertyValue("Name", uno::Any(OUString("myref"))),
41 comphelper::makePropertyValue("Content", uno::Any(OUString("content"))),
42 comphelper::makePropertyValue("Wrapper", uno::Any(OUString("Footnote"))),
44 dispatchCommand(mxComponent
, ".uno:InsertField", aArgs
);
46 // Then make sure that the note body contains the refmark:
47 SwDoc
* pDoc
= getSwDoc();
48 SwFootnoteIdxs
& rNotes
= pDoc
->GetFootnoteIdxs();
49 // Without the accompanying fix in place, this test would have failed with:
52 // i.e. no note was inserted.
53 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rNotes
.size());
54 SwTextFootnote
* pNote
= rNotes
[0];
55 const SwFormatFootnote
& rFormatNote
= pNote
->GetFootnote();
56 CPPUNIT_ASSERT(!rFormatNote
.IsEndNote());
57 SwWrtShell
* pWrtShell
= getSwDocShell()->GetWrtShell();
58 CPPUNIT_ASSERT_EQUAL(OUString("content"), rFormatNote
.GetFootnoteText(*pWrtShell
->GetLayout()));
61 CPPUNIT_TEST_FIXTURE(Test
, testInsertRefmarkEndnote
)
63 // Given an empty document:
66 // When inserting a refmark inside an endnote:
67 uno::Sequence
<css::beans::PropertyValue
> aArgs
= {
68 comphelper::makePropertyValue("TypeName", uno::Any(OUString("SetRef"))),
69 comphelper::makePropertyValue("Name", uno::Any(OUString("myref"))),
70 comphelper::makePropertyValue("Content", uno::Any(OUString("content"))),
71 comphelper::makePropertyValue("Wrapper", uno::Any(OUString("Endnote"))),
73 dispatchCommand(mxComponent
, ".uno:InsertField", aArgs
);
75 // Then make sure that the note body contains the refmark:
76 SwDoc
* pDoc
= getSwDoc();
77 SwFootnoteIdxs
& rNotes
= pDoc
->GetFootnoteIdxs();
78 // Without the accompanying fix in place, this test would have failed with:
81 // i.e. no endnote was inserted.
82 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rNotes
.size());
83 SwTextFootnote
* pNote
= rNotes
[0];
84 const SwFormatFootnote
& rNote
= pNote
->GetFootnote();
85 CPPUNIT_ASSERT(rNote
.IsEndNote());
86 SwWrtShell
* pWrtShell
= getSwDocShell()->GetWrtShell();
87 CPPUNIT_ASSERT_EQUAL(OUString("content"), rNote
.GetFootnoteText(*pWrtShell
->GetLayout()));
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */