sw/qa/extras/uiwriter/data/tdf143904.odt |binary sw/qa/extras/uiwriter/uiwriter2.cxx | 23 +++++++++++++++++++++++ sw/source/core/table/swtable.cxx | 14 ++++---------- 3 files changed, 27 insertions(+), 10 deletions(-)
New commits: commit 72590c55ad6c699b34dc404542abc3f60bc32a09 Author: Balazs Santha <santha.bal...@simonyi.bme.hu> AuthorDate: Wed Aug 18 09:30:41 2021 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Aug 27 11:27:44 2021 +0200 tdf#143904 fix direct character formatting copied into paragraph level Currently, Writer copied the direct character formattings, and applied them on paragraph level, when inserting a new row in a table. This bug is a regression from 498d2b82187ec3ff58f076e0d15741e64c0505ba . Explanation, why this regression happened: MSO Word uses a paragraph mark symbol (i.e the control character than can be configured to be shown), which is imported in Writer as a 0-length hint. To fasten up the import of DOCX tables, the core applies the formattings from this 0-length attribute on paragraph level, directly before inserting a new row. All in all, to solve this bug, we needed to make sure, that we only copy the formattings, if it is from a 0-length hint. Change-Id: Iba52e9318cc588feda559339e42897568d009806 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120624 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/qa/extras/uiwriter/data/tdf143904.odt b/sw/qa/extras/uiwriter/data/tdf143904.odt new file mode 100644 index 000000000000..5a1d28664c31 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf143904.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 70d63e36871a..2b263a7849dd 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -4440,6 +4440,29 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testOfz18563) TestImportDOCX(aFileStream); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf143904) +{ + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf143904.odt"); + + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + + sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex(); + + dispatchCommand(mxComponent, ".uno:InsertRowsAfter", {}); + pWrtShell->Down(false); + pWrtShell->Insert("foo"); + + SwTextNode* pTextNodeA1 = static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex]); + CPPUNIT_ASSERT(pTextNodeA1->GetText().startsWith("Insert")); + nIndex = pWrtShell->GetCursor()->GetNode().GetIndex(); + SwTextNode* pTextNodeA2 = static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex]); + CPPUNIT_ASSERT_EQUAL(OUString("foo"), pTextNodeA2->GetText()); + CPPUNIT_ASSERT_EQUAL(false, pTextNodeA2->GetSwAttrSet().HasItem(RES_CHRATR_FONT)); + OUString sFontName = pTextNodeA2->GetSwAttrSet().GetItem(RES_CHRATR_FONT)->GetFamilyName(); + CPPUNIT_ASSERT_EQUAL(OUString("Liberation Serif"), sFontName); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf90069) { SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf90069.docx"); diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index ad10eccc7d92..fb5839ea687b 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -145,17 +145,11 @@ void InsTableBox( SwDoc& rDoc, SwTableNode* pTableNd, if( pCNd->GetpSwAttrSet() ) { SwAttrSet aAttrSet( *pCNd->GetpSwAttrSet() ); - SwTextNode* pTNd = static_cast<SwTextNode*>(pCNd); - SwpHints * pSwpHints = pTNd->GetpSwpHints(); - if(pSwpHints && pSwpHints->Count()!=0) + if(pCNd->GetSwAttrSet().HasItem(RES_PARATR_LIST_AUTOFMT)) { - SwTextAttr* textAttr = pSwpHints->Get(pSwpHints->Count()-1); - if(textAttr->Which() == RES_TXTATR_AUTOFMT ) - { - SwFormatAutoFormat& format = static_cast<SwFormatAutoFormat&>(textAttr->GetAttr()); - const std::shared_ptr<SfxItemSet>& handle = format.GetStyleHandle(); - aAttrSet.Put(*handle); - } + SwFormatAutoFormat format = aAttrSet.Get(RES_PARATR_LIST_AUTOFMT); + const std::shared_ptr<SfxItemSet>& handle = format.GetStyleHandle(); + aAttrSet.Put(*handle); } if( pBox->GetSaveNumFormatColor() ) {