use std::vector for fetching DX array data
because I'm trying to track down a related heap corruption, and that is much easier if the access to the array is checked by the std::vector debug runtime Change-Id: Ia665f5cebb7f14d88942e88b4b400ad3c28ef5d9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121527 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -2567,15 +2567,15 @@ namespace cppcanvas::internal
|
||||
// generating a DX array, and uniformly
|
||||
// distributing the excess/insufficient width
|
||||
// to every logical character.
|
||||
std::unique_ptr< ::tools::Long []> pDXArray( new ::tools::Long[nLen] );
|
||||
std::vector<::tools::Long> aDXArray;
|
||||
|
||||
rVDev.GetTextArray( pAct->GetText(), pDXArray.get(),
|
||||
rVDev.GetTextArray( pAct->GetText(), &aDXArray,
|
||||
pAct->GetIndex(), pAct->GetLen() );
|
||||
|
||||
const sal_Int32 nWidthDifference( pAct->GetWidth() - pDXArray[ nLen-1 ] );
|
||||
const sal_Int32 nWidthDifference( pAct->GetWidth() - aDXArray[ nLen-1 ] );
|
||||
|
||||
// Last entry of pDXArray contains total width of the text
|
||||
::tools::Long* p = pDXArray.get();
|
||||
::tools::Long* p = aDXArray.data();
|
||||
for (sal_Int32 i = 1; i <= nLen; ++i)
|
||||
{
|
||||
// calc ratio for every array entry, to
|
||||
@@ -2592,7 +2592,7 @@ namespace cppcanvas::internal
|
||||
sText,
|
||||
pAct->GetIndex(),
|
||||
nLen,
|
||||
pDXArray.get(),
|
||||
aDXArray.data(),
|
||||
rFactoryParms,
|
||||
bSubsettableActions );
|
||||
}
|
||||
|
||||
@@ -186,12 +186,11 @@ namespace cppcanvas::internal
|
||||
{
|
||||
// no external DX array given, create one from given
|
||||
// string
|
||||
std::unique_ptr< ::tools::Long []> pCharWidths( new ::tools::Long[nLen] );
|
||||
std::vector<::tools::Long> aCharWidths;
|
||||
|
||||
rVDev.GetTextArray( rText, pCharWidths.get(),
|
||||
nStartPos, nLen );
|
||||
rVDev.GetTextArray( rText, &aCharWidths, nStartPos, nLen );
|
||||
|
||||
return setupDXArray( pCharWidths.get(), nLen, rState );
|
||||
return setupDXArray( aCharWidths.data(), nLen, rState );
|
||||
}
|
||||
|
||||
::basegfx::B2DPoint adaptStartPoint( const ::basegfx::B2DPoint& rStartPoint,
|
||||
|
||||
@@ -309,7 +309,7 @@ std::vector<double> TextLayouterDevice::getTextArray(const OUString& rText, sal_
|
||||
{
|
||||
aRetval.reserve(nTextLength);
|
||||
std::vector<tools::Long> aArray(nTextLength);
|
||||
mrDevice.GetTextArray(rText, aArray.data(), nIndex, nLength);
|
||||
mrDevice.GetTextArray(rText, &aArray, nIndex, nLength);
|
||||
aRetval.assign(aArray.begin(), aArray.end());
|
||||
}
|
||||
|
||||
|
||||
@@ -286,8 +286,8 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D(
|
||||
sal_Int32 nPos = rTextCandidate.getTextPosition();
|
||||
sal_Int32 nLen = rTextCandidate.getTextLength();
|
||||
|
||||
tools::Long* pDXArray
|
||||
= !aTransformedDXArray.empty() ? aTransformedDXArray.data() : nullptr;
|
||||
std::vector<tools::Long>* pDXArray
|
||||
= !aTransformedDXArray.empty() ? &aTransformedDXArray : nullptr;
|
||||
|
||||
if (rTextCandidate.isFilled())
|
||||
{
|
||||
@@ -314,7 +314,8 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D(
|
||||
|
||||
if (!aTransformedDXArray.empty())
|
||||
{
|
||||
mpOutputDevice->DrawTextArray(aStartPoint, aText, pDXArray, nPos, nLen);
|
||||
mpOutputDevice->DrawTextArray(aStartPoint, aText,
|
||||
pDXArray ? pDXArray->data() : nullptr, nPos, nLen);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -753,7 +753,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
|
||||
|
||||
ImplInitLayoutMode(*GetRefDevice(), nPara, nIndex);
|
||||
|
||||
std::unique_ptr<tools::Long[]> pBuf(new tools::Long[ pNode->Len() ]);
|
||||
std::vector<tools::Long> aBuf( pNode->Len() );
|
||||
|
||||
bool bSameLineAgain = false; // For TextRanger, if the height changes.
|
||||
TabInfo aCurrentTab;
|
||||
@@ -1040,9 +1040,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
|
||||
const sal_Int32 nLength(aFieldValue.getLength());
|
||||
std::unique_ptr<tools::Long[]> pTmpDXArray(new tools::Long[nLength]);
|
||||
pPortion->GetSize() = aTmpFont.QuickGetTextSize(GetRefDevice(), aFieldValue, 0, aFieldValue.getLength(), pTmpDXArray.get());
|
||||
std::vector<tools::Long> aTmpDXArray;
|
||||
pPortion->GetSize() = aTmpFont.QuickGetTextSize(GetRefDevice(), aFieldValue, 0, aFieldValue.getLength(), &aTmpDXArray);
|
||||
|
||||
// So no scrolling for oversized fields
|
||||
if ( pPortion->GetSize().Width() > nXWidth )
|
||||
@@ -1086,7 +1085,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
|
||||
if(a == nNextCellBreak)
|
||||
{
|
||||
// check width
|
||||
if(pTmpDXArray[a] - nLineStartX > nXWidth)
|
||||
if(aTmpDXArray[a] - nLineStartX > nXWidth)
|
||||
{
|
||||
// new CellBreak does not fit in current line, need to
|
||||
// create a break at LastCellBreak - but do not add 1st
|
||||
@@ -1097,7 +1096,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
|
||||
}
|
||||
|
||||
// moveLineStart forward in X
|
||||
nLineStartX = pTmpDXArray[nLastCellBreak];
|
||||
nLineStartX = aTmpDXArray[nLastCellBreak];
|
||||
}
|
||||
|
||||
// update CellBreak iteration values
|
||||
@@ -1147,7 +1146,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
|
||||
if (bContinueLastPortion)
|
||||
{
|
||||
Size aSize( aTmpFont.QuickGetTextSize( GetRefDevice(),
|
||||
rParaPortion.GetNode()->GetString(), nTmpPos, nPortionLen, pBuf.get() ));
|
||||
rParaPortion.GetNode()->GetString(), nTmpPos, nPortionLen, &aBuf ));
|
||||
pPortion->GetSize().AdjustWidth(aSize.Width() );
|
||||
if (pPortion->GetSize().Height() < aSize.Height())
|
||||
pPortion->GetSize().setHeight( aSize.Height() );
|
||||
@@ -1155,7 +1154,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
|
||||
else
|
||||
{
|
||||
pPortion->GetSize() = aTmpFont.QuickGetTextSize( GetRefDevice(),
|
||||
rParaPortion.GetNode()->GetString(), nTmpPos, nPortionLen, pBuf.get() );
|
||||
rParaPortion.GetNode()->GetString(), nTmpPos, nPortionLen, &aBuf );
|
||||
}
|
||||
|
||||
// #i9050# Do Kerning also behind portions...
|
||||
@@ -1167,7 +1166,7 @@ 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, pBuf.get(), pBuf.get() + nPortionLen);
|
||||
rArray.insert( rArray.begin() + nPos, aBuf.data(), aBuf.data() + nPortionLen);
|
||||
|
||||
// And now check for Compression:
|
||||
if ( !bContinueLastPortion && nPortionLen && GetAsianCompressionMode() != CharCompressType::NONE )
|
||||
@@ -1650,8 +1649,6 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
|
||||
if ( bLineBreak )
|
||||
CreateAndInsertEmptyLine( &rParaPortion );
|
||||
|
||||
pBuf.reset();
|
||||
|
||||
bool bHeightChanged = FinishCreateLines( &rParaPortion );
|
||||
|
||||
if ( bMapChanged )
|
||||
@@ -3262,7 +3259,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
|
||||
sal_Int32 nTextStart = 0;
|
||||
sal_Int32 nTextLen = 0;
|
||||
const tools::Long* pDXArray = nullptr;
|
||||
std::unique_ptr<tools::Long[]> pTmpDXArray;
|
||||
std::vector<tools::Long> aTmpDXArray;
|
||||
|
||||
if ( rTextPortion.GetKind() == PortionKind::TEXT )
|
||||
{
|
||||
@@ -3392,10 +3389,9 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
|
||||
}
|
||||
}
|
||||
|
||||
pTmpDXArray.reset(new tools::Long[ aText.getLength() ]);
|
||||
pDXArray = pTmpDXArray.get();
|
||||
aTmpFont.SetPhysFont(*GetRefDevice());
|
||||
aTmpFont.QuickGetTextSize( GetRefDevice(), aText, nTextStart, nTextLen, pTmpDXArray.get() );
|
||||
aTmpFont.QuickGetTextSize( GetRefDevice(), aText, nTextStart, nTextLen, &aTmpDXArray );
|
||||
pDXArray = aTmpDXArray.data();
|
||||
|
||||
// add a meta file comment if we record to a metafile
|
||||
if( bMetafileValid )
|
||||
@@ -3419,10 +3415,9 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
|
||||
nTextLen = aText.getLength();
|
||||
|
||||
// crash when accessing 0 pointer in pDXArray
|
||||
pTmpDXArray.reset(new tools::Long[ aText.getLength() ]);
|
||||
pDXArray = pTmpDXArray.get();
|
||||
aTmpFont.SetPhysFont(*GetRefDevice());
|
||||
aTmpFont.QuickGetTextSize( GetRefDevice(), aText, 0, aText.getLength(), pTmpDXArray.get() );
|
||||
aTmpFont.QuickGetTextSize( GetRefDevice(), aText, 0, aText.getLength(), &aTmpDXArray );
|
||||
pDXArray = aTmpDXArray.data();
|
||||
}
|
||||
|
||||
tools::Long nTxtWidth = rTextPortion.GetSize().Width();
|
||||
@@ -3681,8 +3676,6 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
|
||||
|
||||
rOutDev.Pop();
|
||||
|
||||
pTmpDXArray.reset();
|
||||
|
||||
if ( rTextPortion.GetKind() == PortionKind::FIELD )
|
||||
{
|
||||
// add a meta file comment if we record to a metafile
|
||||
|
||||
@@ -452,7 +452,7 @@ Size SvxFont::GetPhysTxtSize( const OutputDevice *pOut )
|
||||
}
|
||||
|
||||
Size SvxFont::QuickGetTextSize( const OutputDevice *pOut, const OUString &rTxt,
|
||||
const sal_Int32 nIdx, const sal_Int32 nLen, tools::Long* pDXArray ) const
|
||||
const sal_Int32 nIdx, const sal_Int32 nLen, std::vector<tools::Long>* pDXArray ) const
|
||||
{
|
||||
if ( !IsCaseMap() && !IsKern() )
|
||||
return Size( pOut->GetTextArray( rTxt, pDXArray, nIdx, nLen ),
|
||||
@@ -473,9 +473,9 @@ Size SvxFont::QuickGetTextSize( const OutputDevice *pOut, const OUString &rTxt,
|
||||
if ( pDXArray )
|
||||
{
|
||||
for ( sal_Int32 i = 0; i < nLen; i++ )
|
||||
pDXArray[i] += ( (i+1) * tools::Long( nKern ) );
|
||||
(*pDXArray)[i] += ( (i+1) * tools::Long( nKern ) );
|
||||
// The last one is a nKern too big:
|
||||
pDXArray[nLen-1] -= nKern;
|
||||
(*pDXArray)[nLen-1] -= nKern;
|
||||
}
|
||||
}
|
||||
return aTxtSize;
|
||||
|
||||
@@ -975,8 +975,8 @@ void Outliner::PaintBullet(sal_Int32 nPara, const Point& rStartPos, const Point&
|
||||
if(bStrippingPortions)
|
||||
{
|
||||
const vcl::Font& aSvxFont(rOutDev.GetFont());
|
||||
std::unique_ptr<tools::Long[]> pBuf(new tools::Long[ pPara->GetText().getLength() ]);
|
||||
rOutDev.GetTextArray( pPara->GetText(), pBuf.get() );
|
||||
std::vector<tools::Long> aBuf;
|
||||
rOutDev.GetTextArray( pPara->GetText(), &aBuf );
|
||||
|
||||
if(bSymbol)
|
||||
{
|
||||
@@ -985,7 +985,7 @@ void Outliner::PaintBullet(sal_Int32 nPara, const Point& rStartPos, const Point&
|
||||
aTextPos.AdjustY( -(aMetric.GetDescent()) );
|
||||
}
|
||||
|
||||
DrawingText(aTextPos, pPara->GetText(), 0, pPara->GetText().getLength(), pBuf.get(),
|
||||
DrawingText(aTextPos, pPara->GetText(), 0, pPara->GetText().getLength(), aBuf.data(),
|
||||
aSvxFont, nPara, bRightToLeftPara ? 1 : 0, nullptr, nullptr, false, false, true, nullptr, Color(), Color());
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1869,6 +1869,7 @@ namespace emfio
|
||||
/* because text without dx array is badly scaled, we
|
||||
will create such an array if necessary */
|
||||
tools::Long* pDX = pDXArry;
|
||||
std::vector<tools::Long> aMyDXArray;
|
||||
if (pDXArry)
|
||||
{
|
||||
// only useful when we have an imported DXArray
|
||||
@@ -1885,14 +1886,12 @@ namespace emfio
|
||||
// #i117968# VirtualDevice is not thread safe, but filter is used in multithreading
|
||||
SolarMutexGuard aGuard;
|
||||
ScopedVclPtrInstance< VirtualDevice > pVDev;
|
||||
pDX = new tools::Long[ rText.getLength() ];
|
||||
pVDev->SetMapMode(MapMode(MapUnit::Map100thMM));
|
||||
pVDev->SetFont( maLatestFont );
|
||||
pVDev->GetTextArray( rText, pDX, 0, rText.getLength());
|
||||
pVDev->GetTextArray( rText, &aMyDXArray, 0, rText.getLength());
|
||||
pDX = aMyDXArray.data();
|
||||
}
|
||||
mpGDIMetaFile->AddAction( new MetaTextArrayAction( rPosition, rText, pDX, 0, rText.getLength() ) );
|
||||
if ( !pDXArry ) // this means we have created our own array
|
||||
delete[] pDX; // which must be deleted
|
||||
}
|
||||
}
|
||||
SetGfxMode( nOldGfxMode );
|
||||
|
||||
@@ -2644,18 +2644,18 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const OUString& rText,
|
||||
|
||||
ImplMap( rPos, aPos );
|
||||
|
||||
std::unique_ptr<tools::Long[]> xTmpArray(new tools::Long[nLen]);
|
||||
std::vector<tools::Long> aTmpArray(nLen);
|
||||
// get text sizes
|
||||
if( pDXArray )
|
||||
{
|
||||
aNormSize = Size( mpVDev->GetTextWidth( rText ), 0 );
|
||||
memcpy(xTmpArray.get(), pDXArray, nLen * sizeof(tools::Long));
|
||||
memcpy(aTmpArray.data(), pDXArray, nLen * sizeof(tools::Long));
|
||||
}
|
||||
else
|
||||
{
|
||||
aNormSize = Size( mpVDev->GetTextArray( rText, xTmpArray.get() ), 0 );
|
||||
aNormSize = Size( mpVDev->GetTextArray( rText, &aTmpArray ), 0 );
|
||||
}
|
||||
tools::Long* pDX = xTmpArray.get();
|
||||
tools::Long* pDX = aTmpArray.data();
|
||||
|
||||
// if text is rotated, set transform matrix at new g element
|
||||
if( rFont.GetOrientation() )
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
const sal_Int32 nIdx = 0, const sal_Int32 nLen = SAL_MAX_INT32, const tools::Long* pDXArray = nullptr ) const;
|
||||
|
||||
Size QuickGetTextSize( const OutputDevice *pOut, const OUString &rTxt,
|
||||
const sal_Int32 nIdx, const sal_Int32 nLen, tools::Long* pDXArray = nullptr ) const;
|
||||
const sal_Int32 nIdx, const sal_Int32 nLen, std::vector<tools::Long>* pDXArray = nullptr ) const;
|
||||
|
||||
void DrawPrev( OutputDevice* pOut, Printer* pPrinter,
|
||||
const Point &rPos, const OUString &rTxt,
|
||||
|
||||
@@ -1048,7 +1048,7 @@ public:
|
||||
sal_Int32 nLen = -1,
|
||||
SalLayoutFlags flags = SalLayoutFlags::NONE,
|
||||
const SalLayoutGlyphs* pLayoutCache = nullptr);
|
||||
tools::Long GetTextArray( const OUString& rStr, tools::Long* pDXAry,
|
||||
tools::Long GetTextArray( const OUString& rStr, std::vector<tools::Long>* pDXAry,
|
||||
sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
|
||||
vcl::text::TextLayoutCache const* = nullptr,
|
||||
SalLayoutGlyphs const*const pLayoutCache = nullptr) const;
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
|
||||
// methods using string indexing
|
||||
virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const = 0;
|
||||
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const = 0;
|
||||
virtual DeviceCoordinate FillDXArray( std::vector<DeviceCoordinate>* pDXArray ) const = 0;
|
||||
virtual DeviceCoordinate GetTextWidth() const { return FillDXArray( nullptr ); }
|
||||
virtual void GetCaretPositions( int nArraySize, tools::Long* pCaretXArray ) const = 0;
|
||||
virtual bool IsKashidaPosValid ( int /*nCharPos*/ ) const { return true; } // i60594
|
||||
|
||||
@@ -2103,7 +2103,7 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co
|
||||
if (aDX.size() < nLen)
|
||||
aDX.resize(nLen, 0);
|
||||
|
||||
pFmtDevice->GetTextArray(aShort, aDX.data());
|
||||
pFmtDevice->GetTextArray(aShort, &aDX);
|
||||
|
||||
if ( !mpRefDevice->GetConnectMetaFile() ||
|
||||
mpRefDevice->GetOutDevType() == OUTDEV_PRINTER )
|
||||
|
||||
@@ -487,12 +487,11 @@ awt::Rectangle SAL_CALL SmGraphicAccessible::getCharacterBounds( sal_Int32 nInde
|
||||
weld::DrawingArea* pDrawingArea = pWin->GetDrawingArea();
|
||||
OutputDevice& rDevice = pDrawingArea->get_ref_device();
|
||||
|
||||
std::unique_ptr<tools::Long[]> pXAry(new tools::Long[ aNodeText.getLength() ]);
|
||||
std::vector<tools::Long> aXAry;
|
||||
rDevice.SetFont( pNode->GetFont() );
|
||||
rDevice.GetTextArray( aNodeText, pXAry.get(), 0, aNodeText.getLength() );
|
||||
aTLPos.AdjustX(nNodeIndex > 0 ? pXAry[nNodeIndex - 1] : 0 );
|
||||
aSize.setWidth( nNodeIndex > 0 ? pXAry[nNodeIndex] - pXAry[nNodeIndex - 1] : pXAry[nNodeIndex] );
|
||||
pXAry.reset();
|
||||
rDevice.GetTextArray( aNodeText, &aXAry, 0, aNodeText.getLength() );
|
||||
aTLPos.AdjustX(nNodeIndex > 0 ? aXAry[nNodeIndex - 1] : 0 );
|
||||
aSize.setWidth( nNodeIndex > 0 ? aXAry[nNodeIndex] - aXAry[nNodeIndex - 1] : aXAry[nNodeIndex] );
|
||||
|
||||
aTLPos = rDevice.LogicToPixel( aTLPos );
|
||||
aSize = rDevice.LogicToPixel( aSize );
|
||||
@@ -560,15 +559,14 @@ sal_Int32 SAL_CALL SmGraphicAccessible::getIndexAtPoint( const awt::Point& aPoin
|
||||
|
||||
tools::Long nNodeX = pNode->GetLeft();
|
||||
|
||||
std::unique_ptr<tools::Long[]> pXAry(new tools::Long[ aTxt.getLength() ]);
|
||||
std::vector<tools::Long> aXAry;
|
||||
rDevice.SetFont( pNode->GetFont() );
|
||||
rDevice.GetTextArray( aTxt, pXAry.get(), 0, aTxt.getLength() );
|
||||
rDevice.GetTextArray( aTxt, &aXAry, 0, aTxt.getLength() );
|
||||
for (sal_Int32 i = 0; i < aTxt.getLength() && nRes == -1; ++i)
|
||||
{
|
||||
if (pXAry[i] + nNodeX > aPos.X())
|
||||
if (aXAry[i] + nNodeX > aPos.X())
|
||||
nRes = i;
|
||||
}
|
||||
pXAry.reset();
|
||||
OSL_ENSURE( nRes >= 0 && nRes < aTxt.getLength(), "index out of range" );
|
||||
OSL_ENSURE( pNode->GetAccessibleIndex() >= 0,
|
||||
"invalid accessible index" );
|
||||
|
||||
@@ -312,7 +312,6 @@ static void GetTextAreaOutline(
|
||||
|
||||
const SvxCharScaleWidthItem& rCharScaleWidthItem = rSdrObjCustomShape.GetMergedItem( EE_CHAR_FONTWIDTH );
|
||||
sal_uInt16 nCharScaleWidth = rCharScaleWidthItem.GetValue();
|
||||
std::unique_ptr<tools::Long[]> pDXArry;
|
||||
sal_Int32 nWidth = 0;
|
||||
|
||||
// VERTICAL
|
||||
@@ -326,7 +325,7 @@ static void GetTextAreaOutline(
|
||||
{
|
||||
FWCharacterData aCharacterData;
|
||||
OUString aCharText( rText[ i ] );
|
||||
if ( pVirDev->GetTextOutlines( aCharacterData.vOutlines, aCharText, 0, 0, -1, nWidth, pDXArry.get() ) )
|
||||
if ( pVirDev->GetTextOutlines( aCharacterData.vOutlines, aCharText, 0, 0, -1, nWidth, nullptr ) )
|
||||
{
|
||||
sal_Int32 nTextWidth = pVirDev->GetTextWidth( aCharText);
|
||||
if ( aCharacterData.vOutlines.empty() )
|
||||
@@ -363,16 +362,16 @@ static void GetTextAreaOutline(
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<tools::Long> aDXArry;
|
||||
if ( ( nCharScaleWidth != 100 ) && nCharScaleWidth )
|
||||
{ // applying character spacing
|
||||
pDXArry.reset(new tools::Long[ rText.getLength() ]);
|
||||
pVirDev->GetTextArray( rText, pDXArry.get());
|
||||
pVirDev->GetTextArray( rText, &aDXArry);
|
||||
FontMetric aFontMetric( pVirDev->GetFontMetric() );
|
||||
aFont.SetAverageFontWidth( static_cast<sal_Int32>( static_cast<double>(aFontMetric.GetAverageFontWidth()) * ( double(100) / static_cast<double>(nCharScaleWidth) ) ) );
|
||||
pVirDev->SetFont( aFont );
|
||||
}
|
||||
FWCharacterData aCharacterData;
|
||||
if ( pVirDev->GetTextOutlines( aCharacterData.vOutlines, rText, 0, 0, -1, nWidth, pDXArry.get() ) )
|
||||
if ( pVirDev->GetTextOutlines( aCharacterData.vOutlines, rText, 0, 0, -1, nWidth, aDXArry.empty() ? nullptr : aDXArry.data() ) )
|
||||
{
|
||||
rParagraph.vCharacters.push_back( aCharacterData );
|
||||
}
|
||||
|
||||
+109
-113
@@ -1018,13 +1018,13 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
const sal_uInt16 nGridWidth = GetGridWidth(*pGrid, *pDoc);
|
||||
|
||||
// kerning array - gives the absolute position of end of each character
|
||||
std::unique_ptr<tools::Long[]> pKernArray(new tools::Long[sal_Int32(rInf.GetLen())]);
|
||||
std::vector<tools::Long> aKernArray;
|
||||
|
||||
if ( m_pPrinter )
|
||||
m_pPrinter->GetTextArray( rInf.GetText(), pKernArray.get(),
|
||||
m_pPrinter->GetTextArray( rInf.GetText(), &aKernArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
else
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), &aKernArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
|
||||
// Change the average width per character to an appropriate grid width
|
||||
@@ -1032,7 +1032,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
// multiple this ratio to give the new avg width - which in this case
|
||||
// gives a new grid width unit size
|
||||
|
||||
tools::Long nAvgWidthPerChar = pKernArray[sal_Int32(rInf.GetLen()) - 1] / sal_Int32(rInf.GetLen());
|
||||
tools::Long nAvgWidthPerChar = aKernArray[sal_Int32(rInf.GetLen()) - 1] / sal_Int32(rInf.GetLen());
|
||||
|
||||
const sal_uLong nRatioAvgWidthCharToGridWidth = nAvgWidthPerChar ?
|
||||
( nAvgWidthPerChar - 1 ) / nGridWidth + 1:
|
||||
@@ -1041,7 +1041,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
nAvgWidthPerChar = nRatioAvgWidthCharToGridWidth * nGridWidth;
|
||||
|
||||
// the absolute end position of the first character is also its width
|
||||
tools::Long nCharWidth = pKernArray[ 0 ];
|
||||
tools::Long nCharWidth = aKernArray[ 0 ];
|
||||
sal_uLong nHalfWidth = nAvgWidthPerChar / 2;
|
||||
|
||||
tools::Long nNextFix=0;
|
||||
@@ -1076,7 +1076,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
// calculate offsets
|
||||
for (sal_Int32 j = 1; j < sal_Int32(rInf.GetLen()); ++j)
|
||||
{
|
||||
tools::Long nCurrentCharWidth = pKernArray[ j ] - pKernArray[ j - 1 ];
|
||||
tools::Long nCurrentCharWidth = aKernArray[ j ] - aKernArray[ j - 1 ];
|
||||
nNextFix += nAvgWidthPerChar;
|
||||
|
||||
// almost the same as getting the offset for the first character:
|
||||
@@ -1089,25 +1089,25 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
switch ( nType )
|
||||
{
|
||||
case SwScriptInfo::NONE :
|
||||
pKernArray[ j - 1 ] = nNextFix - ( nCurrentCharWidth / 2 );
|
||||
aKernArray[ j - 1 ] = nNextFix - ( nCurrentCharWidth / 2 );
|
||||
break;
|
||||
case SwScriptInfo::SPECIAL_RIGHT :
|
||||
pKernArray[ j - 1 ] = nNextFix - nHalfWidth;
|
||||
aKernArray[ j - 1 ] = nNextFix - nHalfWidth;
|
||||
break;
|
||||
default:
|
||||
pKernArray[ j - 1 ] = nNextFix + nHalfWidth - nCurrentCharWidth;
|
||||
aKernArray[ j - 1 ] = nNextFix + nHalfWidth - nCurrentCharWidth;
|
||||
}
|
||||
}
|
||||
|
||||
// the layout engine requires the total width of the output
|
||||
pKernArray[sal_Int32(rInf.GetLen()) - 1] = rInf.GetWidth() -
|
||||
aKernArray[sal_Int32(rInf.GetLen()) - 1] = rInf.GetWidth() -
|
||||
aTextOriginPos.X() + rInf.GetPos().X() ;
|
||||
|
||||
if ( bSwitchH2V )
|
||||
rInf.GetFrame()->SwitchHorizontalToVertical( aTextOriginPos );
|
||||
|
||||
rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
|
||||
pKernArray.get(), sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
aKernArray.data(), sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1125,13 +1125,13 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
{
|
||||
const tools::Long nGridWidthAdd = EvalGridWidthAdd( pGrid, rInf );
|
||||
|
||||
std::unique_ptr<tools::Long[]> pKernArray(new tools::Long[sal_Int32(rInf.GetLen())]);
|
||||
std::vector<tools::Long> aKernArray;
|
||||
|
||||
if ( m_pPrinter )
|
||||
m_pPrinter->GetTextArray( rInf.GetText(), pKernArray.get(),
|
||||
m_pPrinter->GetTextArray( rInf.GetText(), &aKernArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
else
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), &aKernArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
if ( bSwitchH2V )
|
||||
rInf.GetFrame()->SwitchHorizontalToVertical( aTextOriginPos );
|
||||
@@ -1148,7 +1148,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
pSI && pSI->CountCompChg() &&
|
||||
lcl_IsMonoSpaceFont( *(rInf.GetpOut()) ) )
|
||||
{
|
||||
pSI->Compress( pKernArray.get(), rInf.GetIdx(), rInf.GetLen(),
|
||||
pSI->Compress( aKernArray.data(), rInf.GetIdx(), rInf.GetLen(),
|
||||
rInf.GetKanaComp(), o3tl::narrowing<sal_uInt16>(m_aFont.GetFontSize().Height()), lcl_IsFullstopCentered( rInf.GetOut() ) , &aTextOriginPos );
|
||||
bSpecialJust = true;
|
||||
}
|
||||
@@ -1161,7 +1161,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
tools::Long nSpaceSum = nSpaceAdd;
|
||||
for (sal_Int32 nI = 0; nI < sal_Int32(rInf.GetLen()); ++nI)
|
||||
{
|
||||
pKernArray[ nI ] += nSpaceSum;
|
||||
aKernArray[ nI ] += nSpaceSum;
|
||||
nSpaceSum += nSpaceAdd;
|
||||
}
|
||||
bSpecialJust = true;
|
||||
@@ -1171,7 +1171,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
tools::Long nGridAddSum = nGridWidthAdd;
|
||||
for (sal_Int32 i = 0; i < sal_Int32(rInf.GetLen()); i++, nGridAddSum += nGridWidthAdd )
|
||||
{
|
||||
pKernArray[i] += nGridAddSum;
|
||||
aKernArray[i] += nGridAddSum;
|
||||
}
|
||||
tools::Long nKernSum = rInf.GetKern();
|
||||
if ( bSpecialJust || rInf.GetKern() )
|
||||
@@ -1180,7 +1180,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
{
|
||||
if (CH_BLANK == rInf.GetText()[sal_Int32(rInf.GetIdx())+i])
|
||||
nKernSum += nSpaceAdd;
|
||||
pKernArray[i] += nKernSum;
|
||||
aKernArray[i] += nKernSum;
|
||||
}
|
||||
///With through/uderstr. Grouped style requires a blank at the end
|
||||
///of a text edition special measures:
|
||||
@@ -1191,22 +1191,22 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
///we must spend two:
|
||||
if (TextFrameIndex(1) == rInf.GetLen())
|
||||
{
|
||||
pKernArray[0] = rInf.GetWidth() + nSpaceAdd;
|
||||
aKernArray[0] = rInf.GetWidth() + nSpaceAdd;
|
||||
rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
|
||||
pKernArray.get(), sal_Int32(rInf.GetIdx()), 1);
|
||||
aKernArray.data(), sal_Int32(rInf.GetIdx()), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
pKernArray[sal_Int32(rInf.GetLen()) - 2] += nSpaceAdd;
|
||||
aKernArray[sal_Int32(rInf.GetLen()) - 2] += nSpaceAdd;
|
||||
rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
|
||||
pKernArray.get(), sal_Int32(rInf.GetIdx()),
|
||||
aKernArray.data(), sal_Int32(rInf.GetIdx()),
|
||||
sal_Int32(rInf.GetLen()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
|
||||
pKernArray.get(), sal_Int32(rInf.GetIdx()),
|
||||
aKernArray.data(), sal_Int32(rInf.GetIdx()),
|
||||
sal_Int32(rInf.GetLen()));
|
||||
}
|
||||
}
|
||||
@@ -1219,11 +1219,11 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
if(CH_BLANK == rInf.GetText()[sal_Int32(rInf.GetIdx()) + i])
|
||||
nSpaceSum += nSpaceAdd + nKernSum;
|
||||
|
||||
pKernArray[i] += nSpaceSum;
|
||||
aKernArray[i] += nSpaceSum;
|
||||
}
|
||||
|
||||
rInf.GetOut().DrawTextArray(aTextOriginPos,
|
||||
rInf.GetText(), pKernArray.get(),
|
||||
rInf.GetText(), aKernArray.data(),
|
||||
sal_Int32(rInf.GetIdx()),
|
||||
sal_Int32(rInf.GetLen()));
|
||||
}
|
||||
@@ -1237,10 +1237,10 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
for (sal_Int32 i = 0; i < sal_Int32(rInf.GetLen());
|
||||
i++, nGridAddSum += nGridWidthAdd + nKernAdd)
|
||||
{
|
||||
pKernArray[i] += nGridAddSum;
|
||||
aKernArray[i] += nGridAddSum;
|
||||
}
|
||||
rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
|
||||
pKernArray.get(), sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
aKernArray.data(), sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1267,14 +1267,14 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
// Simple kerning is handled by DrawStretchText
|
||||
if( rInf.GetSpace() || rInf.GetKanaComp() )
|
||||
{
|
||||
std::unique_ptr<tools::Long[]> pKernArray(new tools::Long[sal_Int32(rInf.GetLen())]);
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
|
||||
std::vector<tools::Long> aKernArray;
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), &aKernArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
|
||||
if( bStretch )
|
||||
{
|
||||
sal_Int32 nZwi = sal_Int32(rInf.GetLen()) - 1;
|
||||
tools::Long nDiff = rInf.GetWidth() - pKernArray[ nZwi ]
|
||||
tools::Long nDiff = rInf.GetWidth() - aKernArray[ nZwi ]
|
||||
- sal_Int32(rInf.GetLen()) * rInf.GetKern();
|
||||
tools::Long nRest = nDiff % nZwi;
|
||||
tools::Long nAdd;
|
||||
@@ -1292,7 +1292,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
tools::Long nSum = nDiff;
|
||||
for( sal_Int32 i = 0; i < nZwi; )
|
||||
{
|
||||
pKernArray[ i ] += nSum;
|
||||
aKernArray[ i ] += nSum;
|
||||
if( ++i == nRest )
|
||||
nDiff += nAdd;
|
||||
nSum += nDiff;
|
||||
@@ -1314,7 +1314,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
pSI && pSI->CountCompChg() &&
|
||||
lcl_IsMonoSpaceFont( rInf.GetOut() ) )
|
||||
{
|
||||
pSI->Compress( pKernArray.get(), rInf.GetIdx(), rInf.GetLen(),
|
||||
pSI->Compress( aKernArray.data(), rInf.GetIdx(), rInf.GetLen(),
|
||||
rInf.GetKanaComp(),
|
||||
o3tl::narrowing<sal_uInt16>(m_aFont.GetFontSize().Height()), lcl_IsFullstopCentered( rInf.GetOut() ), &aTextOriginPos );
|
||||
bSpecialJust = true;
|
||||
@@ -1327,7 +1327,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
|
||||
if (!MsLangId::isKorean(aLang))
|
||||
{
|
||||
SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray.get(), nullptr,
|
||||
SwScriptInfo::CJKJustify( rInf.GetText(), aKernArray.data(), nullptr,
|
||||
rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd, rInf.IsSpaceStop() );
|
||||
|
||||
bSpecialJust = true;
|
||||
@@ -1341,7 +1341,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
if ( SwScriptInfo::IsArabicText( rInf.GetText(), rInf.GetIdx(), rInf.GetLen() ) )
|
||||
{
|
||||
if ( pSI && pSI->CountKashida() &&
|
||||
pSI->KashidaJustify( pKernArray.get(), nullptr, rInf.GetIdx(),
|
||||
pSI->KashidaJustify( aKernArray.data(), nullptr, rInf.GetIdx(),
|
||||
rInf.GetLen(), nSpaceAdd ) != -1 )
|
||||
{
|
||||
bSpecialJust = true;
|
||||
@@ -1359,7 +1359,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
{
|
||||
// Use rInf.GetSpace() because it has more precision than
|
||||
// nSpaceAdd:
|
||||
SwScriptInfo::ThaiJustify( rInf.GetText(), pKernArray.get(), nullptr,
|
||||
SwScriptInfo::ThaiJustify( rInf.GetText(), aKernArray.data(), nullptr,
|
||||
rInf.GetIdx(), rInf.GetLen(),
|
||||
rInf.GetNumberOfBlanks(),
|
||||
rInf.GetSpace() );
|
||||
@@ -1380,7 +1380,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
{
|
||||
if (CH_BLANK == rInf.GetText()[sal_Int32(rInf.GetIdx()) + i])
|
||||
nKernSum += nSpaceAdd;
|
||||
pKernArray[i] += nKernSum;
|
||||
aKernArray[i] += nKernSum;
|
||||
}
|
||||
|
||||
// In case of underlined/strike-through justified text
|
||||
@@ -1391,21 +1391,21 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
// If it is a single underlined space, output 2 spaces:
|
||||
if (TextFrameIndex(1) == rInf.GetLen())
|
||||
{
|
||||
pKernArray[0] = rInf.GetWidth() + nSpaceAdd;
|
||||
aKernArray[0] = rInf.GetWidth() + nSpaceAdd;
|
||||
|
||||
rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
|
||||
pKernArray.get(), sal_Int32(rInf.GetIdx()), 1 );
|
||||
aKernArray.data(), sal_Int32(rInf.GetIdx()), 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
pKernArray[ sal_Int32(rInf.GetLen()) - 2 ] += nSpaceAdd;
|
||||
aKernArray[ sal_Int32(rInf.GetLen()) - 2 ] += nSpaceAdd;
|
||||
rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
|
||||
pKernArray.get(), sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
aKernArray.data(), sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
}
|
||||
}
|
||||
else
|
||||
rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
|
||||
pKernArray.get(), sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
aKernArray.data(), sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1421,7 +1421,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
rInf.GetOut().DrawText( aTmpPos, rInf.GetText(),
|
||||
sal_Int32(rInf.GetIdx()) + j, i - j);
|
||||
j = i + 1;
|
||||
SwTwips nAdd = pKernArray[ i ] + nKernSum;
|
||||
SwTwips nAdd = aKernArray[ i ] + nKernSum;
|
||||
if ( ( ComplexTextLayoutFlags::BiDiStrong | ComplexTextLayoutFlags::BiDiRtl ) == nMode )
|
||||
nAdd *= -1;
|
||||
aTmpPos.setX( aTextOriginPos.X() + nAdd );
|
||||
@@ -1475,15 +1475,15 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
bool bBullet = rInf.GetBullet();
|
||||
if( m_bSymbol )
|
||||
bBullet = false;
|
||||
std::unique_ptr<tools::Long[]> pKernArray(new tools::Long[sal_Int32(rInf.GetLen())]);
|
||||
std::vector<tools::Long> aKernArray;
|
||||
CreateScrFont( *rInf.GetShell(), rInf.GetOut() );
|
||||
tools::Long nScrPos;
|
||||
|
||||
// get screen array
|
||||
std::unique_ptr<tools::Long[]> pScrArray(new tools::Long[sal_Int32(rInf.GetLen())]);
|
||||
std::vector<tools::Long> aScrArray;
|
||||
SwTextGlyphsKey aGlyphsKey{ &rInf.GetOut(), rInf.GetText(), sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()) };
|
||||
SalLayoutGlyphs* pGlyphs = GetCachedSalLayoutGlyphs(aGlyphsKey);
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), pScrArray.get(),
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), &aScrArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()), nullptr, pGlyphs);
|
||||
|
||||
// OLE: no printer available
|
||||
@@ -1498,12 +1498,12 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
}
|
||||
aGlyphsKey = SwTextGlyphsKey{ m_pPrinter, rInf.GetText(), sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()) };
|
||||
pGlyphs = GetCachedSalLayoutGlyphs(aGlyphsKey);
|
||||
m_pPrinter->GetTextArray(rInf.GetText(), pKernArray.get(),
|
||||
m_pPrinter->GetTextArray(rInf.GetText(), &aKernArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()), nullptr, pGlyphs);
|
||||
}
|
||||
else
|
||||
{
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), &aKernArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
}
|
||||
|
||||
@@ -1523,10 +1523,10 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
lcl_IsMonoSpaceFont( rInf.GetOut() ) )
|
||||
{
|
||||
Point aTmpPos( aTextOriginPos );
|
||||
pSI->Compress( pScrArray.get(), rInf.GetIdx(), rInf.GetLen(),
|
||||
pSI->Compress( aScrArray.data(), rInf.GetIdx(), rInf.GetLen(),
|
||||
rInf.GetKanaComp(),
|
||||
o3tl::narrowing<sal_uInt16>(m_aFont.GetFontSize().Height()), lcl_IsFullstopCentered( rInf.GetOut() ), &aTmpPos );
|
||||
pSI->Compress( pKernArray.get(), rInf.GetIdx(), rInf.GetLen(),
|
||||
pSI->Compress( aKernArray.data(), rInf.GetIdx(), rInf.GetLen(),
|
||||
rInf.GetKanaComp(),
|
||||
o3tl::narrowing<sal_uInt16>(m_aFont.GetFontSize().Height()), lcl_IsFullstopCentered( rInf.GetOut() ), &aTextOriginPos );
|
||||
}
|
||||
@@ -1538,7 +1538,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
|
||||
if (!MsLangId::isKorean(aLang))
|
||||
{
|
||||
SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray.get(), pScrArray.get(),
|
||||
SwScriptInfo::CJKJustify( rInf.GetText(), aKernArray.data(), aScrArray.data(),
|
||||
rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd, rInf.IsSpaceStop() );
|
||||
|
||||
nSpaceAdd = 0;
|
||||
@@ -1551,7 +1551,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
if ( SwScriptInfo::IsArabicText( rInf.GetText(), rInf.GetIdx(), rInf.GetLen() ) )
|
||||
{
|
||||
if ( pSI && pSI->CountKashida() &&
|
||||
pSI->KashidaJustify( pKernArray.get(), pScrArray.get(), rInf.GetIdx(),
|
||||
pSI->KashidaJustify( aKernArray.data(), aScrArray.data(), rInf.GetIdx(),
|
||||
rInf.GetLen(), nSpaceAdd ) != -1 )
|
||||
nSpaceAdd = 0;
|
||||
else
|
||||
@@ -1566,8 +1566,8 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
|
||||
if ( LANGUAGE_THAI == aLang )
|
||||
{
|
||||
SwScriptInfo::ThaiJustify( rInf.GetText(), pKernArray.get(),
|
||||
pScrArray.get(), rInf.GetIdx(),
|
||||
SwScriptInfo::ThaiJustify( rInf.GetText(), aKernArray.data(),
|
||||
aScrArray.data(), rInf.GetIdx(),
|
||||
rInf.GetLen(),
|
||||
rInf.GetNumberOfBlanks(),
|
||||
rInf.GetSpace() );
|
||||
@@ -1578,7 +1578,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
}
|
||||
}
|
||||
|
||||
nScrPos = pScrArray[ 0 ];
|
||||
nScrPos = aScrArray[ 0 ];
|
||||
|
||||
if( bBullet )
|
||||
{
|
||||
@@ -1605,7 +1605,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
* and don't bother with inserting a bullet in this case.
|
||||
*/
|
||||
if ((i + nCopyStart + 1 >= sal_Int32(rInf.GetLen())) ||
|
||||
pKernArray[i + nCopyStart] != pKernArray[ i + nCopyStart + 1])
|
||||
aKernArray[i + nCopyStart] != aKernArray[ i + nCopyStart + 1])
|
||||
{
|
||||
aBulletOverlay = aBulletOverlay.replaceAt(i, 1, OUString(CH_BULLET));
|
||||
}
|
||||
@@ -1633,7 +1633,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
// have to output 2 spaces:
|
||||
if ((nCnt == TextFrameIndex(1)) && rInf.GetSpace() && (cChPrev == CH_BLANK))
|
||||
{
|
||||
pKernArray[0] = rInf.GetWidth() +
|
||||
aKernArray[0] = rInf.GetWidth() +
|
||||
rInf.GetKern() +
|
||||
( rInf.GetSpace() / SPACING_PRECISION_FACTOR );
|
||||
|
||||
@@ -1644,9 +1644,9 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
rInf.GetFrame()->SwitchHorizontalToVertical( aTextOriginPos );
|
||||
|
||||
rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
|
||||
pKernArray.get(), sal_Int32(rInf.GetIdx()), 1 );
|
||||
aKernArray.data(), sal_Int32(rInf.GetIdx()), 1 );
|
||||
if( bBullet )
|
||||
rInf.GetOut().DrawTextArray( aTextOriginPos, *pStr, pKernArray.get(),
|
||||
rInf.GetOut().DrawTextArray( aTextOriginPos, *pStr, aKernArray.data(),
|
||||
rInf.GetIdx() ? 1 : 0, 1 );
|
||||
}
|
||||
else
|
||||
@@ -1678,9 +1678,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
{
|
||||
nCh = rInf.GetText()[sal_Int32(rInf.GetIdx()) + i];
|
||||
|
||||
OSL_ENSURE( pScrArray, "Where is the screen array?" );
|
||||
tools::Long nScr;
|
||||
nScr = pScrArray[ i ] - pScrArray[ i - 1 ];
|
||||
tools::Long nScr = aScrArray[ i ] - aScrArray[ i - 1 ];
|
||||
|
||||
// If there is an (ex-)Space before us, position optimally,
|
||||
// i.e., our right margin to the 100% printer position;
|
||||
@@ -1688,7 +1686,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
// printer position.
|
||||
if ( nCh == CH_BLANK )
|
||||
{
|
||||
nScrPos = pKernArray[i-1] + nScr;
|
||||
nScrPos = aKernArray[i-1] + nScr;
|
||||
|
||||
if ( cChPrev == CH_BLANK )
|
||||
nSpaceSum += nOtherHalf;
|
||||
@@ -1701,30 +1699,30 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
{
|
||||
if ( cChPrev == CH_BLANK )
|
||||
{
|
||||
nScrPos = pKernArray[i-1] + nScr;
|
||||
nScrPos = aKernArray[i-1] + nScr;
|
||||
// no Pixel is lost:
|
||||
nSpaceSum += nOtherHalf;
|
||||
}
|
||||
else if ( cChPrev == '-' )
|
||||
nScrPos = pKernArray[i-1] + nScr;
|
||||
nScrPos = aKernArray[i-1] + nScr;
|
||||
else
|
||||
{
|
||||
nScrPos += nScr;
|
||||
nScrPos = ( nMul * nScrPos + pKernArray[i] ) / nDiv;
|
||||
nScrPos = ( nMul * nScrPos + aKernArray[i] ) / nDiv;
|
||||
}
|
||||
}
|
||||
cChPrev = nCh;
|
||||
pKernArray[i-1] = nScrPos - nScr + nKernSum + nSpaceSum;
|
||||
aKernArray[i-1] = nScrPos - nScr + nKernSum + nSpaceSum;
|
||||
// In word line mode and for Arabic, we disabled the half space trick. If a portion
|
||||
// ends with a blank, the full nSpaceAdd value has been added to the character in
|
||||
// front of the blank. This leads to painting artifacts, therefore we remove the
|
||||
// nSpaceAdd value again:
|
||||
if ((bNoHalfSpace || m_pPrtFont->IsWordLineMode()) && i+1 == sal_Int32(nCnt) && nCh == CH_BLANK)
|
||||
pKernArray[i-1] = pKernArray[i-1] - nSpaceAdd;
|
||||
aKernArray[i-1] = aKernArray[i-1] - nSpaceAdd;
|
||||
}
|
||||
|
||||
// the layout engine requires the total width of the output
|
||||
pKernArray[sal_Int32(rInf.GetLen()) - 1] += nKernSum + nSpaceSum;
|
||||
aKernArray[sal_Int32(rInf.GetLen()) - 1] += nKernSum + nSpaceSum;
|
||||
|
||||
if( rInf.GetGreyWave() )
|
||||
{
|
||||
@@ -1743,7 +1741,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
rInf.GetOut().SetLineColor( gWaveCol );
|
||||
|
||||
Point aEnd;
|
||||
tools::Long nKernVal = pKernArray[sal_Int32(rInf.GetLen()) - 1];
|
||||
tools::Long nKernVal = aKernArray[sal_Int32(rInf.GetLen()) - 1];
|
||||
|
||||
const Degree10 nDir = bBidiPor
|
||||
? 1800_deg10
|
||||
@@ -1802,7 +1800,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
{
|
||||
CalcLinePosData aCalcLinePosData(rInf, GetFont(), nCnt, bSwitchH2V,
|
||||
bSwitchH2VLRBT, bSwitchL2R, nHalfSpace,
|
||||
pKernArray.get(), bBidiPor);
|
||||
aKernArray.data(), bBidiPor);
|
||||
|
||||
SwForbidden aForbidden;
|
||||
// draw line for smart tag data
|
||||
@@ -1837,7 +1835,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
: sal_Int32(rInf.GetIdx());
|
||||
aGlyphsKey = SwTextGlyphsKey{ &rInf.GetOut(), *pStr, nTmpIdx, nLen };
|
||||
pGlyphs = GetCachedSalLayoutGlyphs(aGlyphsKey);
|
||||
rInf.GetOut().DrawTextArray( aTextOriginPos, *pStr, pKernArray.get(),
|
||||
rInf.GetOut().DrawTextArray( aTextOriginPos, *pStr, aKernArray.data(),
|
||||
nTmpIdx , nLen, SalLayoutFlags::NONE, pGlyphs );
|
||||
if (bBullet)
|
||||
{
|
||||
@@ -1870,12 +1868,12 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
for( sal_Int32 i = 1 ; i < nLen ; ++i )
|
||||
{
|
||||
if ( aBulletOverlay[ i + nTmpIdx ] == CH_BULLET )
|
||||
pKernArray [ i - 1 ] += nShift ;
|
||||
aKernArray [ i - 1 ] += nShift ;
|
||||
if ( nAdd )
|
||||
pKernArray [ i - 1 ] -= nAdd;
|
||||
aKernArray [ i - 1 ] -= nAdd;
|
||||
}
|
||||
}
|
||||
rInf.GetOut().DrawTextArray( aTextOriginPos, aBulletOverlay, pKernArray.get(),
|
||||
rInf.GetOut().DrawTextArray( aTextOriginPos, aBulletOverlay, aKernArray.data(),
|
||||
nTmpIdx , nLen );
|
||||
pTmpFont->SetColor( aPreviousColor );
|
||||
|
||||
@@ -1992,29 +1990,29 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf )
|
||||
aTextSize.setWidth( m_pPrinter->GetTextWidth( rInf.GetText(),
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(nLn)));
|
||||
aTextSize.setHeight( m_pPrinter->GetTextHeight() );
|
||||
std::unique_ptr<tools::Long[]> pKernArray(new tools::Long[sal_Int32(nLn)]);
|
||||
std::vector<tools::Long> aKernArray;
|
||||
CreateScrFont( *rInf.GetShell(), rInf.GetOut() );
|
||||
if( !GetScrFont()->IsSameInstance( rInf.GetOut().GetFont() ) )
|
||||
rInf.GetOut().SetFont( *m_pScrFont );
|
||||
tools::Long nScrPos;
|
||||
|
||||
m_pPrinter->GetTextArray(rInf.GetText(), pKernArray.get(),
|
||||
m_pPrinter->GetTextArray(rInf.GetText(), &aKernArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(nLn));
|
||||
if( bCompress )
|
||||
rInf.SetKanaDiff( rInf.GetScriptInfo()->Compress( pKernArray.get(),
|
||||
rInf.SetKanaDiff( rInf.GetScriptInfo()->Compress( aKernArray.data(),
|
||||
rInf.GetIdx(), nLn, rInf.GetKanaComp(),
|
||||
o3tl::narrowing<sal_uInt16>(m_aFont.GetFontSize().Height()) ,lcl_IsFullstopCentered( rInf.GetOut() ) ) );
|
||||
else
|
||||
rInf.SetKanaDiff( 0 );
|
||||
|
||||
if ( rInf.GetKanaDiff() )
|
||||
nScrPos = pKernArray[ sal_Int32(nLn) - 1 ];
|
||||
nScrPos = aKernArray[ sal_Int32(nLn) - 1 ];
|
||||
else
|
||||
{
|
||||
std::unique_ptr<tools::Long[]> pScrArray(new tools::Long[sal_Int32(rInf.GetLen())]);
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), pScrArray.get(),
|
||||
std::vector<tools::Long> aScrArray;
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), &aScrArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
nScrPos = pScrArray[ 0 ];
|
||||
nScrPos = aScrArray[ 0 ];
|
||||
TextFrameIndex nCnt(rInf.GetText().getLength());
|
||||
if ( nCnt < rInf.GetIdx() )
|
||||
nCnt = TextFrameIndex(0); // assert???
|
||||
@@ -2032,26 +2030,24 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf )
|
||||
for (sal_Int32 i = 1; i < sal_Int32(nCnt); i++)
|
||||
{
|
||||
nCh = rInf.GetText()[ sal_Int32(rInf.GetIdx()) + i ];
|
||||
tools::Long nScr;
|
||||
nScr = pScrArray[ i ] - pScrArray[ i - 1 ];
|
||||
tools::Long nScr = aScrArray[ i ] - aScrArray[ i - 1 ];
|
||||
if ( nCh == CH_BLANK )
|
||||
nScrPos = pKernArray[i-1]+nScr;
|
||||
nScrPos = aKernArray[i-1]+nScr;
|
||||
else
|
||||
{
|
||||
if ( nChPrev == CH_BLANK || nChPrev == '-' )
|
||||
nScrPos = pKernArray[i-1]+nScr;
|
||||
nScrPos = aKernArray[i-1]+nScr;
|
||||
else
|
||||
{
|
||||
nScrPos += nScr;
|
||||
nScrPos = ( nMul * nScrPos + pKernArray[i] ) / nDiv;
|
||||
nScrPos = ( nMul * nScrPos + aKernArray[i] ) / nDiv;
|
||||
}
|
||||
}
|
||||
nChPrev = nCh;
|
||||
pKernArray[i-1] = nScrPos - nScr;
|
||||
aKernArray[i-1] = nScrPos - nScr;
|
||||
}
|
||||
}
|
||||
|
||||
pKernArray.reset();
|
||||
aTextSize.setWidth( nScrPos );
|
||||
}
|
||||
else
|
||||
@@ -2060,13 +2056,13 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf )
|
||||
rInf.GetOut().SetFont( *m_pPrtFont );
|
||||
if( bCompress )
|
||||
{
|
||||
std::unique_ptr<tools::Long[]> pKernArray( new tools::Long[sal_Int32(nLn)] );
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
|
||||
std::vector<tools::Long> aKernArray;
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), &aKernArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(nLn));
|
||||
rInf.SetKanaDiff( rInf.GetScriptInfo()->Compress( pKernArray.get(),
|
||||
rInf.SetKanaDiff( rInf.GetScriptInfo()->Compress( aKernArray.data(),
|
||||
rInf.GetIdx(), nLn, rInf.GetKanaComp(),
|
||||
o3tl::narrowing<sal_uInt16>(m_aFont.GetFontSize().Height()) ,lcl_IsFullstopCentered( rInf.GetOut() ) ) );
|
||||
aTextSize.setWidth( pKernArray[sal_Int32(nLn) - 1] );
|
||||
aTextSize.setWidth( aKernArray[sal_Int32(nLn) - 1] );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2097,7 +2093,7 @@ TextFrameIndex SwFntObj::GetModelPositionForViewPoint(SwDrawTextInfo &rInf)
|
||||
if( 0 != nSperren )
|
||||
nKern -= nSperren;
|
||||
|
||||
std::unique_ptr<tools::Long[]> pKernArray(new tools::Long[sal_Int32(rInf.GetLen())]);
|
||||
std::vector<tools::Long> aKernArray;
|
||||
|
||||
// be sure to have the correct layout mode at the printer
|
||||
if ( m_pPrinter )
|
||||
@@ -2106,11 +2102,11 @@ TextFrameIndex SwFntObj::GetModelPositionForViewPoint(SwDrawTextInfo &rInf)
|
||||
m_pPrinter->SetDigitLanguage( rInf.GetOut().GetDigitLanguage() );
|
||||
SwTextGlyphsKey aGlyphsKey{ m_pPrinter, rInf.GetText(), sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()) };
|
||||
SalLayoutGlyphs* pGlyphs = GetCachedSalLayoutGlyphs(aGlyphsKey);
|
||||
m_pPrinter->GetTextArray( rInf.GetText(), pKernArray.get(),
|
||||
m_pPrinter->GetTextArray( rInf.GetText(), &aKernArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()), nullptr, pGlyphs);
|
||||
}
|
||||
else
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), &aKernArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
|
||||
const SwScriptInfo* pSI = rInf.GetScriptInfo();
|
||||
@@ -2123,7 +2119,7 @@ TextFrameIndex SwFntObj::GetModelPositionForViewPoint(SwDrawTextInfo &rInf)
|
||||
pSI && pSI->CountCompChg() &&
|
||||
lcl_IsMonoSpaceFont( rInf.GetOut() ) )
|
||||
{
|
||||
pSI->Compress( pKernArray.get(), rInf.GetIdx(), rInf.GetLen(),
|
||||
pSI->Compress( aKernArray.data(), rInf.GetIdx(), rInf.GetLen(),
|
||||
rInf.GetKanaComp(),
|
||||
o3tl::narrowing<sal_uInt16>(m_aFont.GetFontSize().Height()),
|
||||
lcl_IsFullstopCentered( rInf.GetOut() ) );
|
||||
@@ -2136,7 +2132,7 @@ TextFrameIndex SwFntObj::GetModelPositionForViewPoint(SwDrawTextInfo &rInf)
|
||||
|
||||
if (!MsLangId::isKorean(aLang))
|
||||
{
|
||||
SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray.get(), nullptr,
|
||||
SwScriptInfo::CJKJustify( rInf.GetText(), aKernArray.data(), nullptr,
|
||||
rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd, rInf.IsSpaceStop() );
|
||||
|
||||
nSpaceAdd = 0;
|
||||
@@ -2150,7 +2146,7 @@ TextFrameIndex SwFntObj::GetModelPositionForViewPoint(SwDrawTextInfo &rInf)
|
||||
if ( SwScriptInfo::IsArabicText( rInf.GetText(), rInf.GetIdx(), rInf.GetLen() ) )
|
||||
{
|
||||
if ( pSI && pSI->CountKashida() &&
|
||||
pSI->KashidaJustify( pKernArray.get(), nullptr, rInf.GetIdx(), rInf.GetLen(),
|
||||
pSI->KashidaJustify( aKernArray.data(), nullptr, rInf.GetIdx(), rInf.GetLen(),
|
||||
nSpaceAdd ) != -1 )
|
||||
nSpaceAdd = 0;
|
||||
}
|
||||
@@ -2163,7 +2159,7 @@ TextFrameIndex SwFntObj::GetModelPositionForViewPoint(SwDrawTextInfo &rInf)
|
||||
|
||||
if ( LANGUAGE_THAI == aLang )
|
||||
{
|
||||
SwScriptInfo::ThaiJustify( rInf.GetText(), pKernArray.get(), nullptr,
|
||||
SwScriptInfo::ThaiJustify( rInf.GetText(), aKernArray.data(), nullptr,
|
||||
rInf.GetIdx(), rInf.GetLen(),
|
||||
rInf.GetNumberOfBlanks(),
|
||||
rInf.GetSpace() );
|
||||
@@ -2189,7 +2185,7 @@ TextFrameIndex SwFntObj::GetModelPositionForViewPoint(SwDrawTextInfo &rInf)
|
||||
const SwDoc* pDoc = rInf.GetShell()->GetDoc();
|
||||
const sal_uInt16 nGridWidth = GetGridWidth(*pGrid, *pDoc);
|
||||
|
||||
tools::Long nAvgWidthPerChar = pKernArray[sal_Int32(rInf.GetLen()) - 1] / sal_Int32(rInf.GetLen());
|
||||
tools::Long nAvgWidthPerChar = aKernArray[sal_Int32(rInf.GetLen()) - 1] / sal_Int32(rInf.GetLen());
|
||||
|
||||
sal_uLong i = nAvgWidthPerChar ?
|
||||
( nAvgWidthPerChar - 1 ) / nGridWidth + 1:
|
||||
@@ -2217,7 +2213,7 @@ TextFrameIndex SwFntObj::GetModelPositionForViewPoint(SwDrawTextInfo &rInf)
|
||||
|
||||
for (TextFrameIndex j(0); j < rInf.GetLen(); j++)
|
||||
{
|
||||
tools::Long nScr = pKernArray[sal_Int32(j)] + (nSpaceAdd + nGridWidthAdd) * (sal_Int32(j) + 1);
|
||||
tools::Long nScr = aKernArray[sal_Int32(j)] + (nSpaceAdd + nGridWidthAdd) * (sal_Int32(j) + 1);
|
||||
if( nScr >= rInf.GetOffset())
|
||||
{
|
||||
nCnt = j;
|
||||
@@ -2253,7 +2249,7 @@ TextFrameIndex SwFntObj::GetModelPositionForViewPoint(SwDrawTextInfo &rInf)
|
||||
break;
|
||||
|
||||
nLeft = nRight;
|
||||
nRight = pKernArray[sal_Int32(nIdx - rInf.GetIdx()) - 1] + nKernSum + nSpaceSum;
|
||||
nRight = aKernArray[sal_Int32(nIdx - rInf.GetIdx()) - 1] + nKernSum + nSpaceSum;
|
||||
|
||||
nKernSum += nKern;
|
||||
}
|
||||
@@ -2414,11 +2410,11 @@ TextFrameIndex SwFont::GetTextBreak(SwDrawTextInfo const & rInf, tools::Long nTe
|
||||
const SwDoc* pDoc = rInf.GetShell()->GetDoc();
|
||||
const sal_uInt16 nGridWidth = GetGridWidth(*pGrid, *pDoc);
|
||||
|
||||
std::unique_ptr<tools::Long[]> pKernArray(new tools::Long[sal_Int32(rInf.GetLen())]);
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
|
||||
std::vector<tools::Long> aKernArray;
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), &aKernArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
|
||||
tools::Long nAvgWidthPerChar = pKernArray[sal_Int32(rInf.GetLen()) - 1] / sal_Int32(rInf.GetLen());
|
||||
tools::Long nAvgWidthPerChar = aKernArray[sal_Int32(rInf.GetLen()) - 1] / sal_Int32(rInf.GetLen());
|
||||
|
||||
const sal_uLong i = nAvgWidthPerChar ?
|
||||
( nAvgWidthPerChar - 1 ) / nGridWidth + 1:
|
||||
@@ -2445,13 +2441,13 @@ TextFrameIndex SwFont::GetTextBreak(SwDrawTextInfo const & rInf, tools::Long nTe
|
||||
{
|
||||
const tools::Long nGridWidthAdd = EvalGridWidthAdd( pGrid, rInf );
|
||||
|
||||
std::unique_ptr<tools::Long[]> pKernArray(new tools::Long[sal_Int32(rInf.GetLen())] );
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
|
||||
std::vector<tools::Long> aKernArray;
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), &aKernArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(rInf.GetLen()));
|
||||
tools::Long nCurrPos = pKernArray[sal_Int32(nTextBreak)] + nGridWidthAdd;
|
||||
tools::Long nCurrPos = aKernArray[sal_Int32(nTextBreak)] + nGridWidthAdd;
|
||||
while (++nTextBreak < rInf.GetLen() && nTextWidth >= nCurrPos)
|
||||
{
|
||||
nCurrPos = pKernArray[sal_Int32(nTextBreak)] + nGridWidthAdd * (sal_Int32(nTextBreak) + 1);
|
||||
nCurrPos = aKernArray[sal_Int32(nTextBreak)] + nGridWidthAdd * (sal_Int32(nTextBreak) + 1);
|
||||
}
|
||||
return nTextBreak + rInf.GetIdx();
|
||||
}
|
||||
@@ -2560,10 +2556,10 @@ TextFrameIndex SwFont::GetTextBreak(SwDrawTextInfo const & rInf, tools::Long nTe
|
||||
nLn = TextFrameIndex(1);
|
||||
else if (nLn > nTextBreak2 + nTextBreak2)
|
||||
nLn = nTextBreak2 + nTextBreak2;
|
||||
std::unique_ptr<tools::Long[]> pKernArray( new tools::Long[sal_Int32(nLn)] );
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
|
||||
std::vector<tools::Long> aKernArray;
|
||||
rInf.GetOut().GetTextArray( rInf.GetText(), &aKernArray,
|
||||
sal_Int32(rInf.GetIdx()), sal_Int32(nLn));
|
||||
if( rInf.GetScriptInfo()->Compress( pKernArray.get(), rInf.GetIdx(), nLn,
|
||||
if( rInf.GetScriptInfo()->Compress( aKernArray.data(), rInf.GetIdx(), nLn,
|
||||
rInf.GetKanaComp(), o3tl::narrowing<sal_uInt16>(GetHeight( m_nActual )),
|
||||
lcl_IsFullstopCentered( rInf.GetOut() ) ) )
|
||||
{
|
||||
@@ -2571,7 +2567,7 @@ TextFrameIndex SwFont::GetTextBreak(SwDrawTextInfo const & rInf, tools::Long nTe
|
||||
TextFrameIndex const nTmpBreak = nTextBreak2;
|
||||
if( nKern && nTextBreak2 )
|
||||
nKern *= sal_Int32(nTextBreak2) - 1;
|
||||
while (nTextBreak2 < nLn && nTextWidth >= pKernArray[sal_Int32(nTextBreak2)] + nKern)
|
||||
while (nTextBreak2 < nLn && nTextWidth >= aKernArray[sal_Int32(nTextBreak2)] + nKern)
|
||||
{
|
||||
nKern += nKernAdd;
|
||||
++nTextBreak2;
|
||||
|
||||
@@ -156,12 +156,12 @@ sal_Int32 VCLXFont::getStringWidthArray( const OUString& str, css::uno::Sequence
|
||||
{
|
||||
vcl::Font aOldFont = pOutDev->GetFont();
|
||||
pOutDev->SetFont( maFont );
|
||||
std::unique_ptr<tools::Long []> pDXA(new tools::Long[str.getLength()]);
|
||||
nRet = pOutDev->GetTextArray( str, pDXA.get() );
|
||||
std::vector<tools::Long> aDXA;
|
||||
nRet = pOutDev->GetTextArray( str, &aDXA );
|
||||
rDXArray = css::uno::Sequence<sal_Int32>( str.getLength() );
|
||||
for(int i = 0; i < str.getLength(); i++)
|
||||
{
|
||||
rDXArray[i] = pDXA[i];
|
||||
rDXArray[i] = aDXA[i];
|
||||
}
|
||||
pOutDev->SetFont( aOldFont );
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ class MultiSalLayout final : public SalLayout
|
||||
public:
|
||||
void DrawText(SalGraphics&) const override;
|
||||
sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const override;
|
||||
DeviceCoordinate FillDXArray(DeviceCoordinate* pDXArray) const override;
|
||||
DeviceCoordinate FillDXArray(std::vector<DeviceCoordinate>* pDXArray) const override;
|
||||
void GetCaretPositions(int nArraySize, tools::Long* pCaretXArray) const override;
|
||||
bool GetNextGlyph(const GlyphItem** pGlyph, Point& rPos, int& nStart,
|
||||
const LogicalFontInstance** ppGlyphFont = nullptr,
|
||||
@@ -179,7 +179,7 @@ public:
|
||||
|
||||
// used by upper layers
|
||||
DeviceCoordinate GetTextWidth() const final override;
|
||||
DeviceCoordinate FillDXArray(DeviceCoordinate* pDXArray) const final override;
|
||||
DeviceCoordinate FillDXArray(std::vector<DeviceCoordinate>* pDXArray) const final override;
|
||||
sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const final override;
|
||||
void GetCaretPositions(int nArraySize, tools::Long* pCaretXArray) const final override;
|
||||
|
||||
@@ -206,7 +206,7 @@ private:
|
||||
void Justify(DeviceCoordinate nNewWidth);
|
||||
void ApplyAsianKerning(const OUString& rStr);
|
||||
|
||||
void GetCharWidths(DeviceCoordinate* pCharWidths) const;
|
||||
void GetCharWidths(std::vector<DeviceCoordinate>& rCharWidths) const;
|
||||
|
||||
void SetNeedFallback(ImplLayoutArgs&, sal_Int32, bool);
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ void VclComplexTextTest::testArabic()
|
||||
std::vector<tools::Long> aRefCharWidths {6, 9, 16, 16, 22, 22, 26, 29, 32, 32,
|
||||
36, 40, 49, 53, 56, 63, 63, 66, 72, 72};
|
||||
std::vector<tools::Long> aCharWidths(aOneTwoThree.getLength(), 0);
|
||||
tools::Long nTextWidth = pOutDev->GetTextArray(aOneTwoThree, aCharWidths.data());
|
||||
tools::Long nTextWidth = pOutDev->GetTextArray(aOneTwoThree, &aCharWidths);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths);
|
||||
// this sporadically returns 75 or 74 on some of the windows tinderboxes eg. tb73
|
||||
|
||||
@@ -755,9 +755,9 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
|
||||
{
|
||||
if (nAryLen+1 == nStrLen && nIndex >= 0)
|
||||
{
|
||||
std::unique_ptr<tools::Long[]> pTmpAry(new tools::Long[nStrLen]);
|
||||
std::vector<tools::Long> aTmpAry;
|
||||
|
||||
aFontVDev->GetTextArray( aStr, pTmpAry.get(), nIndex, nLen );
|
||||
aFontVDev->GetTextArray( aStr, &aTmpAry, nIndex, nLen );
|
||||
|
||||
// now, the difference between the
|
||||
// last and the second last DX array
|
||||
@@ -767,9 +767,9 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
|
||||
// difference to last elem and store
|
||||
// in very last.
|
||||
if( nStrLen > 1 )
|
||||
pDXAry[ nStrLen-1 ] = pDXAry[ nStrLen-2 ] + pTmpAry[ nStrLen-1 ] - pTmpAry[ nStrLen-2 ];
|
||||
pDXAry[ nStrLen-1 ] = pDXAry[ nStrLen-2 ] + aTmpAry[ nStrLen-1 ] - aTmpAry[ nStrLen-2 ];
|
||||
else
|
||||
pDXAry[ nStrLen-1 ] = pTmpAry[ nStrLen-1 ]; // len=1: 0th position taken to be 0
|
||||
pDXAry[ nStrLen-1 ] = aTmpAry[ nStrLen-1 ]; // len=1: 0th position taken to be 0
|
||||
}
|
||||
#ifdef DBG_UTIL
|
||||
else
|
||||
|
||||
@@ -869,7 +869,7 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, c
|
||||
return;
|
||||
|
||||
sal_uInt32 nNormWidth;
|
||||
std::unique_ptr<tools::Long[]> pOwnArray;
|
||||
std::vector<tools::Long> aOwnArray;
|
||||
tools::Long* pDX;
|
||||
|
||||
// get text sizes
|
||||
@@ -880,9 +880,8 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, c
|
||||
}
|
||||
else
|
||||
{
|
||||
pOwnArray.reset(new tools::Long[ nLen ]);
|
||||
nNormWidth = maVDev->GetTextArray( rText, pOwnArray.get() );
|
||||
pDX = pOwnArray.get();
|
||||
nNormWidth = maVDev->GetTextArray( rText, &aOwnArray );
|
||||
pDX = aOwnArray.data();
|
||||
}
|
||||
|
||||
if( nLen > 1 )
|
||||
|
||||
@@ -1197,8 +1197,8 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF )
|
||||
|
||||
pVirDev->SetFont( aSrcFont );
|
||||
const sal_Int32 nLen = aTemp.getLength();
|
||||
std::unique_ptr<tools::Long[]> pDXAry(nLen ? new tools::Long[ nLen ] : nullptr);
|
||||
const sal_Int32 nNormSize = pVirDev->GetTextArray( aTemp, pDXAry.get() );
|
||||
std::vector<tools::Long> aDXAry;
|
||||
const sal_Int32 nNormSize = pVirDev->GetTextArray( aTemp, nLen ? &aDXAry : nullptr );
|
||||
if (nLen && nNormSize == 0)
|
||||
{
|
||||
OSL_FAIL("Impossible div by 0 action: MetaStretchTextAction!");
|
||||
@@ -1206,13 +1206,13 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF )
|
||||
else
|
||||
{
|
||||
for ( sal_Int32 i = 0; i < ( nLen - 1 ); i++ )
|
||||
pDXAry[ i ] = pDXAry[ i ] * static_cast<sal_Int32>(pA->GetWidth()) / nNormSize;
|
||||
aDXAry[ i ] = aDXAry[ i ] * static_cast<sal_Int32>(pA->GetWidth()) / nNormSize;
|
||||
if ( ( nLen <= 1 ) || ( static_cast<sal_Int32>(pA->GetWidth()) == nNormSize ) )
|
||||
pDXAry.reset();
|
||||
aDXAry.clear();
|
||||
aSrcLineInfo = LineInfo();
|
||||
SetAllAttr();
|
||||
if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, pDXAry.get() ) )
|
||||
WMFRecord_ExtTextOut( pA->GetPoint(), aTemp, pDXAry.get() );
|
||||
if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, aDXAry.empty() ? nullptr : aDXAry.data() ) )
|
||||
WMFRecord_ExtTextOut( pA->GetPoint(), aTemp, aDXAry.empty() ? nullptr : aDXAry.data() );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -600,19 +600,19 @@ bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs, const SalLayoutGlyphsIm
|
||||
return true;
|
||||
}
|
||||
|
||||
void GenericSalLayout::GetCharWidths(DeviceCoordinate* pCharWidths) const
|
||||
void GenericSalLayout::GetCharWidths(std::vector<DeviceCoordinate>& rCharWidths) const
|
||||
{
|
||||
const int nCharCount = mnEndCharPos - mnMinCharPos;
|
||||
|
||||
for (int i = 0; i < nCharCount; ++i)
|
||||
pCharWidths[i] = 0;
|
||||
rCharWidths.clear();
|
||||
rCharWidths.resize(nCharCount, 0);
|
||||
|
||||
for (auto const& aGlyphItem : m_GlyphItems)
|
||||
{
|
||||
const int nIndex = aGlyphItem.charPos() - mnMinCharPos;
|
||||
if (nIndex >= nCharCount)
|
||||
continue;
|
||||
pCharWidths[nIndex] += aGlyphItem.m_nNewWidth;
|
||||
rCharWidths[nIndex] += aGlyphItem.m_nNewWidth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -636,11 +636,11 @@ void GenericSalLayout::GetCharWidths(DeviceCoordinate* pCharWidths) const
|
||||
void GenericSalLayout::ApplyDXArray(const DeviceCoordinate* pDXArray, SalLayoutFlags nLayoutFlags)
|
||||
{
|
||||
int nCharCount = mnEndCharPos - mnMinCharPos;
|
||||
std::unique_ptr<DeviceCoordinate[]> const pOldCharWidths(new DeviceCoordinate[nCharCount]);
|
||||
std::vector<DeviceCoordinate> aOldCharWidths;
|
||||
std::unique_ptr<DeviceCoordinate[]> const pNewCharWidths(new DeviceCoordinate[nCharCount]);
|
||||
|
||||
// Get the natural character widths (i.e. before applying DX adjustments).
|
||||
GetCharWidths(pOldCharWidths.get());
|
||||
GetCharWidths(aOldCharWidths);
|
||||
|
||||
// Calculate the character widths after DX adjustments.
|
||||
for (int i = 0; i < nCharCount; ++i)
|
||||
@@ -679,7 +679,7 @@ void GenericSalLayout::ApplyDXArray(const DeviceCoordinate* pDXArray, SalLayoutF
|
||||
int nCharPos = m_GlyphItems[i].charPos() - mnMinCharPos;
|
||||
DeviceCoordinate nDiff = 0;
|
||||
for (int j = 0; j < m_GlyphItems[i].charCount(); j++)
|
||||
nDiff += pNewCharWidths[nCharPos + j] - pOldCharWidths[nCharPos + j];
|
||||
nDiff += pNewCharWidths[nCharPos + j] - aOldCharWidths[nCharPos + j];
|
||||
|
||||
if (!m_GlyphItems[i].IsRTLGlyph())
|
||||
{
|
||||
|
||||
@@ -669,10 +669,10 @@ SalLayoutGlyphs SalLayout::GetGlyphs() const
|
||||
return SalLayoutGlyphs(); // invalid
|
||||
}
|
||||
|
||||
DeviceCoordinate GenericSalLayout::FillDXArray( DeviceCoordinate* pCharWidths ) const
|
||||
DeviceCoordinate GenericSalLayout::FillDXArray( std::vector<DeviceCoordinate>* pCharWidths ) const
|
||||
{
|
||||
if (pCharWidths)
|
||||
GetCharWidths(pCharWidths);
|
||||
GetCharWidths(*pCharWidths);
|
||||
|
||||
return GetTextWidth();
|
||||
}
|
||||
@@ -899,14 +899,13 @@ void GenericSalLayout::GetCaretPositions( int nMaxIndex, tools::Long* pCaretXArr
|
||||
|
||||
sal_Int32 GenericSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor ) const
|
||||
{
|
||||
int nCharCapacity = mnEndCharPos - mnMinCharPos;
|
||||
std::unique_ptr<DeviceCoordinate[]> const pCharWidths(new DeviceCoordinate[nCharCapacity]);
|
||||
GetCharWidths(pCharWidths.get());
|
||||
std::vector<DeviceCoordinate> aCharWidths;
|
||||
GetCharWidths(aCharWidths);
|
||||
|
||||
DeviceCoordinate nWidth = 0;
|
||||
for( int i = mnMinCharPos; i < mnEndCharPos; ++i )
|
||||
{
|
||||
nWidth += pCharWidths[ i - mnMinCharPos ] * nFactor;
|
||||
nWidth += aCharWidths[ i - mnMinCharPos ] * nFactor;
|
||||
if( nWidth > nMaxWidth )
|
||||
return i;
|
||||
nWidth += nCharExtra;
|
||||
@@ -1061,7 +1060,7 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs )
|
||||
{
|
||||
SalLayout::AdjustLayout( rArgs );
|
||||
ImplLayoutArgs aMultiArgs = rArgs;
|
||||
std::unique_ptr<DeviceCoordinate[]> pJustificationArray;
|
||||
std::vector<DeviceCoordinate> aJustificationArray;
|
||||
|
||||
if( !rArgs.mpDXArray && rArgs.mnLayoutWidth )
|
||||
{
|
||||
@@ -1076,8 +1075,7 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs )
|
||||
mpLayouts[n]->SalLayout::AdjustLayout( aMultiArgs );
|
||||
// then we can measure the unmodified metrics
|
||||
int nCharCount = rArgs.mnEndCharPos - rArgs.mnMinCharPos;
|
||||
pJustificationArray.reset(new DeviceCoordinate[nCharCount]);
|
||||
FillDXArray( pJustificationArray.get() );
|
||||
FillDXArray( &aJustificationArray );
|
||||
// #i17359# multilayout is not simplified yet, so calculating the
|
||||
// unjustified width needs handholding; also count the number of
|
||||
// stretchable virtual char widths
|
||||
@@ -1086,8 +1084,8 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs )
|
||||
for( int i = 0; i < nCharCount; ++i )
|
||||
{
|
||||
// convert array from widths to sum of widths
|
||||
nOrigWidth += pJustificationArray[i];
|
||||
if( pJustificationArray[i] > 0 )
|
||||
nOrigWidth += aJustificationArray[i];
|
||||
if( aJustificationArray[i] > 0 )
|
||||
++nStretchable;
|
||||
}
|
||||
|
||||
@@ -1098,7 +1096,7 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs )
|
||||
DeviceCoordinate nWidthSum = 0;
|
||||
for( int i = 0; i < nCharCount; ++i )
|
||||
{
|
||||
DeviceCoordinate nJustWidth = pJustificationArray[i];
|
||||
DeviceCoordinate nJustWidth = aJustificationArray[i];
|
||||
if( (nJustWidth > 0) && (nStretchable > 0) )
|
||||
{
|
||||
DeviceCoordinate nDeltaWidth = nDiffWidth / nStretchable;
|
||||
@@ -1107,10 +1105,10 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs )
|
||||
--nStretchable;
|
||||
}
|
||||
nWidthSum += nJustWidth;
|
||||
pJustificationArray[i] = nWidthSum;
|
||||
aJustificationArray[i] = nWidthSum;
|
||||
}
|
||||
if( nWidthSum != nTargetWidth )
|
||||
pJustificationArray[ nCharCount-1 ] = nTargetWidth;
|
||||
aJustificationArray[ nCharCount-1 ] = nTargetWidth;
|
||||
|
||||
// the justification array is still in base level units
|
||||
// => convert it to pixel units
|
||||
@@ -1118,14 +1116,14 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs )
|
||||
{
|
||||
for( int i = 0; i < nCharCount; ++i )
|
||||
{
|
||||
DeviceCoordinate nVal = pJustificationArray[ i ];
|
||||
DeviceCoordinate nVal = aJustificationArray[ i ];
|
||||
nVal += (mnUnitsPerPixel + 1) / 2;
|
||||
pJustificationArray[ i ] = nVal / mnUnitsPerPixel;
|
||||
aJustificationArray[ i ] = nVal / mnUnitsPerPixel;
|
||||
}
|
||||
}
|
||||
|
||||
// change the mpDXArray temporarily (just for the justification)
|
||||
aMultiArgs.mpDXArray = pJustificationArray.get();
|
||||
aMultiArgs.mpDXArray = aJustificationArray.data();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1429,23 +1427,23 @@ sal_Int32 MultiSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordi
|
||||
return mpLayouts[0]->GetTextBreak( nMaxWidth, nCharExtra, nFactor );
|
||||
|
||||
int nCharCount = mnEndCharPos - mnMinCharPos;
|
||||
std::unique_ptr<DeviceCoordinate[]> const pCharWidths(new DeviceCoordinate[nCharCount]);
|
||||
std::unique_ptr<DeviceCoordinate[]> const pFallbackCharWidths(new DeviceCoordinate[nCharCount]);
|
||||
mpLayouts[0]->FillDXArray( pCharWidths.get() );
|
||||
std::vector<DeviceCoordinate> aCharWidths;
|
||||
std::vector<DeviceCoordinate> aFallbackCharWidths;
|
||||
mpLayouts[0]->FillDXArray( &aCharWidths );
|
||||
|
||||
for( int n = 1; n < mnLevel; ++n )
|
||||
{
|
||||
SalLayout& rLayout = *mpLayouts[ n ];
|
||||
rLayout.FillDXArray( pFallbackCharWidths.get() );
|
||||
rLayout.FillDXArray( &aFallbackCharWidths );
|
||||
double fUnitMul = mnUnitsPerPixel;
|
||||
fUnitMul /= rLayout.GetUnitsPerPixel();
|
||||
for( int i = 0; i < nCharCount; ++i )
|
||||
{
|
||||
if( pCharWidths[ i ] == 0 )
|
||||
if( aCharWidths[ i ] == 0 )
|
||||
{
|
||||
DeviceCoordinate w = pFallbackCharWidths[i];
|
||||
DeviceCoordinate w = aFallbackCharWidths[i];
|
||||
w = static_cast<DeviceCoordinate>(w * fUnitMul + 0.5);
|
||||
pCharWidths[ i ] = w;
|
||||
aCharWidths[ i ] = w;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1453,7 +1451,7 @@ sal_Int32 MultiSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordi
|
||||
DeviceCoordinate nWidth = 0;
|
||||
for( int i = 0; i < nCharCount; ++i )
|
||||
{
|
||||
nWidth += pCharWidths[ i ] * nFactor;
|
||||
nWidth += aCharWidths[ i ] * nFactor;
|
||||
if( nWidth > nMaxWidth )
|
||||
return (i + mnMinCharPos);
|
||||
nWidth += nCharExtra;
|
||||
@@ -1462,24 +1460,23 @@ sal_Int32 MultiSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordi
|
||||
return -1;
|
||||
}
|
||||
|
||||
DeviceCoordinate MultiSalLayout::FillDXArray( DeviceCoordinate* pCharWidths ) const
|
||||
DeviceCoordinate MultiSalLayout::FillDXArray( std::vector<DeviceCoordinate>* pCharWidths ) const
|
||||
{
|
||||
DeviceCoordinate nMaxWidth = 0;
|
||||
|
||||
// prepare merging of fallback levels
|
||||
std::unique_ptr<DeviceCoordinate[]> pTempWidths;
|
||||
std::vector<DeviceCoordinate> aTempWidths;
|
||||
const int nCharCount = mnEndCharPos - mnMinCharPos;
|
||||
if( pCharWidths )
|
||||
{
|
||||
for( int i = 0; i < nCharCount; ++i )
|
||||
pCharWidths[i] = 0;
|
||||
pTempWidths.reset(new DeviceCoordinate[nCharCount]);
|
||||
pCharWidths->clear();
|
||||
pCharWidths->resize(nCharCount, 0);
|
||||
}
|
||||
|
||||
for( int n = mnLevel; --n >= 0; )
|
||||
{
|
||||
// query every fallback level
|
||||
DeviceCoordinate nTextWidth = mpLayouts[n]->FillDXArray( pTempWidths.get() );
|
||||
DeviceCoordinate nTextWidth = mpLayouts[n]->FillDXArray( &aTempWidths );
|
||||
if( !nTextWidth )
|
||||
continue;
|
||||
// merge results from current level
|
||||
@@ -1495,13 +1492,13 @@ DeviceCoordinate MultiSalLayout::FillDXArray( DeviceCoordinate* pCharWidths ) co
|
||||
{
|
||||
// #i17359# restriction:
|
||||
// one char cannot be resolved from different fallbacks
|
||||
if( pCharWidths[i] != 0 )
|
||||
if( (*pCharWidths)[i] != 0 )
|
||||
continue;
|
||||
DeviceCoordinate nCharWidth = pTempWidths[i];
|
||||
DeviceCoordinate nCharWidth = aTempWidths[i];
|
||||
if( !nCharWidth )
|
||||
continue;
|
||||
nCharWidth = static_cast<DeviceCoordinate>(nCharWidth * fUnitMul + 0.5);
|
||||
pCharWidths[i] = nCharWidth;
|
||||
(*pCharWidths)[i] = nCharWidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace vcl
|
||||
tools::Rectangle GetTextRect( const tools::Rectangle& _rRect, const OUString& _rText, DrawTextFlags _nStyle, Size* o_pDeviceSize );
|
||||
|
||||
private:
|
||||
tools::Long GetTextArray( const OUString& _rText, tools::Long* _pDXAry, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const;
|
||||
tools::Long GetTextArray( const OUString& _rText, std::vector<tools::Long>* _pDXAry, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const;
|
||||
|
||||
OutputDevice& m_rTargetDevice;
|
||||
OutputDevice& m_rReferenceDevice;
|
||||
@@ -159,7 +159,7 @@ namespace vcl
|
||||
}
|
||||
}
|
||||
|
||||
tools::Long ReferenceDeviceTextLayout::GetTextArray( const OUString& _rText, tools::Long* _pDXAry, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const
|
||||
tools::Long ReferenceDeviceTextLayout::GetTextArray( const OUString& _rText, std::vector<tools::Long>* _pDXAry, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const
|
||||
{
|
||||
if ( !lcl_normalizeLength( _rText, _nStartIndex, _nLength ) )
|
||||
return 0;
|
||||
@@ -207,10 +207,9 @@ namespace vcl
|
||||
return;
|
||||
}
|
||||
|
||||
std::unique_ptr<tools::Long[]> pCharWidths(new tools::Long[ _nLength ]);
|
||||
tools::Long nTextWidth = GetTextArray( _rText, pCharWidths.get(), _nStartIndex, _nLength );
|
||||
m_rTargetDevice.DrawTextArray( _rStartPoint, _rText, pCharWidths.get(), _nStartIndex, _nLength );
|
||||
pCharWidths.reset();
|
||||
std::vector<tools::Long> aCharWidths;
|
||||
tools::Long nTextWidth = GetTextArray( _rText, &aCharWidths, _nStartIndex, _nLength );
|
||||
m_rTargetDevice.DrawTextArray( _rStartPoint, _rText, aCharWidths.data(), _nStartIndex, _nLength );
|
||||
|
||||
m_aCompleteTextRect.Union( tools::Rectangle( _rStartPoint, Size( nTextWidth, m_rTargetDevice.GetTextHeight() ) ) );
|
||||
}
|
||||
|
||||
@@ -906,7 +906,7 @@ void OutputDevice::DrawTextArray( const Point& rStartPt, const OUString& rStr,
|
||||
mpAlphaVDev->DrawTextArray( rStartPt, rStr, pDXAry, nIndex, nLen, flags );
|
||||
}
|
||||
|
||||
tools::Long OutputDevice::GetTextArray( const OUString& rStr, tools::Long* pDXAry,
|
||||
tools::Long OutputDevice::GetTextArray( const OUString& rStr, std::vector<tools::Long>* pDXAry,
|
||||
sal_Int32 nIndex, sal_Int32 nLen,
|
||||
vcl::text::TextLayoutCache const*const pLayoutCache,
|
||||
SalLayoutGlyphs const*const pSalLayoutCache) const
|
||||
@@ -931,9 +931,7 @@ tools::Long OutputDevice::GetTextArray( const OUString& rStr, tools::Long* pDXAr
|
||||
// element init in the happy case will still be found by tools,
|
||||
// and hope that is sufficient.
|
||||
if (pDXAry)
|
||||
{
|
||||
memset(pDXAry, 0, nLen * sizeof(*pDXAry));
|
||||
}
|
||||
std::fill(pDXAry->begin(), pDXAry->end(), 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -993,14 +991,14 @@ tools::Long OutputDevice::GetTextArray( const OUString& rStr, tools::Long* pDXAr
|
||||
// convert virtual char widths to virtual absolute positions
|
||||
if( pDXAry )
|
||||
for( int i = 1; i < nLen; ++i )
|
||||
pDXAry[ i ] += pDXAry[ i-1 ];
|
||||
(*pDXAry)[ i ] += (*pDXAry)[ i-1 ];
|
||||
|
||||
// convert from font units to logical units
|
||||
if( mbMap )
|
||||
{
|
||||
if( pDXAry )
|
||||
for( int i = 0; i < nLen; ++i )
|
||||
pDXAry[i] = ImplDevicePixelToLogicWidth( pDXAry[i] );
|
||||
(*pDXAry)[i] = ImplDevicePixelToLogicWidth( (*pDXAry)[i] );
|
||||
nWidth = ImplDevicePixelToLogicWidth( nWidth );
|
||||
}
|
||||
|
||||
@@ -1008,7 +1006,7 @@ tools::Long OutputDevice::GetTextArray( const OUString& rStr, tools::Long* pDXAr
|
||||
{
|
||||
if( pDXAry )
|
||||
for( int i = 0; i < nLen; ++i )
|
||||
pDXAry[i] /= nWidthFactor;
|
||||
(*pDXAry)[i] /= nWidthFactor;
|
||||
nWidth /= nWidthFactor;
|
||||
}
|
||||
return nWidth;
|
||||
|
||||
@@ -630,14 +630,14 @@ public:
|
||||
}
|
||||
|
||||
// DX array rendering
|
||||
std::unique_ptr<tools::Long[]> pItems(new tools::Long[aText.getLength()+10]);
|
||||
rDev.GetTextArray(aText, pItems.get());
|
||||
std::vector<tools::Long> aItems;
|
||||
rDev.GetTextArray(aText, &aItems);
|
||||
for (tools::Long j = 0; j < aText.getLength(); ++j)
|
||||
{
|
||||
Point aTop = aTextRect.TopLeft();
|
||||
Point aBottom = aTop;
|
||||
aTop.Move(pItems[j], 0);
|
||||
aBottom.Move(pItems[j], aTextRect.GetHeight());
|
||||
aTop.Move(aItems[j], 0);
|
||||
aBottom.Move(aItems[j], aTextRect.GetHeight());
|
||||
rDev.SetLineColor(COL_RED);
|
||||
rDev.SetRasterOp(RasterOp::Xor);
|
||||
rDev.DrawLine(aTop,aBottom);
|
||||
|
||||
Reference in New Issue
Block a user