diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-03-11 09:06:08 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-03-11 09:58:36 +0000 |
commit | 556373c41fddbac6cbee1c89e7707631270a1852 (patch) | |
tree | 026862690693419beb8810fdc6671ae30c72a026 /sfx2 | |
parent | 62b124b2704adf11a63681164d05a8eb49dfb105 (diff) |
V668 no sense in testing the result of new against null
Change-Id: I4a33bd92fc8448638a4bfe1eab7e5041a4c5cc39
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/doc/graphhelp.cxx | 89 |
1 files changed, 41 insertions, 48 deletions
diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx index 27411314f978..084bb1093c5e 100644 --- a/sfx2/source/doc/graphhelp.cxx +++ b/sfx2/source/doc/graphhelp.cxx @@ -61,14 +61,11 @@ SvMemoryStream* GraphicHelper::getFormatStrFromGDI_Impl( const GDIMetaFile* pGDI if ( pGDIMeta ) { SvMemoryStream* pStream = new SvMemoryStream( 65535, 65535 ); - if ( pStream ) - { - Graphic aGraph( *pGDIMeta ); - if ( GraphicConverter::Export( *pStream, aGraph, nFormat ) == 0 ) - pResult = pStream; - else - delete pStream; - } + Graphic aGraph( *pGDIMeta ); + if ( GraphicConverter::Export( *pStream, aGraph, nFormat ) == 0 ) + pResult = pStream; + else + delete pStream; } return pResult; @@ -120,60 +117,56 @@ void* GraphicHelper::getWinMetaFileFromGDI_Impl( const GDIMetaFile* pGDIMeta, co if ( pGDIMeta ) { SvMemoryStream* pStream = new SvMemoryStream( 65535, 65535 ); - if ( pStream ) + Graphic aGraph( *pGDIMeta ); + sal_Bool bFailed = (sal_Bool)GraphicConverter::Export( *pStream, aGraph, CVT_WMF ); + pStream->Flush(); + if ( !bFailed ) { - Graphic aGraph( *pGDIMeta ); - sal_Bool bFailed = (sal_Bool)GraphicConverter::Export( *pStream, aGraph, CVT_WMF ); - pStream->Flush(); - if ( !bFailed ) + sal_Int32 nLength = pStream->Seek( STREAM_SEEK_TO_END ); + if ( nLength > 22 ) { - sal_Int32 nLength = pStream->Seek( STREAM_SEEK_TO_END ); - if ( nLength > 22 ) + HMETAFILE hMeta = SetMetaFileBitsEx( nLength - 22, + ( reinterpret_cast< const unsigned char*>( pStream->GetData() ) ) + 22 ); + + if ( hMeta ) { - HMETAFILE hMeta = SetMetaFileBitsEx( nLength - 22, - ( reinterpret_cast< const unsigned char*>( pStream->GetData() ) ) + 22 ); + HGLOBAL hMemory = GlobalAlloc( GMEM_DDESHARE | GMEM_MOVEABLE, sizeof( METAFILEPICT ) ); - if ( hMeta ) + if ( hMemory ) { - HGLOBAL hMemory = GlobalAlloc( GMEM_DDESHARE | GMEM_MOVEABLE, sizeof( METAFILEPICT ) ); + METAFILEPICT* pMF = (METAFILEPICT*)GlobalLock( hMemory ); - if ( hMemory ) + pMF->hMF = hMeta; + pMF->mm = MM_ANISOTROPIC; + + MapMode aMetaMode = pGDIMeta->GetPrefMapMode(); + MapMode aWinMode( MAP_100TH_MM ); + + if ( aWinMode == pGDIMeta->GetPrefMapMode() ) { - METAFILEPICT* pMF = (METAFILEPICT*)GlobalLock( hMemory ); - - pMF->hMF = hMeta; - pMF->mm = MM_ANISOTROPIC; - - MapMode aMetaMode = pGDIMeta->GetPrefMapMode(); - MapMode aWinMode( MAP_100TH_MM ); - - if ( aWinMode == pGDIMeta->GetPrefMapMode() ) - { - pMF->xExt = aMetaSize.Width(); - pMF->yExt = aMetaSize.Height(); - } - else - { - Size aWinSize = OutputDevice::LogicToLogic( Size( aMetaSize.Width(), aMetaSize.Height() ), - pGDIMeta->GetPrefMapMode(), - aWinMode ); - pMF->xExt = aWinSize.Width(); - pMF->yExt = aWinSize.Height(); - } - - GlobalUnlock( hMemory ); - pResult = (void*)hMemory; + pMF->xExt = aMetaSize.Width(); + pMF->yExt = aMetaSize.Height(); } else - DeleteMetaFile( hMeta ); + { + Size aWinSize = OutputDevice::LogicToLogic( Size( aMetaSize.Width(), aMetaSize.Height() ), + pGDIMeta->GetPrefMapMode(), + aWinMode ); + pMF->xExt = aWinSize.Width(); + pMF->yExt = aWinSize.Height(); + } + + GlobalUnlock( hMemory ); + pResult = (void*)hMemory; } + else + DeleteMetaFile( hMeta ); } } - - delete pStream; } - } + delete pStream; + } #endif |