summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-03-15 14:07:01 +0100
committerLuboš Luňák <l.lunak@collabora.com>2022-03-15 19:42:45 +0100
commit673a210b73716cf9ceb7b104b38e39987d0515af (patch)
treeddf839b9bfe1edcbb6aef7ad148db791fe9f3614 /editeng
parentb633ab7a53aec033ba933c4ebc48a4fbe56d6c4b (diff)
use SalLayoutGlyphsCache in EditEngine/SvxFont (tdf#94677)
Change-Id: I4c7c94c10b9184ad1d3348e7b364748b4e7c34de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131611 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/impedit.hxx2
-rw-r--r--editeng/source/editeng/impedit2.cxx3
-rw-r--r--editeng/source/editeng/impedit3.cxx36
-rw-r--r--editeng/source/items/svxfont.cxx40
4 files changed, 56 insertions, 25 deletions
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index eb8176561cb1..36480f26bc1c 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -36,6 +36,7 @@
#include <vcl/idle.hxx>
#include <vcl/commandevent.hxx>
#include <vcl/ptrstyle.hxx>
+#include <vcl/glyphitemcache.hxx>
#include <vcl/dndhelp.hxx>
#include <svl/ondemand.hxx>
@@ -607,6 +608,7 @@ private:
bool mbNbspRunNext; // can't be a bitfield as it is passed as bool&
+ SalLayoutGlyphsCache mGlyphsCache;
// Methods...
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 36747c1c8666..402d606d8b57 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -3438,7 +3438,8 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine,
SeekCursor( pPortion->GetNode(), nPos+1, aTmpFont );
aTmpFont.SetPhysFont(*GetRefDevice());
ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage());
- nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(), pPortion->GetNode()->GetString(), nPos, rTextPortion.GetLen() ).Width();
+ nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(),
+ pPortion->GetNode()->GetString(), nPos, rTextPortion.GetLen(), nullptr, &mGlyphsCache ).Width();
}
}
break;
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 4bff8d26c94d..4f341fd65959 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -996,7 +996,8 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
// Height needed...
SeekCursor( pNode, nTmpPos+1, aTmpFont );
- pPortion->GetSize().setHeight( aTmpFont.QuickGetTextSize( GetRefDevice(), OUString(), 0, 0 ).Height() );
+ pPortion->GetSize().setHeight(
+ aTmpFont.QuickGetTextSize( GetRefDevice(), OUString(), 0, 0, nullptr, &mGlyphsCache ).Height() );
DBG_ASSERT( pPortion->GetSize().Width() >= 0, "Tab incorrectly calculated!" );
@@ -1041,7 +1042,8 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
OUString aFieldValue = static_cast<const EditCharAttribField*>(pNextFeature)->GetFieldValue();
// get size, but also DXArray to allow length information in line breaking below
std::vector<sal_Int32> aTmpDXArray;
- pPortion->GetSize() = aTmpFont.QuickGetTextSize(GetRefDevice(), aFieldValue, 0, aFieldValue.getLength(), &aTmpDXArray);
+ pPortion->GetSize() = aTmpFont.QuickGetTextSize(GetRefDevice(),
+ aFieldValue, 0, aFieldValue.getLength(), &aTmpDXArray, &mGlyphsCache);
// So no scrolling for oversized fields
if ( pPortion->GetSize().Width() > nXWidth )
@@ -1146,7 +1148,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
if (bContinueLastPortion)
{
Size aSize( aTmpFont.QuickGetTextSize( GetRefDevice(),
- rParaPortion.GetNode()->GetString(), nTmpPos, nPortionLen, &aBuf ));
+ rParaPortion.GetNode()->GetString(), nTmpPos, nPortionLen, &aBuf, &mGlyphsCache ));
pPortion->GetSize().AdjustWidth(aSize.Width() );
if (pPortion->GetSize().Height() < aSize.Height())
pPortion->GetSize().setHeight( aSize.Height() );
@@ -1154,7 +1156,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
else
{
pPortion->GetSize() = aTmpFont.QuickGetTextSize( GetRefDevice(),
- rParaPortion.GetNode()->GetString(), nTmpPos, nPortionLen, &aBuf );
+ rParaPortion.GetNode()->GetString(), nTmpPos, nPortionLen, &aBuf, &mGlyphsCache );
}
// #i9050# Do Kerning also behind portions...
@@ -1222,7 +1224,8 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
if ( nDecPos != -1 )
{
nW -= rParaPortion.GetTextPortions()[nTmpPortion].GetSize().Width();
- nW += aTmpFont.QuickGetTextSize( GetRefDevice(), rParaPortion.GetNode()->GetString(), nTmpPos, nDecPos ).Width();
+ nW += aTmpFont.QuickGetTextSize( GetRefDevice(), rParaPortion.GetNode()->GetString(),
+ nTmpPos, nDecPos, nullptr, &mGlyphsCache ).Width();
aCurrentTab.bValid = false;
}
}
@@ -2367,7 +2370,8 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_Int32 nPos
aTmpFont.SetPhysFont(*GetRefDevice());
GetRefDevice()->Push( vcl::PushFlags::TEXTLANGUAGE );
ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage());
- Size aSz = aTmpFont.QuickGetTextSize( GetRefDevice(), pPortion->GetNode()->GetString(), nTxtPortionStart, pTextPortion->GetLen() );
+ Size aSz = aTmpFont.QuickGetTextSize( GetRefDevice(), pPortion->GetNode()->GetString(),
+ nTxtPortionStart, pTextPortion->GetLen(), nullptr, &mGlyphsCache );
GetRefDevice()->Pop();
pTextPortion->GetExtraInfos()->nOrgWidth = aSz.Width();
}
@@ -3296,7 +3300,8 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
if ( 0x200B == cChar || 0x2060 == cChar )
{
- tools::Long nHalfBlankWidth = aTmpFont.QuickGetTextSize( &rOutDev, " ", 0, 1 ).Width() / 2;
+ tools::Long nHalfBlankWidth = aTmpFont.QuickGetTextSize( &rOutDev,
+ " ", 0, 1, nullptr, &mGlyphsCache ).Width() / 2;
const tools::Long nAdvanceX = ( nTmpIdx == nTmpEnd ?
rTextPortion.GetSize().Width() :
@@ -3332,13 +3337,14 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
aTmpFont.SetPropr( 25 );
aTmpFont.SetPhysFont(rOutDev);
- const Size aSlashSize = aTmpFont.QuickGetTextSize( &rOutDev, aSlash, 0, 1 );
+ const Size aSlashSize = aTmpFont.QuickGetTextSize( &rOutDev,
+ aSlash, 0, 1, nullptr, &mGlyphsCache );
Point aSlashPos( aTmpPos );
const tools::Long nAddX = nHalfBlankWidth - aSlashSize.Width() / 2;
setXDirectionAwareFrom(aSlashPos, aTopLeftRectPos);
adjustXDirectionAware(aSlashPos, nAddX);
- aTmpFont.QuickDrawText( &rOutDev, aSlashPos, aSlash, 0, 1 );
+ aTmpFont.QuickDrawText( &rOutDev, aSlashPos, aSlash, 0, 1, {}, &mGlyphsCache );
aTmpFont.SetEscapement( nOldEscapement );
aTmpFont.SetPropr( nOldPropr );
@@ -3399,7 +3405,8 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
}
aTmpFont.SetPhysFont(*GetRefDevice());
- aTmpFont.QuickGetTextSize( GetRefDevice(), aText, nTextStart, nTextLen, &aTmpDXArray );
+ aTmpFont.QuickGetTextSize( GetRefDevice(), aText, nTextStart, nTextLen,
+ &aTmpDXArray, &mGlyphsCache );
pDXArray = aTmpDXArray;
// add a meta file comment if we record to a metafile
@@ -3425,7 +3432,8 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
// crash when accessing 0 pointer in pDXArray
aTmpFont.SetPhysFont(*GetRefDevice());
- aTmpFont.QuickGetTextSize( GetRefDevice(), aText, 0, aText.getLength(), &aTmpDXArray );
+ aTmpFont.QuickGetTextSize( GetRefDevice(), aText, 0, aText.getLength(),
+ &aTmpDXArray, &mGlyphsCache );
pDXArray = aTmpDXArray;
}
@@ -3626,7 +3634,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
--nTextLen;
// output directly
- aTmpFont.QuickDrawText( &rOutDev, aRealOutPos, aText, nTextStart, nTextLen, pDXArray );
+ aTmpFont.QuickDrawText( &rOutDev, aRealOutPos, aText, nTextStart, nTextLen, pDXArray, &mGlyphsCache );
if ( bDrawFrame )
{
@@ -3717,7 +3725,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
aTmpFont.SetEscapement( 0 );
aTmpFont.SetPhysFont(rOutDev);
tools::Long nCharWidth = aTmpFont.QuickGetTextSize( &rOutDev,
- OUString(rTextPortion.GetExtraValue()), 0, 1 ).Width();
+ OUString(rTextPortion.GetExtraValue()), 0, 1, {}, &mGlyphsCache ).Width();
sal_Int32 nChars = 2;
if( nCharWidth )
nChars = rTextPortion.GetSize().Width() / nCharWidth;
@@ -3729,7 +3737,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
OUStringBuffer aBuf(nChars);
comphelper::string::padToLength(aBuf, nChars, rTextPortion.GetExtraValue());
OUString aText(aBuf.makeStringAndClear());
- aTmpFont.QuickDrawText( &rOutDev, aTmpPos, aText, 0, aText.getLength() );
+ aTmpFont.QuickDrawText( &rOutDev, aTmpPos, aText, 0, aText.getLength(), {}, &mGlyphsCache );
rOutDev.DrawStretchText( aTmpPos, rTextPortion.GetSize().Width(), aText );
if ( bStripOnly )
diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx
index d4370e9b00de..7c73d0c9d628 100644
--- a/editeng/source/items/svxfont.cxx
+++ b/editeng/source/items/svxfont.cxx
@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <editeng/svxfont.hxx>
+
+#include <vcl/glyphitemcache.hxx>
#include <vcl/metric.hxx>
#include <vcl/outdev.hxx>
#include <vcl/print.hxx>
@@ -25,7 +28,6 @@
#include <tools/poly.hxx>
#include <unotools/charclass.hxx>
#include <com/sun/star/i18n/KCharacterType.hpp>
-#include <editeng/svxfont.hxx>
#include <editeng/escapementitem.hxx>
#include <sal/log.hxx>
@@ -451,20 +453,28 @@ Size SvxFont::GetPhysTxtSize( const OutputDevice *pOut )
return aTxtSize;
}
+static tools::Long GetTextArray( const OutputDevice* pOut, const OUString& rStr, std::vector<sal_Int32>* pDXAry,
+ sal_Int32 nIndex, sal_Int32 nLen, SalLayoutGlyphsCache* cache )
+{
+ const SalLayoutGlyphs* layoutGlyphs = cache ? cache->GetLayoutGlyphs(pOut, rStr, nIndex, nLen) : nullptr;
+ return pOut->GetTextArray( rStr, pDXAry, nIndex, nLen, nullptr, layoutGlyphs);
+}
+
Size SvxFont::QuickGetTextSize( const OutputDevice *pOut, const OUString &rTxt,
- const sal_Int32 nIdx, const sal_Int32 nLen, std::vector<sal_Int32>* pDXArray ) const
+ const sal_Int32 nIdx, const sal_Int32 nLen, std::vector<sal_Int32>* pDXArray,
+ SalLayoutGlyphsCache* cache ) const
{
if ( !IsCaseMap() && !IsKern() )
- return Size( pOut->GetTextArray( rTxt, pDXArray, nIdx, nLen ),
+ return Size( GetTextArray( pOut, rTxt, pDXArray, nIdx, nLen, cache ),
pOut->GetTextHeight() );
Size aTxtSize;
aTxtSize.setHeight( pOut->GetTextHeight() );
if ( !IsCaseMap() )
- aTxtSize.setWidth( pOut->GetTextArray( rTxt, pDXArray, nIdx, nLen ) );
+ aTxtSize.setWidth( GetTextArray( pOut, rTxt, pDXArray, nIdx, nLen, cache ) );
else
- aTxtSize.setWidth( pOut->GetTextArray( CalcCaseMap( rTxt ),
- pDXArray, nIdx, nLen ) );
+ aTxtSize.setWidth( GetTextArray( pOut, CalcCaseMap( rTxt ),
+ pDXArray, nIdx, nLen, cache ) );
if( IsKern() && ( nLen > 1 ) )
{
@@ -498,15 +508,25 @@ Size SvxFont::GetTextSize(const OutputDevice& rOut, const OUString &rTxt,
return aTxtSize;
}
+static void DrawTextArray( OutputDevice* pOut, const Point& rStartPt, const OUString& rStr,
+ o3tl::span<const sal_Int32> pDXAry,
+ sal_Int32 nIndex, sal_Int32 nLen,
+ SalLayoutGlyphsCache* cache )
+{
+ const SalLayoutGlyphs* layoutGlyphs = cache ? cache->GetLayoutGlyphs(pOut, rStr, nIndex, nLen) : nullptr;
+ pOut->DrawTextArray(rStartPt, rStr, pDXAry, nIndex, nLen, SalLayoutFlags::NONE, layoutGlyphs);
+}
+
void SvxFont::QuickDrawText( OutputDevice *pOut,
const Point &rPos, const OUString &rTxt,
- const sal_Int32 nIdx, const sal_Int32 nLen, o3tl::span<const sal_Int32> pDXArray ) const
+ const sal_Int32 nIdx, const sal_Int32 nLen, o3tl::span<const sal_Int32> pDXArray,
+ SalLayoutGlyphsCache* cache ) const
{
// Font has to be selected in OutputDevice...
if ( !IsCaseMap() && !IsCapital() && !IsKern() && !IsEsc() )
{
- pOut->DrawTextArray( rPos, rTxt, pDXArray, nIdx, nLen );
+ DrawTextArray( pOut, rPos, rTxt, pDXArray, nIdx, nLen, cache );
return;
}
@@ -543,9 +563,9 @@ void SvxFont::QuickDrawText( OutputDevice *pOut,
else
{
if ( !IsCaseMap() )
- pOut->DrawTextArray( aPos, rTxt, pDXArray, nIdx, nLen );
+ DrawTextArray( pOut, aPos, rTxt, pDXArray, nIdx, nLen, cache );
else
- pOut->DrawTextArray( aPos, CalcCaseMap( rTxt ), pDXArray, nIdx, nLen );
+ DrawTextArray( pOut, aPos, CalcCaseMap( rTxt ), pDXArray, nIdx, nLen, cache );
}
}
}