summaryrefslogtreecommitdiff
path: root/vcl/source/outdev/text.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/outdev/text.cxx')
-rw-r--r--vcl/source/outdev/text.cxx28
1 files changed, 15 insertions, 13 deletions
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index ceffc84fbbe9..f0a248ddae31 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -23,7 +23,6 @@
#include <cmath>
#include <sal/types.h>
-#include <sal/alloca.h>
#include <basegfx/matrix/b2dhommatrix.hxx>
@@ -1019,12 +1018,12 @@ long OutputDevice::GetTextArray( const OUString& rStr, long* pDXAry,
if( !pSalLayout )
return 0;
#if VCL_FLOAT_DEVICE_PIXEL
- DeviceCoordinate* pDXPixelArray = NULL;
+ std::unique_ptr<DeviceCoordinate[]> pDXPixelArray;
if(pDXAry)
{
- pDXPixelArray = static_cast<DeviceCoordinate*>(alloca(nLen * sizeof(DeviceCoordinate)));
+ pDXPixelArray.reset(new DeviceCoordinate[nLen]);
}
- DeviceCoordinate nWidth = pSalLayout->FillDXArray( pDXPixelArray );
+ DeviceCoordinate nWidth = pSalLayout->FillDXArray( pDXPixelArray.get() );
int nWidthFactor = pSalLayout->GetUnitsPerPixel();
pSalLayout->Release();
@@ -1346,7 +1345,8 @@ SalLayout* OutputDevice::ImplLayout(const OUString& rOrigStr,
pLayoutCache = nullptr; // don't use cache with modified string!
}
DeviceCoordinate nPixelWidth = (DeviceCoordinate)nLogicalWidth;
- DeviceCoordinate* pDXPixelArray = NULL;
+ std::unique_ptr<DeviceCoordinate[]> xDXPixelArray;
+ DeviceCoordinate* pDXPixelArray(nullptr);
if( nLogicalWidth && mbMap )
{
nPixelWidth = LogicWidthToDeviceCoordinate( nLogicalWidth );
@@ -1357,7 +1357,8 @@ SalLayout* OutputDevice::ImplLayout(const OUString& rOrigStr,
if(mbMap)
{
// convert from logical units to font units using a temporary array
- pDXPixelArray = static_cast<DeviceCoordinate*>(alloca( nLen * sizeof(DeviceCoordinate) ));
+ xDXPixelArray.reset(new DeviceCoordinate[nLen]);
+ pDXPixelArray = xDXPixelArray.get();
// using base position for better rounding a.k.a. "dancing characters"
DeviceCoordinate nPixelXOfs = LogicWidthToDeviceCoordinate( rLogicalPos.X() );
for( int i = 0; i < nLen; ++i )
@@ -1368,7 +1369,8 @@ SalLayout* OutputDevice::ImplLayout(const OUString& rOrigStr,
else
{
#if VCL_FLOAT_DEVICE_PIXEL
- pDXPixelArray = static_cast<DeviceCoordinate*>(alloca( nLen * sizeof(DeviceCoordinate) ));
+ xDXPixelArray.reset(new DeviceCoordinate[nLen]);
+ pDXPixelArray = xDXPixelArray.get();
for( int i = 0; i < nLen; ++i )
{
pDXPixelArray[i] = pDXArray[i];
@@ -1693,8 +1695,8 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const Rectangle& r
long nMnemonicY;
DeviceCoordinate nMnemonicWidth;
- long* pCaretXArray = static_cast<long*>(alloca( 2 * sizeof(long) * nLineLen ));
- /*sal_Bool bRet =*/ _rLayout.GetCaretPositions( aStr, pCaretXArray,
+ std::unique_ptr<long[]> const pCaretXArray(new long[2 * nLineLen]);
+ /*sal_Bool bRet =*/ _rLayout.GetCaretPositions( aStr, pCaretXArray.get(),
nIndex, nLineLen );
long lc_x1 = pCaretXArray[2*(nMnemonicPos - nIndex)];
long lc_x2 = pCaretXArray[2*(nMnemonicPos - nIndex)+1];
@@ -1762,8 +1764,8 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const Rectangle& r
DeviceCoordinate nMnemonicWidth = 0;
if ( nMnemonicPos != -1 )
{
- long* pCaretXArray = static_cast<long*>(alloca( 2 * sizeof(long) * aStr.getLength() ));
- /*sal_Bool bRet =*/ _rLayout.GetCaretPositions( aStr, pCaretXArray, 0, aStr.getLength() );
+ std::unique_ptr<long[]> const pCaretXArray(new long[2 * aStr.getLength()]);
+ /*sal_Bool bRet =*/ _rLayout.GetCaretPositions( aStr, pCaretXArray.get(), 0, aStr.getLength() );
long lc_x1 = pCaretXArray[2*(nMnemonicPos)];
long lc_x2 = pCaretXArray[2*(nMnemonicPos)+1];
nMnemonicWidth = rTargetDevice.LogicWidthToDeviceCoordinate( std::abs(lc_x1 - lc_x2) );
@@ -2213,8 +2215,8 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const OUString& rStr,
nMnemonicPos = nLen-1;
}
- long* pCaretXArray = static_cast<long*>(alloca( 2 * sizeof(long) * nLen ));
- /*sal_Bool bRet =*/ GetCaretPositions( aStr, pCaretXArray, nIndex, nLen );
+ std::unique_ptr<long[]> const pCaretXArray(new long[2 * nLen]);
+ /*sal_Bool bRet =*/ GetCaretPositions( aStr, pCaretXArray.get(), nIndex, nLen );
long lc_x1 = pCaretXArray[ 2*(nMnemonicPos - nIndex) ];
long lc_x2 = pCaretXArray[ 2*(nMnemonicPos - nIndex)+1 ];
nMnemonicWidth = ::abs((int)(lc_x1 - lc_x2));