summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@libreoffice.org>2023-06-01 15:25:28 +0300
committerخالد حسني <khaled@libreoffice.org>2023-06-01 15:49:39 +0200
commitef30d351da288b3513cfd30cb82bff7e0827fcb3 (patch)
treeb61c14f9eeea16c7a3e0e06a0fcc44445dae2cfc
parente899a75fc6dd600ea9992c851a42734b334122b6 (diff)
tdf#155623: Revert "tdf#155557: Fix drawing mixed direction underlined text"
This reverts commit 99d22fd79c5532fd6c1b167996e1c27216b92469. Lets revert and figure out a less radical fix for the original issue. Change-Id: If3025d32019e953b7946ebe4209daf74efc5e15a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152490 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@libreoffice.org>
-rw-r--r--sw/qa/extras/layout/layout2.cxx2
-rw-r--r--sw/source/core/txtnode/swfont.cxx61
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx7
3 files changed, 69 insertions, 1 deletions
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index e9f2372c0d97..b4b004951bf0 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -875,7 +875,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineMoving2)
// text and numbering colors show moving of the list item
// These were 0 (other color, not COL_GREEN, color of the tracked text movement)
assertXPath(pXmlDoc, "/metafile/push/push/push/textcolor[@color='#008000']", 5);
- assertXPath(pXmlDoc, "/metafile/push/push/push/font[@color='#008000']", 9);
+ assertXPath(pXmlDoc, "/metafile/push/push/push/font[@color='#008000']", 11);
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineMovingDOCX)
diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx
index a4ac4f675aea..c0149d9a6573 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -1099,6 +1099,16 @@ void SwSubFont::DrawText_( SwDrawTextInfo &rInf, const bool bGrey )
if (TextFrameIndex(COMPLETE_STRING) == rInf.GetLen())
rInf.SetLen( nLn );
+ FontLineStyle nOldUnder = LINESTYLE_NONE;
+ SwUnderlineFont* pUnderFnt = nullptr;
+
+ if( rInf.GetUnderFnt() )
+ {
+ nOldUnder = GetUnderline();
+ SetUnderline( LINESTYLE_NONE );
+ pUnderFnt = rInf.GetUnderFnt();
+ }
+
if( !pLastFont || pLastFont->GetOwner() != m_nFontCacheId )
ChgFnt( rInf.GetShell(), rInf.GetOut() );
@@ -1155,6 +1165,57 @@ void SwSubFont::DrawText_( SwDrawTextInfo &rInf, const bool bGrey )
}
}
+ if( pUnderFnt && nOldUnder != LINESTYLE_NONE )
+ {
+ Size aFontSize = GetTextSize_( rInf );
+ const OUString oldStr = rInf.GetText();
+
+ TextFrameIndex const nOldIdx = rInf.GetIdx();
+ TextFrameIndex const nOldLen = rInf.GetLen();
+ tools::Long nSpace = 0;
+ if( rInf.GetSpace() )
+ {
+ TextFrameIndex nTmpEnd = nOldIdx + nOldLen;
+ if (nTmpEnd > TextFrameIndex(oldStr.getLength()))
+ nTmpEnd = TextFrameIndex(oldStr.getLength());
+
+ const SwScriptInfo* pSI = rInf.GetScriptInfo();
+
+ const bool bAsianFont =
+ ( rInf.GetFont() && SwFontScript::CJK == rInf.GetFont()->GetActual() );
+ for (TextFrameIndex nTmp = nOldIdx; nTmp < nTmpEnd; ++nTmp)
+ {
+ if (CH_BLANK == oldStr[sal_Int32(nTmp)] || bAsianFont ||
+ (nTmp + TextFrameIndex(1) < TextFrameIndex(oldStr.getLength())
+ && pSI
+ && i18n::ScriptType::ASIAN == pSI->ScriptType(nTmp + TextFrameIndex(1))))
+ {
+ ++nSpace;
+ }
+ }
+
+ // if next portion if a hole portion we do not consider any
+ // extra space added because the last character was ASIAN
+ if ( nSpace && rInf.IsSpaceStop() && bAsianFont )
+ --nSpace;
+
+ nSpace *= rInf.GetSpace() / SPACING_PRECISION_FACTOR;
+ }
+
+ rInf.SetWidth( sal_uInt16(aFontSize.Width() + nSpace) );
+ rInf.SetTextIdxLen( " ", TextFrameIndex(0), TextFrameIndex(2) );
+ SetUnderline( nOldUnder );
+ rInf.SetUnderFnt( nullptr );
+
+ // set position for underline font
+ rInf.SetPos( pUnderFnt->GetPos() );
+
+ pUnderFnt->GetFont().DrawStretchText_( rInf );
+
+ rInf.SetUnderFnt( pUnderFnt );
+ rInf.SetTextIdxLen(oldStr, nOldIdx, nOldLen);
+ }
+
rInf.SetPos(aOldPos);
}
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 5f8cce35e69e..0739cd25cd8a 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1338,6 +1338,13 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf145274)
int nPageObjectCount = pPage->getObjectCount();
+ // Without the fix in place, this test would have failed with
+ // - Expected: 6
+ // - Actual : 4
+ CPPUNIT_ASSERT_EQUAL(6, nPageObjectCount);
+
+ auto pTextPage = pPage->getTextPage();
+
for (int i = 0; i < nPageObjectCount; ++i)
{
std::unique_ptr<vcl::pdf::PDFiumPageObject> pPageObject = pPage->getObject(i);