diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-11-29 20:31:27 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-12-02 15:20:07 +0000 |
commit | f9395a123e8c85134bdd6e471bc93b2745e22a9d (patch) | |
tree | fd64e75a7ea36f28e9b993ae0c00480c480803df /editeng | |
parent | 1e222575a3b637398b5b2d8e3172f12538ff34e3 (diff) |
tdf#152094 retain more accuracy from RefDevMode::MSO1
do it like this to avoid adding another mapmode and to keep things
"the same" as much as possible
Change-Id: I1965aa545646f2d27b950d6335b2f608c3e4e04b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143475
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 18 | ||||
-rw-r--r-- | editeng/source/items/svxfont.cxx | 14 | ||||
-rw-r--r-- | editeng/source/outliner/outliner.cxx | 5 |
3 files changed, 22 insertions, 15 deletions
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 2d2a339658df..2ce9a60f3eee 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -838,7 +838,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) EditLine aSaveLine( *pLine ); SvxFont aTmpFont( pNode->GetCharAttribs().GetDefFont() ); - std::vector<sal_Int32> aCharPositionArray(pNode->Len()); + KernArray aCharPositionArray; bool bSameLineAgain = false; // For TextRanger, if the height changes. TabInfo aCurrentTab; @@ -1127,7 +1127,7 @@ 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; + KernArray aTmpDXArray; pPortion->SetSize(aTmpFont.QuickGetTextSize(GetRefDevice(), aFieldValue, 0, aFieldValue.getLength(), &aTmpDXArray)); @@ -1256,7 +1256,9 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) // => Always simply quick inserts. size_t nPos = nTmpPos - pLine->GetStart(); EditLine::CharPosArrayType& rArray = pLine->GetCharPosArray(); - rArray.insert( rArray.begin() + nPos, aCharPositionArray.data(), aCharPositionArray.data() + nPortionLen); + assert(aCharPositionArray.get_factor() == 1); + std::vector<sal_Int32>& rKernArray = aCharPositionArray.get_subunit_array(); + rArray.insert( rArray.begin() + nPos, rKernArray.data(), rKernArray.data() + nPortionLen); // And now check for Compression: if ( !bContinueLastPortion && nPortionLen && GetAsianCompressionMode() != CharCompressType::NONE ) @@ -3462,7 +3464,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po sal_Int32 nTextLen = 0; o3tl::span<const sal_Int32> pDXArray; o3tl::span<const sal_Bool> pKashidaArray; - std::vector<sal_Int32> aTmpDXArray; + KernArray aTmpDXArray; if ( rTextPortion.GetKind() == PortionKind::TEXT ) { @@ -3604,7 +3606,9 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po aTmpFont.SetPhysFont(*GetRefDevice()); aTmpFont.QuickGetTextSize( GetRefDevice(), aText, nTextStart, nTextLen, &aTmpDXArray ); - pDXArray = aTmpDXArray; + assert(aTmpDXArray.get_factor() == 1); + std::vector<sal_Int32>& rKernArray = aTmpDXArray.get_subunit_array(); + pDXArray = rKernArray; // add a meta file comment if we record to a metafile if( bMetafileValid ) @@ -3631,7 +3635,9 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po aTmpFont.SetPhysFont(*GetRefDevice()); aTmpFont.QuickGetTextSize( GetRefDevice(), aText, 0, aText.getLength(), &aTmpDXArray ); - pDXArray = aTmpDXArray; + assert(aTmpDXArray.get_factor() == 1); + std::vector<sal_Int32>& rKernArray = aTmpDXArray.get_subunit_array(); + pDXArray = rKernArray; } tools::Long nTxtWidth = rTextPortion.GetSize().Width(); diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx index b6f9617a4c27..b484a645a7f6 100644 --- a/editeng/source/items/svxfont.cxx +++ b/editeng/source/items/svxfont.cxx @@ -32,7 +32,7 @@ #include <sal/log.hxx> #include <limits> -static tools::Long GetTextArray( const OutputDevice* pOut, const OUString& rStr, std::vector<sal_Int32>* pDXAry, +static tools::Long GetTextArray( const OutputDevice* pOut, const OUString& rStr, KernArray* pDXAry, sal_Int32 nIndex, sal_Int32 nLen ) { @@ -441,7 +441,7 @@ Size SvxFont::GetPhysTxtSize( const OutputDevice *pOut, const OUString &rTxt, if( IsFixKerning() && ( nLen > 1 ) ) { auto nKern = GetFixKerning(); - std::vector<sal_Int32> aDXArray; + KernArray aDXArray(nLen); GetTextArray(pOut, rTxt, &aDXArray, nIdx, nLen); tools::Long nOldValue = aDXArray[0]; sal_Int32 nSpaceCount = 0; @@ -475,13 +475,13 @@ Size SvxFont::GetPhysTxtSize( const OutputDevice *pOut ) } 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, KernArray* pDXArray ) const { if ( !IsCaseMap() && !IsFixKerning() ) return Size( GetTextArray( pOut, rTxt, pDXArray, nIdx, nLen ), pOut->GetTextHeight() ); - std::vector<sal_Int32> aDXArray; + KernArray aDXArray; // We always need pDXArray to count the number of kern spaces if (!pDXArray && IsFixKerning() && nLen > 1) @@ -503,7 +503,7 @@ Size SvxFont::QuickGetTextSize( const OutputDevice *pOut, const OUString &rTxt, auto nKern = GetFixKerning(); tools::Long nOldValue = (*pDXArray)[0]; tools::Long nSpaceSum = nKern; - (*pDXArray)[0] += nSpaceSum; + pDXArray->adjust(0, nSpaceSum); for ( sal_Int32 i = 1; i < nLen; i++ ) { @@ -512,14 +512,14 @@ Size SvxFont::QuickGetTextSize( const OutputDevice *pOut, const OUString &rTxt, nOldValue = (*pDXArray)[i]; nSpaceSum += nKern; } - (*pDXArray)[i] += nSpaceSum; + pDXArray->adjust(i, nSpaceSum); } // The last one is a nKern too big: nOldValue = (*pDXArray)[nLen - 1]; tools::Long nNewValue = nOldValue - nKern; for ( sal_Int32 i = nLen - 1; i >= 0 && (*pDXArray)[i] == nOldValue; --i) - (*pDXArray)[i] = nNewValue; + pDXArray->set(i, nNewValue); aTxtSize.AdjustWidth(nSpaceSum - nKern); } diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 9254bae2ab77..84097ae2a14b 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -964,7 +964,7 @@ void Outliner::PaintBullet(sal_Int32 nPara, const Point& rStartPos, const Point& if(bStrippingPortions) { const vcl::Font& aSvxFont(rOutDev.GetFont()); - std::vector<sal_Int32> aBuf; + KernArray aBuf; rOutDev.GetTextArray( pPara->GetText(), &aBuf ); if(bSymbol) @@ -974,7 +974,8 @@ void Outliner::PaintBullet(sal_Int32 nPara, const Point& rStartPos, const Point& aTextPos.AdjustY( -(aMetric.GetDescent()) ); } - DrawingText(aTextPos, pPara->GetText(), 0, pPara->GetText().getLength(), aBuf, {}, + assert(aBuf.get_factor() == 1); + DrawingText(aTextPos, pPara->GetText(), 0, pPara->GetText().getLength(), aBuf.get_subunit_array(), {}, aSvxFont, nPara, bRightToLeftPara ? 1 : 0, nullptr, nullptr, false, false, true, nullptr, Color(), Color()); } else |