basic/source/runtime/iosys.cxx | 2 basic/source/sbx/sbxvar.cxx | 2 filter/source/placeware/tempfile.cxx | 120 ----------------------------- i18npool/inc/collatorImpl.hxx | 2 l10ntools/source/xmlparse.cxx | 1 sax/source/expatwrap/sax_expat.cxx | 40 --------- sc/inc/pch/precompiled_sc.hxx | 1 sc/source/core/tool/address.cxx | 1 toolkit/source/awt/vclxfont.cxx | 5 - toolkit/source/awt/vclxgraphics.cxx | 5 - vcl/generic/fontmanager/fontconfig.cxx | 6 - vcl/generic/fontmanager/fontmanager.cxx | 4 vcl/generic/glyphs/gcach_layout.cxx | 1 vcl/osx/salframeview.mm | 1 vcl/source/font/PhysicalFontCollection.cxx | 5 - vcl/source/gdi/sallayout.cxx | 25 ++---- vcl/source/outdev/text.cxx | 28 +++--- vcl/unx/generic/app/i18n_ic.cxx | 1 vcl/unx/generic/gdi/salgdi3.cxx | 1 vcl/unx/generic/printer/jobdata.cxx | 7 - vcl/win/source/gdi/winlayout.cxx | 6 + 21 files changed, 49 insertions(+), 215 deletions(-)
New commits: commit ea8de68df5e7f4388bd7d9dea0bdbcf73c889875 Author: Michael Stahl <mst...@redhat.com> Date: Mon Sep 28 22:52:22 2015 +0200 vcl: Vista implies usp10.dll >= 1.600 ... claims https://en.wikipedia.org/wiki/Uniscribe - #ifdef this so it can be removed when dropping XP support. Change-Id: I9a51635cf9bb4876faf6dca011e6da9e1c2dc35d diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index 454ecae..0572b21 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -626,6 +626,7 @@ static bool bManualCellAlign = true; static void InitUSP() { +#if _WIN32_WINNT < _WIN32_WINNT_VISTA // get the usp10.dll version info HMODULE usp10 = GetModuleHandle("usp10.dll"); void *pScriptIsComplex = reinterpret_cast< void* >( GetProcAddress(usp10, "ScriptIsComplex")); @@ -655,7 +656,10 @@ static void InitUSP() // #i77976# USP>=1.0600 changed the need to manually align glyphs in their cells if( nUspVersion >= 10600 ) +#endif + { bManualCellAlign = false; + } bUspInited = true; } commit 28f18b68db1af3668203730ba8cfbb66103fe669 Author: Michael Stahl <mst...@redhat.com> Date: Tue Sep 29 14:25:23 2015 +0200 vcl: replace alloca() with std::unique_ptr Change-Id: I82b982895ee422bcf5a23756df4d81c89bc47636 diff --git a/vcl/generic/fontmanager/fontconfig.cxx b/vcl/generic/fontmanager/fontconfig.cxx index becb419..f6ee508 100644 --- a/vcl/generic/fontmanager/fontconfig.cxx +++ b/vcl/generic/fontmanager/fontconfig.cxx @@ -53,8 +53,6 @@ using namespace psp; #include "rtl/ustrbuf.hxx" -#include "sal/alloca.h" - #include <utility> #include <algorithm> @@ -1086,7 +1084,7 @@ bool PrintFontManager::Substitute( FontSelectPattern &rPattern, OUString& rMissi // update rMissingCodes by removing resolved unicodes if( !rMissingCodes.isEmpty() ) { - sal_uInt32* pRemainingCodes = static_cast<sal_uInt32*>(alloca( rMissingCodes.getLength() * sizeof(sal_uInt32) )); + std::unique_ptr<sal_uInt32[]> const pRemainingCodes(new sal_uInt32[rMissingCodes.getLength()]); int nRemainingLen = 0; FcCharSet* unicodes; if (!FcPatternGetCharSet(pSet->fonts[0], FC_CHARSET, 0, &unicodes)) @@ -1099,7 +1097,7 @@ bool PrintFontManager::Substitute( FontSelectPattern &rPattern, OUString& rMissi pRemainingCodes[ nRemainingLen++ ] = nCode; } } - OUString sStillMissing(pRemainingCodes, nRemainingLen); + OUString sStillMissing(pRemainingCodes.get(), nRemainingLen); #if defined(ENABLE_DBUS) && defined(ENABLE_PACKAGEKIT) if (get_xid_for_dbus()) { diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx index 56917f6..b6651b7 100644 --- a/vcl/generic/fontmanager/fontmanager.cxx +++ b/vcl/generic/fontmanager/fontmanager.cxx @@ -59,8 +59,6 @@ #include <stdio.h> #endif -#include "sal/alloca.h" - #include <algorithm> #include <set> #include <unordered_set> @@ -472,7 +470,7 @@ bool PrintFontManager::PrintFont::readAfmMetrics( MultiAtomProvider* pProvider, // first transform the character codes to unicode // note: this only works with single byte encodings - sal_Unicode* pUnicodes = static_cast<sal_Unicode*>(alloca( pInfo->numOfChars * sizeof(sal_Unicode))); + std::unique_ptr<sal_Unicode[]> const pUnicodes(new sal_Unicode[pInfo->numOfChars]); CharMetricInfo* pChar = pInfo->cmi; int i; diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx index 26b33ed..cd89bdf 100644 --- a/vcl/source/font/PhysicalFontCollection.cxx +++ b/vcl/source/font/PhysicalFontCollection.cxx @@ -18,7 +18,6 @@ */ #include <sal/types.h> -#include <sal/alloca.h> #include <vector> @@ -244,7 +243,7 @@ PhysicalFontFamily* PhysicalFontCollection::GetGlyphFallbackFont( FontSelectPatt // there is a matching fallback in the cache // so update rMissingCodes with codepoints not yet resolved by this fallback int nRemainingLength = 0; - sal_UCS4* pRemainingCodes = static_cast<sal_UCS4*>(alloca( rMissingCodes.getLength() * sizeof(sal_UCS4) )); + std::unique_ptr<sal_UCS4[]> const pRemainingCodes(new sal_UCS4[rMissingCodes.getLength()]); OUString aFontName; while( nStrIndex < rMissingCodes.getLength() ) @@ -254,7 +253,7 @@ PhysicalFontFamily* PhysicalFontCollection::GetGlyphFallbackFont( FontSelectPatt if( !bCached || (rFontSelData.maSearchName != aFontName) ) pRemainingCodes[ nRemainingLength++ ] = cChar; } - rMissingCodes = OUString( pRemainingCodes, nRemainingLength ); + rMissingCodes = OUString( pRemainingCodes.get(), nRemainingLength ); } else { diff --git a/vcl/unx/generic/printer/jobdata.cxx b/vcl/unx/generic/printer/jobdata.cxx index 85f587a..840ef7b 100644 --- a/vcl/unx/generic/printer/jobdata.cxx +++ b/vcl/unx/generic/printer/jobdata.cxx @@ -22,7 +22,6 @@ #include "vcl/printerinfomanager.hxx" #include "tools/stream.hxx" -#include <sal/alloca.h> #include <rtl/strbuf.hxx> #include <memory> @@ -293,9 +292,9 @@ bool JobData::constructFromStreamBuffer( void* pData, int bytes, JobData& rJobDa { rJobData.m_aContext.setParser( rJobData.m_pParser ); int nBytes = bytes - aStream.Tell(); - char* pRemain = static_cast<char*>(alloca( bytes - aStream.Tell() )); - aStream.Read( pRemain, nBytes ); - rJobData.m_aContext.rebuildFromStreamBuffer( pRemain, nBytes ); + std::unique_ptr<char[]> pRemain(new char[bytes - aStream.Tell()]); + aStream.Read( pRemain.get(), nBytes ); + rJobData.m_aContext.rebuildFromStreamBuffer( pRemain.get(), nBytes ); bContext = true; } } commit 9555d03c98346e7c1dc1443c8d8c3ac1b41bf678 Author: Michael Stahl <mst...@redhat.com> Date: Tue Sep 29 14:18:00 2015 +0200 remove unused #include <sal/alloca.h> Change-Id: I490841fd2c526e4ca6d6c94cc7b9dba318c932a1 diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx index 7be2228..5292141 100644 --- a/basic/source/runtime/iosys.cxx +++ b/basic/source/runtime/iosys.cxx @@ -30,8 +30,6 @@ #include "runtime.hxx" -#include <sal/alloca.h> - #include <ctype.h> #include <rtl/byteseq.hxx> #include <rtl/textenc.h> diff --git a/i18npool/inc/collatorImpl.hxx b/i18npool/inc/collatorImpl.hxx index 0acd37a..e044e6d 100644 --- a/i18npool/inc/collatorImpl.hxx +++ b/i18npool/inc/collatorImpl.hxx @@ -27,7 +27,7 @@ #include <cppuhelper/weak.hxx> #include <cppuhelper/implbase.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <sal/alloca.h> + #include <vector> namespace com { namespace sun { namespace star { namespace i18n { diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx index 701848f..7a4c68e 100644 --- a/l10ntools/source/xmlparse.cxx +++ b/l10ntools/source/xmlparse.cxx @@ -22,7 +22,6 @@ #include <cassert> #include <stdio.h> -#include <sal/alloca.h> #include "helper.hxx" #include "common.hxx" diff --git a/sc/inc/pch/precompiled_sc.hxx b/sc/inc/pch/precompiled_sc.hxx index 4a0a1e9..2759e07 100644 --- a/sc/inc/pch/precompiled_sc.hxx +++ b/sc/inc/pch/precompiled_sc.hxx @@ -561,7 +561,6 @@ #include <rtl/tencinfo.h> #include <rtl/ustrbuf.hxx> #include <rtl/ustring.hxx> -#include <sal/alloca.h> #include <sal/config.h> #include <sal/log.hxx> #include <sal/macros.h> diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx index 8973f9d..2b781e9 100644 --- a/sc/source/core/tool/address.cxx +++ b/sc/source/core/tool/address.cxx @@ -24,7 +24,6 @@ #include "externalrefmgr.hxx" #include "globstr.hrc" -#include <sal/alloca.h> #include <osl/diagnose.h> #include <com/sun/star/frame/XModel.hpp> diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx index 26d8c11..4a8c144 100644 --- a/vcl/generic/glyphs/gcach_layout.cxx +++ b/vcl/generic/glyphs/gcach_layout.cxx @@ -27,7 +27,6 @@ #include <vcl/svapp.hxx> #include <vcl/unohelp.hxx> -#include <sal/alloca.h> #include <rtl/instance.hxx> #include <hb-icu.h> diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm index 062acec..5be7cc3 100644 --- a/vcl/osx/salframeview.mm +++ b/vcl/osx/salframeview.mm @@ -19,7 +19,6 @@ #include <sal/config.h> -#include <sal/alloca.h> #include <sal/macros.h> #include <tools/helpers.hxx> diff --git a/vcl/unx/generic/app/i18n_ic.cxx b/vcl/unx/generic/app/i18n_ic.cxx index 76c37e6..e9ddd68 100644 --- a/vcl/unx/generic/app/i18n_ic.cxx +++ b/vcl/unx/generic/app/i18n_ic.cxx @@ -19,7 +19,6 @@ #include <stdio.h> -#include <sal/alloca.h> #include <osl/thread.h> #include <prex.h> diff --git a/vcl/unx/generic/gdi/salgdi3.cxx b/vcl/unx/generic/gdi/salgdi3.cxx index a8ba323..aa4c5c4 100644 --- a/vcl/unx/generic/gdi/salgdi3.cxx +++ b/vcl/unx/generic/gdi/salgdi3.cxx @@ -33,7 +33,6 @@ #include <osl/file.hxx> #include <osl/module.hxx> #include <rtl/tencinfo.h> -#include <sal/alloca.h> #include <tools/stream.hxx> #include <vcl/settings.hxx> #include <vcl/sysdata.hxx> commit e77981764a4b21e57ee8d2302715c8c1269c860c Author: Michael Stahl <mst...@redhat.com> Date: Tue Sep 29 14:06:01 2015 +0200 filter: the placeware filter is not entitled to its own createTempFile Change-Id: Id4f4c23eab4aaf4d0f42827a89ecf90364605d97 diff --git a/filter/source/placeware/tempfile.cxx b/filter/source/placeware/tempfile.cxx index f573bad..6352418 100644 --- a/filter/source/placeware/tempfile.cxx +++ b/filter/source/placeware/tempfile.cxx @@ -17,95 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <osl/file.h> +#include <osl/file.hxx> #include <sal/macros.h> -#if defined( UNX) - -#include <stdio.h> -#include <string.h> -#include <osl/thread.h> - -oslFileError SAL_CALL my_getTempDirURL( rtl_uString** pustrTempDir ) -{ - const char *pValue = getenv( "TEMP" ); - - if ( !pValue ) - { - pValue = getenv( "TMP" ); - if ( !pValue ) - { -#if defined(SOLARIS) || defined (LINUX) - pValue = P_tmpdir; -#else - return osl_File_E_NOENT; -#endif - } - } - - oslFileError error; - rtl_uString *ustrTempPath = NULL; - - rtl_string2UString( &ustrTempPath, pValue, strlen( pValue ), osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS ); - error = osl_getFileURLFromSystemPath( ustrTempPath, pustrTempDir ); - rtl_uString_release( ustrTempPath ); - - return error; -} -#else - -#if defined _MSC_VER -#pragma warning(push, 1) -#endif - -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#include <malloc.h> - -#if defined _MSC_VER -#pragma warning(pop) -#endif - -oslFileError SAL_CALL my_getTempDirURL( rtl_uString** pustrTempDir ) -{ - WCHAR szBuffer[MAX_PATH]; - LPWSTR lpBuffer = szBuffer; - DWORD nBufferLength = SAL_N_ELEMENTS(szBuffer) - 1; - - DWORD nLength; - oslFileError error; - - do - { - nLength = GetTempPathW( SAL_N_ELEMENTS(szBuffer), lpBuffer ); - if ( nLength > nBufferLength ) - { - nLength++; - lpBuffer = (LPWSTR)alloca( sizeof(WCHAR) * nLength ); - nBufferLength = nLength - 1; - } - } while ( nLength > nBufferLength ); - - if ( nLength ) - { - rtl_uString *ustrTempPath = NULL; - - if ( '\\' == lpBuffer[nLength-1] ) - lpBuffer[nLength-1] = 0; - - rtl_uString_newFromStr( &ustrTempPath, reinterpret_cast<const sal_Unicode*>(lpBuffer) ); - - error = osl_getFileURLFromSystemPath( ustrTempPath, pustrTempDir ); - - rtl_uString_release( ustrTempPath ); - } - else - error = GetLastError() == ERROR_SUCCESS ? osl_File_E_None : osl_File_E_INVAL; - - return error; -} -#endif - #include "tempfile.hxx" PlaceWareTempFile::PlaceWareTempFile( const OUString& rTempFileURL ) @@ -125,38 +39,10 @@ OUString PlaceWareTempFile::createTempFileURL() { OUString aTempFileURL; - const sal_uInt32 nRadix = 26; - - OUString aTempDirURL; - /* oslFileError nRC = */ my_getTempDirURL( &aTempDirURL.pData ); - - static sal_uInt32 u = osl_getGlobalTimer(); - for ( sal_uInt32 nOld = u; ++u != nOld; ) - { - u %= (nRadix*nRadix*nRadix); - OUString aTmp( aTempDirURL ); - if( !aTmp.endsWith("/") ) - aTmp += "/"; - aTmp += OUString::number( (unsigned) u, nRadix ); - aTmp += ".tmp"; - - osl::File aFile( aTmp ); - osl::FileBase::RC err = aFile.open(osl_File_OpenFlag_Create); - if ( err == FileBase::E_None ) - { - aTempFileURL = aTmp; - aFile.close(); - break; - } - else if ( err != FileBase::E_EXIST ) - { - // if f.e. name contains invalid chars stop trying to create files - break; - } - } + ::osl::File::createTempFile(nullptr, nullptr, &aTempFileURL); + // TODO: there does not appear to be any way to report an error here? return aTempFileURL; } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 16e3daba9158bfa66050502034bc082583612a40 Author: Michael Stahl <mst...@redhat.com> Date: Tue Sep 29 13:48:03 2015 +0200 vcl: replace alloca() with std::unique_ptr Change-Id: If0f44ac761afdf50a8e6f5c77023ae5d74fdcad9 diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index ceffc84..f0a248d 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)); commit 2c9a1811fcd7f155226b315fc91811ba195c2c57 Author: Michael Stahl <mst...@redhat.com> Date: Mon Sep 28 23:42:27 2015 +0200 vcl: replace alloca() with std::unique_ptr Change-Id: I73d27e0e5a8ad0a02579c43f3fd479cb374d6bbd diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 3fcf3c6..04cbdd2 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -25,7 +25,6 @@ #include <cstdio> #include <math.h> -#include <sal/alloca.h> #include <salgdi.hxx> #include <sallayout.hxx> @@ -995,7 +994,7 @@ void GenericSalLayout::ApplyDXArray( ImplLayoutArgs& rArgs ) // determine cluster boundaries and x base offset const int nCharCount = rArgs.mnEndCharPos - rArgs.mnMinCharPos; - int* pLogCluster = static_cast<int*>(alloca( nCharCount * sizeof(int) )); + std::unique_ptr<int[]> const pLogCluster(new int[nCharCount]); size_t i; int n,p; long nBasePointX = -1; @@ -1030,7 +1029,7 @@ void GenericSalLayout::ApplyDXArray( ImplLayoutArgs& rArgs ) } // calculate adjusted cluster widths - long* pNewGlyphWidths = static_cast<long*>(alloca( m_GlyphItems.size() * sizeof(long) )); + std::unique_ptr<long[]> const pNewGlyphWidths(new long[m_GlyphItems.size()]); for( i = 0; i < m_GlyphItems.size(); ++i ) pNewGlyphWidths[ i ] = 0; @@ -1294,8 +1293,8 @@ void GenericSalLayout::GetCaretPositions( int nMaxIndex, long* pCaretXArray ) co sal_Int32 GenericSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor ) const { int nCharCapacity = mnEndCharPos - mnMinCharPos; - DeviceCoordinate* pCharWidths = static_cast<DeviceCoordinate*>(alloca( nCharCapacity * sizeof(DeviceCoordinate) )); - if( !GetCharWidths( pCharWidths ) ) + std::unique_ptr<DeviceCoordinate[]> const pCharWidths(new DeviceCoordinate[nCharCapacity]); + if (!GetCharWidths(pCharWidths.get())) return -1; DeviceCoordinate nWidth = 0; @@ -1929,13 +1928,13 @@ sal_Int32 MultiSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordi return mpLayouts[0]->GetTextBreak( nMaxWidth, nCharExtra, nFactor ); int nCharCount = mnEndCharPos - mnMinCharPos; - DeviceCoordinate* pCharWidths = static_cast<DeviceCoordinate*>(alloca( 2*nCharCount * sizeof(DeviceCoordinate) )); - mpLayouts[0]->FillDXArray( pCharWidths ); + std::unique_ptr<DeviceCoordinate[]> const pCharWidths(new DeviceCoordinate[2 * nCharCount]); + mpLayouts[0]->FillDXArray( pCharWidths.get() ); for( int n = 1; n < mnLevel; ++n ) { SalLayout& rLayout = *mpLayouts[ n ]; - rLayout.FillDXArray( pCharWidths + nCharCount ); + rLayout.FillDXArray( &pCharWidths[nCharCount] ); double fUnitMul = mnUnitsPerPixel; fUnitMul /= rLayout.GetUnitsPerPixel(); for( int i = 0; i < nCharCount; ++i ) @@ -1963,19 +1962,19 @@ DeviceCoordinate MultiSalLayout::FillDXArray( DeviceCoordinate* pCharWidths ) co DeviceCoordinate nMaxWidth = 0; // prepare merging of fallback levels - DeviceCoordinate* pTempWidths = NULL; + std::unique_ptr<DeviceCoordinate[]> pTempWidths; const int nCharCount = mnEndCharPos - mnMinCharPos; if( pCharWidths ) { for( int i = 0; i < nCharCount; ++i ) pCharWidths[i] = 0; - pTempWidths = static_cast<DeviceCoordinate*>(alloca( nCharCount * sizeof(DeviceCoordinate) )); + pTempWidths.reset(new DeviceCoordinate[nCharCount]); } for( int n = mnLevel; --n >= 0; ) { // query every fallback level - DeviceCoordinate nTextWidth = mpLayouts[n]->FillDXArray( pTempWidths ); + DeviceCoordinate nTextWidth = mpLayouts[n]->FillDXArray( pTempWidths.get() ); if( !nTextWidth ) continue; // merge results from current level @@ -2011,10 +2010,10 @@ void MultiSalLayout::GetCaretPositions( int nMaxIndex, long* pCaretXArray ) cons if( mnLevel > 1 ) { - long* pTempPos = static_cast<long*>(alloca( nMaxIndex * sizeof(long) )); + std::unique_ptr<long[]> const pTempPos(new long[nMaxIndex]); for( int n = 1; n < mnLevel; ++n ) { - mpLayouts[ n ]->GetCaretPositions( nMaxIndex, pTempPos ); + mpLayouts[ n ]->GetCaretPositions( nMaxIndex, pTempPos.get() ); double fUnitMul = mnUnitsPerPixel; fUnitMul /= mpLayouts[n]->GetUnitsPerPixel(); for( int i = 0; i < nMaxIndex; ++i ) commit 8f3d411f46e1bdd1543633cf9b5a729cf89f79f3 Author: Michael Stahl <mst...@redhat.com> Date: Mon Sep 28 23:23:47 2015 +0200 toolkit: convert alloca() to std::unique_ptr Change-Id: Ie50b4a1a189fffdaa6a0b26040c2e7c4cc42cd69 diff --git a/toolkit/source/awt/vclxfont.cxx b/toolkit/source/awt/vclxfont.cxx index a4b0c73..acdae57 100644 --- a/toolkit/source/awt/vclxfont.cxx +++ b/toolkit/source/awt/vclxfont.cxx @@ -26,7 +26,6 @@ #include <cppuhelper/queryinterface.hxx> #include <rtl/uuid.h> #include <rtl/ustring.h> -#include <sal/alloca.h> #include <vcl/outdev.hxx> #include <vcl/svapp.hxx> @@ -179,8 +178,8 @@ sal_Int32 VCLXFont::getStringWidthArray( const OUString& str, ::com::sun::star:: { vcl::Font aOldFont = pOutDev->GetFont(); pOutDev->SetFont( maFont ); - long* pDXA = static_cast<long*>(alloca(str.getLength() * sizeof(long))); - nRet = pOutDev->GetTextArray( str, pDXA ); + std::unique_ptr<long []> pDXA(new long[str.getLength()]); + nRet = pOutDev->GetTextArray( str, pDXA.get() ); rDXArray = ::com::sun::star::uno::Sequence<sal_Int32>( str.getLength() ); for(int i = 0; i < str.getLength(); i++) { diff --git a/toolkit/source/awt/vclxgraphics.cxx b/toolkit/source/awt/vclxgraphics.cxx index 482e29c..4e2268f 100644 --- a/toolkit/source/awt/vclxgraphics.cxx +++ b/toolkit/source/awt/vclxgraphics.cxx @@ -26,7 +26,6 @@ #include <cppuhelper/typeprovider.hxx> #include <cppuhelper/queryinterface.hxx> #include <rtl/uuid.h> -#include <sal/alloca.h> #include <vcl/svapp.hxx> #include <vcl/outdev.hxx> @@ -497,12 +496,12 @@ void VCLXGraphics::drawTextArray( sal_Int32 x, sal_Int32 y, const OUString& rTex if( mpOutputDevice ) { InitOutputDevice( InitOutDevFlags::CLIPREGION|InitOutDevFlags::RASTEROP|InitOutDevFlags::COLORS|InitOutDevFlags::FONT ); - long* pDXA = static_cast<long*>(alloca(rText.getLength() * sizeof(long))); + std::unique_ptr<long []> pDXA(new long[rText.getLength()]); for(int i = 0; i < rText.getLength(); i++) { pDXA[i] = rLongs[i]; } - mpOutputDevice->DrawTextArray( Point( x, y ), rText, pDXA ); + mpOutputDevice->DrawTextArray( Point( x, y ), rText, pDXA.get() ); } } commit 54bb97aa30d29865bf4b9826db7c7ec0607e7992 Author: Michael Stahl <mst...@redhat.com> Date: Mon Sep 28 23:14:53 2015 +0200 sax: remove obsolete XML_UNICODE code Change-Id: Ib5b9b7dc01b713554cf33f58f8fe2f97cb32c369 diff --git a/sax/source/expatwrap/sax_expat.cxx b/sax/source/expatwrap/sax_expat.cxx index c02ee87..51c997f 100644 --- a/sax/source/expatwrap/sax_expat.cxx +++ b/sax/source/expatwrap/sax_expat.cxx @@ -18,7 +18,6 @@ */ #include <stdlib.h> #include <string.h> -#include <sal/alloca.h> #include <cassert> #include <vector> @@ -53,47 +52,8 @@ using namespace ::com::sun::star::io; namespace { -// Useful macros for correct String conversion depending on the chosen expat-mode -#ifdef XML_UNICODE -OUString XmlNChar2OUString( const XML_Char *p , int nLen ) -{ - if( p ) { - if( sizeof( sal_Unicode ) == sizeof( XML_Char ) ) - { - return OUString( (sal_Unicode*)p,nLen); - } - else - { - sal_Unicode *pWchar = (sal_Unicode *)alloca( sizeof( sal_Unicode ) * nLen ); - for( int n = 0 ; n < nLen ; n++ ) { - pWchar[n] = (sal_Unicode) p[n]; - } - return OUString( pWchar , nLen ); - } - } - else { - return OUString(); - } -} - -OUString XmlChar2OUString( const XML_Char *p ) -{ - if( p ) { - int nLen; - for( nLen = 0 ; p[nLen] ; nLen ++ ) - ; - return XmlNChar2OUString( p , nLen ); - } - else return OUString(); -} - - -#define XML_CHAR_TO_OUSTRING(x) XmlChar2OUString(x) -#define XML_CHAR_N_TO_USTRING(x,n) XmlNChar2OUString(x,n) -#else #define XML_CHAR_TO_OUSTRING(x) OUString(x , strlen( x ), RTL_TEXTENCODING_UTF8) #define XML_CHAR_N_TO_USTRING(x,n) OUString(x,n, RTL_TEXTENCODING_UTF8 ) -#endif /* commit 810257500200391de71c8591ce24b8a942249bd5 Author: Michael Stahl <mst...@redhat.com> Date: Mon Sep 28 23:06:51 2015 +0200 vcl: remove alloca() in UniscribeLayout::GetCaretPositions() Change-Id: I0caab3b69b10aba6a5d45a11f8e9724b4d3c6d83 diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index b3562ee..454ecae 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -1873,7 +1873,7 @@ void UniscribeLayout::GetCaretPositions( int nMaxIdx, long* pCaretXArray ) const int i; for( i = 0; i < nMaxIdx; ++i ) pCaretXArray[ i ] = -1; - long* const pGlyphPos = (long*)alloca( (mnGlyphCount+1) * sizeof(long) ); + std::unique_ptr<long[]> const pGlyphPos = new long[mnGlyphCount + 1]; for( i = 0; i <= mnGlyphCount; ++i ) pGlyphPos[ i ] = -1; commit d70302ef5c18207a78f6c81aed85c12260f73820 Author: Michael Stahl <mst...@redhat.com> Date: Tue Sep 29 14:56:24 2015 +0200 basic: more plausible build fix than e5a8eb9e Change-Id: I26fd8a76a17386de73fa12058509ccee7e768512 diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx index 36d459a..e551af2 100644 --- a/basic/source/sbx/sbxvar.cxx +++ b/basic/source/sbx/sbxvar.cxx @@ -408,7 +408,7 @@ void SbxVariable::SetParent( SbxObject* p ) { #ifdef DBG_UTIL // Will the parent of a SbxObject be set? - if (p) + if (p && dynamic_cast<SbxObject*>(this)) { // then this had to be a child of the new parent bool bFound = false; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits