diff options
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/inc/EditLine.hxx | 10 | ||||
-rw-r--r-- | editeng/inc/TextPortion.hxx | 6 | ||||
-rw-r--r-- | editeng/inc/outleeng.hxx | 2 | ||||
-rw-r--r-- | editeng/qa/unit/core-test.cxx | 8 | ||||
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.hxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 36 | ||||
-rw-r--r-- | editeng/source/items/svxfont.cxx | 37 | ||||
-rw-r--r-- | editeng/source/outliner/outleeng.cxx | 2 | ||||
-rw-r--r-- | editeng/source/outliner/outliner.cxx | 5 |
11 files changed, 50 insertions, 62 deletions
diff --git a/editeng/inc/EditLine.hxx b/editeng/inc/EditLine.hxx index 46a2379853e6..38625bc246da 100644 --- a/editeng/inc/EditLine.hxx +++ b/editeng/inc/EditLine.hxx @@ -22,16 +22,14 @@ #include <vector> #include <sal/types.h> #include <tools/gen.hxx> +#include <vcl/kernarray.hxx> class ParaPortion; class EditLine { -public: - typedef std::vector<sal_Int32> CharPosArrayType; - private: - CharPosArrayType maPositions; + KernArray maPositions; std::vector<sal_Bool> maKashidaPositions; sal_Int32 mnTextWidth = 0; sal_Int32 mnStartPosX = 0; @@ -111,8 +109,8 @@ public: bool IsEmpty() const { return mnEnd <= mnStart; } - CharPosArrayType& GetCharPosArray() { return maPositions; } - const CharPosArrayType& GetCharPosArray() const { return maPositions; } + KernArray& GetCharPosArray() { return maPositions; } + const KernArray& GetCharPosArray() const { return maPositions; } std::vector<sal_Bool>& GetKashidaArray() { return maKashidaPositions; } const std::vector<sal_Bool>& GetKashidaArray() const { return maKashidaPositions; } diff --git a/editeng/inc/TextPortion.hxx b/editeng/inc/TextPortion.hxx index e5560f260326..5458eaa9cf23 100644 --- a/editeng/inc/TextPortion.hxx +++ b/editeng/inc/TextPortion.hxx @@ -71,14 +71,14 @@ struct ExtraPortionInfo bool bFirstCharIsRightPunktuation = false; bool bCompressed = false; - std::unique_ptr<sal_Int32[]> pOrgDXArray; + std::unique_ptr<double[]> pOrgDXArray; std::vector<sal_Int32> lineBreaksList; - void SaveOrgDXArray(const sal_Int32* pDXArray, sal_Int32 nLen) + void SaveOrgDXArray(const double* pDXArray, sal_Int32 nLen) { if (pDXArray) { - pOrgDXArray.reset(new sal_Int32[nLen]); + pOrgDXArray.reset(new double[nLen]); memcpy(pOrgDXArray.get(), pDXArray, nLen * sizeof(sal_Int32)); } else diff --git a/editeng/inc/outleeng.hxx b/editeng/inc/outleeng.hxx index c40837dc5f8f..56f7aa62485e 100644 --- a/editeng/inc/outleeng.hxx +++ b/editeng/inc/outleeng.hxx @@ -46,7 +46,7 @@ public: virtual void ParagraphConnected( sal_Int32 nLeftParagraph, sal_Int32 nRightParagraph ) override; virtual void DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, - sal_Int32 nTextLen, std::span<const sal_Int32> pDXArray, + sal_Int32 nTextLen, KernArraySpan pDXArray, std::span<const sal_Bool> pKashidaArray, const SvxFont& rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft, const EEngineData::WrongSpellVector* pWrongSpellVector, diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index 41b01c381250..4918ffb3aeb8 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -2140,12 +2140,12 @@ void Test::testCreateLines() CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rLine.GetStart()); CPPUNIT_ASSERT_EQUAL(sal_Int32(3), rLine.GetEnd()); - std::vector<sal_Int32> const& rArray = rLine.GetCharPosArray(); + KernArray const& rArray = rLine.GetCharPosArray(); CPPUNIT_ASSERT_EQUAL(size_t(3), rArray.size()); - CPPUNIT_ASSERT_EQUAL(sal_Int32(173), rArray[0]); - CPPUNIT_ASSERT_EQUAL(sal_Int32(333), rArray[1]); - CPPUNIT_ASSERT_EQUAL(sal_Int32(493), rArray[2]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(173), sal_Int32(rArray[0])); + CPPUNIT_ASSERT_EQUAL(sal_Int32(333), sal_Int32(rArray[1])); + CPPUNIT_ASSERT_EQUAL(sal_Int32(493), sal_Int32(rArray[2])); } { diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index fec2c8cd3c99..bdb33166d00b 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -1582,7 +1582,7 @@ EditEngine::CreateTransferable(const ESelection& rSelection) // ====================== Virtual Methods ======================== void EditEngine::DrawingText( const Point&, const OUString&, sal_Int32, sal_Int32, - std::span<const sal_Int32>, std::span<const sal_Bool>, + KernArraySpan, std::span<const sal_Bool>, const SvxFont&, sal_Int32 /*nPara*/, sal_uInt8 /*nRightToLeft*/, const EEngineData::WrongSpellVector*, const SvxFieldData*, bool, bool, const css::lang::Locale*, const Color&, const Color&) diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 3387607c4c5b..856a53b792fe 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -758,7 +758,7 @@ private: bool HasScriptType( sal_Int32 nPara, sal_uInt16 nType ) const; bool ImplCalcAsianCompression( ContentNode* pNode, TextPortion* pTextPortion, sal_Int32 nStartPos, - sal_Int32* pDXArray, sal_uInt16 n100thPercentFromMax, bool bManipulateDXArray ); + double* pDXArray, sal_uInt16 n100thPercentFromMax, bool bManipulateDXArray ); void ImplExpandCompressedPortions(EditLine& rLine, ParaPortion& rParaPortion, tools::Long nRemainingWidth); void ImplInitLayoutMode(OutputDevice& rOutDev, sal_Int32 nPara, sal_Int32 nIndex); diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 2e4ac3102ae7..b59c40ca42f4 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -4439,7 +4439,7 @@ tools::Long ImpEditEngine::GetXPos(ParaPortion const& rParaPortion, EditLine con if ( nType == AsianCompressionFlags::PunctuationRight && !rLine.GetCharPosArray().empty() ) { sal_Int32 n = nIndex - nTextPortionStart; - const sal_Int32* pDXArray = rLine.GetCharPosArray().data() + (nTextPortionStart - rLine.GetStart()); + const double* pDXArray = rLine.GetCharPosArray().data() + (nTextPortionStart - rLine.GetStart()); sal_Int32 nCharWidth = ( ( (n+1) < rPortion.GetLen() ) ? pDXArray[n] : rPortion.GetSize().Width() ) - ( n ? pDXArray[n-1] : 0 ); if ( (n+1) < rPortion.GetLen() ) diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index eeb6d3a0a175..ddbdb2176407 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -153,7 +153,7 @@ static void lcl_DrawRedLines( OutputDevice& rOutDev, const Point& rPoint, size_t nIndex, size_t nMaxEnd, - std::span<const sal_Int32> pDXArray, + KernArraySpan pDXArray, WrongList const * pWrongs, Degree10 nOrientation, const Point& rOrigin, @@ -1051,7 +1051,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) bEOL = true; bBrokenLine = true; } - EditLine::CharPosArrayType& rArray = pLine->GetCharPosArray(); + KernArray& rArray = pLine->GetCharPosArray(); size_t nPos = nTmpPos - pLine->GetStart(); rArray.insert(rArray.begin()+nPos, pPortion->GetSize().Width()); bCompressedChars = false; @@ -1065,7 +1065,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) bLineBreak = true; pPortion->SetKind( PortionKind::LINEBREAK ); bCompressedChars = false; - EditLine::CharPosArrayType& rArray = pLine->GetCharPosArray(); + KernArray& rArray = pLine->GetCharPosArray(); size_t nPos = nTmpPos - pLine->GetStart(); rArray.insert(rArray.begin()+nPos, pPortion->GetSize().Width()); } @@ -1179,7 +1179,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) } } nTmpWidth += pPortion->GetSize().Width(); - EditLine::CharPosArrayType& rArray = pLine->GetCharPosArray(); + KernArray& rArray = pLine->GetCharPosArray(); size_t nPos = nTmpPos - pLine->GetStart(); rArray.insert(rArray.begin()+nPos, pPortion->GetSize().Width()); pPortion->SetKind(PortionKind::FIELD); @@ -1233,15 +1233,13 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) // The array is generally flattened at the beginning // => Always simply quick inserts. size_t nPos = nTmpPos - pLine->GetStart(); - EditLine::CharPosArrayType& rArray = pLine->GetCharPosArray(); - assert(aCharPositionArray.get_factor() == 1); - std::vector<sal_Int32>& rKernArray = aCharPositionArray.get_subunit_array(); - rArray.insert( rArray.begin() + nPos, rKernArray.data(), rKernArray.data() + nPortionLen); + KernArray& rArray = pLine->GetCharPosArray(); + rArray.insert( rArray.begin() + nPos, aCharPositionArray.data(), aCharPositionArray.data() + nPortionLen); // And now check for Compression: if ( !bContinueLastPortion && nPortionLen && GetAsianCompressionMode() != CharCompressType::NONE ) { - sal_Int32* pDXArray = rArray.data() + nTmpPos - pLine->GetStart(); + double* pDXArray = rArray.data() + nTmpPos - pLine->GetStart(); bCompressedChars |= ImplCalcAsianCompression( pNode, pPortion, nTmpPos, pDXArray, 10000, false); } @@ -1435,7 +1433,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) if ( bCompressedChars && pPortion && ( pPortion->GetLen() > 1 ) && pPortion->GetExtraInfos() && pPortion->GetExtraInfos()->bCompressed ) { // I need the manipulated DXArray for determining the break position... - sal_Int32* pDXArray = pLine->GetCharPosArray().data() + (nPortionStart - pLine->GetStart()); + double* pDXArray = pLine->GetCharPosArray().data() + (nPortionStart - pLine->GetStart()); ImplCalcAsianCompression( pNode, pPortion, nPortionStart, pDXArray, 10000, true); } @@ -1648,7 +1646,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) // If a portion was wrapped there may be far too many positions in // CharPosArray: - EditLine::CharPosArrayType& rArray = pLine->GetCharPosArray(); + KernArray& rArray = pLine->GetCharPosArray(); size_t nLen = pLine->GetLen(); if (rArray.size() > nLen) rArray.erase(rArray.begin()+nLen, rArray.end()); @@ -3477,7 +3475,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po OUString aText; sal_Int32 nTextStart = 0; sal_Int32 nTextLen = 0; - std::span<const sal_Int32> pDXArray; + KernArraySpan pDXArray; std::span<const sal_Bool> pKashidaArray; KernArray aTmpDXArray; @@ -3486,7 +3484,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po aText = rParaPortion.GetNode()->GetString(); nTextStart = nIndex; nTextLen = rTextPortion.GetLen(); - pDXArray = std::span(pLine->GetCharPosArray().data() + (nIndex - pLine->GetStart()), + pDXArray = KernArraySpan(pLine->GetCharPosArray().data() + (nIndex - pLine->GetStart()), pLine->GetCharPosArray().size() - (nIndex - pLine->GetStart())); if (!pLine->GetKashidaArray().empty()) @@ -3647,9 +3645,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po aTmpFont.SetPhysFont(*GetRefDevice()); aTmpFont.QuickGetTextSize( GetRefDevice(), aText, nTextStart, nTextLen, &aTmpDXArray ); - assert(aTmpDXArray.get_factor() == 1); - std::vector<sal_Int32>& rKernArray = aTmpDXArray.get_subunit_array(); - pDXArray = rKernArray; + pDXArray = KernArraySpan(aTmpDXArray); // add a meta file comment if we record to a metafile if( bMetafileValid ) @@ -3676,9 +3672,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po aTmpFont.SetPhysFont(*GetRefDevice()); aTmpFont.QuickGetTextSize( GetRefDevice(), aText, 0, aText.getLength(), &aTmpDXArray ); - assert(aTmpDXArray.get_factor() == 1); - std::vector<sal_Int32>& rKernArray = aTmpDXArray.get_subunit_array(); - pDXArray = rKernArray; + pDXArray = aTmpDXArray; } tools::Long nTxtWidth = rTextPortion.GetSize().Width(); @@ -4792,7 +4786,7 @@ Color ImpEditEngine::GetAutoColor() const bool ImpEditEngine::ImplCalcAsianCompression(ContentNode* pNode, TextPortion* pTextPortion, sal_Int32 nStartPos, - sal_Int32* pDXArray, sal_uInt16 n100thPercentFromMax, + double* pDXArray, sal_uInt16 n100thPercentFromMax, bool bManipulateDXArray) { DBG_ASSERT( GetAsianCompressionMode() != CharCompressType::NONE, "ImplCalcAsianCompression - Why?" ); @@ -4960,7 +4954,7 @@ void ImpEditEngine::ImplExpandCompressedPortions(EditLine& rLine, ParaPortion& r sal_Int32 nTxtPortion = rParaPortion.GetTextPortions().GetPos( pTP ); sal_Int32 nTxtPortionStart = rParaPortion.GetTextPortions().GetStartPos( nTxtPortion ); DBG_ASSERT( nTxtPortionStart >= rLine.GetStart(), "Portion doesn't belong to the line!!!" ); - sal_Int32* pDXArray = rLine.GetCharPosArray().data() + (nTxtPortionStart - rLine.GetStart()); + double* pDXArray = rLine.GetCharPosArray().data() + (nTxtPortionStart - rLine.GetStart()); if ( pTP->GetExtraInfos()->pOrgDXArray ) memcpy( pDXArray, pTP->GetExtraInfos()->pOrgDXArray.get(), (pTP->GetLen()-1)*sizeof(sal_Int32) ); ImplCalcAsianCompression( rParaPortion.GetNode(), pTP, nTxtPortionStart, pDXArray, static_cast<sal_uInt16>(nCompressPercent), true ); diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx index 3bd2c8086c07..ea8c6523f703 100644 --- a/editeng/source/items/svxfont.cxx +++ b/editeng/source/items/svxfont.cxx @@ -480,10 +480,10 @@ Size SvxFont::QuickGetTextSize( const OutputDevice *pOut, const OUString &rTxt, if( IsFixKerning() && ( nLen > 1 ) && !bStacked) { - auto nKern = GetFixKerning(); - tools::Long nOldValue = (*pDXArray)[0]; + short nKern = GetFixKerning(); + double nOldValue = (*pDXArray)[0]; tools::Long nSpaceSum = nKern; - pDXArray->adjust(0, nSpaceSum); + (*pDXArray)[0] += nSpaceSum; for ( sal_Int32 i = 1; i < nLen; i++ ) { @@ -492,14 +492,14 @@ Size SvxFont::QuickGetTextSize( const OutputDevice *pOut, const OUString &rTxt, nOldValue = (*pDXArray)[i]; nSpaceSum += nKern; } - pDXArray->adjust(i, nSpaceSum); + (*pDXArray)[i] += nSpaceSum; } // The last one is a nKern too big: nOldValue = (*pDXArray)[nLen - 1]; - tools::Long nNewValue = nOldValue - nKern; + double nNewValue = nOldValue - nKern; for ( sal_Int32 i = nLen - 1; i >= 0 && (*pDXArray)[i] == nOldValue; --i) - pDXArray->set(i, nNewValue); + (*pDXArray)[i] = nNewValue; aTxtSize.AdjustWidth(nSpaceSum - nKern); } @@ -525,7 +525,7 @@ Size SvxFont::GetTextSize(const OutputDevice& rOut, const OUString &rTxt, } static void DrawTextArray( OutputDevice* pOut, const Point& rStartPt, const OUString& rStr, - std::span<const sal_Int32> pDXAry, + KernArraySpan pDXAry, std::span<const sal_Bool> pKashidaAry, sal_Int32 nIndex, sal_Int32 nLen ) { @@ -536,7 +536,7 @@ static void DrawTextArray( OutputDevice* pOut, const Point& rStartPt, const OUSt void SvxFont::QuickDrawText( OutputDevice *pOut, const Point &rPos, const OUString &rTxt, const sal_Int32 nIdx, const sal_Int32 nLen, - std::span<const sal_Int32> pDXArray, + KernArraySpan pDXArray, std::span<const sal_Bool> pKashidaArray) const { @@ -728,14 +728,11 @@ void SvxDoGetCapitalSize::Do( const OUString &_rTxt, const sal_Int32 _nIdx, KernArray aKernArray; aPartSize.setWidth(basegfx::fround<tools::Long>( pOut->GetTextArray(_rTxt, &aKernArray, _nIdx, _nLen).nWidth)); - assert(pDXAry->get_factor() == aKernArray.get_factor()); - auto& dest = pDXAry->get_subunit_array(); - sal_Int32 nStart = dest.empty() ? 0 : dest.back(); + double nStart = pDXAry->empty() ? 0 : pDXAry->back(); size_t nSrcLen = aKernArray.size(); - dest.reserve(dest.size() + nSrcLen); - const auto& src = aKernArray.get_subunit_array(); + pDXAry->reserve(pDXAry->size() + nSrcLen); for (size_t i = 0; i < nSrcLen; ++i) - dest.push_back(src[i] + nStart); + (*pDXAry).push_back(aKernArray[i] + nStart); } else { @@ -782,11 +779,11 @@ protected: Point aPos; Point aSpacePos; short nKern; - std::span<const sal_Int32> pDXArray; + KernArraySpan pDXArray; std::span<const sal_Bool> pKashidaArray; public: SvxDoDrawCapital( SvxFont *pFnt, OutputDevice *_pOut, const OUString &_rTxt, - std::span<const sal_Int32> _pDXArray, + KernArraySpan _pDXArray, std::span<const sal_Bool> _pKashidaArray, const sal_Int32 _nIdx, const sal_Int32 _nLen, const Point &rPos, const short nKrn ) @@ -872,10 +869,10 @@ void SvxDoDrawCapital::Do( const OUString &_rTxt, const sal_Int32 nSpanIdx, Point aStartPos(aPos.X() + nStartX, aPos.Y()); - std::vector<sal_Int32> aDXArray; - aDXArray.reserve(nSpanLen); + KernArray aDXArray; + aDXArray.resize(nSpanLen); for (sal_Int32 i = 0; i < nSpanLen; ++i) - aDXArray.push_back(pDXArray[nStartOffset + i] - nStartX); + aDXArray[i] = pDXArray[nStartOffset + i] - nStartX; auto aKashidaArray = !pKashidaArray.empty() ? std::span<const sal_Bool>(pKashidaArray.data() + nStartOffset, nSpanLen) : @@ -901,7 +898,7 @@ void SvxDoDrawCapital::Do( const OUString &_rTxt, const sal_Int32 nSpanIdx, void SvxFont::DrawCapital( OutputDevice *pOut, const Point &rPos, const OUString &rTxt, - std::span<const sal_Int32> pDXArray, + KernArraySpan pDXArray, std::span<const sal_Bool> pKashidaArray, const sal_Int32 nIdx, const sal_Int32 nLen ) const { diff --git a/editeng/source/outliner/outleeng.cxx b/editeng/source/outliner/outleeng.cxx index 6ad8d267ed19..67fcd0c4bd93 100644 --- a/editeng/source/outliner/outleeng.cxx +++ b/editeng/source/outliner/outleeng.cxx @@ -151,7 +151,7 @@ OUString OutlinerEditEng::GetUndoComment( sal_uInt16 nUndoId ) const } void OutlinerEditEng::DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, sal_Int32 nTextLen, - std::span<const sal_Int32> pDXArray, std::span<const sal_Bool> pKashidaArray, + KernArraySpan pDXArray, std::span<const sal_Bool> pKashidaArray, const SvxFont& rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft, const EEngineData::WrongSpellVector* pWrongSpellVector, const SvxFieldData* pFieldData, diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 718e7f42aea8..1a5ad1e0cbdd 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -967,8 +967,7 @@ void Outliner::PaintBullet(sal_Int32 nPara, const Point& rStartPos, const Point& aTextPos.AdjustY( -(aMetric.GetDescent()) ); } - assert(aBuf.get_factor() == 1); - DrawingText(aTextPos, pPara->GetText(), 0, pPara->GetText().getLength(), aBuf.get_subunit_array(), {}, + DrawingText(aTextPos, pPara->GetText(), 0, pPara->GetText().getLength(), aBuf, {}, aSvxFont, nPara, bRightToLeftPara ? 1 : 0, nullptr, nullptr, false, false, true, nullptr, Color(), Color()); } else @@ -1644,7 +1643,7 @@ void Outliner::StripPortions() } void Outliner::DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, - sal_Int32 nTextLen, std::span<const sal_Int32> pDXArray, + sal_Int32 nTextLen, std::span<const double> pDXArray, std::span<const sal_Bool> pKashidaArray, const SvxFont& rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft, const EEngineData::WrongSpellVector* pWrongSpellVector, |