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

tdf#119571 change tracking: show layout changes at paragraph join

in Show changes mode, too. Delayed update of the paragraph
layout at file saving etc. resulted invisible style changes.

All removed paragraphs get the style of the first (partially
deleted) paragraph to avoid text insertion with bad style in
the deleted area later, as in MSO (except the incomplete undo
of paragraph styles here and at other paragraph
formattings during change tracking).

Note: see also tdf#105413 for the remaining problem: style
changes after deleted paragraphs are losing in Show changes mode.

Change-Id: Ic6c6055c2e4da61755b09a1d78b4aa8826212047
Reviewed-on: https://gerrit.libreoffice.org/59821
Tested-by: Jenkins
Reviewed-by: 's avatarLászló Németh <nemeth@numbertext.org>
üst 22639148
......@@ -24,10 +24,12 @@ class SwUiWriterTest2 : public SwModelTestBase
public:
void testTdf101534();
void testTdf54819();
void testTdf119571();
CPPUNIT_TEST_SUITE(SwUiWriterTest2);
CPPUNIT_TEST(testTdf101534);
CPPUNIT_TEST(testTdf54819);
CPPUNIT_TEST(testTdf119571);
CPPUNIT_TEST_SUITE_END();
};
......@@ -91,6 +93,43 @@ void SwUiWriterTest2::testTdf54819()
getProperty<OUString>(getParagraph(1), "ParaStyleName"));
}
void SwUiWriterTest2::testTdf119571()
{
load(DATA_DIRECTORY, "tdf54819.fodt");
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pTextDoc);
CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
getProperty<OUString>(getParagraph(1), "ParaStyleName"));
CPPUNIT_ASSERT_EQUAL(OUString("Standard"),
getProperty<OUString>(getParagraph(2), "ParaStyleName"));
//turn on red-lining and show changes
SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
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()));
// join paragraphs by removing the end of the first one with paragraph break
SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
pWrtShell->EndPara(/*bSelect=*/true);
pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false);
rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell);
pTransfer->Cut();
// second paragraph changes its style in "Show changes" mode
CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
getProperty<OUString>(getParagraph(1), "ParaStyleName"));
CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
getProperty<OUString>(getParagraph(2), "ParaStyleName"));
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -1692,6 +1692,28 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall
if (pDelNode != nullptr && pTextNode != nullptr && pDelNode != pTextNode)
pTextNode->CopyCollFormat( *pDelNode );
}
else
{
// tdf#119571 update the style of the joined paragraph
// after a partially deleted paragraph to show its correct style
// in "Show changes" mode, too. All removed paragraphs
// get the style of the first (partially deleted) paragraph
// to avoid text insertion with bad style in the deleted
// area later.
SwContentNode* pDelNd = pStt->nNode.GetNode().GetContentNode();
SwContentNode* pTextNd = pEnd->nNode.GetNode().GetContentNode();
SwTextNode* pDelNode = pStt->nNode.GetNode().GetTextNode();
SwTextNode* pTextNode;
SwNodeIndex aIdx( pEnd->nNode.GetNode() );
while (pDelNode != nullptr && pTextNd != nullptr && pDelNd->GetIndex() < pTextNd->GetIndex())
{
pTextNode = pTextNd->GetTextNode();
if (pTextNode && pDelNode != pTextNode )
pDelNode->CopyCollFormat( *pTextNode );
pTextNd = SwNodes::GoPrevious( &aIdx );
}
}
mpRedlineTable->Insert( pNewRedl );
}
}
......
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