[Libreoffice-commits] core.git: sw/inc sw/qa sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Jan 24 07:18:00 UTC 2019
sw/inc/editsh.hxx | 3 +-
sw/qa/extras/uiwriter/uiwriter2.cxx | 51 ++++++++++++++++++++++++++++++++++++
sw/source/core/edit/edatmisc.cxx | 11 +++++++
sw/source/uibase/uiview/viewtab.cxx | 2 -
4 files changed, 64 insertions(+), 3 deletions(-)
New commits:
commit 6a54dd844d1821165642bbcc16bd12a01a23393d
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Wed Jan 23 15:05:21 2019 +0100
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Thu Jan 24 08:17:27 2019 +0100
tdf#122901 track changes: keep paragraph top and bottom borders
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: I25a84aec0159f809dd7b67d4e530e87b01070f44
Reviewed-on: https://gerrit.libreoffice.org/66800
Reviewed-by: László Németh <nemeth at numbertext.org>
Tested-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 18b67e8cf0dd..9c550e96f639 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -229,7 +229,8 @@ public:
const bool bMergeIndentValuesOfNumRule = false ) const;
bool GetCurAttr( SfxItemSet& ,
const bool bMergeIndentValuesOfNumRule = false ) const;
- void SetAttrItem( const SfxPoolItem&, SetAttrMode nFlags = SetAttrMode::DEFAULT );
+ void SetAttrItem( const SfxPoolItem&, SetAttrMode nFlags = SetAttrMode::DEFAULT,
+ const bool bParagraphSetting = false );
void SetAttrSet( const SfxItemSet&, SetAttrMode nFlags = SetAttrMode::DEFAULT,
SwPaM* pCursor = nullptr, const bool bParagraphSetting = false );
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index c7d1ed25b446..8b05f26e6241 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -56,6 +56,7 @@ public:
void testUnfloatButtonReadOnlyMode();
void testUnfloating();
void testTdf122893();
+ void testTdf122901();
CPPUNIT_TEST_SUITE(SwUiWriterTest2);
CPPUNIT_TEST(testRedlineMoveInsertInDelete);
@@ -74,6 +75,7 @@ public:
CPPUNIT_TEST(testUnfloatButtonReadOnlyMode);
CPPUNIT_TEST(testUnfloating);
CPPUNIT_TEST(testTdf122893);
+ CPPUNIT_TEST(testTdf122901);
CPPUNIT_TEST_SUITE_END();
private:
@@ -738,6 +740,55 @@ void SwUiWriterTest2::testTdf122893()
sal_Int16(200), getProperty<style::LineSpacing>(getParagraph(1), "ParaLineSpacing").Height);
}
+void SwUiWriterTest2::testTdf122901()
+{
+ load(DATA_DIRECTORY, "tdf105413.fodt");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ // all paragraphs with zero borders
+ for (int i = 1; i < 4; ++i)
+ {
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
+ getProperty<sal_Int32>(getParagraph(i), "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
+ getProperty<sal_Int32>(getParagraph(i), "ParaBottomMargin"));
+ }
+
+ // 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()));
+
+ // Increase paragraph borders in the 3th paragraph, similar to the default icon of the UI
+ // "Increase Paragraph Spacing". 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:ParaspaceIncrease", {});
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(101), getProperty<sal_Int32>(getParagraph(3), "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(101),
+ getProperty<sal_Int32>(getParagraph(3), "ParaBottomMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(2), "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(2), "ParaBottomMargin"));
+
+ // first paragraph is also center-aligned with double line spacing
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(101), getProperty<sal_Int32>(getParagraph(1), "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(101),
+ getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/edit/edatmisc.cxx b/sw/source/core/edit/edatmisc.cxx
index 5121d832daa7..41ea8139b11a 100644
--- a/sw/source/core/edit/edatmisc.cxx
+++ b/sw/source/core/edit/edatmisc.cxx
@@ -110,10 +110,11 @@ static void lcl_disableShowChangesIfNeeded( SwDoc *const pDoc, const SwNode& rNo
}
}
-void SwEditShell::SetAttrItem( const SfxPoolItem& rHint, SetAttrMode nFlags )
+void SwEditShell::SetAttrItem( const SfxPoolItem& rHint, SetAttrMode nFlags, const bool bParagraphSetting )
{
SET_CURR_SHELL( this );
StartAllAction();
+ RedlineFlags eRedlMode = GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags(), eOldMode = eRedlMode;
SwPaM* pCursor = GetCursor();
if( pCursor->GetNext() != pCursor ) // Ring of Cursors
{
@@ -125,6 +126,9 @@ void SwEditShell::SetAttrItem( const SfxPoolItem& rHint, SetAttrMode nFlags )
if( rPaM.HasMark() && ( bIsTableMode ||
*rPaM.GetPoint() != *rPaM.GetMark() ))
{
+ if (bParagraphSetting)
+ lcl_disableShowChangesIfNeeded( GetDoc(), (*rPaM.Start()).nNode.GetNode(), eRedlMode);
+
GetDoc()->getIDocumentContentOperations().InsertPoolItem(rPaM, rHint, nFlags, GetLayout());
}
}
@@ -135,9 +139,14 @@ void SwEditShell::SetAttrItem( const SfxPoolItem& rHint, SetAttrMode nFlags )
{
if( !HasSelection() )
UpdateAttr();
+
+ if (bParagraphSetting)
+ lcl_disableShowChangesIfNeeded( GetDoc(), (*pCursor->Start()).nNode.GetNode(), eRedlMode);
+
GetDoc()->getIDocumentContentOperations().InsertPoolItem(*pCursor, rHint, nFlags, GetLayout());
}
EndAllAction();
+ GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags( eOldMode );
}
void SwEditShell::SetAttrSet( const SfxItemSet& rSet, SetAttrMode nFlags, SwPaM* pPaM, const bool bParagraphSetting )
diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx
index 2a42029afd2c..a5f4c242097f 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -794,7 +794,7 @@ void SwView::ExecTabWin( SfxRequest const & rReq )
rSh.AutoUpdatePara( pColl, aULSpaceSet );
}
else
- rSh.SetAttrItem( aULSpace );
+ rSh.SetAttrItem( aULSpace, SetAttrMode::DEFAULT, true );
}
break;
More information about the Libreoffice-commits
mailing list