diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-14 14:47:34 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-14 15:44:42 +0200 |
commit | e6b8be25a6fb5afbd1649489318a7a2d7ae62efa (patch) | |
tree | 4777f3d63cd8b849b9ac32af3fe6def00749a407 /filter/source/graphicfilter | |
parent | a60b18a8c5d5c11c87dbbaaf884de138dfeb6c8f (diff) |
loplugin:flatten in filter
Change-Id: I24861f7401c0046962d536950fe8b2b6bdbad969
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92186
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'filter/source/graphicfilter')
-rw-r--r-- | filter/source/graphicfilter/egif/egif.cxx | 358 | ||||
-rw-r--r-- | filter/source/graphicfilter/egif/giflzwc.cxx | 122 | ||||
-rw-r--r-- | filter/source/graphicfilter/eps/eps.cxx | 222 | ||||
-rw-r--r-- | filter/source/graphicfilter/icgm/actimpr.cxx | 794 | ||||
-rw-r--r-- | filter/source/graphicfilter/icgm/cgm.cxx | 278 | ||||
-rw-r--r-- | filter/source/graphicfilter/idxf/dxf2mtf.cxx | 428 | ||||
-rw-r--r-- | filter/source/graphicfilter/itiff/itiff.cxx | 30 |
7 files changed, 1121 insertions, 1111 deletions
diff --git a/filter/source/graphicfilter/egif/egif.cxx b/filter/source/graphicfilter/egif/egif.cxx index e8e3a6f6894b..13521944c7bb 100644 --- a/filter/source/graphicfilter/egif/egif.cxx +++ b/filter/source/graphicfilter/egif/egif.cxx @@ -173,29 +173,29 @@ bool GIFWriter::WriteGIF(const Graphic& rGraphic, FilterConfigItem* pFilterConfi void GIFWriter::WriteBitmapEx( const BitmapEx& rBmpEx, const Point& rPoint, bool bExtended, long nTimer, Disposal eDisposal ) { - if( CreateAccess( rBmpEx ) ) - { - nActX = rPoint.X(); - nActY = rPoint.Y(); + if( !CreateAccess( rBmpEx ) ) + return; + + nActX = rPoint.X(); + nActY = rPoint.Y(); + + if( bExtended ) + WriteImageExtension( nTimer, eDisposal ); - if( bExtended ) - WriteImageExtension( nTimer, eDisposal ); + if( bStatus ) + { + WriteLocalHeader(); if( bStatus ) { - WriteLocalHeader(); + WritePalette(); if( bStatus ) - { - WritePalette(); - - if( bStatus ) - WriteAccess(); - } + WriteAccess(); } - - DestroyAccess(); } + + DestroyAccess(); } @@ -203,22 +203,22 @@ void GIFWriter::WriteAnimation( const Animation& rAnimation ) { const sal_uInt16 nCount = rAnimation.Count(); - if( nCount ) - { - const double fStep = 100. / nCount; + if( !nCount ) + return; - nMinPercent = 0; - nMaxPercent = static_cast<sal_uInt32>(fStep); + const double fStep = 100. / nCount; - for( sal_uInt16 i = 0; i < nCount; i++ ) - { - const AnimationBitmap& rAnimationBitmap = rAnimation.Get( i ); + nMinPercent = 0; + nMaxPercent = static_cast<sal_uInt32>(fStep); - WriteBitmapEx(rAnimationBitmap.maBitmapEx, rAnimationBitmap.maPositionPixel, true, - rAnimationBitmap.mnWait, rAnimationBitmap.meDisposal ); - nMinPercent = nMaxPercent; - nMaxPercent = static_cast<sal_uInt32>(nMaxPercent + fStep); - } + for( sal_uInt16 i = 0; i < nCount; i++ ) + { + const AnimationBitmap& rAnimationBitmap = rAnimation.Get( i ); + + WriteBitmapEx(rAnimationBitmap.maBitmapEx, rAnimationBitmap.maPositionPixel, true, + rAnimationBitmap.mnWait, rAnimationBitmap.meDisposal ); + nMinPercent = nMaxPercent; + nMaxPercent = static_cast<sal_uInt32>(nMaxPercent + fStep); } } @@ -291,30 +291,30 @@ void GIFWriter::WriteSignature( bool bGIF89a ) void GIFWriter::WriteGlobalHeader( const Size& rSize ) { - if( bStatus ) - { - // 256 colors - const sal_uInt16 nWidth = static_cast<sal_uInt16>(rSize.Width()); - const sal_uInt16 nHeight = static_cast<sal_uInt16>(rSize.Height()); - const sal_uInt8 cFlags = 128 | ( 7 << 4 ); - - // write values - m_rGIF.WriteUInt16( nWidth ); - m_rGIF.WriteUInt16( nHeight ); - m_rGIF.WriteUChar( cFlags ); - m_rGIF.WriteUChar( 0x00 ); - m_rGIF.WriteUChar( 0x00 ); - - // write dummy palette with two entries (black/white); - // we do this only because of a bug in Photoshop, since those can't - // read pictures without a global color palette - m_rGIF.WriteUInt16( 0 ); - m_rGIF.WriteUInt16( 255 ); - m_rGIF.WriteUInt16( 65535 ); - - if( m_rGIF.GetError() ) - bStatus = false; - } + if( !bStatus ) + return; + + // 256 colors + const sal_uInt16 nWidth = static_cast<sal_uInt16>(rSize.Width()); + const sal_uInt16 nHeight = static_cast<sal_uInt16>(rSize.Height()); + const sal_uInt8 cFlags = 128 | ( 7 << 4 ); + + // write values + m_rGIF.WriteUInt16( nWidth ); + m_rGIF.WriteUInt16( nHeight ); + m_rGIF.WriteUChar( cFlags ); + m_rGIF.WriteUChar( 0x00 ); + m_rGIF.WriteUChar( 0x00 ); + + // write dummy palette with two entries (black/white); + // we do this only because of a bug in Photoshop, since those can't + // read pictures without a global color palette + m_rGIF.WriteUInt16( 0 ); + m_rGIF.WriteUInt16( 255 ); + m_rGIF.WriteUInt16( 65535 ); + + if( m_rGIF.GetError() ) + bStatus = false; } @@ -327,26 +327,26 @@ void GIFWriter::WriteLoopExtension( const Animation& rAnimation ) // if only one run should take place // the LoopExtension won't be written // The default in this case is a single run - if( nLoopCount != 1 ) - { - // Netscape interprets the LoopCount - // as the sole number of _repetitions_ - if( nLoopCount ) - nLoopCount--; - - const sal_uInt8 cLoByte = static_cast<sal_uInt8>(nLoopCount); - const sal_uInt8 cHiByte = static_cast<sal_uInt8>( nLoopCount >> 8 ); - - m_rGIF.WriteUChar( 0x21 ); - m_rGIF.WriteUChar( 0xff ); - m_rGIF.WriteUChar( 0x0b ); - m_rGIF.WriteBytes( "NETSCAPE2.0", 11 ); - m_rGIF.WriteUChar( 0x03 ); - m_rGIF.WriteUChar( 0x01 ); - m_rGIF.WriteUChar( cLoByte ); - m_rGIF.WriteUChar( cHiByte ); - m_rGIF.WriteUChar( 0x00 ); - } + if( nLoopCount == 1 ) + return; + + // Netscape interprets the LoopCount + // as the sole number of _repetitions_ + if( nLoopCount ) + nLoopCount--; + + const sal_uInt8 cLoByte = static_cast<sal_uInt8>(nLoopCount); + const sal_uInt8 cHiByte = static_cast<sal_uInt8>( nLoopCount >> 8 ); + + m_rGIF.WriteUChar( 0x21 ); + m_rGIF.WriteUChar( 0xff ); + m_rGIF.WriteUChar( 0x0b ); + m_rGIF.WriteBytes( "NETSCAPE2.0", 11 ); + m_rGIF.WriteUChar( 0x03 ); + m_rGIF.WriteUChar( 0x01 ); + m_rGIF.WriteUChar( cLoByte ); + m_rGIF.WriteUChar( cHiByte ); + m_rGIF.WriteUChar( 0x00 ); } @@ -370,88 +370,88 @@ void GIFWriter::WriteLogSizeExtension( const Size& rSize100 ) void GIFWriter::WriteImageExtension( long nTimer, Disposal eDisposal ) { - if( bStatus ) - { - const sal_uInt16 nDelay = static_cast<sal_uInt16>(nTimer); - sal_uInt8 cFlags = 0; - - // set Transparency-Flag - if( bTransparent ) - cFlags |= 1; - - // set Disposal-value - if( eDisposal == Disposal::Back ) - cFlags |= ( 2 << 2 ); - else if( eDisposal == Disposal::Previous ) - cFlags |= ( 3 << 2 ); - - m_rGIF.WriteUChar( 0x21 ); - m_rGIF.WriteUChar( 0xf9 ); - m_rGIF.WriteUChar( 0x04 ); - m_rGIF.WriteUChar( cFlags ); - m_rGIF.WriteUInt16( nDelay ); - m_rGIF.WriteUChar( m_pAcc->GetBestPaletteIndex( BMP_COL_TRANS ) ); - m_rGIF.WriteUChar( 0x00 ); - - if( m_rGIF.GetError() ) - bStatus = false; - } + if( !bStatus ) + return; + + const sal_uInt16 nDelay = static_cast<sal_uInt16>(nTimer); + sal_uInt8 cFlags = 0; + + // set Transparency-Flag + if( bTransparent ) + cFlags |= 1; + + // set Disposal-value + if( eDisposal == Disposal::Back ) + cFlags |= ( 2 << 2 ); + else if( eDisposal == Disposal::Previous ) + cFlags |= ( 3 << 2 ); + + m_rGIF.WriteUChar( 0x21 ); + m_rGIF.WriteUChar( 0xf9 ); + m_rGIF.WriteUChar( 0x04 ); + m_rGIF.WriteUChar( cFlags ); + m_rGIF.WriteUInt16( nDelay ); + m_rGIF.WriteUChar( m_pAcc->GetBestPaletteIndex( BMP_COL_TRANS ) ); + m_rGIF.WriteUChar( 0x00 ); + + if( m_rGIF.GetError() ) + bStatus = false; } void GIFWriter::WriteLocalHeader() { - if( bStatus ) - { - const sal_uInt16 nPosX = static_cast<sal_uInt16>(nActX); - const sal_uInt16 nPosY = static_cast<sal_uInt16>(nActY); - const sal_uInt16 nWidth = static_cast<sal_uInt16>(m_pAcc->Width()); - const sal_uInt16 nHeight = static_cast<sal_uInt16>(m_pAcc->Height()); - sal_uInt8 cFlags = static_cast<sal_uInt8>( m_pAcc->GetBitCount() - 1 ); - - // set Interlaced-Flag - if( nInterlaced ) - cFlags |= 0x40; - - // set Flag for the local color palette - cFlags |= 0x80; - - m_rGIF.WriteUChar( 0x2c ); - m_rGIF.WriteUInt16( nPosX ); - m_rGIF.WriteUInt16( nPosY ); - m_rGIF.WriteUInt16( nWidth ); - m_rGIF.WriteUInt16( nHeight ); - m_rGIF.WriteUChar( cFlags ); - - if( m_rGIF.GetError() ) - bStatus = false; - } + if( !bStatus ) + return; + + const sal_uInt16 nPosX = static_cast<sal_uInt16>(nActX); + const sal_uInt16 nPosY = static_cast<sal_uInt16>(nActY); + const sal_uInt16 nWidth = static_cast<sal_uInt16>(m_pAcc->Width()); + const sal_uInt16 nHeight = static_cast<sal_uInt16>(m_pAcc->Height()); + sal_uInt8 cFlags = static_cast<sal_uInt8>( m_pAcc->GetBitCount() - 1 ); + + // set Interlaced-Flag + if( nInterlaced ) + cFlags |= 0x40; + + // set Flag for the local color palette + cFlags |= 0x80; + + m_rGIF.WriteUChar( 0x2c ); + m_rGIF.WriteUInt16( nPosX ); + m_rGIF.WriteUInt16( nPosY ); + m_rGIF.WriteUInt16( nWidth ); + m_rGIF.WriteUInt16( nHeight ); + m_rGIF.WriteUChar( cFlags ); + + if( m_rGIF.GetError() ) + bStatus = false; } void GIFWriter::WritePalette() { - if( bStatus && m_pAcc->HasPalette() ) - { - const sal_uInt16 nCount = m_pAcc->GetPaletteEntryCount(); - const sal_uInt16 nMaxCount = ( 1 << m_pAcc->GetBitCount() ); + if( !(bStatus && m_pAcc->HasPalette()) ) + return; - for ( sal_uInt16 i = 0; i < nCount; i++ ) - { - const BitmapColor& rColor = m_pAcc->GetPaletteColor( i ); - - m_rGIF.WriteUChar( rColor.GetRed() ); - m_rGIF.WriteUChar( rColor.GetGreen() ); - m_rGIF.WriteUChar( rColor.GetBlue() ); - } + const sal_uInt16 nCount = m_pAcc->GetPaletteEntryCount(); + const sal_uInt16 nMaxCount = ( 1 << m_pAcc->GetBitCount() ); - // fill up the rest with 0 - if( nCount < nMaxCount ) - m_rGIF.SeekRel( ( nMaxCount - nCount ) * 3 ); + for ( sal_uInt16 i = 0; i < nCount; i++ ) + { + const BitmapColor& rColor = m_pAcc->GetPaletteColor( i ); - if( m_rGIF.GetError() ) - bStatus = false; + m_rGIF.WriteUChar( rColor.GetRed() ); + m_rGIF.WriteUChar( rColor.GetGreen() ); + m_rGIF.WriteUChar( rColor.GetBlue() ); } + + // fill up the rest with 0 + if( nCount < nMaxCount ) + m_rGIF.SeekRel( ( nMaxCount - nCount ) * 3 ); + + if( m_rGIF.GetError() ) + bStatus = false; } @@ -466,64 +466,64 @@ void GIFWriter::WriteAccess() if( !bNative ) pBuffer.reset(new sal_uInt8[ nWidth ]); - if( bStatus && ( 8 == m_pAcc->GetBitCount() ) && m_pAcc->HasPalette() ) - { - aCompressor.StartCompression( m_rGIF, m_pAcc->GetBitCount() ); + if( !(bStatus && ( 8 == m_pAcc->GetBitCount() ) && m_pAcc->HasPalette()) ) + return; + + aCompressor.StartCompression( m_rGIF, m_pAcc->GetBitCount() ); - long nY, nT; + long nY, nT; - for( long i = 0; i < nHeight; ++i ) + for( long i = 0; i < nHeight; ++i ) + { + if( nInterlaced ) { - if( nInterlaced ) + nY = i << 3; + + if( nY >= nHeight ) { - nY = i << 3; + nT = i - ( ( nHeight + 7 ) >> 3 ); + nY= ( nT << 3 ) + 4; if( nY >= nHeight ) { - nT = i - ( ( nHeight + 7 ) >> 3 ); - nY= ( nT << 3 ) + 4; + nT -= ( nHeight + 3 ) >> 3; + nY = ( nT << 2 ) + 2; - if( nY >= nHeight ) + if ( nY >= nHeight ) { - nT -= ( nHeight + 3 ) >> 3; - nY = ( nT << 2 ) + 2; - - if ( nY >= nHeight ) - { - nT -= ( ( nHeight + 1 ) >> 2 ); - nY = ( nT << 1 ) + 1; - } + nT -= ( ( nHeight + 1 ) >> 2 ); + nY = ( nT << 1 ) + 1; } } } - else - nY = i; - - if( bNative ) - aCompressor.Compress( m_pAcc->GetScanline( nY ), nWidth ); - else - { - Scanline pScanline = m_pAcc->GetScanline( nY ); - for( long nX = 0; nX < nWidth; nX++ ) - pBuffer[ nX ] = m_pAcc->GetIndexFromData( pScanline, nX ); - - aCompressor.Compress( pBuffer.get(), nWidth ); - } - - if ( m_rGIF.GetError() ) - bStatus = false; + } + else + nY = i; - MayCallback( nMinPercent + ( nMaxPercent - nMinPercent ) * i / nHeight ); + if( bNative ) + aCompressor.Compress( m_pAcc->GetScanline( nY ), nWidth ); + else + { + Scanline pScanline = m_pAcc->GetScanline( nY ); + for( long nX = 0; nX < nWidth; nX++ ) + pBuffer[ nX ] = m_pAcc->GetIndexFromData( pScanline, nX ); - if( !bStatus ) - break; + aCompressor.Compress( pBuffer.get(), nWidth ); } - aCompressor.EndCompression(); - if ( m_rGIF.GetError() ) bStatus = false; + + MayCallback( nMinPercent + ( nMaxPercent - nMinPercent ) * i / nHeight ); + + if( !bStatus ) + break; } + + aCompressor.EndCompression(); + + if ( m_rGIF.GetError() ) + bStatus = false; } diff --git a/filter/source/graphicfilter/egif/giflzwc.cxx b/filter/source/graphicfilter/egif/giflzwc.cxx index f61f31dac2c5..41c65d2da4c2 100644 --- a/filter/source/graphicfilter/egif/giflzwc.cxx +++ b/filter/source/graphicfilter/egif/giflzwc.cxx @@ -122,89 +122,89 @@ GIFLZWCompressor::~GIFLZWCompressor() void GIFLZWCompressor::StartCompression( SvStream& rGIF, sal_uInt16 nPixelSize ) { - if( !pIDOS ) - { - sal_uInt16 i; + if( pIDOS ) + return; - nDataSize = nPixelSize; + sal_uInt16 i; - if( nDataSize < 2 ) - nDataSize=2; + nDataSize = nPixelSize; - nClearCode=1<<nDataSize; - nEOICode=nClearCode+1; - nTableSize=nEOICode+1; - nCodeSize=nDataSize+1; + if( nDataSize < 2 ) + nDataSize=2; - pIDOS.reset(new GIFImageDataOutputStream(rGIF,static_cast<sal_uInt8>(nDataSize))); - pTable.reset(new GIFLZWCTreeNode[4096]); + nClearCode=1<<nDataSize; + nEOICode=nClearCode+1; + nTableSize=nEOICode+1; + nCodeSize=nDataSize+1; - for (i=0; i<4096; i++) - { - pTable[i].pBrother = pTable[i].pFirstChild = nullptr; - pTable[i].nCode = i; - pTable[i].nValue = static_cast<sal_uInt8>( i ); - } + pIDOS.reset(new GIFImageDataOutputStream(rGIF,static_cast<sal_uInt8>(nDataSize))); + pTable.reset(new GIFLZWCTreeNode[4096]); - pPrefix = nullptr; - pIDOS->WriteBits( nClearCode,nCodeSize ); + for (i=0; i<4096; i++) + { + pTable[i].pBrother = pTable[i].pFirstChild = nullptr; + pTable[i].nCode = i; + pTable[i].nValue = static_cast<sal_uInt8>( i ); } + + pPrefix = nullptr; + pIDOS->WriteBits( nClearCode,nCodeSize ); } void GIFLZWCompressor::Compress(sal_uInt8* pSrc, sal_uInt32 nSize) { - if( pIDOS ) + if( !pIDOS ) + return; + + GIFLZWCTreeNode* p; + sal_uInt16 i; + sal_uInt8 nV; + + if( !pPrefix && nSize ) { - GIFLZWCTreeNode* p; - sal_uInt16 i; - sal_uInt8 nV; + pPrefix=&pTable[*pSrc++]; + nSize--; + } - if( !pPrefix && nSize ) + while( nSize ) + { + nSize--; + nV=*pSrc++; + for( p=pPrefix->pFirstChild; p!=nullptr; p=p->pBrother ) { - pPrefix=&pTable[*pSrc++]; - nSize--; + if (p->nValue==nV) + break; } - while( nSize ) + if( p) + pPrefix=p; + else { - nSize--; - nV=*pSrc++; - for( p=pPrefix->pFirstChild; p!=nullptr; p=p->pBrother ) + pIDOS->WriteBits(pPrefix->nCode,nCodeSize); + + if (nTableSize==4096) { - if (p->nValue==nV) - break; - } + pIDOS->WriteBits(nClearCode,nCodeSize); + + for (i=0; i<nClearCode; i++) + pTable[i].pFirstChild=nullptr; - if( p) - pPrefix=p; + nCodeSize=nDataSize+1; + nTableSize=nEOICode+1; + } else { - pIDOS->WriteBits(pPrefix->nCode,nCodeSize); - - if (nTableSize==4096) - { - pIDOS->WriteBits(nClearCode,nCodeSize); - - for (i=0; i<nClearCode; i++) - pTable[i].pFirstChild=nullptr; - - nCodeSize=nDataSize+1; - nTableSize=nEOICode+1; - } - else - { - if(nTableSize==static_cast<sal_uInt16>(1<<nCodeSize)) - nCodeSize++; - - p=&pTable[nTableSize++]; - p->pBrother=pPrefix->pFirstChild; - pPrefix->pFirstChild=p; - p->nValue=nV; - p->pFirstChild=nullptr; - } - - pPrefix=&pTable[nV]; + if(nTableSize==static_cast<sal_uInt16>(1<<nCodeSize)) + nCodeSize++; + + p=&pTable[nTableSize++]; + p->pBrother=pPrefix->pFirstChild; + pPrefix->pFirstChild=p; + p->nValue=nV; + p->pFirstChild=nullptr; } + + pPrefix=&pTable[nV]; } } } diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx index a96a40ef62ec..ee631ff75a46 100644 --- a/filter/source/graphicfilter/eps/eps.cxx +++ b/filter/source/graphicfilter/eps/eps.cxx @@ -1489,23 +1489,23 @@ void PSWriter::ImplRectFill( const tools::Rectangle & rRect ) void PSWriter::ImplAddPath( const tools::Polygon & rPolygon ) { sal_uInt16 nPointCount = rPolygon.GetSize(); - if ( nPointCount > 1 ) + if ( nPointCount <= 1 ) + return; + + sal_uInt16 i = 1; + ImplMoveTo( rPolygon.GetPoint( 0 ) ); + while ( i < nPointCount ) { - sal_uInt16 i = 1; - ImplMoveTo( rPolygon.GetPoint( 0 ) ); - while ( i < nPointCount ) + if ( ( rPolygon.GetFlags( i ) == PolyFlags::Control ) + && ( ( i + 2 ) < nPointCount ) + && ( rPolygon.GetFlags( i + 1 ) == PolyFlags::Control ) + && ( rPolygon.GetFlags( i + 2 ) != PolyFlags::Control ) ) { - if ( ( rPolygon.GetFlags( i ) == PolyFlags::Control ) - && ( ( i + 2 ) < nPointCount ) - && ( rPolygon.GetFlags( i + 1 ) == PolyFlags::Control ) - && ( rPolygon.GetFlags( i + 2 ) != PolyFlags::Control ) ) - { - ImplCurveTo( rPolygon[ i ], rPolygon[ i + 1 ], rPolygon[ i + 2 ], PS_WRAP ); - i += 3; - } - else - ImplLineTo( rPolygon.GetPoint( i++ ), PS_SPACE | PS_WRAP ); + ImplCurveTo( rPolygon[ i ], rPolygon[ i + 1 ], rPolygon[ i + 2 ], PS_WRAP ); + i += 3; } + else + ImplLineTo( rPolygon.GetPoint( i++ ), PS_SPACE | PS_WRAP ); } } @@ -1537,107 +1537,107 @@ void PSWriter::ImplWriteGradient( const tools::PolyPolygon& rPolyPoly, const Gra void PSWriter::ImplPolyPoly( const tools::PolyPolygon & rPolyPoly, bool bTextOutline ) { sal_uInt16 i, nPolyCount = rPolyPoly.Count(); - if ( nPolyCount ) + if ( !nPolyCount ) + return; + + if ( bFillColor || bTextOutline ) { - if ( bFillColor || bTextOutline ) + if ( bTextOutline ) + ImplWriteTextColor( PS_SPACE ); + else + ImplWriteFillColor( PS_SPACE ); + for ( i = 0; i < nPolyCount; ) { - if ( bTextOutline ) - ImplWriteTextColor( PS_SPACE ); - else - ImplWriteFillColor( PS_SPACE ); - for ( i = 0; i < nPolyCount; ) + ImplAddPath( rPolyPoly.GetObject( i ) ); + if ( ++i < nPolyCount ) { - ImplAddPath( rPolyPoly.GetObject( i ) ); - if ( ++i < nPolyCount ) - { - mpPS->WriteCharPtr( "p" ); - mnCursorPos += 2; - ImplExecMode( PS_RET ); - } + mpPS->WriteCharPtr( "p" ); + mnCursorPos += 2; + ImplExecMode( PS_RET ); } - mpPS->WriteCharPtr( "p ef" ); - mnCursorPos += 4; - ImplExecMode( PS_RET ); - } - if ( bLineColor ) - { - ImplWriteLineColor( PS_SPACE ); - for ( i = 0; i < nPolyCount; i++ ) - ImplAddPath( rPolyPoly.GetObject( i ) ); - ImplClosePathDraw(); } + mpPS->WriteCharPtr( "p ef" ); + mnCursorPos += 4; + ImplExecMode( PS_RET ); + } + if ( bLineColor ) + { + ImplWriteLineColor( PS_SPACE ); + for ( i = 0; i < nPolyCount; i++ ) + ImplAddPath( rPolyPoly.GetObject( i ) ); + ImplClosePathDraw(); } } void PSWriter::ImplPolyLine( const tools::Polygon & rPoly ) { - if ( bLineColor ) + if ( !bLineColor ) + return; + + ImplWriteLineColor( PS_SPACE ); + sal_uInt16 i, nPointCount = rPoly.GetSize(); + if ( !nPointCount ) + return; + + if ( nPointCount > 1 ) { - ImplWriteLineColor( PS_SPACE ); - sal_uInt16 i, nPointCount = rPoly.GetSize(); - if ( nPointCount ) + ImplMoveTo( rPoly.GetPoint( 0 ) ); + i = 1; + while ( i < nPointCount ) { - if ( nPointCount > 1 ) + if ( ( rPoly.GetFlags( i ) == PolyFlags::Control ) + && ( ( i + 2 ) < nPointCount ) + && ( rPoly.GetFlags( i + 1 ) == PolyFlags::Control ) + && ( rPoly.GetFlags( i + 2 ) != PolyFlags::Control ) ) { - ImplMoveTo( rPoly.GetPoint( 0 ) ); - i = 1; - while ( i < nPointCount ) - { - if ( ( rPoly.GetFlags( i ) == PolyFlags::Control ) - && ( ( i + 2 ) < nPointCount ) - && ( rPoly.GetFlags( i + 1 ) == PolyFlags::Control ) - && ( rPoly.GetFlags( i + 2 ) != PolyFlags::Control ) ) - { - ImplCurveTo( rPoly[ i ], rPoly[ i + 1 ], rPoly[ i + 2 ], PS_WRAP ); - i += 3; - } - else - ImplLineTo( rPoly.GetPoint( i++ ), PS_SPACE | PS_WRAP ); - } + ImplCurveTo( rPoly[ i ], rPoly[ i + 1 ], rPoly[ i + 2 ], PS_WRAP ); + i += 3; } - - // #104645# explicitly close path if polygon is closed - if( rPoly[ 0 ] == rPoly[ nPointCount-1 ] ) - ImplClosePathDraw(); else - ImplPathDraw(); + ImplLineTo( rPoly.GetPoint( i++ ), PS_SPACE | PS_WRAP ); } } + + // #104645# explicitly close path if polygon is closed + if( rPoly[ 0 ] == rPoly[ nPointCount-1 ] ) + ImplClosePathDraw(); + else + ImplPathDraw(); } void PSWriter::ImplSetClipRegion( vcl::Region const & rClipRegion ) { - if ( !rClipRegion.IsEmpty() ) - { - RectangleVector aRectangles; - rClipRegion.GetRegionRectangles(aRectangles); + if ( rClipRegion.IsEmpty() ) + return; - for (auto const& rectangle : aRectangles) - { - double nX1(rectangle.Left()); - double nY1(rectangle.Top()); - double nX2(rectangle.Right()); - double nY2(rectangle.Bottom()); - - ImplWriteDouble( nX1 ); - ImplWriteDouble( nY1 ); - ImplWriteByte( 'm' ); - ImplWriteDouble( nX2 ); - ImplWriteDouble( nY1 ); - ImplWriteByte( 'l' ); - ImplWriteDouble( nX2 ); - ImplWriteDouble( nY2 ); - ImplWriteByte( 'l' ); - ImplWriteDouble( nX1 ); - ImplWriteDouble( nY2 ); - ImplWriteByte( 'l' ); - ImplWriteDouble( nX1 ); - ImplWriteDouble( nY1 ); - ImplWriteByte( 'l', PS_SPACE | PS_WRAP ); - } + RectangleVector aRectangles; + rClipRegion.GetRegionRectangles(aRectangles); - ImplWriteLine( "eoclip newpath" ); + for (auto const& rectangle : aRectangles) + { + double nX1(rectangle.Left()); + double nY1(rectangle.Top()); + double nX2(rectangle.Right()); + double nY2(rectangle.Bottom()); + + ImplWriteDouble( nX1 ); + ImplWriteDouble( nY1 ); + ImplWriteByte( 'm' ); + ImplWriteDouble( nX2 ); + ImplWriteDouble( nY1 ); + ImplWriteByte( 'l' ); + ImplWriteDouble( nX2 ); + ImplWriteDouble( nY2 ); + ImplWriteByte( 'l' ); + ImplWriteDouble( nX1 ); + ImplWriteDouble( nY2 ); + ImplWriteByte( 'l' ); + ImplWriteDouble( nX1 ); + ImplWriteDouble( nY1 ); + ImplWriteByte( 'l', PS_SPACE | PS_WRAP ); } + + ImplWriteLine( "eoclip newpath" ); } // possible gfx formats: @@ -1969,31 +1969,31 @@ void PSWriter::ImplWriteCharacter( char nChar ) void PSWriter::ImplWriteString( const OString& rString, VirtualDevice const & rVDev, const long* pDXArry, bool bStretch ) { sal_Int32 nLen = rString.getLength(); - if ( nLen ) + if ( !nLen ) + return; + + if ( pDXArry ) { - if ( pDXArry ) - { - double nx = 0; + double nx = 0; - for (sal_Int32 i = 0; i < nLen; ++i) - { - if ( i > 0 ) - nx = pDXArry[ i - 1 ]; - ImplWriteDouble( bStretch ? nx : rVDev.GetTextWidth( OUString(rString[i]) ) ); - ImplWriteDouble( nx ); - ImplWriteLine( "(", PS_NONE ); - ImplWriteCharacter( rString[i] ); - ImplWriteLine( ") bs" ); - } - } - else + for (sal_Int32 i = 0; i < nLen; ++i) { - ImplWriteByte( '(', PS_NONE ); - for (sal_Int32 i = 0; i < nLen; ++i) - ImplWriteCharacter( rString[i] ); - ImplWriteLine( ") sw" ); + if ( i > 0 ) + nx = pDXArry[ i - 1 ]; + ImplWriteDouble( bStretch ? nx : rVDev.GetTextWidth( OUString(rString[i]) ) ); + ImplWriteDouble( nx ); + ImplWriteLine( "(", PS_NONE ); + ImplWriteCharacter( rString[i] ); + ImplWriteLine( ") bs" ); } } + else + { + ImplWriteByte( '(', PS_NONE ); + for (sal_Int32 i = 0; i < nLen; ++i) + ImplWriteCharacter( rString[i] ); + ImplWriteLine( ") sw" ); + } } void PSWriter::ImplText( const OUString& rUniString, const Point& rPos, const long* pDXArry, sal_Int32 nWidth, VirtualDevice const & rVDev ) diff --git a/filter/source/graphicfilter/icgm/actimpr.cxx b/filter/source/graphicfilter/icgm/actimpr.cxx index d7fe844c066e..604c09862b29 100644 --- a/filter/source/graphicfilter/icgm/actimpr.cxx +++ b/filter/source/graphicfilter/icgm/actimpr.cxx @@ -62,27 +62,27 @@ CGMImpressOutAct::CGMImpressOutAct(CGM& rCGM, const uno::Reference< frame::XMode , mpCGM(&rCGM) , nFinalTextCount(0) { - if ( mpCGM->mbStatus ) - { - bool bStatRet = false; + if ( !mpCGM->mbStatus ) + return; - uno::Reference< drawing::XDrawPagesSupplier > aDrawPageSup( rModel, uno::UNO_QUERY ); - if( aDrawPageSup.is() ) + bool bStatRet = false; + + uno::Reference< drawing::XDrawPagesSupplier > aDrawPageSup( rModel, uno::UNO_QUERY ); + if( aDrawPageSup.is() ) + { + maXDrawPages = aDrawPageSup->getDrawPages(); + if ( maXDrawPages.is() ) { - maXDrawPages = aDrawPageSup->getDrawPages(); - if ( maXDrawPages.is() ) + maXMultiServiceFactory.set( rModel, uno::UNO_QUERY); + if( maXMultiServiceFactory.is() ) { - maXMultiServiceFactory.set( rModel, uno::UNO_QUERY); - if( maXMultiServiceFactory.is() ) - { - maXDrawPage = *o3tl::doAccess<uno::Reference<drawing::XDrawPage>>(maXDrawPages->getByIndex( 0 )); - if ( ImplInitPage() ) - bStatRet = true; - } + maXDrawPage = *o3tl::doAccess<uno::Reference<drawing::XDrawPage>>(maXDrawPages->getByIndex( 0 )); + if ( ImplInitPage() ) + bStatRet = true; } } - mpCGM->mbStatus = bStatRet; } + mpCGM->mbStatus = bStatRet; } CGMImpressOutAct::~CGMImpressOutAct() @@ -312,31 +312,31 @@ void CGMImpressOutAct::ImplSetFillBundle() maXPropSet->setPropertyValue( "LineStyle", uno::Any(eLS) ); - if ( eFS == drawing::FillStyle_HATCH ) - { - drawing::Hatch aHatch; + if ( eFS != drawing::FillStyle_HATCH ) + return; - aHatch.Color = nFillColor; - if ( mpCGM->pElement->maHatchMap.find( nHatchIndex ) != mpCGM->pElement->maHatchMap.end() ) - { - HatchEntry& rHatchEntry = mpCGM->pElement->maHatchMap[ nHatchIndex ]; - switch ( rHatchEntry.HatchStyle ) - { - case 0 : aHatch.Style = drawing::HatchStyle_SINGLE; break; - case 1 : aHatch.Style = drawing::HatchStyle_DOUBLE; break; - case 2 : aHatch.Style = drawing::HatchStyle_TRIPLE; break; - } - aHatch.Distance = rHatchEntry.HatchDistance; - aHatch.Angle = rHatchEntry.HatchAngle; - } - else + drawing::Hatch aHatch; + + aHatch.Color = nFillColor; + if ( mpCGM->pElement->maHatchMap.find( nHatchIndex ) != mpCGM->pElement->maHatchMap.end() ) + { + HatchEntry& rHatchEntry = mpCGM->pElement->maHatchMap[ nHatchIndex ]; + switch ( rHatchEntry.HatchStyle ) { - aHatch.Style = drawing::HatchStyle_TRIPLE; - aHatch.Distance = 10 * ( nHatchIndex & 0x1f ) | 100; - aHatch.Angle = 15 * ( ( nHatchIndex & 0x1f ) - 5 ); + case 0 : aHatch.Style = drawing::HatchStyle_SINGLE; break; + case 1 : aHatch.Style = drawing::HatchStyle_DOUBLE; break; + case 2 : aHatch.Style = drawing::HatchStyle_TRIPLE; break; } - maXPropSet->setPropertyValue( "FillHatch", uno::Any(aHatch) ); + aHatch.Distance = rHatchEntry.HatchDistance; + aHatch.Angle = rHatchEntry.HatchAngle; } + else + { + aHatch.Style = drawing::HatchStyle_TRIPLE; + aHatch.Distance = 10 * ( nHatchIndex & 0x1f ) | 100; + aHatch.Angle = 15 * ( ( nHatchIndex & 0x1f ) - 5 ); + } + maXPropSet->setPropertyValue( "FillHatch", uno::Any(aHatch) ); } void CGMImpressOutAct::ImplSetTextBundle( const uno::Reference< beans::XPropertySet > & rProperty ) @@ -405,31 +405,31 @@ void CGMImpressOutAct::EndGroup() if (!mnGroupLevel) return; --mnGroupLevel; - if ( mnGroupLevel < CGM_OUTACT_MAX_GROUP_LEVEL ) + if ( mnGroupLevel >= CGM_OUTACT_MAX_GROUP_LEVEL ) + return; + + sal_uInt32 nFirstIndex = maGroupLevel[mnGroupLevel]; + if ( nFirstIndex == 0xffffffff ) + nFirstIndex = 0; + sal_uInt32 nCurrentCount = maXShapes->getCount(); + if ( ( nCurrentCount - nFirstIndex ) <= 1 ) + return; + + uno::Reference< drawing::XShapeGrouper > aXShapeGrouper; + aXShapeGrouper.set( maXDrawPage, uno::UNO_QUERY ); + if( !aXShapeGrouper.is() ) + return; + + uno::Reference< drawing::XShapes > aXShapes = drawing::ShapeCollection::create(comphelper::getProcessComponentContext()); + for ( sal_uInt32 i = nFirstIndex; i < nCurrentCount; i++ ) { - sal_uInt32 nFirstIndex = maGroupLevel[mnGroupLevel]; - if ( nFirstIndex == 0xffffffff ) - nFirstIndex = 0; - sal_uInt32 nCurrentCount = maXShapes->getCount(); - if ( ( nCurrentCount - nFirstIndex ) > 1 ) + uno::Reference< drawing::XShape > aXShape = *o3tl::doAccess<uno::Reference<drawing::XShape>>(maXShapes->getByIndex( i )); + if (aXShape.is() ) { - uno::Reference< drawing::XShapeGrouper > aXShapeGrouper; - aXShapeGrouper.set( maXDrawPage, uno::UNO_QUERY ); - if( aXShapeGrouper.is() ) - { - uno::Reference< drawing::XShapes > aXShapes = drawing::ShapeCollection::create(comphelper::getProcessComponentContext()); - for ( sal_uInt32 i = nFirstIndex; i < nCurrentCount; i++ ) - { - uno::Reference< drawing::XShape > aXShape = *o3tl::doAccess<uno::Reference<drawing::XShape>>(maXShapes->getByIndex( i )); - if (aXShape.is() ) - { - aXShapes->add( aXShape ); - } - } - aXShapeGrouper->group( aXShapes ); - } + aXShapes->add( aXShape ); } } + aXShapeGrouper->group( aXShapes ); } void CGMImpressOutAct::EndGrouping() @@ -456,433 +456,433 @@ void CGMImpressOutAct::DrawRectangle( FloatRect const & rFloatRect ) void CGMImpressOutAct::DrawEllipse( FloatPoint const & rCenter, FloatPoint const & rSize, double& rOrientation ) { - if ( ImplCreateShape( "com.sun.star.drawing.EllipseShape" ) ) - { - drawing::CircleKind eCircleKind = drawing::CircleKind_FULL; - uno::Any aAny( &eCircleKind, ::cppu::UnoType<drawing::CircleKind>::get() ); - maXPropSet->setPropertyValue( "CircleKind", aAny ); - - long nXSize = static_cast<long>( rSize.X * 2.0 ); // strange behaviour with an awt::Size of 0 - long nYSize = static_cast<long>( rSize.Y * 2.0 ); - if ( nXSize < 1 ) - nXSize = 1; - if ( nYSize < 1 ) - nYSize = 1; - maXShape->setSize( awt::Size( nXSize, nYSize ) ); - maXShape->setPosition( awt::Point( static_cast<long>( rCenter.X - rSize.X ), static_cast<long>( rCenter.Y - rSize.Y ) ) ); - - if ( rOrientation != 0 ) - { - ImplSetOrientation( rCenter, rOrientation ); - } - ImplSetFillBundle(); + if ( !ImplCreateShape( "com.sun.star.drawing.EllipseShape" ) ) + return; + + drawing::CircleKind eCircleKind = drawing::CircleKind_FULL; + uno::Any aAny( &eCircleKind, ::cppu::UnoType<drawing::CircleKind>::get() ); + maXPropSet->setPropertyValue( "CircleKind", aAny ); + + long nXSize = static_cast<long>( rSize.X * 2.0 ); // strange behaviour with an awt::Size of 0 + long nYSize = static_cast<long>( rSize.Y * 2.0 ); + if ( nXSize < 1 ) + nXSize = 1; + if ( nYSize < 1 ) + nYSize = 1; + maXShape->setSize( awt::Size( nXSize, nYSize ) ); + maXShape->setPosition( awt::Point( static_cast<long>( rCenter.X - rSize.X ), static_cast<long>( rCenter.Y - rSize.Y ) ) ); + + if ( rOrientation != 0 ) + { + ImplSetOrientation( rCenter, rOrientation ); } + ImplSetFillBundle(); } void CGMImpressOutAct::DrawEllipticalArc( FloatPoint const & rCenter, FloatPoint const & rSize, double& rOrientation, sal_uInt32 nType, double& fStartAngle, double& fEndAngle ) { - if ( ImplCreateShape( "com.sun.star.drawing.EllipseShape" ) ) - { - uno::Any aAny; - drawing::CircleKind eCircleKind; + if ( !ImplCreateShape( "com.sun.star.drawing.EllipseShape" ) ) + return; + uno::Any aAny; + drawing::CircleKind eCircleKind; - long nXSize = static_cast<long>( rSize.X * 2.0 ); // strange behaviour with an awt::Size of 0 - long nYSize = static_cast<long>( rSize.Y * 2.0 ); - if ( nXSize < 1 ) - nXSize = 1; - if ( nYSize < 1 ) - nYSize = 1; - maXShape->setSize( awt::Size ( nXSize, nYSize ) ); + long nXSize = static_cast<long>( rSize.X * 2.0 ); // strange behaviour with an awt::Size of 0 + long nYSize = static_cast<long>( rSize.Y * 2.0 ); + if ( nXSize < 1 ) + nXSize = 1; + if ( nYSize < 1 ) + nYSize = 1; - if ( rOrientation != 0 ) - { - fStartAngle = NormAngle360(fStartAngle + rOrientation); - fEndAngle = NormAngle360(fEndAngle + rOrientation); - } - switch( nType ) - { - case 0 : eCircleKind = drawing::CircleKind_SECTION; break; - case 1 : eCircleKind = drawing::CircleKind_CUT; break; - case 2 : eCircleKind = drawing::CircleKind_ARC; break; - default : eCircleKind = drawing::CircleKind_FULL; break; - } - if ( static_cast<long>(fStartAngle) == static_cast<long>(fEndAngle) ) - { - eCircleKind = drawing::CircleKind_FULL; - maXPropSet->setPropertyValue( "CircleKind", uno::Any(eCircleKind) ); - } - else - { - maXPropSet->setPropertyValue( "CircleKind", uno::Any(eCircleKind) ); - maXPropSet->setPropertyValue( "CircleStartAngle", uno::Any(static_cast<sal_Int32>( fStartAngle * 100 )) ); - maXPropSet->setPropertyValue( "CircleEndAngle", uno::Any(static_cast<sal_Int32>( fEndAngle * 100 )) ); - } - maXShape->setPosition( awt::Point( static_cast<long>( rCenter.X - rSize.X ), static_cast<long>( rCenter.Y - rSize.Y ) ) ); - if ( rOrientation != 0 ) - { - ImplSetOrientation( rCenter, rOrientation ); - } - if ( eCircleKind == drawing::CircleKind_ARC ) + maXShape->setSize( awt::Size ( nXSize, nYSize ) ); + + if ( rOrientation != 0 ) + { + fStartAngle = NormAngle360(fStartAngle + rOrientation); + fEndAngle = NormAngle360(fEndAngle + rOrientation); + } + switch( nType ) + { + case 0 : eCircleKind = drawing::CircleKind_SECTION; break; + case 1 : eCircleKind = drawing::CircleKind_CUT; break; + case 2 : eCircleKind = drawing::CircleKind_ARC; break; + default : eCircleKind = drawing::CircleKind_FULL; break; + } + if ( static_cast<long>(fStartAngle) == static_cast<long>(fEndAngle) ) + { + eCircleKind = drawing::CircleKind_FULL; + maXPropSet->setPropertyValue( "CircleKind", uno::Any(eCircleKind) ); + } + else + { + maXPropSet->setPropertyValue( "CircleKind", uno::Any(eCircleKind) ); + maXPropSet->setPropertyValue( "CircleStartAngle", uno::Any(static_cast<sal_Int32>( fStartAngle * 100 )) ); + maXPropSet->setPropertyValue( "CircleEndAngle", uno::Any(static_cast<sal_Int32>( fEndAngle * 100 )) ); + } + maXShape->setPosition( awt::Point( static_cast<long>( rCenter.X - rSize.X ), static_cast<long>( rCenter.Y - rSize.Y ) ) ); + if ( rOrientation != 0 ) + { + ImplSetOrientation( rCenter, rOrientation ); + } + if ( eCircleKind == drawing::CircleKind_ARC ) + { + ImplSetLineBundle(); + } + else + { + ImplSetFillBundle(); + if ( nType == 2 ) { ImplSetLineBundle(); - } - else - { - ImplSetFillBundle(); - if ( nType == 2 ) - { - ImplSetLineBundle(); - aAny <<= drawing::FillStyle_NONE; - maXPropSet->setPropertyValue( "FillStyle", aAny ); - } + aAny <<= drawing::FillStyle_NONE; + maXPropSet->setPropertyValue( "FillStyle", aAny ); } } } void CGMImpressOutAct::DrawBitmap( CGMBitmapDescriptor* pBmpDesc ) { - if ( pBmpDesc->mbStatus && !!pBmpDesc->mxBitmap ) - { - FloatPoint aOrigin = pBmpDesc->mnOrigin; - double fdx = pBmpDesc->mndx; - double fdy = pBmpDesc->mndy; + if ( !(pBmpDesc->mbStatus && !!pBmpDesc->mxBitmap) ) + return; - BmpMirrorFlags nMirr = BmpMirrorFlags::NONE; - if ( pBmpDesc->mbVMirror ) - nMirr |= BmpMirrorFlags::Vertical; - if ( nMirr != BmpMirrorFlags::NONE ) - pBmpDesc->mxBitmap.Mirror( nMirr ); + FloatPoint aOrigin = pBmpDesc->mnOrigin; + double fdx = pBmpDesc->mndx; + double fdy = pBmpDesc->mndy; - mpCGM->ImplMapPoint( aOrigin ); - mpCGM->ImplMapX( fdx ); - mpCGM->ImplMapY( fdy ); + BmpMirrorFlags nMirr = BmpMirrorFlags::NONE; + if ( pBmpDesc->mbVMirror ) + nMirr |= BmpMirrorFlags::Vertical; + if ( nMirr != BmpMirrorFlags::NONE ) + pBmpDesc->mxBitmap.Mirror( nMirr ); - if ( ImplCreateShape( "com.sun.star.drawing.GraphicObjectShape" ) ) - { - maXShape->setSize( awt::Size( static_cast<long>(fdx), static_cast<long>(fdy) ) ); - maXShape->setPosition( awt::Point( static_cast<long>(aOrigin.X), static_cast<long>(aOrigin.Y) ) ); + mpCGM->ImplMapPoint( aOrigin ); + mpCGM->ImplMapX( fdx ); + mpCGM->ImplMapY( fdy ); - if ( pBmpDesc->mnOrientation != 0 ) - { - ImplSetOrientation( aOrigin, pBmpDesc->mnOrientation ); - } + if ( !ImplCreateShape( "com.sun.star.drawing.GraphicObjectShape" ) ) + return; - uno::Reference< awt::XBitmap > xBitmap( VCLUnoHelper::CreateBitmap( pBmpDesc->mxBitmap ) ); - maXPropSet->setPropertyValue( "GraphicObjectFillBitmap", uno::Any(xBitmap) ); - } + maXShape->setSize( awt::Size( static_cast<long>(fdx), static_cast<long>(fdy) ) ); + maXShape->setPosition( awt::Point( static_cast<long>(aOrigin.X), static_cast<long>(aOrigin.Y) ) ); + + if ( pBmpDesc->mnOrientation != 0 ) + { + ImplSetOrientation( aOrigin, pBmpDesc->mnOrientation ); } + + uno::Reference< awt::XBitmap > xBitmap( VCLUnoHelper::CreateBitmap( pBmpDesc->mxBitmap ) ); + maXPropSet->setPropertyValue( "GraphicObjectFillBitmap", uno::Any(xBitmap) ); } void CGMImpressOutAct::DrawPolygon( tools::Polygon& rPoly ) { sal_uInt16 nPoints = rPoly.GetSize(); - if ( ( nPoints > 1 ) && ImplCreateShape( "com.sun.star.drawing.PolyPolygonShape" ) ) - { - drawing::PointSequenceSequence aRetval; + if ( !(( nPoints > 1 ) && ImplCreateShape( "com.sun.star.drawing.PolyPolygonShape" )) ) + return; - // prepare inside polygons - aRetval.realloc( 1 ); + drawing::PointSequenceSequence aRetval; - // get pointer to outside arrays - drawing::PointSequence* pOuterSequence = aRetval.getArray(); + // prepare inside polygons + aRetval.realloc( 1 ); - // make room in arrays - pOuterSequence->realloc(static_cast<sal_Int32>(nPoints)); + // get pointer to outside arrays + drawing::PointSequence* pOuterSequence = aRetval.getArray(); - // get pointer to arrays - awt::Point* pInnerSequence = pOuterSequence->getArray(); + // make room in arrays + pOuterSequence->realloc(static_cast<sal_Int32>(nPoints)); - for( sal_uInt16 n = 0; n < nPoints; n++ ) - *pInnerSequence++ = awt::Point( rPoly[ n ].X(), rPoly[n].Y() ); + // get pointer to arrays + awt::Point* pInnerSequence = pOuterSequence->getArray(); - uno::Any aParam; - aParam <<= aRetval; - maXPropSet->setPropertyValue( "PolyPolygon", aParam ); - ImplSetFillBundle(); - } + for( sal_uInt16 n = 0; n < nPoints; n++ ) + *pInnerSequence++ = awt::Point( rPoly[ n ].X(), rPoly[n].Y() ); + + uno::Any aParam; + aParam <<= aRetval; + maXPropSet->setPropertyValue( "PolyPolygon", aParam ); + ImplSetFillBundle(); } void CGMImpressOutAct::DrawPolyLine( tools::Polygon& rPoly ) { sal_uInt16 nPoints = rPoly.GetSize(); - if ( ( nPoints > 1 ) && ImplCreateShape( "com.sun.star.drawing.PolyLineShape" ) ) - { - drawing::PointSequenceSequence aRetval; + if ( !(( nPoints > 1 ) && ImplCreateShape( "com.sun.star.drawing.PolyLineShape" )) ) + return; - // prepare inside polygons - aRetval.realloc( 1 ); + drawing::PointSequenceSequence aRetval; - // get pointer to outside arrays - drawing::PointSequence* pOuterSequence = aRetval.getArray(); + // prepare inside polygons + aRetval.realloc( 1 ); - // make room in arrays - pOuterSequence->realloc(static_cast<sal_Int32>(nPoints)); + // get pointer to outside arrays + drawing::PointSequence* pOuterSequence = aRetval.getArray(); - // get pointer to arrays - awt::Point* pInnerSequence = pOuterSequence->getArray(); + // make room in arrays + pOuterSequence->realloc(static_cast<sal_Int32>(nPoints)); - for( sal_uInt16 n = 0; n < nPoints; n++ ) - *pInnerSequence++ = awt::Point( rPoly[ n ].X(), rPoly[n].Y() ); + // get pointer to arrays + awt::Point* pInnerSequence = pOuterSequence->getArray(); - uno::Any aParam; - aParam <<= aRetval; - maXPropSet->setPropertyValue( "PolyPolygon", aParam ); - ImplSetLineBundle(); - } + for( sal_uInt16 n = 0; n < nPoints; n++ ) + *pInnerSequence++ = awt::Point( rPoly[ n ].X(), rPoly[n].Y() ); + + uno::Any aParam; + aParam <<= aRetval; + maXPropSet->setPropertyValue( "PolyPolygon", aParam ); + ImplSetLineBundle(); } void CGMImpressOutAct::DrawPolybezier( tools::Polygon& rPolygon ) { sal_uInt16 nPoints = rPolygon.GetSize(); - if ( ( nPoints > 1 ) && ImplCreateShape( "com.sun.star.drawing.OpenBezierShape" ) ) - { - drawing::PolyPolygonBezierCoords aRetval; + if ( !(( nPoints > 1 ) && ImplCreateShape( "com.sun.star.drawing.OpenBezierShape" )) ) + return; - aRetval.Coordinates.realloc( 1 ); - aRetval.Flags.realloc( 1 ); + drawing::PolyPolygonBezierCoords aRetval; - // get pointer to outside arrays - drawing::PointSequence* pOuterSequence = aRetval.Coordinates.getArray(); - drawing::FlagSequence* pOuterFlags = aRetval.Flags.getArray(); + aRetval.Coordinates.realloc( 1 ); + aRetval.Flags.realloc( 1 ); - // make room in arrays - pOuterSequence->realloc( nPoints ); - pOuterFlags->realloc( nPoints ); + // get pointer to outside arrays + drawing::PointSequence* pOuterSequence = aRetval.Coordinates.getArray(); + drawing::FlagSequence* pOuterFlags = aRetval.Flags.getArray(); - awt::Point* pInnerSequence = pOuterSequence->getArray(); - drawing::PolygonFlags* pInnerFlags = pOuterFlags->getArray(); + // make room in arrays + pOuterSequence->realloc( nPoints ); + pOuterFlags->realloc( nPoints ); - for( sal_uInt16 i = 0; i < nPoints; i++ ) - { - *pInnerSequence++ = awt::Point( rPolygon[ i ].X(), rPolygon[ i ].Y() ); - *pInnerFlags++ = static_cast<drawing::PolygonFlags>(rPolygon.GetFlags( i )); - } - uno::Any aParam; - aParam <<= aRetval; - maXPropSet->setPropertyValue( "PolyPolygonBezier", aParam ); - ImplSetLineBundle(); + awt::Point* pInnerSequence = pOuterSequence->getArray(); + drawing::PolygonFlags* pInnerFlags = pOuterFlags->getArray(); + + for( sal_uInt16 i = 0; i < nPoints; i++ ) + { + *pInnerSequence++ = awt::Point( rPolygon[ i ].X(), rPolygon[ i ].Y() ); + *pInnerFlags++ = static_cast<drawing::PolygonFlags>(rPolygon.GetFlags( i )); } + uno::Any aParam; + aParam <<= aRetval; + maXPropSet->setPropertyValue( "PolyPolygonBezier", aParam ); + ImplSetLineBundle(); } void CGMImpressOutAct::DrawPolyPolygon( tools::PolyPolygon const & rPolyPolygon ) { sal_uInt32 nNumPolys = rPolyPolygon.Count(); - if ( nNumPolys && ImplCreateShape( "com.sun.star.drawing.ClosedBezierShape" ) ) - { - drawing::PolyPolygonBezierCoords aRetval; + if ( !(nNumPolys && ImplCreateShape( "com.sun.star.drawing.ClosedBezierShape" )) ) + return; - // prepare inside polygons - aRetval.Coordinates.realloc(static_cast<sal_Int32>(nNumPolys)); - aRetval.Flags.realloc(static_cast<sal_Int32>(nNumPolys)); + drawing::PolyPolygonBezierCoords aRetval; - // get pointer to outside arrays - drawing::PointSequence* pOuterSequence = aRetval.Coordinates.getArray(); - drawing::FlagSequence* pOuterFlags = aRetval.Flags.getArray(); + // prepare inside polygons + aRetval.Coordinates.realloc(static_cast<sal_Int32>(nNumPolys)); + aRetval.Flags.realloc(static_cast<sal_Int32>(nNumPolys)); - for( sal_uInt32 a = 0; a < nNumPolys; a++ ) - { - const tools::Polygon& aPolygon( rPolyPolygon.GetObject( a ) ); - sal_uInt32 nNumPoints = aPolygon.GetSize(); + // get pointer to outside arrays + drawing::PointSequence* pOuterSequence = aRetval.Coordinates.getArray(); + drawing::FlagSequence* pOuterFlags = aRetval.Flags.getArray(); + + for( sal_uInt32 a = 0; a < nNumPolys; a++ ) + { + const tools::Polygon& aPolygon( rPolyPolygon.GetObject( a ) ); + sal_uInt32 nNumPoints = aPolygon.GetSize(); - // make room in arrays - pOuterSequence->realloc(static_cast<sal_Int32>(nNumPoints)); - pOuterFlags->realloc(static_cast<sal_Int32>(nNumPoints)); + // make room in arrays + pOuterSequence->realloc(static_cast<sal_Int32>(nNumPoints)); + pOuterFlags->realloc(static_cast<sal_Int32>(nNumPoints)); - // get pointer to arrays - awt::Point* pInnerSequence = pOuterSequence->getArray(); - drawing::PolygonFlags* pInnerFlags = pOuterFlags->getArray(); + // get pointer to arrays + awt::Point* pInnerSequence = pOuterSequence->getArray(); + drawing::PolygonFlags* pInnerFlags = pOuterFlags->getArray(); - for( sal_uInt32 b = 0; b < nNumPoints; b++ ) - { - *pInnerSequence++ = awt::Point( aPolygon.GetPoint( b ).X(), aPolygon.GetPoint( b ).Y() ) ; - *pInnerFlags++ = static_cast<drawing::PolygonFlags>(aPolygon.GetFlags( b )); - } - pOuterSequence++; - pOuterFlags++; + for( sal_uInt32 b = 0; b < nNumPoints; b++ ) + { + *pInnerSequence++ = awt::Point( aPolygon.GetPoint( b ).X(), aPolygon.GetPoint( b ).Y() ) ; + *pInnerFlags++ = static_cast<drawing::PolygonFlags>(aPolygon.GetFlags( b )); } - uno::Any aParam; - aParam <<= aRetval; - maXPropSet->setPropertyValue( "PolyPolygonBezier", aParam); - ImplSetFillBundle(); + pOuterSequence++; + pOuterFlags++; } + uno::Any aParam; + aParam <<= aRetval; + maXPropSet->setPropertyValue( "PolyPolygonBezier", aParam); + ImplSetFillBundle(); } void CGMImpressOutAct::DrawText(awt::Point const & rTextPos, awt::Size const & rTextSize, const OUString& rString, FinalFlag eFlag) { - if ( ImplCreateShape( "com.sun.star.drawing.TextShape" ) ) - { - uno::Any aAny; - long nWidth = rTextSize.Width; - long nHeight = rTextSize.Height; - - awt::Point aTextPos( rTextPos ); - switch ( mpCGM->pElement->eTextAlignmentV ) - { - case TAV_HALF : - { - aTextPos.Y = o3tl::saturating_add(aTextPos.X, static_cast<sal_Int32>((mpCGM->pElement->nCharacterHeight * -1.5) / 2)); - } - break; + if ( !ImplCreateShape( "com.sun.star.drawing.TextShape" ) ) + return; - case TAV_BASE : - case TAV_BOTTOM : - case TAV_NORMAL : - aTextPos.Y = o3tl::saturating_add(aTextPos.Y, static_cast<sal_Int32>(mpCGM->pElement->nCharacterHeight * -1.5)); - break; - case TAV_TOP : - break; - case TAV_CAP: - case TAV_CONT: - break; // -Wall these two were not here. - } + uno::Any aAny; + long nWidth = rTextSize.Width; + long nHeight = rTextSize.Height; - if ( nWidth < 0 ) - { - nWidth = -nWidth; - } - else if ( nWidth == 0 ) - { - nWidth = -1; - } - if ( nHeight < 0 ) - { - nHeight = -nHeight; - } - else if ( nHeight == 0 ) - { - nHeight = -1; - } - maXShape->setPosition( aTextPos ); - maXShape->setSize( awt::Size( nWidth, nHeight ) ); - double nX = mpCGM->pElement->nCharacterOrientation[ 2 ]; - double nY = mpCGM->pElement->nCharacterOrientation[ 3 ]; - double fSqrt = sqrt(nX * nX + nY * nY); - double nOrientation = fSqrt != 0.0 ? (acos(nX / fSqrt) * 57.29577951308) : 0.0; - if ( nY < 0 ) - nOrientation = 360 - nOrientation; - - if ( nOrientation ) + awt::Point aTextPos( rTextPos ); + switch ( mpCGM->pElement->eTextAlignmentV ) + { + case TAV_HALF : { - maXPropSet->setPropertyValue( "RotationPointX", uno::Any(aTextPos.X) ); - maXPropSet->setPropertyValue( "RotationPointY", uno::Any(static_cast<sal_Int32>( aTextPos.Y + nHeight )) ); - maXPropSet->setPropertyValue( "RotateAngle", uno::Any(static_cast<sal_Int32>( nOrientation * 100 )) ); + aTextPos.Y = o3tl::saturating_add(aTextPos.X, static_cast<sal_Int32>((mpCGM->pElement->nCharacterHeight * -1.5) / 2)); } - if ( nWidth == -1 ) - { - aAny <<= true; - maXPropSet->setPropertyValue( "TextAutoGrowWidth", aAny ); + break; - drawing::TextAdjust eTextAdjust; - switch ( mpCGM->pElement->eTextAlignmentH ) - { - case TAH_RIGHT : - eTextAdjust = drawing::TextAdjust_RIGHT; - break; - case TAH_LEFT : - case TAH_CONT : - case TAH_NORMAL : - eTextAdjust = drawing::TextAdjust_LEFT; - break; - case TAH_CENTER : - eTextAdjust = drawing::TextAdjust_CENTER; - break; - } - maXPropSet->setPropertyValue( "TextHorizontalAdjust", uno::Any(eTextAdjust) ); - } - if ( nHeight == -1 ) + case TAV_BASE : + case TAV_BOTTOM : + case TAV_NORMAL : + aTextPos.Y = o3tl::saturating_add(aTextPos.Y, static_cast<sal_Int32>(mpCGM->pElement->nCharacterHeight * -1.5)); + break; + case TAV_TOP : + break; + case TAV_CAP: + case TAV_CONT: + break; // -Wall these two were not here. + } + + if ( nWidth < 0 ) + { + nWidth = -nWidth; + } + else if ( nWidth == 0 ) + { + nWidth = -1; + } + if ( nHeight < 0 ) + { + nHeight = -nHeight; + } + else if ( nHeight == 0 ) + { + nHeight = -1; + } + maXShape->setPosition( aTextPos ); + maXShape->setSize( awt::Size( nWidth, nHeight ) ); + double nX = mpCGM->pElement->nCharacterOrientation[ 2 ]; + double nY = mpCGM->pElement->nCharacterOrientation[ 3 ]; + double fSqrt = sqrt(nX * nX + nY * nY); + double nOrientation = fSqrt != 0.0 ? (acos(nX / fSqrt) * 57.29577951308) : 0.0; + if ( nY < 0 ) + nOrientation = 360 - nOrientation; + + if ( nOrientation ) + { + maXPropSet->setPropertyValue( "RotationPointX", uno::Any(aTextPos.X) ); + maXPropSet->setPropertyValue( "RotationPointY", uno::Any(static_cast<sal_Int32>( aTextPos.Y + nHeight )) ); + maXPropSet->setPropertyValue( "RotateAngle", uno::Any(static_cast<sal_Int32>( nOrientation * 100 )) ); + } + if ( nWidth == -1 ) + { + aAny <<= true; + maXPropSet->setPropertyValue( "TextAutoGrowWidth", aAny ); + + drawing::TextAdjust eTextAdjust; + switch ( mpCGM->pElement->eTextAlignmentH ) { - maXPropSet->setPropertyValue( "TextAutoGrowHeight", uno::Any(true) ); + case TAH_RIGHT : + eTextAdjust = drawing::TextAdjust_RIGHT; + break; + case TAH_LEFT : + case TAH_CONT : + case TAH_NORMAL : + eTextAdjust = drawing::TextAdjust_LEFT; + break; + case TAH_CENTER : + eTextAdjust = drawing::TextAdjust_CENTER; + break; } - uno::Reference< text::XText > xText; - uno::Any aFirstQuery( maXShape->queryInterface( cppu::UnoType<text::XText>::get())); - if( aFirstQuery >>= xText ) + maXPropSet->setPropertyValue( "TextHorizontalAdjust", uno::Any(eTextAdjust) ); + } + if ( nHeight == -1 ) + { + maXPropSet->setPropertyValue( "TextAutoGrowHeight", uno::Any(true) ); + } + uno::Reference< text::XText > xText; + uno::Any aFirstQuery( maXShape->queryInterface( cppu::UnoType<text::XText>::get())); + if( aFirstQuery >>= xText ) + { + uno::Reference< text::XTextCursor > aXTextCursor( xText->createTextCursor() ); { - uno::Reference< text::XTextCursor > aXTextCursor( xText->createTextCursor() ); + aXTextCursor->gotoEnd( false ); + uno::Reference< text::XTextRange > aCursorText; + uno::Any aSecondQuery( aXTextCursor->queryInterface( cppu::UnoType<text::XTextRange>::get())); + if ( aSecondQuery >>= aCursorText ) { - aXTextCursor->gotoEnd( false ); - uno::Reference< text::XTextRange > aCursorText; - uno::Any aSecondQuery( aXTextCursor->queryInterface( cppu::UnoType<text::XTextRange>::get())); - if ( aSecondQuery >>= aCursorText ) - { - uno::Reference< beans::XPropertySet > aCursorPropSet; + uno::Reference< beans::XPropertySet > aCursorPropSet; - uno::Any aQuery( aCursorText->queryInterface( cppu::UnoType<beans::XPropertySet>::get())); - if( aQuery >>= aCursorPropSet ) + uno::Any aQuery( aCursorText->queryInterface( cppu::UnoType<beans::XPropertySet>::get())); + if( aQuery >>= aCursorPropSet ) + { + if ( nWidth != -1 ) // paragraph adjusting in a valid textbox ? { - if ( nWidth != -1 ) // paragraph adjusting in a valid textbox ? + switch ( mpCGM->pElement->eTextAlignmentH ) { - switch ( mpCGM->pElement->eTextAlignmentH ) - { - case TAH_RIGHT : - aAny <<= sal_Int16(style::HorizontalAlignment_RIGHT); - break; - case TAH_LEFT : - case TAH_CONT : - case TAH_NORMAL : - aAny <<= sal_Int16(style::HorizontalAlignment_LEFT); - break; - case TAH_CENTER : - aAny <<= sal_Int16(style::HorizontalAlignment_CENTER); - break; - } - aCursorPropSet->setPropertyValue( "ParaAdjust", aAny ); + case TAH_RIGHT : + aAny <<= sal_Int16(style::HorizontalAlignment_RIGHT); + break; + case TAH_LEFT : + case TAH_CONT : + case TAH_NORMAL : + aAny <<= sal_Int16(style::HorizontalAlignment_LEFT); + break; + case TAH_CENTER : + aAny <<= sal_Int16(style::HorizontalAlignment_CENTER); + break; } - if ( nWidth > 0 && nHeight > 0 ) // restricted text - { - aAny <<= true; - maXPropSet->setPropertyValue( "TextFitToSize", aAny ); - } - aCursorText->setString(rString); - aXTextCursor->gotoEnd( true ); - ImplSetTextBundle( aCursorPropSet ); + aCursorPropSet->setPropertyValue( "ParaAdjust", aAny ); + } + if ( nWidth > 0 && nHeight > 0 ) // restricted text + { + aAny <<= true; + maXPropSet->setPropertyValue( "TextFitToSize", aAny ); } + aCursorText->setString(rString); + aXTextCursor->gotoEnd( true ); + ImplSetTextBundle( aCursorPropSet ); } } } - if ( eFlag == FF_NOT_FINAL ) - { - nFinalTextCount = maXShapes->getCount(); - } + } + if ( eFlag == FF_NOT_FINAL ) + { + nFinalTextCount = maXShapes->getCount(); } } void CGMImpressOutAct::AppendText( const char* pString ) { - if ( nFinalTextCount ) + if ( !nFinalTextCount ) + return; + + uno::Reference< drawing::XShape > aShape = *o3tl::doAccess<uno::Reference<drawing::XShape>>(maXShapes->getByIndex( nFinalTextCount - 1 )); + if ( !aShape.is() ) + return; + + uno::Reference< text::XText > xText; + uno::Any aFirstQuery( aShape->queryInterface( cppu::UnoType<text::XText>::get()) ); + if( !(aFirstQuery >>= xText) ) + return; + + OUString aStr(pString, strlen(pString), RTL_TEXTENCODING_ASCII_US); + + uno::Reference< text::XTextCursor > aXTextCursor( xText->createTextCursor() ); + if ( !aXTextCursor.is() ) + return; + + aXTextCursor->gotoEnd( false ); + uno::Reference< text::XTextRange > aCursorText; + uno::Any aSecondQuery(aXTextCursor->queryInterface( cppu::UnoType<text::XTextRange>::get())); + if ( aSecondQuery >>= aCursorText ) { - uno::Reference< drawing::XShape > aShape = *o3tl::doAccess<uno::Reference<drawing::XShape>>(maXShapes->getByIndex( nFinalTextCount - 1 )); - if ( aShape.is() ) + uno::Reference< beans::XPropertySet > aPropSet; + uno::Any aQuery(aCursorText->queryInterface( cppu::UnoType<beans::XPropertySet>::get())); + if( aQuery >>= aPropSet ) { - uno::Reference< text::XText > xText; - uno::Any aFirstQuery( aShape->queryInterface( cppu::UnoType<text::XText>::get()) ); - if( aFirstQuery >>= xText ) - { - OUString aStr(pString, strlen(pString), RTL_TEXTENCODING_ASCII_US); - - uno::Reference< text::XTextCursor > aXTextCursor( xText->createTextCursor() ); - if ( aXTextCursor.is() ) - { - aXTextCursor->gotoEnd( false ); - uno::Reference< text::XTextRange > aCursorText; - uno::Any aSecondQuery(aXTextCursor->queryInterface( cppu::UnoType<text::XTextRange>::get())); - if ( aSecondQuery >>= aCursorText ) - { - uno::Reference< beans::XPropertySet > aPropSet; - uno::Any aQuery(aCursorText->queryInterface( cppu::UnoType<beans::XPropertySet>::get())); - if( aQuery >>= aPropSet ) - { - aCursorText->setString( aStr ); - aXTextCursor->gotoEnd( true ); - ImplSetTextBundle( aPropSet ); - } - } - } - } + aCursorText->setString( aStr ); + aXTextCursor->gotoEnd( true ); + ImplSetTextBundle( aPropSet ); } } } @@ -932,23 +932,23 @@ void CGMImpressOutAct::EndFigure() void CGMImpressOutAct::RegPolyLine( tools::Polygon const & rPolygon, bool bReverse ) { sal_uInt16 nPoints = rPolygon.GetSize(); - if ( nPoints ) + if ( !nPoints ) + return; + + if ( bReverse ) { - if ( bReverse ) + for ( sal_uInt16 i = 0; i < nPoints; i++ ) { - for ( sal_uInt16 i = 0; i < nPoints; i++ ) - { - maPoints.push_back(rPolygon.GetPoint(nPoints - i - 1)); - maFlags.push_back(rPolygon.GetFlags(nPoints - i - 1)); - } + maPoints.push_back(rPolygon.GetPoint(nPoints - i - 1)); + maFlags.push_back(rPolygon.GetFlags(nPoints - i - 1)); } - else + } + else + { + for ( sal_uInt16 i = 0; i < nPoints; i++ ) { - for ( sal_uInt16 i = 0; i < nPoints; i++ ) - { - maPoints.push_back(rPolygon.GetPoint(i)); - maFlags.push_back(rPolygon.GetFlags(i)); - } + maPoints.push_back(rPolygon.GetPoint(i)); + maFlags.push_back(rPolygon.GetFlags(i)); } } } diff --git a/filter/source/graphicfilter/icgm/cgm.cxx b/filter/source/graphicfilter/icgm/cgm.cxx index 9a13e5ebb99e..c12ed6fa6625 100644 --- a/filter/source/graphicfilter/icgm/cgm.cxx +++ b/filter/source/graphicfilter/icgm/cgm.cxx @@ -418,146 +418,146 @@ void CGM::ImplSetMapMode() void CGM::ImplMapDouble( double& nNumb ) { - if ( pElement->eDeviceViewPortMap == DVPM_FORCED ) + if ( pElement->eDeviceViewPortMap != DVPM_FORCED ) + return; + + // point is 1mm * ScalingFactor + switch ( pElement->eDeviceViewPortMode ) { - // point is 1mm * ScalingFactor - switch ( pElement->eDeviceViewPortMode ) + case DVPM_FRACTION : { - case DVPM_FRACTION : - { - nNumb *= ( mnXFraction + mnYFraction ) / 2; - } - break; + nNumb *= ( mnXFraction + mnYFraction ) / 2; + } + break; - case DVPM_METRIC : - { - // nNumb *= ( 100 * pElement->nDeviceViewPortScale ); - nNumb *= ( mnXFraction + mnYFraction ) / 2; - if ( pElement->nDeviceViewPortScale < 0 ) - nNumb = -nNumb; - } - break; + case DVPM_METRIC : + { + // nNumb *= ( 100 * pElement->nDeviceViewPortScale ); + nNumb *= ( mnXFraction + mnYFraction ) / 2; + if ( pElement->nDeviceViewPortScale < 0 ) + nNumb = -nNumb; + } + break; - case DVPM_DEVICE : - { + case DVPM_DEVICE : + { - } - break; + } + break; - default: + default: - break; - } + break; } } void CGM::ImplMapX( double& nNumb ) { - if ( pElement->eDeviceViewPortMap == DVPM_FORCED ) + if ( pElement->eDeviceViewPortMap != DVPM_FORCED ) + return; + + // point is 1mm * ScalingFactor + switch ( pElement->eDeviceViewPortMode ) { - // point is 1mm * ScalingFactor - switch ( pElement->eDeviceViewPortMode ) + case DVPM_FRACTION : { - case DVPM_FRACTION : - { - nNumb *= mnXFraction; - } - break; + nNumb *= mnXFraction; + } + break; - case DVPM_METRIC : - { - // nNumb *= ( 100 * pElement->nDeviceViewPortScale ); - nNumb *= mnXFraction; - if ( pElement->nDeviceViewPortScale < 0 ) - nNumb = -nNumb; - } - break; + case DVPM_METRIC : + { + // nNumb *= ( 100 * pElement->nDeviceViewPortScale ); + nNumb *= mnXFraction; + if ( pElement->nDeviceViewPortScale < 0 ) + nNumb = -nNumb; + } + break; - case DVPM_DEVICE : - { + case DVPM_DEVICE : + { - } - break; + } + break; - default: + default: - break; - } + break; } } void CGM::ImplMapY( double& nNumb ) { - if ( pElement->eDeviceViewPortMap == DVPM_FORCED ) + if ( pElement->eDeviceViewPortMap != DVPM_FORCED ) + return; + + // point is 1mm * ScalingFactor + switch ( pElement->eDeviceViewPortMode ) { - // point is 1mm * ScalingFactor - switch ( pElement->eDeviceViewPortMode ) + case DVPM_FRACTION : { - case DVPM_FRACTION : - { - nNumb *= mnYFraction; - } - break; + nNumb *= mnYFraction; + } + break; - case DVPM_METRIC : - { - // nNumb *= ( 100 * pElement->nDeviceViewPortScale ); - nNumb *= mnYFraction; - if ( pElement->nDeviceViewPortScale < 0 ) - nNumb = -nNumb; - } - break; + case DVPM_METRIC : + { + // nNumb *= ( 100 * pElement->nDeviceViewPortScale ); + nNumb *= mnYFraction; + if ( pElement->nDeviceViewPortScale < 0 ) + nNumb = -nNumb; + } + break; - case DVPM_DEVICE : - { + case DVPM_DEVICE : + { - } - break; + } + break; - default: + default: - break; - } + break; } } // convert a point to the current VC mapmode (1/100TH mm) void CGM::ImplMapPoint( FloatPoint& rFloatPoint ) { - if ( pElement->eDeviceViewPortMap == DVPM_FORCED ) + if ( pElement->eDeviceViewPortMap != DVPM_FORCED ) + return; + + // point is 1mm * ScalingFactor + switch ( pElement->eDeviceViewPortMode ) { - // point is 1mm * ScalingFactor - switch ( pElement->eDeviceViewPortMode ) + case DVPM_FRACTION : { - case DVPM_FRACTION : - { - rFloatPoint.X *= mnXFraction; - rFloatPoint.Y *= mnYFraction; - } - break; + rFloatPoint.X *= mnXFraction; + rFloatPoint.Y *= mnYFraction; + } + break; - case DVPM_METRIC : + case DVPM_METRIC : + { + rFloatPoint.X *= mnXFraction; + rFloatPoint.Y *= mnYFraction; + if ( pElement->nDeviceViewPortScale < 0 ) { - rFloatPoint.X *= mnXFraction; - rFloatPoint.Y *= mnYFraction; - if ( pElement->nDeviceViewPortScale < 0 ) - { - rFloatPoint.X = -rFloatPoint.X; - rFloatPoint.Y = -rFloatPoint.Y; - } + rFloatPoint.X = -rFloatPoint.X; + rFloatPoint.Y = -rFloatPoint.Y; } - break; + } + break; - case DVPM_DEVICE : - { + case DVPM_DEVICE : + { - } - break; + } + break; - default: + default: - break; - } + break; } } @@ -588,60 +588,60 @@ void CGM::ImplDoClass() void CGM::ImplDefaultReplacement() { - if (!maDefRepList.empty()) + if (maDefRepList.empty()) + return; + + if (mbInDefaultReplacement) { - if (mbInDefaultReplacement) - { - SAL_WARN("filter.icgm", "recursion in ImplDefaultReplacement"); - return; - } + SAL_WARN("filter.icgm", "recursion in ImplDefaultReplacement"); + return; + } - mbInDefaultReplacement = true; + mbInDefaultReplacement = true; - sal_uInt32 nOldEscape = mnEscape; - sal_uInt32 nOldElementClass = mnElementClass; - sal_uInt32 nOldElementID = mnElementID; - sal_uInt32 nOldElementSize = mnElementSize; - sal_uInt8* pOldBuf = mpSource; - sal_uInt8* pOldEndValidSource = mpEndValidSource; + sal_uInt32 nOldEscape = mnEscape; + sal_uInt32 nOldElementClass = mnElementClass; + sal_uInt32 nOldElementID = mnElementID; + sal_uInt32 nOldElementSize = mnElementSize; + sal_uInt8* pOldBuf = mpSource; + sal_uInt8* pOldEndValidSource = mpEndValidSource; - for ( size_t i = 0, n = maDefRepList.size(); i < n; ++i ) + for ( size_t i = 0, n = maDefRepList.size(); i < n; ++i ) + { + sal_uInt8* pBuf = maDefRepList[ i ].get(); + sal_uInt32 nElementSize = maDefRepSizeList[ i ]; + mpEndValidSource = pBuf + nElementSize; + sal_uInt32 nCount = 0; + while ( mbStatus && ( nCount < nElementSize ) ) { - sal_uInt8* pBuf = maDefRepList[ i ].get(); - sal_uInt32 nElementSize = maDefRepSizeList[ i ]; - mpEndValidSource = pBuf + nElementSize; - sal_uInt32 nCount = 0; - while ( mbStatus && ( nCount < nElementSize ) ) + mpSource = pBuf + nCount; + mnParaSize = 0; + mnEscape = ImplGetUI16(); + mnElementClass = mnEscape >> 12; + mnElementID = ( mnEscape & 0x0fe0 ) >> 5; + mnElementSize = mnEscape & 0x1f; + if ( mnElementSize == 31 ) { - mpSource = pBuf + nCount; - mnParaSize = 0; - mnEscape = ImplGetUI16(); - mnElementClass = mnEscape >> 12; - mnElementID = ( mnEscape & 0x0fe0 ) >> 5; - mnElementSize = mnEscape & 0x1f; - if ( mnElementSize == 31 ) - { - mnElementSize = ImplGetUI16(); - } - nCount += mnParaSize; - mnParaSize = 0; - mpSource = pBuf + nCount; - if ( mnElementSize & 1 ) - nCount++; - nCount += mnElementSize; - if ( ( mnElementClass != 1 ) || ( mnElementID != 0xc ) ) // recursion is not possible here!! - ImplDoClass(); + mnElementSize = ImplGetUI16(); } + nCount += mnParaSize; + mnParaSize = 0; + mpSource = pBuf + nCount; + if ( mnElementSize & 1 ) + nCount++; + nCount += mnElementSize; + if ( ( mnElementClass != 1 ) || ( mnElementID != 0xc ) ) // recursion is not possible here!! + ImplDoClass(); } - mnEscape = nOldEscape; - mnElementClass = nOldElementClass; - mnElementID = nOldElementID; - mnParaSize = mnElementSize = nOldElementSize; - mpSource = pOldBuf; - mpEndValidSource = pOldEndValidSource; - - mbInDefaultReplacement = false; } + mnEscape = nOldEscape; + mnElementClass = nOldElementClass; + mnElementID = nOldElementID; + mnParaSize = mnElementSize = nOldElementSize; + mpSource = pOldBuf; + mpEndValidSource = pOldEndValidSource; + + mbInDefaultReplacement = false; } bool CGM::Write( SvStream& rIStm ) diff --git a/filter/source/graphicfilter/idxf/dxf2mtf.cxx b/filter/source/graphicfilter/idxf/dxf2mtf.cxx index c193961cff41..898dc6159ecb 100644 --- a/filter/source/graphicfilter/idxf/dxf2mtf.cxx +++ b/filter/source/graphicfilter/idxf/dxf2mtf.cxx @@ -219,24 +219,25 @@ bool DXF2GDIMetaFile::SetFontAttribute(const DXFBasicEntity & rE, short nAngle, void DXF2GDIMetaFile::DrawLineEntity(const DXFLineEntity & rE, const DXFTransform & rTransform) { - if (SetLineAttribute(rE)) { - Point aP0,aP1; - rTransform.Transform(rE.aP0,aP0); - rTransform.Transform(rE.aP1,aP1); + if (!SetLineAttribute(rE)) + return; - DXFLineInfo aDXFLineInfo=GetEntityDXFLineInfo(rE); - LineInfo aLineInfo; - aLineInfo = rTransform.Transform(aDXFLineInfo); + Point aP0,aP1; + rTransform.Transform(rE.aP0,aP0); + rTransform.Transform(rE.aP1,aP1); - pVirDev->DrawLine(aP0,aP1,aLineInfo); - if (rE.fThickness!=0) { - Point aP2,aP3; - rTransform.Transform(rE.aP0+DXFVector(0,0,rE.fThickness),aP2); - rTransform.Transform(rE.aP1+DXFVector(0,0,rE.fThickness),aP3); - DrawLine(aP2,aP3); - DrawLine(aP0,aP2); - DrawLine(aP1,aP3); - } + DXFLineInfo aDXFLineInfo=GetEntityDXFLineInfo(rE); + LineInfo aLineInfo; + aLineInfo = rTransform.Transform(aDXFLineInfo); + + pVirDev->DrawLine(aP0,aP1,aLineInfo); + if (rE.fThickness!=0) { + Point aP2,aP3; + rTransform.Transform(rE.aP0+DXFVector(0,0,rE.fThickness),aP2); + rTransform.Transform(rE.aP1+DXFVector(0,0,rE.fThickness),aP3); + DrawLine(aP2,aP3); + DrawLine(aP0,aP2); + DrawLine(aP1,aP3); } } @@ -374,52 +375,54 @@ void DXF2GDIMetaFile::DrawArcEntity(const DXFArcEntity & rE, const DXFTransform void DXF2GDIMetaFile::DrawTraceEntity(const DXFTraceEntity & rE, const DXFTransform & rTransform) { - if (SetLineAttribute(rE)) { - tools::Polygon aPoly(4); - rTransform.Transform(rE.aP0,aPoly[0]); - rTransform.Transform(rE.aP1,aPoly[1]); - rTransform.Transform(rE.aP3,aPoly[2]); - rTransform.Transform(rE.aP2,aPoly[3]); - pVirDev->DrawPolygon(aPoly); - if (rE.fThickness!=0) { - sal_uInt16 i; - tools::Polygon aPoly2(4); - DXFVector aVAdd(0,0,rE.fThickness); - rTransform.Transform(rE.aP0+aVAdd,aPoly2[0]); - rTransform.Transform(rE.aP1+aVAdd,aPoly2[1]); - rTransform.Transform(rE.aP3+aVAdd,aPoly2[2]); - rTransform.Transform(rE.aP2+aVAdd,aPoly2[3]); - pVirDev->DrawPolygon(aPoly2); - for (i=0; i<4; i++) DrawLine(aPoly[i],aPoly2[i]); - } + if (!SetLineAttribute(rE)) + return; + + tools::Polygon aPoly(4); + rTransform.Transform(rE.aP0,aPoly[0]); + rTransform.Transform(rE.aP1,aPoly[1]); + rTransform.Transform(rE.aP3,aPoly[2]); + rTransform.Transform(rE.aP2,aPoly[3]); + pVirDev->DrawPolygon(aPoly); + if (rE.fThickness!=0) { + sal_uInt16 i; + tools::Polygon aPoly2(4); + DXFVector aVAdd(0,0,rE.fThickness); + rTransform.Transform(rE.aP0+aVAdd,aPoly2[0]); + rTransform.Transform(rE.aP1+aVAdd,aPoly2[1]); + rTransform.Transform(rE.aP3+aVAdd,aPoly2[2]); + rTransform.Transform(rE.aP2+aVAdd,aPoly2[3]); + pVirDev->DrawPolygon(aPoly2); + for (i=0; i<4; i++) DrawLine(aPoly[i],aPoly2[i]); } } void DXF2GDIMetaFile::DrawSolidEntity(const DXFSolidEntity & rE, const DXFTransform & rTransform) { - if (SetAreaAttribute(rE)) { - sal_uInt16 nN; - if (rE.aP2==rE.aP3) nN=3; else nN=4; - tools::Polygon aPoly(nN); - rTransform.Transform(rE.aP0,aPoly[0]); - rTransform.Transform(rE.aP1,aPoly[1]); - rTransform.Transform(rE.aP3,aPoly[2]); - if (nN>3) rTransform.Transform(rE.aP2,aPoly[3]); - pVirDev->DrawPolygon(aPoly); - if (rE.fThickness!=0) { - tools::Polygon aPoly2(nN); - DXFVector aVAdd(0,0,rE.fThickness); - rTransform.Transform(rE.aP0+aVAdd,aPoly2[0]); - rTransform.Transform(rE.aP1+aVAdd,aPoly2[1]); - rTransform.Transform(rE.aP3+aVAdd,aPoly2[2]); - if (nN>3) rTransform.Transform(rE.aP2+aVAdd,aPoly2[3]); - pVirDev->DrawPolygon(aPoly2); - if (SetLineAttribute(rE)) { - sal_uInt16 i; - for (i=0; i<nN; i++) DrawLine(aPoly[i],aPoly2[i]); - } - } + if (!SetAreaAttribute(rE)) + return; + + sal_uInt16 nN; + if (rE.aP2==rE.aP3) nN=3; else nN=4; + tools::Polygon aPoly(nN); + rTransform.Transform(rE.aP0,aPoly[0]); + rTransform.Transform(rE.aP1,aPoly[1]); + rTransform.Transform(rE.aP3,aPoly[2]); + if (nN>3) rTransform.Transform(rE.aP2,aPoly[3]); + pVirDev->DrawPolygon(aPoly); + if (rE.fThickness==0) return; + + tools::Polygon aPoly2(nN); + DXFVector aVAdd(0,0,rE.fThickness); + rTransform.Transform(rE.aP0+aVAdd,aPoly2[0]); + rTransform.Transform(rE.aP1+aVAdd,aPoly2[1]); + rTransform.Transform(rE.aP3+aVAdd,aPoly2[2]); + if (nN>3) rTransform.Transform(rE.aP2+aVAdd,aPoly2[3]); + pVirDev->DrawPolygon(aPoly2); + if (SetLineAttribute(rE)) { + sal_uInt16 i; + for (i=0; i<nN; i++) DrawLine(aPoly[i],aPoly2[i]); } } @@ -450,57 +453,59 @@ void DXF2GDIMetaFile::DrawInsertEntity(const DXFInsertEntity & rE, const DXFTran { const DXFBlock * pB; pB=pDXF->aBlocks.Search(rE.m_sName); - if (pB!=nullptr) { - DXFTransform aDXFTransform1(1.0,1.0,1.0,DXFVector(0.0,0.0,0.0)-pB->aBasePoint); - DXFTransform aDXFTransform2(rE.fXScale,rE.fYScale,rE.fZScale,rE.fRotAngle,rE.aP0); - DXFTransform aT( - DXFTransform( aDXFTransform1, aDXFTransform2 ), - rTransform - ); - long nSavedBlockColor, nSavedParentLayerColor; - DXFLineInfo aSavedBlockDXFLineInfo, aSavedParentLayerDXFLineInfo; - nSavedBlockColor=nBlockColor; - nSavedParentLayerColor=nParentLayerColor; - aSavedBlockDXFLineInfo=aBlockDXFLineInfo; - aSavedParentLayerDXFLineInfo=aParentLayerDXFLineInfo; - nBlockColor=GetEntityColor(rE); - aBlockDXFLineInfo=GetEntityDXFLineInfo(rE); - if (rE.m_sLayer.getLength() > 1) { - DXFLayer * pLayer=pDXF->aTables.SearchLayer(rE.m_sLayer); - if (pLayer!=nullptr) { - nParentLayerColor=pLayer->nColor; - aParentLayerDXFLineInfo = LTypeToDXFLineInfo(pLayer->m_sLineType); - } + if (pB==nullptr) + return; + + DXFTransform aDXFTransform1(1.0,1.0,1.0,DXFVector(0.0,0.0,0.0)-pB->aBasePoint); + DXFTransform aDXFTransform2(rE.fXScale,rE.fYScale,rE.fZScale,rE.fRotAngle,rE.aP0); + DXFTransform aT( + DXFTransform( aDXFTransform1, aDXFTransform2 ), + rTransform + ); + long nSavedBlockColor, nSavedParentLayerColor; + DXFLineInfo aSavedBlockDXFLineInfo, aSavedParentLayerDXFLineInfo; + nSavedBlockColor=nBlockColor; + nSavedParentLayerColor=nParentLayerColor; + aSavedBlockDXFLineInfo=aBlockDXFLineInfo; + aSavedParentLayerDXFLineInfo=aParentLayerDXFLineInfo; + nBlockColor=GetEntityColor(rE); + aBlockDXFLineInfo=GetEntityDXFLineInfo(rE); + if (rE.m_sLayer.getLength() > 1) { + DXFLayer * pLayer=pDXF->aTables.SearchLayer(rE.m_sLayer); + if (pLayer!=nullptr) { + nParentLayerColor=pLayer->nColor; + aParentLayerDXFLineInfo = LTypeToDXFLineInfo(pLayer->m_sLineType); } - DrawEntities(*pB,aT); - aBlockDXFLineInfo=aSavedBlockDXFLineInfo; - aParentLayerDXFLineInfo=aSavedParentLayerDXFLineInfo; - nBlockColor=nSavedBlockColor; - nParentLayerColor=nSavedParentLayerColor; } + DrawEntities(*pB,aT); + aBlockDXFLineInfo=aSavedBlockDXFLineInfo; + aParentLayerDXFLineInfo=aSavedParentLayerDXFLineInfo; + nBlockColor=nSavedBlockColor; + nParentLayerColor=nSavedParentLayerColor; } void DXF2GDIMetaFile::DrawAttribEntity(const DXFAttribEntity & rE, const DXFTransform & rTransform) { - if ((rE.nAttrFlags&1)==0) { - DXFVector aV; - Point aPt; - double fA; - sal_uInt16 nHeight; - short nAng; - DXFTransform aT( DXFTransform( rE.fXScale, rE.fHeight, 1.0, rE.fRotAngle, rE.aP0 ), rTransform ); - aT.TransDir(DXFVector(0,1,0),aV); - nHeight=static_cast<sal_uInt16>(aV.Abs()+0.5); - fA=aT.CalcRotAngle(); - nAng=static_cast<short>(fA*10.0+0.5); - aT.TransDir(DXFVector(1,0,0),aV); - if (SetFontAttribute(rE,nAng,nHeight)) - { - OUString const aUString(pDXF->ToOUString(rE.m_sText)); - aT.Transform( DXFVector( 0, 0, 0 ), aPt ); - pVirDev->DrawText( aPt, aUString ); - } + if ((rE.nAttrFlags&1)!=0) + return; + + DXFVector aV; + Point aPt; + double fA; + sal_uInt16 nHeight; + short nAng; + DXFTransform aT( DXFTransform( rE.fXScale, rE.fHeight, 1.0, rE.fRotAngle, rE.aP0 ), rTransform ); + aT.TransDir(DXFVector(0,1,0),aV); + nHeight=static_cast<sal_uInt16>(aV.Abs()+0.5); + fA=aT.CalcRotAngle(); + nAng=static_cast<short>(fA*10.0+0.5); + aT.TransDir(DXFVector(1,0,0),aV); + if (SetFontAttribute(rE,nAng,nHeight)) + { + OUString const aUString(pDXF->ToOUString(rE.m_sText)); + aT.Transform( DXFVector( 0, 0, 0 ), aPt ); + pVirDev->DrawText( aPt, aUString ); } } @@ -516,7 +521,8 @@ void DXF2GDIMetaFile::DrawPolyLineEntity(const DXFPolyLineEntity & rE, const DXF nPolySize++; pBE=pBE->pSucc; } - if (nPolySize<2) return; + if (nPolySize<2) + return; tools::Polygon aPoly(nPolySize); pBE=rE.pSucc; for (i=0; i<nPolySize; i++) { @@ -524,119 +530,122 @@ void DXF2GDIMetaFile::DrawPolyLineEntity(const DXFPolyLineEntity & rE, const DXF pBE=pBE->pSucc; } - if (SetLineAttribute(rE)) { - if ((rE.nFlags&1)!=0) pVirDev->DrawPolygon(aPoly); - else pVirDev->DrawPolyLine(aPoly); - if (rE.fThickness!=0) { - tools::Polygon aPoly2(nPolySize); - pBE=rE.pSucc; - for (i=0; i<nPolySize; i++) { - rTransform.Transform( - (static_cast<const DXFVertexEntity*>(pBE)->aP0)+DXFVector(0,0,rE.fThickness), - aPoly2[i] - ); - pBE=pBE->pSucc; - } - if ((rE.nFlags&1)!=0) pVirDev->DrawPolygon(aPoly2); - else pVirDev->DrawPolyLine(aPoly2); - for (i=0; i<nPolySize; i++) DrawLine(aPoly[i],aPoly2[i]); - } + if (!SetLineAttribute(rE)) + return; + + if ((rE.nFlags&1)!=0) pVirDev->DrawPolygon(aPoly); + else pVirDev->DrawPolyLine(aPoly); + if (rE.fThickness==0) + return; + + tools::Polygon aPoly2(nPolySize); + pBE=rE.pSucc; + for (i=0; i<nPolySize; i++) { + rTransform.Transform( + (static_cast<const DXFVertexEntity*>(pBE)->aP0)+DXFVector(0,0,rE.fThickness), + aPoly2[i] + ); + pBE=pBE->pSucc; } + if ((rE.nFlags&1)!=0) pVirDev->DrawPolygon(aPoly2); + else pVirDev->DrawPolyLine(aPoly2); + for (i=0; i<nPolySize; i++) DrawLine(aPoly[i],aPoly2[i]); } void DXF2GDIMetaFile::DrawLWPolyLineEntity(const DXFLWPolyLineEntity & rE, const DXFTransform & rTransform ) { sal_Int32 nPolySize = rE.aP.size(); - if (nPolySize) + if (!nPolySize) + return; + + tools::Polygon aPoly( static_cast<sal_uInt16>(nPolySize)); + for (sal_Int32 i = 0; i < nPolySize; ++i) { - tools::Polygon aPoly( static_cast<sal_uInt16>(nPolySize)); - for (sal_Int32 i = 0; i < nPolySize; ++i) - { - rTransform.Transform( rE.aP[ static_cast<sal_uInt16>(i) ], aPoly[ static_cast<sal_uInt16>(i) ] ); - } - if ( SetLineAttribute( rE ) ) - { - if ( ( rE.nFlags & 1 ) != 0 ) - pVirDev->DrawPolygon( aPoly ); - else - pVirDev->DrawPolyLine( aPoly ); - } + rTransform.Transform( rE.aP[ static_cast<sal_uInt16>(i) ], aPoly[ static_cast<sal_uInt16>(i) ] ); + } + if ( SetLineAttribute( rE ) ) + { + if ( ( rE.nFlags & 1 ) != 0 ) + pVirDev->DrawPolygon( aPoly ); + else + pVirDev->DrawPolyLine( aPoly ); } } void DXF2GDIMetaFile::DrawHatchEntity(const DXFHatchEntity & rE, const DXFTransform & rTransform ) { - if ( rE.nBoundaryPathCount ) + if ( !rE.nBoundaryPathCount ) + return; + + SetAreaAttribute( rE ); + sal_Int32 j = 0; + tools::PolyPolygon aPolyPoly; + for ( j = 0; j < rE.nBoundaryPathCount; j++ ) { - SetAreaAttribute( rE ); - sal_Int32 j = 0; - tools::PolyPolygon aPolyPoly; - for ( j = 0; j < rE.nBoundaryPathCount; j++ ) + std::vector< Point > aPtAry; + const DXFBoundaryPathData& rPathData = rE.pBoundaryPathData[ j ]; + if ( rPathData.bIsPolyLine ) { - std::vector< Point > aPtAry; - const DXFBoundaryPathData& rPathData = rE.pBoundaryPathData[ j ]; - if ( rPathData.bIsPolyLine ) + for (const auto& a : rPathData.aP) { - for (const auto& a : rPathData.aP) - { - Point aPt; - rTransform.Transform(a, aPt); - aPtAry.push_back( aPt ); - } + Point aPt; + rTransform.Transform(a, aPt); + aPtAry.push_back( aPt ); } - else + } + else + { + for ( auto& rEdge : rPathData.aEdges ) { - for ( auto& rEdge : rPathData.aEdges ) + const DXFEdgeType* pEdge = rEdge.get(); + switch( pEdge->nEdgeType ) { - const DXFEdgeType* pEdge = rEdge.get(); - switch( pEdge->nEdgeType ) + case 1 : { - case 1 : - { - Point aPt; - rTransform.Transform( static_cast<const DXFEdgeTypeLine*>(pEdge)->aStartPoint, aPt ); - aPtAry.push_back( aPt ); - rTransform.Transform( static_cast<const DXFEdgeTypeLine*>(pEdge)->aEndPoint, aPt ); - aPtAry.push_back( aPt ); - } - break; - case 2 : - case 3 : - case 4 : - break; + Point aPt; + rTransform.Transform( static_cast<const DXFEdgeTypeLine*>(pEdge)->aStartPoint, aPt ); + aPtAry.push_back( aPt ); + rTransform.Transform( static_cast<const DXFEdgeTypeLine*>(pEdge)->aEndPoint, aPt ); + aPtAry.push_back( aPt ); } + break; + case 2 : + case 3 : + case 4 : + break; } } - sal_uInt16 i, nSize = static_cast<sal_uInt16>(aPtAry.size()); - if ( nSize ) - { - tools::Polygon aPoly( nSize ); - for ( i = 0; i < nSize; i++ ) - aPoly[ i ] = aPtAry[ i ]; - aPolyPoly.Insert( aPoly ); - } } - if ( aPolyPoly.Count() ) - pVirDev->DrawPolyPolygon( aPolyPoly ); + sal_uInt16 i, nSize = static_cast<sal_uInt16>(aPtAry.size()); + if ( nSize ) + { + tools::Polygon aPoly( nSize ); + for ( i = 0; i < nSize; i++ ) + aPoly[ i ] = aPtAry[ i ]; + aPolyPoly.Insert( aPoly ); + } } + if ( aPolyPoly.Count() ) + pVirDev->DrawPolyPolygon( aPolyPoly ); } void DXF2GDIMetaFile::Draw3DFaceEntity(const DXF3DFaceEntity & rE, const DXFTransform & rTransform) { sal_uInt16 nN,i; - if (SetLineAttribute(rE)) { - if (rE.aP2==rE.aP3) nN=3; else nN=4; - tools::Polygon aPoly(nN); - rTransform.Transform(rE.aP0,aPoly[0]); - rTransform.Transform(rE.aP1,aPoly[1]); - rTransform.Transform(rE.aP2,aPoly[2]); - if (nN>3) rTransform.Transform(rE.aP3,aPoly[3]); - if ((rE.nIEFlags&0x0f)==0) pVirDev->DrawPolygon(aPoly); - else { - for (i=0; i<nN; i++) { - if ( (rE.nIEFlags & (1<<i)) == 0 ) { - DrawLine(aPoly[i],aPoly[(i+1)%nN]); - } + if (!SetLineAttribute(rE)) + return; + + if (rE.aP2==rE.aP3) nN=3; else nN=4; + tools::Polygon aPoly(nN); + rTransform.Transform(rE.aP0,aPoly[0]); + rTransform.Transform(rE.aP1,aPoly[1]); + rTransform.Transform(rE.aP2,aPoly[2]); + if (nN>3) rTransform.Transform(rE.aP3,aPoly[3]); + if ((rE.nIEFlags&0x0f)==0) pVirDev->DrawPolygon(aPoly); + else { + for (i=0; i<nN; i++) { + if ( (rE.nIEFlags & (1<<i)) == 0 ) { + DrawLine(aPoly[i],aPoly[(i+1)%nN]); } } } @@ -646,32 +655,33 @@ void DXF2GDIMetaFile::DrawDimensionEntity(const DXFDimensionEntity & rE, const D { const DXFBlock * pB; pB=pDXF->aBlocks.Search(rE.m_sPseudoBlock); - if (pB!=nullptr) { - DXFTransform aT( - DXFTransform(1.0,1.0,1.0,DXFVector(0.0,0.0,0.0)-pB->aBasePoint), - rTransform - ); - long nSavedBlockColor, nSavedParentLayerColor; - DXFLineInfo aSavedBlockDXFLineInfo, aSavedParentLayerDXFLineInfo; - nSavedBlockColor=nBlockColor; - nSavedParentLayerColor=nParentLayerColor; - aSavedBlockDXFLineInfo=aBlockDXFLineInfo; - aSavedParentLayerDXFLineInfo=aParentLayerDXFLineInfo; - nBlockColor=GetEntityColor(rE); - aBlockDXFLineInfo=GetEntityDXFLineInfo(rE); - if (rE.m_sLayer.getLength() > 1) { - DXFLayer * pLayer=pDXF->aTables.SearchLayer(rE.m_sLayer); - if (pLayer!=nullptr) { - nParentLayerColor=pLayer->nColor; - aParentLayerDXFLineInfo = LTypeToDXFLineInfo(pLayer->m_sLineType); - } + if (pB==nullptr) + return; + + DXFTransform aT( + DXFTransform(1.0,1.0,1.0,DXFVector(0.0,0.0,0.0)-pB->aBasePoint), + rTransform + ); + long nSavedBlockColor, nSavedParentLayerColor; + DXFLineInfo aSavedBlockDXFLineInfo, aSavedParentLayerDXFLineInfo; + nSavedBlockColor=nBlockColor; + nSavedParentLayerColor=nParentLayerColor; + aSavedBlockDXFLineInfo=aBlockDXFLineInfo; + aSavedParentLayerDXFLineInfo=aParentLayerDXFLineInfo; + nBlockColor=GetEntityColor(rE); + aBlockDXFLineInfo=GetEntityDXFLineInfo(rE); + if (rE.m_sLayer.getLength() > 1) { + DXFLayer * pLayer=pDXF->aTables.SearchLayer(rE.m_sLayer); + if (pLayer!=nullptr) { + nParentLayerColor=pLayer->nColor; + aParentLayerDXFLineInfo = LTypeToDXFLineInfo(pLayer->m_sLineType); } - DrawEntities(*pB,aT); - aBlockDXFLineInfo=aSavedBlockDXFLineInfo; - aParentLayerDXFLineInfo=aSavedParentLayerDXFLineInfo; - nBlockColor=nSavedBlockColor; - nParentLayerColor=nSavedParentLayerColor; } + DrawEntities(*pB,aT); + aBlockDXFLineInfo=aSavedBlockDXFLineInfo; + aParentLayerDXFLineInfo=aSavedParentLayerDXFLineInfo; + nBlockColor=nSavedBlockColor; + nParentLayerColor=nSavedParentLayerColor; } diff --git a/filter/source/graphicfilter/itiff/itiff.cxx b/filter/source/graphicfilter/itiff/itiff.cxx index 83fdf73e4f35..4a15becae1b8 100644 --- a/filter/source/graphicfilter/itiff/itiff.cxx +++ b/filter/source/graphicfilter/itiff/itiff.cxx @@ -1218,23 +1218,23 @@ void TIFFReader::MakePalCol() } } - if ( fXResolution > 1.0 && fYResolution > 1.0 && ( nResolutionUnit == 2 || nResolutionUnit == 3 ) ) + if ( !(fXResolution > 1.0 && fYResolution > 1.0 && ( nResolutionUnit == 2 || nResolutionUnit == 3 )) ) + return; + + sal_uInt32 nRX, nRY; + if (nResolutionUnit==2) { - sal_uInt32 nRX, nRY; - if (nResolutionUnit==2) - { - nRX=static_cast<sal_uInt32>(fXResolution+0.5); - nRY=static_cast<sal_uInt32>(fYResolution+0.5); - } - else - { - nRX=static_cast<sal_uInt32>(fXResolution*2.54+0.5); - nRY=static_cast<sal_uInt32>(fYResolution*2.54+0.5); - } - MapMode aMapMode(MapUnit::MapInch,Point(0,0),Fraction(1,nRX),Fraction(1,nRY)); - maBitmapPrefMapMode = aMapMode; - maBitmapPrefSize = Size(nImageWidth,nImageLength); + nRX=static_cast<sal_uInt32>(fXResolution+0.5); + nRY=static_cast<sal_uInt32>(fYResolution+0.5); + } + else + { + nRX=static_cast<sal_uInt32>(fXResolution*2.54+0.5); + nRY=static_cast<sal_uInt32>(fYResolution*2.54+0.5); } + MapMode aMapMode(MapUnit::MapInch,Point(0,0),Fraction(1,nRX),Fraction(1,nRY)); + maBitmapPrefMapMode = aMapMode; + maBitmapPrefSize = Size(nImageWidth,nImageLength); } |