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

tdf#119019 DOCX track changes: fix invisible delete and insert

during editing in a paragraph with tracked paragraph formatting,
by accepting the old formatting change automatically in the
actual paragraph before text deletion/insertion.

Note: it's not possible to reject paragraph formatting
changes in LO, but showing them is a minimal requirement.
Now they are still visible in change tracking dialog and
by the vertical line before the related paragraphs until
there are no new text deletions and insertions in those
paragraphs.

Change-Id: I526daad8dd96212ac73a10627128553452e4d31c
Reviewed-on: https://gerrit.libreoffice.org/60101
Tested-by: Jenkins
Reviewed-by: 's avatarLászló Németh <nemeth@numbertext.org>
üst 453fde35
......@@ -205,6 +205,8 @@ public:
virtual bool AcceptRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) = 0;
virtual void AcceptRedlineParagraphFormatting(/*[in]*/const SwPaM& rPam ) = 0;
virtual bool RejectRedline(/*[in]*/SwRedlineTable::size_type nPos, /*[in]*/bool bCallDelete) = 0;
virtual bool RejectRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) = 0;
......
......@@ -25,11 +25,13 @@ public:
void testTdf101534();
void testTdf54819();
void testTdf119571();
void testTdf119019();
CPPUNIT_TEST_SUITE(SwUiWriterTest2);
CPPUNIT_TEST(testTdf101534);
CPPUNIT_TEST(testTdf54819);
CPPUNIT_TEST(testTdf119571);
CPPUNIT_TEST(testTdf119019);
CPPUNIT_TEST_SUITE_END();
};
......@@ -130,6 +132,39 @@ void SwUiWriterTest2::testTdf119571()
getProperty<OUString>(getParagraph(2), "ParaStyleName"));
}
void SwUiWriterTest2::testTdf119019()
{
load(DATA_DIRECTORY, "tdf119019.docx");
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pTextDoc);
CPPUNIT_ASSERT_EQUAL(OUString("Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus."),
getParagraph(2)->getString());
CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(2), 1)->getString());
// second paragraph has got a tracked paragraph formatting yet
CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(2), 1), "RedlineType"));
// delete last word of the second paragraph to remove tracked paragraph formatting
// of this paragraph to track and show word deletion correctly.
SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
pWrtShell->Down(/*bSelect=*/false);
pWrtShell->Down(/*bSelect=*/false);
pWrtShell->Down(/*bSelect=*/false);
pWrtShell->EndPara(/*bSelect=*/false);
pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 7, /*bBasicCall=*/false);
rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell);
pTransfer->Cut();
// check tracked text deletion
CPPUNIT_ASSERT_EQUAL(OUString("tellus."), getRun(getParagraph(2), 3)->getString());
CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(2), 2)->getString());
CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(2), 2), "RedlineType"));
// check removing of tracked paragraph formatting
CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(2), 1), "RedlineType"));
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -2449,6 +2449,15 @@ bool DocumentContentOperationsManager::Overwrite( const SwPaM &rRg, const OUStri
bool DocumentContentOperationsManager::InsertString( const SwPaM &rRg, const OUString &rStr,
const SwInsertFlags nInsertMode )
{
// tdf#119019 accept tracked paragraph formatting to do not hide new insertions
if( m_rDoc.getIDocumentRedlineAccess().IsRedlineOn() )
{
RedlineFlags eOld = m_rDoc.getIDocumentRedlineAccess().GetRedlineFlags();
m_rDoc.getIDocumentRedlineAccess().AcceptRedlineParagraphFormatting( rRg );
if (eOld != m_rDoc.getIDocumentRedlineAccess().GetRedlineFlags())
m_rDoc.getIDocumentRedlineAccess().SetRedlineFlags( eOld );
}
// fetching DoesUndo is surprisingly expensive
bool bDoesUndo = m_rDoc.GetIDocumentUndoRedo().DoesUndo();
if (bDoesUndo)
......@@ -3578,6 +3587,10 @@ bool DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl( SwPaM & rPa
}
}
// tdf#119019 accept tracked paragraph formatting to do not hide new deletions
if ( *rPam.GetPoint() != *rPam.GetMark() )
m_rDoc.getIDocumentRedlineAccess().AcceptRedlineParagraphFormatting( rPam );
if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
{
......
......@@ -2262,6 +2262,31 @@ bool DocumentRedlineManager::AcceptRedline( const SwPaM& rPam, bool bCallDelete
// #TODO - add 'SwExtraRedlineTable' also ?
}
void DocumentRedlineManager::AcceptRedlineParagraphFormatting( const SwPaM &rPam )
{
const SwPosition* pStt = rPam.Start(),
* pEnd = pStt == rPam.GetPoint() ? rPam.GetMark()
: rPam.GetPoint();
const sal_uLong nSttIdx = pStt->nNode.GetIndex();
const sal_uLong nEndIdx = pEnd->nNode.GetIndex();
for( SwRedlineTable::size_type n = 0; n < mpRedlineTable->size() ; ++n )
{
const SwRangeRedline* pTmp = (*mpRedlineTable)[ n ];
sal_uLong nPt = pTmp->GetPoint()->nNode.GetIndex(),
nMk = pTmp->GetMark()->nNode.GetIndex();
if( nPt < nMk ) { long nTmp = nMk; nMk = nPt; nPt = nTmp; }
if( nsRedlineType_t::REDLINE_PARAGRAPH_FORMAT == pTmp->GetType() &&
( (nSttIdx <= nMk && nMk <= nEndIdx) || (nSttIdx <= nPt && nPt <= nEndIdx) ) )
AcceptRedline( n, false );
if( nMk > nEndIdx )
break;
}
}
bool DocumentRedlineManager::RejectRedline( SwRedlineTable::size_type nPos, bool bCallDelete )
{
bool bRet = false;
......
......@@ -86,6 +86,8 @@ public:
virtual bool AcceptRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) override;
virtual void AcceptRedlineParagraphFormatting(/*[in]*/const SwPaM& rPam) override;
virtual bool RejectRedline(/*[in]*/SwRedlineTable::size_type nPos, /*[in]*/bool bCallDelete) override;
virtual bool RejectRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) override;
......
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