summaryrefslogtreecommitdiff
path: root/sw/source/core/txtnode/fntcache.cxx
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@aliftype.com>2022-09-25 11:37:05 +0200
committerخالد حسني <khaled@aliftype.com>2022-09-25 15:59:06 +0200
commit092e37a284ea8b8bc1e8dabbbeb001c98012a996 (patch)
tree63538c5bc9766583ad012c06986de13a0c6c6901 /sw/source/core/txtnode/fntcache.cxx
parentaa0a39f2be0cf9d633c3654babc6f738d67f871f (diff)
tdf#150726: Pass full string to DrawTextArray() when drawing bullet
When drawing bullets for spaces, we were passing a substring to DrawTextArray() and even taking care of adding an extra character to both sides to help with Arabic layout. This, however, does not work when part of the text is in different color because the portion will cover only that substring and we wouldn’t be passing enough context. Copying the substring is unnecessary, though, and we can pass the full string like we do in the non-bullet case. The bullet array (where we replace spaces with bullets), can continue to be a substring as we are only drawing the bullets in this case. This probably also means we can re-use the glyph cache when switching between bullet and non-bullet mode. Change-Id: I256ae7b6d592b8c6670d66619e428f943714be57 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140568 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
Diffstat (limited to 'sw/source/core/txtnode/fntcache.cxx')
-rw-r--r--sw/source/core/txtnode/fntcache.cxx39
1 files changed, 10 insertions, 29 deletions
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index fa17f0617f13..fe095aa5105b 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -1186,9 +1186,6 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
else
{
- const OUString* pStr = &rInf.GetText();
-
- OUString aStr;
OUString aBulletOverlay;
bool bBullet = rInf.GetBullet();
if( m_bSymbol )
@@ -1288,19 +1285,10 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
if( bBullet )
{
- // !!! HACK !!!
- // The Arabic layout engine requires some context of the string
- // which should be painted.
+ // Copy the substring that will be painted, and replace spaces with
+ // bullets, and everything else with space.
sal_Int32 nCopyStart = sal_Int32(rInf.GetIdx());
- if ( nCopyStart )
- --nCopyStart;
-
sal_Int32 nCopyLen = sal_Int32(rInf.GetLen());
- if ( nCopyStart + nCopyLen < rInf.GetText().getLength() )
- ++nCopyLen;
-
- aStr = rInf.GetText().copy( nCopyStart, nCopyLen );
- pStr = &aStr;
aBulletOverlay = rInf.GetText().copy( nCopyStart, nCopyLen );
@@ -1351,7 +1339,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
aKernArray, aKashidaArray, sal_Int32(rInf.GetIdx()), 1 );
if( bBullet )
- rInf.GetOut().DrawTextArray( aTextOriginPos, *pStr, aKernArray, {},
+ rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(), aKernArray, {},
rInf.GetIdx() ? 1 : 0, 1 );
}
else
@@ -1465,17 +1453,11 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
if ( bSwitchH2V )
rInf.GetFrame()->SwitchHorizontalToVertical( aTextOriginPos );
- // If we paint bullets instead of spaces, we use a copy of
- // the paragraph string. For the layout engine, the copy
- // of the string has to be an environment of the range which
- // is painted
- sal_Int32 nTmpIdx = bBullet
- ? (rInf.GetIdx() ? 1 : 0)
- : sal_Int32(rInf.GetIdx());
+ sal_Int32 nIdx = sal_Int32(rInf.GetIdx());
const SalLayoutGlyphs* pGlyphs = SalLayoutGlyphsCache::self()->GetLayoutGlyphs(&rInf.GetOut(),
- *pStr, nTmpIdx, nLen);
- rInf.GetOut().DrawTextArray( aTextOriginPos, *pStr, aKernArray, aKashidaArray,
- nTmpIdx , nLen, SalLayoutFlags::NONE, pGlyphs );
+ rInf.GetText(), nIdx, nLen);
+ rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(), aKernArray, aKashidaArray,
+ nIdx, nLen, SalLayoutFlags::NONE, pGlyphs );
if (bBullet)
{
rInf.GetOut().Push();
@@ -1495,8 +1477,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
{
tools::Long nAdd = 0;
- if (aBulletOverlay.getLength() > nTmpIdx &&
- aBulletOverlay[ nTmpIdx ] == CH_BULLET )
+ if ( aBulletOverlay[ 0 ] == CH_BULLET )
{
if (bSwitchH2V)
aTextOriginPos.AdjustY(nShift ) ;
@@ -1506,14 +1487,14 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
}
for( sal_Int32 i = 1 ; i < nLen ; ++i )
{
- if ( aBulletOverlay[ i + nTmpIdx ] == CH_BULLET )
+ if ( aBulletOverlay[ i ] == CH_BULLET )
aKernArray [ i - 1 ] += nShift ;
if ( nAdd )
aKernArray [ i - 1 ] -= nAdd;
}
}
rInf.GetOut().DrawTextArray( aTextOriginPos, aBulletOverlay, aKernArray,
- {}, nTmpIdx , nLen );
+ {}, 0, nLen );
pTmpFont->SetColor( aPreviousColor );
pTmpFont->SetUnderline(aPreviousUnderline);