summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-10-17 13:40:38 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-11-14 10:19:32 +0100
commit8f54136caa786523fd224f6c98fc8e7c45cd805d (patch)
treee77e4cba4e281a32e2bee5fd6a10d43ae6c7a360 /vcl/source
parentb5344daa0cfc31cf187832261651e5490b19d922 (diff)
use std::unique_ptr for SalLayout
to make the ownership passing around more obvious Change-Id: I147ec6d9cfe7566cf3600685e0730ed741c2d90d Reviewed-on: https://gerrit.libreoffice.org/43454 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx9
-rw-r--r--vcl/source/gdi/print2.cxx6
-rw-r--r--vcl/source/gdi/sallayout.cxx10
-rw-r--r--vcl/source/outdev/font.cxx20
-rw-r--r--vcl/source/outdev/text.cxx61
-rw-r--r--vcl/source/outdev/textline.cxx4
-rw-r--r--vcl/source/window/status.cxx12
7 files changed, 45 insertions, 77 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index e9fa6ad99673..33ea6b0f194e 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -7039,11 +7039,10 @@ void PDFWriterImpl::drawText( const Point& rPos, const OUString& rText, sal_Int3
// get a layout from the OutputDevice's SalGraphics
// this also enforces font substitution and sets the font on SalGraphics
- SalLayout* pLayout = m_pReferenceDevice->ImplLayout( rText, nIndex, nLen, rPos );
+ std::unique_ptr<SalLayout> pLayout = m_pReferenceDevice->ImplLayout( rText, nIndex, nLen, rPos );
if( pLayout )
{
drawLayout( *pLayout, rText, bTextLines );
- delete pLayout;
}
}
@@ -7055,11 +7054,10 @@ void PDFWriterImpl::drawTextArray( const Point& rPos, const OUString& rText, con
// get a layout from the OutputDevice's SalGraphics
// this also enforces font substitution and sets the font on SalGraphics
- SalLayout* pLayout = m_pReferenceDevice->ImplLayout( rText, nIndex, nLen, rPos, 0, pDXArray );
+ std::unique_ptr<SalLayout> pLayout = m_pReferenceDevice->ImplLayout( rText, nIndex, nLen, rPos, 0, pDXArray );
if( pLayout )
{
drawLayout( *pLayout, rText, true );
- delete pLayout;
}
}
@@ -7071,11 +7069,10 @@ void PDFWriterImpl::drawStretchText( const Point& rPos, sal_uLong nWidth, const
// get a layout from the OutputDevice's SalGraphics
// this also enforces font substitution and sets the font on SalGraphics
- SalLayout* pLayout = m_pReferenceDevice->ImplLayout( rText, nIndex, nLen, rPos, nWidth );
+ std::unique_ptr<SalLayout> pLayout = m_pReferenceDevice->ImplLayout( rText, nIndex, nLen, rPos, nWidth );
if( pLayout )
{
drawLayout( *pLayout, rText, true );
- delete pLayout;
}
}
diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx
index 75f55716995c..75c5c1ae5b0d 100644
--- a/vcl/source/gdi/print2.cxx
+++ b/vcl/source/gdi/print2.cxx
@@ -585,14 +585,13 @@ tools::Rectangle ImplCalcActionBounds( const MetaAction& rAct, const OutputDevic
if( !aString.isEmpty() )
{
// #105987# ImplLayout takes everything in logical coordinates
- SalLayout* pSalLayout = rOut.ImplLayout( rTextAct.GetText(), rTextAct.GetIndex(),
+ std::unique_ptr<SalLayout> pSalLayout = rOut.ImplLayout( rTextAct.GetText(), rTextAct.GetIndex(),
rTextAct.GetLen(), rTextAct.GetPoint(),
0, rTextAct.GetDXArray() );
if( pSalLayout )
{
tools::Rectangle aBoundRect( const_cast<OutputDevice&>(rOut).ImplGetTextBoundRect( *pSalLayout ) );
aActionBounds = rOut.PixelToLogic( aBoundRect );
- delete pSalLayout;
}
}
}
@@ -615,14 +614,13 @@ tools::Rectangle ImplCalcActionBounds( const MetaAction& rAct, const OutputDevic
if( !aString.isEmpty() )
{
// #105987# ImplLayout takes everything in logical coordinates
- SalLayout* pSalLayout = rOut.ImplLayout( rTextAct.GetText(), rTextAct.GetIndex(),
+ std::unique_ptr<SalLayout> pSalLayout = rOut.ImplLayout( rTextAct.GetText(), rTextAct.GetIndex(),
rTextAct.GetLen(), rTextAct.GetPoint(),
rTextAct.GetWidth() );
if( pSalLayout )
{
tools::Rectangle aBoundRect( const_cast<OutputDevice&>(rOut).ImplGetTextBoundRect( *pSalLayout ) );
aActionBounds = rOut.PixelToLogic( aBoundRect );
- delete pSalLayout;
}
}
}
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index e277e661f61e..6184d18e2ca9 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -1024,15 +1024,15 @@ void GenericSalLayout::Simplify( bool bIsBase )
m_GlyphItems.erase(m_GlyphItems.begin() + j, m_GlyphItems.end());
}
-MultiSalLayout::MultiSalLayout( SalLayout& rBaseLayout )
+MultiSalLayout::MultiSalLayout( std::unique_ptr<SalLayout> pBaseLayout )
: SalLayout()
, mnLevel( 1 )
, mbIncomplete( false )
{
//maFallbackRuns[0].Clear();
mpFallbackFonts[ 0 ] = nullptr;
- mpLayouts[ 0 ] = &rBaseLayout;
- mnUnitsPerPixel = rBaseLayout.GetUnitsPerPixel();
+ mpLayouts[ 0 ] = pBaseLayout.release();
+ mnUnitsPerPixel = mpLayouts[ 0 ]->GetUnitsPerPixel();
}
void MultiSalLayout::SetIncomplete(bool bIncomplete)
@@ -1047,14 +1047,14 @@ MultiSalLayout::~MultiSalLayout()
delete mpLayouts[ i ];
}
-void MultiSalLayout::AddFallback( SalLayout& rFallback,
+void MultiSalLayout::AddFallback( std::unique_ptr<SalLayout> pFallback,
ImplLayoutRuns const & rFallbackRuns, const PhysicalFontFace* pFallbackFont )
{
if( mnLevel >= MAX_FALLBACK )
return;
mpFallbackFonts[ mnLevel ] = pFallbackFont;
- mpLayouts[ mnLevel ] = &rFallback;
+ mpLayouts[ mnLevel ] = pFallback.release();
maFallbackRuns[ mnLevel-1 ] = rFallbackRuns;
++mnLevel;
}
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index c018113a9ff5..2a5d88852fb2 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -1295,7 +1295,7 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout )
mpMetaFile = pOldMetaFile;
}
-SalLayout* OutputDevice::getFallbackFont(
+std::unique_ptr<SalLayout> OutputDevice::getFallbackFont(
FontSelectPattern &rFontSelData, int nFallbackLevel,
ImplLayoutArgs& rLayoutArgs) const
{
@@ -1307,7 +1307,7 @@ SalLayout* OutputDevice::getFallbackFont(
mpGraphics->SetFont( &rFontSelData, nFallbackLevel );
rLayoutArgs.ResetPos();
- SalLayout* pFallback = mpGraphics->GetTextLayout( rLayoutArgs, nFallbackLevel );
+ std::unique_ptr<SalLayout> pFallback = mpGraphics->GetTextLayout( rLayoutArgs, nFallbackLevel );
if (!pFallback)
return nullptr;
@@ -1315,7 +1315,6 @@ SalLayout* OutputDevice::getFallbackFont(
if (!pFallback->LayoutText(rLayoutArgs))
{
// there is no need for a font that couldn't resolve anything
- delete pFallback;
return nullptr;
}
@@ -1324,7 +1323,7 @@ SalLayout* OutputDevice::getFallbackFont(
return pFallback;
}
-SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLayoutArgs& rLayoutArgs ) const
+std::unique_ptr<SalLayout> OutputDevice::ImplGlyphFallbackLayout( std::unique_ptr<SalLayout> pSalLayout, ImplLayoutArgs& rLayoutArgs ) const
{
// This function relies on a valid mpFontInstance, if it doesn't exist bail out
// - we'd have crashed later on anyway. At least here we can catch the error in debug
@@ -1337,7 +1336,7 @@ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLay
}
// prepare multi level glyph fallback
- MultiSalLayout* pMultiSalLayout = nullptr;
+ std::unique_ptr<MultiSalLayout> pMultiSalLayout;
ImplLayoutRuns aLayoutRuns = rLayoutArgs.maRuns;
rLayoutArgs.PrepareFallback();
rLayoutArgs.mnFlags |= SalLayoutFlags::ForFallback;
@@ -1382,13 +1381,13 @@ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLay
}
// create and add glyph fallback layout to multilayout
- SalLayout* pFallback = getFallbackFont(aFontSelData,
+ std::unique_ptr<SalLayout> pFallback = getFallbackFont(aFontSelData,
nFallbackLevel, rLayoutArgs);
if (pFallback)
{
if( !pMultiSalLayout )
- pMultiSalLayout = new MultiSalLayout( *pSalLayout );
- pMultiSalLayout->AddFallback( *pFallback,
+ pMultiSalLayout.reset( new MultiSalLayout( std::move(pSalLayout) ) );
+ pMultiSalLayout->AddFallback( std::move(pFallback),
rLayoutArgs.maRuns, aFontSelData.mpFontData );
if (nFallbackLevel == MAX_FALLBACK-1)
pMultiSalLayout->SetIncomplete(true);
@@ -1402,7 +1401,7 @@ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLay
}
if( pMultiSalLayout && pMultiSalLayout->LayoutText( rLayoutArgs ) )
- pSalLayout = pMultiSalLayout;
+ pSalLayout = std::move(pMultiSalLayout);
// restore orig font settings
pSalLayout->InitFont();
@@ -1426,7 +1425,7 @@ sal_Int32 OutputDevice::ValidateKashidas ( const OUString& rTxt,
sal_Int32* pKashidaPosDropped ) const
{
// do layout
- SalLayout* pSalLayout = ImplLayout( rTxt, nIdx, nLen );
+ std::unique_ptr<SalLayout> pSalLayout = ImplLayout( rTxt, nIdx, nLen );
if( !pSalLayout )
return 0;
sal_Int32 nDropped = 0;
@@ -1438,7 +1437,6 @@ sal_Int32 OutputDevice::ValidateKashidas ( const OUString& rTxt,
++nDropped;
}
}
- delete pSalLayout;
return nDropped;
}
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 7b1a8f957d38..1d93f7730aae 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -864,13 +864,11 @@ void OutputDevice::DrawText( const Point& rStartPt, const OUString& rStr,
// without cache
if(!pLayoutCache)
{
- SalLayout* pSalLayout = ImplLayout(rStr, nIndex, nLen, rStartPt);
+ std::unique_ptr<SalLayout> pSalLayout = ImplLayout(rStr, nIndex, nLen, rStartPt);
if(pSalLayout)
{
ImplDrawText( *pSalLayout );
- delete pSalLayout;
}
-
}
else
{
@@ -953,11 +951,10 @@ void OutputDevice::DrawTextArray( const Point& rStartPt, const OUString& rStr,
if( mbOutputClipped )
return;
- SalLayout* pSalLayout = ImplLayout(rStr, nIndex, nLen, rStartPt, 0, pDXAry, flags);
+ std::unique_ptr<SalLayout> pSalLayout = ImplLayout(rStr, nIndex, nLen, rStartPt, 0, pDXAry, flags);
if( pSalLayout )
{
ImplDrawText( *pSalLayout );
- delete pSalLayout;
}
if( mpAlphaVDev )
@@ -977,13 +974,15 @@ long OutputDevice::GetTextArray( const OUString& rStr, long* pDXAry,
nLen = rStr.getLength() - nIndex;
}
+ std::unique_ptr<SalLayout> xSalLayout;
const SalLayout* pSalLayout = pSalLayoutCache;
if(!pSalLayoutCache)
{
// do layout
- pSalLayout = ImplLayout(rStr, nIndex, nLen,
+ xSalLayout = ImplLayout(rStr, nIndex, nLen,
Point(0,0), 0, nullptr, SalLayoutFlags::NONE, pLayoutCache);
+ pSalLayout = xSalLayout.get();
if( !pSalLayout )
{
// The caller expects this to init the elements of pDXAry.
@@ -1009,9 +1008,6 @@ long OutputDevice::GetTextArray( const OUString& rStr, long* pDXAry,
DeviceCoordinate nWidth = pSalLayout->FillDXArray( pDXPixelArray.get() );
int nWidthFactor = pSalLayout->GetUnitsPerPixel();
- if(!pSalLayoutCache)
- delete pSalLayout;
-
// convert virtual char widths to virtual absolute positions
if( pDXPixelArray )
{
@@ -1056,9 +1052,6 @@ long OutputDevice::GetTextArray( const OUString& rStr, long* pDXAry,
long nWidth = pSalLayout->FillDXArray( pDXAry );
int nWidthFactor = pSalLayout->GetUnitsPerPixel();
- if(!pSalLayoutCache)
- delete pSalLayout;
-
// convert virtual char widths to virtual absolute positions
if( pDXAry )
for( int i = 1; i < nLen; ++i )
@@ -1094,14 +1087,13 @@ bool OutputDevice::GetCaretPositions( const OUString& rStr, long* pCaretXArray,
nLen = rStr.getLength() - nIndex;
// layout complex text
- SalLayout* pSalLayout = ImplLayout( rStr, nIndex, nLen, Point(0,0) );
+ std::unique_ptr<SalLayout> pSalLayout = ImplLayout( rStr, nIndex, nLen, Point(0,0) );
if( !pSalLayout )
return false;
int nWidthFactor = pSalLayout->GetUnitsPerPixel();
pSalLayout->GetCaretPositions( 2*nLen, pCaretXArray );
long nWidth = pSalLayout->GetTextWidth();
- delete pSalLayout;
// fixup unknown caret positions
int i;
@@ -1157,11 +1149,10 @@ void OutputDevice::DrawStretchText( const Point& rStartPt, sal_uLong nWidth,
if ( !IsDeviceOutputNecessary() )
return;
- SalLayout* pSalLayout = ImplLayout(rStr, nIndex, nLen, rStartPt, nWidth);
+ std::unique_ptr<SalLayout> pSalLayout = ImplLayout(rStr, nIndex, nLen, rStartPt, nWidth);
if( pSalLayout )
{
ImplDrawText( *pSalLayout );
- delete pSalLayout;
}
if( mpAlphaVDev )
@@ -1258,7 +1249,7 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr,
return aLayoutArgs;
}
-SalLayout* OutputDevice::ImplLayout(const OUString& rOrigStr,
+std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr,
sal_Int32 nMinIndex, sal_Int32 nLen,
const Point& rLogicalPos, long nLogicalWidth,
const long* pDXArray, SalLayoutFlags flags,
@@ -1334,13 +1325,12 @@ SalLayout* OutputDevice::ImplLayout(const OUString& rOrigStr,
nPixelWidth, pDXPixelArray, flags, pLayoutCache);
// get matching layout object for base font
- SalLayout* pSalLayout = mpGraphics->GetTextLayout( aLayoutArgs, 0 );
+ std::unique_ptr<SalLayout> pSalLayout = mpGraphics->GetTextLayout( aLayoutArgs, 0 );
// layout text
if( pSalLayout && !pSalLayout->LayoutText( aLayoutArgs ) )
{
- delete pSalLayout;
- pSalLayout = nullptr;
+ pSalLayout.reset();
}
if( !pSalLayout )
@@ -1349,7 +1339,7 @@ SalLayout* OutputDevice::ImplLayout(const OUString& rOrigStr,
// do glyph fallback if needed
// #105768# avoid fallback for very small font sizes
if (aLayoutArgs.NeedFallback() && mpFontInstance->maFontSelData.mnHeight >= 3)
- pSalLayout = ImplGlyphFallbackLayout(pSalLayout, aLayoutArgs);
+ pSalLayout = ImplGlyphFallbackLayout(std::move(pSalLayout), aLayoutArgs);
// position, justify, etc. the layout
pSalLayout->AdjustLayout( aLayoutArgs );
@@ -1379,12 +1369,11 @@ std::shared_ptr<vcl::TextLayoutCache> OutputDevice::CreateTextLayoutCache(
ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs(copyBecausePrepareModifiesIt,
0, rString.getLength(), 0, nullptr);
- SalLayout *const pSalLayout = mpGraphics->GetTextLayout( aLayoutArgs, 0 );
+ std::unique_ptr<SalLayout> pSalLayout = mpGraphics->GetTextLayout( aLayoutArgs, 0 );
if (!pSalLayout)
return nullptr;
std::shared_ptr<vcl::TextLayoutCache> const ret(
pSalLayout->CreateTextLayoutCache(copyBecausePrepareModifiesIt));
- delete pSalLayout;
return ret;
}
@@ -1404,7 +1393,7 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth,
long nCharExtra,
vcl::TextLayoutCache const*const pLayoutCache) const
{
- SalLayout *const pSalLayout = ImplLayout( rStr, nIndex, nLen,
+ std::unique_ptr<SalLayout> pSalLayout = ImplLayout( rStr, nIndex, nLen,
Point(0,0), 0, nullptr, SalLayoutFlags::NONE, pLayoutCache);
sal_Int32 nRetVal = -1;
if( pSalLayout )
@@ -1424,8 +1413,6 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth,
nExtraPixelWidth = LogicWidthToDeviceCoordinate( nCharExtra );
}
nRetVal = pSalLayout->GetTextBreak( nTextPixelWidth, nExtraPixelWidth, nSubPixelFactor );
-
- delete pSalLayout;
}
return nRetVal;
@@ -1439,7 +1426,7 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth,
{
rHyphenPos = -1;
- SalLayout *const pSalLayout = ImplLayout( rStr, nIndex, nLen,
+ std::unique_ptr<SalLayout> pSalLayout = ImplLayout( rStr, nIndex, nLen,
Point(0,0), 0, nullptr, SalLayoutFlags::NONE, pLayoutCache);
sal_Int32 nRetVal = -1;
if( pSalLayout )
@@ -1465,12 +1452,11 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth,
// calculate hyphenated break position
OUString aHyphenStr(nHyphenChar);
- SalLayout* pHyphenLayout = ImplLayout( aHyphenStr, 0, 1 );
+ std::unique_ptr<SalLayout> pHyphenLayout = ImplLayout( aHyphenStr, 0, 1 );
if( pHyphenLayout )
{
// calculate subpixel width of hyphenation character
long nHyphenPixelWidth = pHyphenLayout->GetTextWidth() * nSubPixelFactor;
- delete pHyphenLayout;
// calculate hyphenated break position
nTextPixelWidth -= nHyphenPixelWidth;
@@ -1482,8 +1468,6 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth,
if( rHyphenPos > nRetVal )
rHyphenPos = nRetVal;
}
-
- delete pSalLayout;
}
return nRetVal;
@@ -2328,7 +2312,7 @@ SystemTextLayoutData OutputDevice::GetSysTextLayoutData(const Point& rStartPt, c
if ( !IsDeviceOutputNecessary() ) return aSysLayoutData;
- SalLayout* pLayout = ImplLayout(rStr, nIndex, nLen, rStartPt, 0, pDXAry);
+ std::unique_ptr<SalLayout> pLayout = ImplLayout(rStr, nIndex, nLen, rStartPt, 0, pDXAry);
if ( !pLayout ) return aSysLayoutData;
@@ -2350,8 +2334,6 @@ SystemTextLayoutData OutputDevice::GetSysTextLayoutData(const Point& rStartPt, c
// Get font data
aSysLayoutData.orientation = pLayout->GetOrientation();
- delete pLayout;
-
return aSysLayoutData;
}
@@ -2363,7 +2345,7 @@ bool OutputDevice::GetTextBoundRect( tools::Rectangle& rRect,
bool bRet = false;
rRect.SetEmpty();
- SalLayout* pSalLayout = nullptr;
+ std::unique_ptr<SalLayout> pSalLayout;
const Point aPoint;
// calculate offset when nBase!=nIndex
long nXOffset = 0;
@@ -2376,7 +2358,6 @@ bool OutputDevice::GetTextBoundRect( tools::Rectangle& rRect,
{
nXOffset = pSalLayout->GetTextWidth();
nXOffset /= pSalLayout->GetUnitsPerPixel();
- delete pSalLayout;
// TODO: fix offset calculation for Bidi case
if( nBase < nIndex)
nXOffset = -nXOffset;
@@ -2413,8 +2394,6 @@ bool OutputDevice::GetTextBoundRect( tools::Rectangle& rRect,
if( mbMap )
rRect += Point( maMapRes.mnMapOfsX, maMapRes.mnMapOfsY );
}
-
- delete pSalLayout;
}
return bRet;
@@ -2450,7 +2429,7 @@ bool OutputDevice::GetTextOutlines( basegfx::B2DPolyPolygonVector& rVector,
const_cast<OutputDevice&>(*this).mbNewFont = true;
}
- SalLayout* pSalLayout = nullptr;
+ std::unique_ptr<SalLayout> pSalLayout;
// calculate offset when nBase!=nIndex
long nXOffset = 0;
@@ -2462,7 +2441,7 @@ bool OutputDevice::GetTextOutlines( basegfx::B2DPolyPolygonVector& rVector,
if( pSalLayout )
{
nXOffset = pSalLayout->GetTextWidth();
- delete pSalLayout;
+ pSalLayout.reset();
// TODO: fix offset calculation for Bidi case
if( nBase > nIndex)
nXOffset = -nXOffset;
@@ -2500,7 +2479,7 @@ bool OutputDevice::GetTextOutlines( basegfx::B2DPolyPolygonVector& rVector,
}
}
- delete pSalLayout;
+ pSalLayout.reset();
}
if( bOldMap )
diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx
index 513e22f09aa6..7d1d44075823 100644
--- a/vcl/source/outdev/textline.cxx
+++ b/vcl/source/outdev/textline.cxx
@@ -600,11 +600,10 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY,
// calculate approximation of strikeout atom size
long nStrikeoutWidth = 0;
- SalLayout* pLayout = ImplLayout( aStrikeoutTest, 0, nTestStrLen );
+ std::unique_ptr<SalLayout> pLayout = ImplLayout( aStrikeoutTest, 0, nTestStrLen );
if( pLayout )
{
nStrikeoutWidth = pLayout->GetTextWidth() / (nTestStrLen * pLayout->GetUnitsPerPixel());
- delete pLayout;
}
if( nStrikeoutWidth <= 0 ) // sanity check
return;
@@ -664,7 +663,6 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY,
pLayout->DrawText( *mpGraphics );
- delete pLayout;
Pop();
SetTextColor( aOldColor );
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index e24a153896cb..11a2480323ff 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -376,11 +376,9 @@ void StatusBar::ImplDrawItem(vcl::RenderContext& rRenderContext, bool bOffScreen
if(!pLayoutCache)
{
- pLayoutCache = rRenderContext.ImplLayout(pItem->maText, 0, -1);
-
// update cache
- if(pLayoutCache)
- pItem->mxLayoutCache.reset(pLayoutCache);
+ pItem->mxLayoutCache = rRenderContext.ImplLayout(pItem->maText, 0, -1);
+ pLayoutCache = pItem->mxLayoutCache.get();
}
Size aTextSize(rRenderContext.GetTextWidth(pItem->maText,0,-1,nullptr,pLayoutCache), rRenderContext.GetTextHeight());
@@ -1168,11 +1166,11 @@ void StatusBar::SetItemText( sal_uInt16 nItemId, const OUString& rText )
// adjust item width - see also DataChanged()
long nFudge = GetTextHeight()/4;
- SalLayout* pSalLayout = ImplLayout(pItem->maText,0,-1);
- long nWidth = GetTextWidth( pItem->maText,0,-1,nullptr,pSalLayout ) + nFudge;
+ std::unique_ptr<SalLayout> pSalLayout = ImplLayout(pItem->maText,0,-1);
+ long nWidth = GetTextWidth( pItem->maText,0,-1,nullptr,pSalLayout.get() ) + nFudge;
// update cache
- pItem->mxLayoutCache.reset(pSalLayout);
+ pItem->mxLayoutCache = std::move(pSalLayout);
if( (nWidth > pItem->mnWidth + STATUSBAR_OFFSET) ||
((nWidth < pItem->mnWidth) && (mnDX - STATUSBAR_OFFSET) < mnItemsWidth ))