diff --git a/editeng/qa/editeng/editeng.cxx b/editeng/qa/editeng/editeng.cxx index f3df37592f14..6c5e9e29596c 100644 --- a/editeng/qa/editeng/editeng.cxx +++ b/editeng/qa/editeng/editeng.cxx @@ -190,6 +190,28 @@ CPPUNIT_TEST_FIXTURE(Test, testRTFStyleExportFollowRecursive) SvMemoryStream& rStream = pData->GetRTFStream(); CPPUNIT_ASSERT_GREATER(static_cast(0), rStream.remainingSize()); } + +CPPUNIT_TEST_FIXTURE(Test, testTdf119192) +{ + // Tests that font changes due to a script type change are placed in paragraph scope + EditEngine aEditEngine(mpItemPool.get()); + + OUString aText = u"mytest"_ustr; + aEditEngine.SetText(aText); + + uno::Reference xData + = aEditEngine.CreateTransferable(ESelection(0, 0, 0, aText.getLength())); + + auto pData = dynamic_cast(xData.get()); + SvMemoryStream& rStream = pData->GetRTFStream(); + + std::string aCnt{ static_cast(rStream.GetData()), + static_cast(rStream.GetSize()) }; + + // Without the fix, the RTF text will include font attributes inside the curly braces. + bool bContains = (aCnt.find("{mytest}") != std::string::npos); + CPPUNIT_ASSERT(bContains); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index c8ae50031c19..a3a349f04243 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -716,6 +716,12 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel, bool bCl aAttribItems.Insert( &aAttribs.Get( GetScriptItemId( EE_CHAR_WEIGHT, nScriptType ) ) ); aAttribItems.Insert( &aAttribs.Get( GetScriptItemId( EE_CHAR_ITALIC, nScriptType ) ) ); aAttribItems.Insert( &aAttribs.Get( GetScriptItemId( EE_CHAR_LANGUAGE, nScriptType ) ) ); + + // tdf#119192: Write these font attributes at paragraph scope, so they can be + // reused across multiple runs. + WriteItemListAsRTF(aAttribItems, rOutput, nNode, nIndex, aFontTable, + aColorList); + aAttribItems.Clear(); } // Insert hard attribs AFTER CJK attribs... lcl_FindValidAttribs( aAttribItems, pNode, nIndex, nScriptTypeI18N );