summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-03-11 09:06:08 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-03-11 09:58:36 +0000
commit556373c41fddbac6cbee1c89e7707631270a1852 (patch)
tree026862690693419beb8810fdc6671ae30c72a026 /filter
parent62b124b2704adf11a63681164d05a8eb49dfb105 (diff)
V668 no sense in testing the result of new against null
Change-Id: I4a33bd92fc8448638a4bfe1eab7e5041a4c5cc39
Diffstat (limited to 'filter')
-rw-r--r--filter/source/graphicfilter/icgm/bitmap.cxx255
-rw-r--r--filter/source/graphicfilter/icgm/class1.cxx9
-rw-r--r--filter/source/graphicfilter/ieps/ieps.cxx239
-rw-r--r--filter/source/graphicfilter/ipsd/ipsd.cxx7
-rw-r--r--filter/source/graphicfilter/itga/itga.cxx83
-rw-r--r--filter/source/svg/svgexport.cxx99
6 files changed, 329 insertions, 363 deletions
diff --git a/filter/source/graphicfilter/icgm/bitmap.cxx b/filter/source/graphicfilter/icgm/bitmap.cxx
index b0b844ff106a..a7fcbe514313 100644
--- a/filter/source/graphicfilter/icgm/bitmap.cxx
+++ b/filter/source/graphicfilter/icgm/bitmap.cxx
@@ -44,160 +44,156 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
if ( ImplGetDimensions( rDesc ) && rDesc.mpBuf )
{
- if ( ( rDesc.mpBitmap = new Bitmap( Size( rDesc.mnX, rDesc.mnY ), (sal_uInt16)rDesc.mnDstBitsPerPixel ) ) != NULL )
+ rDesc.mpBitmap = new Bitmap( Size( rDesc.mnX, rDesc.mnY ), (sal_uInt16)rDesc.mnDstBitsPerPixel );
+ if ( ( rDesc.mpAcc = rDesc.mpBitmap->AcquireWriteAccess() ) != NULL )
{
- if ( ( rDesc.mpAcc = rDesc.mpBitmap->AcquireWriteAccess() ) != NULL )
- {
- // the picture may either be read from left to right or right to left, from top to bottom ...
+ // the picture may either be read from left to right or right to left, from top to bottom ...
- long nxCount = rDesc.mnX + 1; // +1 because we are using prefix decreasing
- long nyCount = rDesc.mnY + 1;
- long nx, ny, nxC;
+ long nxCount = rDesc.mnX + 1; // +1 because we are using prefix decreasing
+ long nyCount = rDesc.mnY + 1;
+ long nx, ny, nxC;
- switch ( rDesc.mnDstBitsPerPixel )
+ switch ( rDesc.mnDstBitsPerPixel )
+ {
+ case 1 :
{
- case 1 :
+ if ( rDesc.mnLocalColorPrecision == 1 )
+ ImplSetCurrentPalette( rDesc );
+ else
{
- if ( rDesc.mnLocalColorPrecision == 1 )
- ImplSetCurrentPalette( rDesc );
- else
- {
- rDesc.mpAcc->SetPaletteEntryCount( 2 );
- rDesc.mpAcc->SetPaletteColor( 0, BMCOL( mpCGM->pElement->nBackGroundColor ) );
- rDesc.mpAcc->SetPaletteColor( 1,
- ( mpCGM->pElement->nAspectSourceFlags & ASF_FILLINTERIORSTYLE )
- ? BMCOL( mpCGM->pElement->pFillBundle->GetColor() )
- : BMCOL( mpCGM->pElement->aFillBundle.GetColor() ) ) ;
- }
- for ( ny = 0; --nyCount ; ny++, rDesc.mpBuf += rDesc.mnScanSize )
- {
- nxC = nxCount;
- for ( nx = 0; --nxC; nx++ )
- { // this is not fast, but a one bit/pixel format is rarely used
- rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>( (*( rDesc.mpBuf + (nx >> 3)) >> ((nx & 7)^7))) & 1 );
- }
+ rDesc.mpAcc->SetPaletteEntryCount( 2 );
+ rDesc.mpAcc->SetPaletteColor( 0, BMCOL( mpCGM->pElement->nBackGroundColor ) );
+ rDesc.mpAcc->SetPaletteColor( 1,
+ ( mpCGM->pElement->nAspectSourceFlags & ASF_FILLINTERIORSTYLE )
+ ? BMCOL( mpCGM->pElement->pFillBundle->GetColor() )
+ : BMCOL( mpCGM->pElement->aFillBundle.GetColor() ) ) ;
+ }
+ for ( ny = 0; --nyCount ; ny++, rDesc.mpBuf += rDesc.mnScanSize )
+ {
+ nxC = nxCount;
+ for ( nx = 0; --nxC; nx++ )
+ { // this is not fast, but a one bit/pixel format is rarely used
+ rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>( (*( rDesc.mpBuf + (nx >> 3)) >> ((nx & 7)^7))) & 1 );
}
}
- break;
+ }
+ break;
- case 2 :
+ case 2 :
+ {
+ ImplSetCurrentPalette( rDesc );
+ for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize )
{
- ImplSetCurrentPalette( rDesc );
- for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize )
- {
- nxC = nxCount;
- for ( nx = 0; --nxC; nx++ )
- { // this is not fast, but a two bits/pixel format is rarely used
- rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>( (*(rDesc.mpBuf + (nx >> 2)) >> (((nx & 3)^3) << 1))) & 3 );
- }
+ nxC = nxCount;
+ for ( nx = 0; --nxC; nx++ )
+ { // this is not fast, but a two bits/pixel format is rarely used
+ rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>( (*(rDesc.mpBuf + (nx >> 2)) >> (((nx & 3)^3) << 1))) & 3 );
}
}
- break;
+ }
+ break;
- case 4 :
+ case 4 :
+ {
+ ImplSetCurrentPalette( rDesc );
+ for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize )
{
- ImplSetCurrentPalette( rDesc );
- for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize )
+ nxC = nxCount;
+ sal_Int8 nDat;
+ sal_uInt8* pTemp = rDesc.mpBuf;
+ for ( nx = 0; --nxC; nx++ )
{
- nxC = nxCount;
- sal_Int8 nDat;
- sal_uInt8* pTemp = rDesc.mpBuf;
- for ( nx = 0; --nxC; nx++ )
+ nDat = *pTemp++;
+ rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>(nDat >> 4) );
+ if ( --nxC )
{
- nDat = *pTemp++;
- rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>(nDat >> 4) );
- if ( --nxC )
- {
- nx ++;
- rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>(nDat & 15) );
- }
- else
- break;
+ nx ++;
+ rDesc.mpAcc->SetPixelIndex( ny, nx, static_cast<sal_uInt8>(nDat & 15) );
}
+ else
+ break;
}
}
- break;
+ }
+ break;
- case 8 :
+ case 8 :
+ {
+ ImplSetCurrentPalette( rDesc );
+ for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize )
{
- ImplSetCurrentPalette( rDesc );
- for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize )
+ sal_uInt8* pTemp = rDesc.mpBuf;
+ nxC = nxCount;
+ for ( nx = 0; --nxC; nx++ )
{
- sal_uInt8* pTemp = rDesc.mpBuf;
- nxC = nxCount;
- for ( nx = 0; --nxC; nx++ )
- {
- rDesc.mpAcc->SetPixelIndex( ny, nx, *(pTemp++) );
- }
+ rDesc.mpAcc->SetPixelIndex( ny, nx, *(pTemp++) );
}
}
- break;
+ }
+ break;
- case 24 :
+ case 24 :
+ {
{
+ BitmapColor aBitmapColor;
+ for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize )
{
- BitmapColor aBitmapColor;
- for ( ny = 0; --nyCount; ny++, rDesc.mpBuf += rDesc.mnScanSize )
+ sal_uInt8* pTemp = rDesc.mpBuf;
+ nxC = nxCount;
+ for ( nx = 0; --nxC; nx++ )
{
- sal_uInt8* pTemp = rDesc.mpBuf;
- nxC = nxCount;
- for ( nx = 0; --nxC; nx++ )
- {
- aBitmapColor.SetRed( *pTemp++ );
- aBitmapColor.SetGreen( *pTemp++ );
- aBitmapColor.SetBlue( *pTemp++ );
- rDesc.mpAcc->SetPixel( ny, nx, aBitmapColor );
- }
+ aBitmapColor.SetRed( *pTemp++ );
+ aBitmapColor.SetGreen( *pTemp++ );
+ aBitmapColor.SetBlue( *pTemp++ );
+ rDesc.mpAcc->SetPixel( ny, nx, aBitmapColor );
}
}
}
- break;
}
- double nX = rDesc.mnR.X - rDesc.mnQ.X;
- double nY = rDesc.mnR.Y - rDesc.mnQ.Y;
+ break;
+ }
+ double nX = rDesc.mnR.X - rDesc.mnQ.X;
+ double nY = rDesc.mnR.Y - rDesc.mnQ.Y;
- rDesc.mndy = sqrt( nX * nX + nY * nY );
+ rDesc.mndy = sqrt( nX * nX + nY * nY );
- nX = rDesc.mnR.X - rDesc.mnP.X;
- nY = rDesc.mnR.Y - rDesc.mnP.Y;
+ nX = rDesc.mnR.X - rDesc.mnP.X;
+ nY = rDesc.mnR.Y - rDesc.mnP.Y;
- rDesc.mndx = sqrt( nX * nX + nY * nY );
+ rDesc.mndx = sqrt( nX * nX + nY * nY );
- nX = rDesc.mnR.X - rDesc.mnP.X;
- nY = rDesc.mnR.Y - rDesc.mnP.Y;
+ nX = rDesc.mnR.X - rDesc.mnP.X;
+ nY = rDesc.mnR.Y - rDesc.mnP.Y;
- rDesc.mnOrientation = acos( nX / sqrt( nX * nX + nY * nY ) ) * 57.29577951308;
- if ( nY > 0 )
- rDesc.mnOrientation = 360 - rDesc.mnOrientation;
+ rDesc.mnOrientation = acos( nX / sqrt( nX * nX + nY * nY ) ) * 57.29577951308;
+ if ( nY > 0 )
+ rDesc.mnOrientation = 360 - rDesc.mnOrientation;
- nX = rDesc.mnQ.X - rDesc.mnR.X;
- nY = rDesc.mnQ.Y - rDesc.mnR.Y;
+ nX = rDesc.mnQ.X - rDesc.mnR.X;
+ nY = rDesc.mnQ.Y - rDesc.mnR.Y;
- double fAngle = 0.01745329251994 * ( 360 - rDesc.mnOrientation );
- double fSin = sin(fAngle);
- double fCos = cos(fAngle);
- nX = fCos * nX + fSin * nY;
- nY = -( fSin * nX - fCos * nY );
+ double fAngle = 0.01745329251994 * ( 360 - rDesc.mnOrientation );
+ double fSin = sin(fAngle);
+ double fCos = cos(fAngle);
+ nX = fCos * nX + fSin * nY;
+ nY = -( fSin * nX - fCos * nY );
- fAngle = acos( nX / sqrt( nX * nX + nY * nY ) ) * 57.29577951308;
- if ( nY > 0 )
- fAngle = 360 - fAngle;
+ fAngle = acos( nX / sqrt( nX * nX + nY * nY ) ) * 57.29577951308;
+ if ( nY > 0 )
+ fAngle = 360 - fAngle;
- if ( fAngle > 180 ) // is the picture build upwards or downwards ?
- {
- rDesc.mnOrigin = rDesc.mnP;
- }
- else
- {
- rDesc.mbVMirror = true;
- rDesc.mnOrigin = rDesc.mnP;
- rDesc.mnOrigin.X += rDesc.mnQ.X - rDesc.mnR.X;
- rDesc.mnOrigin.Y += rDesc.mnQ.Y - rDesc.mnR.Y;
- }
+ if ( fAngle > 180 ) // is the picture build upwards or downwards ?
+ {
+ rDesc.mnOrigin = rDesc.mnP;
}
else
- rDesc.mbStatus = false;
+ {
+ rDesc.mbVMirror = true;
+ rDesc.mnOrigin = rDesc.mnP;
+ rDesc.mnOrigin.X += rDesc.mnQ.X - rDesc.mnR.X;
+ rDesc.mnOrigin.Y += rDesc.mnQ.Y - rDesc.mnR.Y;
+ }
}
else
rDesc.mbStatus = false;
@@ -358,40 +354,29 @@ void CGMBitmap::ImplInsert( CGMBitmapDescriptor& rSource, CGMBitmapDescriptor& r
rDest.mndy += rSource.mndy;
};
-
-
CGMBitmap* CGMBitmap::GetNext()
{
if ( pCGMBitmapDescriptor->mpBitmap && pCGMBitmapDescriptor->mbStatus )
{
CGMBitmap* pCGMTempBitmap = new CGMBitmap( *mpCGM );
- if ( pCGMTempBitmap )
+ if ( ( (long)pCGMTempBitmap->pCGMBitmapDescriptor->mnOrientation == (long)pCGMBitmapDescriptor->mnOrientation ) &&
+ ( ( ( pCGMTempBitmap->pCGMBitmapDescriptor->mnR.X == pCGMBitmapDescriptor->mnQ.X ) &&
+ ( pCGMTempBitmap->pCGMBitmapDescriptor->mnR.Y == pCGMBitmapDescriptor->mnQ.Y ) ) ||
+ ( ( pCGMTempBitmap->pCGMBitmapDescriptor->mnQ.X == pCGMBitmapDescriptor->mnR.X ) &&
+ ( pCGMTempBitmap->pCGMBitmapDescriptor->mnQ.Y == pCGMBitmapDescriptor->mnR.Y ) ) ) )
{
- if ( ( (long)pCGMTempBitmap->pCGMBitmapDescriptor->mnOrientation == (long)pCGMBitmapDescriptor->mnOrientation ) &&
- ( ( ( pCGMTempBitmap->pCGMBitmapDescriptor->mnR.X == pCGMBitmapDescriptor->mnQ.X ) &&
- ( pCGMTempBitmap->pCGMBitmapDescriptor->mnR.Y == pCGMBitmapDescriptor->mnQ.Y ) ) ||
- ( ( pCGMTempBitmap->pCGMBitmapDescriptor->mnQ.X == pCGMBitmapDescriptor->mnR.X ) &&
- ( pCGMTempBitmap->pCGMBitmapDescriptor->mnQ.Y == pCGMBitmapDescriptor->mnR.Y ) ) ) )
- {
- ImplInsert( *(pCGMTempBitmap->pCGMBitmapDescriptor), *(pCGMBitmapDescriptor) );
- delete pCGMTempBitmap;
- return NULL;
- }
- else // we'll replace the pointers and return the old one
- {
- CGMBitmapDescriptor* pTempBD = pCGMBitmapDescriptor;
- pCGMBitmapDescriptor = pCGMTempBitmap->pCGMBitmapDescriptor;
- pCGMTempBitmap->pCGMBitmapDescriptor = pTempBD;
- return pCGMTempBitmap;
- }
+ ImplInsert( *(pCGMTempBitmap->pCGMBitmapDescriptor), *(pCGMBitmapDescriptor) );
+ delete pCGMTempBitmap;
+ return NULL;
}
- return NULL;
+
+ CGMBitmapDescriptor* pTempBD = pCGMBitmapDescriptor;
+ pCGMBitmapDescriptor = pCGMTempBitmap->pCGMBitmapDescriptor;
+ pCGMTempBitmap->pCGMBitmapDescriptor = pTempBD;
+ return pCGMTempBitmap;
}
else
return NULL;
}
-
-
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/graphicfilter/icgm/class1.cxx b/filter/source/graphicfilter/icgm/class1.cxx
index 1eae8c54e3e6..b43238f5a140 100644
--- a/filter/source/graphicfilter/icgm/class1.cxx
+++ b/filter/source/graphicfilter/icgm/class1.cxx
@@ -166,12 +166,9 @@ void CGM::ImplDoClass1()
if ( mnElementSize > 1 )
{
sal_uInt8* pBuf = new sal_uInt8[ mnElementSize ];
- if ( pBuf )
- {
- memcpy( pBuf, mpSource, mnElementSize );
- maDefRepList.push_back( pBuf );
- maDefRepSizeList.push_back( mnElementSize );
- }
+ memcpy( pBuf, mpSource, mnElementSize );
+ maDefRepList.push_back( pBuf );
+ maDefRepSizeList.push_back( mnElementSize );
}
mnParaSize = mnElementSize;
}
diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx
index 2e5f9a141fa4..3ca015eca050 100644
--- a/filter/source/graphicfilter/ieps/ieps.cxx
+++ b/filter/source/graphicfilter/ieps/ieps.cxx
@@ -596,161 +596,160 @@ GraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
rStream.Seek( nPSStreamPos );
sal_uInt8* pBuf = new sal_uInt8[ nPSSize ];
- if ( pBuf )
+
+ sal_uInt32 nBufStartPos = rStream.Tell();
+ sal_uInt32 nBytesRead = rStream.Read( pBuf, nPSSize );
+ if ( nBytesRead == nPSSize )
{
- sal_uInt32 nBufStartPos = rStream.Tell();
- sal_uInt32 nBytesRead = rStream.Read( pBuf, nPSSize );
- if ( nBytesRead == nPSSize )
+ int nSecurityCount = 32;
+ if ( !bHasPreview ) // if there is no tiff/wmf preview, we will parse for an preview in the eps prolog
{
- int nSecurityCount = 32;
- if ( !bHasPreview ) // if there is no tiff/wmf preview, we will parse for an preview in the eps prolog
+ sal_uInt8* pDest = ImplSearchEntry( pBuf, reinterpret_cast<sal_uInt8 const *>("%%BeginPreview:"), nBytesRead - 32, 15 );
+ if ( pDest )
{
- sal_uInt8* pDest = ImplSearchEntry( pBuf, reinterpret_cast<sal_uInt8 const *>("%%BeginPreview:"), nBytesRead - 32, 15 );
- if ( pDest )
+ pDest += 15;
+ long nWidth = ImplGetNumber( &pDest, nSecurityCount );
+ long nHeight = ImplGetNumber( &pDest, nSecurityCount );
+ long nBitDepth = ImplGetNumber( &pDest, nSecurityCount );
+ long nScanLines = ImplGetNumber( &pDest, nSecurityCount );
+ pDest = ImplSearchEntry( pDest, reinterpret_cast<sal_uInt8 const *>("%"), 16, 1 ); // go to the first Scanline
+ if ( nSecurityCount && pDest && nWidth && nHeight && ( ( nBitDepth == 1 ) || ( nBitDepth == 8 ) ) && nScanLines )
{
- pDest += 15;
- long nWidth = ImplGetNumber( &pDest, nSecurityCount );
- long nHeight = ImplGetNumber( &pDest, nSecurityCount );
- long nBitDepth = ImplGetNumber( &pDest, nSecurityCount );
- long nScanLines = ImplGetNumber( &pDest, nSecurityCount );
- pDest = ImplSearchEntry( pDest, reinterpret_cast<sal_uInt8 const *>("%"), 16, 1 ); // go to the first Scanline
- if ( nSecurityCount && pDest && nWidth && nHeight && ( ( nBitDepth == 1 ) || ( nBitDepth == 8 ) ) && nScanLines )
- {
- rStream.Seek( nBufStartPos + ( pDest - pBuf ) );
+ rStream.Seek( nBufStartPos + ( pDest - pBuf ) );
- Bitmap aBitmap( Size( nWidth, nHeight ), 1 );
- BitmapWriteAccess* pAcc = aBitmap.AcquireWriteAccess();
- if ( pAcc )
+ Bitmap aBitmap( Size( nWidth, nHeight ), 1 );
+ BitmapWriteAccess* pAcc = aBitmap.AcquireWriteAccess();
+ if ( pAcc )
+ {
+ bool bIsValid = true;
+ sal_uInt8 nDat = 0;
+ char nByte;
+ for ( long y = 0; bIsValid && ( y < nHeight ); y++ )
{
- bool bIsValid = true;
- sal_uInt8 nDat = 0;
- char nByte;
- for ( long y = 0; bIsValid && ( y < nHeight ); y++ )
+ int nBitsLeft = 0;
+ for ( long x = 0; x < nWidth; x++ )
{
- int nBitsLeft = 0;
- for ( long x = 0; x < nWidth; x++ )
+ if ( --nBitsLeft < 0 )
{
- if ( --nBitsLeft < 0 )
+ while ( bIsValid && ( nBitsLeft != 7 ) )
{
- while ( bIsValid && ( nBitsLeft != 7 ) )
+ rStream.ReadChar( nByte );
+ switch ( nByte )
{
- rStream.ReadChar( nByte );
- switch ( nByte )
+ case 0x0a :
+ if ( --nScanLines < 0 )
+ bIsValid = false;
+ case 0x09 :
+ case 0x0d :
+ case 0x20 :
+ case 0x25 :
+ break;
+ default:
{
- case 0x0a :
- if ( --nScanLines < 0 )
- bIsValid = false;
- case 0x09 :
- case 0x0d :
- case 0x20 :
- case 0x25 :
- break;
- default:
+ if ( nByte >= '0' )
{
- if ( nByte >= '0' )
+ if ( nByte > '9' )
{
- if ( nByte > '9' )
- {
- nByte &=~0x20; // case none sensitive for hexadecimal values
- nByte -= ( 'A' - 10 );
- if ( nByte > 15 )
- bIsValid = false;
- }
- else
- nByte -= '0';
- nBitsLeft += 4;
- nDat <<= 4;
- nDat |= ( nByte ^ 0xf ); // in epsi a zero bit represents white color
+ nByte &=~0x20; // case none sensitive for hexadecimal values
+ nByte -= ( 'A' - 10 );
+ if ( nByte > 15 )
+ bIsValid = false;
}
else
- bIsValid = false;
+ nByte -= '0';
+ nBitsLeft += 4;
+ nDat <<= 4;
+ nDat |= ( nByte ^ 0xf ); // in epsi a zero bit represents white color
}
- break;
+ else
+ bIsValid = false;
}
+ break;
}
}
- if ( nBitDepth == 1 )
- pAcc->SetPixelIndex( y, x, static_cast<sal_uInt8>(nDat >> nBitsLeft) & 1 );
- else
- {
- pAcc->SetPixelIndex( y, x, nDat ? 1 : 0 ); // nBitDepth == 8
- nBitsLeft = 0;
- }
}
- }
- if ( bIsValid )
- {
- VirtualDevice aVDev;
- GDIMetaFile aMtf;
- Size aSize;
- aVDev.EnableOutput( false );
- aMtf.Record( &aVDev );
- aSize = aBitmap.GetPrefSize();
- if( !aSize.Width() || !aSize.Height() )
- aSize = Application::GetDefaultDevice()->PixelToLogic( aBitmap.GetSizePixel(), MAP_100TH_MM );
+ if ( nBitDepth == 1 )
+ pAcc->SetPixelIndex( y, x, static_cast<sal_uInt8>(nDat >> nBitsLeft) & 1 );
else
- aSize = OutputDevice::LogicToLogic( aSize, aBitmap.GetPrefMapMode(), MAP_100TH_MM );
- aVDev.DrawBitmap( Point(), aSize, aBitmap );
- aMtf.Stop();
- aMtf.WindStart();
- aMtf.SetPrefMapMode( MAP_100TH_MM );
- aMtf.SetPrefSize( aSize );
- aGraphic = aMtf;
- bHasPreview = bRetValue = true;
+ {
+ pAcc->SetPixelIndex( y, x, nDat ? 1 : 0 ); // nBitDepth == 8
+ nBitsLeft = 0;
+ }
}
- aBitmap.ReleaseAccess( pAcc );
}
+ if ( bIsValid )
+ {
+ VirtualDevice aVDev;
+ GDIMetaFile aMtf;
+ Size aSize;
+ aVDev.EnableOutput( false );
+ aMtf.Record( &aVDev );
+ aSize = aBitmap.GetPrefSize();
+ if( !aSize.Width() || !aSize.Height() )
+ aSize = Application::GetDefaultDevice()->PixelToLogic( aBitmap.GetSizePixel(), MAP_100TH_MM );
+ else
+ aSize = OutputDevice::LogicToLogic( aSize, aBitmap.GetPrefMapMode(), MAP_100TH_MM );
+ aVDev.DrawBitmap( Point(), aSize, aBitmap );
+ aMtf.Stop();
+ aMtf.WindStart();
+ aMtf.SetPrefMapMode( MAP_100TH_MM );
+ aMtf.SetPrefSize( aSize );
+ aGraphic = aMtf;
+ bHasPreview = bRetValue = true;
+ }
+ aBitmap.ReleaseAccess( pAcc );
}
}
}
+ }
- sal_uInt8* pDest = ImplSearchEntry( pBuf, reinterpret_cast<sal_uInt8 const *>("%%BoundingBox:"), nBytesRead, 14 );
- if ( pDest )
+ sal_uInt8* pDest = ImplSearchEntry( pBuf, reinterpret_cast<sal_uInt8 const *>("%%BoundingBox:"), nBytesRead, 14 );
+ if ( pDest )
+ {
+ nSecurityCount = 100;
+ long nNumb[4];
+ nNumb[0] = nNumb[1] = nNumb[2] = nNumb[3] = 0;
+ pDest += 14;
+ for ( int i = 0; ( i < 4 ) && nSecurityCount; i++ )
{
- nSecurityCount = 100;
- long nNumb[4];
- nNumb[0] = nNumb[1] = nNumb[2] = nNumb[3] = 0;
- pDest += 14;
- for ( int i = 0; ( i < 4 ) && nSecurityCount; i++ )
- {
- nNumb[ i ] = ImplGetNumber( &pDest, nSecurityCount );
- }
- if ( nSecurityCount)
- {
- bGraphicLinkCreated = true;
- GfxLink aGfxLink( pBuf, nPSSize, GFX_LINK_TYPE_EPS_BUFFER, true ) ;
- GDIMetaFile aMtf;
-
- long nWidth = nNumb[2] - nNumb[0] + 1;
- long nHeight = nNumb[3] - nNumb[1] + 1;
+ nNumb[ i ] = ImplGetNumber( &pDest, nSecurityCount );
+ }
+ if ( nSecurityCount)
+ {
+ bGraphicLinkCreated = true;
+ GfxLink aGfxLink( pBuf, nPSSize, GFX_LINK_TYPE_EPS_BUFFER, true ) ;
+ GDIMetaFile aMtf;
- // if there is no preview -> try with gs to make one
- if( !bHasPreview )
- {
- bHasPreview = RenderAsEMF(pBuf, nBytesRead, aGraphic);
- if (!bHasPreview)
- bHasPreview = RenderAsBMP(pBuf, nBytesRead, aGraphic);
- }
+ long nWidth = nNumb[2] - nNumb[0] + 1;
+ long nHeight = nNumb[3] - nNumb[1] + 1;
- // if there is no preview -> make a red box
- if( !bHasPreview )
- {
- MakePreview(pBuf, nBytesRead, nWidth, nHeight,
- aGraphic);
- }
+ // if there is no preview -> try with gs to make one
+ if( !bHasPreview )
+ {
+ bHasPreview = RenderAsEMF(pBuf, nBytesRead, aGraphic);
+ if (!bHasPreview)
+ bHasPreview = RenderAsBMP(pBuf, nBytesRead, aGraphic);
+ }
- aMtf.AddAction( (MetaAction*)( new MetaEPSAction( Point(), Size( nWidth, nHeight ),
- aGfxLink, aGraphic.GetGDIMetaFile() ) ) );
- CreateMtfReplacementAction( aMtf, rStream, nOrigPos, nPSSize, nPosWMF, nSizeWMF, nPosTIFF, nSizeTIFF );
- aMtf.WindStart();
- aMtf.SetPrefMapMode( MAP_POINT );
- aMtf.SetPrefSize( Size( nWidth, nHeight ) );
- rGraphic = aMtf;
- bRetValue = true;
+ // if there is no preview -> make a red box
+ if( !bHasPreview )
+ {
+ MakePreview(pBuf, nBytesRead, nWidth, nHeight,
+ aGraphic);
}
+
+ aMtf.AddAction( (MetaAction*)( new MetaEPSAction( Point(), Size( nWidth, nHeight ),
+ aGfxLink, aGraphic.GetGDIMetaFile() ) ) );
+ CreateMtfReplacementAction( aMtf, rStream, nOrigPos, nPSSize, nPosWMF, nSizeWMF, nPosTIFF, nSizeTIFF );
+ aMtf.WindStart();
+ aMtf.SetPrefMapMode( MAP_POINT );
+ aMtf.SetPrefSize( Size( nWidth, nHeight ) );
+ rGraphic = aMtf;
+ bRetValue = true;
}
}
}
+
if ( !bGraphicLinkCreated )
delete[] pBuf;
}
diff --git a/filter/source/graphicfilter/ipsd/ipsd.cxx b/filter/source/graphicfilter/ipsd/ipsd.cxx
index 64b7233a9384..c3c767cf0e45 100644
--- a/filter/source/graphicfilter/ipsd/ipsd.cxx
+++ b/filter/source/graphicfilter/ipsd/ipsd.cxx
@@ -177,9 +177,6 @@ bool PSDReader::ImplReadHeader()
mpFileHeader = new PSDFileHeader;
- if ( !mpFileHeader )
- return false;
-
m_rPSD.ReadUInt32( mpFileHeader->nSignature ).ReadUInt16( mpFileHeader->nVersion ).ReadUInt32( mpFileHeader->nPad1 ). ReadUInt16( mpFileHeader->nPad2 ).ReadUInt16( mpFileHeader->nChannels ).ReadUInt32( mpFileHeader->nRows ). ReadUInt32( mpFileHeader->nColumns ).ReadUInt16( mpFileHeader->nDepth ).ReadUInt16( mpFileHeader->nMode );
if ( ( mpFileHeader->nSignature != 0x38425053 ) || ( mpFileHeader->nVersion != 1 ) )
@@ -240,8 +237,6 @@ bool PSDReader::ImplReadHeader()
if ( nColorLength != 768 ) // we need the color map
return false;
mpPalette = new sal_uInt8[ 768 ];
- if ( mpPalette == NULL )
- return false;
m_rPSD.Read( mpPalette, 768 );
}
break;
@@ -255,8 +250,6 @@ bool PSDReader::ImplReadHeader()
if ( nColorLength )
return false;
mpPalette = new sal_uInt8[ 768 ];
- if ( mpPalette == NULL )
- return false;
for ( sal_uInt16 i = 0; i < 256; i++ )
{
mpPalette[ i ] = mpPalette[ i + 256 ] = mpPalette[ i + 512 ] = (sal_uInt8)i;
diff --git a/filter/source/graphicfilter/itga/itga.cxx b/filter/source/graphicfilter/itga/itga.cxx
index 23f9163873d5..29dc073303dc 100644
--- a/filter/source/graphicfilter/itga/itga.cxx
+++ b/filter/source/graphicfilter/itga/itga.cxx
@@ -175,8 +175,6 @@ bool TGAReader::ReadTGA(Graphic & rGraphic)
bool TGAReader::ImplReadHeader()
{
mpFileHeader = new TGAFileHeader;
- if ( mpFileHeader == NULL )
- return false;
m_rTGA.ReadUChar( mpFileHeader->nImageIDLength ).ReadUChar( mpFileHeader->nColorMapType ).ReadUChar( mpFileHeader->nImageType ). ReadUInt16( mpFileHeader->nColorMapFirstEntryIndex ).ReadUInt16( mpFileHeader->nColorMapLength ).ReadUChar( mpFileHeader->nColorMapEntrySize ). ReadUInt16( mpFileHeader->nColorMapXOrigin ).ReadUInt16( mpFileHeader->nColorMapYOrigin ).ReadUInt16( mpFileHeader->nImageWidth ). ReadUInt16( mpFileHeader->nImageHeight ).ReadUChar( mpFileHeader->nPixelDepth ).ReadUChar( mpFileHeader->nImageDescriptor );
@@ -190,56 +188,53 @@ bool TGAReader::ImplReadHeader()
// first we want to get the version
mpFileFooter = new TGAFileFooter; // read the TGA-File-Footer to determine whether
- if ( mpFileFooter ) // we got an old TGA format or the new one
- {
- sal_uLong nCurStreamPos = m_rTGA.Tell();
- m_rTGA.Seek( STREAM_SEEK_TO_END );
- sal_uLong nTemp = m_rTGA.Tell();
- m_rTGA.Seek( nTemp - SizeOfTGAFileFooter );
+ // we got an old TGA format or the new one
+
+ sal_uLong nCurStreamPos = m_rTGA.Tell();
+ m_rTGA.Seek( STREAM_SEEK_TO_END );
+ sal_uLong nTemp = m_rTGA.Tell();
+ m_rTGA.Seek( nTemp - SizeOfTGAFileFooter );
+
+ m_rTGA.ReadUInt32( mpFileFooter->nExtensionFileOffset ).ReadUInt32( mpFileFooter->nDeveloperDirectoryOffset ). ReadUInt32( mpFileFooter->nSignature[0] ).ReadUInt32( mpFileFooter->nSignature[1] ).ReadUInt32( mpFileFooter->nSignature[2] ). ReadUInt32( mpFileFooter->nSignature[3] ).ReadUChar( mpFileFooter->nPadByte ).ReadUChar( mpFileFooter->nStringTerminator );
- m_rTGA.ReadUInt32( mpFileFooter->nExtensionFileOffset ).ReadUInt32( mpFileFooter->nDeveloperDirectoryOffset ). ReadUInt32( mpFileFooter->nSignature[0] ).ReadUInt32( mpFileFooter->nSignature[1] ).ReadUInt32( mpFileFooter->nSignature[2] ). ReadUInt32( mpFileFooter->nSignature[3] ).ReadUChar( mpFileFooter->nPadByte ).ReadUChar( mpFileFooter->nStringTerminator );
+ if ( !m_rTGA.good())
+ return false;
+
+ // check for sal_True, VISI, ON-X, FILE in the signatures
+ if ( mpFileFooter->nSignature[ 0 ] == (('T'<<24)|('R'<<16)|('U'<<8)|'E') &&
+ mpFileFooter->nSignature[ 1 ] == (('V'<<24)|('I'<<16)|('S'<<8)|'I') &&
+ mpFileFooter->nSignature[ 2 ] == (('O'<<24)|('N'<<16)|('-'<<8)|'X') &&
+ mpFileFooter->nSignature[ 3 ] == (('F'<<24)|('I'<<16)|('L'<<8)|'E') )
+ {
+ mpExtension = new TGAExtension;
+ m_rTGA.Seek( mpFileFooter->nExtensionFileOffset );
+ m_rTGA.ReadUInt16( mpExtension->nExtensionSize );
if ( !m_rTGA.good())
return false;
-
- // check for sal_True, VISI, ON-X, FILE in the signatures
- if ( mpFileFooter->nSignature[ 0 ] == (('T'<<24)|('R'<<16)|('U'<<8)|'E') &&
- mpFileFooter->nSignature[ 1 ] == (('V'<<24)|('I'<<16)|('S'<<8)|'I') &&
- mpFileFooter->nSignature[ 2 ] == (('O'<<24)|('N'<<16)|('-'<<8)|'X') &&
- mpFileFooter->nSignature[ 3 ] == (('F'<<24)|('I'<<16)|('L'<<8)|'E') )
+ if ( mpExtension->nExtensionSize >= SizeOfTGAExtension )
{
- mpExtension = new TGAExtension;
- if ( mpExtension )
- {
- m_rTGA.Seek( mpFileFooter->nExtensionFileOffset );
- m_rTGA.ReadUInt16( mpExtension->nExtensionSize );
- if ( !m_rTGA.good())
- return false;
- if ( mpExtension->nExtensionSize >= SizeOfTGAExtension )
- {
- mnTGAVersion = 2;
-
- m_rTGA.Read( mpExtension->sAuthorName, 41 );
- m_rTGA.Read( mpExtension->sAuthorComment, 324 );
- m_rTGA.Read( mpExtension->sDateTimeStamp, 12 );
- m_rTGA.Read( mpExtension->sJobNameID, 12 );
- m_rTGA.ReadChar( mpExtension->sJobNameID[ 0 ] ).ReadChar( mpExtension->sJobNameID[ 1 ] ).ReadChar( mpExtension->sJobNameID[ 2 ] );
- m_rTGA.Read( mpExtension->sSoftwareID, 41 );
- m_rTGA.ReadUInt16( mpExtension->nSoftwareVersionNumber ).ReadUChar( mpExtension->nSoftwareVersionLetter )
- .ReadUInt32( mpExtension->nKeyColor ).ReadUInt16( mpExtension->nPixelAspectRatioNumerator )
- .ReadUInt16( mpExtension->nPixelAspectRatioDeNumerator ).ReadUInt16( mpExtension->nGammaValueNumerator )
- .ReadUInt16( mpExtension->nGammaValueDeNumerator ).ReadUInt32( mpExtension->nColorCorrectionOffset )
- .ReadUInt32( mpExtension->nPostageStampOffset ).ReadUInt32( mpExtension->nScanLineOffset )
- .ReadUChar( mpExtension->nAttributesType );
-
- if ( !m_rTGA.good())
- return false;
- }
- }
+ mnTGAVersion = 2;
+
+ m_rTGA.Read( mpExtension->sAuthorName, 41 );
+ m_rTGA.Read( mpExtension->sAuthorComment, 324 );
+ m_rTGA.Read( mpExtension->sDateTimeStamp, 12 );
+ m_rTGA.Read( mpExtension->sJobNameID, 12 );
+ m_rTGA.ReadChar( mpExtension->sJobNameID[ 0 ] ).ReadChar( mpExtension->sJobNameID[ 1 ] ).ReadChar( mpExtension->sJobNameID[ 2 ] );
+ m_rTGA.Read( mpExtension->sSoftwareID, 41 );
+ m_rTGA.ReadUInt16( mpExtension->nSoftwareVersionNumber ).ReadUChar( mpExtension->nSoftwareVersionLetter )
+ .ReadUInt32( mpExtension->nKeyColor ).ReadUInt16( mpExtension->nPixelAspectRatioNumerator )
+ .ReadUInt16( mpExtension->nPixelAspectRatioDeNumerator ).ReadUInt16( mpExtension->nGammaValueNumerator )
+ .ReadUInt16( mpExtension->nGammaValueDeNumerator ).ReadUInt32( mpExtension->nColorCorrectionOffset )
+ .ReadUInt32( mpExtension->nPostageStampOffset ).ReadUInt32( mpExtension->nScanLineOffset )
+ .ReadUChar( mpExtension->nAttributesType );
+
+ if ( !m_rTGA.good())
+ return false;
}
- m_rTGA.Seek( nCurStreamPos );
}
+ m_rTGA.Seek( nCurStreamPos );
// using the TGA file specification this was the correct form but adobe photoshop sets nImageDescriptor
// equal to nPixelDepth
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index efe3e8ccef83..d21260ba4510 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -570,73 +570,70 @@ bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
// mpSVGExport = new SVGExport( xDocHandler );
mpSVGExport = new SVGExport( xContext, xDocHandler, maFilterData );
- if( mpSVGExport != NULL )
- {
- // xSVGExport is set up only to manage the life-time of the object pointed by mpSVGExport,
- // and in order to prevent that it is destroyed when passed to AnimationExporter.
- Reference< XInterface > xSVGExport = static_cast< ::com::sun::star::document::XFilter* >( mpSVGExport );
+ // xSVGExport is set up only to manage the life-time of the object pointed by mpSVGExport,
+ // and in order to prevent that it is destroyed when passed to AnimationExporter.
+ Reference< XInterface > xSVGExport = static_cast< ::com::sun::star::document::XFilter* >( mpSVGExport );
+
+ // create an id for each draw page
+ for( sal_Int32 i = 0; i < mSelectedPages.getLength(); ++i )
+ implRegisterInterface( mSelectedPages[i] );
- // create an id for each draw page
- for( sal_Int32 i = 0; i < mSelectedPages.getLength(); ++i )
- implRegisterInterface( mSelectedPages[i] );
+ // create an id for each master page
+ for( sal_Int32 i = 0; i < mMasterPageTargets.getLength(); ++i )
+ implRegisterInterface( mMasterPageTargets[i] );
- // create an id for each master page
- for( sal_Int32 i = 0; i < mMasterPageTargets.getLength(); ++i )
- implRegisterInterface( mMasterPageTargets[i] );
+ try
+ {
+ mxDefaultPage = mSelectedPages[0];
- try
+ if( mxDefaultPage.is() )
{
- mxDefaultPage = mSelectedPages[0];
+ SvxDrawPage* pSvxDrawPage = SvxDrawPage::getImplementation( mxDefaultPage );
- if( mxDefaultPage.is() )
+ if( pSvxDrawPage )
{
- SvxDrawPage* pSvxDrawPage = SvxDrawPage::getImplementation( mxDefaultPage );
+ mpDefaultSdrPage = pSvxDrawPage->GetSdrPage();
+ mpSdrModel = mpDefaultSdrPage->GetModel();
- if( pSvxDrawPage )
+ if( mpSdrModel )
{
- mpDefaultSdrPage = pSvxDrawPage->GetSdrPage();
- mpSdrModel = mpDefaultSdrPage->GetModel();
-
- if( mpSdrModel )
- {
- SdrOutliner& rOutl = mpSdrModel->GetDrawOutliner(NULL);
+ SdrOutliner& rOutl = mpSdrModel->GetDrawOutliner(NULL);
- maOldFieldHdl = rOutl.GetCalcFieldValueHdl();
- maNewFieldHdl = LINK(this, SVGFilter, CalcFieldHdl);
- rOutl.SetCalcFieldValueHdl(maNewFieldHdl);
- }
+ maOldFieldHdl = rOutl.GetCalcFieldValueHdl();
+ maNewFieldHdl = LINK(this, SVGFilter, CalcFieldHdl);
+ rOutl.SetCalcFieldValueHdl(maNewFieldHdl);
}
- bRet = implExportDocument();
}
+ bRet = implExportDocument();
}
- catch( ... )
- {
- delete mpSVGDoc, mpSVGDoc = NULL;
- OSL_FAIL( "Exception caught" );
- }
+ }
+ catch( ... )
+ {
+ delete mpSVGDoc, mpSVGDoc = NULL;
+ OSL_FAIL( "Exception caught" );
+ }
- if( mpSdrModel )
+ if( mpSdrModel )
+ {
+ //fdo#62682 The maNewFieldHdl can end up getting copied
+ //into various other outliners which live past this
+ //method, so get the full list of outliners and restore
+ //the maOldFieldHdl for all that have ended up using
+ //maNewFieldHdl
+ std::vector<SdrOutliner*> aOutliners(mpSdrModel->GetActiveOutliners());
+ for (auto aIter = aOutliners.begin(); aIter != aOutliners.end(); ++aIter)
{
- //fdo#62682 The maNewFieldHdl can end up getting copied
- //into various other outliners which live past this
- //method, so get the full list of outliners and restore
- //the maOldFieldHdl for all that have ended up using
- //maNewFieldHdl
- std::vector<SdrOutliner*> aOutliners(mpSdrModel->GetActiveOutliners());
- for (auto aIter = aOutliners.begin(); aIter != aOutliners.end(); ++aIter)
- {
- SdrOutliner* pOutliner = *aIter;
- if (maNewFieldHdl == pOutliner->GetCalcFieldValueHdl())
- pOutliner->SetCalcFieldValueHdl(maOldFieldHdl);
- }
+ SdrOutliner* pOutliner = *aIter;
+ if (maNewFieldHdl == pOutliner->GetCalcFieldValueHdl())
+ pOutliner->SetCalcFieldValueHdl(maOldFieldHdl);
}
-
- delete mpSVGWriter, mpSVGWriter = NULL;
- mpSVGExport = NULL; // pointed object is released by xSVGExport dtor at the end of this scope
- delete mpSVGFontExport, mpSVGFontExport = NULL;
- delete mpObjects, mpObjects = NULL;
- mbPresentation = false;
}
+
+ delete mpSVGWriter, mpSVGWriter = NULL;
+ mpSVGExport = NULL; // pointed object is released by xSVGExport dtor at the end of this scope
+ delete mpSVGFontExport, mpSVGFontExport = NULL;
+ delete mpObjects, mpObjects = NULL;
+ mbPresentation = false;
}
}
}