diff --git a/sw/qa/extras/rtfimport/data/.~lock.tdf116269.rtf# b/sw/qa/extras/rtfimport/data/.~lock.tdf116269.rtf# new file mode 100755 index 000000000000..59761cebfa1a --- /dev/null +++ b/sw/qa/extras/rtfimport/data/.~lock.tdf116269.rtf# @@ -0,0 +1 @@ +,CIB/Olivers,twisterix2,16.04.2025 16:29,file:///D:/develop/LO/old_build/core-master/instdir; \ No newline at end of file diff --git a/sw/qa/extras/rtfimport/data/tdf166191.rtf b/sw/qa/extras/rtfimport/data/tdf166191.rtf new file mode 100644 index 000000000000..6c026bf22443 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/tdf166191.rtf @@ -0,0 +1,7 @@ +{\rtf1 +{\stylesheet{\*\cs10 \additive \rtlch\fcs1 +\ab\af0\afs32 \ltrch\fcs0 \b\fs32\lang1031\langfe0\kerning32\loch\f31502\hich\af31502\dbch\af31501\langnp1031\langfenp0 \sbasedon10 \slink1 \slocked \spriority9 \'dcberschrift 1 Zchn;}} +\pard Simple text \par +\pard \cs10 Simple text with char style\par +} + diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 080a8ccdf706..76a4ca37ade5 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -997,6 +998,15 @@ CPPUNIT_TEST_FIXTURE(Test, testColumnBreak) getProperty(getParagraph(2), u"BreakType"_ustr)); } +CPPUNIT_TEST_FIXTURE(Test, testTdf166191) +{ + createSwDoc("tdf166191.rtf"); + //text of second paragraph should be in 12pt and not bold + uno::Reference textRun = getRun(getParagraph(2), 1); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty(textRun, u"CharWeight"_ustr)); + CPPUNIT_ASSERT_EQUAL(12.0f, getProperty(textRun, u"CharHeight"_ustr)); +} + // tests should only be added to rtfIMPORT *if* they fail round-tripping in rtfEXPORT } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx b/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx index c93f04a2e245..acb3f722a238 100644 --- a/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx +++ b/sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx @@ -513,7 +513,8 @@ static void lcl_copyFlatten(RTFReferenceProperties& rProps, RTFSprms& rStyleAttr } writerfilter::Reference::Pointer_t -RTFDocumentImpl::getProperties(const RTFSprms& rAttributes, RTFSprms const& rSprms, Id nStyleType) +RTFDocumentImpl::getProperties(const RTFSprms& rAttributes, RTFSprms const& rSprms, Id nStyleType, + bool bReplay) { RTFSprms aSprms(rSprms); RTFValue::Pointer_t pAbstractList; @@ -539,12 +540,22 @@ RTFDocumentImpl::getProperties(const RTFSprms& rAttributes, RTFSprms const& rSpr auto it = m_aInvalidListTableFirstIndents.find(nAbstractListId); if (it != m_aInvalidListTableFirstIndents.end()) aSprms.deduplicateList(it->second); + aSprms.duplicateList(pAbstractList); } int nStyle = 0; if (!m_aStates.empty()) nStyle = m_aStates.top().getCurrentStyleIndex(); auto it = m_pStyleTableEntries->find(nStyle); + if (!nStyle && it == m_pStyleTableEntries->end()) + { + RTFSprms aAttributes; + writerfilter::Reference::Pointer_t pProps( + new RTFReferenceProperties(aAttributes)); + writerfilter::Reference::Pointer_t const pProp(pProps); + m_pStyleTableEntries->insert(std::make_pair(0, pProp)); + it = m_pStyleTableEntries->find(nStyle); + } if (it != m_pStyleTableEntries->end()) { @@ -553,7 +564,29 @@ RTFDocumentImpl::getProperties(const RTFSprms& rAttributes, RTFSprms const& rSpr auto itChar = m_pStyleTableEntries->end(); if (!m_aStates.empty()) { - int nCharStyle = m_aStates.top().getCurrentCharacterStyleIndex(); + int nCharStyle = -1; + if (bReplay) + { + auto pCharStyleName = aSprms.find(NS_ooxml::LN_EG_RPrBase_rStyle); + if (pCharStyleName) + { + for (auto& rCharStyle : *m_pStyleTableEntries) + { + RTFReferenceProperties& rCharStyleProps + = *static_cast(rCharStyle.second.get()); + auto rEntryStyleName + = rCharStyleProps.getSprms().find(NS_ooxml::LN_CT_Style_name); + if (rEntryStyleName + && pCharStyleName->getString() == rEntryStyleName->getString()) + { + nCharStyle = rCharStyle.first; + break; + } + } + } + } + else + nCharStyle = m_aStates.top().getCurrentCharacterStyleIndex(); itChar = m_pStyleTableEntries->find(nCharStyle); } @@ -581,8 +614,6 @@ RTFDocumentImpl::getProperties(const RTFSprms& rAttributes, RTFSprms const& rSpr return new RTFReferenceProperties(std::move(attributes), std::move(sprms)); } - if (pAbstractList) - aSprms.duplicateList(pAbstractList); writerfilter::Reference::Pointer_t pRet = new RTFReferenceProperties(rAttributes, std::move(aSprms)); return pRet; @@ -1773,7 +1804,8 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer, RTFSprms* const pSprms, writerfilter::Reference::Pointer_t const pProp(getProperties( std::get<1>(aTuple)->getAttributes(), std::get<1>(aTuple)->getSprms(), std::get<0>(aTuple) == BUFFER_PROPS_CHAR ? NS_ooxml::LN_Value_ST_StyleType_character - : 0)); + : 0, + std::get<0>(aTuple) == BUFFER_PROPS_CHAR)); Mapper().props(pProp); } else if (std::get<0>(aTuple) == BUFFER_NESTROW) diff --git a/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx b/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx index a3d7d7dd4637..fe0a960c8fb0 100644 --- a/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx +++ b/sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx @@ -784,8 +784,10 @@ private: void runBreak(); void parBreak(); void tableBreak(); - writerfilter::Reference::Pointer_t - getProperties(const RTFSprms& rAttributes, RTFSprms const& rSprms, Id nStyleType); + writerfilter::Reference::Pointer_t getProperties(const RTFSprms& rAttributes, + RTFSprms const& rSprms, + Id nStyleType, + bool bReplay = false); void checkNeedPap(); void handleFontTableEntry(); void sectBreak(bool bFinal = false);