diff options
author | László Németh <nemeth@numbertext.org> | 2020-01-08 14:26:40 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-05-18 12:36:50 +0200 |
commit | f30585abfe198914511df004ac712f0e066cf0b9 (patch) | |
tree | 6ede557ba9d7bfbc81cc4c0a0187514c120cc596 | |
parent | 1d11615cbe06f48f67b878dee28c9acd6a8834d8 (diff) |
tdf#90069 DOCX: fix character style of new table rows
DOCX table import didn't set paragraph level
character styles on paragraph level, only on
text portions, resulting default character style
in the newly inserted table rows instead of copying
the style of the previous table row.
(cherry picked from commit 2ab481b038b62b1ff576ac4d49d03c1798cd7f84)
Conflicts:
sw/qa/extras/uiwriter/uiwriter2.cxx
Change-Id: Idb4438c767bdc7e0026fc6e0f0a795d8efdda3c8
-rw-r--r-- | sw/qa/extras/uiwriter/data2/tdf90069.docx | bin | 0 -> 4737 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 33 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 13 |
3 files changed, 46 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data2/tdf90069.docx b/sw/qa/extras/uiwriter/data2/tdf90069.docx Binary files differnew file mode 100644 index 000000000000..719502a67e78 --- /dev/null +++ b/sw/qa/extras/uiwriter/data2/tdf90069.docx diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 2da2640e7fcc..374c8c6b2b37 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -24,6 +24,8 @@ #include <xmloff/odffields.hxx> #include <com/sun/star/frame/DispatchHelper.hpp> #include <fmtornt.hxx> +#include <editeng/fontitem.hxx> +#include <ndtxt.hxx> namespace { @@ -45,6 +47,7 @@ public: void testDropDownFormFieldInsertion(); void testMixedFormFieldInsertion(); void testTdf122942(); + void testTdf90069(); CPPUNIT_TEST_SUITE(SwUiWriterTest2); CPPUNIT_TEST(testTdf101534); @@ -57,6 +60,7 @@ public: CPPUNIT_TEST(testDropDownFormFieldInsertion); CPPUNIT_TEST(testMixedFormFieldInsertion); CPPUNIT_TEST(testTdf122942); + CPPUNIT_TEST(testTdf90069); CPPUNIT_TEST_SUITE_END(); private: @@ -475,6 +479,35 @@ void SwUiWriterTest2::testTdf122942() #endif } +void SwUiWriterTest2::testTdf90069() +{ + SwDoc* pDoc = createDoc("tdf90069.docx"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + SwDocShell* pDocShell = pTextDoc->GetDocShell(); + CPPUNIT_ASSERT(pDocShell); + + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + + sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex(); + + lcl_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(true, pTextNodeA2->GetSwAttrSet().HasItem(RES_CHRATR_FONT)); + OUString sFontName = pTextNodeA2->GetSwAttrSet().GetItem(RES_CHRATR_FONT)->GetFamilyName(); + CPPUNIT_ASSERT_EQUAL(OUString("Lohit Devanagari"), sFontName); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 0838e1713967..a6f62a7b4f23 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1477,6 +1477,19 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap ) } } } + + // tdf#90069 in tables, apply paragraph level character style also on + // paragraph level to support its copy during insertion of new table rows + if ( xParaProps && m_nTableDepth > 0 ) + { + uno::Sequence< beans::PropertyValue > aValues = pParaContext->GetPropertyValues(false); + + for( const auto& rProp : aValues ) + { + if ( rProp.Name.startsWith("Char") && rProp.Name != "CharStyleName" && rProp.Name != "CharInteropGrabBag" ) + xParaProps->setPropertyValue( rProp.Name, rProp.Value ); + } + } } if( !bKeepLastParagraphProperties ) rAppendContext.pLastParagraphProperties = pToBeSavedProperties; |