[Libreoffice-commits] core.git: sw/qa
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Wed Aug 25 06:43:56 UTC 2021
sw/qa/extras/uiwriter/uiwriter2.cxx | 68 ++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
New commits:
commit 400a44261c3891c1fb99b5339ada69cbc4777dd0
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Mon Aug 23 14:02:35 2021 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Wed Aug 25 08:43:16 2021 +0200
tdf#143938 sw test: track format changes of the paragraph
Character formatting changes of the wholly selected
paragraph weren't tracked before the following fix:
commit 5e891c2ee82f2d7566ddb4e15b9c03cecb9fc1f8
"tdf#143939 sw: track format changes of the actual word".
This is only an unit test to cover both fixed problems.
Change-Id: Ia8ee15895fc309f4c57c54ac8e6b4265969b5256
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120957
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 8461ef96197a..70d63e36871a 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -13,6 +13,8 @@
#include <boost/property_tree/json_parser.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
#include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/chart/XChartDocument.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
@@ -2892,6 +2894,72 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf143918)
}
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf143938)
+{
+ SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf54819.fodt");
+
+ SwWrtShell* const pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+ // select first paragraph, add underline without change tracking
+ pWrtShell->EndPara(/*bSelect=*/true);
+ dispatchCommand(mxComponent, ".uno:Underline", {});
+
+ auto xText = getParagraph(1)->getText();
+ CPPUNIT_ASSERT(xText.is());
+ {
+ auto xCursor(xText->createTextCursorByRange(getRun(getParagraph(1), 1)));
+ CPPUNIT_ASSERT(xCursor.is());
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem ipsum"), xCursor->getString());
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::FontUnderline::SINGLE),
+ getProperty<sal_Int16>(xCursor, "CharUnderline"));
+ CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE,
+ getProperty<awt::FontSlant>(xCursor, "CharPosture"));
+ }
+
+ // turn on red-lining and show changes
+ pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete
+ | RedlineFlags::ShowInsert);
+ CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+ pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+ CPPUNIT_ASSERT_MESSAGE(
+ "redlines should be visible",
+ IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+ // apply italic with change tracking
+ pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 6, /*bBasicCall=*/false);
+ dispatchCommand(mxComponent, ".uno:Italic", {});
+
+ xText = getParagraph(1)->getText();
+ CPPUNIT_ASSERT(xText.is());
+ {
+ // (first empty run is associated to the redline)
+ auto xCursor(xText->createTextCursorByRange(getRun(getParagraph(1), 2)));
+ CPPUNIT_ASSERT(xCursor.is());
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem ipsum"), xCursor->getString());
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::FontUnderline::SINGLE),
+ getProperty<sal_Int16>(xCursor, "CharUnderline"));
+ CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC,
+ getProperty<awt::FontSlant>(xCursor, "CharPosture"));
+ }
+
+ // reject tracked changes
+ dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {});
+
+ // no italic, but still underline direct formatting
+ xText = getParagraph(1)->getText();
+ CPPUNIT_ASSERT(xText.is());
+ {
+ auto xCursor(xText->createTextCursorByRange(getRun(getParagraph(1), 1)));
+ CPPUNIT_ASSERT(xCursor.is());
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem ipsum"), xCursor->getString());
+ // This wasn't underlined (lost direct formatting)
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::FontUnderline::SINGLE),
+ getProperty<sal_Int16>(xCursor, "CharUnderline"));
+ CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE,
+ getProperty<awt::FontSlant>(xCursor, "CharPosture"));
+ }
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf143939)
{
SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf126206.docx");
More information about the Libreoffice-commits
mailing list