diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2018-02-19 22:23:32 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2018-02-19 23:38:17 +0100 |
commit | f0485ba2d90aae0312f5775588f22789016165d2 (patch) | |
tree | 426cfdbcafd4097da042ac050652e7fc1af6fe8b /editeng/qa/unit | |
parent | 59c95b3992002bd408ad2d11df61468dcd284d82 (diff) |
tdf#115639: Handle alignment correctly for multiple paragraph case
I used the wrong calculator method to get the line width.
This commit also fixes the crashes found by crashtest.
Change-Id: I25392f86af912ee54c07b14480d82282210ac346
Reviewed-on: https://gerrit.libreoffice.org/49994
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'editeng/qa/unit')
-rw-r--r-- | editeng/qa/unit/core-test.cxx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index 195fae1bcb4a..5907e5c0100f 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -1957,6 +1957,39 @@ void Test::testHoriAlignIgnoreTrailingWhitespace() EditLine* pLine = &pParaPortion->GetLines()[0]; CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<long>(8815), pLine->GetStartPosX(), 10); } + + // Test multiple paragraph case + { + // Set initial text + aText = "Some text \nMore Text "; + aTextLen = aText.getLength(); + aEditEngine.SetText(aText); + + // Assert changes - text insertion + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(aTextLen - 1), rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(OUString("Some text "), rDoc.GetParaAsString(static_cast<sal_Int32>(0))); + CPPUNIT_ASSERT_EQUAL(OUString("More Text "), rDoc.GetParaAsString(static_cast<sal_Int32>(1))); + + aEditEngine.SetHoriAlignIgnoreTrailingWhitespace(true); + std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(aEditEngine.GetEmptyItemSet())); + pSet->Put(SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST )); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), pSet->Count()); + + // Select all paragraphs and apply changes + ESelection aSelection(0, 0, 0, aTextLen); + aEditEngine.QuickSetAttribs(*pSet, aSelection); + + // Get one line paragraphs + aEditEngine.SetPaperSize(Size(10000, 6000)); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aEditEngine.GetLineCount(0)); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aEditEngine.GetLineCount(1)); + + // Check horizontal position + ParaPortion* pParaPortion = aEditEngine.GetParaPortions()[0]; + CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<long>(4527), pParaPortion->GetLines()[0].GetStartPosX(), 50); + pParaPortion = aEditEngine.GetParaPortions()[1]; + CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<long>(8815), pParaPortion->GetLines()[0].GetStartPosX(), 50); + } } CPPUNIT_TEST_SUITE_REGISTRATION(Test); |