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

tdf#118699 DOCX import: don't add numbering

after a tracked deletion of a numbered list to the
next not numbered paragraph.

Note: we remove the numbering of the first item of
the deleted numbered list to import the actual text
content correctly, giving correct numbering after
accepting the changes or in the Hide Changes mode.

Change-Id: I98767937bc783cb5e8ecb05558a5ad05a57ff281
Reviewed-on: https://gerrit.libreoffice.org/72001
Tested-by: Jenkins
Reviewed-by: 's avatarLászló Németh <nemeth@numbertext.org>
üst 051f0dca
......@@ -1231,4 +1231,25 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testDocxAttributeTableExport)
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xShape, "HoriOrientRelation"));
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf118699_redline_numbering)
{
load(DATA_DIRECTORY, "tdf118699.docx");
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pTextDoc);
SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess());
rIDRA.AcceptAllRedline(true);
uno::Reference<beans::XPropertySet> xProps(getParagraph(2), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("first paragraph after the first deletion: erroneous numbering",
!xProps->getPropertyValue("NumberingRules").hasValue());
CPPUNIT_ASSERT_MESSAGE(
"first paragraph after the second deletion: missing numbering",
getProperty<uno::Reference<container::XIndexAccess>>(getParagraph(5), "NumberingRules")
.is());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -820,6 +820,12 @@ RedlineFlags DocumentRedlineManager::GetRedlineFlags() const
void DocumentRedlineManager::SetRedlineFlags( RedlineFlags eMode )
{
if ( m_bFinalizeImport )
{
FinalizeImport();
m_bFinalizeImport = false;
}
if( meRedlineFlags != eMode )
{
if( (RedlineFlags::ShowMask & meRedlineFlags) != (RedlineFlags::ShowMask & eMode)
......@@ -1418,6 +1424,8 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall
// better fix it.
n = 0;
bDec = true;
// or simply this is an OOXML import
m_bFinalizeImport = true;
}
mpRedlineTable->DeleteAndDestroy( nToBeDeleted );
......@@ -3011,6 +3019,30 @@ void DocumentRedlineManager::SetAutoFormatRedlineComment( const OUString* pText,
mnAutoFormatRedlnCommentNo = nSeqNo;
}
void DocumentRedlineManager::FinalizeImport()
{
// tdf#118699 fix numbering after deletion of numbered list items
for( SwRedlineTable::size_type n = 0; n < mpRedlineTable->size(); ++n )
{
SwRangeRedline* pRedl = (*mpRedlineTable)[ n ];
if ( nsRedlineType_t::REDLINE_DELETE == pRedl->GetType() )
{
const SwPosition* pStt = pRedl->Start(),
* pEnd = pStt == pRedl->GetPoint()
? pRedl->GetMark() : pRedl->GetPoint();
SwTextNode* pDelNode = pStt->nNode.GetNode().GetTextNode();
SwTextNode* pTextNode = pEnd->nNode.GetNode().GetTextNode();
// remove numbering of the first deleted list item
// to avoid of incorrect numbering after the deletion
if ( pDelNode->GetNumRule() && !pTextNode->GetNumRule() )
{
const SwPaM aPam( *pStt, *pStt );
m_rDoc.DelNumRules( aPam );
}
}
}
}
DocumentRedlineManager::~DocumentRedlineManager()
{
}
......
......@@ -127,6 +127,7 @@ public:
bool IsHideRedlines() const { return m_bHideRedlines; }
void SetHideRedlines(bool const bHideRedlines) { m_bHideRedlines = bHideRedlines; }
void FinalizeImport();
virtual ~DocumentRedlineManager() override;
private:
......@@ -148,6 +149,8 @@ private:
/// this flag is necessary for file import because the ViewShell/layout is
/// created "too late" and the ShowRedlineChanges item is not below "Views"
bool m_bHideRedlines = false;
/// need post-processing, eg. for OOXML import
bool m_bFinalizeImport = false;
};
}
......
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