filter/source/config/cache/basecontainer.cxx | 32 filter/source/config/cache/configflush.cxx | 32 filter/source/config/cache/typedetection.cxx | 24 filter/source/flash/swfwriter.cxx | 22 filter/source/flash/swfwriter1.cxx | 304 +- filter/source/graphic/GraphicExportFilter.cxx | 28 filter/source/graphicfilter/egif/egif.cxx | 358 +- filter/source/graphicfilter/egif/giflzwc.cxx | 122 filter/source/graphicfilter/eps/eps.cxx | 222 - filter/source/graphicfilter/icgm/actimpr.cxx | 794 ++--- filter/source/graphicfilter/icgm/cgm.cxx | 278 - filter/source/graphicfilter/idxf/dxf2mtf.cxx | 428 +-- filter/source/graphicfilter/itiff/itiff.cxx | 30 filter/source/msfilter/escherex.cxx | 2656 +++++++++---------- filter/source/msfilter/eschesdo.cxx | 54 filter/source/msfilter/mscodec.cxx | 38 filter/source/msfilter/msdffimp.cxx | 580 ++-- filter/source/msfilter/mstoolbar.cxx | 48 filter/source/msfilter/svdfppt.cxx | 1810 ++++++------ filter/source/pdf/impdialog.cxx | 80 filter/source/pdf/pdfexport.cxx | 34 filter/source/svg/svgexport.cxx | 456 +-- filter/source/svg/svgfontexport.cxx | 150 - filter/source/svg/svgwriter.cxx | 874 +++--- filter/source/t602/t602filter.cxx | 41 filter/source/xsltdialog/typedetectionimport.cxx | 50 filter/source/xsltdialog/xmlfilterjar.cxx | 28 filter/source/xsltdialog/xmlfiltersettingsdialog.cxx | 144 - filter/source/xsltdialog/xmlfiltertabpagebasic.cxx | 76 filter/source/xsltdialog/xmlfiltertestdialog.cxx | 38 30 files changed, 4920 insertions(+), 4911 deletions(-)
New commits: commit e6b8be25a6fb5afbd1649489318a7a2d7ae62efa Author: Noel Grandin <[email protected]> AuthorDate: Tue Apr 14 14:47:34 2020 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Tue Apr 14 15:44:42 2020 +0200 loplugin:flatten in filter Change-Id: I24861f7401c0046962d536950fe8b2b6bdbad969 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92186 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/filter/source/config/cache/basecontainer.cxx b/filter/source/config/cache/basecontainer.cxx index 60b8332314c2..4f7b4f04ca49 100644 --- a/filter/source/config/cache/basecontainer.cxx +++ b/filter/source/config/cache/basecontainer.cxx @@ -454,24 +454,24 @@ void SAL_CALL BaseContainer::flush() // if an outside object is called :-) css::lang::EventObject aSource (static_cast< css::util::XFlushable* >(this)); ::cppu::OInterfaceContainerHelper* pContainer = m_lListener.getContainer(cppu::UnoType<css::util::XFlushListener>::get()); - if (pContainer) + if (!pContainer) + return; + + ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); + while (pIterator.hasMoreElements()) { - ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); - while (pIterator.hasMoreElements()) + try + { + // ... this pointer can be interesting to find out, where will be called as listener + // Don't optimize it to a direct iterator cast :-) + css::util::XFlushListener* pListener = static_cast<css::util::XFlushListener*>(pIterator.next()); + pListener->flushed(aSource); + } + catch(const css::uno::Exception&) { - try - { - // ... this pointer can be interesting to find out, where will be called as listener - // Don't optimize it to a direct iterator cast :-) - css::util::XFlushListener* pListener = static_cast<css::util::XFlushListener*>(pIterator.next()); - pListener->flushed(aSource); - } - catch(const css::uno::Exception&) - { - // ignore any "damaged" flush listener! - // May its remote reference is broken ... - pIterator.remove(); - } + // ignore any "damaged" flush listener! + // May its remote reference is broken ... + pIterator.remove(); } } } diff --git a/filter/source/config/cache/configflush.cxx b/filter/source/config/cache/configflush.cxx index f9193712c7dd..97699c2c0508 100644 --- a/filter/source/config/cache/configflush.cxx +++ b/filter/source/config/cache/configflush.cxx @@ -58,24 +58,24 @@ void SAL_CALL ConfigFlush::refresh() // if an outside object is called :-) css::lang::EventObject aSource (static_cast< css::util::XRefreshable* >(this)); ::cppu::OInterfaceContainerHelper* pContainer = m_lListener.getContainer(cppu::UnoType<css::util::XRefreshListener>::get()); - if (pContainer) + if (!pContainer) + return; + + ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); + while (pIterator.hasMoreElements()) { - ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); - while (pIterator.hasMoreElements()) + try + { + // ... this pointer can be interesting to find out, where will be called as listener + // Don't optimize it to a direct iterator cast :-) + css::util::XRefreshListener* pListener = static_cast<css::util::XRefreshListener*>(pIterator.next()); + pListener->refreshed(aSource); + } + catch(const css::uno::Exception&) { - try - { - // ... this pointer can be interesting to find out, where will be called as listener - // Don't optimize it to a direct iterator cast :-) - css::util::XRefreshListener* pListener = static_cast<css::util::XRefreshListener*>(pIterator.next()); - pListener->refreshed(aSource); - } - catch(const css::uno::Exception&) - { - // ignore any "damaged" flush listener! - // May its remote reference is broken ... - pIterator.remove(); - } + // ignore any "damaged" flush listener! + // May its remote reference is broken ... + pIterator.remove(); } } } diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx index b552483e22c2..3e2b8f03e7e9 100644 --- a/filter/source/config/cache/typedetection.cxx +++ b/filter/source/config/cache/typedetection.cxx @@ -947,19 +947,19 @@ void TypeDetection::impl_seekStreamToZero(utl::MediaDescriptor const & rDescript utl::MediaDescriptor::PROP_INPUTSTREAM(), css::uno::Reference< css::io::XInputStream >()); css::uno::Reference< css::io::XSeekable > xSeek(xStream, css::uno::UNO_QUERY); - if (xSeek.is()) + if (!xSeek.is()) + return; + + try + { + xSeek->seek(0); + } + catch(const css::uno::RuntimeException&) + { + throw; + } + catch(const css::uno::Exception&) { - try - { - xSeek->seek(0); - } - catch(const css::uno::RuntimeException&) - { - throw; - } - catch(const css::uno::Exception&) - { - } } } diff --git a/filter/source/flash/swfwriter.cxx b/filter/source/flash/swfwriter.cxx index 979f13e3e78f..5ac5c4a17d8d 100644 --- a/filter/source/flash/swfwriter.cxx +++ b/filter/source/flash/swfwriter.cxx @@ -179,19 +179,19 @@ sal_uInt16 Writer::startSprite() void Writer::endSprite() { - if( mpSprite ) - { - startTag( TAG_END ); - endTag(); + if( !mpSprite ) + return; - mpSprite->write( *mpMovieStream ); - mpSprite.reset(); + startTag( TAG_END ); + endTag(); - if (!mvSpriteStack.empty()) - { - mpSprite.reset( mvSpriteStack.top() ); - mvSpriteStack.pop(); - } + mpSprite->write( *mpMovieStream ); + mpSprite.reset(); + + if (!mvSpriteStack.empty()) + { + mpSprite.reset( mvSpriteStack.top() ); + mvSpriteStack.pop(); } } diff --git a/filter/source/flash/swfwriter1.cxx b/filter/source/flash/swfwriter1.cxx index d48fc83e31e4..a926b50b0ffc 100644 --- a/filter/source/flash/swfwriter1.cxx +++ b/filter/source/flash/swfwriter1.cxx @@ -82,18 +82,18 @@ Size Writer::map( const Size& rSize ) const void Writer::map( tools::PolyPolygon& rPolyPolygon ) const { const sal_uInt16 nPolyCount = rPolyPolygon.Count(); - if( nPolyCount ) + if( !nPolyCount ) + return; + + sal_uInt16 nPoly, nPoint, nPointCount; + for( nPoly = 0; nPoly < nPolyCount; nPoly++ ) { - sal_uInt16 nPoly, nPoint, nPointCount; - for( nPoly = 0; nPoly < nPolyCount; nPoly++ ) - { - tools::Polygon& rPoly = rPolyPolygon[nPoly]; - nPointCount = rPoly.GetSize(); + tools::Polygon& rPoly = rPolyPolygon[nPoly]; + nPointCount = rPoly.GetSize(); - for( nPoint = 0; nPoint < nPointCount; nPoint++ ) - { - rPoly[nPoint] = map( rPoly[nPoint] ); - } + for( nPoint = 0; nPoint < nPointCount; nPoint++ ) + { + rPoly[nPoint] = map( rPoly[nPoint] ); } } } @@ -278,66 +278,66 @@ void Writer::Impl_writePolyPolygon( const tools::PolyPolygon& rPolyPoly, bool bF { tools::PolyPolygon aPolyPoly( rPolyPoly ); - if( aPolyPoly.Count() ) - { - map( aPolyPoly ); + if( !aPolyPoly.Count() ) + return; - if( mpClipPolyPolygon ) - rPolyPoly.GetIntersection( *mpClipPolyPolygon, aPolyPoly ); + map( aPolyPoly ); - sal_uInt16 nID; - if( bFilled ) - { - Color aFillColor( rFillColor ); - if( 0 != mnGlobalTransparency ) - aFillColor.SetTransparency( mnGlobalTransparency ); + if( mpClipPolyPolygon ) + rPolyPoly.GetIntersection( *mpClipPolyPolygon, aPolyPoly ); - FillStyle aStyle( aFillColor ); - nID = defineShape( aPolyPoly, aStyle ); - } - else - { - Color aLineColor( rLineColor ); - if( 0 != mnGlobalTransparency ) - aLineColor.SetTransparency( mnGlobalTransparency ); + sal_uInt16 nID; + if( bFilled ) + { + Color aFillColor( rFillColor ); + if( 0 != mnGlobalTransparency ) + aFillColor.SetTransparency( mnGlobalTransparency ); - nID = defineShape( aPolyPoly, 1, aLineColor ); - } - maShapeIds.push_back( nID ); + FillStyle aStyle( aFillColor ); + nID = defineShape( aPolyPoly, aStyle ); + } + else + { + Color aLineColor( rLineColor ); + if( 0 != mnGlobalTransparency ) + aLineColor.SetTransparency( mnGlobalTransparency ); + + nID = defineShape( aPolyPoly, 1, aLineColor ); } + maShapeIds.push_back( nID ); } /** A gradient is a transition from one color to another, rendered inside a given polypolygon */ void Writer::Impl_writeGradientEx( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient ) { - if( rPolyPoly.Count() ) - { - tools::PolyPolygon aPolyPolygon( rPolyPoly ); - map( aPolyPolygon ); + if( !rPolyPoly.Count() ) + return; - if( (rGradient.GetStyle() == GradientStyle::Linear && rGradient.GetAngle() == 900) || (rGradient.GetStyle() == GradientStyle::Radial) ) - { - const tools::Rectangle aBoundRect( aPolyPolygon.GetBoundRect() ); + tools::PolyPolygon aPolyPolygon( rPolyPoly ); + map( aPolyPolygon ); - FillStyle aFillStyle( aBoundRect, rGradient ); + if( (rGradient.GetStyle() == GradientStyle::Linear && rGradient.GetAngle() == 900) || (rGradient.GetStyle() == GradientStyle::Radial) ) + { + const tools::Rectangle aBoundRect( aPolyPolygon.GetBoundRect() ); - sal_uInt16 nShapeId = defineShape( aPolyPolygon, aFillStyle ); - maShapeIds.push_back( nShapeId ); - } - else - { - setClipping( &aPolyPolygon ); + FillStyle aFillStyle( aBoundRect, rGradient ); - // render the gradient filling to simple polygons - { - GDIMetaFile aTmpMtf; - mpVDev->AddGradientActions( aPolyPolygon.GetBoundRect(), rGradient, aTmpMtf ); - Impl_writeActions( aTmpMtf ); - } + sal_uInt16 nShapeId = defineShape( aPolyPolygon, aFillStyle ); + maShapeIds.push_back( nShapeId ); + } + else + { + setClipping( &aPolyPolygon ); - setClipping( nullptr ); + // render the gradient filling to simple polygons + { + GDIMetaFile aTmpMtf; + mpVDev->AddGradientActions( aPolyPolygon.GetBoundRect(), rGradient, aTmpMtf ); + Impl_writeActions( aTmpMtf ); } + + setClipping( nullptr ); } } @@ -781,98 +781,98 @@ sal_uInt16 Writer::defineBitmap( const BitmapEx &bmpSource, sal_Int32 nJPEGQuali void Writer::Impl_writeImage( const BitmapEx& rBmpEx, const Point& rPt, const Size& rSz, const Point& /* rSrcPt */, const Size& /* rSrcSz */, const tools::Rectangle& rClipRect, bool bNeedToMapClipRect ) { - if( !!rBmpEx ) - { - BitmapEx bmpSource( rBmpEx ); + if( !rBmpEx ) + return; - tools::Rectangle originalPixelRect(Point(), bmpSource.GetSizePixel()); + BitmapEx bmpSource( rBmpEx ); - Point srcPt( map(rPt) ); - Size srcSize( map(rSz) ); - tools::Rectangle destRect( srcPt, srcSize ); + tools::Rectangle originalPixelRect(Point(), bmpSource.GetSizePixel()); - // AS: Christian, my scaling factors are different than yours, and work better for me. - // However, I can't explain why exactly. I got some of this by trial and error. - double XScale = destRect.GetWidth() ? static_cast<double>(originalPixelRect.GetWidth())/destRect.GetWidth() : 1.0; - double YScale = destRect.GetHeight() ? static_cast<double>(originalPixelRect.GetHeight())/destRect.GetHeight() : 1.0; + Point srcPt( map(rPt) ); + Size srcSize( map(rSz) ); + tools::Rectangle destRect( srcPt, srcSize ); - // AS: If rClipRect has a value set, then we need to crop the bmp appropriately. - // If a map event already occurred in the metafile, then we do not need to map - // the clip rect as it's already been done. - if (!rClipRect.IsEmpty()) - { - // AS: Christian, I also don't understand why bNeedToMapClipRect is necessary, but it - // works like a charm. Usually, the map event in the meta file does not cause the - // clipping rectangle to get mapped. However, sometimes there are multiple layers - // of mapping which eventually do cause the clipping rect to be mapped. - Size clipSize( bNeedToMapClipRect ? map(rClipRect.GetSize()) : rClipRect.GetSize() ); - tools::Rectangle clipRect(Point(), clipSize); - destRect.Intersection( clipRect ); - - tools::Rectangle cropRect(destRect); - - // AS: The bmp origin is always 0,0 so we have to adjust before we crop. - cropRect.Move(-srcPt.X(), -srcPt.Y()); - // AS: Rectangle has no scale function (?!) so I do it manually... - tools::Rectangle cropPixelRect(static_cast<long>(cropRect.Left()*XScale), - static_cast<long>(cropRect.Top()*YScale), - static_cast<long>(cropRect.Right()*XScale), - static_cast<long>(cropRect.Bottom()*YScale)); - - bmpSource.Crop(cropPixelRect); - } + // AS: Christian, my scaling factors are different than yours, and work better for me. + // However, I can't explain why exactly. I got some of this by trial and error. + double XScale = destRect.GetWidth() ? static_cast<double>(originalPixelRect.GetWidth())/destRect.GetWidth() : 1.0; + double YScale = destRect.GetHeight() ? static_cast<double>(originalPixelRect.GetHeight())/destRect.GetHeight() : 1.0; - if( !!bmpSource ) - { - // #105949# fix images that are under 16 pixels width or height by - // expanding them. Some swf players can't display such small - // bitmaps - const Size& rSizePixel = bmpSource.GetSizePixel(); - if( (rSizePixel.Width() < 16) || (rSizePixel.Height() < 16) ) - { - const sal_uInt32 nDX = rSizePixel.Width() < 16 ? 16 - rSizePixel.Width() : 0; - const sal_uInt32 nDY = rSizePixel.Height() < 16 ? 16 - rSizePixel.Height() : 0; - bmpSource.Expand( nDX, nDY ); - } + // AS: If rClipRect has a value set, then we need to crop the bmp appropriately. + // If a map event already occurred in the metafile, then we do not need to map + // the clip rect as it's already been done. + if (!rClipRect.IsEmpty()) + { + // AS: Christian, I also don't understand why bNeedToMapClipRect is necessary, but it + // works like a charm. Usually, the map event in the meta file does not cause the + // clipping rectangle to get mapped. However, sometimes there are multiple layers + // of mapping which eventually do cause the clipping rect to be mapped. + Size clipSize( bNeedToMapClipRect ? map(rClipRect.GetSize()) : rClipRect.GetSize() ); + tools::Rectangle clipRect(Point(), clipSize); + destRect.Intersection( clipRect ); + + tools::Rectangle cropRect(destRect); + + // AS: The bmp origin is always 0,0 so we have to adjust before we crop. + cropRect.Move(-srcPt.X(), -srcPt.Y()); + // AS: Rectangle has no scale function (?!) so I do it manually... + tools::Rectangle cropPixelRect(static_cast<long>(cropRect.Left()*XScale), + static_cast<long>(cropRect.Top()*YScale), + static_cast<long>(cropRect.Right()*XScale), + static_cast<long>(cropRect.Bottom()*YScale)); + + bmpSource.Crop(cropPixelRect); + } - sal_Int32 nJPEGQuality = mnJPEGCompressMode; + if( !bmpSource ) + return; - Size szDestPixel = mpVDev->LogicToPixel(srcSize, aTWIPSMode); + // #105949# fix images that are under 16 pixels width or height by + // expanding them. Some swf players can't display such small + // bitmaps + const Size& rSizePixel = bmpSource.GetSizePixel(); + if( (rSizePixel.Width() < 16) || (rSizePixel.Height() < 16) ) + { + const sal_uInt32 nDX = rSizePixel.Width() < 16 ? 16 - rSizePixel.Width() : 0; + const sal_uInt32 nDY = rSizePixel.Height() < 16 ? 16 - rSizePixel.Height() : 0; + bmpSource.Expand( nDX, nDY ); + } - double pixXScale = originalPixelRect.GetWidth() ? static_cast<double>(szDestPixel.Width()) / originalPixelRect.GetWidth() : 1.0; - double pixYScale = originalPixelRect.GetHeight() ? static_cast<double>(szDestPixel.Height()) / originalPixelRect.GetHeight() : 1.0; + sal_Int32 nJPEGQuality = mnJPEGCompressMode; - // AS: If the image has been scaled down, then scale down the quality - // that we use for JPEG compression. - if (pixXScale < 1.0 && pixYScale < 1.0) - { + Size szDestPixel = mpVDev->LogicToPixel(srcSize, aTWIPSMode); - double qualityScale = (pixXScale + pixYScale)/2; + double pixXScale = originalPixelRect.GetWidth() ? static_cast<double>(szDestPixel.Width()) / originalPixelRect.GetWidth() : 1.0; + double pixYScale = originalPixelRect.GetHeight() ? static_cast<double>(szDestPixel.Height()) / originalPixelRect.GetHeight() : 1.0; - nJPEGQuality = static_cast<sal_Int32>( nJPEGQuality * qualityScale ); + // AS: If the image has been scaled down, then scale down the quality + // that we use for JPEG compression. + if (pixXScale < 1.0 && pixYScale < 1.0) + { - if (nJPEGQuality < 10) - nJPEGQuality += 3; - } + double qualityScale = (pixXScale + pixYScale)/2; - sal_uInt16 nBitmapId = defineBitmap(bmpSource, nJPEGQuality); + nJPEGQuality = static_cast<sal_Int32>( nJPEGQuality * qualityScale ); - tools::Polygon aPoly( destRect ); + if (nJPEGQuality < 10) + nJPEGQuality += 3; + } - // AS: Since images are being cropped now, no translation is normally necessary. - // However, some things like graphical bullet points still get translated. - ::basegfx::B2DHomMatrix m; // #i73264# - m.scale(1.0/XScale, 1.0/YScale ); - if (destRect.Left() || destRect.Top()) - m.translate(destRect.Left(), destRect.Top()); + sal_uInt16 nBitmapId = defineBitmap(bmpSource, nJPEGQuality); - FillStyle aFillStyle( nBitmapId, true, m ); + tools::Polygon aPoly( destRect ); - sal_uInt16 nShapeId = defineShape( aPoly, aFillStyle ); + // AS: Since images are being cropped now, no translation is normally necessary. + // However, some things like graphical bullet points still get translated. + ::basegfx::B2DHomMatrix m; // #i73264# + m.scale(1.0/XScale, 1.0/YScale ); + if (destRect.Left() || destRect.Top()) + m.translate(destRect.Left(), destRect.Top()); - maShapeIds.push_back( nShapeId ); - } - } + FillStyle aFillStyle( nBitmapId, true, m ); + + sal_uInt16 nShapeId = defineShape( aPoly, aFillStyle ); + + maShapeIds.push_back( nShapeId ); } @@ -1230,40 +1230,40 @@ bool Writer::Impl_writePageField( Rectangle& rTextBounds ) void Writer::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon) { - if(rLinePolygon.count()) - { - basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon); - basegfx::B2DPolyPolygon aFillPolyPolygon; + if(!rLinePolygon.count()) + return; + + basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon); + basegfx::B2DPolyPolygon aFillPolyPolygon; - rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon); + rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon); - if(aLinePolyPolygon.count()) + if(aLinePolyPolygon.count()) + { + for(sal_uInt32 a(0); a < aLinePolyPolygon.count(); a++) { - for(sal_uInt32 a(0); a < aLinePolyPolygon.count(); a++) - { - const basegfx::B2DPolygon& aCandidate(aLinePolyPolygon.getB2DPolygon(a)); - Impl_writePolygon( tools::Polygon(aCandidate), false ); - } + const basegfx::B2DPolygon& aCandidate(aLinePolyPolygon.getB2DPolygon(a)); + Impl_writePolygon( tools::Polygon(aCandidate), false ); } + } - if(aFillPolyPolygon.count()) - { - const Color aOldLineColor(mpVDev->GetLineColor()); - const Color aOldFillColor(mpVDev->GetFillColor()); + if(!aFillPolyPolygon.count()) + return; - mpVDev->SetLineColor(); - mpVDev->SetFillColor(aOldLineColor); + const Color aOldLineColor(mpVDev->GetLineColor()); + const Color aOldFillColor(mpVDev->GetFillColor()); - for(sal_uInt32 a(0); a < aFillPolyPolygon.count(); a++) - { - const tools::Polygon aPolygon(aFillPolyPolygon.getB2DPolygon(a)); - Impl_writePolyPolygon(tools::PolyPolygon(aPolygon), true ); - } + mpVDev->SetLineColor(); + mpVDev->SetFillColor(aOldLineColor); - mpVDev->SetLineColor(aOldLineColor); - mpVDev->SetFillColor(aOldFillColor); - } + for(sal_uInt32 a(0); a < aFillPolyPolygon.count(); a++) + { + const tools::Polygon aPolygon(aFillPolyPolygon.getB2DPolygon(a)); + Impl_writePolyPolygon(tools::PolyPolygon(aPolygon), true ); } + + mpVDev->SetLineColor(aOldLineColor); + mpVDev->SetFillColor(aOldFillColor); } diff --git a/filter/source/graphic/GraphicExportFilter.cxx b/filter/source/graphic/GraphicExportFilter.cxx index f2d0abbb33dc..b7123363ddd2 100644 --- a/filter/source/graphic/GraphicExportFilter.cxx +++ b/filter/source/graphic/GraphicExportFilter.cxx @@ -86,22 +86,22 @@ void GraphicExportFilter::gatherProperties( const uno::Sequence< beans::Property } } - if ( !aInternalFilterName.isEmpty() ) - { - GraphicFilter aGraphicFilter( true ); + if ( aInternalFilterName.isEmpty() ) + return; - sal_uInt16 nFilterCount = aGraphicFilter.GetExportFormatCount(); - sal_uInt16 nFormat; + GraphicFilter aGraphicFilter( true ); - for ( nFormat = 0; nFormat < nFilterCount; nFormat++ ) - { - if ( aGraphicFilter.GetExportInternalFilterName( nFormat ) == aInternalFilterName ) - break; - } - if ( nFormat < nFilterCount ) - { - maFilterExtension = aGraphicFilter.GetExportFormatShortName( nFormat ); - } + sal_uInt16 nFilterCount = aGraphicFilter.GetExportFormatCount(); + sal_uInt16 nFormat; + + for ( nFormat = 0; nFormat < nFilterCount; nFormat++ ) + { + if ( aGraphicFilter.GetExportInternalFilterName( nFormat ) == aInternalFilterName ) + break; + } + if ( nFormat < nFilterCount ) + { + maFilterExtension = aGraphicFilter.GetExportFormatShortName( nFormat ); } } 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; ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
