summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2019-01-23 11:27:01 +0100
committerLászló Németh <nemeth@numbertext.org>2019-01-24 08:15:52 +0100
commitd97fc64a819f834302e384792668507df4cc412c (patch)
tree3350e85a074f53ca74bc5190d2605cf910ce97fb /sw/qa/extras
parent976da2b60ebe4e8bb7c311c1c6325519db6c5bda (diff)
tdf#122893 track changes: keep paragraph alignment
and preset line spaces applied in Show Changes mode, instead of losing them after saving the document or hiding the changes. The bug occurred in paragraphs with directly preceding tracked deletions. Change-Id: I33d9db8ee3522470c4f2dfdcfbea4060db8769a2 Reviewed-on: https://gerrit.libreoffice.org/66789 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx55
1 files changed, 55 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 2f0242a6964c..c7d1ed25b446 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -10,6 +10,7 @@
#include <swmodeltestbase.hxx>
#include <com/sun/star/awt/FontSlant.hpp>
#include <com/sun/star/frame/DispatchHelper.hpp>
+#include <com/sun/star/style/LineSpacing.hpp>
#include <comphelper/propertysequence.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <svx/svdpage.hxx>
@@ -54,6 +55,7 @@ public:
void testUnfloatButton();
void testUnfloatButtonReadOnlyMode();
void testUnfloating();
+ void testTdf122893();
CPPUNIT_TEST_SUITE(SwUiWriterTest2);
CPPUNIT_TEST(testRedlineMoveInsertInDelete);
@@ -71,6 +73,7 @@ public:
CPPUNIT_TEST(testUnfloatButton);
CPPUNIT_TEST(testUnfloatButtonReadOnlyMode);
CPPUNIT_TEST(testUnfloating);
+ CPPUNIT_TEST(testTdf122893);
CPPUNIT_TEST_SUITE_END();
private:
@@ -683,6 +686,58 @@ void SwUiWriterTest2::testUnfloating()
pWrtShell->GetLayout()->GetLower()->GetNext()->GetLower()->GetLower()->GetType());
}
+void SwUiWriterTest2::testTdf122893()
+{
+ load(DATA_DIRECTORY, "tdf105413.fodt");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ // all paragraphs are left-aligned with preset single line spacing
+ for (int i = 1; i < 4; ++i)
+ {
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(i), "ParaAdjust"));
+ lcl_dispatchCommand(mxComponent, ".uno:SpacePara1", {});
+ }
+
+ // turn on red-lining and show changes
+ SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+ pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowInsert
+ | RedlineFlags::ShowDelete);
+ CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+ pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+ CPPUNIT_ASSERT_MESSAGE(
+ "redlines should be visible",
+ IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+ // Set center-aligned paragraph with preset double line spacing in the 3th paragraph.
+ // Because of the tracked deleted region between them,
+ // this sets also the same formatting in the first paragraph automatically
+ // to keep the changed paragraph formatting at hiding tracked changes or saving the document
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->Down(/*bSelect=*/false);
+ pWrtShell->Down(/*bSelect=*/false);
+ pWrtShell->EndPara(/*bSelect=*/false);
+
+ lcl_dispatchCommand(mxComponent, ".uno:CenterPara", {});
+ lcl_dispatchCommand(mxComponent, ".uno:SpacePara2", {});
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3),
+ getProperty<sal_Int32>(getParagraph(3), "ParaAdjust")); // center-aligned
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(200),
+ getProperty<style::LineSpacing>(getParagraph(3), "ParaLineSpacing")
+ .Height); // double line spacing
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
+ getProperty<sal_Int32>(getParagraph(2), "ParaAdjust")); // left-aligned
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100),
+ getProperty<style::LineSpacing>(getParagraph(2), "ParaLineSpacing")
+ .Height); // single line spacing
+ // first paragraph is also center-aligned with double line spacing
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3), getProperty<sal_Int32>(getParagraph(1), "ParaAdjust"));
+ CPPUNIT_ASSERT_EQUAL(
+ sal_Int16(200), getProperty<style::LineSpacing>(getParagraph(1), "ParaLineSpacing").Height);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */