| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 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 |
*/ |
| 9 |
|
| 10 |
#include <swmodeltestbase.hxx> |
| 11 |
|
| 12 |
#include <comphelper/propertyvalue.hxx> |
| 13 |
|
| 14 |
#include <wrtsh.hxx> |
| 15 |
#include <docsh.hxx> |
| 16 |
|
| 17 |
namespace |
| 18 |
{ |
| 19 |
/// Covers sw/source/uibase/dialog/ fixes. |
| 20 |
class Test : public SwModelTestBase |
| 21 |
{ |
| 22 |
public: |
| 23 |
Test() |
| 24 |
: SwModelTestBase(u"/sw/qa/uibase/dialog/data/"_ustr) |
| 25 |
{ |
| 26 |
} |
| 27 |
}; |
| 28 |
} |
| 29 |
|
| 30 |
CPPUNIT_TEST_FIXTURE(Test, testInsertSection) |
| 31 |
{ |
| 32 |
// Given an empty document: |
| 33 |
createSwDoc(); |
| 34 |
|
| 35 |
// When inserting a section with text: |
| 36 |
uno::Sequence<css::beans::PropertyValue> aArgs = { |
| 37 |
comphelper::makePropertyValue( |
| 38 |
u"RegionName"_ustr, uno::Any(u"ZOTERO_BIBL {} CSL_BIBLIOGRAPHY RNDRfiit6mXBc"_ustr)), |
| 39 |
comphelper::makePropertyValue(u"Content"_ustr, uno::Any(u"<p>aaa</p><p>bbb</p>"_ustr)), |
| 40 |
}; |
| 41 |
dispatchCommand(mxComponent, u".uno:InsertSection"_ustr, aArgs); |
| 42 |
|
| 43 |
// Then make sure that we created a section that covers that text: |
| 44 |
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); |
| 45 |
pWrtShell->SttEndDoc(/*bStt=*/true); |
| 46 |
pWrtShell->EndOfSection(/*bSelect=*/true); |
| 47 |
SwCursor* pCursor = pWrtShell->GetCursor(); |
| 48 |
OUString aActualResult = pCursor->GetText(); |
| 49 |
// Without the accompanying fix in place, this test would have failed with: |
| 50 |
// - Expected: aaa\nbbb |
| 51 |
// - Actual : |
| 52 |
// i.e. the value of the Content parameter was ignored. |
| 53 |
CPPUNIT_ASSERT_EQUAL(u"aaa\nbbb"_ustr, aActualResult); |
| 54 |
} |
| 55 |
|
| 56 |
CPPUNIT_PLUGIN_IMPLEMENT(); |
| 57 |
|
| 58 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |