Kaydet (Commit) 6a54dd84 authored tarafından László Németh's avatar László Németh

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/66800Reviewed-by: 's avatarLászló Németh <nemeth@numbertext.org>
Tested-by: 's avatarLászló Németh <nemeth@numbertext.org>
üst d97fc64a
......@@ -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 );
......
......@@ -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: */
......@@ -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 )
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment