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 | |
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')
30 files changed, 4916 insertions, 4907 deletions
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; - 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); } diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index c01280a48232..2abe567fdbeb 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -319,27 +319,27 @@ static int EscherPropSortFunc( const void* p1, const void* p2 ) void EscherPropertyContainer::Commit( SvStream& rSt, sal_uInt16 nVersion, sal_uInt16 nRecType ) { rSt.WriteUInt16( ( nCountCount << 4 ) | ( nVersion & 0xf ) ).WriteUInt16( nRecType ).WriteUInt32( nCountSize ); - if ( !pSortStruct.empty() ) + if ( pSortStruct.empty() ) + return; + + qsort( pSortStruct.data(), pSortStruct.size(), sizeof( EscherPropSortStruct ), EscherPropSortFunc ); + + for ( size_t i = 0; i < pSortStruct.size(); i++ ) { - qsort( pSortStruct.data(), pSortStruct.size(), sizeof( EscherPropSortStruct ), EscherPropSortFunc ); + sal_uInt32 nPropValue = pSortStruct[ i ].nPropValue; + sal_uInt16 nPropId = pSortStruct[ i ].nPropId; + rSt.WriteUInt16( nPropId ) + .WriteUInt32( nPropValue ); + } + if ( bHasComplexData ) + { for ( size_t i = 0; i < pSortStruct.size(); i++ ) { - sal_uInt32 nPropValue = pSortStruct[ i ].nPropValue; - sal_uInt16 nPropId = pSortStruct[ i ].nPropId; - - rSt.WriteUInt16( nPropId ) - .WriteUInt32( nPropValue ); - } - if ( bHasComplexData ) - { - for ( size_t i = 0; i < pSortStruct.size(); i++ ) - { - if ( !pSortStruct[ i ].nProp.empty() ) - rSt.WriteBytes( - pSortStruct[i].nProp.data(), - pSortStruct[i].nProp.size()); - } + if ( !pSortStruct[ i ].nProp.empty() ) + rSt.WriteBytes( + pSortStruct[i].nProp.data(), + pSortStruct[i].nProp.size()); } } } @@ -845,19 +845,19 @@ void EscherPropertyContainer::CreateTextProperties( // n#404221: In case of rotation we need to write the txtflTextFlow // attribute too. // fdo#58204: not custom shapes (TODO: other cases when it doesn't work?) - if (bIsTextFrame && !bIsCustomShape) + if (!(bIsTextFrame && !bIsCustomShape)) + return; + + sal_uInt16 nAngle = EscherPropertyValueHelper::GetPropertyValue( + aAny, rXPropSet, "RotateAngle", true ) ? + static_cast<sal_uInt16>( ( *o3tl::doAccess<sal_Int32>(aAny) ) + 5 ) / 10 : 0; + if (nAngle==900) { - sal_uInt16 nAngle = EscherPropertyValueHelper::GetPropertyValue( - aAny, rXPropSet, "RotateAngle", true ) ? - static_cast<sal_uInt16>( ( *o3tl::doAccess<sal_Int32>(aAny) ) + 5 ) / 10 : 0; - if (nAngle==900) - { - AddOpt( ESCHER_Prop_txflTextFlow, ESCHER_txflBtoT ); - } - if (nAngle==2700) - { - AddOpt( ESCHER_Prop_txflTextFlow, ESCHER_txflTtoBA ); - } + AddOpt( ESCHER_Prop_txflTextFlow, ESCHER_txflBtoT ); + } + if (nAngle==2700) + { + AddOpt( ESCHER_Prop_txflTextFlow, ESCHER_txflTtoBA ); } } @@ -1260,71 +1260,71 @@ void EscherPropertyContainer::ImplCreateGraphicAttributes( const uno::Reference< if ( nPicFlags ) AddOpt( ESCHER_Prop_pictureActive, nPicFlags ); - if ( bCreateCroppingAttributes && pGraphicProvider ) + if ( !(bCreateCroppingAttributes && pGraphicProvider) ) + return; + + Size aPrefSize; + MapMode aPrefMapMode; + if ( !pGraphicProvider->GetPrefSize( nBlibId, aPrefSize, aPrefMapMode ) ) + return; + + Size aCropSize(lcl_SizeToEmu(aPrefSize, aPrefMapMode)); + if ( !(aCropSize.Width() && aCropSize.Height()) ) + return; + + if ( !EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, "GraphicCrop" ) ) + return; + + text::GraphicCrop aGraphCrop; + if ( !(aAny >>= aGraphCrop) ) + return; + + if ( aGraphCrop.Left ) { - Size aPrefSize; - MapMode aPrefMapMode; - if ( pGraphicProvider->GetPrefSize( nBlibId, aPrefSize, aPrefMapMode ) ) - { - Size aCropSize(lcl_SizeToEmu(aPrefSize, aPrefMapMode)); - if ( aCropSize.Width() && aCropSize.Height() ) - { - if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, "GraphicCrop" ) ) - { - text::GraphicCrop aGraphCrop; - if ( aAny >>= aGraphCrop ) - { - if ( aGraphCrop.Left ) - { - sal_uInt32 nLeft = ( aGraphCrop.Left * 65536 ) / aCropSize.Width(); - AddOpt( ESCHER_Prop_cropFromLeft, nLeft ); - } - if ( aGraphCrop.Top ) - { - sal_uInt32 nTop = ( aGraphCrop.Top * 65536 ) / aCropSize.Height(); - AddOpt( ESCHER_Prop_cropFromTop, nTop ); - } - if ( aGraphCrop.Right ) - { - sal_uInt32 nRight = ( aGraphCrop.Right * 65536 ) / aCropSize.Width(); - AddOpt( ESCHER_Prop_cropFromRight, nRight ); - } - if ( aGraphCrop.Bottom ) - { - sal_uInt32 nBottom = ( aGraphCrop.Bottom * 65536 ) / aCropSize.Height(); - AddOpt( ESCHER_Prop_cropFromBottom, nBottom ); - } - } - } - } - } + sal_uInt32 nLeft = ( aGraphCrop.Left * 65536 ) / aCropSize.Width(); + AddOpt( ESCHER_Prop_cropFromLeft, nLeft ); + } + if ( aGraphCrop.Top ) + { + sal_uInt32 nTop = ( aGraphCrop.Top * 65536 ) / aCropSize.Height(); + AddOpt( ESCHER_Prop_cropFromTop, nTop ); + } + if ( aGraphCrop.Right ) + { + sal_uInt32 nRight = ( aGraphCrop.Right * 65536 ) / aCropSize.Width(); + AddOpt( ESCHER_Prop_cropFromRight, nRight ); + } + if ( aGraphCrop.Bottom ) + { + sal_uInt32 nBottom = ( aGraphCrop.Bottom * 65536 ) / aCropSize.Height(); + AddOpt( ESCHER_Prop_cropFromBottom, nBottom ); } } void EscherPropertyContainer::CreateShapeProperties( const uno::Reference<drawing::XShape> & rXShape ) { uno::Reference< beans::XPropertySet > aXPropSet( rXShape, uno::UNO_QUERY ); - if ( aXPropSet.is() ) + if ( !aXPropSet.is() ) + return; + + bool bVisible = false; + bool bPrintable = false; + uno::Any aAny; + sal_uInt32 nShapeAttr = 0; + if (EscherPropertyValueHelper::GetPropertyValue(aAny, aXPropSet, "Visible", true) && (aAny >>= bVisible)) { - bool bVisible = false; - bool bPrintable = false; - uno::Any aAny; - sal_uInt32 nShapeAttr = 0; - if (EscherPropertyValueHelper::GetPropertyValue(aAny, aXPropSet, "Visible", true) && (aAny >>= bVisible)) - { - if ( !bVisible ) - nShapeAttr |= 0x20002; // set fHidden = true - } - // This property (fPrint) isn't used in Excel anymore, leaving it for legacy reasons - // one change, based on XLSX: hidden implies not printed, let's not export the fPrint property in that case - if (bVisible && EscherPropertyValueHelper::GetPropertyValue(aAny, aXPropSet, "Printable", true) && (aAny >>= bPrintable)) - { - if ( !bPrintable ) - nShapeAttr |= 0x10000; // set fPrint = false; - } - if ( nShapeAttr ) - AddOpt( ESCHER_Prop_fPrint, nShapeAttr ); + if ( !bVisible ) + nShapeAttr |= 0x20002; // set fHidden = true + } + // This property (fPrint) isn't used in Excel anymore, leaving it for legacy reasons + // one change, based on XLSX: hidden implies not printed, let's not export the fPrint property in that case + if (bVisible && EscherPropertyValueHelper::GetPropertyValue(aAny, aXPropSet, "Printable", true) && (aAny >>= bPrintable)) + { + if ( !bPrintable ) + nShapeAttr |= 0x10000; // set fPrint = false; } + if ( nShapeAttr ) + AddOpt( ESCHER_Prop_fPrint, nShapeAttr ); } bool EscherPropertyContainer::CreateOLEGraphicProperties(const uno::Reference<drawing::XShape> & rXShape) @@ -2441,67 +2441,67 @@ static void ConvertEnhancedCustomShapeEquation( if ( pAny ) *pAny >>= sEquationSource; sal_Int32 nEquationSourceCount = sEquationSource.getLength(); - if ( nEquationSourceCount && (nEquationSourceCount <= 128) ) + if ( !(nEquationSourceCount && (nEquationSourceCount <= 128)) ) + return; + + sal_Int32 i; + for ( i = 0; i < nEquationSourceCount; i++ ) { - sal_Int32 i; - for ( i = 0; i < nEquationSourceCount; i++ ) + EnhancedCustomShape2d aCustoShape2d( + const_cast< SdrObjCustomShape& >(rSdrObjCustomShape)); + try { - EnhancedCustomShape2d aCustoShape2d( - const_cast< SdrObjCustomShape& >(rSdrObjCustomShape)); - try - { - std::shared_ptr< EnhancedCustomShape::ExpressionNode > aExpressNode( - EnhancedCustomShape::FunctionParser::parseFunction( - sEquationSource[ i ], aCustoShape2d)); - drawing::EnhancedCustomShapeParameter aPara( aExpressNode->fillNode( rEquations, nullptr, 0 ) ); - if ( aPara.Type != drawing::EnhancedCustomShapeParameterType::EQUATION ) - { - EnhancedCustomShapeEquation aEquation; - aEquation.nOperation = 0; - EnhancedCustomShape::FillEquationParameter( aPara, 0, aEquation ); - rEquations.push_back( aEquation ); - } - } - catch ( const EnhancedCustomShape::ParseError& ) + std::shared_ptr< EnhancedCustomShape::ExpressionNode > aExpressNode( + EnhancedCustomShape::FunctionParser::parseFunction( + sEquationSource[ i ], aCustoShape2d)); + drawing::EnhancedCustomShapeParameter aPara( aExpressNode->fillNode( rEquations, nullptr, 0 ) ); + if ( aPara.Type != drawing::EnhancedCustomShapeParameterType::EQUATION ) { - EnhancedCustomShapeEquation aEquation; // ups, we should not be here, - aEquation.nOperation = 0; // creating a default equation with value 1 - aEquation.nPara[ 0 ] = 1; // hoping that this will not break anything + EnhancedCustomShapeEquation aEquation; + aEquation.nOperation = 0; + EnhancedCustomShape::FillEquationParameter( aPara, 0, aEquation ); rEquations.push_back( aEquation ); } - catch ( ... ) - { - EnhancedCustomShapeEquation aEquation; // #i112309# EnhancedCustomShape::Parse error - aEquation.nOperation = 0; // not caught on linux platform - aEquation.nPara[ 0 ] = 1; - rEquations.push_back( aEquation ); - } - rEquationOrder.push_back( rEquations.size() - 1 ); } - // now updating our old equation indices, they are marked with a bit in the hiword of nOperation - for (auto & equation : rEquations) + catch ( const EnhancedCustomShape::ParseError& ) { - sal_uInt32 nMask = 0x20000000; - for( i = 0; i < 3; i++ ) + EnhancedCustomShapeEquation aEquation; // ups, we should not be here, + aEquation.nOperation = 0; // creating a default equation with value 1 + aEquation.nPara[ 0 ] = 1; // hoping that this will not break anything + rEquations.push_back( aEquation ); + } + catch ( ... ) + { + EnhancedCustomShapeEquation aEquation; // #i112309# EnhancedCustomShape::Parse error + aEquation.nOperation = 0; // not caught on linux platform + aEquation.nPara[ 0 ] = 1; + rEquations.push_back( aEquation ); + } + rEquationOrder.push_back( rEquations.size() - 1 ); + } + // now updating our old equation indices, they are marked with a bit in the hiword of nOperation + for (auto & equation : rEquations) + { + sal_uInt32 nMask = 0x20000000; + for( i = 0; i < 3; i++ ) + { + if ( equation.nOperation & nMask ) { - if ( equation.nOperation & nMask ) - { - equation.nOperation ^= nMask; - const size_t nIndex(equation.nPara[ i ] & 0x3ff); + equation.nOperation ^= nMask; + const size_t nIndex(equation.nPara[ i ] & 0x3ff); - // #i124661# check index access, there are cases where this is out of bound leading - // to errors up to crashes when executed - if(nIndex < rEquationOrder.size()) - { - equation.nPara[ i ] = rEquationOrder[ nIndex ] | 0x400; - } - else - { - OSL_ENSURE(false, "Attempted out of bound access to rEquationOrder of CustomShape (!)"); - } + // #i124661# check index access, there are cases where this is out of bound leading + // to errors up to crashes when executed + if(nIndex < rEquationOrder.size()) + { + equation.nPara[ i ] = rEquationOrder[ nIndex ] | 0x400; + } + else + { + OSL_ENSURE(false, "Attempted out of bound access to rEquationOrder of CustomShape (!)"); } - nMask <<= 1; } + nMask <<= 1; } } } @@ -2533,8 +2533,9 @@ bool EscherPropertyContainer::IsDefaultObject( void EscherPropertyContainer::LookForPolarHandles( const MSO_SPT eShapeType, sal_Int32& nAdjustmentsWhichNeedsToBeConverted ) { const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eShapeType ); - if ( pDefCustomShape && pDefCustomShape->nHandles && pDefCustomShape->pHandles ) - { + if ( !(pDefCustomShape && pDefCustomShape->nHandles && pDefCustomShape->pHandles) ) + return; + sal_Int32 k, nkCount = pDefCustomShape->nHandles; const SvxMSDffHandle* pData = pDefCustomShape->pHandles; for ( k = 0; k < nkCount; k++, pData++ ) @@ -2545,7 +2546,6 @@ void EscherPropertyContainer::LookForPolarHandles( const MSO_SPT eShapeType, sal nAdjustmentsWhichNeedsToBeConverted |= ( 1 << k ); } } - } } bool EscherPropertyContainer::GetAdjustmentValue( const drawing::EnhancedCustomShapeAdjustmentValue & rkProp, sal_Int32 nIndex, sal_Int32 nAdjustmentsWhichNeedsToBeConverted, sal_Int32& nValue ) @@ -2575,1158 +2575,1158 @@ bool EscherPropertyContainer::GetAdjustmentValue( const drawing::EnhancedCustomS void EscherPropertyContainer::CreateCustomShapeProperties( const MSO_SPT eShapeType, const uno::Reference< drawing::XShape > & rXShape ) { uno::Reference< beans::XPropertySet > aXPropSet( rXShape, uno::UNO_QUERY ); - if ( aXPropSet.is() ) + if ( !aXPropSet.is() ) + return; + + if(nullptr == dynamic_cast< SdrObjCustomShape* >(GetSdrObjectFromXShape(rXShape))) { - if(nullptr == dynamic_cast< SdrObjCustomShape* >(GetSdrObjectFromXShape(rXShape))) + return; + } + + SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& >(*GetSdrObjectFromXShape(rXShape))); + const OUString sCustomShapeGeometry( "CustomShapeGeometry" ); + uno::Any aGeoPropSet = aXPropSet->getPropertyValue( sCustomShapeGeometry ); + uno::Sequence< beans::PropertyValue > aGeoPropSeq; + if ( !(aGeoPropSet >>= aGeoPropSeq) ) + return; + + const OUString sViewBox ( "ViewBox" ); + const OUString sTextRotateAngle ( "TextRotateAngle" ); + const OUString sExtrusion ( "Extrusion" ); + const OUString sEquations ( "Equations" ); + const OUString sPath ( "Path" ); + const OUString sTextPath ( "TextPath" ); + const OUString sHandles ( "Handles" ); + const OUString sAdjustmentValues ( "AdjustmentValues" ); + + bool bAdjustmentValuesProp = false; + uno::Any aAdjustmentValuesProp; + bool bPathCoordinatesProp = false; + uno::Any aPathCoordinatesProp; + + sal_Int32 nAdjustmentsWhichNeedsToBeConverted = 0; + uno::Sequence< beans::PropertyValues > aHandlesPropSeq; + bool bPredefinedHandlesUsed = true; + const bool bIsDefaultObject( + IsDefaultObject( + rSdrObjCustomShape, + eShapeType)); + + // convert property "Equations" into std::vector< EnhancedCustomShapeEquationEquation > + std::vector< EnhancedCustomShapeEquation > aEquations; + std::vector< sal_Int32 > aEquationOrder; + ConvertEnhancedCustomShapeEquation( + rSdrObjCustomShape, + aEquations, + aEquationOrder); + + sal_Int32 i, nCount = aGeoPropSeq.getLength(); + for ( i = 0; i < nCount; i++ ) + { + const beans::PropertyValue& rProp = aGeoPropSeq[ i ]; + if ( rProp.Name == sViewBox ) { - return; + if ( !bIsDefaultObject ) + { + awt::Rectangle aViewBox; + if ( rProp.Value >>= aViewBox ) + { + AddOpt( DFF_Prop_geoLeft, aViewBox.X ); + AddOpt( DFF_Prop_geoTop, aViewBox.Y ); + AddOpt( DFF_Prop_geoRight, aViewBox.X + aViewBox.Width ); + AddOpt( DFF_Prop_geoBottom,aViewBox.Y + aViewBox.Height ); + } + } } - - SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& >(*GetSdrObjectFromXShape(rXShape))); - const OUString sCustomShapeGeometry( "CustomShapeGeometry" ); - uno::Any aGeoPropSet = aXPropSet->getPropertyValue( sCustomShapeGeometry ); - uno::Sequence< beans::PropertyValue > aGeoPropSeq; - if ( aGeoPropSet >>= aGeoPropSeq ) + else if ( rProp.Name == sTextRotateAngle ) + { + double f = 0; + if ( rProp.Value >>= f ) + { + double fTextRotateAngle = fmod( f, 360.0 ); + if ( fTextRotateAngle < 0 ) + fTextRotateAngle = 360 + fTextRotateAngle; + if ( ( fTextRotateAngle < 271.0 ) && ( fTextRotateAngle > 269.0 ) ) + AddOpt( DFF_Prop_cdirFont, mso_cdir90 ); + else if ( ( fTextRotateAngle < 181.0 ) && ( fTextRotateAngle > 179.0 ) ) + AddOpt( DFF_Prop_cdirFont, mso_cdir180 ); + else if ( ( fTextRotateAngle < 91.0 ) && ( fTextRotateAngle > 79.0 ) ) + AddOpt( DFF_Prop_cdirFont, mso_cdir270 ); + } + } + else if ( rProp.Name == sExtrusion ) { - const OUString sViewBox ( "ViewBox" ); - const OUString sTextRotateAngle ( "TextRotateAngle" ); - const OUString sExtrusion ( "Extrusion" ); - const OUString sEquations ( "Equations" ); - const OUString sPath ( "Path" ); - const OUString sTextPath ( "TextPath" ); - const OUString sHandles ( "Handles" ); - const OUString sAdjustmentValues ( "AdjustmentValues" ); - - bool bAdjustmentValuesProp = false; - uno::Any aAdjustmentValuesProp; - bool bPathCoordinatesProp = false; - uno::Any aPathCoordinatesProp; - - sal_Int32 nAdjustmentsWhichNeedsToBeConverted = 0; - uno::Sequence< beans::PropertyValues > aHandlesPropSeq; - bool bPredefinedHandlesUsed = true; - const bool bIsDefaultObject( - IsDefaultObject( - rSdrObjCustomShape, - eShapeType)); - - // convert property "Equations" into std::vector< EnhancedCustomShapeEquationEquation > - std::vector< EnhancedCustomShapeEquation > aEquations; - std::vector< sal_Int32 > aEquationOrder; - ConvertEnhancedCustomShapeEquation( - rSdrObjCustomShape, - aEquations, - aEquationOrder); - - sal_Int32 i, nCount = aGeoPropSeq.getLength(); - for ( i = 0; i < nCount; i++ ) + uno::Sequence< beans::PropertyValue > aExtrusionPropSeq; + if ( rProp.Value >>= aExtrusionPropSeq ) { - const beans::PropertyValue& rProp = aGeoPropSeq[ i ]; - if ( rProp.Name == sViewBox ) + sal_uInt32 nLightFaceFlagsOrg, nLightFaceFlags; + sal_uInt32 nFillHarshFlagsOrg, nFillHarshFlags; + nLightFaceFlagsOrg = nLightFaceFlags = 0x000001; + nFillHarshFlagsOrg = nFillHarshFlags = 0x00001e; + if ( GetOpt( DFF_Prop_fc3DLightFace, nLightFaceFlags ) ) + nLightFaceFlagsOrg = nLightFaceFlags; + if ( GetOpt( DFF_Prop_fc3DFillHarsh, nFillHarshFlags ) ) + nFillHarshFlagsOrg = nFillHarshFlags; + + sal_Int32 r, nrCount = aExtrusionPropSeq.getLength(); + for ( r = 0; r < nrCount; r++ ) { - if ( !bIsDefaultObject ) + const beans::PropertyValue& rrProp = aExtrusionPropSeq[ r ]; + const OUString sExtrusionBrightness ( "Brightness" ); + const OUString sExtrusionDepth ( "Depth" ); + const OUString sExtrusionDiffusion ( "Diffusion" ); + const OUString sExtrusionNumberOfLineSegments ( "NumberOfLineSegments" ); + const OUString sExtrusionLightFace ( "LightFace" ); + const OUString sExtrusionFirstLightHarsh ( "FirstLightHarsh" ); + const OUString sExtrusionSecondLightHarsh ( "SecondLightHarsh" ); + const OUString sExtrusionFirstLightLevel ( "FirstLightLevel" ); + const OUString sExtrusionSecondLightLevel ( "SecondLightLevel" ); + const OUString sExtrusionFirstLightDirection ( "FirstLightDirection" ); + const OUString sExtrusionSecondLightDirection ( "SecondLightDirection" ); + const OUString sExtrusionMetal ( "Metal" ); + const OUString sExtrusionShadeMode ( "ShadeMode" ); + const OUString sExtrusionRotateAngle ( "RotateAngle" ); + const OUString sExtrusionRotationCenter ( "RotationCenter" ); + const OUString sExtrusionShininess ( "Shininess" ); + const OUString sExtrusionSkew ( "Skew" ); + const OUString sExtrusionSpecularity ( "Specularity" ); + const OUString sExtrusionProjectionMode ( "ProjectionMode" ); + const OUString sExtrusionViewPoint ( "ViewPoint" ); + const OUString sExtrusionOrigin ( "Origin" ); + const OUString sExtrusionColor ( "Color" ); + + if ( rrProp.Name == sExtrusion ) { - awt::Rectangle aViewBox; - if ( rProp.Value >>= aViewBox ) + bool bExtrusionOn; + if ( rrProp.Value >>= bExtrusionOn ) { - AddOpt( DFF_Prop_geoLeft, aViewBox.X ); - AddOpt( DFF_Prop_geoTop, aViewBox.Y ); - AddOpt( DFF_Prop_geoRight, aViewBox.X + aViewBox.Width ); - AddOpt( DFF_Prop_geoBottom,aViewBox.Y + aViewBox.Height ); + nLightFaceFlags |= 0x80000; + if ( bExtrusionOn ) + nLightFaceFlags |= 8; + else + nLightFaceFlags &=~8; } } - } - else if ( rProp.Name == sTextRotateAngle ) - { - double f = 0; - if ( rProp.Value >>= f ) + else if ( rrProp.Name == sExtrusionBrightness ) { - double fTextRotateAngle = fmod( f, 360.0 ); - if ( fTextRotateAngle < 0 ) - fTextRotateAngle = 360 + fTextRotateAngle; - if ( ( fTextRotateAngle < 271.0 ) && ( fTextRotateAngle > 269.0 ) ) - AddOpt( DFF_Prop_cdirFont, mso_cdir90 ); - else if ( ( fTextRotateAngle < 181.0 ) && ( fTextRotateAngle > 179.0 ) ) - AddOpt( DFF_Prop_cdirFont, mso_cdir180 ); - else if ( ( fTextRotateAngle < 91.0 ) && ( fTextRotateAngle > 79.0 ) ) - AddOpt( DFF_Prop_cdirFont, mso_cdir270 ); + double fExtrusionBrightness = 0; + if ( rrProp.Value >>= fExtrusionBrightness ) + AddOpt( DFF_Prop_c3DAmbientIntensity, static_cast<sal_Int32>( fExtrusionBrightness * 655.36 ) ); } - } - else if ( rProp.Name == sExtrusion ) - { - uno::Sequence< beans::PropertyValue > aExtrusionPropSeq; - if ( rProp.Value >>= aExtrusionPropSeq ) + else if ( rrProp.Name == sExtrusionDepth ) { - sal_uInt32 nLightFaceFlagsOrg, nLightFaceFlags; - sal_uInt32 nFillHarshFlagsOrg, nFillHarshFlags; - nLightFaceFlagsOrg = nLightFaceFlags = 0x000001; - nFillHarshFlagsOrg = nFillHarshFlags = 0x00001e; - if ( GetOpt( DFF_Prop_fc3DLightFace, nLightFaceFlags ) ) - nLightFaceFlagsOrg = nLightFaceFlags; - if ( GetOpt( DFF_Prop_fc3DFillHarsh, nFillHarshFlags ) ) - nFillHarshFlagsOrg = nFillHarshFlags; - - sal_Int32 r, nrCount = aExtrusionPropSeq.getLength(); - for ( r = 0; r < nrCount; r++ ) + double fDepth = 0; + double fFraction = 0; + drawing::EnhancedCustomShapeParameterPair aDepthParaPair; + if ( ( rrProp.Value >>= aDepthParaPair ) && ( aDepthParaPair.First.Value >>= fDepth ) && ( aDepthParaPair.Second.Value >>= fFraction ) ) { - const beans::PropertyValue& rrProp = aExtrusionPropSeq[ r ]; - const OUString sExtrusionBrightness ( "Brightness" ); - const OUString sExtrusionDepth ( "Depth" ); - const OUString sExtrusionDiffusion ( "Diffusion" ); - const OUString sExtrusionNumberOfLineSegments ( "NumberOfLineSegments" ); - const OUString sExtrusionLightFace ( "LightFace" ); - const OUString sExtrusionFirstLightHarsh ( "FirstLightHarsh" ); - const OUString sExtrusionSecondLightHarsh ( "SecondLightHarsh" ); - const OUString sExtrusionFirstLightLevel ( "FirstLightLevel" ); - const OUString sExtrusionSecondLightLevel ( "SecondLightLevel" ); - const OUString sExtrusionFirstLightDirection ( "FirstLightDirection" ); - const OUString sExtrusionSecondLightDirection ( "SecondLightDirection" ); - const OUString sExtrusionMetal ( "Metal" ); - const OUString sExtrusionShadeMode ( "ShadeMode" ); - const OUString sExtrusionRotateAngle ( "RotateAngle" ); - const OUString sExtrusionRotationCenter ( "RotationCenter" ); - const OUString sExtrusionShininess ( "Shininess" ); - const OUString sExtrusionSkew ( "Skew" ); - const OUString sExtrusionSpecularity ( "Specularity" ); - const OUString sExtrusionProjectionMode ( "ProjectionMode" ); - const OUString sExtrusionViewPoint ( "ViewPoint" ); - const OUString sExtrusionOrigin ( "Origin" ); - const OUString sExtrusionColor ( "Color" ); - - if ( rrProp.Name == sExtrusion ) - { - bool bExtrusionOn; - if ( rrProp.Value >>= bExtrusionOn ) - { - nLightFaceFlags |= 0x80000; - if ( bExtrusionOn ) - nLightFaceFlags |= 8; - else - nLightFaceFlags &=~8; - } - } - else if ( rrProp.Name == sExtrusionBrightness ) - { - double fExtrusionBrightness = 0; - if ( rrProp.Value >>= fExtrusionBrightness ) - AddOpt( DFF_Prop_c3DAmbientIntensity, static_cast<sal_Int32>( fExtrusionBrightness * 655.36 ) ); - } - else if ( rrProp.Name == sExtrusionDepth ) - { - double fDepth = 0; - double fFraction = 0; - drawing::EnhancedCustomShapeParameterPair aDepthParaPair; - if ( ( rrProp.Value >>= aDepthParaPair ) && ( aDepthParaPair.First.Value >>= fDepth ) && ( aDepthParaPair.Second.Value >>= fFraction ) ) - { - double fForeDepth = fDepth * fFraction; - double fBackDepth = fDepth - fForeDepth; + double fForeDepth = fDepth * fFraction; + double fBackDepth = fDepth - fForeDepth; - fBackDepth *= 360.0; - AddOpt( DFF_Prop_c3DExtrudeBackward, static_cast<sal_Int32>(fBackDepth) ); + fBackDepth *= 360.0; + AddOpt( DFF_Prop_c3DExtrudeBackward, static_cast<sal_Int32>(fBackDepth) ); - if ( fForeDepth != 0.0 ) - { - fForeDepth *= 360.0; - AddOpt( DFF_Prop_c3DExtrudeForward, static_cast<sal_Int32>(fForeDepth) ); - } - } - } - else if ( rrProp.Name == sExtrusionDiffusion ) - { - double fExtrusionDiffusion = 0; - if ( rrProp.Value >>= fExtrusionDiffusion ) - AddOpt( DFF_Prop_c3DDiffuseAmt, static_cast<sal_Int32>( fExtrusionDiffusion * 655.36 ) ); - } - else if ( rrProp.Name == sExtrusionNumberOfLineSegments ) + if ( fForeDepth != 0.0 ) { - sal_Int32 nExtrusionNumberOfLineSegments = 0; - if ( rrProp.Value >>= nExtrusionNumberOfLineSegments ) - AddOpt( DFF_Prop_c3DTolerance, nExtrusionNumberOfLineSegments ); + fForeDepth *= 360.0; + AddOpt( DFF_Prop_c3DExtrudeForward, static_cast<sal_Int32>(fForeDepth) ); } - else if ( rrProp.Name == sExtrusionLightFace ) - { - bool bExtrusionLightFace; - if ( rrProp.Value >>= bExtrusionLightFace ) - { - nLightFaceFlags |= 0x10000; - if ( bExtrusionLightFace ) - nLightFaceFlags |= 1; - else - nLightFaceFlags &=~1; - } - } - else if ( rrProp.Name == sExtrusionFirstLightHarsh ) - { - bool bExtrusionFirstLightHarsh; - if ( rrProp.Value >>= bExtrusionFirstLightHarsh ) - { - nFillHarshFlags |= 0x20000; - if ( bExtrusionFirstLightHarsh ) - nFillHarshFlags |= 2; - else - nFillHarshFlags &=~2; - } - } - else if ( rrProp.Name == sExtrusionSecondLightHarsh ) + } + } + else if ( rrProp.Name == sExtrusionDiffusion ) + { + double fExtrusionDiffusion = 0; + if ( rrProp.Value >>= fExtrusionDiffusion ) + AddOpt( DFF_Prop_c3DDiffuseAmt, static_cast<sal_Int32>( fExtrusionDiffusion * 655.36 ) ); + } + else if ( rrProp.Name == sExtrusionNumberOfLineSegments ) + { + sal_Int32 nExtrusionNumberOfLineSegments = 0; + if ( rrProp.Value >>= nExtrusionNumberOfLineSegments ) + AddOpt( DFF_Prop_c3DTolerance, nExtrusionNumberOfLineSegments ); + } + else if ( rrProp.Name == sExtrusionLightFace ) + { + bool bExtrusionLightFace; + if ( rrProp.Value >>= bExtrusionLightFace ) + { + nLightFaceFlags |= 0x10000; + if ( bExtrusionLightFace ) + nLightFaceFlags |= 1; + else + nLightFaceFlags &=~1; + } + } + else if ( rrProp.Name == sExtrusionFirstLightHarsh ) + { + bool bExtrusionFirstLightHarsh; + if ( rrProp.Value >>= bExtrusionFirstLightHarsh ) + { + nFillHarshFlags |= 0x20000; + if ( bExtrusionFirstLightHarsh ) + nFillHarshFlags |= 2; + else + nFillHarshFlags &=~2; + } + } + else if ( rrProp.Name == sExtrusionSecondLightHarsh ) + { + bool bExtrusionSecondLightHarsh; + if ( rrProp.Value >>= bExtrusionSecondLightHarsh ) + { + nFillHarshFlags |= 0x10000; + if ( bExtrusionSecondLightHarsh ) + nFillHarshFlags |= 1; + else + nFillHarshFlags &=~1; + } + } + else if ( rrProp.Name == sExtrusionFirstLightLevel ) + { + double fExtrusionFirstLightLevel = 0; + if ( rrProp.Value >>= fExtrusionFirstLightLevel ) + AddOpt( DFF_Prop_c3DKeyIntensity, static_cast<sal_Int32>( fExtrusionFirstLightLevel * 655.36 ) ); + } + else if ( rrProp.Name == sExtrusionSecondLightLevel ) + { + double fExtrusionSecondLightLevel = 0; + if ( rrProp.Value >>= fExtrusionSecondLightLevel ) + AddOpt( DFF_Prop_c3DFillIntensity, static_cast<sal_Int32>( fExtrusionSecondLightLevel * 655.36 ) ); + } + else if ( rrProp.Name == sExtrusionFirstLightDirection ) + { + drawing::Direction3D aExtrusionFirstLightDirection; + if ( rrProp.Value >>= aExtrusionFirstLightDirection ) + { + AddOpt( DFF_Prop_c3DKeyX, static_cast<sal_Int32>(aExtrusionFirstLightDirection.DirectionX) ); + AddOpt( DFF_Prop_c3DKeyY, static_cast<sal_Int32>(aExtrusionFirstLightDirection.DirectionY) ); + AddOpt( DFF_Prop_c3DKeyZ, static_cast<sal_Int32>(aExtrusionFirstLightDirection.DirectionZ) ); + } + } + else if ( rrProp.Name == sExtrusionSecondLightDirection ) + { + drawing::Direction3D aExtrusionSecondLightPosition; + if ( rrProp.Value >>= aExtrusionSecondLightPosition ) + { + AddOpt( DFF_Prop_c3DFillX, static_cast<sal_Int32>(aExtrusionSecondLightPosition.DirectionX) ); + AddOpt( DFF_Prop_c3DFillY, static_cast<sal_Int32>(aExtrusionSecondLightPosition.DirectionY) ); + AddOpt( DFF_Prop_c3DFillZ, static_cast<sal_Int32>(aExtrusionSecondLightPosition.DirectionZ) ); + } + } + else if ( rrProp.Name == sExtrusionMetal ) + { + bool bExtrusionMetal; + if ( rrProp.Value >>= bExtrusionMetal ) + { + nLightFaceFlags |= 0x40000; + if ( bExtrusionMetal ) + nLightFaceFlags |= 4; + else + nLightFaceFlags &=~4; + } + } + else if ( rrProp.Name == sExtrusionShadeMode ) + { + drawing::ShadeMode eExtrusionShadeMode; + if ( rrProp.Value >>= eExtrusionShadeMode ) + { + sal_uInt32 nRenderMode; + switch( eExtrusionShadeMode ) { - bool bExtrusionSecondLightHarsh; - if ( rrProp.Value >>= bExtrusionSecondLightHarsh ) + default: + case drawing::ShadeMode_FLAT : + case drawing::ShadeMode_PHONG : + case drawing::ShadeMode_SMOOTH : + nRenderMode = mso_FullRender; + break; + case drawing::ShadeMode_DRAFT : { - nFillHarshFlags |= 0x10000; - if ( bExtrusionSecondLightHarsh ) - nFillHarshFlags |= 1; - else - nFillHarshFlags &=~1; + nRenderMode = mso_Wireframe; } + break; } - else if ( rrProp.Name == sExtrusionFirstLightLevel ) - { - double fExtrusionFirstLightLevel = 0; - if ( rrProp.Value >>= fExtrusionFirstLightLevel ) - AddOpt( DFF_Prop_c3DKeyIntensity, static_cast<sal_Int32>( fExtrusionFirstLightLevel * 655.36 ) ); - } - else if ( rrProp.Name == sExtrusionSecondLightLevel ) - { - double fExtrusionSecondLightLevel = 0; - if ( rrProp.Value >>= fExtrusionSecondLightLevel ) - AddOpt( DFF_Prop_c3DFillIntensity, static_cast<sal_Int32>( fExtrusionSecondLightLevel * 655.36 ) ); - } - else if ( rrProp.Name == sExtrusionFirstLightDirection ) + AddOpt( DFF_Prop_c3DRenderMode, nRenderMode ); + } + } + else if ( rrProp.Name == sExtrusionRotateAngle ) + { + double fExtrusionAngleX = 0; + double fExtrusionAngleY = 0; + drawing::EnhancedCustomShapeParameterPair aRotateAnglePair; + if ( ( rrProp.Value >>= aRotateAnglePair ) && ( aRotateAnglePair.First.Value >>= fExtrusionAngleX ) && ( aRotateAnglePair.Second.Value >>= fExtrusionAngleY ) ) + { + fExtrusionAngleX *= 65536; + fExtrusionAngleY *= 65536; + AddOpt( DFF_Prop_c3DXRotationAngle, static_cast<sal_Int32>(fExtrusionAngleX) ); + AddOpt( DFF_Prop_c3DYRotationAngle, static_cast<sal_Int32>(fExtrusionAngleY) ); + } + } + else if ( rrProp.Name == sExtrusionRotationCenter ) + { + drawing::Direction3D aExtrusionRotationCenter; + if ( rrProp.Value >>= aExtrusionRotationCenter ) + { + AddOpt( DFF_Prop_c3DRotationCenterX, static_cast<sal_Int32>( aExtrusionRotationCenter.DirectionX * 360.0 ) ); + AddOpt( DFF_Prop_c3DRotationCenterY, static_cast<sal_Int32>( aExtrusionRotationCenter.DirectionY * 360.0 ) ); + AddOpt( DFF_Prop_c3DRotationCenterZ, static_cast<sal_Int32>( aExtrusionRotationCenter.DirectionZ * 360.0 ) ); + nFillHarshFlags &=~8; // don't use AutoRotationCenter; + } + } + else if ( rrProp.Name == sExtrusionShininess ) + { + double fExtrusionShininess = 0; + if ( rrProp.Value >>= fExtrusionShininess ) + AddOpt( DFF_Prop_c3DShininess, static_cast<sal_Int32>( fExtrusionShininess * 655.36 ) ); + } + else if ( rrProp.Name == sExtrusionSkew ) + { + double fSkewAmount = 0; + double fSkewAngle = 0; + drawing::EnhancedCustomShapeParameterPair aSkewParaPair; + if ( ( rrProp.Value >>= aSkewParaPair ) && ( aSkewParaPair.First.Value >>= fSkewAmount ) && ( aSkewParaPair.Second.Value >>= fSkewAngle ) ) + { + AddOpt( DFF_Prop_c3DSkewAmount, static_cast<sal_Int32>(fSkewAmount) ); + AddOpt( DFF_Prop_c3DSkewAngle, static_cast<sal_Int32>( fSkewAngle * 65536 ) ); + } + } + else if ( rrProp.Name == sExtrusionSpecularity ) + { + double fExtrusionSpecularity = 0; + if ( rrProp.Value >>= fExtrusionSpecularity ) + AddOpt( DFF_Prop_c3DSpecularAmt, static_cast<sal_Int32>( fExtrusionSpecularity * 1333 ) ); + } + else if ( rrProp.Name == sExtrusionProjectionMode ) + { + drawing::ProjectionMode eExtrusionProjectionMode; + if ( rrProp.Value >>= eExtrusionProjectionMode ) + { + nFillHarshFlags |= 0x40000; + if ( eExtrusionProjectionMode == drawing::ProjectionMode_PARALLEL ) + nFillHarshFlags |= 4; + else + nFillHarshFlags &=~4; + } + } + else if ( rrProp.Name == sExtrusionViewPoint ) + { + drawing::Position3D aExtrusionViewPoint; + if ( rrProp.Value >>= aExtrusionViewPoint ) + { + aExtrusionViewPoint.PositionX *= 360.0; + aExtrusionViewPoint.PositionY *= 360.0; + aExtrusionViewPoint.PositionZ *= 360.0; + AddOpt( DFF_Prop_c3DXViewpoint, static_cast<sal_Int32>(aExtrusionViewPoint.PositionX) ); + AddOpt( DFF_Prop_c3DYViewpoint, static_cast<sal_Int32>(aExtrusionViewPoint.PositionY) ); + AddOpt( DFF_Prop_c3DZViewpoint, static_cast<sal_Int32>(aExtrusionViewPoint.PositionZ) ); + } + } + else if ( rrProp.Name == sExtrusionOrigin ) + { + double fExtrusionOriginX = 0; + double fExtrusionOriginY = 0; + drawing::EnhancedCustomShapeParameterPair aOriginPair; + if ( ( rrProp.Value >>= aOriginPair ) && ( aOriginPair.First.Value >>= fExtrusionOriginX ) && ( aOriginPair.Second.Value >>= fExtrusionOriginY ) ) + { + AddOpt( DFF_Prop_c3DOriginX, static_cast<sal_Int32>( fExtrusionOriginX * 65536 ) ); + AddOpt( DFF_Prop_c3DOriginY, static_cast<sal_Int32>( fExtrusionOriginY * 65536 ) ); + } + } + else if ( rrProp.Name == sExtrusionColor ) + { + bool bExtrusionColor; + if ( rrProp.Value >>= bExtrusionColor ) + { + nLightFaceFlags |= 0x20000; + if ( bExtrusionColor ) { - drawing::Direction3D aExtrusionFirstLightDirection; - if ( rrProp.Value >>= aExtrusionFirstLightDirection ) + nLightFaceFlags |= 2; + uno::Any aFillColor2; + if ( EscherPropertyValueHelper::GetPropertyValue( aFillColor2, aXPropSet, "FillColor2", true ) ) { - AddOpt( DFF_Prop_c3DKeyX, static_cast<sal_Int32>(aExtrusionFirstLightDirection.DirectionX) ); - AddOpt( DFF_Prop_c3DKeyY, static_cast<sal_Int32>(aExtrusionFirstLightDirection.DirectionY) ); - AddOpt( DFF_Prop_c3DKeyZ, static_cast<sal_Int32>(aExtrusionFirstLightDirection.DirectionZ) ); + sal_uInt32 nFillColor = ImplGetColor( *o3tl::doAccess<sal_uInt32>(aFillColor2) ); + AddOpt( DFF_Prop_c3DExtrusionColor, nFillColor ); } } - else if ( rrProp.Name == sExtrusionSecondLightDirection ) + else + nLightFaceFlags &=~2; + } + } + } + if ( nLightFaceFlags != nLightFaceFlagsOrg ) + AddOpt( DFF_Prop_fc3DLightFace, nLightFaceFlags ); + if ( nFillHarshFlags != nFillHarshFlagsOrg ) + AddOpt( DFF_Prop_fc3DFillHarsh, nFillHarshFlags ); + } + } + else if ( rProp.Name == sEquations ) + { + if ( !bIsDefaultObject ) + { + sal_uInt16 nElements = static_cast<sal_uInt16>(aEquations.size()); + if ( nElements ) + { + sal_uInt16 nElementSize = 8; + sal_uInt32 nStreamSize = nElementSize * nElements + 6; + SvMemoryStream aMemStrm( nStreamSize ); + aMemStrm.WriteUInt16( nElements ) + .WriteUInt16( nElements ) + .WriteUInt16( nElementSize ); + + for (auto const& equation : aEquations) + { + aMemStrm.WriteUInt16( equation.nOperation ) + .WriteInt16( + std::clamp( + equation.nPara[ 0 ], sal_Int32(SAL_MIN_INT16), + sal_Int32(SAL_MAX_INT16)) ) + .WriteInt16( + std::clamp( + equation.nPara[ 1 ], sal_Int32(SAL_MIN_INT16), + sal_Int32(SAL_MAX_INT16)) ) + .WriteInt16( + std::clamp( + equation.nPara[ 2 ], sal_Int32(SAL_MIN_INT16), + sal_Int32(SAL_MAX_INT16)) ); + } + + AddOpt(DFF_Prop_pFormulas, true, 6, aMemStrm); + } + else + { + AddOpt(DFF_Prop_pFormulas, 0, true); + } + } + } + else if ( rProp.Name == sPath ) + { + uno::Sequence< beans::PropertyValue > aPathPropSeq; + if ( rProp.Value >>= aPathPropSeq ) + { + sal_uInt32 nPathFlags, nPathFlagsOrg; + nPathFlagsOrg = nPathFlags = 0x39; + if ( GetOpt( DFF_Prop_fFillOK, nPathFlags ) ) + nPathFlagsOrg = nPathFlags; + + sal_Int32 r, nrCount = aPathPropSeq.getLength(); + for ( r = 0; r < nrCount; r++ ) + { + const beans::PropertyValue& rrProp = aPathPropSeq[ r ]; + const OUString sPathExtrusionAllowed ( "ExtrusionAllowed" ); + const OUString sPathConcentricGradientFillAllowed ( "ConcentricGradientFillAllowed" ); + const OUString sPathTextPathAllowed ( "TextPathAllowed" ); + const OUString sPathCoordinates ( "Coordinates" ); + const OUString sPathGluePoints ( "GluePoints" ); + const OUString sPathGluePointType ( "GluePointType" ); + const OUString sPathSegments ( "Segments" ); + const OUString sPathStretchX ( "StretchX" ); + const OUString sPathStretchY ( "StretchY" ); + const OUString sPathTextFrames ( "TextFrames" ); + + if ( rrProp.Name == sPathExtrusionAllowed ) + { + bool bExtrusionAllowed; + if ( rrProp.Value >>= bExtrusionAllowed ) + { + nPathFlags |= 0x100000; + if ( bExtrusionAllowed ) + nPathFlags |= 16; + else + nPathFlags &=~16; + } + } + else if ( rrProp.Name == sPathConcentricGradientFillAllowed ) + { + bool bConcentricGradientFillAllowed; + if ( rrProp.Value >>= bConcentricGradientFillAllowed ) + { + nPathFlags |= 0x20000; + if ( bConcentricGradientFillAllowed ) + nPathFlags |= 2; + else + nPathFlags &=~2; + } + } + else if ( rrProp.Name == sPathTextPathAllowed ) + { + bool bTextPathAllowed; + if ( rrProp.Value >>= bTextPathAllowed ) + { + nPathFlags |= 0x40000; + if ( bTextPathAllowed ) + nPathFlags |= 4; + else + nPathFlags &=~4; + } + } + else if ( rrProp.Name == sPathCoordinates ) + { + if ( !bIsDefaultObject ) + { + aPathCoordinatesProp = rrProp.Value; + bPathCoordinatesProp = true; + } + } + else if ( rrProp.Name == sPathGluePoints ) + { + if ( !bIsDefaultObject ) + { + uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aGluePoints; + if ( rrProp.Value >>= aGluePoints ) { - drawing::Direction3D aExtrusionSecondLightPosition; - if ( rrProp.Value >>= aExtrusionSecondLightPosition ) + // creating the vertices + sal_uInt16 nElements = static_cast<sal_uInt16>(aGluePoints.getLength()); + if ( nElements ) { - AddOpt( DFF_Prop_c3DFillX, static_cast<sal_Int32>(aExtrusionSecondLightPosition.DirectionX) ); - AddOpt( DFF_Prop_c3DFillY, static_cast<sal_Int32>(aExtrusionSecondLightPosition.DirectionY) ); - AddOpt( DFF_Prop_c3DFillZ, static_cast<sal_Int32>(aExtrusionSecondLightPosition.DirectionZ) ); + sal_uInt16 j, nElementSize = 8; + sal_uInt32 nStreamSize = nElementSize * nElements + 6; + SvMemoryStream aMemStrm( nStreamSize ); + aMemStrm.WriteUInt16( nElements ) + .WriteUInt16( nElements ) + .WriteUInt16( nElementSize ); + for( j = 0; j < nElements; j++ ) + { + sal_Int32 X = GetValueForEnhancedCustomShapeParameter( aGluePoints[ j ].First, aEquationOrder ); + sal_Int32 Y = GetValueForEnhancedCustomShapeParameter( aGluePoints[ j ].Second, aEquationOrder ); + aMemStrm.WriteInt32( X ) + .WriteInt32( Y ); + } + + AddOpt(DFF_Prop_connectorPoints, true, 6, aMemStrm); // -6 } - } - else if ( rrProp.Name == sExtrusionMetal ) - { - bool bExtrusionMetal; - if ( rrProp.Value >>= bExtrusionMetal ) + else { - nLightFaceFlags |= 0x40000; - if ( bExtrusionMetal ) - nLightFaceFlags |= 4; - else - nLightFaceFlags &=~4; + AddOpt(DFF_Prop_connectorPoints, 0, true); } } - else if ( rrProp.Name == sExtrusionShadeMode ) + } + } + else if ( rrProp.Name == sPathGluePointType ) + { + sal_Int16 nGluePointType = sal_Int16(); + if ( rrProp.Value >>= nGluePointType ) + AddOpt( DFF_Prop_connectorType, static_cast<sal_uInt16>(nGluePointType) ); + } + else if ( rrProp.Name == sPathSegments ) + { + if ( !bIsDefaultObject ) + { + uno::Sequence<drawing::EnhancedCustomShapeSegment> aSegments; + if ( rrProp.Value >>= aSegments ) { - drawing::ShadeMode eExtrusionShadeMode; - if ( rrProp.Value >>= eExtrusionShadeMode ) + // creating seginfo + if ( aSegments.hasElements() ) { - sal_uInt32 nRenderMode; - switch( eExtrusionShadeMode ) + sal_uInt16 j, nElements = static_cast<sal_uInt16>(aSegments.getLength()); + sal_uInt16 nElementSize = 2; + sal_uInt32 nStreamSize = nElementSize * nElements + 6; + SvMemoryStream aMemStrm( nStreamSize ); + aMemStrm.WriteUInt16( nElements ) + .WriteUInt16( nElements ) + .WriteUInt16( nElementSize ); + for ( j = 0; j < nElements; j++ ) { - default: - case drawing::ShadeMode_FLAT : - case drawing::ShadeMode_PHONG : - case drawing::ShadeMode_SMOOTH : - nRenderMode = mso_FullRender; - break; - case drawing::ShadeMode_DRAFT : + // The segment type is stored in the upper 3 bits + // and segment count is stored in the lower 13 + // bits. + // + // If the segment type is msopathEscape, the lower 13 bits + // are divided in a 5 bit escape code and 8 bit + // vertex count (not segment count!) + sal_uInt16 nVal = static_cast<sal_uInt16>(aSegments[ j ].Count); + switch( aSegments[ j ].Command ) { - nRenderMode = mso_Wireframe; + case drawing::EnhancedCustomShapeSegmentCommand::UNKNOWN : + case drawing::EnhancedCustomShapeSegmentCommand::LINETO : + break; + case drawing::EnhancedCustomShapeSegmentCommand::MOVETO : + nVal = (msopathMoveTo << 13); + break; + case drawing::EnhancedCustomShapeSegmentCommand::CURVETO : + { + nVal |= (msopathCurveTo << 13); + } + break; + case drawing::EnhancedCustomShapeSegmentCommand::CLOSESUBPATH : + { + nVal = 1; + nVal |= (msopathClose << 13); + } + break; + case drawing::EnhancedCustomShapeSegmentCommand::ENDSUBPATH : + { + nVal = (msopathEnd << 13); + } + break; + case drawing::EnhancedCustomShapeSegmentCommand::NOFILL : + { + nVal = (msopathEscape << 13) | (10 << 8); + } + break; + case drawing::EnhancedCustomShapeSegmentCommand::NOSTROKE : + { + nVal = (msopathEscape << 13) | (11 << 8); + } + break; + case drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO : + { + nVal *= 3; + nVal |= (msopathEscape << 13) | (1 << 8); + } + break; + case drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE : + { + nVal *= 3; + nVal |= (msopathEscape << 13) | (2 << 8); + } + break; + case drawing::EnhancedCustomShapeSegmentCommand::ARCTO : + { + nVal <<= 2; + nVal |= (msopathEscape << 13) | (3 << 8); + } + break; + case drawing::EnhancedCustomShapeSegmentCommand::ARC : + { + nVal <<= 2; + nVal |= (msopathEscape << 13) | (4 << 8); + } + break; + case drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO : + { + nVal <<= 2; + nVal |= (msopathEscape << 13) | (5 << 8); + } + break; + case drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARC : + { + nVal <<= 2; + nVal |= (msopathEscape << 13) | (6 << 8); + } + break; + case drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX : + { + nVal |= (msopathEscape << 13) | (7 << 8); + } + break; + case drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY : + { + nVal |= (msopathEscape << 13) | (8 << 8); + } + break; } - break; + aMemStrm.WriteUInt16( nVal ); } - AddOpt( DFF_Prop_c3DRenderMode, nRenderMode ); - } - } - else if ( rrProp.Name == sExtrusionRotateAngle ) - { - double fExtrusionAngleX = 0; - double fExtrusionAngleY = 0; - drawing::EnhancedCustomShapeParameterPair aRotateAnglePair; - if ( ( rrProp.Value >>= aRotateAnglePair ) && ( aRotateAnglePair.First.Value >>= fExtrusionAngleX ) && ( aRotateAnglePair.Second.Value >>= fExtrusionAngleY ) ) - { - fExtrusionAngleX *= 65536; - fExtrusionAngleY *= 65536; - AddOpt( DFF_Prop_c3DXRotationAngle, static_cast<sal_Int32>(fExtrusionAngleX) ); - AddOpt( DFF_Prop_c3DYRotationAngle, static_cast<sal_Int32>(fExtrusionAngleY) ); - } - } - else if ( rrProp.Name == sExtrusionRotationCenter ) - { - drawing::Direction3D aExtrusionRotationCenter; - if ( rrProp.Value >>= aExtrusionRotationCenter ) - { - AddOpt( DFF_Prop_c3DRotationCenterX, static_cast<sal_Int32>( aExtrusionRotationCenter.DirectionX * 360.0 ) ); - AddOpt( DFF_Prop_c3DRotationCenterY, static_cast<sal_Int32>( aExtrusionRotationCenter.DirectionY * 360.0 ) ); - AddOpt( DFF_Prop_c3DRotationCenterZ, static_cast<sal_Int32>( aExtrusionRotationCenter.DirectionZ * 360.0 ) ); - nFillHarshFlags &=~8; // don't use AutoRotationCenter; - } - } - else if ( rrProp.Name == sExtrusionShininess ) - { - double fExtrusionShininess = 0; - if ( rrProp.Value >>= fExtrusionShininess ) - AddOpt( DFF_Prop_c3DShininess, static_cast<sal_Int32>( fExtrusionShininess * 655.36 ) ); - } - else if ( rrProp.Name == sExtrusionSkew ) - { - double fSkewAmount = 0; - double fSkewAngle = 0; - drawing::EnhancedCustomShapeParameterPair aSkewParaPair; - if ( ( rrProp.Value >>= aSkewParaPair ) && ( aSkewParaPair.First.Value >>= fSkewAmount ) && ( aSkewParaPair.Second.Value >>= fSkewAngle ) ) - { - AddOpt( DFF_Prop_c3DSkewAmount, static_cast<sal_Int32>(fSkewAmount) ); - AddOpt( DFF_Prop_c3DSkewAngle, static_cast<sal_Int32>( fSkewAngle * 65536 ) ); - } - } - else if ( rrProp.Name == sExtrusionSpecularity ) - { - double fExtrusionSpecularity = 0; - if ( rrProp.Value >>= fExtrusionSpecularity ) - AddOpt( DFF_Prop_c3DSpecularAmt, static_cast<sal_Int32>( fExtrusionSpecularity * 1333 ) ); - } - else if ( rrProp.Name == sExtrusionProjectionMode ) - { - drawing::ProjectionMode eExtrusionProjectionMode; - if ( rrProp.Value >>= eExtrusionProjectionMode ) - { - nFillHarshFlags |= 0x40000; - if ( eExtrusionProjectionMode == drawing::ProjectionMode_PARALLEL ) - nFillHarshFlags |= 4; - else - nFillHarshFlags &=~4; - } - } - else if ( rrProp.Name == sExtrusionViewPoint ) - { - drawing::Position3D aExtrusionViewPoint; - if ( rrProp.Value >>= aExtrusionViewPoint ) - { - aExtrusionViewPoint.PositionX *= 360.0; - aExtrusionViewPoint.PositionY *= 360.0; - aExtrusionViewPoint.PositionZ *= 360.0; - AddOpt( DFF_Prop_c3DXViewpoint, static_cast<sal_Int32>(aExtrusionViewPoint.PositionX) ); - AddOpt( DFF_Prop_c3DYViewpoint, static_cast<sal_Int32>(aExtrusionViewPoint.PositionY) ); - AddOpt( DFF_Prop_c3DZViewpoint, static_cast<sal_Int32>(aExtrusionViewPoint.PositionZ) ); + + AddOpt(DFF_Prop_pSegmentInfo, false, 6, aMemStrm); } - } - else if ( rrProp.Name == sExtrusionOrigin ) - { - double fExtrusionOriginX = 0; - double fExtrusionOriginY = 0; - drawing::EnhancedCustomShapeParameterPair aOriginPair; - if ( ( rrProp.Value >>= aOriginPair ) && ( aOriginPair.First.Value >>= fExtrusionOriginX ) && ( aOriginPair.Second.Value >>= fExtrusionOriginY ) ) + else { - AddOpt( DFF_Prop_c3DOriginX, static_cast<sal_Int32>( fExtrusionOriginX * 65536 ) ); - AddOpt( DFF_Prop_c3DOriginY, static_cast<sal_Int32>( fExtrusionOriginY * 65536 ) ); + AddOpt(DFF_Prop_pSegmentInfo, 0, true); } } - else if ( rrProp.Name == sExtrusionColor ) + } + } + else if ( rrProp.Name == sPathStretchX ) + { + if ( !bIsDefaultObject ) + { + sal_Int32 nStretchX = 0; + if ( rrProp.Value >>= nStretchX ) + AddOpt( DFF_Prop_stretchPointX, nStretchX ); + } + } + else if ( rrProp.Name == sPathStretchY ) + { + if ( !bIsDefaultObject ) + { + sal_Int32 nStretchY = 0; + if ( rrProp.Value >>= nStretchY ) + AddOpt( DFF_Prop_stretchPointY, nStretchY ); + } + } + else if ( rrProp.Name == sPathTextFrames ) + { + if ( !bIsDefaultObject ) + { + uno::Sequence<drawing::EnhancedCustomShapeTextFrame> aPathTextFrames; + if ( rrProp.Value >>= aPathTextFrames ) { - bool bExtrusionColor; - if ( rrProp.Value >>= bExtrusionColor ) + if ( aPathTextFrames.hasElements() ) { - nLightFaceFlags |= 0x20000; - if ( bExtrusionColor ) + sal_uInt16 j, nElements = static_cast<sal_uInt16>(aPathTextFrames.getLength()); + sal_uInt16 nElementSize = 16; + sal_uInt32 nStreamSize = nElementSize * nElements + 6; + SvMemoryStream aMemStrm( nStreamSize ); + aMemStrm.WriteUInt16( nElements ) + .WriteUInt16( nElements ) + .WriteUInt16( nElementSize ); + for ( j = 0; j < nElements; j++ ) { - nLightFaceFlags |= 2; - uno::Any aFillColor2; - if ( EscherPropertyValueHelper::GetPropertyValue( aFillColor2, aXPropSet, "FillColor2", true ) ) - { - sal_uInt32 nFillColor = ImplGetColor( *o3tl::doAccess<sal_uInt32>(aFillColor2) ); - AddOpt( DFF_Prop_c3DExtrusionColor, nFillColor ); - } + sal_Int32 nLeft = GetValueForEnhancedCustomShapeParameter( aPathTextFrames[ j ].TopLeft.First, aEquationOrder ); + sal_Int32 nTop = GetValueForEnhancedCustomShapeParameter( aPathTextFrames[ j ].TopLeft.Second, aEquationOrder ); + sal_Int32 nRight = GetValueForEnhancedCustomShapeParameter( aPathTextFrames[ j ].BottomRight.First, aEquationOrder ); + sal_Int32 nBottom = GetValueForEnhancedCustomShapeParameter( aPathTextFrames[ j ].BottomRight.Second, aEquationOrder ); + + aMemStrm.WriteInt32( nLeft ) + .WriteInt32( nTop ) + .WriteInt32( nRight ) + .WriteInt32( nBottom ); } - else - nLightFaceFlags &=~2; + + AddOpt(DFF_Prop_textRectangles, true, 6, aMemStrm); + } + else + { + AddOpt(DFF_Prop_textRectangles, 0, true); } } } - if ( nLightFaceFlags != nLightFaceFlagsOrg ) - AddOpt( DFF_Prop_fc3DLightFace, nLightFaceFlags ); - if ( nFillHarshFlags != nFillHarshFlagsOrg ) - AddOpt( DFF_Prop_fc3DFillHarsh, nFillHarshFlags ); } } - else if ( rProp.Name == sEquations ) + if ( nPathFlags != nPathFlagsOrg ) + AddOpt( DFF_Prop_fFillOK, nPathFlags ); + } + } + else if ( rProp.Name == sTextPath ) + { + uno::Sequence< beans::PropertyValue > aTextPathPropSeq; + if ( rProp.Value >>= aTextPathPropSeq ) + { + sal_uInt32 nTextPathFlagsOrg, nTextPathFlags; + nTextPathFlagsOrg = nTextPathFlags = 0xffff1000; // default + if ( GetOpt( DFF_Prop_gtextFStrikethrough, nTextPathFlags ) ) + nTextPathFlagsOrg = nTextPathFlags; + + sal_Int32 r, nrCount = aTextPathPropSeq.getLength(); + for ( r = 0; r < nrCount; r++ ) { - if ( !bIsDefaultObject ) + const beans::PropertyValue& rrProp = aTextPathPropSeq[ r ]; + const OUString sTextPathMode ( "TextPathMode" ); + const OUString sTextPathScaleX ( "ScaleX" ); + const OUString sSameLetterHeights ( "SameLetterHeights" ); + + if ( rrProp.Name == sTextPath ) { - sal_uInt16 nElements = static_cast<sal_uInt16>(aEquations.size()); - if ( nElements ) + bool bTextPathOn; + if ( rrProp.Value >>= bTextPathOn ) { - sal_uInt16 nElementSize = 8; - sal_uInt32 nStreamSize = nElementSize * nElements + 6; - SvMemoryStream aMemStrm( nStreamSize ); - aMemStrm.WriteUInt16( nElements ) - .WriteUInt16( nElements ) - .WriteUInt16( nElementSize ); - - for (auto const& equation : aEquations) + nTextPathFlags |= 0x40000000; + if ( bTextPathOn ) { - aMemStrm.WriteUInt16( equation.nOperation ) - .WriteInt16( - std::clamp( - equation.nPara[ 0 ], sal_Int32(SAL_MIN_INT16), - sal_Int32(SAL_MAX_INT16)) ) - .WriteInt16( - std::clamp( - equation.nPara[ 1 ], sal_Int32(SAL_MIN_INT16), - sal_Int32(SAL_MAX_INT16)) ) - .WriteInt16( - std::clamp( - equation.nPara[ 2 ], sal_Int32(SAL_MIN_INT16), - sal_Int32(SAL_MAX_INT16)) ); - } + nTextPathFlags |= 0x4000; - AddOpt(DFF_Prop_pFormulas, true, 6, aMemStrm); + sal_uInt32 nPathFlags = 0x39; + GetOpt( DFF_Prop_fFillOK, nPathFlags ); // SJ: can be removed if we are supporting the TextPathAllowed property in XML + nPathFlags |= 0x40004; + AddOpt( DFF_Prop_fFillOK, nPathFlags ); + } + else + nTextPathFlags &=~0x4000; } - else + } + else if ( rrProp.Name == sTextPathMode ) + { + drawing::EnhancedCustomShapeTextPathMode eTextPathMode; + if ( rrProp.Value >>= eTextPathMode ) { - AddOpt(DFF_Prop_pFormulas, 0, true); + nTextPathFlags |= 0x05000000; + nTextPathFlags &=~0x500; // TextPathMode_NORMAL + if ( eTextPathMode == drawing::EnhancedCustomShapeTextPathMode_PATH ) + nTextPathFlags |= 0x100; + else if ( eTextPathMode == drawing::EnhancedCustomShapeTextPathMode_SHAPE ) + nTextPathFlags |= 0x500; + } + } + else if ( rrProp.Name == sTextPathScaleX ) + { + bool bTextPathScaleX; + if ( rrProp.Value >>= bTextPathScaleX ) + { + nTextPathFlags |= 0x00400000; + if ( bTextPathScaleX ) + nTextPathFlags |= 0x40; + else + nTextPathFlags &=~0x40; + } + } + else if ( rrProp.Name == sSameLetterHeights ) + { + bool bSameLetterHeights; + if ( rrProp.Value >>= bSameLetterHeights ) + { + nTextPathFlags |= 0x00800000; + if ( bSameLetterHeights ) + nTextPathFlags |= 0x80; + else + nTextPathFlags &=~0x80; } } } - else if ( rProp.Name == sPath ) + if ( nTextPathFlags & 0x4000 ) // Is FontWork ? { - uno::Sequence< beans::PropertyValue > aPathPropSeq; - if ( rProp.Value >>= aPathPropSeq ) + // FontWork Text + OUString aText; + uno::Reference< text::XSimpleText > xText( rXShape, uno::UNO_QUERY ); + if ( xText.is() ) + aText = xText->getString(); + if ( aText.isEmpty() ) + aText = "your text"; // TODO: moving into a resource + AddOpt( DFF_Prop_gtextUNICODE, aText ); + + // FontWork Font + OUString aFontName; + const OUString sCharFontName( "CharFontName" ); + uno::Any aAny = aXPropSet->getPropertyValue( sCharFontName ); + aAny >>= aFontName; + if ( aFontName.isEmpty() ) + aFontName = "Arial Black"; + AddOpt( DFF_Prop_gtextFont, aFontName ); + + if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, "CharScaleWidth", true ) ) { - sal_uInt32 nPathFlags, nPathFlagsOrg; - nPathFlagsOrg = nPathFlags = 0x39; - if ( GetOpt( DFF_Prop_fFillOK, nPathFlags ) ) - nPathFlagsOrg = nPathFlags; - - sal_Int32 r, nrCount = aPathPropSeq.getLength(); - for ( r = 0; r < nrCount; r++ ) + sal_Int16 nCharScaleWidth = 100; + if ( aAny >>= nCharScaleWidth ) { - const beans::PropertyValue& rrProp = aPathPropSeq[ r ]; - const OUString sPathExtrusionAllowed ( "ExtrusionAllowed" ); - const OUString sPathConcentricGradientFillAllowed ( "ConcentricGradientFillAllowed" ); - const OUString sPathTextPathAllowed ( "TextPathAllowed" ); - const OUString sPathCoordinates ( "Coordinates" ); - const OUString sPathGluePoints ( "GluePoints" ); - const OUString sPathGluePointType ( "GluePointType" ); - const OUString sPathSegments ( "Segments" ); - const OUString sPathStretchX ( "StretchX" ); - const OUString sPathStretchY ( "StretchY" ); - const OUString sPathTextFrames ( "TextFrames" ); - - if ( rrProp.Name == sPathExtrusionAllowed ) + if ( nCharScaleWidth != 100 ) { - bool bExtrusionAllowed; - if ( rrProp.Value >>= bExtrusionAllowed ) - { - nPathFlags |= 0x100000; - if ( bExtrusionAllowed ) - nPathFlags |= 16; - else - nPathFlags &=~16; - } + sal_Int32 nVal = nCharScaleWidth * 655; + AddOpt( DFF_Prop_gtextSpacing, nVal ); } - else if ( rrProp.Name == sPathConcentricGradientFillAllowed ) - { - bool bConcentricGradientFillAllowed; - if ( rrProp.Value >>= bConcentricGradientFillAllowed ) - { - nPathFlags |= 0x20000; - if ( bConcentricGradientFillAllowed ) - nPathFlags |= 2; - else - nPathFlags &=~2; - } - } - else if ( rrProp.Name == sPathTextPathAllowed ) - { - bool bTextPathAllowed; - if ( rrProp.Value >>= bTextPathAllowed ) - { - nPathFlags |= 0x40000; - if ( bTextPathAllowed ) - nPathFlags |= 4; - else - nPathFlags &=~4; - } - } - else if ( rrProp.Name == sPathCoordinates ) - { - if ( !bIsDefaultObject ) - { - aPathCoordinatesProp = rrProp.Value; - bPathCoordinatesProp = true; - } - } - else if ( rrProp.Name == sPathGluePoints ) - { - if ( !bIsDefaultObject ) - { - uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aGluePoints; - if ( rrProp.Value >>= aGluePoints ) - { - // creating the vertices - sal_uInt16 nElements = static_cast<sal_uInt16>(aGluePoints.getLength()); - if ( nElements ) - { - sal_uInt16 j, nElementSize = 8; - sal_uInt32 nStreamSize = nElementSize * nElements + 6; - SvMemoryStream aMemStrm( nStreamSize ); - aMemStrm.WriteUInt16( nElements ) - .WriteUInt16( nElements ) - .WriteUInt16( nElementSize ); - for( j = 0; j < nElements; j++ ) - { - sal_Int32 X = GetValueForEnhancedCustomShapeParameter( aGluePoints[ j ].First, aEquationOrder ); - sal_Int32 Y = GetValueForEnhancedCustomShapeParameter( aGluePoints[ j ].Second, aEquationOrder ); - aMemStrm.WriteInt32( X ) - .WriteInt32( Y ); - } - - AddOpt(DFF_Prop_connectorPoints, true, 6, aMemStrm); // -6 - } - else - { - AddOpt(DFF_Prop_connectorPoints, 0, true); - } - } - } - } - else if ( rrProp.Name == sPathGluePointType ) - { - sal_Int16 nGluePointType = sal_Int16(); - if ( rrProp.Value >>= nGluePointType ) - AddOpt( DFF_Prop_connectorType, static_cast<sal_uInt16>(nGluePointType) ); - } - else if ( rrProp.Name == sPathSegments ) - { - if ( !bIsDefaultObject ) - { - uno::Sequence<drawing::EnhancedCustomShapeSegment> aSegments; - if ( rrProp.Value >>= aSegments ) - { - // creating seginfo - if ( aSegments.hasElements() ) - { - sal_uInt16 j, nElements = static_cast<sal_uInt16>(aSegments.getLength()); - sal_uInt16 nElementSize = 2; - sal_uInt32 nStreamSize = nElementSize * nElements + 6; - SvMemoryStream aMemStrm( nStreamSize ); - aMemStrm.WriteUInt16( nElements ) - .WriteUInt16( nElements ) - .WriteUInt16( nElementSize ); - for ( j = 0; j < nElements; j++ ) - { - // The segment type is stored in the upper 3 bits - // and segment count is stored in the lower 13 - // bits. - // - // If the segment type is msopathEscape, the lower 13 bits - // are divided in a 5 bit escape code and 8 bit - // vertex count (not segment count!) - sal_uInt16 nVal = static_cast<sal_uInt16>(aSegments[ j ].Count); - switch( aSegments[ j ].Command ) - { - case drawing::EnhancedCustomShapeSegmentCommand::UNKNOWN : - case drawing::EnhancedCustomShapeSegmentCommand::LINETO : - break; - case drawing::EnhancedCustomShapeSegmentCommand::MOVETO : - nVal = (msopathMoveTo << 13); - break; - case drawing::EnhancedCustomShapeSegmentCommand::CURVETO : - { - nVal |= (msopathCurveTo << 13); - } - break; - case drawing::EnhancedCustomShapeSegmentCommand::CLOSESUBPATH : - { - nVal = 1; - nVal |= (msopathClose << 13); - } - break; - case drawing::EnhancedCustomShapeSegmentCommand::ENDSUBPATH : - { - nVal = (msopathEnd << 13); - } - break; - case drawing::EnhancedCustomShapeSegmentCommand::NOFILL : - { - nVal = (msopathEscape << 13) | (10 << 8); - } - break; - case drawing::EnhancedCustomShapeSegmentCommand::NOSTROKE : - { - nVal = (msopathEscape << 13) | (11 << 8); - } - break; - case drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO : - { - nVal *= 3; - nVal |= (msopathEscape << 13) | (1 << 8); - } - break; - case drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE : - { - nVal *= 3; - nVal |= (msopathEscape << 13) | (2 << 8); - } - break; - case drawing::EnhancedCustomShapeSegmentCommand::ARCTO : - { - nVal <<= 2; - nVal |= (msopathEscape << 13) | (3 << 8); - } - break; - case drawing::EnhancedCustomShapeSegmentCommand::ARC : - { - nVal <<= 2; - nVal |= (msopathEscape << 13) | (4 << 8); - } - break; - case drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO : - { - nVal <<= 2; - nVal |= (msopathEscape << 13) | (5 << 8); - } - break; - case drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARC : - { - nVal <<= 2; - nVal |= (msopathEscape << 13) | (6 << 8); - } - break; - case drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX : - { - nVal |= (msopathEscape << 13) | (7 << 8); - } - break; - case drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY : - { - nVal |= (msopathEscape << 13) | (8 << 8); - } - break; - } - aMemStrm.WriteUInt16( nVal ); - } - - AddOpt(DFF_Prop_pSegmentInfo, false, 6, aMemStrm); - } - else - { - AddOpt(DFF_Prop_pSegmentInfo, 0, true); - } - } - } - } - else if ( rrProp.Name == sPathStretchX ) - { - if ( !bIsDefaultObject ) - { - sal_Int32 nStretchX = 0; - if ( rrProp.Value >>= nStretchX ) - AddOpt( DFF_Prop_stretchPointX, nStretchX ); - } - } - else if ( rrProp.Name == sPathStretchY ) + } + } + if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, "CharHeight", true ) ) + { + float fCharHeight = 0.0; + if ( aAny >>= fCharHeight ) + { + sal_Int32 nTextSize = static_cast< sal_Int32 > ( fCharHeight * 65536 ); + AddOpt(ESCHER_Prop_gtextSize, nTextSize); + } + } + if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, "CharKerning", true ) ) + { + sal_Int16 nCharKerning = sal_Int16(); + if ( aAny >>= nCharKerning ) + { + nTextPathFlags |= 0x10000000; + if ( nCharKerning ) + nTextPathFlags |= 0x1000; + else + nTextPathFlags &=~0x1000; + } + } + if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, "CharPosture", true ) ) + { + awt::FontSlant eFontSlant; + if ( aAny >>= eFontSlant ) + { + nTextPathFlags |= 0x100010; + if ( eFontSlant != awt::FontSlant_NONE ) + nTextPathFlags |= 0x10; + else + nTextPathFlags &=~0x10; + } + } + if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, "CharWeight", true ) ) + { + float fFontWidth = 0; + if ( aAny >>= fFontWidth ) + { + nTextPathFlags |= 0x200020; + if ( fFontWidth > awt::FontWeight::NORMAL ) + nTextPathFlags |= 0x20; + else + nTextPathFlags &=~0x20; + } + } + // export gTextAlign attr + if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, "TextHorizontalAdjust", true ) ) + { + MSO_GeoTextAlign gTextAlign = mso_alignTextCenter; + drawing::TextHorizontalAdjust eHA( drawing::TextHorizontalAdjust_LEFT ); + aAny >>= eHA; + switch( eHA ) + { + case drawing::TextHorizontalAdjust_LEFT : + gTextAlign = mso_alignTextLeft; + break; + case drawing::TextHorizontalAdjust_CENTER: + gTextAlign = mso_alignTextCenter; + break; + case drawing::TextHorizontalAdjust_RIGHT: + gTextAlign = mso_alignTextRight; + break; + case drawing::TextHorizontalAdjust_BLOCK: { - if ( !bIsDefaultObject ) + drawing::TextFitToSizeType const eFTS( + rSdrObjCustomShape.GetMergedItem( SDRATTR_TEXT_FITTOSIZE ).GetValue() ); + if (eFTS == drawing::TextFitToSizeType_ALLLINES || + eFTS == drawing::TextFitToSizeType_PROPORTIONAL) { - sal_Int32 nStretchY = 0; - if ( rrProp.Value >>= nStretchY ) - AddOpt( DFF_Prop_stretchPointY, nStretchY ); + gTextAlign = mso_alignTextStretch; } - } - else if ( rrProp.Name == sPathTextFrames ) - { - if ( !bIsDefaultObject ) + else { - uno::Sequence<drawing::EnhancedCustomShapeTextFrame> aPathTextFrames; - if ( rrProp.Value >>= aPathTextFrames ) - { - if ( aPathTextFrames.hasElements() ) - { - sal_uInt16 j, nElements = static_cast<sal_uInt16>(aPathTextFrames.getLength()); - sal_uInt16 nElementSize = 16; - sal_uInt32 nStreamSize = nElementSize * nElements + 6; - SvMemoryStream aMemStrm( nStreamSize ); - aMemStrm.WriteUInt16( nElements ) - .WriteUInt16( nElements ) - .WriteUInt16( nElementSize ); - for ( j = 0; j < nElements; j++ ) - { - sal_Int32 nLeft = GetValueForEnhancedCustomShapeParameter( aPathTextFrames[ j ].TopLeft.First, aEquationOrder ); - sal_Int32 nTop = GetValueForEnhancedCustomShapeParameter( aPathTextFrames[ j ].TopLeft.Second, aEquationOrder ); - sal_Int32 nRight = GetValueForEnhancedCustomShapeParameter( aPathTextFrames[ j ].BottomRight.First, aEquationOrder ); - sal_Int32 nBottom = GetValueForEnhancedCustomShapeParameter( aPathTextFrames[ j ].BottomRight.Second, aEquationOrder ); - - aMemStrm.WriteInt32( nLeft ) - .WriteInt32( nTop ) - .WriteInt32( nRight ) - .WriteInt32( nBottom ); - } - - AddOpt(DFF_Prop_textRectangles, true, 6, aMemStrm); - } - else - { - AddOpt(DFF_Prop_textRectangles, 0, true); - } - } + gTextAlign = mso_alignTextWordJust; } + break; } + default: + break; } - if ( nPathFlags != nPathFlagsOrg ) - AddOpt( DFF_Prop_fFillOK, nPathFlags ); + AddOpt(DFF_Prop_gtextAlign,gTextAlign); } } - else if ( rProp.Name == sTextPath ) + if((nTextPathFlags & 0x4000) != 0) // Is Font work { - uno::Sequence< beans::PropertyValue > aTextPathPropSeq; - if ( rProp.Value >>= aTextPathPropSeq ) + OutlinerParaObject* pOutlinerParaObject(rSdrObjCustomShape.GetOutlinerParaObject()); + if ( pOutlinerParaObject && pOutlinerParaObject->IsVertical() ) + nTextPathFlags |= 0x2000; + } + + // Use gtextFStretch for Watermark like MSO does + nTextPathFlags |= use_gtextFBestFit | gtextFBestFit + | use_gtextFStretch | gtextFStretch + | use_gtextFShrinkFit | gtextFShrinkFit; + + if ( nTextPathFlags != nTextPathFlagsOrg ) + AddOpt( DFF_Prop_gtextFStrikethrough, nTextPathFlags ); + } + } + else if ( rProp.Name == sHandles ) + { + if ( !bIsDefaultObject ) + { + bPredefinedHandlesUsed = false; + if ( rProp.Value >>= aHandlesPropSeq ) + { + sal_uInt16 nElements = static_cast<sal_uInt16>(aHandlesPropSeq.getLength()); + if ( nElements ) { - sal_uInt32 nTextPathFlagsOrg, nTextPathFlags; - nTextPathFlagsOrg = nTextPathFlags = 0xffff1000; // default - if ( GetOpt( DFF_Prop_gtextFStrikethrough, nTextPathFlags ) ) - nTextPathFlagsOrg = nTextPathFlags; + sal_uInt16 k, nElementSize = 36; + sal_uInt32 nStreamSize = nElementSize * nElements + 6; + SvMemoryStream aMemStrm( nStreamSize ); + aMemStrm.WriteUInt16( nElements ) + .WriteUInt16( nElements ) + .WriteUInt16( nElementSize ); - sal_Int32 r, nrCount = aTextPathPropSeq.getLength(); - for ( r = 0; r < nrCount; r++ ) + for ( k = 0; k < nElements; k++ ) { - const beans::PropertyValue& rrProp = aTextPathPropSeq[ r ]; - const OUString sTextPathMode ( "TextPathMode" ); - const OUString sTextPathScaleX ( "ScaleX" ); - const OUString sSameLetterHeights ( "SameLetterHeights" ); - - if ( rrProp.Name == sTextPath ) + sal_uInt32 nFlags = 0; + sal_Int32 nXPosition = 0; + sal_Int32 nYPosition = 0; + sal_Int32 nXMap = 0; + sal_Int32 nYMap = 0; + sal_Int32 nXRangeMin = 0x80000000; + sal_Int32 nXRangeMax = 0x7fffffff; + sal_Int32 nYRangeMin = 0x80000000; + sal_Int32 nYRangeMax = 0x7fffffff; + + const uno::Sequence< beans::PropertyValue >& rPropSeq = aHandlesPropSeq[ k ]; + for ( const beans::PropertyValue& rPropVal: rPropSeq ) { - bool bTextPathOn; - if ( rrProp.Value >>= bTextPathOn ) + const OUString sPosition ( "Position" ); + const OUString sMirroredX ( "MirroredX" ); + const OUString sMirroredY ( "MirroredY" ); + const OUString sSwitched ( "Switched" ); + const OUString sPolar ( "Polar" ); + const OUString sRadiusRangeMinimum ( "RadiusRangeMinimum" ); + const OUString sRadiusRangeMaximum ( "RadiusRangeMaximum" ); + const OUString sRangeXMinimum ( "RangeXMinimum" ); + const OUString sRangeXMaximum ( "RangeXMaximum" ); + const OUString sRangeYMinimum ( "RangeYMinimum" ); + const OUString sRangeYMaximum ( "RangeYMaximum" ); + + if ( rPropVal.Name == sPosition ) { - nTextPathFlags |= 0x40000000; - if ( bTextPathOn ) + drawing::EnhancedCustomShapeParameterPair aPosition; + if ( rPropVal.Value >>= aPosition ) { - nTextPathFlags |= 0x4000; - - sal_uInt32 nPathFlags = 0x39; - GetOpt( DFF_Prop_fFillOK, nPathFlags ); // SJ: can be removed if we are supporting the TextPathAllowed property in XML - nPathFlags |= 0x40004; - AddOpt( DFF_Prop_fFillOK, nPathFlags ); + GetValueForEnhancedCustomShapeHandleParameter( nXPosition, aPosition.First ); + GetValueForEnhancedCustomShapeHandleParameter( nYPosition, aPosition.Second ); } - else - nTextPathFlags &=~0x4000; } - } - else if ( rrProp.Name == sTextPathMode ) - { - drawing::EnhancedCustomShapeTextPathMode eTextPathMode; - if ( rrProp.Value >>= eTextPathMode ) + else if ( rPropVal.Name == sMirroredX ) { - nTextPathFlags |= 0x05000000; - nTextPathFlags &=~0x500; // TextPathMode_NORMAL - if ( eTextPathMode == drawing::EnhancedCustomShapeTextPathMode_PATH ) - nTextPathFlags |= 0x100; - else if ( eTextPathMode == drawing::EnhancedCustomShapeTextPathMode_SHAPE ) - nTextPathFlags |= 0x500; + bool bMirroredX; + if ( rPropVal.Value >>= bMirroredX ) + { + if ( bMirroredX ) + nFlags |= 1; + } } - } - else if ( rrProp.Name == sTextPathScaleX ) - { - bool bTextPathScaleX; - if ( rrProp.Value >>= bTextPathScaleX ) + else if ( rPropVal.Name == sMirroredY ) { - nTextPathFlags |= 0x00400000; - if ( bTextPathScaleX ) - nTextPathFlags |= 0x40; - else - nTextPathFlags &=~0x40; + bool bMirroredY; + if ( rPropVal.Value >>= bMirroredY ) + { + if ( bMirroredY ) + nFlags |= 2; + } } - } - else if ( rrProp.Name == sSameLetterHeights ) - { - bool bSameLetterHeights; - if ( rrProp.Value >>= bSameLetterHeights ) + else if ( rPropVal.Name == sSwitched ) { - nTextPathFlags |= 0x00800000; - if ( bSameLetterHeights ) - nTextPathFlags |= 0x80; - else - nTextPathFlags &=~0x80; + bool bSwitched; + if ( rPropVal.Value >>= bSwitched ) + { + if ( bSwitched ) + nFlags |= 4; + } } - } - } - if ( nTextPathFlags & 0x4000 ) // Is FontWork ? - { - // FontWork Text - OUString aText; - uno::Reference< text::XSimpleText > xText( rXShape, uno::UNO_QUERY ); - if ( xText.is() ) - aText = xText->getString(); - if ( aText.isEmpty() ) - aText = "your text"; // TODO: moving into a resource - AddOpt( DFF_Prop_gtextUNICODE, aText ); - - // FontWork Font - OUString aFontName; - const OUString sCharFontName( "CharFontName" ); - uno::Any aAny = aXPropSet->getPropertyValue( sCharFontName ); - aAny >>= aFontName; - if ( aFontName.isEmpty() ) - aFontName = "Arial Black"; - AddOpt( DFF_Prop_gtextFont, aFontName ); - - if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, "CharScaleWidth", true ) ) - { - sal_Int16 nCharScaleWidth = 100; - if ( aAny >>= nCharScaleWidth ) + else if ( rPropVal.Name == sPolar ) { - if ( nCharScaleWidth != 100 ) + drawing::EnhancedCustomShapeParameterPair aPolar; + if ( rPropVal.Value >>= aPolar ) { - sal_Int32 nVal = nCharScaleWidth * 655; - AddOpt( DFF_Prop_gtextSpacing, nVal ); + if ( GetValueForEnhancedCustomShapeHandleParameter( nXMap, aPolar.First ) ) + nFlags |= 0x800; + if ( GetValueForEnhancedCustomShapeHandleParameter( nYMap, aPolar.Second ) ) + nFlags |= 0x1000; + nFlags |= 8; } } - } - if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, "CharHeight", true ) ) - { - float fCharHeight = 0.0; - if ( aAny >>= fCharHeight ) + else if ( rPropVal.Name == sRadiusRangeMinimum ) { - sal_Int32 nTextSize = static_cast< sal_Int32 > ( fCharHeight * 65536 ); - AddOpt(ESCHER_Prop_gtextSize, nTextSize); + nYRangeMin = sal_Int32(0xff4c0000); // the range of angles seems to be a not + nYRangeMax = sal_Int32(0x00b40000); // used feature, so we are defaulting this + + drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum; + if ( rPropVal.Value >>= aRadiusRangeMinimum ) + { + if ( GetValueForEnhancedCustomShapeHandleParameter( nXRangeMin, aRadiusRangeMinimum ) ) + nFlags |= 0x80; + nFlags |= 0x2000; + } } - } - if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, "CharKerning", true ) ) - { - sal_Int16 nCharKerning = sal_Int16(); - if ( aAny >>= nCharKerning ) + else if ( rPropVal.Name == sRadiusRangeMaximum ) { - nTextPathFlags |= 0x10000000; - if ( nCharKerning ) - nTextPathFlags |= 0x1000; - else - nTextPathFlags &=~0x1000; + nYRangeMin = sal_Int32(0xff4c0000); // the range of angles seems to be a not + nYRangeMax = sal_Int32(0x00b40000); // used feature, so we are defaulting this + + drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum; + if ( rPropVal.Value >>= aRadiusRangeMaximum ) + { + if ( GetValueForEnhancedCustomShapeHandleParameter( nXRangeMax, aRadiusRangeMaximum ) ) + nFlags |= 0x100; + nFlags |= 0x2000; + } } - } - if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, "CharPosture", true ) ) - { - awt::FontSlant eFontSlant; - if ( aAny >>= eFontSlant ) + else if ( rPropVal.Name == sRangeXMinimum ) { - nTextPathFlags |= 0x100010; - if ( eFontSlant != awt::FontSlant_NONE ) - nTextPathFlags |= 0x10; - else - nTextPathFlags &=~0x10; + drawing::EnhancedCustomShapeParameter aXRangeMinimum; + if ( rPropVal.Value >>= aXRangeMinimum ) + { + if ( GetValueForEnhancedCustomShapeHandleParameter( nXRangeMin, aXRangeMinimum ) ) + nFlags |= 0x80; + nFlags |= 0x20; + } } - } - if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, "CharWeight", true ) ) - { - float fFontWidth = 0; - if ( aAny >>= fFontWidth ) + else if ( rPropVal.Name == sRangeXMaximum ) { - nTextPathFlags |= 0x200020; - if ( fFontWidth > awt::FontWeight::NORMAL ) - nTextPathFlags |= 0x20; - else - nTextPathFlags &=~0x20; + drawing::EnhancedCustomShapeParameter aXRangeMaximum; + if ( rPropVal.Value >>= aXRangeMaximum ) + { + if ( GetValueForEnhancedCustomShapeHandleParameter( nXRangeMax, aXRangeMaximum ) ) + nFlags |= 0x100; + nFlags |= 0x20; + } } - } - // export gTextAlign attr - if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, "TextHorizontalAdjust", true ) ) - { - MSO_GeoTextAlign gTextAlign = mso_alignTextCenter; - drawing::TextHorizontalAdjust eHA( drawing::TextHorizontalAdjust_LEFT ); - aAny >>= eHA; - switch( eHA ) + else if ( rPropVal.Name == sRangeYMinimum ) { - case drawing::TextHorizontalAdjust_LEFT : - gTextAlign = mso_alignTextLeft; - break; - case drawing::TextHorizontalAdjust_CENTER: - gTextAlign = mso_alignTextCenter; - break; - case drawing::TextHorizontalAdjust_RIGHT: - gTextAlign = mso_alignTextRight; - break; - case drawing::TextHorizontalAdjust_BLOCK: + drawing::EnhancedCustomShapeParameter aYRangeMinimum; + if ( rPropVal.Value >>= aYRangeMinimum ) { - drawing::TextFitToSizeType const eFTS( - rSdrObjCustomShape.GetMergedItem( SDRATTR_TEXT_FITTOSIZE ).GetValue() ); - if (eFTS == drawing::TextFitToSizeType_ALLLINES || - eFTS == drawing::TextFitToSizeType_PROPORTIONAL) - { - gTextAlign = mso_alignTextStretch; - } - else - { - gTextAlign = mso_alignTextWordJust; - } - break; + if ( GetValueForEnhancedCustomShapeHandleParameter( nYRangeMin, aYRangeMinimum ) ) + nFlags |= 0x200; + nFlags |= 0x20; } - default: - break; } - AddOpt(DFF_Prop_gtextAlign,gTextAlign); - } - } - if((nTextPathFlags & 0x4000) != 0) // Is Font work - { - OutlinerParaObject* pOutlinerParaObject(rSdrObjCustomShape.GetOutlinerParaObject()); - if ( pOutlinerParaObject && pOutlinerParaObject->IsVertical() ) - nTextPathFlags |= 0x2000; - } - - // Use gtextFStretch for Watermark like MSO does - nTextPathFlags |= use_gtextFBestFit | gtextFBestFit - | use_gtextFStretch | gtextFStretch - | use_gtextFShrinkFit | gtextFShrinkFit; - - if ( nTextPathFlags != nTextPathFlagsOrg ) - AddOpt( DFF_Prop_gtextFStrikethrough, nTextPathFlags ); - } - } - else if ( rProp.Name == sHandles ) - { - if ( !bIsDefaultObject ) - { - bPredefinedHandlesUsed = false; - if ( rProp.Value >>= aHandlesPropSeq ) - { - sal_uInt16 nElements = static_cast<sal_uInt16>(aHandlesPropSeq.getLength()); - if ( nElements ) - { - sal_uInt16 k, nElementSize = 36; - sal_uInt32 nStreamSize = nElementSize * nElements + 6; - SvMemoryStream aMemStrm( nStreamSize ); - aMemStrm.WriteUInt16( nElements ) - .WriteUInt16( nElements ) - .WriteUInt16( nElementSize ); - - for ( k = 0; k < nElements; k++ ) + else if ( rPropVal.Name == sRangeYMaximum ) { - sal_uInt32 nFlags = 0; - sal_Int32 nXPosition = 0; - sal_Int32 nYPosition = 0; - sal_Int32 nXMap = 0; - sal_Int32 nYMap = 0; - sal_Int32 nXRangeMin = 0x80000000; - sal_Int32 nXRangeMax = 0x7fffffff; - sal_Int32 nYRangeMin = 0x80000000; - sal_Int32 nYRangeMax = 0x7fffffff; - - const uno::Sequence< beans::PropertyValue >& rPropSeq = aHandlesPropSeq[ k ]; - for ( const beans::PropertyValue& rPropVal: rPropSeq ) + drawing::EnhancedCustomShapeParameter aYRangeMaximum; + if ( rPropVal.Value >>= aYRangeMaximum ) { - const OUString sPosition ( "Position" ); - const OUString sMirroredX ( "MirroredX" ); - const OUString sMirroredY ( "MirroredY" ); - const OUString sSwitched ( "Switched" ); - const OUString sPolar ( "Polar" ); - const OUString sRadiusRangeMinimum ( "RadiusRangeMinimum" ); - const OUString sRadiusRangeMaximum ( "RadiusRangeMaximum" ); - const OUString sRangeXMinimum ( "RangeXMinimum" ); - const OUString sRangeXMaximum ( "RangeXMaximum" ); - const OUString sRangeYMinimum ( "RangeYMinimum" ); - const OUString sRangeYMaximum ( "RangeYMaximum" ); - - if ( rPropVal.Name == sPosition ) - { - drawing::EnhancedCustomShapeParameterPair aPosition; - if ( rPropVal.Value >>= aPosition ) - { - GetValueForEnhancedCustomShapeHandleParameter( nXPosition, aPosition.First ); - GetValueForEnhancedCustomShapeHandleParameter( nYPosition, aPosition.Second ); - } - } - else if ( rPropVal.Name == sMirroredX ) - { - bool bMirroredX; - if ( rPropVal.Value >>= bMirroredX ) - { - if ( bMirroredX ) - nFlags |= 1; - } - } - else if ( rPropVal.Name == sMirroredY ) - { - bool bMirroredY; - if ( rPropVal.Value >>= bMirroredY ) - { - if ( bMirroredY ) - nFlags |= 2; - } - } - else if ( rPropVal.Name == sSwitched ) - { - bool bSwitched; - if ( rPropVal.Value >>= bSwitched ) - { - if ( bSwitched ) - nFlags |= 4; - } - } - else if ( rPropVal.Name == sPolar ) - { - drawing::EnhancedCustomShapeParameterPair aPolar; - if ( rPropVal.Value >>= aPolar ) - { - if ( GetValueForEnhancedCustomShapeHandleParameter( nXMap, aPolar.First ) ) - nFlags |= 0x800; - if ( GetValueForEnhancedCustomShapeHandleParameter( nYMap, aPolar.Second ) ) - nFlags |= 0x1000; - nFlags |= 8; - } - } - else if ( rPropVal.Name == sRadiusRangeMinimum ) - { - nYRangeMin = sal_Int32(0xff4c0000); // the range of angles seems to be a not - nYRangeMax = sal_Int32(0x00b40000); // used feature, so we are defaulting this - - drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum; - if ( rPropVal.Value >>= aRadiusRangeMinimum ) - { - if ( GetValueForEnhancedCustomShapeHandleParameter( nXRangeMin, aRadiusRangeMinimum ) ) - nFlags |= 0x80; - nFlags |= 0x2000; - } - } - else if ( rPropVal.Name == sRadiusRangeMaximum ) - { - nYRangeMin = sal_Int32(0xff4c0000); // the range of angles seems to be a not - nYRangeMax = sal_Int32(0x00b40000); // used feature, so we are defaulting this - - drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum; - if ( rPropVal.Value >>= aRadiusRangeMaximum ) - { - if ( GetValueForEnhancedCustomShapeHandleParameter( nXRangeMax, aRadiusRangeMaximum ) ) - nFlags |= 0x100; - nFlags |= 0x2000; - } - } - else if ( rPropVal.Name == sRangeXMinimum ) - { - drawing::EnhancedCustomShapeParameter aXRangeMinimum; - if ( rPropVal.Value >>= aXRangeMinimum ) - { - if ( GetValueForEnhancedCustomShapeHandleParameter( nXRangeMin, aXRangeMinimum ) ) - nFlags |= 0x80; - nFlags |= 0x20; - } - } - else if ( rPropVal.Name == sRangeXMaximum ) - { - drawing::EnhancedCustomShapeParameter aXRangeMaximum; - if ( rPropVal.Value >>= aXRangeMaximum ) - { - if ( GetValueForEnhancedCustomShapeHandleParameter( nXRangeMax, aXRangeMaximum ) ) - nFlags |= 0x100; - nFlags |= 0x20; - } - } - else if ( rPropVal.Name == sRangeYMinimum ) - { - drawing::EnhancedCustomShapeParameter aYRangeMinimum; - if ( rPropVal.Value >>= aYRangeMinimum ) - { - if ( GetValueForEnhancedCustomShapeHandleParameter( nYRangeMin, aYRangeMinimum ) ) - nFlags |= 0x200; - nFlags |= 0x20; - } - } - else if ( rPropVal.Name == sRangeYMaximum ) - { - drawing::EnhancedCustomShapeParameter aYRangeMaximum; - if ( rPropVal.Value >>= aYRangeMaximum ) - { - if ( GetValueForEnhancedCustomShapeHandleParameter( nYRangeMax, aYRangeMaximum ) ) - nFlags |= 0x400; - nFlags |= 0x20; - } - } + if ( GetValueForEnhancedCustomShapeHandleParameter( nYRangeMax, aYRangeMaximum ) ) + nFlags |= 0x400; + nFlags |= 0x20; } - aMemStrm.WriteUInt32( nFlags ) - .WriteInt32( nXPosition ) - .WriteInt32( nYPosition ) - .WriteInt32( nXMap ) - .WriteInt32( nYMap ) - .WriteInt32( nXRangeMin ) - .WriteInt32( nXRangeMax ) - .WriteInt32( nYRangeMin ) - .WriteInt32( nYRangeMax ); - - if ( nFlags & 8 ) - nAdjustmentsWhichNeedsToBeConverted |= ( 1 << ( nYPosition - 0x100 ) ); } - - AddOpt(DFF_Prop_Handles, true, 6, aMemStrm); } - else - { - AddOpt(DFF_Prop_Handles, 0, true); - } - } - } - } - else if ( rProp.Name == sAdjustmentValues ) - { - // it is required, that the information which handle is polar has already be read, - // so we are able to change the polar value to a fixed float - aAdjustmentValuesProp = rProp.Value; - bAdjustmentValuesProp = true; - } - } - if ( bAdjustmentValuesProp ) - { - uno::Sequence<drawing::EnhancedCustomShapeAdjustmentValue> aAdjustmentSeq; - if ( aAdjustmentValuesProp >>= aAdjustmentSeq ) - { - if ( bPredefinedHandlesUsed ) - LookForPolarHandles( eShapeType, nAdjustmentsWhichNeedsToBeConverted ); - - sal_Int32 k, nValue = 0, nAdjustmentValues = aAdjustmentSeq.getLength(); - for ( k = 0; k < nAdjustmentValues; k++ ) - if( GetAdjustmentValue( aAdjustmentSeq[ k ], k, nAdjustmentsWhichNeedsToBeConverted, nValue ) ) - AddOpt( static_cast<sal_uInt16>( DFF_Prop_adjustValue + k ), static_cast<sal_uInt32>(nValue) ); - } - } - if( bPathCoordinatesProp ) - { - uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aCoordinates; - if ( aPathCoordinatesProp >>= aCoordinates ) - { - // creating the vertices - if (aCoordinates.hasElements()) - { - sal_uInt16 j, nElements = static_cast<sal_uInt16>(aCoordinates.getLength()); - sal_uInt16 nElementSize = 8; - sal_uInt32 nStreamSize = nElementSize * nElements + 6; - SvMemoryStream aMemStrm( nStreamSize ); - aMemStrm.WriteUInt16( nElements ) - .WriteUInt16( nElements ) - .WriteUInt16( nElementSize ); - for( j = 0; j < nElements; j++ ) - { - sal_Int32 X = GetValueForEnhancedCustomShapeParameter( aCoordinates[ j ].First, aEquationOrder, true ); - sal_Int32 Y = GetValueForEnhancedCustomShapeParameter( aCoordinates[ j ].Second, aEquationOrder, true ); - aMemStrm.WriteInt32( X ) - .WriteInt32( Y ); + aMemStrm.WriteUInt32( nFlags ) + .WriteInt32( nXPosition ) + .WriteInt32( nYPosition ) + .WriteInt32( nXMap ) + .WriteInt32( nYMap ) + .WriteInt32( nXRangeMin ) + .WriteInt32( nXRangeMax ) + .WriteInt32( nYRangeMin ) + .WriteInt32( nYRangeMax ); + + if ( nFlags & 8 ) + nAdjustmentsWhichNeedsToBeConverted |= ( 1 << ( nYPosition - 0x100 ) ); } - AddOpt(DFF_Prop_pVertices, true, 6, aMemStrm); // -6 + AddOpt(DFF_Prop_Handles, true, 6, aMemStrm); } else { - AddOpt(DFF_Prop_pVertices, 0, true); + AddOpt(DFF_Prop_Handles, 0, true); } } } } + else if ( rProp.Name == sAdjustmentValues ) + { + // it is required, that the information which handle is polar has already be read, + // so we are able to change the polar value to a fixed float + aAdjustmentValuesProp = rProp.Value; + bAdjustmentValuesProp = true; + } + } + if ( bAdjustmentValuesProp ) + { + uno::Sequence<drawing::EnhancedCustomShapeAdjustmentValue> aAdjustmentSeq; + if ( aAdjustmentValuesProp >>= aAdjustmentSeq ) + { + if ( bPredefinedHandlesUsed ) + LookForPolarHandles( eShapeType, nAdjustmentsWhichNeedsToBeConverted ); + + sal_Int32 k, nValue = 0, nAdjustmentValues = aAdjustmentSeq.getLength(); + for ( k = 0; k < nAdjustmentValues; k++ ) + if( GetAdjustmentValue( aAdjustmentSeq[ k ], k, nAdjustmentsWhichNeedsToBeConverted, nValue ) ) + AddOpt( static_cast<sal_uInt16>( DFF_Prop_adjustValue + k ), static_cast<sal_uInt32>(nValue) ); + } + } + if( !bPathCoordinatesProp ) + return; + + uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aCoordinates; + if ( !(aPathCoordinatesProp >>= aCoordinates) ) + return; + + // creating the vertices + if (aCoordinates.hasElements()) + { + sal_uInt16 j, nElements = static_cast<sal_uInt16>(aCoordinates.getLength()); + sal_uInt16 nElementSize = 8; + sal_uInt32 nStreamSize = nElementSize * nElements + 6; + SvMemoryStream aMemStrm( nStreamSize ); + aMemStrm.WriteUInt16( nElements ) + .WriteUInt16( nElements ) + .WriteUInt16( nElementSize ); + for( j = 0; j < nElements; j++ ) + { + sal_Int32 X = GetValueForEnhancedCustomShapeParameter( aCoordinates[ j ].First, aEquationOrder, true ); + sal_Int32 Y = GetValueForEnhancedCustomShapeParameter( aCoordinates[ j ].Second, aEquationOrder, true ); + aMemStrm.WriteInt32( X ) + .WriteInt32( Y ); + } + + AddOpt(DFF_Prop_pVertices, true, 6, aMemStrm); // -6 + } + else + { + AddOpt(DFF_Prop_pVertices, 0, true); } } @@ -3951,56 +3951,56 @@ EscherBlibEntry::EscherBlibEntry( sal_uInt32 nPictureOffset, const GraphicObject sal_uInt32 nLen = static_cast<sal_uInt32>(rId.getLength()); const char* pData = rId.getStr(); GraphicType eType( rObject.GetType() ); - if (nLen && (eType != GraphicType::NONE)) - { - mnIdentifier[ 0 ] = rtl_crc32( 0,pData, nLen ); - mnIdentifier[ 1 ] = 0; + if (!(nLen && (eType != GraphicType::NONE))) + return; - if ( pGraphicAttr ) - { - if ( pGraphicAttr->IsSpecialDrawMode() - || pGraphicAttr->IsMirrored() - || pGraphicAttr->IsCropped() - || pGraphicAttr->IsRotated() - || pGraphicAttr->IsTransparent() - || pGraphicAttr->IsAdjusted() ) - { - SvMemoryStream aSt( sizeof( GraphicAttr ) ); - aSt.WriteUInt16( static_cast<sal_uInt16>(pGraphicAttr->GetDrawMode()) ) - .WriteUInt32( static_cast<sal_uInt32>(pGraphicAttr->GetMirrorFlags()) ) - .WriteInt32( pGraphicAttr->GetLeftCrop() ) - .WriteInt32( pGraphicAttr->GetTopCrop() ) - .WriteInt32( pGraphicAttr->GetRightCrop() ) - .WriteInt32( pGraphicAttr->GetBottomCrop() ) - .WriteUInt16( pGraphicAttr->GetRotation() ) - .WriteInt16( pGraphicAttr->GetLuminance() ) - .WriteInt16( pGraphicAttr->GetContrast() ) - .WriteInt16( pGraphicAttr->GetChannelR() ) - .WriteInt16( pGraphicAttr->GetChannelG() ) - .WriteInt16( pGraphicAttr->GetChannelB() ) - .WriteDouble( pGraphicAttr->GetGamma() ); - aSt.WriteBool( pGraphicAttr->IsInvert() ) - .WriteUChar( pGraphicAttr->GetTransparency() ); - mnIdentifier[ 1 ] = rtl_crc32( 0, aSt.GetData(), aSt.Tell() ); - } - else - mbIsNativeGraphicPossible = true; - } - sal_uInt32 i, nTmp, n1, n2; - n1 = n2 = 0; - for ( i = 0; i < nLen; i++ ) + mnIdentifier[ 0 ] = rtl_crc32( 0,pData, nLen ); + mnIdentifier[ 1 ] = 0; + + if ( pGraphicAttr ) + { + if ( pGraphicAttr->IsSpecialDrawMode() + || pGraphicAttr->IsMirrored() + || pGraphicAttr->IsCropped() + || pGraphicAttr->IsRotated() + || pGraphicAttr->IsTransparent() + || pGraphicAttr->IsAdjusted() ) { - nTmp = n2 >> 28; // rotating 4 bit - n2 <<= 4; - n2 |= n1 >> 28; - n1 <<= 4; - n1 |= nTmp; - n1 ^= *pData++ - '0'; + SvMemoryStream aSt( sizeof( GraphicAttr ) ); + aSt.WriteUInt16( static_cast<sal_uInt16>(pGraphicAttr->GetDrawMode()) ) + .WriteUInt32( static_cast<sal_uInt32>(pGraphicAttr->GetMirrorFlags()) ) + .WriteInt32( pGraphicAttr->GetLeftCrop() ) + .WriteInt32( pGraphicAttr->GetTopCrop() ) + .WriteInt32( pGraphicAttr->GetRightCrop() ) + .WriteInt32( pGraphicAttr->GetBottomCrop() ) + .WriteUInt16( pGraphicAttr->GetRotation() ) + .WriteInt16( pGraphicAttr->GetLuminance() ) + .WriteInt16( pGraphicAttr->GetContrast() ) + .WriteInt16( pGraphicAttr->GetChannelR() ) + .WriteInt16( pGraphicAttr->GetChannelG() ) + .WriteInt16( pGraphicAttr->GetChannelB() ) + .WriteDouble( pGraphicAttr->GetGamma() ); + aSt.WriteBool( pGraphicAttr->IsInvert() ) + .WriteUChar( pGraphicAttr->GetTransparency() ); + mnIdentifier[ 1 ] = rtl_crc32( 0, aSt.GetData(), aSt.Tell() ); } - mnIdentifier[ 2 ] = n1; - mnIdentifier[ 3 ] = n2; - mbIsEmpty = false; + else + mbIsNativeGraphicPossible = true; } + sal_uInt32 i, nTmp, n1, n2; + n1 = n2 = 0; + for ( i = 0; i < nLen; i++ ) + { + nTmp = n2 >> 28; // rotating 4 bit + n2 <<= 4; + n2 |= n1 >> 28; + n1 <<= 4; + n1 |= nTmp; + n1 ^= *pData++ - '0'; + } + mnIdentifier[ 2 ] = n1; + mnIdentifier[ 3 ] = n2; + mbIsEmpty = false; }; void EscherBlibEntry::WriteBlibEntry( SvStream& rSt, bool bWritePictureOffset, sal_uInt32 nResize ) @@ -4088,57 +4088,57 @@ void EscherGraphicProvider::WriteBlibStoreEntry(SvStream& rSt, void EscherGraphicProvider::WriteBlibStoreContainer( SvStream& rSt, SvStream* pMergePicStreamBSE ) { sal_uInt32 nSize = GetBlibStoreContainerSize( pMergePicStreamBSE ); - if ( nSize ) + if ( !nSize ) + return; + + rSt.WriteUInt32( ( ESCHER_BstoreContainer << 16 ) | 0x1f ) + .WriteUInt32( nSize - 8 ); + + if ( pMergePicStreamBSE ) { - rSt.WriteUInt32( ( ESCHER_BstoreContainer << 16 ) | 0x1f ) - .WriteUInt32( nSize - 8 ); + sal_uInt32 nBlipSize, nOldPos = pMergePicStreamBSE->Tell(); + const sal_uInt32 nBuf = 0x40000; // 256KB buffer + std::unique_ptr<sal_uInt8[]> pBuf(new sal_uInt8[ nBuf ]); - if ( pMergePicStreamBSE ) + for ( size_t i = 0; i < mvBlibEntrys.size(); i++ ) { - sal_uInt32 nBlipSize, nOldPos = pMergePicStreamBSE->Tell(); - const sal_uInt32 nBuf = 0x40000; // 256KB buffer - std::unique_ptr<sal_uInt8[]> pBuf(new sal_uInt8[ nBuf ]); - - for ( size_t i = 0; i < mvBlibEntrys.size(); i++ ) + EscherBlibEntry* pBlibEntry = mvBlibEntrys[ i ].get(); + + ESCHER_BlibType nBlibType = pBlibEntry->meBlibType; + nBlipSize = pBlibEntry->mnSize + pBlibEntry->mnSizeExtra; + pBlibEntry->WriteBlibEntry( rSt, false, nBlipSize ); + + // BLIP + pMergePicStreamBSE->Seek( pBlibEntry->mnPictureOffset ); + sal_uInt16 n16; + // record version and instance + pMergePicStreamBSE->ReadUInt16( n16 ); + rSt.WriteUInt16( n16 ); + // record type + pMergePicStreamBSE->ReadUInt16( n16 ); + rSt.WriteUInt16( ESCHER_BlipFirst + nBlibType ); + DBG_ASSERT( n16 == ESCHER_BlipFirst + nBlibType , "EscherGraphicProvider::WriteBlibStoreContainer: BLIP record types differ" ); + sal_uInt32 n32; + // record size + pMergePicStreamBSE->ReadUInt32( n32 ); + nBlipSize -= 8; + rSt.WriteUInt32( nBlipSize ); + DBG_ASSERT( nBlipSize == n32, "EscherGraphicProvider::WriteBlibStoreContainer: BLIP sizes differ" ); + // record + while ( nBlipSize ) { - EscherBlibEntry* pBlibEntry = mvBlibEntrys[ i ].get(); - - ESCHER_BlibType nBlibType = pBlibEntry->meBlibType; - nBlipSize = pBlibEntry->mnSize + pBlibEntry->mnSizeExtra; - pBlibEntry->WriteBlibEntry( rSt, false, nBlipSize ); - - // BLIP - pMergePicStreamBSE->Seek( pBlibEntry->mnPictureOffset ); - sal_uInt16 n16; - // record version and instance - pMergePicStreamBSE->ReadUInt16( n16 ); - rSt.WriteUInt16( n16 ); - // record type - pMergePicStreamBSE->ReadUInt16( n16 ); - rSt.WriteUInt16( ESCHER_BlipFirst + nBlibType ); - DBG_ASSERT( n16 == ESCHER_BlipFirst + nBlibType , "EscherGraphicProvider::WriteBlibStoreContainer: BLIP record types differ" ); - sal_uInt32 n32; - // record size - pMergePicStreamBSE->ReadUInt32( n32 ); - nBlipSize -= 8; - rSt.WriteUInt32( nBlipSize ); - DBG_ASSERT( nBlipSize == n32, "EscherGraphicProvider::WriteBlibStoreContainer: BLIP sizes differ" ); - // record - while ( nBlipSize ) - { - sal_uInt32 nBytes = std::min( nBlipSize, nBuf ); - pMergePicStreamBSE->ReadBytes(pBuf.get(), nBytes); - rSt.WriteBytes(pBuf.get(), nBytes); - nBlipSize -= nBytes; - } + sal_uInt32 nBytes = std::min( nBlipSize, nBuf ); + pMergePicStreamBSE->ReadBytes(pBuf.get(), nBytes); + rSt.WriteBytes(pBuf.get(), nBytes); + nBlipSize -= nBytes; } - pMergePicStreamBSE->Seek( nOldPos ); - } - else - { - for ( size_t i = 0; i < mvBlibEntrys.size(); i++ ) - mvBlibEntrys[ i ]->WriteBlibEntry( rSt, true ); } + pMergePicStreamBSE->Seek( nOldPos ); + } + else + { + for ( size_t i = 0; i < mvBlibEntrys.size(); i++ ) + mvBlibEntrys[ i ]->WriteBlibEntry( rSt, true ); } } @@ -4720,49 +4720,49 @@ sal_uInt32 EscherSolverContainer::GetShapeId( const uno::Reference<drawing::XSha void EscherSolverContainer::WriteSolver( SvStream& rStrm ) { sal_uInt32 nCount = maConnectorList.size(); - if ( nCount ) - { - sal_uInt32 nRecHdPos, nCurrentPos, nSize; - rStrm .WriteUInt16( ( nCount << 4 ) | 0xf ) // open an ESCHER_SolverContainer - .WriteUInt16( ESCHER_SolverContainer ) - .WriteUInt32( 0 ); + if ( !nCount ) + return; - nRecHdPos = rStrm.Tell() - 4; + sal_uInt32 nRecHdPos, nCurrentPos, nSize; + rStrm .WriteUInt16( ( nCount << 4 ) | 0xf ) // open an ESCHER_SolverContainer + .WriteUInt16( ESCHER_SolverContainer ) + .WriteUInt32( 0 ); - EscherConnectorRule aConnectorRule; - aConnectorRule.nRuleId = 2; - for (auto const & pPtr : maConnectorList) - { - aConnectorRule.ncptiA = aConnectorRule.ncptiB = 0xffffffff; - aConnectorRule.nShapeC = GetShapeId( pPtr->mXConnector ); - aConnectorRule.nShapeA = GetShapeId( pPtr->mXConnectToA ); - aConnectorRule.nShapeB = GetShapeId( pPtr->mXConnectToB ); + nRecHdPos = rStrm.Tell() - 4; - if ( aConnectorRule.nShapeC ) - { - if ( aConnectorRule.nShapeA ) - aConnectorRule.ncptiA = pPtr->GetConnectorRule( true ); - if ( aConnectorRule.nShapeB ) - aConnectorRule.ncptiB = pPtr->GetConnectorRule( false ); - } - rStrm .WriteUInt32( ( ESCHER_ConnectorRule << 16 ) | 1 ) // atom hd - .WriteUInt32( 24 ) - .WriteUInt32( aConnectorRule.nRuleId ) - .WriteUInt32( aConnectorRule.nShapeA ) - .WriteUInt32( aConnectorRule.nShapeB ) - .WriteUInt32( aConnectorRule.nShapeC ) - .WriteUInt32( aConnectorRule.ncptiA ) - .WriteUInt32( aConnectorRule.ncptiB ); - - aConnectorRule.nRuleId += 2; - } + EscherConnectorRule aConnectorRule; + aConnectorRule.nRuleId = 2; + for (auto const & pPtr : maConnectorList) + { + aConnectorRule.ncptiA = aConnectorRule.ncptiB = 0xffffffff; + aConnectorRule.nShapeC = GetShapeId( pPtr->mXConnector ); + aConnectorRule.nShapeA = GetShapeId( pPtr->mXConnectToA ); + aConnectorRule.nShapeB = GetShapeId( pPtr->mXConnectToB ); - nCurrentPos = rStrm.Tell(); // close the ESCHER_SolverContainer - nSize = ( nCurrentPos - nRecHdPos ) - 4; - rStrm.Seek( nRecHdPos ); - rStrm.WriteUInt32( nSize ); - rStrm.Seek( nCurrentPos ); + if ( aConnectorRule.nShapeC ) + { + if ( aConnectorRule.nShapeA ) + aConnectorRule.ncptiA = pPtr->GetConnectorRule( true ); + if ( aConnectorRule.nShapeB ) + aConnectorRule.ncptiB = pPtr->GetConnectorRule( false ); + } + rStrm .WriteUInt32( ( ESCHER_ConnectorRule << 16 ) | 1 ) // atom hd + .WriteUInt32( 24 ) + .WriteUInt32( aConnectorRule.nRuleId ) + .WriteUInt32( aConnectorRule.nShapeA ) + .WriteUInt32( aConnectorRule.nShapeB ) + .WriteUInt32( aConnectorRule.nShapeC ) + .WriteUInt32( aConnectorRule.ncptiA ) + .WriteUInt32( aConnectorRule.ncptiB ); + + aConnectorRule.nRuleId += 2; } + + nCurrentPos = rStrm.Tell(); // close the ESCHER_SolverContainer + nSize = ( nCurrentPos - nRecHdPos ) - 4; + rStrm.Seek( nRecHdPos ); + rStrm.WriteUInt32( nSize ); + rStrm.Seek( nCurrentPos ); } EscherExGlobal::EscherExGlobal() : @@ -4940,37 +4940,37 @@ EscherEx::~EscherEx() void EscherEx::Flush( SvStream* pPicStreamMergeBSE /* = NULL */ ) { - if ( mxGlobal->HasDggContainer() ) + if ( !mxGlobal->HasDggContainer() ) + return; + + // store the current stream position at ESCHER_Persist_CurrentPosition key + PtReplaceOrInsert( ESCHER_Persist_CurrentPosition, mpOutStrm->Tell() ); + if ( DoSeek( ESCHER_Persist_Dgg ) ) { - // store the current stream position at ESCHER_Persist_CurrentPosition key - PtReplaceOrInsert( ESCHER_Persist_CurrentPosition, mpOutStrm->Tell() ); - if ( DoSeek( ESCHER_Persist_Dgg ) ) - { - /* The DGG record is still not written. ESCHER_Persist_Dgg seeks - to the place where the complete record has to be inserted. */ - InsertAtCurrentPos( mxGlobal->GetDggAtomSize() ); - mxGlobal->WriteDggAtom( *mpOutStrm ); + /* The DGG record is still not written. ESCHER_Persist_Dgg seeks + to the place where the complete record has to be inserted. */ + InsertAtCurrentPos( mxGlobal->GetDggAtomSize() ); + mxGlobal->WriteDggAtom( *mpOutStrm ); - if ( mxGlobal->HasGraphics() ) + if ( mxGlobal->HasGraphics() ) + { + /* Calculate the total size of the BSTORECONTAINER including + all BSE records containing the picture data contained in + the passed in pPicStreamMergeBSE. */ + sal_uInt32 nBSCSize = mxGlobal->GetBlibStoreContainerSize( pPicStreamMergeBSE ); + if ( nBSCSize > 0 ) { - /* Calculate the total size of the BSTORECONTAINER including - all BSE records containing the picture data contained in - the passed in pPicStreamMergeBSE. */ - sal_uInt32 nBSCSize = mxGlobal->GetBlibStoreContainerSize( pPicStreamMergeBSE ); - if ( nBSCSize > 0 ) - { - InsertAtCurrentPos( nBSCSize ); - mxGlobal->WriteBlibStoreContainer( *mpOutStrm, pPicStreamMergeBSE ); - } + InsertAtCurrentPos( nBSCSize ); + mxGlobal->WriteBlibStoreContainer( *mpOutStrm, pPicStreamMergeBSE ); } - - /* Forget the stream position stored for the DGG which is invalid - after the call to InsertAtCurrentPos() anyway. */ - PtDelete( ESCHER_Persist_Dgg ); } - // seek to initial position (may be different due to inserted DGG and BLIPs) - mpOutStrm->Seek( PtGetOffsetByID( ESCHER_Persist_CurrentPosition ) ); + + /* Forget the stream position stored for the DGG which is invalid + after the call to InsertAtCurrentPos() anyway. */ + PtDelete( ESCHER_Persist_Dgg ); } + // seek to initial position (may be different due to inserted DGG and BLIPs) + mpOutStrm->Seek( PtGetOffsetByID( ESCHER_Persist_CurrentPosition ) ); } void EscherEx::InsertAtCurrentPos( sal_uInt32 nBytes ) diff --git a/filter/source/msfilter/eschesdo.cxx b/filter/source/msfilter/eschesdo.cxx index e92933cf2775..af78b7be323e 100644 --- a/filter/source/msfilter/eschesdo.cxx +++ b/filter/source/msfilter/eschesdo.cxx @@ -1129,39 +1129,39 @@ static basegfx::B2DRange getUnrotatedGroupBoundRange(const Reference< XShape >& void ImplEESdrObject::Init( ImplEESdrWriter& rEx ) { mXPropSet.set( mXShape, UNO_QUERY ); - if( mXPropSet.is() ) - { - // detect name first to make below test (is group) work - mType = mXShape->getShapeType(); - (void)mType.startsWith( "com.sun.star.", &mType ); // strip "com.sun.star." - (void)mType.endsWith( "Shape", &mType ); // strip "Shape" + if( !mXPropSet.is() ) + return; - if(GetType() == "drawing.Group") - { - // if it's a group, the unrotated range is needed for that group - const basegfx::B2DRange aUnroatedRange(getUnrotatedGroupBoundRange(mXShape)); - const Point aNewP(basegfx::fround(aUnroatedRange.getMinX()), basegfx::fround(aUnroatedRange.getMinY())); - const Size aNewS(basegfx::fround(aUnroatedRange.getWidth()), basegfx::fround(aUnroatedRange.getHeight())); + // detect name first to make below test (is group) work + mType = mXShape->getShapeType(); + (void)mType.startsWith( "com.sun.star.", &mType ); // strip "com.sun.star." + (void)mType.endsWith( "Shape", &mType ); // strip "Shape" - SetRect(rEx.ImplMapPoint(aNewP), rEx.ImplMapSize(aNewS)); - } - else - { - // if it's no group, use position and size directly, rotated/sheared or not - const Point aOldP(mXShape->getPosition().X, mXShape->getPosition().Y); - const Size aOldS(mXShape->getSize().Width, mXShape->getSize().Height); + if(GetType() == "drawing.Group") + { + // if it's a group, the unrotated range is needed for that group + const basegfx::B2DRange aUnroatedRange(getUnrotatedGroupBoundRange(mXShape)); + const Point aNewP(basegfx::fround(aUnroatedRange.getMinX()), basegfx::fround(aUnroatedRange.getMinY())); + const Size aNewS(basegfx::fround(aUnroatedRange.getWidth()), basegfx::fround(aUnroatedRange.getHeight())); - SetRect(rEx.ImplMapPoint(aOldP), rEx.ImplMapSize(aOldS)); - } + SetRect(rEx.ImplMapPoint(aNewP), rEx.ImplMapSize(aNewS)); + } + else + { + // if it's no group, use position and size directly, rotated/sheared or not + const Point aOldP(mXShape->getPosition().X, mXShape->getPosition().Y); + const Size aOldS(mXShape->getSize().Width, mXShape->getSize().Height); - if( ImplGetPropertyValue( "IsPresentationObject" ) ) - mbPresObj = ::cppu::any2bool( mAny ); + SetRect(rEx.ImplMapPoint(aOldP), rEx.ImplMapSize(aOldS)); + } - if( mbPresObj && ImplGetPropertyValue( "IsEmptyPresentationObject" ) ) - mbEmptyPresObj = ::cppu::any2bool( mAny ); + if( ImplGetPropertyValue( "IsPresentationObject" ) ) + mbPresObj = ::cppu::any2bool( mAny ); - mbValid = true; - } + if( mbPresObj && ImplGetPropertyValue( "IsEmptyPresentationObject" ) ) + mbEmptyPresObj = ::cppu::any2bool( mAny ); + + mbValid = true; } bool ImplEESdrObject::ImplGetPropertyValue( const OUString& rString ) diff --git a/filter/source/msfilter/mscodec.cxx b/filter/source/msfilter/mscodec.cxx index 50b2de6dedb0..0a03b50de454 100644 --- a/filter/source/msfilter/mscodec.cxx +++ b/filter/source/msfilter/mscodec.cxx @@ -578,31 +578,31 @@ void MSCodec_Std97::GetEncryptKey ( sal_uInt8 pSaltData[16], sal_uInt8 pSaltDigest[16]) { - if (InitCipher(0)) - { - sal_uInt8 pDigest[RTL_DIGEST_LENGTH_MD5]; - sal_uInt8 pBuffer[64]; + if (!InitCipher(0)) + return; - rtl_cipher_encode ( - m_hCipher, pSalt, 16, pSaltData, sizeof(pBuffer)); + sal_uInt8 pDigest[RTL_DIGEST_LENGTH_MD5]; + sal_uInt8 pBuffer[64]; + + rtl_cipher_encode ( + m_hCipher, pSalt, 16, pSaltData, sizeof(pBuffer)); - (void)memcpy( pBuffer, pSalt, 16 ); + (void)memcpy( pBuffer, pSalt, 16 ); - pBuffer[16] = 0x80; - (void)memset (pBuffer + 17, 0, sizeof(pBuffer) - 17); - pBuffer[56] = 0x80; + pBuffer[16] = 0x80; + (void)memset (pBuffer + 17, 0, sizeof(pBuffer) - 17); + pBuffer[56] = 0x80; - rtl_digest_updateMD5 ( - m_hDigest, pBuffer, sizeof(pBuffer)); - rtl_digest_rawMD5 ( - m_hDigest, pDigest, sizeof(pDigest)); + rtl_digest_updateMD5 ( + m_hDigest, pBuffer, sizeof(pBuffer)); + rtl_digest_rawMD5 ( + m_hDigest, pDigest, sizeof(pDigest)); - rtl_cipher_encode ( - m_hCipher, pDigest, 16, pSaltDigest, 16); + rtl_cipher_encode ( + m_hCipher, pDigest, 16, pSaltDigest, 16); - rtl_secureZeroMemory (pBuffer, sizeof(pBuffer)); - rtl_secureZeroMemory (pDigest, sizeof(pDigest)); - } + rtl_secureZeroMemory (pBuffer, sizeof(pBuffer)); + rtl_secureZeroMemory (pDigest, sizeof(pDigest)); } void MSCodec97::GetDocId( sal_uInt8 pDocId[16] ) diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 800a675dc54b..4c195865a2fc 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -1154,159 +1154,159 @@ static void ApplyRectangularGradientAsBitmap( const SvxMSDffManager& rManager, S { Size aBitmapSizePixel( static_cast< sal_Int32 >( ( rObjData.aBoundRect.GetWidth() / 2540.0 ) * 90.0 ), // we will create a bitmap with 90 dpi static_cast< sal_Int32 >( ( rObjData.aBoundRect.GetHeight() / 2540.0 ) * 90.0 ) ); - if (aBitmapSizePixel.Width() > 0 && aBitmapSizePixel.Height() > 0 && - aBitmapSizePixel.Width() <= 1024 && aBitmapSizePixel.Height() <= 1024) - { - double fFocusX = rManager.GetPropertyValue( DFF_Prop_fillToRight, 0 ) / 65536.0; - double fFocusY = rManager.GetPropertyValue( DFF_Prop_fillToBottom, 0 ) / 65536.0; + if (!(aBitmapSizePixel.Width() > 0 && aBitmapSizePixel.Height() > 0 && + aBitmapSizePixel.Width() <= 1024 && aBitmapSizePixel.Height() <= 1024)) + return; + + double fFocusX = rManager.GetPropertyValue( DFF_Prop_fillToRight, 0 ) / 65536.0; + double fFocusY = rManager.GetPropertyValue( DFF_Prop_fillToBottom, 0 ) / 65536.0; - vcl::bitmap::RawBitmap aBitmap(aBitmapSizePixel, 24); + vcl::bitmap::RawBitmap aBitmap(aBitmapSizePixel, 24); - for ( long nY = 0; nY < aBitmapSizePixel.Height(); nY++ ) + for ( long nY = 0; nY < aBitmapSizePixel.Height(); nY++ ) + { + for ( long nX = 0; nX < aBitmapSizePixel.Width(); nX++ ) { - for ( long nX = 0; nX < aBitmapSizePixel.Width(); nX++ ) - { - double fX = static_cast< double >( nX ) / aBitmapSizePixel.Width(); - double fY = static_cast< double >( nY ) / aBitmapSizePixel.Height(); + double fX = static_cast< double >( nX ) / aBitmapSizePixel.Width(); + double fY = static_cast< double >( nY ) / aBitmapSizePixel.Height(); - double fD, fDist; - if ( fX < fFocusX ) + double fD, fDist; + if ( fX < fFocusX ) + { + if ( fY < fFocusY ) { - if ( fY < fFocusY ) + if ( fX > fY ) { - if ( fX > fY ) - { - fDist = fY; - fD = fFocusY; - } - else - { - fDist = fX; - fD = fFocusX; - } + fDist = fY; + fD = fFocusY; } else { - if ( fX > ( 1 - fY ) ) - { - fDist = 1 - fY; - fD = 1 - fFocusY; - } - else - { - fDist = fX; - fD = fFocusX; - } + fDist = fX; + fD = fFocusX; } } else { - if ( fY < fFocusY ) + if ( fX > ( 1 - fY ) ) { - if ( ( 1 - fX ) > fY ) - { - fDist = fY; - fD = fFocusY; - } - else - { - fDist = 1 - fX; - fD = 1 - fFocusX; - } + fDist = 1 - fY; + fD = 1 - fFocusY; } else { - if ( ( 1 - fX ) > ( 1 - fY ) ) - { - fDist = 1 - fY; - fD = 1 - fFocusY; - } - else - { - fDist = 1 - fX; - fD = 1 - fFocusX; - } + fDist = fX; + fD = fFocusX; } } - if ( fD != 0.0 ) - fDist /= fD; - - double fA = 0.0; - Color aColorA = rShadeColors.front().aColor; - double fB = 1.0; - Color aColorB( aColorA ); - for ( const auto& rShadeColor : rShadeColors ) + } + else + { + if ( fY < fFocusY ) { - if ( fA <= rShadeColor.fDist && rShadeColor.fDist <= fDist ) + if ( ( 1 - fX ) > fY ) { - fA = rShadeColor.fDist; - aColorA = rShadeColor.aColor; + fDist = fY; + fD = fFocusY; } - if ( fDist < rShadeColor.fDist && rShadeColor.fDist <= fB ) + else { - fB = rShadeColor.fDist; - aColorB = rShadeColor.aColor; + fDist = 1 - fX; + fD = 1 - fFocusX; } } - double fRed = aColorA.GetRed(), fGreen = aColorA.GetGreen(), fBlue = aColorA.GetBlue(); - double fD1 = fB - fA; - if ( fD1 != 0.0 ) + else { - fRed += ( ( ( fDist - fA ) * ( aColorB.GetRed() - aColorA.GetRed() ) ) / fD1 ); // + aQuantErrCurrScan[ nX ].fRed; - fGreen += ( ( ( fDist - fA ) * ( aColorB.GetGreen() - aColorA.GetGreen() ) ) / fD1 ); // + aQuantErrCurrScan[ nX ].fGreen; - fBlue += ( ( ( fDist - fA ) * ( aColorB.GetBlue() - aColorA.GetBlue() ) ) / fD1 ); // + aQuantErrCurrScan[ nX ].fBlue; + if ( ( 1 - fX ) > ( 1 - fY ) ) + { + fDist = 1 - fY; + fD = 1 - fFocusY; + } + else + { + fDist = 1 - fX; + fD = 1 - fFocusX; + } } - sal_Int16 nRed = static_cast< sal_Int16 >( fRed + 0.5 ); - sal_Int16 nGreen = static_cast< sal_Int16 >( fGreen + 0.5 ); - sal_Int16 nBlue = static_cast< sal_Int16 >( fBlue + 0.5 ); - if ( nRed < 0 ) - nRed = 0; - if ( nRed > 255 ) - nRed = 255; - if ( nGreen < 0 ) - nGreen = 0; - if ( nGreen > 255 ) - nGreen = 255; - if ( nBlue < 0 ) - nBlue = 0; - if ( nBlue > 255 ) - nBlue = 255; - - aBitmap.SetPixel(nY, nX, Color(static_cast<sal_Int8>(nRed), static_cast<sal_Int8>(nGreen), static_cast<sal_Int8>(nBlue))); } - } - BitmapEx aBitmapEx = vcl::bitmap::CreateFromData( std::move(aBitmap) ); - - if ( nFix16Angle ) - { - bool bRotateWithShape = true; // sal_True seems to be default - sal_uInt32 nPos = rIn.Tell(); - if ( const_cast< SvxMSDffManager& >( rManager ).maShapeRecords.SeekToContent( rIn, DFF_msofbtUDefProp, SEEK_FROM_CURRENT_AND_RESTART ) ) + if ( fD != 0.0 ) + fDist /= fD; + + double fA = 0.0; + Color aColorA = rShadeColors.front().aColor; + double fB = 1.0; + Color aColorB( aColorA ); + for ( const auto& rShadeColor : rShadeColors ) { - const_cast< SvxMSDffManager& >( rManager ).maShapeRecords.Current()->SeekToBegOfRecord( rIn ); - DffPropertyReader aSecPropSet( rManager ); - aSecPropSet.ReadPropSet( rIn, nullptr ); - sal_Int32 nSecFillProperties = aSecPropSet.GetPropertyValue( DFF_Prop_fNoFillHitTest, 0x200020 ); - bRotateWithShape = ( nSecFillProperties & 0x0020 ); + if ( fA <= rShadeColor.fDist && rShadeColor.fDist <= fDist ) + { + fA = rShadeColor.fDist; + aColorA = rShadeColor.aColor; + } + if ( fDist < rShadeColor.fDist && rShadeColor.fDist <= fB ) + { + fB = rShadeColor.fDist; + aColorB = rShadeColor.aColor; + } } - rIn.Seek( nPos ); - if ( bRotateWithShape ) + double fRed = aColorA.GetRed(), fGreen = aColorA.GetGreen(), fBlue = aColorA.GetBlue(); + double fD1 = fB - fA; + if ( fD1 != 0.0 ) { - aBitmapEx.Rotate( nFix16Angle / 10, rShadeColors[ 0 ].aColor ); - - BmpMirrorFlags nMirrorFlags = BmpMirrorFlags::NONE; - if ( rObjData.nSpFlags & ShapeFlag::FlipV ) - nMirrorFlags |= BmpMirrorFlags::Vertical; - if ( rObjData.nSpFlags & ShapeFlag::FlipH ) - nMirrorFlags |= BmpMirrorFlags::Horizontal; - if ( nMirrorFlags != BmpMirrorFlags::NONE ) - aBitmapEx.Mirror( nMirrorFlags ); + fRed += ( ( ( fDist - fA ) * ( aColorB.GetRed() - aColorA.GetRed() ) ) / fD1 ); // + aQuantErrCurrScan[ nX ].fRed; + fGreen += ( ( ( fDist - fA ) * ( aColorB.GetGreen() - aColorA.GetGreen() ) ) / fD1 ); // + aQuantErrCurrScan[ nX ].fGreen; + fBlue += ( ( ( fDist - fA ) * ( aColorB.GetBlue() - aColorA.GetBlue() ) ) / fD1 ); // + aQuantErrCurrScan[ nX ].fBlue; } + sal_Int16 nRed = static_cast< sal_Int16 >( fRed + 0.5 ); + sal_Int16 nGreen = static_cast< sal_Int16 >( fGreen + 0.5 ); + sal_Int16 nBlue = static_cast< sal_Int16 >( fBlue + 0.5 ); + if ( nRed < 0 ) + nRed = 0; + if ( nRed > 255 ) + nRed = 255; + if ( nGreen < 0 ) + nGreen = 0; + if ( nGreen > 255 ) + nGreen = 255; + if ( nBlue < 0 ) + nBlue = 0; + if ( nBlue > 255 ) + nBlue = 255; + + aBitmap.SetPixel(nY, nX, Color(static_cast<sal_Int8>(nRed), static_cast<sal_Int8>(nGreen), static_cast<sal_Int8>(nBlue))); + } + } + BitmapEx aBitmapEx = vcl::bitmap::CreateFromData( std::move(aBitmap) ); + + if ( nFix16Angle ) + { + bool bRotateWithShape = true; // sal_True seems to be default + sal_uInt32 nPos = rIn.Tell(); + if ( const_cast< SvxMSDffManager& >( rManager ).maShapeRecords.SeekToContent( rIn, DFF_msofbtUDefProp, SEEK_FROM_CURRENT_AND_RESTART ) ) + { + const_cast< SvxMSDffManager& >( rManager ).maShapeRecords.Current()->SeekToBegOfRecord( rIn ); + DffPropertyReader aSecPropSet( rManager ); + aSecPropSet.ReadPropSet( rIn, nullptr ); + sal_Int32 nSecFillProperties = aSecPropSet.GetPropertyValue( DFF_Prop_fNoFillHitTest, 0x200020 ); + bRotateWithShape = ( nSecFillProperties & 0x0020 ); } + rIn.Seek( nPos ); + if ( bRotateWithShape ) + { + aBitmapEx.Rotate( nFix16Angle / 10, rShadeColors[ 0 ].aColor ); - rSet.Put(XFillBmpTileItem(false)); - rSet.Put(XFillBitmapItem(OUString(), Graphic(aBitmapEx))); + BmpMirrorFlags nMirrorFlags = BmpMirrorFlags::NONE; + if ( rObjData.nSpFlags & ShapeFlag::FlipV ) + nMirrorFlags |= BmpMirrorFlags::Vertical; + if ( rObjData.nSpFlags & ShapeFlag::FlipH ) + nMirrorFlags |= BmpMirrorFlags::Horizontal; + if ( nMirrorFlags != BmpMirrorFlags::NONE ) + aBitmapEx.Mirror( nMirrorFlags ); + } } + + rSet.Put(XFillBmpTileItem(false)); + rSet.Put(XFillBitmapItem(OUString(), Graphic(aBitmapEx))); } void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, const DffObjData& rObjData ) const @@ -2814,27 +2814,27 @@ void DffPropertyReader::CheckAndCorrectExcelTextRotation( SvStream& rIn, SfxItem } } } - if ( !bRotateTextWithShape ) - { - const css::uno::Any* pAny; - SdrCustomShapeGeometryItem aGeometryItem(rSet.Get( SDRATTR_CUSTOMSHAPE_GEOMETRY )); - const OUString sTextRotateAngle( "TextRotateAngle" ); - pAny = aGeometryItem.GetPropertyValueByName( sTextRotateAngle ); - double fExtraTextRotateAngle = 0.0; - if ( pAny ) - *pAny >>= fExtraTextRotateAngle; - - if ( rManager.mnFix16Angle ) - fExtraTextRotateAngle += mnFix16Angle / 100.0; - if ( rObjData.nSpFlags & ShapeFlag::FlipV ) - fExtraTextRotateAngle -= 180.0; + if ( bRotateTextWithShape ) + return; - css::beans::PropertyValue aTextRotateAngle; - aTextRotateAngle.Name = sTextRotateAngle; - aTextRotateAngle.Value <<= fExtraTextRotateAngle; - aGeometryItem.SetPropertyValue( aTextRotateAngle ); - rSet.Put( aGeometryItem ); - } + const css::uno::Any* pAny; + SdrCustomShapeGeometryItem aGeometryItem(rSet.Get( SDRATTR_CUSTOMSHAPE_GEOMETRY )); + const OUString sTextRotateAngle( "TextRotateAngle" ); + pAny = aGeometryItem.GetPropertyValueByName( sTextRotateAngle ); + double fExtraTextRotateAngle = 0.0; + if ( pAny ) + *pAny >>= fExtraTextRotateAngle; + + if ( rManager.mnFix16Angle ) + fExtraTextRotateAngle += mnFix16Angle / 100.0; + if ( rObjData.nSpFlags & ShapeFlag::FlipV ) + fExtraTextRotateAngle -= 180.0; + + css::beans::PropertyValue aTextRotateAngle; + aTextRotateAngle.Name = sTextRotateAngle; + aTextRotateAngle.Value <<= fExtraTextRotateAngle; + aGeometryItem.SetPropertyValue( aTextRotateAngle ); + rSet.Put( aGeometryItem ); } @@ -2986,23 +2986,23 @@ void DffRecordManager::Consume( SvStream& rIn, sal_uInt32 nStOfs ) if (bOk && aHd.nRecVer == DFF_PSFLAG_CONTAINER) nStOfs = aHd.GetRecEndFilePos(); } - if ( nStOfs ) + if ( !nStOfs ) + return; + + pCList = this; + while ( pCList->pNext ) + pCList = pCList->pNext.get(); + while (rIn.good() && ( ( rIn.Tell() + 8 ) <= nStOfs )) { - pCList = this; - while ( pCList->pNext ) - pCList = pCList->pNext.get(); - while (rIn.good() && ( ( rIn.Tell() + 8 ) <= nStOfs )) - { - if ( pCList->nCount == DFF_RECORD_MANAGER_BUF_SIZE ) - pCList = new DffRecordList( pCList ); - if (!ReadDffRecordHeader(rIn, pCList->mHd[ pCList->nCount ])) - break; - bool bSeekSucceeded = pCList->mHd[ pCList->nCount++ ].SeekToEndOfRecord(rIn); - if (!bSeekSucceeded) - break; - } - rIn.Seek( nOldPos ); + if ( pCList->nCount == DFF_RECORD_MANAGER_BUF_SIZE ) + pCList = new DffRecordList( pCList ); + if (!ReadDffRecordHeader(rIn, pCList->mHd[ pCList->nCount ])) + break; + bool bSeekSucceeded = pCList->mHd[ pCList->nCount++ ].SeekToEndOfRecord(rIn); + if (!bSeekSucceeded) + break; } + rIn.Seek( nOldPos ); } void DffRecordManager::Clear() @@ -3635,31 +3635,31 @@ void SvxMSDffManager::ReadObjText( SvStream& rStream, SdrObject* pObj ) DffRecordHeader aRecHd; if (!ReadDffRecordHeader(rStream, aRecHd)) return; - if( aRecHd.nRecType == DFF_msofbtClientTextbox || aRecHd.nRecType == 0x1022 ) + if( !(aRecHd.nRecType == DFF_msofbtClientTextbox || aRecHd.nRecType == 0x1022) ) + return; + + while (rStream.good() && rStream.Tell() < aRecHd.GetRecEndFilePos()) { - while (rStream.good() && rStream.Tell() < aRecHd.GetRecEndFilePos()) + DffRecordHeader aHd; + if (!ReadDffRecordHeader(rStream, aHd)) + break; + switch( aHd.nRecType ) { - DffRecordHeader aHd; - if (!ReadDffRecordHeader(rStream, aHd)) + case DFF_PST_TextBytesAtom: + case DFF_PST_TextCharsAtom: + { + bool bUniCode = ( aHd.nRecType == DFF_PST_TextCharsAtom ); + sal_uInt32 nBytes = aHd.nRecLen; + OUString aStr = MSDFFReadZString( rStream, nBytes, bUniCode ); + ReadObjText( aStr, pObj ); + } break; - switch( aHd.nRecType ) - { - case DFF_PST_TextBytesAtom: - case DFF_PST_TextCharsAtom: - { - bool bUniCode = ( aHd.nRecType == DFF_PST_TextCharsAtom ); - sal_uInt32 nBytes = aHd.nRecLen; - OUString aStr = MSDFFReadZString( rStream, nBytes, bUniCode ); - ReadObjText( aStr, pObj ); - } - break; - default: - break; - } - bool bSeekSuccess = aHd.SeekToEndOfRecord(rStream); - if (!bSeekSuccess) + default: break; } + bool bSeekSuccess = aHd.SeekToEndOfRecord(rStream); + if (!bSeekSuccess) + break; } } @@ -3669,61 +3669,61 @@ void SvxMSDffManager::ReadObjText( SvStream& rStream, SdrObject* pObj ) void SvxMSDffManager::ReadObjText( const OUString& rText, SdrObject* pObj ) { SdrTextObj* pText = dynamic_cast<SdrTextObj*>( pObj ); - if ( pText ) - { - SdrOutliner& rOutliner = pText->ImpGetDrawOutliner(); - rOutliner.Init( OutlinerMode::TextObject ); + if ( !pText ) + return; - bool bOldUpdateMode = rOutliner.GetUpdateMode(); - rOutliner.SetUpdateMode( false ); - rOutliner.SetVertical( pText->IsVerticalWriting() ); + SdrOutliner& rOutliner = pText->ImpGetDrawOutliner(); + rOutliner.Init( OutlinerMode::TextObject ); - sal_Int32 nParaIndex = 0; - sal_Int32 nParaSize; - const sal_Unicode* pBuf = rText.getStr(); - const sal_Unicode* pEnd = rText.getStr() + rText.getLength(); + bool bOldUpdateMode = rOutliner.GetUpdateMode(); + rOutliner.SetUpdateMode( false ); + rOutliner.SetVertical( pText->IsVerticalWriting() ); - while( pBuf < pEnd ) - { - const sal_Unicode* pCurrent = pBuf; + sal_Int32 nParaIndex = 0; + sal_Int32 nParaSize; + const sal_Unicode* pBuf = rText.getStr(); + const sal_Unicode* pEnd = rText.getStr() + rText.getLength(); + + while( pBuf < pEnd ) + { + const sal_Unicode* pCurrent = pBuf; - for ( nParaSize = 0; pBuf < pEnd; ) + for ( nParaSize = 0; pBuf < pEnd; ) + { + sal_Unicode nChar = *pBuf++; + if ( nChar == 0xa ) { - sal_Unicode nChar = *pBuf++; - if ( nChar == 0xa ) - { - if ( ( pBuf < pEnd ) && ( *pBuf == 0xd ) ) - pBuf++; - break; - } - else if ( nChar == 0xd ) - { - if ( ( pBuf < pEnd ) && ( *pBuf == 0xa ) ) - pBuf++; - break; - } - else - ++nParaSize; + if ( ( pBuf < pEnd ) && ( *pBuf == 0xd ) ) + pBuf++; + break; } - ESelection aSelection( nParaIndex, 0, nParaIndex, 0 ); - OUString aParagraph( pCurrent, nParaSize ); - if ( !nParaIndex && aParagraph.isEmpty() ) // SJ: we are crashing if the first paragraph is empty ? - aParagraph += " "; // otherwise these two lines can be removed. - rOutliner.Insert( aParagraph, nParaIndex ); - rOutliner.SetParaAttribs( nParaIndex, rOutliner.GetEmptyItemSet() ); - - SfxItemSet aParagraphAttribs( rOutliner.GetEmptyItemSet() ); - if ( !aSelection.nStartPos ) - aParagraphAttribs.Put( SfxBoolItem( EE_PARA_BULLETSTATE, false ) ); - aSelection.nStartPos = 0; - rOutliner.QuickSetAttribs( aParagraphAttribs, aSelection ); - nParaIndex++; - } - std::unique_ptr<OutlinerParaObject> pNewText = rOutliner.CreateParaObject(); - rOutliner.Clear(); - rOutliner.SetUpdateMode( bOldUpdateMode ); - pText->SetOutlinerParaObject( std::move(pNewText) ); + else if ( nChar == 0xd ) + { + if ( ( pBuf < pEnd ) && ( *pBuf == 0xa ) ) + pBuf++; + break; + } + else + ++nParaSize; + } + ESelection aSelection( nParaIndex, 0, nParaIndex, 0 ); + OUString aParagraph( pCurrent, nParaSize ); + if ( !nParaIndex && aParagraph.isEmpty() ) // SJ: we are crashing if the first paragraph is empty ? + aParagraph += " "; // otherwise these two lines can be removed. + rOutliner.Insert( aParagraph, nParaIndex ); + rOutliner.SetParaAttribs( nParaIndex, rOutliner.GetEmptyItemSet() ); + + SfxItemSet aParagraphAttribs( rOutliner.GetEmptyItemSet() ); + if ( !aSelection.nStartPos ) + aParagraphAttribs.Put( SfxBoolItem( EE_PARA_BULLETSTATE, false ) ); + aSelection.nStartPos = 0; + rOutliner.QuickSetAttribs( aParagraphAttribs, aSelection ); + nParaIndex++; } + std::unique_ptr<OutlinerParaObject> pNewText = rOutliner.CreateParaObject(); + rOutliner.Clear(); + rOutliner.SetUpdateMode( bOldUpdateMode ); + pText->SetOutlinerParaObject( std::move(pNewText) ); } //static @@ -3771,51 +3771,51 @@ static void lcl_ApplyCropping( const DffPropSet& rPropSet, SfxItemSet* pSet, Gra sal_Int32 nCropLeft = static_cast<sal_Int32>(rPropSet.GetPropertyValue( DFF_Prop_cropFromLeft, 0 )); sal_Int32 nCropRight = static_cast<sal_Int32>(rPropSet.GetPropertyValue( DFF_Prop_cropFromRight, 0 )); - if( nCropTop || nCropBottom || nCropLeft || nCropRight ) - { - double fFactor; - Size aCropSize; - BitmapEx aCropBitmap; - sal_uInt32 nTop( 0 ), nBottom( 0 ), nLeft( 0 ), nRight( 0 ); + if( !(nCropTop || nCropBottom || nCropLeft || nCropRight) ) + return; - // Cropping has to be applied on a loaded graphic. - rGraf.makeAvailable(); + double fFactor; + Size aCropSize; + BitmapEx aCropBitmap; + sal_uInt32 nTop( 0 ), nBottom( 0 ), nLeft( 0 ), nRight( 0 ); - if ( pSet ) // use crop attributes ? - aCropSize = lcl_GetPrefSize(rGraf, MapMode(MapUnit::Map100thMM)); - else - { - aCropBitmap = rGraf.GetBitmapEx(); - aCropSize = aCropBitmap.GetSizePixel(); - } - if ( nCropTop ) - { - fFactor = static_cast<double>(nCropTop) / 65536.0; - nTop = static_cast<sal_uInt32>( ( static_cast<double>( aCropSize.Height() + 1 ) * fFactor ) + 0.5 ); - } - if ( nCropBottom ) - { - fFactor = static_cast<double>(nCropBottom) / 65536.0; - nBottom = static_cast<sal_uInt32>( ( static_cast<double>( aCropSize.Height() + 1 ) * fFactor ) + 0.5 ); - } - if ( nCropLeft ) - { - fFactor = static_cast<double>(nCropLeft) / 65536.0; - nLeft = static_cast<sal_uInt32>( ( static_cast<double>( aCropSize.Width() + 1 ) * fFactor ) + 0.5 ); - } - if ( nCropRight ) - { - fFactor = static_cast<double>(nCropRight) / 65536.0; - nRight = static_cast<sal_uInt32>( ( static_cast<double>( aCropSize.Width() + 1 ) * fFactor ) + 0.5 ); - } - if ( pSet ) // use crop attributes ? - pSet->Put( SdrGrafCropItem( nLeft, nTop, nRight, nBottom ) ); - else - { - tools::Rectangle aCropRect( nLeft, nTop, aCropSize.Width() - nRight, aCropSize.Height() - nBottom ); - aCropBitmap.Crop( aCropRect ); - rGraf = aCropBitmap; - } + // Cropping has to be applied on a loaded graphic. + rGraf.makeAvailable(); + + if ( pSet ) // use crop attributes ? + aCropSize = lcl_GetPrefSize(rGraf, MapMode(MapUnit::Map100thMM)); + else + { + aCropBitmap = rGraf.GetBitmapEx(); + aCropSize = aCropBitmap.GetSizePixel(); + } + if ( nCropTop ) + { + fFactor = static_cast<double>(nCropTop) / 65536.0; + nTop = static_cast<sal_uInt32>( ( static_cast<double>( aCropSize.Height() + 1 ) * fFactor ) + 0.5 ); + } + if ( nCropBottom ) + { + fFactor = static_cast<double>(nCropBottom) / 65536.0; + nBottom = static_cast<sal_uInt32>( ( static_cast<double>( aCropSize.Height() + 1 ) * fFactor ) + 0.5 ); + } + if ( nCropLeft ) + { + fFactor = static_cast<double>(nCropLeft) / 65536.0; + nLeft = static_cast<sal_uInt32>( ( static_cast<double>( aCropSize.Width() + 1 ) * fFactor ) + 0.5 ); + } + if ( nCropRight ) + { + fFactor = static_cast<double>(nCropRight) / 65536.0; + nRight = static_cast<sal_uInt32>( ( static_cast<double>( aCropSize.Width() + 1 ) * fFactor ) + 0.5 ); + } + if ( pSet ) // use crop attributes ? + pSet->Put( SdrGrafCropItem( nLeft, nTop, nRight, nBottom ) ); + else + { + tools::Rectangle aCropRect( nLeft, nTop, aCropSize.Width() - nRight, aCropSize.Height() - nBottom ); + aCropBitmap.Crop( aCropRect ); + rGraf = aCropBitmap; } } @@ -5982,39 +5982,39 @@ void SvxMSDffManager::GetCtrlData(sal_uInt32 nOffsDggL) sal_uLong nPos = nOffsDggL + DFF_COMMON_RECORD_HEADER_SIZE; // case A: first Drawing Group Container, then n times Drawing Container - if( DFF_msofbtDggContainer == nFbt ) + if( DFF_msofbtDggContainer != nFbt ) + return; + + bool bOk; + GetDrawingGroupContainerData( rStCtrl, nLength ); + + sal_uInt32 nMaxStrPos = rStCtrl.TellEnd(); + + nPos += nLength; + sal_uInt16 nDrawingContainerId = 1; + do { - bool bOk; - GetDrawingGroupContainerData( rStCtrl, nLength ); + if (!checkSeek(rStCtrl, nPos)) + break; - sal_uInt32 nMaxStrPos = rStCtrl.TellEnd(); + bOk = ReadCommonRecordHeader( rStCtrl, nVer, nInst, nFbt, nLength ) && ( DFF_msofbtDgContainer == nFbt ); - nPos += nLength; - sal_uInt16 nDrawingContainerId = 1; - do + if( !bOk ) { - if (!checkSeek(rStCtrl, nPos)) + nPos++; // ????????? TODO: trying to get a one-hit wonder, this code should be rewritten... + if (nPos != rStCtrl.Seek(nPos)) break; - - bOk = ReadCommonRecordHeader( rStCtrl, nVer, nInst, nFbt, nLength ) && ( DFF_msofbtDgContainer == nFbt ); - - if( !bOk ) - { - nPos++; // ????????? TODO: trying to get a one-hit wonder, this code should be rewritten... - if (nPos != rStCtrl.Seek(nPos)) - break; - bOk = ReadCommonRecordHeader( rStCtrl, nVer, nInst, nFbt, nLength ) - && ( DFF_msofbtDgContainer == nFbt ); - } - if( bOk ) - { - GetDrawingContainerData( rStCtrl, nLength, nDrawingContainerId ); - } - nPos += DFF_COMMON_RECORD_HEADER_SIZE + nLength; - ++nDrawingContainerId; + bOk = ReadCommonRecordHeader( rStCtrl, nVer, nInst, nFbt, nLength ) + && ( DFF_msofbtDgContainer == nFbt ); + } + if( bOk ) + { + GetDrawingContainerData( rStCtrl, nLength, nDrawingContainerId ); } - while( ( rStCtrl.GetError() == ERRCODE_NONE ) && ( nPos < nMaxStrPos ) && bOk ); + nPos += DFF_COMMON_RECORD_HEADER_SIZE + nLength; + ++nDrawingContainerId; } + while( ( rStCtrl.GetError() == ERRCODE_NONE ) && ( nPos < nMaxStrPos ) && bOk ); } diff --git a/filter/source/msfilter/mstoolbar.cxx b/filter/source/msfilter/mstoolbar.cxx index e32181019602..8b792eb3b98d 100644 --- a/filter/source/msfilter/mstoolbar.cxx +++ b/filter/source/msfilter/mstoolbar.cxx @@ -475,33 +475,34 @@ TBCGeneralInfo::Print( FILE* fp ) void TBCGeneralInfo::ImportToolBarControlData( CustomToolBarImportHelper& helper, std::vector< beans::PropertyValue >& sControlData ) { - if ( bFlags & 0x5 ) - { - beans::PropertyValue aProp; - // probably access to the header would be a better test than seeing if there is an action, e.g. - // if ( rHeader.getTct() == 0x01 && rHeader.getTcID() == 0x01 ) // not defined, probably this is a command - if ( !extraInfo.getOnAction().isEmpty() ) - { - aProp.Name = "CommandURL"; - ooo::vba::MacroResolvedInfo aMacroInf = ooo::vba::resolveVBAMacro( &helper.GetDocShell(), extraInfo.getOnAction(), true ); - if ( aMacroInf.mbFound ) - aProp.Value = CustomToolBarImportHelper::createCommandFromMacro( aMacroInf.msResolvedMacro ); - else - aProp.Value <<= OUString( "UnResolvedMacro[" ).concat( extraInfo.getOnAction() ).concat( "]" ); - sControlData.push_back( aProp ); - } + if ( !(bFlags & 0x5) ) + return; - aProp.Name = "Label"; - aProp.Value <<= customText.getString().replace('&','~'); + beans::PropertyValue aProp; + // probably access to the header would be a better test than seeing if there is an action, e.g. + // if ( rHeader.getTct() == 0x01 && rHeader.getTcID() == 0x01 ) // not defined, probably this is a command + if ( !extraInfo.getOnAction().isEmpty() ) + { + aProp.Name = "CommandURL"; + ooo::vba::MacroResolvedInfo aMacroInf = ooo::vba::resolveVBAMacro( &helper.GetDocShell(), extraInfo.getOnAction(), true ); + if ( aMacroInf.mbFound ) + aProp.Value = CustomToolBarImportHelper::createCommandFromMacro( aMacroInf.msResolvedMacro ); + else + aProp.Value <<= OUString( "UnResolvedMacro[" ).concat( extraInfo.getOnAction() ).concat( "]" ); sControlData.push_back( aProp ); + } - aProp.Name = "Type"; - aProp.Value <<= ui::ItemType::DEFAULT; - sControlData.push_back( aProp ); + aProp.Name = "Label"; + aProp.Value <<= customText.getString().replace('&','~'); + sControlData.push_back( aProp ); - aProp.Name = "Tooltip"; - aProp.Value <<= tooltip.getString(); - sControlData.push_back( aProp ); + aProp.Name = "Type"; + aProp.Value <<= ui::ItemType::DEFAULT; + sControlData.push_back( aProp ); + + aProp.Name = "Tooltip"; + aProp.Value <<= tooltip.getString(); + sControlData.push_back( aProp ); /* aToolbarItem(0).Name = "CommandURL" wstrOnAction aToolbarItem(0).Value = Command @@ -512,7 +513,6 @@ aToolbarItem(2).Value = 0 aToolbarItem(3).Name = "Visible" aToolbarItem(3).Value = true */ - } } TBCMenuSpecific::TBCMenuSpecific() : tbid( 0 ) diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index be84fe5f4815..f4ee10034c50 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -593,101 +593,101 @@ void SdrEscherImport::ProcessClientAnchor2( SvStream& rSt, DffRecordHeader& rHd, void SdrEscherImport::RecolorGraphic( SvStream& rSt, sal_uInt32 nRecLen, Graphic& rGraphic ) { - if ( rGraphic.GetType() == GraphicType::GdiMetafile ) - { - sal_uInt16 nX, nGlobalColorsCount, nFillColorsCount; + if ( rGraphic.GetType() != GraphicType::GdiMetafile ) + return; - rSt.ReadUInt16( nX ) - .ReadUInt16( nGlobalColorsCount ) - .ReadUInt16( nFillColorsCount ) - .ReadUInt16( nX ) - .ReadUInt16( nX ) - .ReadUInt16( nX ); + sal_uInt16 nX, nGlobalColorsCount, nFillColorsCount; - if ( ( nGlobalColorsCount <= 64 ) && ( nFillColorsCount <= 64 ) ) - { - if ( static_cast<sal_uInt32>( ( nGlobalColorsCount + nFillColorsCount ) * 44 + 12 ) == nRecLen ) - { - sal_uInt32 OriginalGlobalColors[ 64 ]; - sal_uInt32 NewGlobalColors[ 64 ]; + rSt.ReadUInt16( nX ) + .ReadUInt16( nGlobalColorsCount ) + .ReadUInt16( nFillColorsCount ) + .ReadUInt16( nX ) + .ReadUInt16( nX ) + .ReadUInt16( nX ); + + if ( !(( nGlobalColorsCount <= 64 ) && ( nFillColorsCount <= 64 )) ) + return; + + if ( static_cast<sal_uInt32>( ( nGlobalColorsCount + nFillColorsCount ) * 44 + 12 ) != nRecLen ) + return; + + sal_uInt32 OriginalGlobalColors[ 64 ]; + sal_uInt32 NewGlobalColors[ 64 ]; - sal_uInt32 i, j, nGlobalColorsChanged, nFillColorsChanged; - nGlobalColorsChanged = nFillColorsChanged = 0; + sal_uInt32 i, j, nGlobalColorsChanged, nFillColorsChanged; + nGlobalColorsChanged = nFillColorsChanged = 0; - sal_uInt32* pCurrentOriginal = OriginalGlobalColors; - sal_uInt32* pCurrentNew = NewGlobalColors; - sal_uInt32* pCount = &nGlobalColorsChanged; - i = nGlobalColorsCount; + sal_uInt32* pCurrentOriginal = OriginalGlobalColors; + sal_uInt32* pCurrentNew = NewGlobalColors; + sal_uInt32* pCount = &nGlobalColorsChanged; + i = nGlobalColorsCount; - for ( j = 0; j < 2; j++ ) + for ( j = 0; j < 2; j++ ) + { + for ( ; i > 0; i-- ) + { + sal_uInt32 nIndex, nPos = rSt.Tell(); + sal_uInt8 nDummy, nRed, nGreen, nBlue; + sal_uInt16 nChanged; + rSt.ReadUInt16( nChanged ); + if ( nChanged & 1 ) + { + sal_uInt32 nColor = 0; + rSt.ReadUChar( nDummy ) + .ReadUChar( nRed ) + .ReadUChar( nDummy ) + .ReadUChar( nGreen ) + .ReadUChar( nDummy ) + .ReadUChar( nBlue ) + .ReadUInt32( nIndex ); + + if ( nIndex < 8 ) { - for ( ; i > 0; i-- ) - { - sal_uInt32 nIndex, nPos = rSt.Tell(); - sal_uInt8 nDummy, nRed, nGreen, nBlue; - sal_uInt16 nChanged; - rSt.ReadUInt16( nChanged ); - if ( nChanged & 1 ) - { - sal_uInt32 nColor = 0; - rSt.ReadUChar( nDummy ) - .ReadUChar( nRed ) - .ReadUChar( nDummy ) - .ReadUChar( nGreen ) - .ReadUChar( nDummy ) - .ReadUChar( nBlue ) - .ReadUInt32( nIndex ); - - if ( nIndex < 8 ) - { - Color aColor = MSO_CLR_ToColor( nIndex << 24 ); - nRed = aColor.GetRed(); - nGreen = aColor.GetGreen(); - nBlue = aColor.GetBlue(); - } - nColor = nRed | ( nGreen << 8 ) | ( nBlue << 16 ); - *pCurrentNew++ = nColor; - rSt.ReadUChar( nDummy ) - .ReadUChar( nRed ) - .ReadUChar( nDummy ) - .ReadUChar( nGreen ) - .ReadUChar( nDummy ) - .ReadUChar( nBlue ); - nColor = nRed | ( nGreen << 8 ) | ( nBlue << 16 ); - *pCurrentOriginal++ = nColor; - (*pCount)++; - } - rSt.Seek( nPos + 44 ); - } - pCount = &nFillColorsChanged; - i = nFillColorsCount; + Color aColor = MSO_CLR_ToColor( nIndex << 24 ); + nRed = aColor.GetRed(); + nGreen = aColor.GetGreen(); + nBlue = aColor.GetBlue(); } - if ( nGlobalColorsChanged || nFillColorsChanged ) - { - std::unique_ptr<Color[]> pSearchColors(new Color[ nGlobalColorsChanged ]); - std::unique_ptr<Color[]> pReplaceColors(new Color[ nGlobalColorsChanged ]); + nColor = nRed | ( nGreen << 8 ) | ( nBlue << 16 ); + *pCurrentNew++ = nColor; + rSt.ReadUChar( nDummy ) + .ReadUChar( nRed ) + .ReadUChar( nDummy ) + .ReadUChar( nGreen ) + .ReadUChar( nDummy ) + .ReadUChar( nBlue ); + nColor = nRed | ( nGreen << 8 ) | ( nBlue << 16 ); + *pCurrentOriginal++ = nColor; + (*pCount)++; + } + rSt.Seek( nPos + 44 ); + } + pCount = &nFillColorsChanged; + i = nFillColorsCount; + } + if ( !(nGlobalColorsChanged || nFillColorsChanged) ) + return; - for ( j = 0; j < nGlobalColorsChanged; j++ ) - { - sal_uInt32 nSearch = OriginalGlobalColors[ j ]; - sal_uInt32 nReplace = NewGlobalColors[ j ]; + std::unique_ptr<Color[]> pSearchColors(new Color[ nGlobalColorsChanged ]); + std::unique_ptr<Color[]> pReplaceColors(new Color[ nGlobalColorsChanged ]); - pSearchColors[ j ].SetRed( static_cast<sal_uInt8>(nSearch) ); - pSearchColors[ j ].SetGreen( static_cast<sal_uInt8>( nSearch >> 8 ) ); - pSearchColors[ j ].SetBlue( static_cast<sal_uInt8>( nSearch >> 16 ) ); + for ( j = 0; j < nGlobalColorsChanged; j++ ) + { + sal_uInt32 nSearch = OriginalGlobalColors[ j ]; + sal_uInt32 nReplace = NewGlobalColors[ j ]; - pReplaceColors[ j ].SetRed( static_cast<sal_uInt8>(nReplace) ); - pReplaceColors[ j ].SetGreen( static_cast<sal_uInt8>( nReplace >> 8 ) ); - pReplaceColors[ j ].SetBlue( static_cast<sal_uInt8>( nReplace >> 16 ) ); - } - GDIMetaFile aGdiMetaFile( rGraphic.GetGDIMetaFile() ); - aGdiMetaFile.ReplaceColors( pSearchColors.get(), pReplaceColors.get(), - nGlobalColorsChanged ); - rGraphic = aGdiMetaFile; - } - } - } + pSearchColors[ j ].SetRed( static_cast<sal_uInt8>(nSearch) ); + pSearchColors[ j ].SetGreen( static_cast<sal_uInt8>( nSearch >> 8 ) ); + pSearchColors[ j ].SetBlue( static_cast<sal_uInt8>( nSearch >> 16 ) ); + + pReplaceColors[ j ].SetRed( static_cast<sal_uInt8>(nReplace) ); + pReplaceColors[ j ].SetGreen( static_cast<sal_uInt8>( nReplace >> 8 ) ); + pReplaceColors[ j ].SetBlue( static_cast<sal_uInt8>( nReplace >> 16 ) ); } + GDIMetaFile aGdiMetaFile( rGraphic.GetGDIMetaFile() ); + aGdiMetaFile.ReplaceColors( pSearchColors.get(), pReplaceColors.get(), + nGlobalColorsChanged ); + rGraphic = aGdiMetaFile; } sal_uLong DffPropSet::SanitizeEndPos(SvStream &rIn, sal_uLong nEndRecPos) @@ -1723,36 +1723,36 @@ bool PPTConvertOCXControls::InsertControl( }; void PPTConvertOCXControls::GetDrawPage() { - if( !xDrawPage.is() && mxModel.is() ) + if( !(!xDrawPage.is() && mxModel.is()) ) + return; + + css::uno::Reference< css::drawing::XDrawPages > xDrawPages; + switch( ePageKind ) { - css::uno::Reference< css::drawing::XDrawPages > xDrawPages; - switch( ePageKind ) + case PPT_SLIDEPAGE : + case PPT_NOTEPAGE : { - case PPT_SLIDEPAGE : - case PPT_NOTEPAGE : - { - css::uno::Reference< css::drawing::XDrawPagesSupplier > - xDrawPagesSupplier( mxModel, css::uno::UNO_QUERY); - if ( xDrawPagesSupplier.is() ) - xDrawPages = xDrawPagesSupplier->getDrawPages(); - } - break; - - case PPT_MASTERPAGE : - { - css::uno::Reference< css::drawing::XMasterPagesSupplier > - xMasterPagesSupplier( mxModel, css::uno::UNO_QUERY); - if ( xMasterPagesSupplier.is() ) - xDrawPages = xMasterPagesSupplier->getMasterPages(); - } - break; + css::uno::Reference< css::drawing::XDrawPagesSupplier > + xDrawPagesSupplier( mxModel, css::uno::UNO_QUERY); + if ( xDrawPagesSupplier.is() ) + xDrawPages = xDrawPagesSupplier->getDrawPages(); } - if ( xDrawPages.is() && xDrawPages->getCount() ) + break; + + case PPT_MASTERPAGE : { - xDrawPages->getCount(); - css::uno::Any aAny( xDrawPages->getByIndex( xDrawPages->getCount() - 1 ) ); - aAny >>= xDrawPage; + css::uno::Reference< css::drawing::XMasterPagesSupplier > + xMasterPagesSupplier( mxModel, css::uno::UNO_QUERY); + if ( xMasterPagesSupplier.is() ) + xDrawPages = xMasterPagesSupplier->getMasterPages(); } + break; + } + if ( xDrawPages.is() && xDrawPages->getCount() ) + { + xDrawPages->getCount(); + css::uno::Any aAny( xDrawPages->getByIndex( xDrawPages->getCount() - 1 ) ); + aAny >>= xDrawPage; } } @@ -1994,92 +1994,92 @@ std::unique_ptr<SvMemoryStream> SdrPowerPointImport::ImportExOleObjStg( sal_uInt void SdrPowerPointImport::SeekOle( SfxObjectShell* pShell, sal_uInt32 nFilterOptions ) { - if ( pShell ) - { - DffRecordHeader* pHd; + if ( !pShell ) + return; + + DffRecordHeader* pHd; - sal_uInt32 nOldPos = rStCtrl.Tell(); - if ( nFilterOptions & 1 ) + sal_uInt32 nOldPos = rStCtrl.Tell(); + if ( nFilterOptions & 1 ) + { + pHd = aDocRecManager.GetRecordHeader( PPT_PST_List ); + if ( pHd ) { - pHd = aDocRecManager.GetRecordHeader( PPT_PST_List ); - if ( pHd ) + // we try to locate the basic atom + pHd->SeekToContent( rStCtrl ); + if ( SeekToRec( rStCtrl, PPT_PST_VBAInfo, pHd->GetRecEndFilePos(), pHd ) ) { - // we try to locate the basic atom - pHd->SeekToContent( rStCtrl ); - if ( SeekToRec( rStCtrl, PPT_PST_VBAInfo, pHd->GetRecEndFilePos(), pHd ) ) + if ( SeekToRec( rStCtrl, PPT_PST_VBAInfoAtom, pHd->GetRecEndFilePos(), pHd ) ) { - if ( SeekToRec( rStCtrl, PPT_PST_VBAInfoAtom, pHd->GetRecEndFilePos(), pHd ) ) + sal_uInt32 nPersistPtr, nIDoNotKnow1, nIDoNotKnow2; + rStCtrl.ReadUInt32( nPersistPtr ) + .ReadUInt32( nIDoNotKnow1 ) + .ReadUInt32( nIDoNotKnow2 ); + + sal_uInt32 nOleId; + std::unique_ptr<SvMemoryStream> pBas = ImportExOleObjStg( nPersistPtr, nOleId ); + if ( pBas ) { - sal_uInt32 nPersistPtr, nIDoNotKnow1, nIDoNotKnow2; - rStCtrl.ReadUInt32( nPersistPtr ) - .ReadUInt32( nIDoNotKnow1 ) - .ReadUInt32( nIDoNotKnow2 ); - - sal_uInt32 nOleId; - std::unique_ptr<SvMemoryStream> pBas = ImportExOleObjStg( nPersistPtr, nOleId ); - if ( pBas ) + tools::SvRef<SotStorage> xSource( new SotStorage( pBas.release(), true ) ); + tools::SvRef<SotStorage> xDest( new SotStorage( new SvMemoryStream(), true ) ); + if ( xSource.is() && xDest.is() ) { - tools::SvRef<SotStorage> xSource( new SotStorage( pBas.release(), true ) ); - tools::SvRef<SotStorage> xDest( new SotStorage( new SvMemoryStream(), true ) ); - if ( xSource.is() && xDest.is() ) + // is this a visual basic storage ? + tools::SvRef<SotStorage> xSubStorage = xSource->OpenSotStorage( "VBA", + StreamMode::READWRITE | StreamMode::NOCREATE | StreamMode::SHARE_DENYALL ); + if( xSubStorage.is() && ( ERRCODE_NONE == xSubStorage->GetError() ) ) { - // is this a visual basic storage ? - tools::SvRef<SotStorage> xSubStorage = xSource->OpenSotStorage( "VBA", - StreamMode::READWRITE | StreamMode::NOCREATE | StreamMode::SHARE_DENYALL ); - if( xSubStorage.is() && ( ERRCODE_NONE == xSubStorage->GetError() ) ) + tools::SvRef<SotStorage> xMacros = xDest->OpenSotStorage( "MACROS" ); + if ( xMacros.is() ) { - tools::SvRef<SotStorage> xMacros = xDest->OpenSotStorage( "MACROS" ); - if ( xMacros.is() ) - { - SvStorageInfoList aList; - xSource->FillInfoList( &aList ); - SvStorageInfoList::size_type i; + SvStorageInfoList aList; + xSource->FillInfoList( &aList ); + SvStorageInfoList::size_type i; - bool bCopied = true; - for ( i = 0; i < aList.size(); i++ ) // copy all entries - { - const SvStorageInfo& rInfo = aList[ i ]; - if ( !xSource->CopyTo( rInfo.GetName(), xMacros.get(), rInfo.GetName() ) ) - bCopied = false; - } - if ( i && bCopied ) + bool bCopied = true; + for ( i = 0; i < aList.size(); i++ ) // copy all entries + { + const SvStorageInfo& rInfo = aList[ i ]; + if ( !xSource->CopyTo( rInfo.GetName(), xMacros.get(), rInfo.GetName() ) ) + bCopied = false; + } + if ( i && bCopied ) + { + uno::Reference < embed::XStorage > xDoc( pShell->GetStorage() ); + if ( xDoc.is() ) { - uno::Reference < embed::XStorage > xDoc( pShell->GetStorage() ); - if ( xDoc.is() ) + tools::SvRef<SotStorage> xVBA = SotStorage::OpenOLEStorage( xDoc, SvxImportMSVBasic::GetMSBasicStorageName() ); + if ( xVBA.is() && ( xVBA->GetError() == ERRCODE_NONE ) ) { - tools::SvRef<SotStorage> xVBA = SotStorage::OpenOLEStorage( xDoc, SvxImportMSVBasic::GetMSBasicStorageName() ); - if ( xVBA.is() && ( xVBA->GetError() == ERRCODE_NONE ) ) + tools::SvRef<SotStorage> xSubVBA = xVBA->OpenSotStorage( "_MS_VBA_Overhead" ); + if ( xSubVBA.is() && ( xSubVBA->GetError() == ERRCODE_NONE ) ) { - tools::SvRef<SotStorage> xSubVBA = xVBA->OpenSotStorage( "_MS_VBA_Overhead" ); - if ( xSubVBA.is() && ( xSubVBA->GetError() == ERRCODE_NONE ) ) + tools::SvRef<SotStorageStream> xOriginal = xSubVBA->OpenSotStream( "_MS_VBA_Overhead2" ); + if ( xOriginal.is() && ( xOriginal->GetError() == ERRCODE_NONE ) ) { - tools::SvRef<SotStorageStream> xOriginal = xSubVBA->OpenSotStream( "_MS_VBA_Overhead2" ); - if ( xOriginal.is() && ( xOriginal->GetError() == ERRCODE_NONE ) ) + if ( nPersistPtr && ( nPersistPtr < m_nPersistPtrCnt ) ) { - if ( nPersistPtr && ( nPersistPtr < m_nPersistPtrCnt ) ) + rStCtrl.Seek( m_pPersistPtr[ nPersistPtr ] ); + ReadDffRecordHeader( rStCtrl, *pHd ); + + xOriginal->WriteUInt32( nIDoNotKnow1 ) + .WriteUInt32( nIDoNotKnow2 ); + + sal_uInt32 nToCopy, nBufSize; + nToCopy = pHd->nRecLen; + std::unique_ptr<sal_uInt8[]> pBuf(new sal_uInt8[ 0x40000 ]); // 256KB Buffer + while ( nToCopy ) { - rStCtrl.Seek( m_pPersistPtr[ nPersistPtr ] ); - ReadDffRecordHeader( rStCtrl, *pHd ); - - xOriginal->WriteUInt32( nIDoNotKnow1 ) - .WriteUInt32( nIDoNotKnow2 ); - - sal_uInt32 nToCopy, nBufSize; - nToCopy = pHd->nRecLen; - std::unique_ptr<sal_uInt8[]> pBuf(new sal_uInt8[ 0x40000 ]); // 256KB Buffer - while ( nToCopy ) - { - nBufSize = ( nToCopy >= 0x40000 ) ? 0x40000 : nToCopy; - rStCtrl.ReadBytes(pBuf.get(), nBufSize); - xOriginal->WriteBytes(pBuf.get(), nBufSize); - nToCopy -= nBufSize; - } + nBufSize = ( nToCopy >= 0x40000 ) ? 0x40000 : nToCopy; + rStCtrl.ReadBytes(pBuf.get(), nBufSize); + xOriginal->WriteBytes(pBuf.get(), nBufSize); + nToCopy -= nBufSize; } } } } - xVBA->Commit(); } + xVBA->Commit(); } } } @@ -2089,52 +2089,52 @@ void SdrPowerPointImport::SeekOle( SfxObjectShell* pShell, sal_uInt32 nFilterOpt } } } - pHd = aDocRecManager.GetRecordHeader( PPT_PST_ExObjList ); - if ( pHd ) - { - DffRecordHeader* pExEmbed = nullptr; + } + pHd = aDocRecManager.GetRecordHeader( PPT_PST_ExObjList ); + if ( pHd ) + { + DffRecordHeader* pExEmbed = nullptr; - pHd->SeekToBegOfRecord( rStCtrl ); - std::unique_ptr<DffRecordManager> pExObjListManager(new DffRecordManager( rStCtrl )); - sal_uInt16 i, nRecType(PPT_PST_ExEmbed); + pHd->SeekToBegOfRecord( rStCtrl ); + std::unique_ptr<DffRecordManager> pExObjListManager(new DffRecordManager( rStCtrl )); + sal_uInt16 i, nRecType(PPT_PST_ExEmbed); - for ( i = 0; i < 2; i++ ) + for ( i = 0; i < 2; i++ ) + { + switch ( i ) { - switch ( i ) - { - case 0 : nRecType = PPT_PST_ExEmbed; break; - case 1 : nRecType = PPT_PST_ExControl; break; - } - for ( pExEmbed = pExObjListManager->GetRecordHeader( nRecType ); - pExEmbed; pExEmbed = pExObjListManager->GetRecordHeader( nRecType, SEEK_FROM_CURRENT ) ) + case 0 : nRecType = PPT_PST_ExEmbed; break; + case 1 : nRecType = PPT_PST_ExControl; break; + } + for ( pExEmbed = pExObjListManager->GetRecordHeader( nRecType ); + pExEmbed; pExEmbed = pExObjListManager->GetRecordHeader( nRecType, SEEK_FROM_CURRENT ) ) + { + pExEmbed->SeekToContent( rStCtrl ); + + DffRecordHeader aExOleAtHd; + if ( SeekToRec( rStCtrl, PPT_PST_ExOleObjAtom, pExEmbed->GetRecEndFilePos(), &aExOleAtHd ) ) { - pExEmbed->SeekToContent( rStCtrl ); + PptExOleObjAtom aAt; + ReadPptExOleObjAtom( rStCtrl, aAt ); - DffRecordHeader aExOleAtHd; - if ( SeekToRec( rStCtrl, PPT_PST_ExOleObjAtom, pExEmbed->GetRecEndFilePos(), &aExOleAtHd ) ) + if ( aAt.nPersistPtr && ( aAt.nPersistPtr < m_nPersistPtrCnt ) ) { - PptExOleObjAtom aAt; - ReadPptExOleObjAtom( rStCtrl, aAt ); - - if ( aAt.nPersistPtr && ( aAt.nPersistPtr < m_nPersistPtrCnt ) ) + sal_uInt32 nId; + rStCtrl.Seek( m_pPersistPtr[ aAt.nPersistPtr ] ); + DffRecordHeader aHd; + ReadDffRecordHeader( rStCtrl, aHd ); + if ( aHd.nRecType == DFF_PST_ExOleObjStg ) { - sal_uInt32 nId; - rStCtrl.Seek( m_pPersistPtr[ aAt.nPersistPtr ] ); - DffRecordHeader aHd; - ReadDffRecordHeader( rStCtrl, aHd ); - if ( aHd.nRecType == DFF_PST_ExOleObjStg ) - { - rStCtrl.ReadUInt32( nId ); - aOleObjectList.emplace_back( - aAt.nId, aHd.nFilePos, pShell, nRecType, aAt.nAspect ); - } + rStCtrl.ReadUInt32( nId ); + aOleObjectList.emplace_back( + aAt.nId, aHd.nFilePos, pShell, nRecType, aAt.nAspect ); } } } } } - rStCtrl.Seek( nOldPos ); } + rStCtrl.Seek( nOldPos ); } bool SdrPowerPointImport::ReadFontCollection() @@ -4534,80 +4534,80 @@ PPTTextRulerInterpreter::PPTTextRulerInterpreter( PPTTextRulerInterpreter const PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs, DffRecordHeader const & rHeader, SvStream& rIn ) : mxImplRuler ( new PPTRuler() ) { - if ( nFileOfs != 0xffffffff ) + if ( nFileOfs == 0xffffffff ) + return; + + sal_uInt32 nOldPos = rIn.Tell(); + DffRecordHeader rHd; + if ( nFileOfs ) { - sal_uInt32 nOldPos = rIn.Tell(); - DffRecordHeader rHd; - if ( nFileOfs ) - { - rIn.Seek( nFileOfs ); - ReadDffRecordHeader( rIn, rHd ); - } - else - { - rHeader.SeekToContent( rIn ); - if ( SvxMSDffManager::SeekToRec( rIn, PPT_PST_TextRulerAtom, rHeader.GetRecEndFilePos(), &rHd ) ) - nFileOfs++; - } - if ( nFileOfs ) - { - bool bRecordOk = true; + rIn.Seek( nFileOfs ); + ReadDffRecordHeader( rIn, rHd ); + } + else + { + rHeader.SeekToContent( rIn ); + if ( SvxMSDffManager::SeekToRec( rIn, PPT_PST_TextRulerAtom, rHeader.GetRecEndFilePos(), &rHd ) ) + nFileOfs++; + } + if ( nFileOfs ) + { + bool bRecordOk = true; - sal_Int16 nTCount(0); - sal_Int32 i; - rIn.ReadInt32( mxImplRuler->nFlags ); + sal_Int16 nTCount(0); + sal_Int32 i; + rIn.ReadInt32( mxImplRuler->nFlags ); - // number of indent levels, unused now - if ( mxImplRuler->nFlags & 2 ) - rIn.ReadInt16( nTCount ); - if ( mxImplRuler->nFlags & 1 ) - rIn.ReadUInt16( mxImplRuler->nDefaultTab ); - if ( mxImplRuler->nFlags & 4 ) - { - rIn.ReadInt16(nTCount); + // number of indent levels, unused now + if ( mxImplRuler->nFlags & 2 ) + rIn.ReadInt16( nTCount ); + if ( mxImplRuler->nFlags & 1 ) + rIn.ReadUInt16( mxImplRuler->nDefaultTab ); + if ( mxImplRuler->nFlags & 4 ) + { + rIn.ReadInt16(nTCount); - const size_t nMaxPossibleRecords = rIn.remainingSize() / (2*sizeof(sal_uInt16)); - const sal_uInt16 nTabCount(nTCount); + const size_t nMaxPossibleRecords = rIn.remainingSize() / (2*sizeof(sal_uInt16)); + const sal_uInt16 nTabCount(nTCount); - bRecordOk = nTabCount <= nMaxPossibleRecords; + bRecordOk = nTabCount <= nMaxPossibleRecords; - if (nTCount && bRecordOk) + if (nTCount && bRecordOk) + { + mxImplRuler->nTabCount = nTabCount; + mxImplRuler->pTab.reset( new PPTTabEntry[ mxImplRuler->nTabCount ] ); + for ( i = 0; i < nTCount; i++ ) { - mxImplRuler->nTabCount = nTabCount; - mxImplRuler->pTab.reset( new PPTTabEntry[ mxImplRuler->nTabCount ] ); - for ( i = 0; i < nTCount; i++ ) - { - rIn.ReadUInt16( mxImplRuler->pTab[ i ].nOffset ) - .ReadUInt16( mxImplRuler->pTab[ i ].nStyle ); - } + rIn.ReadUInt16( mxImplRuler->pTab[ i ].nOffset ) + .ReadUInt16( mxImplRuler->pTab[ i ].nStyle ); } } + } - if (bRecordOk) + if (bRecordOk) + { + for ( i = 0; i < 5; i++ ) { - for ( i = 0; i < 5; i++ ) + if ( mxImplRuler->nFlags & ( 8 << i ) ) + rIn.ReadUInt16( mxImplRuler->nTextOfs[ i ] ); + if ( mxImplRuler->nFlags & ( 256 << i ) ) + rIn.ReadUInt16( mxImplRuler->nBulletOfs[ i ] ); + if( mxImplRuler->nBulletOfs[ i ] > 0x7fff) { - if ( mxImplRuler->nFlags & ( 8 << i ) ) - rIn.ReadUInt16( mxImplRuler->nTextOfs[ i ] ); - if ( mxImplRuler->nFlags & ( 256 << i ) ) - rIn.ReadUInt16( mxImplRuler->nBulletOfs[ i ] ); - if( mxImplRuler->nBulletOfs[ i ] > 0x7fff) - { - // workaround - // when bullet offset is > 0x7fff, the paragraph should look like - // * first line text - // second line text - - // we add to bullet para indent 0xffff - bullet offset. It looks like - // best we can do for now - mxImplRuler->nTextOfs[ i ] += 0xffff - mxImplRuler->nBulletOfs[ i ]; - mxImplRuler->nBulletOfs[ i ] = 0; - } + // workaround + // when bullet offset is > 0x7fff, the paragraph should look like + // * first line text + // second line text + + // we add to bullet para indent 0xffff - bullet offset. It looks like + // best we can do for now + mxImplRuler->nTextOfs[ i ] += 0xffff - mxImplRuler->nBulletOfs[ i ]; + mxImplRuler->nBulletOfs[ i ] = 0; } } } - rIn.Seek( nOldPos ); } + rIn.Seek( nOldPos ); } bool PPTTextRulerInterpreter::GetDefaultTab( sal_uInt16& nValue ) const @@ -5159,18 +5159,18 @@ void PPTStyleTextPropReader::ReadCharProps( SvStream& rIn, PPTCharPropSet& aChar rIn.ReadUInt16( aSet.mnEscapement ); aSet.mnAttrSet |= 1 << PPT_CharAttr_Escapement; } - if ( nExtParaPos ) + if ( !nExtParaPos ) + return; + + sal_uInt32 nExtBuInd = nMask & 0x3c00; + if ( nExtBuInd ) + nExtBuInd = ( aSet.mnFlags & 0x3c00 ) >> 10; + if ( nExtBuInd < aStyleTextProp9.size() ) { - sal_uInt32 nExtBuInd = nMask & 0x3c00; - if ( nExtBuInd ) - nExtBuInd = ( aSet.mnFlags & 0x3c00 ) >> 10; - if ( nExtBuInd < aStyleTextProp9.size() ) - { - nExtParaFlags = aStyleTextProp9[ nExtBuInd ].mnExtParagraphMask; - nBuBlip = aStyleTextProp9[ nExtBuInd ].mnBuBlip; - nHasAnm = aStyleTextProp9[ nExtBuInd ].mnHasAnm; - nAnmScheme = aStyleTextProp9[ nExtBuInd ].mnAnmScheme; - } + nExtParaFlags = aStyleTextProp9[ nExtBuInd ].mnExtParagraphMask; + nBuBlip = aStyleTextProp9[ nExtBuInd ].mnBuBlip; + nHasAnm = aStyleTextProp9[ nExtBuInd ].mnHasAnm; + nAnmScheme = aStyleTextProp9[ nExtBuInd ].mnAnmScheme; } } @@ -5833,24 +5833,24 @@ PPTParagraphObj::PPTParagraphObj( PPTStyleTextPropReader& rPropReader, mbTab ( false ), mnCurrentObject ( 0 ) { - if (rnCurCharPos < rPropReader.aCharPropList.size()) + if (rnCurCharPos >= rPropReader.aCharPropList.size()) + return; + + sal_uInt32 const nCurrentParagraph = + rPropReader.aCharPropList[rnCurCharPos]->mnParagraph; + for (; rnCurCharPos < rPropReader.aCharPropList.size() && + rPropReader.aCharPropList[rnCurCharPos]->mnParagraph == nCurrentParagraph; + ++rnCurCharPos) { - sal_uInt32 const nCurrentParagraph = - rPropReader.aCharPropList[rnCurCharPos]->mnParagraph; - for (; rnCurCharPos < rPropReader.aCharPropList.size() && - rPropReader.aCharPropList[rnCurCharPos]->mnParagraph == nCurrentParagraph; - ++rnCurCharPos) + PPTCharPropSet *const pCharPropSet = + rPropReader.aCharPropList[rnCurCharPos].get(); + std::unique_ptr<PPTPortionObj> pPPTPortion(new PPTPortionObj( + *pCharPropSet, rStyleSheet, nInstance, mxParaSet->mnDepth)); + if (!mbTab) { - PPTCharPropSet *const pCharPropSet = - rPropReader.aCharPropList[rnCurCharPos].get(); - std::unique_ptr<PPTPortionObj> pPPTPortion(new PPTPortionObj( - *pCharPropSet, rStyleSheet, nInstance, mxParaSet->mnDepth)); - if (!mbTab) - { - mbTab = pPPTPortion->HasTabulator(); - } - m_PortionList.push_back(std::move(pPPTPortion)); + mbTab = pPPTPortion->HasTabulator(); } + m_PortionList.push_back(std::move(pPPTPortion)); } } @@ -5870,24 +5870,24 @@ void PPTParagraphObj::AppendPortion( PPTPortionObj& rPPTPortion ) void PPTParagraphObj::UpdateBulletRelSize( sal_uInt32& nBulletRelSize ) const { - if ( nBulletRelSize > 0x7fff ) // a negative value is the absolute bullet height + if ( nBulletRelSize <= 0x7fff ) // a negative value is the absolute bullet height + return; + + sal_uInt16 nFontHeight = 0; + if (!m_PortionList.empty()) { - sal_uInt16 nFontHeight = 0; - if (!m_PortionList.empty()) + PPTPortionObj const& rPortion = *m_PortionList.front(); + if (rPortion.mpImplPPTCharPropSet->mnAttrSet & (1 << PPT_CharAttr_FontHeight)) { - PPTPortionObj const& rPortion = *m_PortionList.front(); - if (rPortion.mpImplPPTCharPropSet->mnAttrSet & (1 << PPT_CharAttr_FontHeight)) - { - nFontHeight = rPortion.mpImplPPTCharPropSet->mnFontHeight; - } + nFontHeight = rPortion.mpImplPPTCharPropSet->mnFontHeight; } - // if we do not have a hard attributed fontheight, the fontheight is taken from the style - if ( !nFontHeight ) - { - nFontHeight = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[sanitizeForMaxPPTLevels(mxParaSet->mnDepth)].mnFontHeight; - } - nBulletRelSize = nFontHeight ? ((- static_cast<sal_Int16>(nBulletRelSize)) * 100 ) / nFontHeight : 100; } + // if we do not have a hard attributed fontheight, the fontheight is taken from the style + if ( !nFontHeight ) + { + nFontHeight = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[sanitizeForMaxPPTLevels(mxParaSet->mnDepth)].mnFontHeight; + } + nBulletRelSize = nFontHeight ? ((- static_cast<sal_Int16>(nBulletRelSize)) * 100 ) / nFontHeight : 100; } bool PPTParagraphObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& rRetValue, TSS_Type nDestinationInstance ) @@ -6310,50 +6310,50 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet, std::optional< sal_Int16 >& rS rSet.Put( aULSpaceItem ); } - if ( mbTab ) // makes it sense to apply tabsettings + if ( !mbTab ) // makes it sense to apply tabsettings + return; + + sal_uInt32 i, nDefaultTab, nTab, nTextOfs2 = 0; + sal_uInt32 nLatestManTab = 0; + GetAttrib( PPT_ParaAttr_TextOfs, nTextOfs2, nDestinationInstance ); + GetAttrib( PPT_ParaAttr_BulletOfs, nTab, nDestinationInstance ); + GetAttrib( PPT_ParaAttr_BulletOn, i, nDestinationInstance ); + GetAttrib( PPT_ParaAttr_DefaultTab, nDefaultTab, nDestinationInstance ); + SvxTabStopItem aTabItem( 0, 0, SvxTabAdjust::Default, EE_PARA_TABS ); + if ( GetTabCount() ) { - sal_uInt32 i, nDefaultTab, nTab, nTextOfs2 = 0; - sal_uInt32 nLatestManTab = 0; - GetAttrib( PPT_ParaAttr_TextOfs, nTextOfs2, nDestinationInstance ); - GetAttrib( PPT_ParaAttr_BulletOfs, nTab, nDestinationInstance ); - GetAttrib( PPT_ParaAttr_BulletOn, i, nDestinationInstance ); - GetAttrib( PPT_ParaAttr_DefaultTab, nDefaultTab, nDestinationInstance ); - SvxTabStopItem aTabItem( 0, 0, SvxTabAdjust::Default, EE_PARA_TABS ); - if ( GetTabCount() ) + //paragraph offset = MIN(first_line_offset, hanging_offset) + sal_uInt32 nParaOffset = std::min(nTextOfs2, nTab); + for ( i = 0; i < GetTabCount(); i++ ) { - //paragraph offset = MIN(first_line_offset, hanging_offset) - sal_uInt32 nParaOffset = std::min(nTextOfs2, nTab); - for ( i = 0; i < GetTabCount(); i++ ) + SvxTabAdjust eTabAdjust; + nTab = GetTabOffsetByIndex( static_cast<sal_uInt16>(i) ); + switch( GetTabStyleByIndex( static_cast<sal_uInt16>(i) ) ) { - SvxTabAdjust eTabAdjust; - nTab = GetTabOffsetByIndex( static_cast<sal_uInt16>(i) ); - switch( GetTabStyleByIndex( static_cast<sal_uInt16>(i) ) ) - { - case 1 : eTabAdjust = SvxTabAdjust::Center; break; - case 2 : eTabAdjust = SvxTabAdjust::Right; break; - case 3 : eTabAdjust = SvxTabAdjust::Decimal; break; - default : eTabAdjust = SvxTabAdjust::Left; - } - if ( nTab > nParaOffset )//If tab stop greater than paragraph offset - aTabItem.Insert( SvxTabStop( ( ( (long( nTab - nTextOfs2 )) * 2540 ) / 576 ), eTabAdjust ) ); + case 1 : eTabAdjust = SvxTabAdjust::Center; break; + case 2 : eTabAdjust = SvxTabAdjust::Right; break; + case 3 : eTabAdjust = SvxTabAdjust::Decimal; break; + default : eTabAdjust = SvxTabAdjust::Left; } - nLatestManTab = nTab; + if ( nTab > nParaOffset )//If tab stop greater than paragraph offset + aTabItem.Insert( SvxTabStop( ( ( (long( nTab - nTextOfs2 )) * 2540 ) / 576 ), eTabAdjust ) ); } - if ( nIsBullet2 == 0 ) - aTabItem.Insert( SvxTabStop( sal_uInt16(0) ) ); - if ( nDefaultTab ) + nLatestManTab = nTab; + } + if ( nIsBullet2 == 0 ) + aTabItem.Insert( SvxTabStop( sal_uInt16(0) ) ); + if ( nDefaultTab ) + { + nTab = std::max( nTextOfs2, nLatestManTab ); + nTab /= nDefaultTab; + nTab = nDefaultTab * ( 1 + nTab ); + for ( i = 0; ( i < 20 ) && ( nTab < 0x1b00 ); i++ ) { - nTab = std::max( nTextOfs2, nLatestManTab ); - nTab /= nDefaultTab; - nTab = nDefaultTab * ( 1 + nTab ); - for ( i = 0; ( i < 20 ) && ( nTab < 0x1b00 ); i++ ) - { - aTabItem.Insert( SvxTabStop( static_cast<sal_uInt16>( ( ( nTab - nTextOfs2 ) * 2540 ) / 576 ) ) ); - nTab += nDefaultTab; - } + aTabItem.Insert( SvxTabStop( static_cast<sal_uInt16>( ( ( nTab - nTextOfs2 ) * 2540 ) / 576 ) ) ); + nTab += nDefaultTab; } - rSet.Put( aTabItem ); } + rSet.Put( aTabItem ); } sal_uInt32 PPTParagraphObj::GetTextSize() @@ -6469,624 +6469,624 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport DffRecordHeader aShapeContainerHd; ReadDffRecordHeader( rIn, aShapeContainerHd ); - if ( ( pObjData == nullptr ) || ( pObjData->bShapeType ) ) + if ( !(( pObjData == nullptr ) || ( pObjData->bShapeType )) ) + return; + + PPTExtParaProv* pExtParaProv = rSdrPowerPointImport.m_pPPTStyleSheet->pExtParaProv.get(); + if ( pObjData ) { - PPTExtParaProv* pExtParaProv = rSdrPowerPointImport.m_pPPTStyleSheet->pExtParaProv.get(); - if ( pObjData ) + mxImplTextObj->mnShapeId = pObjData->nShapeId; + if ( pObjData->nSpFlags & ShapeFlag::HaveMaster ) + mxImplTextObj->mnShapeMaster = rSdrPowerPointImport.GetPropertyValue( DFF_Prop_hspMaster, 0 ); + } + // ClientData + if ( rSdrPowerPointImport.maShapeRecords.SeekToContent( rIn, DFF_msofbtClientData, SEEK_FROM_CURRENT_AND_RESTART ) ) + { + sal_uInt32 nOldPos = rIn.Tell(); + DffRecordHeader& aClientDataContainerHd = *rSdrPowerPointImport.maShapeRecords.Current(); + DffRecordHeader aPlaceHolderAtomHd; + if ( SvxMSDffManager::SeekToRec( rIn, PPT_PST_OEPlaceholderAtom, aClientDataContainerHd.GetRecEndFilePos(), &aPlaceHolderAtomHd ) ) { - mxImplTextObj->mnShapeId = pObjData->nShapeId; - if ( pObjData->nSpFlags & ShapeFlag::HaveMaster ) - mxImplTextObj->mnShapeMaster = rSdrPowerPointImport.GetPropertyValue( DFF_Prop_hspMaster, 0 ); + mxImplTextObj->mpPlaceHolderAtom.reset( new PptOEPlaceholderAtom ); + ReadPptOEPlaceholderAtom( rIn, *( mxImplTextObj->mpPlaceHolderAtom ) ); } - // ClientData - if ( rSdrPowerPointImport.maShapeRecords.SeekToContent( rIn, DFF_msofbtClientData, SEEK_FROM_CURRENT_AND_RESTART ) ) + rIn.Seek( nOldPos ); + DffRecordHeader aProgTagHd; + if ( SdrPowerPointImport::SeekToContentOfProgTag( 9, rIn, aClientDataContainerHd, aProgTagHd ) ) { - sal_uInt32 nOldPos = rIn.Tell(); - DffRecordHeader& aClientDataContainerHd = *rSdrPowerPointImport.maShapeRecords.Current(); - DffRecordHeader aPlaceHolderAtomHd; - if ( SvxMSDffManager::SeekToRec( rIn, PPT_PST_OEPlaceholderAtom, aClientDataContainerHd.GetRecEndFilePos(), &aPlaceHolderAtomHd ) ) - { - mxImplTextObj->mpPlaceHolderAtom.reset( new PptOEPlaceholderAtom ); - ReadPptOEPlaceholderAtom( rIn, *( mxImplTextObj->mpPlaceHolderAtom ) ); - } - rIn.Seek( nOldPos ); - DffRecordHeader aProgTagHd; - if ( SdrPowerPointImport::SeekToContentOfProgTag( 9, rIn, aClientDataContainerHd, aProgTagHd ) ) - { - ReadDffRecordHeader( rIn, aExtParaHd ); - } + ReadDffRecordHeader( rIn, aExtParaHd ); } + } - // ClientTextBox - if ( rSdrPowerPointImport.maShapeRecords.SeekToContent( rIn, DFF_msofbtClientTextbox, SEEK_FROM_CURRENT_AND_RESTART ) ) - { - bool bStatus = true; + // ClientTextBox + if ( !rSdrPowerPointImport.maShapeRecords.SeekToContent( rIn, DFF_msofbtClientTextbox, SEEK_FROM_CURRENT_AND_RESTART ) ) + return; + + bool bStatus = true; - DffRecordHeader aClientTextBoxHd( *rSdrPowerPointImport.maShapeRecords.Current() ); - sal_uInt32 nTextRulerAtomOfs = 0; // case of zero -> this atom may be found in aClientDataContainerHd; - // case of -1 -> there is no atom of this kind - // else -> this is the fileofs where we can get it + DffRecordHeader aClientTextBoxHd( *rSdrPowerPointImport.maShapeRecords.Current() ); + sal_uInt32 nTextRulerAtomOfs = 0; // case of zero -> this atom may be found in aClientDataContainerHd; + // case of -1 -> there is no atom of this kind + // else -> this is the fileofs where we can get it + + // checkout if this is a referenced + // textobj, if so the we will patch + // the ClientTextBoxHd for a + // equivalent one + DffRecordHeader aTextHd; + if ( SvxMSDffManager::SeekToRec( rIn, PPT_PST_OutlineTextRefAtom, aClientTextBoxHd.GetRecEndFilePos(), &aTextHd ) ) + { + sal_uInt32 nRefNum; + rIn.ReadUInt32( nRefNum ); + + if ( SvxMSDffManager::SeekToRec( rIn, PPT_PST_TextRulerAtom, aClientTextBoxHd.GetRecEndFilePos() ) ) + nTextRulerAtomOfs = rIn.Tell(); + else + nTextRulerAtomOfs = 0xffffffff; - // checkout if this is a referenced - // textobj, if so the we will patch - // the ClientTextBoxHd for a - // equivalent one - DffRecordHeader aTextHd; - if ( SvxMSDffManager::SeekToRec( rIn, PPT_PST_OutlineTextRefAtom, aClientTextBoxHd.GetRecEndFilePos(), &aTextHd ) ) + sal_uInt32 nInstance = 0; + switch( rSdrPowerPointImport.m_eCurrentPageKind ) + { + case PPT_NOTEPAGE : + nInstance++; + [[fallthrough]]; + case PPT_MASTERPAGE : + nInstance++; + break; + case PPT_SLIDEPAGE : + break; + default : + bStatus = false; + } + if ( bStatus ) + { + sal_uInt32 nSlideId = rSdrPowerPointImport.GetCurrentPageId(); + if ( !nSlideId ) + bStatus = false; + else { - sal_uInt32 nRefNum; - rIn.ReadUInt32( nRefNum ); + if ( !aExtParaHd.nRecType ) + { + sal_uInt32 nOldPos = rIn.Tell(); + // try to locate the referenced ExtendedParaHd + DffRecordHeader* pHd = pExtParaProv-> + aExtendedPresRules.GetRecordHeader( PPT_PST_ExtendedParagraphHeaderAtom, + SEEK_FROM_CURRENT_AND_RESTART ); + DffRecordHeader aPresRuleHd; + DffRecordHeader* pFirst = pHd; + + sal_uInt32 nTmpSlideId, nTmpRef; + while ( pHd ) + { + pHd->SeekToContent( rIn ); + rIn.ReadUInt32( nTmpSlideId ) + .ReadUInt32( nTmpRef ); // this seems to be the instance - if ( SvxMSDffManager::SeekToRec( rIn, PPT_PST_TextRulerAtom, aClientTextBoxHd.GetRecEndFilePos() ) ) - nTextRulerAtomOfs = rIn.Tell(); + if ( ( nTmpSlideId == nSlideId ) && ( pHd->nRecInstance == nRefNum ) ) + { + if (!pHd->SeekToEndOfRecord(rIn)) + break; + ReadDffRecordHeader( rIn, aPresRuleHd ); + if ( aPresRuleHd.nRecType == PPT_PST_ExtendedParagraphAtom ) + { + aExtParaHd = aPresRuleHd; + break; + } + } + pHd = pExtParaProv-> + aExtendedPresRules.GetRecordHeader( PPT_PST_ExtendedParagraphHeaderAtom, + SEEK_FROM_CURRENT_AND_RESTART ); + if ( pHd == pFirst ) + break; + } + rIn.Seek( nOldPos ); + } + // now pHd points to the right SlideListWithText Container + PptSlidePersistList* pPageList = rSdrPowerPointImport.GetPageList( rSdrPowerPointImport.m_eCurrentPageKind ); + PptSlidePersistEntry* pE = nullptr; + if ( pPageList && ( rSdrPowerPointImport.m_nCurrentPageNum < pPageList->size() ) ) + pE = &(*pPageList)[ rSdrPowerPointImport.m_nCurrentPageNum ]; + if ( (!pE) || (!pE->nSlidePersistStartOffset) || ( pE->aPersistAtom.nSlideId != nSlideId ) ) + bStatus = false; else - nTextRulerAtomOfs = 0xffffffff; - - sal_uInt32 nInstance = 0; - switch( rSdrPowerPointImport.m_eCurrentPageKind ) { - case PPT_NOTEPAGE : - nInstance++; - [[fallthrough]]; - case PPT_MASTERPAGE : - nInstance++; - break; - case PPT_SLIDEPAGE : - break; - default : + auto nOffset(pE->nSlidePersistStartOffset); + bStatus = (nOffset == rIn.Seek(nOffset)); + // now we got the right page and are searching for the right + // TextHeaderAtom + auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, pE->nSlidePersistEndOffset); + while (bStatus && rIn.Tell() < nEndRecPos) + { + ReadDffRecordHeader( rIn, aClientTextBoxHd ); + if ( aClientTextBoxHd.nRecType == PPT_PST_TextHeaderAtom ) + { + if ( aClientTextBoxHd.nRecInstance == nRefNum ) + { + aClientTextBoxHd.SeekToEndOfRecord( rIn ); + break; + } + } + if (!aClientTextBoxHd.SeekToEndOfRecord(rIn)) + break; + } + if ( rIn.Tell() > pE->nSlidePersistEndOffset ) bStatus = false; + else + { // patching the RecordHeader + aClientTextBoxHd.nFilePos -= DFF_COMMON_RECORD_HEADER_SIZE; + aClientTextBoxHd.nRecLen += DFF_COMMON_RECORD_HEADER_SIZE; + aClientTextBoxHd.nRecType = DFF_msofbtClientTextbox; + aClientTextBoxHd.nRecVer = DFF_PSFLAG_CONTAINER; + + // we have to calculate the correct record len + DffRecordHeader aTmpHd; + nEndRecPos = DffPropSet::SanitizeEndPos(rIn, pE->nSlidePersistEndOffset); + while (rIn.Tell() < nEndRecPos) + { + ReadDffRecordHeader( rIn, aTmpHd ); + if ( ( aTmpHd.nRecType == PPT_PST_SlidePersistAtom ) || ( aTmpHd.nRecType == PPT_PST_TextHeaderAtom ) ) + break; + if (!aTmpHd.SeekToEndOfRecord(rIn)) + break; + aClientTextBoxHd.nRecLen += aTmpHd.nRecLen + DFF_COMMON_RECORD_HEADER_SIZE; + } + aClientTextBoxHd.SeekToContent( rIn ); + } } - if ( bStatus ) + } + } + } + + if ( !bStatus ) + return; + + if ( !SvxMSDffManager::SeekToRec( rIn, PPT_PST_TextHeaderAtom, aClientTextBoxHd.GetRecEndFilePos(), &aTextHd ) ) + return; + + // TextHeaderAtom is always the first Atom + sal_uInt16 nTmp; + rIn.ReadUInt16( nTmp ); // this number tells us the TxMasterStyleAtom Instance + if ( nTmp > 8 ) + nTmp = 4; + TSS_Type nInstance = static_cast<TSS_Type>(nTmp); + aTextHd.SeekToEndOfRecord( rIn ); + mxImplTextObj->mnInstance = nInstance; + + sal_uInt32 nFilePos = rIn.Tell(); + if ( !(rSdrPowerPointImport.SeekToRec2( PPT_PST_TextBytesAtom, + PPT_PST_TextCharsAtom, + aClientTextBoxHd.GetRecEndFilePos() ) + || SvxMSDffManager::SeekToRec( rIn, + PPT_PST_StyleTextPropAtom, + aClientTextBoxHd.GetRecEndFilePos() )) ) + return; + + PPTTextRulerInterpreter aTextRulerInterpreter( nTextRulerAtomOfs, aClientTextBoxHd, rIn ); + + PPTStyleTextPropReader aStyleTextPropReader( rIn, aClientTextBoxHd, + aTextRulerInterpreter, aExtParaHd, nInstance ); + sal_uInt32 nParagraphs = mxImplTextObj->mnParagraphCount = aStyleTextPropReader.aParaPropList.size(); + if ( !nParagraphs ) + return; + + // the language settings will be merged into the list of PPTCharPropSet + DffRecordHeader aTextSpecInfoHd; + PPTTextSpecInfoAtomInterpreter aTextSpecInfoAtomInterpreter; + if ( SvxMSDffManager::SeekToRec( rIn, PPT_PST_TextSpecInfoAtom, + aClientTextBoxHd.GetRecEndFilePos(), &aTextSpecInfoHd ) ) + { + if ( aTextSpecInfoAtomInterpreter.Read( rIn, aTextSpecInfoHd, PPT_PST_TextSpecInfoAtom, + &(rSdrPowerPointImport.m_pPPTStyleSheet->maTxSI) ) ) + { + size_t nI = 0; + for (const PPTTextSpecInfo& rSpecInfo : aTextSpecInfoAtomInterpreter.aList) + { + sal_uInt32 nCharIdx = rSpecInfo.nCharIdx; + + // portions and text have to been split in some cases + for ( ; nI < aStyleTextPropReader.aCharPropList.size(); ++nI) { - sal_uInt32 nSlideId = rSdrPowerPointImport.GetCurrentPageId(); - if ( !nSlideId ) - bStatus = false; + PPTCharPropSet* pSet = aStyleTextPropReader.aCharPropList[nI].get(); + if (pSet->mnOriginalTextPos >= nCharIdx) + break; + pSet->mnLanguage[0] = rSpecInfo.nLanguage[0]; + pSet->mnLanguage[1] = rSpecInfo.nLanguage[1]; + pSet->mnLanguage[2] = rSpecInfo.nLanguage[2]; + // test if the current portion needs to be split + if (pSet->maString.getLength() <= 1) + continue; + sal_Int32 nIndexOfNextPortion = pSet->maString.getLength() + pSet->mnOriginalTextPos; + sal_Int32 nNewLen = nIndexOfNextPortion - nCharIdx; + if (nNewLen <= 0) + continue; + sal_Int32 nOldLen = pSet->maString.getLength() - nNewLen; + if (nOldLen <= 0) + continue; + OUString aString(pSet->maString); + PPTCharPropSet* pNew = new PPTCharPropSet(*pSet); + pSet->maString = aString.copy(0, nOldLen); + pNew->maString = aString.copy(nOldLen, nNewLen); + pNew->mnOriginalTextPos += nOldLen; + aStyleTextPropReader.aCharPropList.emplace(aStyleTextPropReader.aCharPropList.begin() + nI + 1, pNew); + } + } + } +#ifdef DBG_UTIL + else + { + if (!(rSdrPowerPointImport.rImportParam.nImportFlags & PPT_IMPORTFLAGS_NO_TEXT_ASSERT)) + { + OSL_FAIL( "SdrTextSpecInfoAtomInterpreter::Ctor(): parsing error, this document needs to be analysed (SJ)" ); + } + } +#endif + } + // now will search for possible textextensions such as date/time fields + // or ParaTabStops and append them on this textobj + rIn.Seek( nFilePos ); + ::std::vector< std::unique_ptr<PPTFieldEntry> > FieldList; + auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, aClientTextBoxHd.GetRecEndFilePos()); + while (rIn.Tell() < nEndRecPos) + { + ReadDffRecordHeader( rIn, aTextHd ); + sal_uInt16 nVal = 0; + std::unique_ptr<PPTFieldEntry> xEntry; + switch ( aTextHd.nRecType ) + { + case PPT_PST_DateTimeMCAtom : + { + xEntry.reset(new PPTFieldEntry); + rIn.ReadUInt16(xEntry->nPos) + .ReadUInt16( nVal ) + .ReadUInt16( nVal ); + xEntry->SetDateTime( nVal & 0xff ); + } + break; + + case PPT_PST_FooterMCAtom : + { + xEntry.reset(new PPTFieldEntry); + rIn.ReadUInt16(xEntry->nPos); + xEntry->xField1.reset(new SvxFieldItem(SvxFooterField(), EE_FEATURE_FIELD)); + } + break; + + case PPT_PST_HeaderMCAtom : + { + xEntry.reset(new PPTFieldEntry); + rIn.ReadUInt16(xEntry->nPos); + xEntry->xField1.reset(new SvxFieldItem(SvxHeaderField(), EE_FEATURE_FIELD)); + } + break; + + case PPT_PST_GenericDateMCAtom : + { + xEntry.reset(new PPTFieldEntry); + rIn.ReadUInt16(xEntry->nPos); + xEntry->xField1.reset(new SvxFieldItem(SvxDateTimeField(), EE_FEATURE_FIELD)); + if (rPersistEntry.xHeaderFooterEntry) // sj: #i34111# on master pages it is possible + { // that there is no HeaderFooterEntry available + if (rPersistEntry.xHeaderFooterEntry->nAtom & 0x20000) // auto date time + xEntry->SetDateTime(rPersistEntry.xHeaderFooterEntry->nAtom & 0xff); else + xEntry->xString = rPersistEntry.xHeaderFooterEntry->pPlaceholder[nVal]; + } + } + break; + + case PPT_PST_SlideNumberMCAtom : + case PPT_PST_RTFDateTimeMCAtom : + { + xEntry.reset(new PPTFieldEntry); + if ( aTextHd.nRecLen >= 4 ) + { + rIn.ReadUInt16(xEntry->nPos) + .ReadUInt16( nVal ); + + // evaluate ID + //SvxFieldItem* pFieldItem = NULL; + switch( aTextHd.nRecType ) { - if ( !aExtParaHd.nRecType ) + case PPT_PST_SlideNumberMCAtom: + xEntry->xField1.reset(new SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD)); + break; + + case PPT_PST_RTFDateTimeMCAtom: { - sal_uInt32 nOldPos = rIn.Tell(); - // try to locate the referenced ExtendedParaHd - DffRecordHeader* pHd = pExtParaProv-> - aExtendedPresRules.GetRecordHeader( PPT_PST_ExtendedParagraphHeaderAtom, - SEEK_FROM_CURRENT_AND_RESTART ); - DffRecordHeader aPresRuleHd; - DffRecordHeader* pFirst = pHd; - - sal_uInt32 nTmpSlideId, nTmpRef; - while ( pHd ) + // Rude workaround for one special case reported + // by a customer. (#i75203#) + + // Don't even attempt to handle the general use + // case for PPT_PST_RTFDateTimeMCAtom (a generic + // MS style date/time format string). Just handle + // the special case where the format string + // contains only one or several possibly empty + // quoted strings. I.e. something that doesn't + // expand to any date or time at all, but to a + // fixed string. How on earth somebody manages to + // produce such things in PPT slides I have no + // idea. + if (nVal == 0) { - pHd->SeekToContent( rIn ); - rIn.ReadUInt32( nTmpSlideId ) - .ReadUInt32( nTmpRef ); // this seems to be the instance - - if ( ( nTmpSlideId == nSlideId ) && ( pHd->nRecInstance == nRefNum ) ) + OUStringBuffer aStr; + bool inquote = false; + for (int nLen = 0; nLen < 64; ++nLen) { - if (!pHd->SeekToEndOfRecord(rIn)) + sal_Unicode n(0); + rIn.ReadUtf16( n ); + + // Collect quoted characters into aStr + if ( n == '\'') + inquote = !inquote; + else if (!n) + { + // End of format string + xEntry->xString = aStr.makeStringAndClear(); break; - ReadDffRecordHeader( rIn, aPresRuleHd ); - if ( aPresRuleHd.nRecType == PPT_PST_ExtendedParagraphAtom ) + } + else if (!inquote) { - aExtParaHd = aPresRuleHd; + // Non-quoted character, i.e. a real + // format specifier. We don't handle + // those. Sorry. break; } + else + { + aStr.append(OUStringChar(n)); + } } - pHd = pExtParaProv-> - aExtendedPresRules.GetRecordHeader( PPT_PST_ExtendedParagraphHeaderAtom, - SEEK_FROM_CURRENT_AND_RESTART ); - if ( pHd == pFirst ) - break; } - rIn.Seek( nOldPos ); + if (!xEntry->xString) + { + // Handle as previously + xEntry->xField1.reset(new SvxFieldItem( SvxDateField( Date( Date::SYSTEM ), SvxDateType::Fix ), EE_FEATURE_FIELD )); + } } - // now pHd points to the right SlideListWithText Container - PptSlidePersistList* pPageList = rSdrPowerPointImport.GetPageList( rSdrPowerPointImport.m_eCurrentPageKind ); - PptSlidePersistEntry* pE = nullptr; - if ( pPageList && ( rSdrPowerPointImport.m_nCurrentPageNum < pPageList->size() ) ) - pE = &(*pPageList)[ rSdrPowerPointImport.m_nCurrentPageNum ]; - if ( (!pE) || (!pE->nSlidePersistStartOffset) || ( pE->aPersistAtom.nSlideId != nSlideId ) ) - bStatus = false; - else + } + } + } + break; + + case PPT_PST_InteractiveInfo : + { + DffRecordHeader aHdInteractiveInfoAtom; + if ( SvxMSDffManager::SeekToRec( rIn, PPT_PST_InteractiveInfoAtom, aTextHd.GetRecEndFilePos(), &aHdInteractiveInfoAtom ) ) + { + PptInteractiveInfoAtom aInteractiveInfoAtom; + ReadPptInteractiveInfoAtom( rIn, aInteractiveInfoAtom ); + for (const SdHyperlinkEntry& rHyperlink : rSdrPowerPointImport.m_aHyperList) + { + if ( rHyperlink.nIndex == aInteractiveInfoAtom.nExHyperlinkId ) { - auto nOffset(pE->nSlidePersistStartOffset); - bStatus = (nOffset == rIn.Seek(nOffset)); - // now we got the right page and are searching for the right - // TextHeaderAtom - auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, pE->nSlidePersistEndOffset); - while (bStatus && rIn.Tell() < nEndRecPos) + if (!aTextHd.SeekToEndOfRecord(rIn)) { - ReadDffRecordHeader( rIn, aClientTextBoxHd ); - if ( aClientTextBoxHd.nRecType == PPT_PST_TextHeaderAtom ) - { - if ( aClientTextBoxHd.nRecInstance == nRefNum ) - { - aClientTextBoxHd.SeekToEndOfRecord( rIn ); - break; - } - } - if (!aClientTextBoxHd.SeekToEndOfRecord(rIn)) - break; + break; + } + ReadDffRecordHeader( rIn, aTextHd ); + if ( aTextHd.nRecType != PPT_PST_TxInteractiveInfoAtom ) + { + aTextHd.SeekToBegOfRecord( rIn ); + continue; } - if ( rIn.Tell() > pE->nSlidePersistEndOffset ) - bStatus = false; else - { // patching the RecordHeader - aClientTextBoxHd.nFilePos -= DFF_COMMON_RECORD_HEADER_SIZE; - aClientTextBoxHd.nRecLen += DFF_COMMON_RECORD_HEADER_SIZE; - aClientTextBoxHd.nRecType = DFF_msofbtClientTextbox; - aClientTextBoxHd.nRecVer = DFF_PSFLAG_CONTAINER; - - // we have to calculate the correct record len - DffRecordHeader aTmpHd; - nEndRecPos = DffPropSet::SanitizeEndPos(rIn, pE->nSlidePersistEndOffset); - while (rIn.Tell() < nEndRecPos) + { + sal_uInt32 nStartPos, nEndPos; + rIn.ReadUInt32( nStartPos ) + .ReadUInt32( nEndPos ); + if ( nEndPos ) { - ReadDffRecordHeader( rIn, aTmpHd ); - if ( ( aTmpHd.nRecType == PPT_PST_SlidePersistAtom ) || ( aTmpHd.nRecType == PPT_PST_TextHeaderAtom ) ) - break; - if (!aTmpHd.SeekToEndOfRecord(rIn)) - break; - aClientTextBoxHd.nRecLen += aTmpHd.nRecLen + DFF_COMMON_RECORD_HEADER_SIZE; + xEntry.reset(new PPTFieldEntry); + xEntry->nPos = static_cast<sal_uInt16>(nStartPos); + xEntry->nTextRangeEnd = static_cast<sal_uInt16>(nEndPos); + OUString aTarget( rHyperlink.aTarget ); + if ( !rHyperlink.aConvSubString.isEmpty() ) + { + aTarget += "#" + rHyperlink.aConvSubString; + } + xEntry->xField1.reset(new SvxFieldItem( SvxURLField( aTarget, OUString(), SvxURLFormat::Repr ), EE_FEATURE_FIELD )); } - aClientTextBoxHd.SeekToContent( rIn ); } + break; } } } } + break; + } + if (!aTextHd.SeekToEndOfRecord(rIn)) + break; + if (xEntry) + { + // sorting fields ( hi >> lo ) + auto it = std::find_if(FieldList.begin(), FieldList.end(), + [&xEntry](const std::unique_ptr<PPTFieldEntry>& rxField) { + return rxField->nPos < xEntry->nPos; }); + if ( it != FieldList.end() ) { + FieldList.insert(it, std::move(xEntry)); + } else { + FieldList.push_back( std::move(xEntry)); + } + } + } + if ( !FieldList.empty() ) + { + auto FE = FieldList.begin(); + auto& aCharPropList = aStyleTextPropReader.aCharPropList; + + sal_Int32 i = nParagraphs - 1; + sal_Int32 n = aCharPropList.size() - 1; - if ( bStatus ) + // at this point we just have a list of textportions(aCharPropList) + // the next while loop tries to resolve the list of fields(pFieldList) + while( ( FE < FieldList.end() ) && ( n >= 0 ) && ( i >= 0 ) ) + { + PPTCharPropSet* pSet = aCharPropList[n].get(); + OUString aString( pSet->maString ); + sal_uInt32 nCount = aString.getLength(); + sal_uInt32 nPos = pSet->mnOriginalTextPos + nCount; + while ( ( FE < FieldList.end() ) && nCount-- ) { - if ( SvxMSDffManager::SeekToRec( rIn, PPT_PST_TextHeaderAtom, aClientTextBoxHd.GetRecEndFilePos(), &aTextHd ) ) + nPos--; + FE = std::find_if(FE, FieldList.end(), + [&nPos](const std::unique_ptr<PPTFieldEntry>& rxField) {return rxField->nPos <= nPos;}); + if (FE == FieldList.end()) + break; + + if ( (*FE)->nPos == nPos ) { - // TextHeaderAtom is always the first Atom - sal_uInt16 nTmp; - rIn.ReadUInt16( nTmp ); // this number tells us the TxMasterStyleAtom Instance - if ( nTmp > 8 ) - nTmp = 4; - TSS_Type nInstance = static_cast<TSS_Type>(nTmp); - aTextHd.SeekToEndOfRecord( rIn ); - mxImplTextObj->mnInstance = nInstance; - - sal_uInt32 nFilePos = rIn.Tell(); - if ( rSdrPowerPointImport.SeekToRec2( PPT_PST_TextBytesAtom, - PPT_PST_TextCharsAtom, - aClientTextBoxHd.GetRecEndFilePos() ) - || SvxMSDffManager::SeekToRec( rIn, - PPT_PST_StyleTextPropAtom, - aClientTextBoxHd.GetRecEndFilePos() ) ) + if ( aString[nCount] == 0x2a ) { - PPTTextRulerInterpreter aTextRulerInterpreter( nTextRulerAtomOfs, aClientTextBoxHd, rIn ); + sal_uInt32 nBehind = aString.getLength() - ( nCount + 1 ); + pSet->maString.clear(); + if ( nBehind ) + { + PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet ); + pNewCPS->maString = aString.copy( nCount + 1, nBehind ); + aCharPropList.emplace( aCharPropList.begin() + n + 1, pNewCPS ); + } + if ( (*FE)->xField2 ) + { + PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet ); + pNewCPS->mpFieldItem = std::move((*FE)->xField2); + aCharPropList.emplace( aCharPropList.begin() + n + 1, pNewCPS ); - PPTStyleTextPropReader aStyleTextPropReader( rIn, aClientTextBoxHd, - aTextRulerInterpreter, aExtParaHd, nInstance ); - sal_uInt32 nParagraphs = mxImplTextObj->mnParagraphCount = aStyleTextPropReader.aParaPropList.size(); - if ( nParagraphs ) + pNewCPS = new PPTCharPropSet( *pSet ); + pNewCPS->maString = " "; + aCharPropList.emplace( aCharPropList.begin() + n + 1, pNewCPS ); + } + if ( nCount ) { - // the language settings will be merged into the list of PPTCharPropSet - DffRecordHeader aTextSpecInfoHd; - PPTTextSpecInfoAtomInterpreter aTextSpecInfoAtomInterpreter; - if ( SvxMSDffManager::SeekToRec( rIn, PPT_PST_TextSpecInfoAtom, - aClientTextBoxHd.GetRecEndFilePos(), &aTextSpecInfoHd ) ) + PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet ); + pNewCPS->maString = aString.copy( 0, nCount ); + aCharPropList.emplace( aCharPropList.begin() + n++, pNewCPS ); + } + if ( (*FE)->xField1 ) + { + pSet->mpFieldItem = std::move((*FE)->xField1); + } + else if ( (*FE)->xString ) + pSet->maString = *(*FE)->xString; + } + else + { + if ( (*FE)->nTextRangeEnd ) // text range hyperlink + { + sal_uInt32 nHyperLen = (*FE)->nTextRangeEnd - nPos; + if ( nHyperLen ) { - if ( aTextSpecInfoAtomInterpreter.Read( rIn, aTextSpecInfoHd, PPT_PST_TextSpecInfoAtom, - &(rSdrPowerPointImport.m_pPPTStyleSheet->maTxSI) ) ) - { - size_t nI = 0; - for (const PPTTextSpecInfo& rSpecInfo : aTextSpecInfoAtomInterpreter.aList) - { - sal_uInt32 nCharIdx = rSpecInfo.nCharIdx; - - // portions and text have to been split in some cases - for ( ; nI < aStyleTextPropReader.aCharPropList.size(); ++nI) - { - PPTCharPropSet* pSet = aStyleTextPropReader.aCharPropList[nI].get(); - if (pSet->mnOriginalTextPos >= nCharIdx) - break; - pSet->mnLanguage[0] = rSpecInfo.nLanguage[0]; - pSet->mnLanguage[1] = rSpecInfo.nLanguage[1]; - pSet->mnLanguage[2] = rSpecInfo.nLanguage[2]; - // test if the current portion needs to be split - if (pSet->maString.getLength() <= 1) - continue; - sal_Int32 nIndexOfNextPortion = pSet->maString.getLength() + pSet->mnOriginalTextPos; - sal_Int32 nNewLen = nIndexOfNextPortion - nCharIdx; - if (nNewLen <= 0) - continue; - sal_Int32 nOldLen = pSet->maString.getLength() - nNewLen; - if (nOldLen <= 0) - continue; - OUString aString(pSet->maString); - PPTCharPropSet* pNew = new PPTCharPropSet(*pSet); - pSet->maString = aString.copy(0, nOldLen); - pNew->maString = aString.copy(nOldLen, nNewLen); - pNew->mnOriginalTextPos += nOldLen; - aStyleTextPropReader.aCharPropList.emplace(aStyleTextPropReader.aCharPropList.begin() + nI + 1, pNew); - } - } - } -#ifdef DBG_UTIL - else + PPTCharPropSet* pBefCPS = nullptr; + if ( nCount ) { - if (!(rSdrPowerPointImport.rImportParam.nImportFlags & PPT_IMPORTFLAGS_NO_TEXT_ASSERT)) - { - OSL_FAIL( "SdrTextSpecInfoAtomInterpreter::Ctor(): parsing error, this document needs to be analysed (SJ)" ); - } + pBefCPS = new PPTCharPropSet( *pSet ); + pSet->maString = pSet->maString.copy(nCount); } -#endif - } - // now will search for possible textextensions such as date/time fields - // or ParaTabStops and append them on this textobj - rIn.Seek( nFilePos ); - ::std::vector< std::unique_ptr<PPTFieldEntry> > FieldList; - auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, aClientTextBoxHd.GetRecEndFilePos()); - while (rIn.Tell() < nEndRecPos) - { - ReadDffRecordHeader( rIn, aTextHd ); - sal_uInt16 nVal = 0; - std::unique_ptr<PPTFieldEntry> xEntry; - switch ( aTextHd.nRecType ) - { - case PPT_PST_DateTimeMCAtom : - { - xEntry.reset(new PPTFieldEntry); - rIn.ReadUInt16(xEntry->nPos) - .ReadUInt16( nVal ) - .ReadUInt16( nVal ); - xEntry->SetDateTime( nVal & 0xff ); - } - break; + sal_uInt32 nIdx = n; + sal_Int32 nHyperLenLeft = nHyperLen; - case PPT_PST_FooterMCAtom : - { - xEntry.reset(new PPTFieldEntry); - rIn.ReadUInt16(xEntry->nPos); - xEntry->xField1.reset(new SvxFieldItem(SvxFooterField(), EE_FEATURE_FIELD)); - } - break; + while ( ( aCharPropList.size() > nIdx ) && nHyperLenLeft ) + { + // the textrange hyperlink can take more than 1 paragraph + // the solution here is to clone the hyperlink... - case PPT_PST_HeaderMCAtom : - { - xEntry.reset(new PPTFieldEntry); - rIn.ReadUInt16(xEntry->nPos); - xEntry->xField1.reset(new SvxFieldItem(SvxHeaderField(), EE_FEATURE_FIELD)); - } - break; + PPTCharPropSet* pCurrent = aCharPropList[ nIdx ].get(); + sal_Int32 nNextStringLen = pCurrent->maString.getLength(); - case PPT_PST_GenericDateMCAtom : - { - xEntry.reset(new PPTFieldEntry); - rIn.ReadUInt16(xEntry->nPos); - xEntry->xField1.reset(new SvxFieldItem(SvxDateTimeField(), EE_FEATURE_FIELD)); - if (rPersistEntry.xHeaderFooterEntry) // sj: #i34111# on master pages it is possible - { // that there is no HeaderFooterEntry available - if (rPersistEntry.xHeaderFooterEntry->nAtom & 0x20000) // auto date time - xEntry->SetDateTime(rPersistEntry.xHeaderFooterEntry->nAtom & 0xff); - else - xEntry->xString = rPersistEntry.xHeaderFooterEntry->pPlaceholder[nVal]; - } - } - break; - - case PPT_PST_SlideNumberMCAtom : - case PPT_PST_RTFDateTimeMCAtom : - { - xEntry.reset(new PPTFieldEntry); - if ( aTextHd.nRecLen >= 4 ) - { - rIn.ReadUInt16(xEntry->nPos) - .ReadUInt16( nVal ); + DBG_ASSERT( (*FE)->xField1, "missing field!" ); + if (!(*FE)->xField1) + break; - // evaluate ID - //SvxFieldItem* pFieldItem = NULL; - switch( aTextHd.nRecType ) - { - case PPT_PST_SlideNumberMCAtom: - xEntry->xField1.reset(new SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD)); - break; + const SvxURLField* pField = static_cast<const SvxURLField*>((*FE)->xField1->GetField()); - case PPT_PST_RTFDateTimeMCAtom: - { - // Rude workaround for one special case reported - // by a customer. (#i75203#) - - // Don't even attempt to handle the general use - // case for PPT_PST_RTFDateTimeMCAtom (a generic - // MS style date/time format string). Just handle - // the special case where the format string - // contains only one or several possibly empty - // quoted strings. I.e. something that doesn't - // expand to any date or time at all, but to a - // fixed string. How on earth somebody manages to - // produce such things in PPT slides I have no - // idea. - if (nVal == 0) - { - OUStringBuffer aStr; - bool inquote = false; - for (int nLen = 0; nLen < 64; ++nLen) - { - sal_Unicode n(0); - rIn.ReadUtf16( n ); + pCurrent->mbIsHyperlink = true; + pCurrent->mnHylinkOrigColor = pCurrent->mpImplPPTCharPropSet->mnColor; + pCurrent->mbHardHylinkOrigColor = ( ( pCurrent->mpImplPPTCharPropSet->mnAttrSet >>PPT_CharAttr_FontColor ) & 1)>0; - // Collect quoted characters into aStr - if ( n == '\'') - inquote = !inquote; - else if (!n) - { - // End of format string - xEntry->xString = aStr.makeStringAndClear(); - break; - } - else if (!inquote) - { - // Non-quoted character, i.e. a real - // format specifier. We don't handle - // those. Sorry. - break; - } - else - { - aStr.append(OUStringChar(n)); - } - } - } - if (!xEntry->xString) - { - // Handle as previously - xEntry->xField1.reset(new SvxFieldItem( SvxDateField( Date( Date::SYSTEM ), SvxDateType::Fix ), EE_FEATURE_FIELD )); - } - } - } - } - } - break; + // add missing attribute to show underline property + pCurrent->mpImplPPTCharPropSet->mnAttrSet |= 1 << PPT_CharAttr_Underline; + pCurrent->mpImplPPTCharPropSet->mnFlags = 1 << PPT_CharAttr_Underline; - case PPT_PST_InteractiveInfo : + if ( pCurrent->mpFieldItem ) { - DffRecordHeader aHdInteractiveInfoAtom; - if ( SvxMSDffManager::SeekToRec( rIn, PPT_PST_InteractiveInfoAtom, aTextHd.GetRecEndFilePos(), &aHdInteractiveInfoAtom ) ) - { - PptInteractiveInfoAtom aInteractiveInfoAtom; - ReadPptInteractiveInfoAtom( rIn, aInteractiveInfoAtom ); - for (const SdHyperlinkEntry& rHyperlink : rSdrPowerPointImport.m_aHyperList) - { - if ( rHyperlink.nIndex == aInteractiveInfoAtom.nExHyperlinkId ) - { - if (!aTextHd.SeekToEndOfRecord(rIn)) - { - break; - } - ReadDffRecordHeader( rIn, aTextHd ); - if ( aTextHd.nRecType != PPT_PST_TxInteractiveInfoAtom ) - { - aTextHd.SeekToBegOfRecord( rIn ); - continue; - } - else - { - sal_uInt32 nStartPos, nEndPos; - rIn.ReadUInt32( nStartPos ) - .ReadUInt32( nEndPos ); - if ( nEndPos ) - { - xEntry.reset(new PPTFieldEntry); - xEntry->nPos = static_cast<sal_uInt16>(nStartPos); - xEntry->nTextRangeEnd = static_cast<sal_uInt16>(nEndPos); - OUString aTarget( rHyperlink.aTarget ); - if ( !rHyperlink.aConvSubString.isEmpty() ) - { - aTarget += "#" + rHyperlink.aConvSubString; - } - xEntry->xField1.reset(new SvxFieldItem( SvxURLField( aTarget, OUString(), SvxURLFormat::Repr ), EE_FEATURE_FIELD )); - } - } - break; - } - } - } - } - break; - } - if (!aTextHd.SeekToEndOfRecord(rIn)) - break; - if (xEntry) - { - // sorting fields ( hi >> lo ) - auto it = std::find_if(FieldList.begin(), FieldList.end(), - [&xEntry](const std::unique_ptr<PPTFieldEntry>& rxField) { - return rxField->nPos < xEntry->nPos; }); - if ( it != FieldList.end() ) { - FieldList.insert(it, std::move(xEntry)); - } else { - FieldList.push_back( std::move(xEntry)); + pCurrent->SetColor( PPT_COLSCHEME_A_UND_HYPERLINK ); + if ( dynamic_cast< const SvxURLField* >(pCurrent->mpFieldItem->GetField()) != nullptr) + break; + nHyperLenLeft--; } - } - } - if ( !FieldList.empty() ) - { - auto FE = FieldList.begin(); - auto& aCharPropList = aStyleTextPropReader.aCharPropList; - - sal_Int32 i = nParagraphs - 1; - sal_Int32 n = aCharPropList.size() - 1; - - // at this point we just have a list of textportions(aCharPropList) - // the next while loop tries to resolve the list of fields(pFieldList) - while( ( FE < FieldList.end() ) && ( n >= 0 ) && ( i >= 0 ) ) - { - PPTCharPropSet* pSet = aCharPropList[n].get(); - OUString aString( pSet->maString ); - sal_uInt32 nCount = aString.getLength(); - sal_uInt32 nPos = pSet->mnOriginalTextPos + nCount; - while ( ( FE < FieldList.end() ) && nCount-- ) + else if ( nNextStringLen ) { - nPos--; - FE = std::find_if(FE, FieldList.end(), - [&nPos](const std::unique_ptr<PPTFieldEntry>& rxField) {return rxField->nPos <= nPos;}); - if (FE == FieldList.end()) - break; - - if ( (*FE)->nPos == nPos ) + if ( nNextStringLen <= nHyperLenLeft ) { - if ( aString[nCount] == 0x2a ) - { - sal_uInt32 nBehind = aString.getLength() - ( nCount + 1 ); - pSet->maString.clear(); - if ( nBehind ) - { - PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet ); - pNewCPS->maString = aString.copy( nCount + 1, nBehind ); - aCharPropList.emplace( aCharPropList.begin() + n + 1, pNewCPS ); - } - if ( (*FE)->xField2 ) - { - PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet ); - pNewCPS->mpFieldItem = std::move((*FE)->xField2); - aCharPropList.emplace( aCharPropList.begin() + n + 1, pNewCPS ); + pCurrent->mpFieldItem.reset( new SvxFieldItem( SvxURLField( pField->GetURL(), pCurrent->maString, SvxURLFormat::Repr ), EE_FEATURE_FIELD ) ); + nHyperLenLeft -= nNextStringLen; - pNewCPS = new PPTCharPropSet( *pSet ); - pNewCPS->maString = " "; - aCharPropList.emplace( aCharPropList.begin() + n + 1, pNewCPS ); - } - if ( nCount ) - { - PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet ); - pNewCPS->maString = aString.copy( 0, nCount ); - aCharPropList.emplace( aCharPropList.begin() + n++, pNewCPS ); - } - if ( (*FE)->xField1 ) - { - pSet->mpFieldItem = std::move((*FE)->xField1); - } - else if ( (*FE)->xString ) - pSet->maString = *(*FE)->xString; - } - else + if ( nHyperLenLeft ) { - if ( (*FE)->nTextRangeEnd ) // text range hyperlink + // if the next portion is in a higher paragraph, + // the textrange is to decrease (because of the LineBreak character) + if ( aCharPropList.size() > ( nIdx + 1 ) ) { - sal_uInt32 nHyperLen = (*FE)->nTextRangeEnd - nPos; - if ( nHyperLen ) - { - PPTCharPropSet* pBefCPS = nullptr; - if ( nCount ) - { - pBefCPS = new PPTCharPropSet( *pSet ); - pSet->maString = pSet->maString.copy(nCount); - } - sal_uInt32 nIdx = n; - sal_Int32 nHyperLenLeft = nHyperLen; - - while ( ( aCharPropList.size() > nIdx ) && nHyperLenLeft ) - { - // the textrange hyperlink can take more than 1 paragraph - // the solution here is to clone the hyperlink... - - PPTCharPropSet* pCurrent = aCharPropList[ nIdx ].get(); - sal_Int32 nNextStringLen = pCurrent->maString.getLength(); - - DBG_ASSERT( (*FE)->xField1, "missing field!" ); - if (!(*FE)->xField1) - break; - - const SvxURLField* pField = static_cast<const SvxURLField*>((*FE)->xField1->GetField()); - - pCurrent->mbIsHyperlink = true; - pCurrent->mnHylinkOrigColor = pCurrent->mpImplPPTCharPropSet->mnColor; - pCurrent->mbHardHylinkOrigColor = ( ( pCurrent->mpImplPPTCharPropSet->mnAttrSet >>PPT_CharAttr_FontColor ) & 1)>0; - - // add missing attribute to show underline property - pCurrent->mpImplPPTCharPropSet->mnAttrSet |= 1 << PPT_CharAttr_Underline; - pCurrent->mpImplPPTCharPropSet->mnFlags = 1 << PPT_CharAttr_Underline; - - if ( pCurrent->mpFieldItem ) - { - pCurrent->SetColor( PPT_COLSCHEME_A_UND_HYPERLINK ); - if ( dynamic_cast< const SvxURLField* >(pCurrent->mpFieldItem->GetField()) != nullptr) - break; - nHyperLenLeft--; - } - else if ( nNextStringLen ) - { - if ( nNextStringLen <= nHyperLenLeft ) - { - pCurrent->mpFieldItem.reset( new SvxFieldItem( SvxURLField( pField->GetURL(), pCurrent->maString, SvxURLFormat::Repr ), EE_FEATURE_FIELD ) ); - nHyperLenLeft -= nNextStringLen; - - if ( nHyperLenLeft ) - { - // if the next portion is in a higher paragraph, - // the textrange is to decrease (because of the LineBreak character) - if ( aCharPropList.size() > ( nIdx + 1 ) ) - { - PPTCharPropSet* pNext = aCharPropList[ nIdx + 1 ].get(); - if ( pNext->mnParagraph > pCurrent->mnParagraph ) - nHyperLenLeft--; - } - } - } - else - { - PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pCurrent ); - pNewCPS->maString = pCurrent->maString.copy( nHyperLenLeft,( nNextStringLen - nHyperLenLeft ) ); - aCharPropList.emplace( aCharPropList.begin() + nIdx + 1, pNewCPS ); - OUString aRepresentation = pCurrent->maString.copy( 0, nHyperLenLeft ); - pCurrent->mpFieldItem.reset( new SvxFieldItem( SvxURLField( pField->GetURL(), aRepresentation, SvxURLFormat::Repr ), EE_FEATURE_FIELD ) ); - nHyperLenLeft = 0; - } - pCurrent->maString.clear(); - pCurrent->SetColor( PPT_COLSCHEME_A_UND_HYPERLINK ); - } - nIdx++; - } - (*FE)->xField1.reset(); - - if ( pBefCPS ) - { - pBefCPS->maString = aString.copy( 0, nCount ); - aCharPropList.emplace( aCharPropList.begin() + n, pBefCPS ); - n++; - } - } + PPTCharPropSet* pNext = aCharPropList[ nIdx + 1 ].get(); + if ( pNext->mnParagraph > pCurrent->mnParagraph ) + nHyperLenLeft--; } } - break; } + else + { + PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pCurrent ); + pNewCPS->maString = pCurrent->maString.copy( nHyperLenLeft,( nNextStringLen - nHyperLenLeft ) ); + aCharPropList.emplace( aCharPropList.begin() + nIdx + 1, pNewCPS ); + OUString aRepresentation = pCurrent->maString.copy( 0, nHyperLenLeft ); + pCurrent->mpFieldItem.reset( new SvxFieldItem( SvxURLField( pField->GetURL(), aRepresentation, SvxURLFormat::Repr ), EE_FEATURE_FIELD ) ); + nHyperLenLeft = 0; + } + pCurrent->maString.clear(); + pCurrent->SetColor( PPT_COLSCHEME_A_UND_HYPERLINK ); } - n--; + nIdx++; } - } - mxImplTextObj->maParagraphList.resize( nParagraphs ); - for (size_t nCurCharPos = 0, nCurPos = 0; - nCurPos < aStyleTextPropReader.aParaPropList.size(); - ++nCurPos) - { - mxImplTextObj->maParagraphList[ nCurPos ].reset( - new PPTParagraphObj( - aStyleTextPropReader, nCurPos, nCurCharPos, - *rSdrPowerPointImport.m_pPPTStyleSheet, - nInstance, aTextRulerInterpreter ) ); + (*FE)->xField1.reset(); - sal_uInt32 nParaAdjust, nFlags = 0; - mxImplTextObj->maParagraphList[ nCurPos ]->GetAttrib( PPT_ParaAttr_Adjust, nParaAdjust, GetInstance() ); - - switch ( nParaAdjust ) + if ( pBefCPS ) { - case 0 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT; break; - case 1 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER; break; - case 2 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT; break; - case 3 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK; break; + pBefCPS->maString = aString.copy( 0, nCount ); + aCharPropList.emplace( aCharPropList.begin() + n, pBefCPS ); + n++; } - mxImplTextObj->mnTextFlags |= nFlags; } } } + break; } } + n--; } } + mxImplTextObj->maParagraphList.resize( nParagraphs ); + for (size_t nCurCharPos = 0, nCurPos = 0; + nCurPos < aStyleTextPropReader.aParaPropList.size(); + ++nCurPos) + { + mxImplTextObj->maParagraphList[ nCurPos ].reset( + new PPTParagraphObj( + aStyleTextPropReader, nCurPos, nCurCharPos, + *rSdrPowerPointImport.m_pPPTStyleSheet, + nInstance, aTextRulerInterpreter ) ); + + sal_uInt32 nParaAdjust, nFlags = 0; + mxImplTextObj->maParagraphList[ nCurPos ]->GetAttrib( PPT_ParaAttr_Adjust, nParaAdjust, GetInstance() ); + + switch ( nParaAdjust ) + { + case 0 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT; break; + case 1 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER; break; + case 2 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT; break; + case 3 : nFlags = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK; break; + } + mxImplTextObj->mnTextFlags |= nFlags; + } } PPTTextObj::PPTTextObj( PPTTextObj const & rTextObj ) @@ -7186,19 +7186,19 @@ static void GetRowPositions( const tools::Rectangle& rSnapRect, const std::set< const std::set< sal_Int32 >& rColumns, std::vector< sal_Int32 >& rPositions, sal_Int32 nColumn, sal_Int32 nFlags ) { std::set< sal_Int32 >::const_iterator aRow( rRows.find( rSnapRect.Top() ) ); - if ( aRow != rRows.end() ) + if ( aRow == rRows.end() ) + return; + + sal_Int32 nRow = std::distance( rRows.begin(), aRow ); + while( ( aRow != rRows.end() ) && ((*aRow) < rSnapRect.Bottom() ) ) { - sal_Int32 nRow = std::distance( rRows.begin(), aRow ); - while( ( aRow != rRows.end() ) && ((*aRow) < rSnapRect.Bottom() ) ) - { - if ( nFlags & LinePositionLeft ) - rPositions.push_back( ( ( nRow * rColumns.size() ) + nColumn ) | LinePositionLeft ); - if ( nFlags & LinePositionRight ) - rPositions.push_back( ( ( nRow * rColumns.size() ) + ( nColumn - 1 ) ) | LinePositionRight ); + if ( nFlags & LinePositionLeft ) + rPositions.push_back( ( ( nRow * rColumns.size() ) + nColumn ) | LinePositionLeft ); + if ( nFlags & LinePositionRight ) + rPositions.push_back( ( ( nRow * rColumns.size() ) + ( nColumn - 1 ) ) | LinePositionRight ); - ++nRow; - ++aRow; - } + ++nRow; + ++aRow; } } @@ -7207,19 +7207,19 @@ static void GetColumnPositions( const tools::Rectangle& rSnapRect, const std::set< sal_Int32 >& rColumns, std::vector< sal_Int32 >& rPositions, sal_Int32 nRow, sal_Int32 nFlags ) { std::set< sal_Int32 >::const_iterator aColumn( rColumns.find( rSnapRect.Left() ) ); - if ( aColumn != rColumns.end() ) + if ( aColumn == rColumns.end() ) + return; + + sal_Int32 nColumn = std::distance( rColumns.begin(), aColumn ); + while( ( aColumn != rColumns.end() ) && ((*aColumn) < rSnapRect.Right() ) ) { - sal_Int32 nColumn = std::distance( rColumns.begin(), aColumn ); - while( ( aColumn != rColumns.end() ) && ((*aColumn) < rSnapRect.Right() ) ) - { - if ( nFlags & LinePositionTop ) - rPositions.push_back( ( ( nRow * rColumns.size() ) + nColumn ) | LinePositionTop ); - if ( nFlags & LinePositionBottom ) - rPositions.push_back( ( ( ( nRow - 1 ) * rColumns.size() ) + nColumn ) | LinePositionBottom ); + if ( nFlags & LinePositionTop ) + rPositions.push_back( ( ( nRow * rColumns.size() ) + nColumn ) | LinePositionTop ); + if ( nFlags & LinePositionBottom ) + rPositions.push_back( ( ( ( nRow - 1 ) * rColumns.size() ) + nColumn ) | LinePositionBottom ); - ++nColumn; - ++aColumn; - } + ++nColumn; + ++aColumn; } } diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx index af0d87c2a240..954e7d3a8c03 100644 --- a/filter/source/pdf/impdialog.cxx +++ b/filter/source/pdf/impdialog.cxx @@ -803,22 +803,22 @@ IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleWatermarkHdl, weld::ToggleButton&, v IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleAddStreamHdl, weld::ToggleButton&, void) { - if (mxCbAddStream->get_visible()) + if (!mxCbAddStream->get_visible()) + return; + + if( mxCbAddStream->get_active() ) { - if( mxCbAddStream->get_active() ) - { - mxRbAll->set_active(true); - mxRbRange->set_sensitive( false ); - mxRbSelection->set_sensitive( false ); - mxEdPages->set_sensitive( false ); - mxRbAll->set_sensitive( false ); - } - else - { - mxRbAll->set_sensitive(true); - mxRbRange->set_sensitive(true); - mxRbSelection->set_sensitive(true); - } + mxRbAll->set_active(true); + mxRbRange->set_sensitive( false ); + mxRbSelection->set_sensitive( false ); + mxEdPages->set_sensitive( false ); + mxRbAll->set_sensitive( false ); + } + else + { + mxRbAll->set_sensitive(true); + mxRbRange->set_sensitive(true); + mxRbSelection->set_sensitive(true); } } @@ -1535,37 +1535,37 @@ IMPL_LINK_NOARG(ImpPDFTabSigningPage, ClickmaPbSignCertSelect, weld::Button&, vo OUString aDescription; maSignCertificate = xSigner->chooseCertificate(aDescription); - if (maSignCertificate.is()) + if (!maSignCertificate.is()) + return; + + mxEdSignCert->set_text(maSignCertificate->getSubjectName()); + mxPbSignCertClear->set_sensitive(true); + mxEdSignLocation->set_sensitive(true); + mxEdSignPassword->set_sensitive(true); + mxEdSignContactInfo->set_sensitive(true); + mxEdSignReason->set_sensitive(true); + mxEdSignReason->set_text(aDescription); + + try { - mxEdSignCert->set_text(maSignCertificate->getSubjectName()); - mxPbSignCertClear->set_sensitive(true); - mxEdSignLocation->set_sensitive(true); - mxEdSignPassword->set_sensitive(true); - mxEdSignContactInfo->set_sensitive(true); - mxEdSignReason->set_sensitive(true); - mxEdSignReason->set_text(aDescription); - - try + std::optional<css::uno::Sequence<OUString>> aTSAURLs(officecfg::Office::Common::Security::Scripting::TSAURLs::get()); + if (aTSAURLs) { - std::optional<css::uno::Sequence<OUString>> aTSAURLs(officecfg::Office::Common::Security::Scripting::TSAURLs::get()); - if (aTSAURLs) + const css::uno::Sequence<OUString>& rTSAURLs = *aTSAURLs; + for (auto const& elem : rTSAURLs) { - const css::uno::Sequence<OUString>& rTSAURLs = *aTSAURLs; - for (auto const& elem : rTSAURLs) - { - mxLBSignTSA->append_text(elem); - } + mxLBSignTSA->append_text(elem); } } - catch (const uno::Exception &) - { - TOOLS_INFO_EXCEPTION("filter.pdf", "TSAURLsDialog::TSAURLsDialog()"); - } - - // If more than only the "None" entry is there, enable the ListBox - if (mxLBSignTSA->get_count() > 1) - mxLBSignTSA->set_sensitive(true); } + catch (const uno::Exception &) + { + TOOLS_INFO_EXCEPTION("filter.pdf", "TSAURLsDialog::TSAURLsDialog()"); + } + + // If more than only the "None" entry is there, enable the ListBox + if (mxLBSignTSA->get_count() > 1) + mxLBSignTSA->set_sensitive(true); } IMPL_LINK_NOARG(ImpPDFTabSigningPage, ClickmaPbSignCertClear, weld::Button&, void) diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index 758c7e786114..6e13beb96cd6 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -292,25 +292,25 @@ public: void PDFExportStreamDoc::write( const Reference< XOutputStream >& xStream ) { Reference< css::frame::XStorable > xStore( m_xSrcDoc, UNO_QUERY ); - if( xStore.is() ) + if( !xStore.is() ) + return; + + Sequence< beans::PropertyValue > aArgs( 2 + (m_aPreparedPassword.hasElements() ? 1 : 0) ); + aArgs.getArray()[0].Name = "FilterName"; + aArgs.getArray()[1].Name = "OutputStream"; + aArgs.getArray()[1].Value <<= xStream; + if( m_aPreparedPassword.hasElements() ) { - Sequence< beans::PropertyValue > aArgs( 2 + (m_aPreparedPassword.hasElements() ? 1 : 0) ); - aArgs.getArray()[0].Name = "FilterName"; - aArgs.getArray()[1].Name = "OutputStream"; - aArgs.getArray()[1].Value <<= xStream; - if( m_aPreparedPassword.hasElements() ) - { - aArgs.getArray()[2].Name = "EncryptionData"; - aArgs.getArray()[2].Value <<= m_aPreparedPassword; - } + aArgs.getArray()[2].Name = "EncryptionData"; + aArgs.getArray()[2].Value <<= m_aPreparedPassword; + } - try - { - xStore->storeToURL( "private:stream", aArgs ); - } - catch( const IOException& ) - { - } + try + { + xStore->storeToURL( "private:stream", aArgs ); + } + catch( const IOException& ) + { } } diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx index aa071ca37f50..556c3869fa77 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -948,38 +948,38 @@ void SVGFilter::implExportDocumentHeaderImpressOrDraw(sal_Int32 nDocX, sal_Int32 mpSVGDoc = new SvXMLElementExport( *mpSVGExport, XML_NAMESPACE_NONE, "svg", true, true ); // Create a ClipPath element that will be used for cutting bitmaps and other elements that could exceed the page margins. - if(!mbExportShapeSelection) + if(mbExportShapeSelection) + return; + + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", "ClipPathGroup" ); + SvXMLElementExport aDefsElem( *mpSVGExport, XML_NAMESPACE_NONE, "defs", true, true ); { - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", "ClipPathGroup" ); - SvXMLElementExport aDefsElem( *mpSVGExport, XML_NAMESPACE_NONE, "defs", true, true ); + msClipPathId = "presentation_clip_path"; + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", msClipPathId ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "clipPathUnits", "userSpaceOnUse" ); + SvXMLElementExport aClipPathElem( *mpSVGExport, XML_NAMESPACE_NONE, "clipPath", true, true ); { - msClipPathId = "presentation_clip_path"; - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", msClipPathId ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "clipPathUnits", "userSpaceOnUse" ); - SvXMLElementExport aClipPathElem( *mpSVGExport, XML_NAMESPACE_NONE, "clipPath", true, true ); - { - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "x", OUString::number( nDocX ) ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "y", OUString::number( nDocY ) ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "width", OUString::number( nDocWidth ) ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "height", OUString::number( nDocHeight ) ); - SvXMLElementExport aRectElem( *mpSVGExport, XML_NAMESPACE_NONE, "rect", true, true ); - } + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "x", OUString::number( nDocX ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "y", OUString::number( nDocY ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "width", OUString::number( nDocWidth ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "height", OUString::number( nDocHeight ) ); + SvXMLElementExport aRectElem( *mpSVGExport, XML_NAMESPACE_NONE, "rect", true, true ); } - // Create a ClipPath element applied to the leaving slide in order - // to avoid that slide borders are visible during transition + } + // Create a ClipPath element applied to the leaving slide in order + // to avoid that slide borders are visible during transition + { + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", "presentation_clip_path_shrink" ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "clipPathUnits", "userSpaceOnUse" ); + SvXMLElementExport aClipPathElem( *mpSVGExport, XML_NAMESPACE_NONE, "clipPath", true, true ); { - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", "presentation_clip_path_shrink" ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "clipPathUnits", "userSpaceOnUse" ); - SvXMLElementExport aClipPathElem( *mpSVGExport, XML_NAMESPACE_NONE, "clipPath", true, true ); - { - sal_Int32 nDocWidthExt = nDocWidth / 500; - sal_Int32 nDocHeightExt = nDocHeight / 500; - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "x", OUString::number( nDocX + nDocWidthExt / 2 ) ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "y", OUString::number( nDocY + nDocHeightExt / 2) ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "width", OUString::number( nDocWidth - nDocWidthExt ) ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "height", OUString::number( nDocHeight - nDocHeightExt ) ); - SvXMLElementExport aRectElem( *mpSVGExport, XML_NAMESPACE_NONE, "rect", true, true ); - } + sal_Int32 nDocWidthExt = nDocWidth / 500; + sal_Int32 nDocHeightExt = nDocHeight / 500; + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "x", OUString::number( nDocX + nDocWidthExt / 2 ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "y", OUString::number( nDocY + nDocHeightExt / 2) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "width", OUString::number( nDocWidth - nDocWidthExt ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "height", OUString::number( nDocHeight - nDocHeightExt ) ); + SvXMLElementExport aRectElem( *mpSVGExport, XML_NAMESPACE_NONE, "rect", true, true ); } } } @@ -1048,229 +1048,229 @@ static OUString implGenerateFieldId( std::vector< std::unique_ptr<TextField> > & void SVGFilter::implGenerateMetaData() { sal_Int32 nCount = mSelectedPages.size(); - if( nCount != 0 ) + if( nCount == 0 ) + return; + + // we wrap all meta presentation info into a svg:defs element + SvXMLElementExport aDefsElem( *mpSVGExport, XML_NAMESPACE_NONE, "defs", true, true ); + + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", NSPREFIX "meta_slides" ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, NSPREFIX "number-of-slides", OUString::number( nCount ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, NSPREFIX "start-slide-number", OUString::number( mnVisiblePage ) ); + + if( mpSVGExport->IsUsePositionedCharacters() ) { - // we wrap all meta presentation info into a svg:defs element - SvXMLElementExport aDefsElem( *mpSVGExport, XML_NAMESPACE_NONE, "defs", true, true ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, NSPREFIX "use-positioned-chars", "true" ); + } - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", NSPREFIX "meta_slides" ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, NSPREFIX "number-of-slides", OUString::number( nCount ) ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, NSPREFIX "start-slide-number", OUString::number( mnVisiblePage ) ); + // Add a (global) Page Numbering Type attribute for the document + // NOTE: at present pSdrModel->GetPageNumType() returns always css::style::NumberingType::ARABIC + // so the following code fragment is pretty useless + sal_Int32 nPageNumberingType = css::style::NumberingType::ARABIC; + SvxDrawPage* pSvxDrawPage = comphelper::getUnoTunnelImplementation<SvxDrawPage>( mSelectedPages[0] ); + if( pSvxDrawPage ) + { + SdrPage* pSdrPage = pSvxDrawPage->GetSdrPage(); + SdrModel& rSdrModel(pSdrPage->getSdrModelFromSdrPage()); + nPageNumberingType = rSdrModel.GetPageNumType(); - if( mpSVGExport->IsUsePositionedCharacters() ) + // That is used by CalcFieldHdl method. + mVisiblePagePropSet.nPageNumberingType = nPageNumberingType; + } + if( nPageNumberingType != css::style::NumberingType::NUMBER_NONE ) + { + OUString sNumberingType; + switch( nPageNumberingType ) { - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, NSPREFIX "use-positioned-chars", "true" ); + case css::style::NumberingType::CHARS_UPPER_LETTER: + sNumberingType = "alpha-upper"; + break; + case css::style::NumberingType::CHARS_LOWER_LETTER: + sNumberingType = "alpha-lower"; + break; + case css::style::NumberingType::ROMAN_UPPER: + sNumberingType = "roman-upper"; + break; + case css::style::NumberingType::ROMAN_LOWER: + sNumberingType = "roman-lower"; + break; + case css::style::NumberingType::ARABIC: + // arabic numbering type is the default, so we do not append any attribute for it + default: + // in case the numbering type is not handled we fall back on arabic numbering + break; } + if( !sNumberingType.isEmpty() ) + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, NSPREFIX "page-numbering-type", sNumberingType ); + } - // Add a (global) Page Numbering Type attribute for the document - // NOTE: at present pSdrModel->GetPageNumType() returns always css::style::NumberingType::ARABIC - // so the following code fragment is pretty useless - sal_Int32 nPageNumberingType = css::style::NumberingType::ARABIC; - SvxDrawPage* pSvxDrawPage = comphelper::getUnoTunnelImplementation<SvxDrawPage>( mSelectedPages[0] ); - if( pSvxDrawPage ) - { - SdrPage* pSdrPage = pSvxDrawPage->GetSdrPage(); - SdrModel& rSdrModel(pSdrPage->getSdrModelFromSdrPage()); - nPageNumberingType = rSdrModel.GetPageNumType(); - // That is used by CalcFieldHdl method. - mVisiblePagePropSet.nPageNumberingType = nPageNumberingType; - } - if( nPageNumberingType != css::style::NumberingType::NUMBER_NONE ) + { + SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true ); + const OUString aId( NSPREFIX "meta_slide" ); + const OUString aElemTextFieldId( aOOOElemTextField ); + std::vector< std::unique_ptr<TextField> > aFieldSet; + + // dummy slide - used as leaving slide for transition on the first slide + if( mbPresentation ) { - OUString sNumberingType; - switch( nPageNumberingType ) - { - case css::style::NumberingType::CHARS_UPPER_LETTER: - sNumberingType = "alpha-upper"; - break; - case css::style::NumberingType::CHARS_LOWER_LETTER: - sNumberingType = "alpha-lower"; - break; - case css::style::NumberingType::ROMAN_UPPER: - sNumberingType = "roman-upper"; - break; - case css::style::NumberingType::ROMAN_LOWER: - sNumberingType = "roman-lower"; - break; - case css::style::NumberingType::ARABIC: - // arabic numbering type is the default, so we do not append any attribute for it - default: - // in case the numbering type is not handled we fall back on arabic numbering - break; - } - if( !sNumberingType.isEmpty() ) - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, NSPREFIX "page-numbering-type", sNumberingType ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", NSPREFIX "meta_dummy_slide" ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrSlide, "dummy-slide" ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrMaster, "dummy-master-page" ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrBackgroundVisibility, "hidden" ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrMasterObjectsVisibility, "hidden" ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrHasTransition, "false" ); + SvXMLElementExport aMetaDummySlideElem( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true ); } - + for( sal_Int32 i = 0; i < nCount; ++i ) { - SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true ); - const OUString aId( NSPREFIX "meta_slide" ); - const OUString aElemTextFieldId( aOOOElemTextField ); - std::vector< std::unique_ptr<TextField> > aFieldSet; - - // dummy slide - used as leaving slide for transition on the first slide - if( mbPresentation ) - { - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", NSPREFIX "meta_dummy_slide" ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrSlide, "dummy-slide" ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrMaster, "dummy-master-page" ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrBackgroundVisibility, "hidden" ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrMasterObjectsVisibility, "hidden" ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrHasTransition, "false" ); - SvXMLElementExport aMetaDummySlideElem( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true ); - } + const Reference< css::drawing::XDrawPage > & xDrawPage = mSelectedPages[i]; + Reference< css::drawing::XMasterPageTarget > xMasterPageTarget( xDrawPage, UNO_QUERY ); + Reference< css::drawing::XDrawPage > xMasterPage = xMasterPageTarget->getMasterPage(); + OUString aSlideId(aId + "_" + OUString::number( i )); - for( sal_Int32 i = 0; i < nCount; ++i ) - { - const Reference< css::drawing::XDrawPage > & xDrawPage = mSelectedPages[i]; - Reference< css::drawing::XMasterPageTarget > xMasterPageTarget( xDrawPage, UNO_QUERY ); - Reference< css::drawing::XDrawPage > xMasterPage = xMasterPageTarget->getMasterPage(); - OUString aSlideId(aId + "_" + OUString::number( i )); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aSlideId ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrSlide, implGetValidIDFromInterface( xDrawPage ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrMaster, implGetValidIDFromInterface( xMasterPage ) ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aSlideId ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrSlide, implGetValidIDFromInterface( xDrawPage ) ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrMaster, implGetValidIDFromInterface( xMasterPage ) ); + if( mbPresentation ) + { + Reference< XPropertySet > xPropSet( xDrawPage, UNO_QUERY ); - if( mbPresentation ) + if( xPropSet.is() ) { - Reference< XPropertySet > xPropSet( xDrawPage, UNO_QUERY ); - - if( xPropSet.is() ) + bool bBackgroundVisibility = true; // default: visible + bool bBackgroundObjectsVisibility = true; // default: visible + + FixedDateTimeField aFixedDateTimeField; + VariableDateTimeField aVariableDateTimeField; + FooterField aFooterField; + + xPropSet->getPropertyValue( "IsBackgroundVisible" ) >>= bBackgroundVisibility; + // in case the attribute is set to its default value it is not appended to the meta-slide element + if( !bBackgroundVisibility ) // visibility default value: 'visible' + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrBackgroundVisibility, "hidden" ); + + // Page Number, Date/Time, Footer and Header Fields are regarded as background objects. + // So bBackgroundObjectsVisibility overrides visibility of master page text fields. + xPropSet->getPropertyValue( "IsBackgroundObjectsVisible" ) >>= bBackgroundObjectsVisibility; + if( bBackgroundObjectsVisibility ) // visibility default value: 'visible' { - bool bBackgroundVisibility = true; // default: visible - bool bBackgroundObjectsVisibility = true; // default: visible - - FixedDateTimeField aFixedDateTimeField; - VariableDateTimeField aVariableDateTimeField; - FooterField aFooterField; - - xPropSet->getPropertyValue( "IsBackgroundVisible" ) >>= bBackgroundVisibility; - // in case the attribute is set to its default value it is not appended to the meta-slide element - if( !bBackgroundVisibility ) // visibility default value: 'visible' - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrBackgroundVisibility, "hidden" ); - - // Page Number, Date/Time, Footer and Header Fields are regarded as background objects. - // So bBackgroundObjectsVisibility overrides visibility of master page text fields. - xPropSet->getPropertyValue( "IsBackgroundObjectsVisible" ) >>= bBackgroundObjectsVisibility; - if( bBackgroundObjectsVisibility ) // visibility default value: 'visible' + bool bPageNumberVisibility = false; // default: hidden + bool bDateTimeVisibility = true; // default: visible + bool bFooterVisibility = true; // default: visible + + // Page Number Field + xPropSet->getPropertyValue( "IsPageNumberVisible" ) >>= bPageNumberVisibility; + bPageNumberVisibility = bPageNumberVisibility && ( nPageNumberingType != css::style::NumberingType::NUMBER_NONE ); + if( bPageNumberVisibility ) // visibility default value: 'hidden' { - bool bPageNumberVisibility = false; // default: hidden - bool bDateTimeVisibility = true; // default: visible - bool bFooterVisibility = true; // default: visible - - // Page Number Field - xPropSet->getPropertyValue( "IsPageNumberVisible" ) >>= bPageNumberVisibility; - bPageNumberVisibility = bPageNumberVisibility && ( nPageNumberingType != css::style::NumberingType::NUMBER_NONE ); - if( bPageNumberVisibility ) // visibility default value: 'hidden' - { - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, NSPREFIX "page-number-visibility", "visible" ); - } + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, NSPREFIX "page-number-visibility", "visible" ); + } - // Date/Time Field - xPropSet->getPropertyValue( "IsDateTimeVisible" ) >>= bDateTimeVisibility; - if( bDateTimeVisibility ) // visibility default value: 'visible' + // Date/Time Field + xPropSet->getPropertyValue( "IsDateTimeVisible" ) >>= bDateTimeVisibility; + if( bDateTimeVisibility ) // visibility default value: 'visible' + { + bool bDateTimeFixed = true; // default: fixed + xPropSet->getPropertyValue( "IsDateTimeFixed" ) >>= bDateTimeFixed; + if( bDateTimeFixed ) // we are interested only in the field text not in the date/time format { - bool bDateTimeFixed = true; // default: fixed - xPropSet->getPropertyValue( "IsDateTimeFixed" ) >>= bDateTimeFixed; - if( bDateTimeFixed ) // we are interested only in the field text not in the date/time format + xPropSet->getPropertyValue( "DateTimeText" ) >>= aFixedDateTimeField.text; + if( !aFixedDateTimeField.text.isEmpty() ) { - xPropSet->getPropertyValue( "DateTimeText" ) >>= aFixedDateTimeField.text; - if( !aFixedDateTimeField.text.isEmpty() ) - { - OUString sFieldId = implGenerateFieldId( aFieldSet, aFixedDateTimeField, aElemTextFieldId, xMasterPage ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrDateTimeField, sFieldId ); - } - } - else // the inverse applies: we are interested only in the date/time format not in the field text - { - xPropSet->getPropertyValue( "DateTimeFormat" ) >>= aVariableDateTimeField.format; - OUString sFieldId = implGenerateFieldId( aFieldSet, aVariableDateTimeField, aElemTextFieldId, xMasterPage ); + OUString sFieldId = implGenerateFieldId( aFieldSet, aFixedDateTimeField, aElemTextFieldId, xMasterPage ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrDateTimeField, sFieldId ); } } - else + else // the inverse applies: we are interested only in the date/time format not in the field text { - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, NSPREFIX "date-time-visibility", "hidden" ); + xPropSet->getPropertyValue( "DateTimeFormat" ) >>= aVariableDateTimeField.format; + OUString sFieldId = implGenerateFieldId( aFieldSet, aVariableDateTimeField, aElemTextFieldId, xMasterPage ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrDateTimeField, sFieldId ); } + } + else + { + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, NSPREFIX "date-time-visibility", "hidden" ); + } - // Footer Field - xPropSet->getPropertyValue( "IsFooterVisible" ) >>= bFooterVisibility; - if( bFooterVisibility ) // visibility default value: 'visible' - { - xPropSet->getPropertyValue( "FooterText" ) >>= aFooterField.text; - if( !aFooterField.text.isEmpty() ) - { - OUString sFieldId = implGenerateFieldId( aFieldSet, aFooterField, aElemTextFieldId, xMasterPage ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrFooterField, sFieldId ); - } - } - else + // Footer Field + xPropSet->getPropertyValue( "IsFooterVisible" ) >>= bFooterVisibility; + if( bFooterVisibility ) // visibility default value: 'visible' + { + xPropSet->getPropertyValue( "FooterText" ) >>= aFooterField.text; + if( !aFooterField.text.isEmpty() ) { - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, NSPREFIX "footer-visibility", "hidden" ); + OUString sFieldId = implGenerateFieldId( aFieldSet, aFooterField, aElemTextFieldId, xMasterPage ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrFooterField, sFieldId ); } } else { - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrMasterObjectsVisibility, "hidden" ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, NSPREFIX "footer-visibility", "hidden" ); } + } + else + { + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrMasterObjectsVisibility, "hidden" ); + } - sal_Int32 nChange(0); - double fSlideDuration(0); + sal_Int32 nChange(0); + double fSlideDuration(0); - if( xPropSet->getPropertySetInfo()->hasPropertyByName( "Change" ) && - (xPropSet->getPropertyValue( "Change" ) >>= nChange ) && nChange == 1 ) + if( xPropSet->getPropertySetInfo()->hasPropertyByName( "Change" ) && + (xPropSet->getPropertyValue( "Change" ) >>= nChange ) && nChange == 1 ) + { + if( xPropSet->getPropertySetInfo()->hasPropertyByName( "HighResDuration" ) && + (xPropSet->getPropertyValue( "HighResDuration" ) >>= fSlideDuration) ) { - if( xPropSet->getPropertySetInfo()->hasPropertyByName( "HighResDuration" ) && - (xPropSet->getPropertyValue( "HighResDuration" ) >>= fSlideDuration) ) - { - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrSlideDuration, OUString::number(fSlideDuration) ); - } + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrSlideDuration, OUString::number(fSlideDuration) ); } - // We look for a slide transition. - // Transition properties are exported together with animations. - sal_Int16 nTransitionType(0); - if( xPropSet->getPropertySetInfo()->hasPropertyByName( "TransitionType" ) && - (xPropSet->getPropertyValue( "TransitionType" ) >>= nTransitionType) ) + } + // We look for a slide transition. + // Transition properties are exported together with animations. + sal_Int16 nTransitionType(0); + if( xPropSet->getPropertySetInfo()->hasPropertyByName( "TransitionType" ) && + (xPropSet->getPropertyValue( "TransitionType" ) >>= nTransitionType) ) + { + sal_Int16 nTransitionSubType(0); + if( xPropSet->getPropertyValue( "TransitionSubtype" ) >>= nTransitionSubType ) { - sal_Int16 nTransitionSubType(0); - if( xPropSet->getPropertyValue( "TransitionSubtype" ) >>= nTransitionSubType ) - { - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrHasTransition, "true" ); - } + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrHasTransition, "true" ); } - } - } - { - SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true ); - } // when the aExp2 destructor is called the </g> tag is appended to the output file + } } - // export text field elements - if( mbPresentation ) { - for( sal_Int32 i = 0, nSize = aFieldSet.size(); i < nSize; ++i ) - { - OUString sElemId = OUStringLiteral(aOOOElemTextField) + "_" + OUString::number( i ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", sElemId ); - aFieldSet[i]->elementExport( mpSVGExport ); - } - if( mpSVGExport->IsEmbedFonts() && mpSVGExport->IsUsePositionedCharacters() ) + SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true ); + } // when the aExp2 destructor is called the </g> tag is appended to the output file + } + + // export text field elements + if( mbPresentation ) + { + for( sal_Int32 i = 0, nSize = aFieldSet.size(); i < nSize; ++i ) + { + OUString sElemId = OUStringLiteral(aOOOElemTextField) + "_" + OUString::number( i ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", sElemId ); + aFieldSet[i]->elementExport( mpSVGExport ); + } + if( mpSVGExport->IsEmbedFonts() && mpSVGExport->IsUsePositionedCharacters() ) + { + for(const std::unique_ptr<TextField>& i : aFieldSet) { - for(const std::unique_ptr<TextField>& i : aFieldSet) - { - i->growCharSet( mTextFieldCharSets ); - } + i->growCharSet( mTextFieldCharSets ); } } - - // text fields are used only for generating meta info so we don't need them anymore - aFieldSet.clear(); } + + // text fields are used only for generating meta info so we don't need them anymore + aFieldSet.clear(); } } @@ -1524,33 +1524,33 @@ void SVGFilter::implGetPagePropSet( const Reference< css::drawing::XDrawPage > & // We collect info on master page elements visibility, and placeholder text shape content. Reference< XPropertySet > xPropSet( rxPage, UNO_QUERY ); - if( xPropSet.is() ) + if( !xPropSet.is() ) + return; + + Reference< XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); + if( !xPropSetInfo.is() ) + return; + + implSafeGetPagePropSet( "IsBackgroundVisible", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bIsBackgroundVisible; + implSafeGetPagePropSet( "IsBackgroundObjectsVisible", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bAreBackgroundObjectsVisible; + implSafeGetPagePropSet( "IsPageNumberVisible", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bIsPageNumberFieldVisible; + implSafeGetPagePropSet( "IsHeaderVisible", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bIsHeaderFieldVisible; + implSafeGetPagePropSet( "IsFooterVisible", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bIsFooterFieldVisible; + implSafeGetPagePropSet( "IsDateTimeVisible", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bIsDateTimeFieldVisible; + + implSafeGetPagePropSet( "IsDateTimeFixed", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bIsDateTimeFieldFixed; + sal_Int32 nTmp; + if (implSafeGetPagePropSet( "DateTimeFormat", xPropSet, xPropSetInfo ) >>= nTmp) + mVisiblePagePropSet.nDateTimeFormat = static_cast<SvxDateFormat>(nTmp); + + if( mVisiblePagePropSet.bIsPageNumberFieldVisible ) { - Reference< XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); - if( xPropSetInfo.is() ) + SvxDrawPage* pSvxDrawPage = comphelper::getUnoTunnelImplementation<SvxDrawPage>( rxPage ); + if( pSvxDrawPage ) { - implSafeGetPagePropSet( "IsBackgroundVisible", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bIsBackgroundVisible; - implSafeGetPagePropSet( "IsBackgroundObjectsVisible", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bAreBackgroundObjectsVisible; - implSafeGetPagePropSet( "IsPageNumberVisible", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bIsPageNumberFieldVisible; - implSafeGetPagePropSet( "IsHeaderVisible", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bIsHeaderFieldVisible; - implSafeGetPagePropSet( "IsFooterVisible", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bIsFooterFieldVisible; - implSafeGetPagePropSet( "IsDateTimeVisible", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bIsDateTimeFieldVisible; - - implSafeGetPagePropSet( "IsDateTimeFixed", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bIsDateTimeFieldFixed; - sal_Int32 nTmp; - if (implSafeGetPagePropSet( "DateTimeFormat", xPropSet, xPropSetInfo ) >>= nTmp) - mVisiblePagePropSet.nDateTimeFormat = static_cast<SvxDateFormat>(nTmp); - - if( mVisiblePagePropSet.bIsPageNumberFieldVisible ) - { - SvxDrawPage* pSvxDrawPage = comphelper::getUnoTunnelImplementation<SvxDrawPage>( rxPage ); - if( pSvxDrawPage ) - { - SdrPage* pSdrPage = pSvxDrawPage->GetSdrPage(); - SdrModel& rSdrModel(pSdrPage->getSdrModelFromSdrPage()); - mVisiblePagePropSet.nPageNumberingType = rSdrModel.GetPageNumType(); - } - } + SdrPage* pSdrPage = pSvxDrawPage->GetSdrPage(); + SdrModel& rSdrModel(pSdrPage->getSdrModelFromSdrPage()); + mVisiblePagePropSet.nPageNumberingType = rSdrModel.GetPageNumType(); } } } diff --git a/filter/source/svg/svgfontexport.cxx b/filter/source/svg/svgfontexport.cxx index 40e4207a1a0d..bab7cf823b64 100644 --- a/filter/source/svg/svgfontexport.cxx +++ b/filter/source/svg/svgfontexport.cxx @@ -173,78 +173,78 @@ void SVGFontExport::implCollectGlyphs() void SVGFontExport::implEmbedFont( const vcl::Font& rFont ) { - if( mrExport.IsEmbedFonts() ) - { - GlyphSet& rGlyphSet = implGetGlyphSet( rFont ); + if( !mrExport.IsEmbedFonts() ) + return; - if( !rGlyphSet.empty() ) - { - const OUString aEmbeddedFontStr( "EmbeddedFont_" ); + GlyphSet& rGlyphSet = implGetGlyphSet( rFont ); - { - SvXMLElementExport aExp( mrExport, XML_NAMESPACE_NONE, "defs", true, true ); - OUString aCurIdStr( aEmbeddedFontStr ); - OUString aUnitsPerEM( OUString::number( nFontEM ) ); - ScopedVclPtrInstance< VirtualDevice > pVDev; - vcl::Font aFont( rFont ); + if( rGlyphSet.empty() ) + return; - aFont.SetFontSize( Size( 0, nFontEM ) ); - aFont.SetAlignment( ALIGN_BASELINE ); + const OUString aEmbeddedFontStr( "EmbeddedFont_" ); - pVDev->SetMapMode(MapMode(MapUnit::Map100thMM)); - pVDev->SetFont( aFont ); + { + SvXMLElementExport aExp( mrExport, XML_NAMESPACE_NONE, "defs", true, true ); + OUString aCurIdStr( aEmbeddedFontStr ); + OUString aUnitsPerEM( OUString::number( nFontEM ) ); + ScopedVclPtrInstance< VirtualDevice > pVDev; + vcl::Font aFont( rFont ); - aCurIdStr += OUString::number( ++mnCurFontId ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", aCurIdStr ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", aUnitsPerEM ); + aFont.SetFontSize( Size( 0, nFontEM ) ); + aFont.SetAlignment( ALIGN_BASELINE ); - { - SvXMLElementExport aExp2( mrExport, XML_NAMESPACE_NONE, "font", true, true ); - OUString aFontWeight; - OUString aFontStyle; - const Size aSize( nFontEM, nFontEM ); - - // Font Weight - if( aFont.GetWeight() != WEIGHT_NORMAL ) - aFontWeight = "bold"; - else - aFontWeight = "normal"; + pVDev->SetMapMode(MapMode(MapUnit::Map100thMM)); + pVDev->SetFont( aFont ); - // Font Italic - if( aFont.GetItalic() != ITALIC_NONE ) - aFontStyle = "italic"; - else - aFontStyle = "normal"; + aCurIdStr += OUString::number( ++mnCurFontId ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", aCurIdStr ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", aUnitsPerEM ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "font-family", GetMappedFontName( rFont.GetFamilyName() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "units-per-em", aUnitsPerEM ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "font-weight", aFontWeight ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "font-style", aFontStyle ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "ascent", OUString::number( pVDev->GetFontMetric().GetAscent() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "descent", OUString::number( pVDev->GetFontMetric().GetDescent() ) ); + { + SvXMLElementExport aExp2( mrExport, XML_NAMESPACE_NONE, "font", true, true ); + OUString aFontWeight; + OUString aFontStyle; + const Size aSize( nFontEM, nFontEM ); + + // Font Weight + if( aFont.GetWeight() != WEIGHT_NORMAL ) + aFontWeight = "bold"; + else + aFontWeight = "normal"; + + // Font Italic + if( aFont.GetItalic() != ITALIC_NONE ) + aFontStyle = "italic"; + else + aFontStyle = "normal"; + + mrExport.AddAttribute( XML_NAMESPACE_NONE, "font-family", GetMappedFontName( rFont.GetFamilyName() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "units-per-em", aUnitsPerEM ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "font-weight", aFontWeight ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "font-style", aFontStyle ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "ascent", OUString::number( pVDev->GetFontMetric().GetAscent() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "descent", OUString::number( pVDev->GetFontMetric().GetDescent() ) ); - { - SvXMLElementExport aExp3( mrExport, XML_NAMESPACE_NONE, "font-face", true, true ); - } + { + SvXMLElementExport aExp3( mrExport, XML_NAMESPACE_NONE, "font-face", true, true ); + } - mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", OUString::number( aSize.Width() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", OUString::number( aSize.Width() ) ); - { - const Point aPos; - const tools::PolyPolygon aMissingGlyphPolyPoly( tools::Rectangle( aPos, aSize ) ); + { + const Point aPos; + const tools::PolyPolygon aMissingGlyphPolyPoly( tools::Rectangle( aPos, aSize ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "d", SVGActionWriter::GetPathString( aMissingGlyphPolyPoly, false ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "d", SVGActionWriter::GetPathString( aMissingGlyphPolyPoly, false ) ); - { - SvXMLElementExport aExp4( mrExport, XML_NAMESPACE_NONE, "missing-glyph", true, true ); - } - } - for (auto const& glyph : rGlyphSet) - { - implEmbedGlyph( *pVDev, glyph); - } + { + SvXMLElementExport aExp4( mrExport, XML_NAMESPACE_NONE, "missing-glyph", true, true ); } } + for (auto const& glyph : rGlyphSet) + { + implEmbedGlyph( *pVDev, glyph); + } } } } @@ -255,31 +255,31 @@ void SVGFontExport::implEmbedGlyph( OutputDevice const & rOut, const OUString& r tools::PolyPolygon aPolyPoly; const sal_Unicode nSpace = ' '; - if( rOut.GetTextOutline( aPolyPoly, rCellStr ) ) - { - tools::Rectangle aBoundRect; + if( !rOut.GetTextOutline( aPolyPoly, rCellStr ) ) + return; - aPolyPoly.Scale( 1.0, -1.0 ); + tools::Rectangle aBoundRect; - if( !rOut.GetTextBoundRect( aBoundRect, rCellStr ) ) - aBoundRect = tools::Rectangle( Point( 0, 0 ), Size( rOut.GetTextWidth( rCellStr ), 0 ) ); + aPolyPoly.Scale( 1.0, -1.0 ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "unicode", rCellStr ); + if( !rOut.GetTextBoundRect( aBoundRect, rCellStr ) ) + aBoundRect = tools::Rectangle( Point( 0, 0 ), Size( rOut.GetTextWidth( rCellStr ), 0 ) ); - if( rCellStr[ 0 ] == nSpace && rCellStr.getLength() == 1 ) - aBoundRect = tools::Rectangle( Point( 0, 0 ), Size( rOut.GetTextWidth( OUString(' ') ), 0 ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "unicode", rCellStr ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", OUString::number( aBoundRect.GetWidth() ) ); + if( rCellStr[ 0 ] == nSpace && rCellStr.getLength() == 1 ) + aBoundRect = tools::Rectangle( Point( 0, 0 ), Size( rOut.GetTextWidth( OUString(' ') ), 0 ) ); - const OUString aPathString( SVGActionWriter::GetPathString( aPolyPoly, false ) ); - if( !aPathString.isEmpty() ) - { - mrExport.AddAttribute( XML_NAMESPACE_NONE, "d", aPathString ); - } + mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", OUString::number( aBoundRect.GetWidth() ) ); - { - SvXMLElementExport aExp( mrExport, XML_NAMESPACE_NONE, "glyph", true, true ); - } + const OUString aPathString( SVGActionWriter::GetPathString( aPolyPoly, false ) ); + if( !aPathString.isEmpty() ) + { + mrExport.AddAttribute( XML_NAMESPACE_NONE, "d", aPathString ); + } + + { + SvXMLElementExport aExp( mrExport, XML_NAMESPACE_NONE, "glyph", true, true ); } } diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index c276fd903048..a55dec5b07f2 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -338,69 +338,69 @@ void SVGAttributeWriter::SetFontAttr( const vcl::Font& rFont ) { vcl::Font& rCurFont = mrCurrentState.aFont; - if( rFont != rCurFont ) - { - OUString aFontStyle, aTextDecoration; - sal_Int32 nFontWeight; + if( rFont == rCurFont ) + return; - rCurFont = rFont; + OUString aFontStyle, aTextDecoration; + sal_Int32 nFontWeight; - // Font Family - setFontFamily(); + rCurFont = rFont; - // Font Size - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontSize, - OUString::number( rFont.GetFontHeight() ) + "px" ); + // Font Family + setFontFamily(); - // Font Style - if( rFont.GetItalic() != ITALIC_NONE ) - { - if( rFont.GetItalic() == ITALIC_OBLIQUE ) - aFontStyle = "oblique"; - else - aFontStyle = "italic"; - } + // Font Size + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontSize, + OUString::number( rFont.GetFontHeight() ) + "px" ); + + // Font Style + if( rFont.GetItalic() != ITALIC_NONE ) + { + if( rFont.GetItalic() == ITALIC_OBLIQUE ) + aFontStyle = "oblique"; else - aFontStyle = "normal"; + aFontStyle = "italic"; + } + else + aFontStyle = "normal"; - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontStyle, aFontStyle ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontStyle, aFontStyle ); - // Font Weight - switch( rFont.GetWeight() ) - { - case WEIGHT_THIN: nFontWeight = 100; break; - case WEIGHT_ULTRALIGHT: nFontWeight = 200; break; - case WEIGHT_LIGHT: nFontWeight = 300; break; - case WEIGHT_SEMILIGHT: nFontWeight = 400; break; - case WEIGHT_NORMAL: nFontWeight = 400; break; - case WEIGHT_MEDIUM: nFontWeight = 500; break; - case WEIGHT_SEMIBOLD: nFontWeight = 600; break; - case WEIGHT_BOLD: nFontWeight = 700; break; - case WEIGHT_ULTRABOLD: nFontWeight = 800; break; - case WEIGHT_BLACK: nFontWeight = 900; break; - default: nFontWeight = 400; break; - } + // Font Weight + switch( rFont.GetWeight() ) + { + case WEIGHT_THIN: nFontWeight = 100; break; + case WEIGHT_ULTRALIGHT: nFontWeight = 200; break; + case WEIGHT_LIGHT: nFontWeight = 300; break; + case WEIGHT_SEMILIGHT: nFontWeight = 400; break; + case WEIGHT_NORMAL: nFontWeight = 400; break; + case WEIGHT_MEDIUM: nFontWeight = 500; break; + case WEIGHT_SEMIBOLD: nFontWeight = 600; break; + case WEIGHT_BOLD: nFontWeight = 700; break; + case WEIGHT_ULTRABOLD: nFontWeight = 800; break; + case WEIGHT_BLACK: nFontWeight = 900; break; + default: nFontWeight = 400; break; + } - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontWeight, OUString::number( nFontWeight ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontWeight, OUString::number( nFontWeight ) ); - if( mrExport.IsUseNativeTextDecoration() ) + if( mrExport.IsUseNativeTextDecoration() ) + { + if( rFont.GetUnderline() != LINESTYLE_NONE || rFont.GetStrikeout() != STRIKEOUT_NONE ) { - if( rFont.GetUnderline() != LINESTYLE_NONE || rFont.GetStrikeout() != STRIKEOUT_NONE ) - { - if( rFont.GetUnderline() != LINESTYLE_NONE ) - aTextDecoration = "underline "; - - if( rFont.GetStrikeout() != STRIKEOUT_NONE ) - aTextDecoration += "line-through "; - } - else - aTextDecoration = "none"; + if( rFont.GetUnderline() != LINESTYLE_NONE ) + aTextDecoration = "underline "; - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTextDecoration, aTextDecoration ); + if( rFont.GetStrikeout() != STRIKEOUT_NONE ) + aTextDecoration += "line-through "; } + else + aTextDecoration = "none"; - startFontSettings(); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTextDecoration, aTextDecoration ); } + + startFontSettings(); } @@ -787,114 +787,113 @@ void SVGTextWriter::addFontAttributes( bool bIsTextContainer ) { implSetCurrentFont(); - if( maCurrentFont != maParentFont ) - { - const OUString& rsCurFontName = maCurrentFont.GetFamilyName(); - long int nCurFontSize = maCurrentFont.GetFontHeight(); - FontItalic eCurFontItalic = maCurrentFont.GetItalic(); - FontWeight eCurFontWeight = maCurrentFont.GetWeight(); + if( maCurrentFont == maParentFont ) + return; - const OUString& rsParFontName = maParentFont.GetFamilyName(); - long int nParFontSize = maParentFont.GetFontHeight(); - FontItalic eParFontItalic = maParentFont.GetItalic(); - FontWeight eParFontWeight = maParentFont.GetWeight(); + const OUString& rsCurFontName = maCurrentFont.GetFamilyName(); + long int nCurFontSize = maCurrentFont.GetFontHeight(); + FontItalic eCurFontItalic = maCurrentFont.GetItalic(); + FontWeight eCurFontWeight = maCurrentFont.GetWeight(); + const OUString& rsParFontName = maParentFont.GetFamilyName(); + long int nParFontSize = maParentFont.GetFontHeight(); + FontItalic eParFontItalic = maParentFont.GetItalic(); + FontWeight eParFontWeight = maParentFont.GetWeight(); - // Font Family - if( rsCurFontName != rsParFontName ) - { - implSetFontFamily(); - } - // Font Size - if( nCurFontSize != nParFontSize ) - { - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontSize, - OUString::number( nCurFontSize ) + "px" ); - } + // Font Family + if( rsCurFontName != rsParFontName ) + { + implSetFontFamily(); + } - // Font Style - if( eCurFontItalic != eParFontItalic ) + // Font Size + if( nCurFontSize != nParFontSize ) + { + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontSize, + OUString::number( nCurFontSize ) + "px" ); + } + + // Font Style + if( eCurFontItalic != eParFontItalic ) + { + OUString sFontStyle; + if( eCurFontItalic != ITALIC_NONE ) { - OUString sFontStyle; - if( eCurFontItalic != ITALIC_NONE ) - { - if( eCurFontItalic == ITALIC_OBLIQUE ) - sFontStyle = "oblique"; - else - sFontStyle = "italic"; - } + if( eCurFontItalic == ITALIC_OBLIQUE ) + sFontStyle = "oblique"; else - { - sFontStyle = "normal"; - } - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontStyle, sFontStyle ); + sFontStyle = "italic"; } - - // Font Weight - if( eCurFontWeight != eParFontWeight ) + else { - sal_Int32 nFontWeight; - switch( eCurFontWeight ) - { - case WEIGHT_THIN: nFontWeight = 100; break; - case WEIGHT_ULTRALIGHT: nFontWeight = 200; break; - case WEIGHT_LIGHT: nFontWeight = 300; break; - case WEIGHT_SEMILIGHT: nFontWeight = 400; break; - case WEIGHT_NORMAL: nFontWeight = 400; break; - case WEIGHT_MEDIUM: nFontWeight = 500; break; - case WEIGHT_SEMIBOLD: nFontWeight = 600; break; - case WEIGHT_BOLD: nFontWeight = 700; break; - case WEIGHT_ULTRABOLD: nFontWeight = 800; break; - case WEIGHT_BLACK: nFontWeight = 900; break; - default: nFontWeight = 400; break; - } - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontWeight, OUString::number( nFontWeight ) ); + sFontStyle = "normal"; } + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontStyle, sFontStyle ); + } - - if( mrExport.IsUseNativeTextDecoration() ) + // Font Weight + if( eCurFontWeight != eParFontWeight ) + { + sal_Int32 nFontWeight; + switch( eCurFontWeight ) { - FontLineStyle eCurFontLineStyle = maCurrentFont.GetUnderline(); - FontStrikeout eCurFontStrikeout = maCurrentFont.GetStrikeout(); + case WEIGHT_THIN: nFontWeight = 100; break; + case WEIGHT_ULTRALIGHT: nFontWeight = 200; break; + case WEIGHT_LIGHT: nFontWeight = 300; break; + case WEIGHT_SEMILIGHT: nFontWeight = 400; break; + case WEIGHT_NORMAL: nFontWeight = 400; break; + case WEIGHT_MEDIUM: nFontWeight = 500; break; + case WEIGHT_SEMIBOLD: nFontWeight = 600; break; + case WEIGHT_BOLD: nFontWeight = 700; break; + case WEIGHT_ULTRABOLD: nFontWeight = 800; break; + case WEIGHT_BLACK: nFontWeight = 900; break; + default: nFontWeight = 400; break; + } + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontWeight, OUString::number( nFontWeight ) ); + } - FontLineStyle eParFontLineStyle = maParentFont.GetUnderline(); - FontStrikeout eParFontStrikeout = maParentFont.GetStrikeout(); - OUString sTextDecoration; - bool bIsDecorationChanged = false; - if( eCurFontLineStyle != eParFontLineStyle ) - { - if( eCurFontLineStyle != LINESTYLE_NONE ) - sTextDecoration = "underline"; - bIsDecorationChanged = true; - } - if( eCurFontStrikeout != eParFontStrikeout ) - { - if( eCurFontStrikeout != STRIKEOUT_NONE ) - { - if( !sTextDecoration.isEmpty() ) - sTextDecoration += " "; - sTextDecoration += "line-through"; - } - bIsDecorationChanged = true; - } + if( mrExport.IsUseNativeTextDecoration() ) + { + FontLineStyle eCurFontLineStyle = maCurrentFont.GetUnderline(); + FontStrikeout eCurFontStrikeout = maCurrentFont.GetStrikeout(); - if( !sTextDecoration.isEmpty() ) - { - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTextDecoration, sTextDecoration ); - } - else if( bIsDecorationChanged ) + FontLineStyle eParFontLineStyle = maParentFont.GetUnderline(); + FontStrikeout eParFontStrikeout = maParentFont.GetStrikeout(); + + OUString sTextDecoration; + bool bIsDecorationChanged = false; + if( eCurFontLineStyle != eParFontLineStyle ) + { + if( eCurFontLineStyle != LINESTYLE_NONE ) + sTextDecoration = "underline"; + bIsDecorationChanged = true; + } + if( eCurFontStrikeout != eParFontStrikeout ) + { + if( eCurFontStrikeout != STRIKEOUT_NONE ) { - sTextDecoration = "none"; - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTextDecoration, sTextDecoration ); + if( !sTextDecoration.isEmpty() ) + sTextDecoration += " "; + sTextDecoration += "line-through"; } + bIsDecorationChanged = true; } - if( bIsTextContainer ) - maParentFont = maCurrentFont; - + if( !sTextDecoration.isEmpty() ) + { + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTextDecoration, sTextDecoration ); + } + else if( bIsDecorationChanged ) + { + sTextDecoration = "none"; + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTextDecoration, sTextDecoration ); + } } + + if( bIsTextContainer ) + maParentFont = maCurrentFont; } @@ -1427,72 +1426,72 @@ void SVGTextWriter::writeBitmapPlaceholder( const MetaBitmapActionType* pAction void SVGTextWriter::implWriteEmbeddedBitmaps() { - if( mpTextEmbeddedBitmapMtf && mpTextEmbeddedBitmapMtf->GetActionSize() ) - { - mrExport.AddAttribute( XML_NAMESPACE_NONE, "class", "EmbeddedBitmaps" ); - SvXMLElementExport aEmbBitmapGroupElem( mrExport, XML_NAMESPACE_NONE, aXMLElemG, true, true ); + if( !(mpTextEmbeddedBitmapMtf && mpTextEmbeddedBitmapMtf->GetActionSize()) ) + return; - const GDIMetaFile& rMtf = *mpTextEmbeddedBitmapMtf; + mrExport.AddAttribute( XML_NAMESPACE_NONE, "class", "EmbeddedBitmaps" ); + SvXMLElementExport aEmbBitmapGroupElem( mrExport, XML_NAMESPACE_NONE, aXMLElemG, true, true ); - BitmapChecksum nId, nChecksum = 0; - Point aPt; - Size aSz; - sal_uLong nCount = rMtf.GetActionSize(); - for( sal_uLong nCurAction = 0; nCurAction < nCount; nCurAction++ ) - { + const GDIMetaFile& rMtf = *mpTextEmbeddedBitmapMtf; - const MetaAction* pAction = rMtf.GetAction( nCurAction ); - const MetaActionType nType = pAction->GetType(); + BitmapChecksum nId, nChecksum = 0; + Point aPt; + Size aSz; + sal_uLong nCount = rMtf.GetActionSize(); + for( sal_uLong nCurAction = 0; nCurAction < nCount; nCurAction++ ) + { + + const MetaAction* pAction = rMtf.GetAction( nCurAction ); + const MetaActionType nType = pAction->GetType(); - switch( nType ) + switch( nType ) + { + case MetaActionType::BMPSCALE: { - case MetaActionType::BMPSCALE: - { - const MetaBmpScaleAction* pA = static_cast<const MetaBmpScaleAction*>(pAction); - nChecksum = pA->GetBitmap().GetChecksum(); - aPt = pA->GetPoint(); - aSz = pA->GetSize(); - } - break; - case MetaActionType::BMPEXSCALE: - { - const MetaBmpExScaleAction* pA = static_cast<const MetaBmpExScaleAction*>(pAction); - nChecksum = pA->GetBitmapEx().GetChecksum(); - aPt = pA->GetPoint(); - aSz = pA->GetSize(); - } - break; - default: break; + const MetaBmpScaleAction* pA = static_cast<const MetaBmpScaleAction*>(pAction); + nChecksum = pA->GetBitmap().GetChecksum(); + aPt = pA->GetPoint(); + aSz = pA->GetSize(); } - - // <g id="?" > (used by animations) + break; + case MetaActionType::BMPEXSCALE: { - // embedded bitmap id - nId = SVGActionWriter::GetChecksum( pAction ); - OUString sId = "embedded-bitmap(" + msShapeId + "." + OUString::number( nId ) + ")"; - mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", sId ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "class", "EmbeddedBitmap" ); + const MetaBmpExScaleAction* pA = static_cast<const MetaBmpExScaleAction*>(pAction); + nChecksum = pA->GetBitmapEx().GetChecksum(); + aPt = pA->GetPoint(); + aSz = pA->GetSize(); + } + break; + default: break; + } - SvXMLElementExport aEmbBitmapElem( mrExport, XML_NAMESPACE_NONE, aXMLElemG, true, true ); + // <g id="?" > (used by animations) + { + // embedded bitmap id + nId = SVGActionWriter::GetChecksum( pAction ); + OUString sId = "embedded-bitmap(" + msShapeId + "." + OUString::number( nId ) + ")"; + mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", sId ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "class", "EmbeddedBitmap" ); - // <use x="?" y="?" xlink:ref="?" > - { - // referenced bitmap template - OUString sRefId = "#bitmap(" + OUString::number( nChecksum ) + ")"; + SvXMLElementExport aEmbBitmapElem( mrExport, XML_NAMESPACE_NONE, aXMLElemG, true, true ); - Point aPoint; - Size aSize; - implMap( aPt, aPoint ); - implMap( aSz, aSize ); + // <use x="?" y="?" xlink:ref="?" > + { + // referenced bitmap template + OUString sRefId = "#bitmap(" + OUString::number( nChecksum ) + ")"; - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, OUString::number( aPoint.X() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, OUString::number( aPoint.Y() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrXLinkHRef, sRefId ); + Point aPoint; + Size aSize; + implMap( aPt, aPoint ); + implMap( aSz, aSize ); - SvXMLElementExport aRefElem( mrExport, XML_NAMESPACE_NONE, "use", true, true ); - } - } // close aEmbBitmapElem - } + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, OUString::number( aPoint.X() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, OUString::number( aPoint.Y() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrXLinkHRef, sRefId ); + + SvXMLElementExport aRefElem( mrExport, XML_NAMESPACE_NONE, "use", true, true ); + } + } // close aEmbBitmapElem } } @@ -1921,54 +1920,53 @@ void SVGActionWriter::ImplWriteEllipse( const Point& rCenter, long nRadX, long n void SVGActionWriter::ImplAddLineAttr( const LineInfo &rAttrs ) { - if ( !rAttrs.IsDefault() ) + if ( rAttrs.IsDefault() ) + return; + + sal_Int32 nStrokeWidth = ImplMap( rAttrs.GetWidth() ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStrokeWidth, + OUString::number( nStrokeWidth ) ); + // support for LineJoint + switch(rAttrs.GetLineJoin()) { - sal_Int32 nStrokeWidth = ImplMap( rAttrs.GetWidth() ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStrokeWidth, - OUString::number( nStrokeWidth ) ); - // support for LineJoint - switch(rAttrs.GetLineJoin()) + case basegfx::B2DLineJoin::NONE: + case basegfx::B2DLineJoin::Miter: { - case basegfx::B2DLineJoin::NONE: - case basegfx::B2DLineJoin::Miter: - { - mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinejoin, "miter"); - break; - } - case basegfx::B2DLineJoin::Bevel: - { - mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinejoin, "bevel"); - break; - } - case basegfx::B2DLineJoin::Round: - { - mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinejoin, "round"); - break; - } + mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinejoin, "miter"); + break; } - - // support for LineCap - switch(rAttrs.GetLineCap()) + case basegfx::B2DLineJoin::Bevel: { - default: /* css::drawing::LineCap_BUTT */ - { - // butt is Svg default, so no need to write until the exporter might write styles. - // If this happens, activate here - // mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinecap, "butt"); - break; - } - case css::drawing::LineCap_ROUND: - { - mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinecap, "round"); - break; - } - case css::drawing::LineCap_SQUARE: - { - mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinecap, "square"); - break; - } + mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinejoin, "bevel"); + break; + } + case basegfx::B2DLineJoin::Round: + { + mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinejoin, "round"); + break; } + } + // support for LineCap + switch(rAttrs.GetLineCap()) + { + default: /* css::drawing::LineCap_BUTT */ + { + // butt is Svg default, so no need to write until the exporter might write styles. + // If this happens, activate here + // mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinecap, "butt"); + break; + } + case css::drawing::LineCap_ROUND: + { + mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinecap, "round"); + break; + } + case css::drawing::LineCap_SQUARE: + { + mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinecap, "square"); + break; + } } } @@ -2134,56 +2132,56 @@ void SVGActionWriter::ImplWritePattern( const tools::PolyPolygon& rPolyPoly, const Gradient* pGradient, sal_uInt32 nWriteFlags ) { - if( rPolyPoly.Count() ) + if( !rPolyPoly.Count() ) + return; + + SvXMLElementExport aElemG( mrExport, XML_NAMESPACE_NONE, aXMLElemG, true, true ); + + OUString aPatternId = "pattern" + OUString::number( mnCurPatternId++ ); + { - SvXMLElementExport aElemG( mrExport, XML_NAMESPACE_NONE, aXMLElemG, true, true ); + SvXMLElementExport aElemDefs( mrExport, XML_NAMESPACE_NONE, aXMLElemDefs, true, true ); - OUString aPatternId = "pattern" + OUString::number( mnCurPatternId++ ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, aPatternId ); - { - SvXMLElementExport aElemDefs( mrExport, XML_NAMESPACE_NONE, aXMLElemDefs, true, true ); + tools::Rectangle aRect; + ImplMap( rPolyPoly.GetBoundRect(), aRect ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, aPatternId ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, OUString::number( aRect.Left() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, OUString::number( aRect.Top() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, OUString::number( aRect.GetWidth() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, OUString::number( aRect.GetHeight() ) ); - tools::Rectangle aRect; - ImplMap( rPolyPoly.GetBoundRect(), aRect ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "patternUnits", OUString( "userSpaceOnUse") ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, OUString::number( aRect.Left() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, OUString::number( aRect.Top() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, OUString::number( aRect.GetWidth() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, OUString::number( aRect.GetHeight() ) ); + { + SvXMLElementExport aElemPattern( mrExport, XML_NAMESPACE_NONE, "pattern", true, true ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "patternUnits", OUString( "userSpaceOnUse") ); + // The origin of a pattern is positioned at (aRect.Left(), aRect.Top()). + // So we need to adjust the pattern coordinate. + OUString aTransform = "translate(" + + OUString::number( -aRect.Left() ) + + "," + OUString::number( -aRect.Top() ) + + ")"; + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTransform, aTransform ); { - SvXMLElementExport aElemPattern( mrExport, XML_NAMESPACE_NONE, "pattern", true, true ); - - // The origin of a pattern is positioned at (aRect.Left(), aRect.Top()). - // So we need to adjust the pattern coordinate. - OUString aTransform = "translate(" + - OUString::number( -aRect.Left() ) + - "," + OUString::number( -aRect.Top() ) + - ")"; - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTransform, aTransform ); + SvXMLElementExport aElemG2( mrExport, XML_NAMESPACE_NONE, aXMLElemG, true, true ); - { - SvXMLElementExport aElemG2( mrExport, XML_NAMESPACE_NONE, aXMLElemG, true, true ); - - GDIMetaFile aTmpMtf; - if( pHatch ) - mpVDev->AddHatchActions( rPolyPoly, *pHatch, aTmpMtf ); - else if ( pGradient ) - mpVDev->AddGradientActions( rPolyPoly.GetBoundRect(), *pGradient, aTmpMtf ); - ImplWriteActions( aTmpMtf, nWriteFlags, nullptr ); - } + GDIMetaFile aTmpMtf; + if( pHatch ) + mpVDev->AddHatchActions( rPolyPoly, *pHatch, aTmpMtf ); + else if ( pGradient ) + mpVDev->AddGradientActions( rPolyPoly.GetBoundRect(), *pGradient, aTmpMtf ); + ImplWriteActions( aTmpMtf, nWriteFlags, nullptr ); } } + } - OUString aPatternStyle = "fill:url(#" + aPatternId + ")"; + OUString aPatternStyle = "fill:url(#" + aPatternId + ")"; - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aPatternStyle ); - ImplWritePolyPolygon( rPolyPoly, false ); - } + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aPatternStyle ); + ImplWritePolyPolygon( rPolyPoly, false ); } @@ -2205,109 +2203,109 @@ void SVGActionWriter::ImplWriteGradientEx( const tools::PolyPolygon& rPolyPoly, void SVGActionWriter::ImplWriteGradientLinear( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient ) { - if( rPolyPoly.Count() ) - { - SvXMLElementExport aElemG( mrExport, XML_NAMESPACE_NONE, aXMLElemG, true, true ); - - OUString aGradientId = "gradient" + OUString::number( mnCurGradientId++ ); - - { - SvXMLElementExport aElemDefs( mrExport, XML_NAMESPACE_NONE, aXMLElemDefs, true, true ); + if( !rPolyPoly.Count() ) + return; - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, aGradientId ); - { - tools::Rectangle aTmpRect, aRect; - Point aTmpCenter, aCenter; + SvXMLElementExport aElemG( mrExport, XML_NAMESPACE_NONE, aXMLElemG, true, true ); - rGradient.GetBoundRect( rPolyPoly.GetBoundRect(), aTmpRect, aTmpCenter ); - ImplMap( aTmpRect, aRect ); - ImplMap( aTmpCenter, aCenter ); - const sal_uInt16 nAngle = rGradient.GetAngle() % 3600; + OUString aGradientId = "gradient" + OUString::number( mnCurGradientId++ ); - tools::Polygon aPoly( 2 ); - // Setting x value of a gradient vector to rotation center to - // place a gradient vector in a target polygon. - // This would help editing it in SVG editors like inkscape. - aPoly[ 0 ].setX( aCenter.X() ); - aPoly[ 1 ].setX( aCenter.X() ); - aPoly[ 0 ].setY( aRect.Top() ); - aPoly[ 1 ].setY( aRect.Bottom() ); - aPoly.Rotate( aCenter, nAngle ); + { + SvXMLElementExport aElemDefs( mrExport, XML_NAMESPACE_NONE, aXMLElemDefs, true, true ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX1, OUString::number( aPoly[ 0 ].X() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY1, OUString::number( aPoly[ 0 ].Y() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX2, OUString::number( aPoly[ 1 ].X() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY2, OUString::number( aPoly[ 1 ].Y() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, aGradientId ); + { + tools::Rectangle aTmpRect, aRect; + Point aTmpCenter, aCenter; + + rGradient.GetBoundRect( rPolyPoly.GetBoundRect(), aTmpRect, aTmpCenter ); + ImplMap( aTmpRect, aRect ); + ImplMap( aTmpCenter, aCenter ); + const sal_uInt16 nAngle = rGradient.GetAngle() % 3600; + + tools::Polygon aPoly( 2 ); + // Setting x value of a gradient vector to rotation center to + // place a gradient vector in a target polygon. + // This would help editing it in SVG editors like inkscape. + aPoly[ 0 ].setX( aCenter.X() ); + aPoly[ 1 ].setX( aCenter.X() ); + aPoly[ 0 ].setY( aRect.Top() ); + aPoly[ 1 ].setY( aRect.Bottom() ); + aPoly.Rotate( aCenter, nAngle ); + + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX1, OUString::number( aPoly[ 0 ].X() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY1, OUString::number( aPoly[ 0 ].Y() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX2, OUString::number( aPoly[ 1 ].X() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY2, OUString::number( aPoly[ 1 ].Y() ) ); + + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrGradientUnits, + OUString( "userSpaceOnUse" ) ); + } - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrGradientUnits, - OUString( "userSpaceOnUse" ) ); - } + { + SvXMLElementExport aElemLinearGradient( mrExport, XML_NAMESPACE_NONE, aXMLElemLinearGradient, true, true ); + const Color aStartColor = ImplGetColorWithIntensity( rGradient.GetStartColor(), rGradient.GetStartIntensity() ); + const Color aEndColor = ImplGetColorWithIntensity( rGradient.GetEndColor(), rGradient.GetEndIntensity() ); + double fBorderOffset = rGradient.GetBorder() / 100.0; + const sal_uInt16 nSteps = rGradient.GetSteps(); + if( rGradient.GetStyle() == GradientStyle::Linear ) { - SvXMLElementExport aElemLinearGradient( mrExport, XML_NAMESPACE_NONE, aXMLElemLinearGradient, true, true ); - - const Color aStartColor = ImplGetColorWithIntensity( rGradient.GetStartColor(), rGradient.GetStartIntensity() ); - const Color aEndColor = ImplGetColorWithIntensity( rGradient.GetEndColor(), rGradient.GetEndIntensity() ); - double fBorderOffset = rGradient.GetBorder() / 100.0; - const sal_uInt16 nSteps = rGradient.GetSteps(); - if( rGradient.GetStyle() == GradientStyle::Linear ) + // Emulate non-smooth gradient + if( 0 < nSteps && nSteps < 100 ) { - // Emulate non-smooth gradient - if( 0 < nSteps && nSteps < 100 ) - { - double fOffsetStep = ( 1.0 - fBorderOffset ) / static_cast<double>(nSteps); - for( sal_uInt16 i = 0; i < nSteps; i++ ) { - Color aColor = ImplGetGradientColor( aStartColor, aEndColor, i / static_cast<double>(nSteps) ); - ImplWriteGradientStop( aColor, fBorderOffset + ( i + 1 ) * fOffsetStep ); - aColor = ImplGetGradientColor( aStartColor, aEndColor, ( i + 1 ) / static_cast<double>(nSteps) ); - ImplWriteGradientStop( aColor, fBorderOffset + ( i + 1 ) * fOffsetStep ); - } - } - else - { - ImplWriteGradientStop( aStartColor, fBorderOffset ); - ImplWriteGradientStop( aEndColor, 1.0 ); + double fOffsetStep = ( 1.0 - fBorderOffset ) / static_cast<double>(nSteps); + for( sal_uInt16 i = 0; i < nSteps; i++ ) { + Color aColor = ImplGetGradientColor( aStartColor, aEndColor, i / static_cast<double>(nSteps) ); + ImplWriteGradientStop( aColor, fBorderOffset + ( i + 1 ) * fOffsetStep ); + aColor = ImplGetGradientColor( aStartColor, aEndColor, ( i + 1 ) / static_cast<double>(nSteps) ); + ImplWriteGradientStop( aColor, fBorderOffset + ( i + 1 ) * fOffsetStep ); } } else { - fBorderOffset /= 2; - // Emulate non-smooth gradient - if( 0 < nSteps && nSteps < 100 ) + ImplWriteGradientStop( aStartColor, fBorderOffset ); + ImplWriteGradientStop( aEndColor, 1.0 ); + } + } + else + { + fBorderOffset /= 2; + // Emulate non-smooth gradient + if( 0 < nSteps && nSteps < 100 ) + { + double fOffsetStep = ( 0.5 - fBorderOffset ) / static_cast<double>(nSteps); + // Upper half + for( sal_uInt16 i = 0; i < nSteps; i++ ) { - double fOffsetStep = ( 0.5 - fBorderOffset ) / static_cast<double>(nSteps); - // Upper half - for( sal_uInt16 i = 0; i < nSteps; i++ ) - { - Color aColor = ImplGetGradientColor( aEndColor, aStartColor, i / static_cast<double>(nSteps) ); - ImplWriteGradientStop( aColor, fBorderOffset + i * fOffsetStep ); - aColor = ImplGetGradientColor( aEndColor, aStartColor, (i + 1 ) / static_cast<double>(nSteps) ); - ImplWriteGradientStop( aColor, fBorderOffset + i * fOffsetStep ); - } - // Lower half - for( sal_uInt16 i = 0; i < nSteps; i++ ) - { - Color aColor = ImplGetGradientColor( aStartColor, aEndColor, i / static_cast<double>(nSteps) ); - ImplWriteGradientStop( aColor, 0.5 + (i + 1) * fOffsetStep ); - aColor = ImplGetGradientColor( aStartColor, aEndColor, (i + 1 ) / static_cast<double>(nSteps) ); - ImplWriteGradientStop( aColor, 0.5 + (i + 1) * fOffsetStep ); - } + Color aColor = ImplGetGradientColor( aEndColor, aStartColor, i / static_cast<double>(nSteps) ); + ImplWriteGradientStop( aColor, fBorderOffset + i * fOffsetStep ); + aColor = ImplGetGradientColor( aEndColor, aStartColor, (i + 1 ) / static_cast<double>(nSteps) ); + ImplWriteGradientStop( aColor, fBorderOffset + i * fOffsetStep ); } - else + // Lower half + for( sal_uInt16 i = 0; i < nSteps; i++ ) { - ImplWriteGradientStop( aEndColor, fBorderOffset ); - ImplWriteGradientStop( aStartColor, 0.5 ); - ImplWriteGradientStop( aEndColor, 1.0 - fBorderOffset ); + Color aColor = ImplGetGradientColor( aStartColor, aEndColor, i / static_cast<double>(nSteps) ); + ImplWriteGradientStop( aColor, 0.5 + (i + 1) * fOffsetStep ); + aColor = ImplGetGradientColor( aStartColor, aEndColor, (i + 1 ) / static_cast<double>(nSteps) ); + ImplWriteGradientStop( aColor, 0.5 + (i + 1) * fOffsetStep ); } } + else + { + ImplWriteGradientStop( aEndColor, fBorderOffset ); + ImplWriteGradientStop( aStartColor, 0.5 ); + ImplWriteGradientStop( aEndColor, 1.0 - fBorderOffset ); + } } } + } - OUString aGradientStyle = "fill:url(#" + aGradientId + ")"; + OUString aGradientStyle = "fill:url(#" + aGradientId + ")"; - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aGradientStyle ); - ImplWritePolyPolygon( rPolyPoly, false ); - } + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aGradientStyle ); + ImplWritePolyPolygon( rPolyPoly, false ); } @@ -2663,37 +2661,37 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const OUString& rText, } - if( !mrExport.IsUseNativeTextDecoration() ) - { - if( rFont.GetStrikeout() != STRIKEOUT_NONE || rFont.GetUnderline() != LINESTYLE_NONE ) - { - tools::Polygon aPoly( 4 ); - const long nLineHeight = std::max<long>( FRound( aMetric.GetLineHeight() * 0.05 ), 1 ); + if( mrExport.IsUseNativeTextDecoration() ) + return; - if( rFont.GetStrikeout() ) - { - const long nYLinePos = aBaseLinePos.Y() - FRound( aMetric.GetAscent() * 0.26 ); + if( rFont.GetStrikeout() == STRIKEOUT_NONE && rFont.GetUnderline() == LINESTYLE_NONE ) + return; - aPoly[ 0 ].setX( aBaseLinePos.X() ); aPoly[ 0 ].setY( nYLinePos - ( nLineHeight >> 1 ) ); - aPoly[ 1 ].setX( aBaseLinePos.X() + aNormSize.Width() - 1 ); aPoly[ 1 ].setY( aPoly[ 0 ].Y() ); - aPoly[ 2 ].setX( aPoly[ 1 ].X() ); aPoly[ 2 ].setY( aPoly[ 0 ].Y() + nLineHeight - 1 ); - aPoly[ 3 ].setX( aPoly[ 0 ].X() ); aPoly[ 3 ].setY( aPoly[ 2 ].Y() ); + tools::Polygon aPoly( 4 ); + const long nLineHeight = std::max<long>( FRound( aMetric.GetLineHeight() * 0.05 ), 1 ); - ImplWritePolyPolygon( aPoly, false ); - } + if( rFont.GetStrikeout() ) + { + const long nYLinePos = aBaseLinePos.Y() - FRound( aMetric.GetAscent() * 0.26 ); - if( rFont.GetUnderline() ) - { - const long nYLinePos = aBaseLinePos.Y() + ( nLineHeight << 1 ); + aPoly[ 0 ].setX( aBaseLinePos.X() ); aPoly[ 0 ].setY( nYLinePos - ( nLineHeight >> 1 ) ); + aPoly[ 1 ].setX( aBaseLinePos.X() + aNormSize.Width() - 1 ); aPoly[ 1 ].setY( aPoly[ 0 ].Y() ); + aPoly[ 2 ].setX( aPoly[ 1 ].X() ); aPoly[ 2 ].setY( aPoly[ 0 ].Y() + nLineHeight - 1 ); + aPoly[ 3 ].setX( aPoly[ 0 ].X() ); aPoly[ 3 ].setY( aPoly[ 2 ].Y() ); + + ImplWritePolyPolygon( aPoly, false ); + } - aPoly[ 0 ].setX( aBaseLinePos.X() ); aPoly[ 0 ].setY( nYLinePos - ( nLineHeight >> 1 ) ); - aPoly[ 1 ].setX( aBaseLinePos.X() + aNormSize.Width() - 1 ); aPoly[ 1 ].setY( aPoly[ 0 ].Y() ); - aPoly[ 2 ].setX( aPoly[ 1 ].X() ); aPoly[ 2 ].setY( aPoly[ 0 ].Y() + nLineHeight - 1 ); - aPoly[ 3 ].setX( aPoly[ 0 ].X() ); aPoly[ 3 ].setY( aPoly[ 2 ].Y() ); + if( rFont.GetUnderline() ) + { + const long nYLinePos = aBaseLinePos.Y() + ( nLineHeight << 1 ); - ImplWritePolyPolygon( aPoly, false ); - } - } + aPoly[ 0 ].setX( aBaseLinePos.X() ); aPoly[ 0 ].setY( nYLinePos - ( nLineHeight >> 1 ) ); + aPoly[ 1 ].setX( aBaseLinePos.X() + aNormSize.Width() - 1 ); aPoly[ 1 ].setY( aPoly[ 0 ].Y() ); + aPoly[ 2 ].setX( aPoly[ 1 ].X() ); aPoly[ 2 ].setY( aPoly[ 0 ].Y() + nLineHeight - 1 ); + aPoly[ 3 ].setX( aPoly[ 0 ].X() ); aPoly[ 3 ].setY( aPoly[ 2 ].Y() ); + + ImplWritePolyPolygon( aPoly, false ); } } @@ -2723,82 +2721,82 @@ void SVGActionWriter::ImplWriteBmp( const BitmapEx& rBmpEx, const Point& rSrcPt, const Size& rSrcSz, const css::uno::Reference<css::drawing::XShape>* pShape ) { - if( !!rBmpEx ) - { - BitmapEx aBmpEx( rBmpEx ); - const tools::Rectangle aBmpRect( Point(), rBmpEx.GetSizePixel() ); - const tools::Rectangle aSrcRect( rSrcPt, rSrcSz ); + if( !rBmpEx ) + return; - if( aSrcRect != aBmpRect ) - aBmpEx.Crop( aSrcRect ); + BitmapEx aBmpEx( rBmpEx ); + const tools::Rectangle aBmpRect( Point(), rBmpEx.GetSizePixel() ); + const tools::Rectangle aSrcRect( rSrcPt, rSrcSz ); - if( !!aBmpEx ) - { - SvMemoryStream aOStm( 65535, 65535 ); + if( aSrcRect != aBmpRect ) + aBmpEx.Crop( aSrcRect ); - bool bCached = false; - Graphic aGraphic; - bool bPNG = false; - bool bJPG = false; - if (pShape) + if( !aBmpEx ) + return; + + SvMemoryStream aOStm( 65535, 65535 ); + + bool bCached = false; + Graphic aGraphic; + bool bPNG = false; + bool bJPG = false; + if (pShape) + { + GetGraphicFromXShape(pShape, aGraphic); + if (aGraphic.GetType() == GraphicType::Bitmap) + { + const BitmapEx& rGraphicBitmap = aGraphic.GetBitmapExRef(); + if (rGraphicBitmap.GetChecksum() == rBmpEx.GetChecksum()) { - GetGraphicFromXShape(pShape, aGraphic); - if (aGraphic.GetType() == GraphicType::Bitmap) + GfxLink aGfxLink = aGraphic.GetGfxLink(); + if (aGfxLink.GetType() == GfxLinkType::NativePng) { - const BitmapEx& rGraphicBitmap = aGraphic.GetBitmapExRef(); - if (rGraphicBitmap.GetChecksum() == rBmpEx.GetChecksum()) - { - GfxLink aGfxLink = aGraphic.GetGfxLink(); - if (aGfxLink.GetType() == GfxLinkType::NativePng) - { - bPNG = true; - } - else if (aGfxLink.GetType() == GfxLinkType::NativeJpg) - { - bJPG = true; - } - if (bPNG || bJPG) - { - aOStm.WriteBytes(aGfxLink.GetData(), aGfxLink.GetDataSize()); - bCached = true; - } - } + bPNG = true; } - } - - if( bCached || GraphicConverter::Export( aOStm, rBmpEx, ConvertDataFormat::PNG ) == ERRCODE_NONE ) - { - Point aPt; - Size aSz; - Sequence< sal_Int8 > aSeq( static_cast<sal_Int8 const *>(aOStm.GetData()), aOStm.Tell() ); - OUStringBuffer aBuffer; - if (bJPG) + else if (aGfxLink.GetType() == GfxLinkType::NativeJpg) { - aBuffer.append("data:image/jpeg;base64,"); + bJPG = true; } - else + if (bPNG || bJPG) { - aBuffer.append("data:image/png;base64,"); + aOStm.WriteBytes(aGfxLink.GetData(), aGfxLink.GetDataSize()); + bCached = true; } - ::comphelper::Base64::encode( aBuffer, aSeq ); + } + } + } + + if( !(bCached || GraphicConverter::Export( aOStm, rBmpEx, ConvertDataFormat::PNG ) == ERRCODE_NONE) ) + return; + + Point aPt; + Size aSz; + Sequence< sal_Int8 > aSeq( static_cast<sal_Int8 const *>(aOStm.GetData()), aOStm.Tell() ); + OUStringBuffer aBuffer; + if (bJPG) + { + aBuffer.append("data:image/jpeg;base64,"); + } + else + { + aBuffer.append("data:image/png;base64,"); + } + ::comphelper::Base64::encode( aBuffer, aSeq ); - ImplMap( rPt, aPt ); - ImplMap( rSz, aSz ); + ImplMap( rPt, aPt ); + ImplMap( rSz, aSz ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, OUString::number( aPt.X() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, OUString::number( aPt.Y() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, OUString::number( aSz.Width() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, OUString::number( aSz.Height() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, OUString::number( aPt.X() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, OUString::number( aPt.Y() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, OUString::number( aSz.Width() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, OUString::number( aSz.Height() ) ); - // the image must be scaled to aSz in a non-uniform way - mrExport.AddAttribute( XML_NAMESPACE_NONE, "preserveAspectRatio", "none" ); + // the image must be scaled to aSz in a non-uniform way + mrExport.AddAttribute( XML_NAMESPACE_NONE, "preserveAspectRatio", "none" ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrXLinkHRef, aBuffer.makeStringAndClear() ); - { - SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, "image", true, true ); - } - } - } + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrXLinkHRef, aBuffer.makeStringAndClear() ); + { + SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, "image", true, true ); } } diff --git a/filter/source/t602/t602filter.cxx b/filter/source/t602/t602filter.cxx index bf5d8fc10e94..1c2c453c0135 100644 --- a/filter/source/t602/t602filter.cxx +++ b/filter/source/t602/t602filter.cxx @@ -568,26 +568,27 @@ void T602ImportFilter::par602(bool endofpage) pst.waspar = true; } - if(!pst.comment) { - switch(format602.lh) { - case 3: pst.pars += 4; break; - case 4: pst.pars += 3; break; - case 6: pst.pars += 2; break; - default: pst.pars +=2; break; - } - endp = format602.pl-format602.mt-format602.mb; - if(((pst.pars+1)/2) >= endp || endofpage) { - pst.pars = 0; - if(!ini.reformatpars) { - End_("text:span"); - End_("text:p"); - if (mpAttrList) - mpAttrList->AddAttribute("text:style-name", "P2"); - Start_("text:p"); - Start_("text:span"); - wrtfnt(); - } - } + if(pst.comment) + return; + + switch(format602.lh) { + case 3: pst.pars += 4; break; + case 4: pst.pars += 3; break; + case 6: pst.pars += 2; break; + default: pst.pars +=2; break; + } + endp = format602.pl-format602.mt-format602.mb; + if(!(((pst.pars+1)/2) >= endp || endofpage)) return; + + pst.pars = 0; + if(!ini.reformatpars) { + End_("text:span"); + End_("text:p"); + if (mpAttrList) + mpAttrList->AddAttribute("text:style-name", "P2"); + Start_("text:p"); + Start_("text:span"); + wrtfnt(); } } diff --git a/filter/source/xsltdialog/typedetectionimport.cxx b/filter/source/xsltdialog/typedetectionimport.cxx index 8c479fa4c203..76dfeb54d250 100644 --- a/filter/source/xsltdialog/typedetectionimport.cxx +++ b/filter/source/xsltdialog/typedetectionimport.cxx @@ -263,38 +263,38 @@ void SAL_CALL TypeDetectionImporter::startElement( const OUString& aName, const } void SAL_CALL TypeDetectionImporter::endElement( const OUString& /* aName */ ) { - if( !maStack.empty() ) + if( maStack.empty() ) + return; + + ImportState eCurrentState = maStack.top(); + switch( eCurrentState ) { - ImportState eCurrentState = maStack.top(); - switch( eCurrentState ) + case e_Filter: + case e_Type: { - case e_Filter: - case e_Type: + std::unique_ptr<Node> pNode(new Node); + pNode->maName = maNodeName; + pNode->maPropertyMap = maPropertyMap; + maPropertyMap.clear(); + + if( eCurrentState == e_Filter ) { - std::unique_ptr<Node> pNode(new Node); - pNode->maName = maNodeName; - pNode->maPropertyMap = maPropertyMap; - maPropertyMap.clear(); - - if( eCurrentState == e_Filter ) - { - maFilterNodes.push_back( std::move(pNode) ); - } - else - { - maTypeNodes.push_back( std::move(pNode) ); - } + maFilterNodes.push_back( std::move(pNode) ); + } + else + { + maTypeNodes.push_back( std::move(pNode) ); } - break; - - case e_Property: - maPropertyMap[ maPropertyName ] = maValue; - break; - default: break; } + break; - maStack.pop(); + case e_Property: + maPropertyMap[ maPropertyName ] = maValue; + break; + default: break; } + + maStack.pop(); } void SAL_CALL TypeDetectionImporter::characters( const OUString& aChars ) { diff --git a/filter/source/xsltdialog/xmlfilterjar.cxx b/filter/source/xsltdialog/xmlfilterjar.cxx index 5cee8bd9176b..94dd2540d478 100644 --- a/filter/source/xsltdialog/xmlfilterjar.cxx +++ b/filter/source/xsltdialog/xmlfilterjar.cxx @@ -115,26 +115,26 @@ static void addFile_( Reference< XInterface > const & xRootFolder, Reference< XS void XMLFilterJarHelper::addFile( Reference< XInterface > const & xRootFolder, Reference< XSingleServiceFactory > const & xFactory, const OUString& rSourceFile ) { - if( !rSourceFile.isEmpty() && + if( !(!rSourceFile.isEmpty() && !rSourceFile.startsWith("http:") && !rSourceFile.startsWith("https:") && !rSourceFile.startsWith("jar:") && - !rSourceFile.startsWith("ftp:") ) - { - OUString aFileURL( rSourceFile ); - - if( !aFileURL.matchIgnoreAsciiCase("file://") ) - { - aFileURL = URIHelper::SmartRel2Abs( INetURLObject(sProgPath), aFileURL, Link<OUString *, bool>(), false ); - } + !rSourceFile.startsWith("ftp:")) ) + return; - INetURLObject aURL( aFileURL ); - OUString aName( aURL.getName() ); + OUString aFileURL( rSourceFile ); - SvFileStream* pStream = new SvFileStream(aFileURL, StreamMode::READ ); - Reference< XInputStream > xInput( new utl::OSeekableInputStreamWrapper( pStream, true ) ); - addFile_( xRootFolder, xFactory, xInput, aName ); + if( !aFileURL.matchIgnoreAsciiCase("file://") ) + { + aFileURL = URIHelper::SmartRel2Abs( INetURLObject(sProgPath), aFileURL, Link<OUString *, bool>(), false ); } + + INetURLObject aURL( aFileURL ); + OUString aName( aURL.getName() ); + + SvFileStream* pStream = new SvFileStream(aFileURL, StreamMode::READ ); + Reference< XInputStream > xInput( new utl::OSeekableInputStreamWrapper( pStream, true ) ); + addFile_( xRootFolder, xFactory, xInput, aName ); } bool XMLFilterJarHelper::savePackage( const OUString& rPackageURL, const std::vector<filter_info_impl*>& rFilters ) diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx index c15a2a97780c..18bdb585a160 100644 --- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx +++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx @@ -230,19 +230,19 @@ void XMLFilterSettingsDialog::onEdit() { // get selected filter info filter_info_impl* pOldInfo = reinterpret_cast<filter_info_impl*>(m_xFilterListBox->get_selected_id().toInt64()); - if (pOldInfo) + if (!pOldInfo) + return; + + // execute XML Filter Dialog + XMLFilterTabDialog aDlg(m_xDialog.get(), mxContext, pOldInfo); + if (aDlg.run() == RET_OK) { - // execute XML Filter Dialog - XMLFilterTabDialog aDlg(m_xDialog.get(), mxContext, pOldInfo); - if (aDlg.run() == RET_OK) - { - filter_info_impl* pNewInfo = aDlg.getNewFilterInfo(); + filter_info_impl* pNewInfo = aDlg.getNewFilterInfo(); - if( !(*pOldInfo == *pNewInfo) ) - { - // change filter - insertOrEdit( pNewInfo, pOldInfo ); - } + if( !(*pOldInfo == *pNewInfo) ) + { + // change filter + insertOrEdit( pNewInfo, pOldInfo ); } } } @@ -853,34 +853,34 @@ void XMLFilterSettingsDialog::onSave() aDlg.AddFilter( aFilterName, aExtensions ); - if ( aDlg.Execute() == ERRCODE_NONE ) - { - XMLFilterJarHelper aJarHelper( mxContext ); - aJarHelper.savePackage( aDlg.GetPath(), aFilters ); + if ( aDlg.Execute() != ERRCODE_NONE ) + return; - INetURLObject aURL( aDlg.GetPath() ); + XMLFilterJarHelper aJarHelper( mxContext ); + aJarHelper.savePackage( aDlg.GetPath(), aFilters ); - OUString sPlaceholder( "%s" ); + INetURLObject aURL( aDlg.GetPath() ); - OUString aMsg; - if( nFilters > 0 ) - { - aMsg = XsltResId(STR_FILTERS_HAVE_BEEN_SAVED); - aMsg = aMsg.replaceFirst( sPlaceholder, OUString::number( nFilters ) ); - aMsg = aMsg.replaceFirst(sPlaceholder, aURL.GetLastName()); - } - else - { - aMsg = XsltResId(STR_FILTER_HAS_BEEN_SAVED); - aMsg = aMsg.replaceFirst( sPlaceholder, (*aFilters.begin())->maFilterName ); - aMsg = aMsg.replaceFirst(sPlaceholder, aURL.GetLastName()); - } + OUString sPlaceholder( "%s" ); - std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), - VclMessageType::Info, VclButtonsType::Ok, - aMsg)); - xInfoBox->run(); + OUString aMsg; + if( nFilters > 0 ) + { + aMsg = XsltResId(STR_FILTERS_HAVE_BEEN_SAVED); + aMsg = aMsg.replaceFirst( sPlaceholder, OUString::number( nFilters ) ); + aMsg = aMsg.replaceFirst(sPlaceholder, aURL.GetLastName()); } + else + { + aMsg = XsltResId(STR_FILTER_HAS_BEEN_SAVED); + aMsg = aMsg.replaceFirst( sPlaceholder, (*aFilters.begin())->maFilterName ); + aMsg = aMsg.replaceFirst(sPlaceholder, aURL.GetLastName()); + } + + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), + VclMessageType::Info, VclButtonsType::Ok, + aMsg)); + xInfoBox->run(); } void XMLFilterSettingsDialog::onOpen() @@ -898,53 +898,53 @@ void XMLFilterSettingsDialog::onOpen() aDlg.AddFilter( aFilterName, aExtensions ); - if ( aDlg.Execute() == ERRCODE_NONE ) - { - OUString aURL( aDlg.GetPath() ); + if ( aDlg.Execute() != ERRCODE_NONE ) + return; - XMLFilterJarHelper aJarHelper( mxContext ); - aJarHelper.openPackage( aURL, aFilters ); + OUString aURL( aDlg.GetPath() ); - int nFilters = 0; - for (auto& filter : aFilters) - { - if( insertOrEdit(filter.get()) ) - { - aFilterName = filter->maFilterName; - nFilters++; - } + XMLFilterJarHelper aJarHelper( mxContext ); + aJarHelper.openPackage( aURL, aFilters ); - filter.reset(); + int nFilters = 0; + for (auto& filter : aFilters) + { + if( insertOrEdit(filter.get()) ) + { + aFilterName = filter->maFilterName; + nFilters++; } - disposeFilterList(); - initFilterList(); + filter.reset(); + } - OUString sPlaceholder( "%s" ); - OUString aMsg; - if( nFilters == 0 ) - { - INetURLObject aURLObj( aURL ); - aMsg = XsltResId(STR_NO_FILTERS_FOUND); - aMsg = aMsg.replaceFirst(sPlaceholder, aURLObj.GetLastName()); - } - else if( nFilters == 1 ) - { - aMsg = XsltResId(STR_FILTER_INSTALLED); - aMsg = aMsg.replaceFirst( sPlaceholder, aFilterName ); + disposeFilterList(); + initFilterList(); - } - else - { - aMsg = XsltResId(STR_FILTERS_INSTALLED); - aMsg = aMsg.replaceFirst( sPlaceholder, OUString::number( nFilters ) ); - } + OUString sPlaceholder( "%s" ); + OUString aMsg; + if( nFilters == 0 ) + { + INetURLObject aURLObj( aURL ); + aMsg = XsltResId(STR_NO_FILTERS_FOUND); + aMsg = aMsg.replaceFirst(sPlaceholder, aURLObj.GetLastName()); + } + else if( nFilters == 1 ) + { + aMsg = XsltResId(STR_FILTER_INSTALLED); + aMsg = aMsg.replaceFirst( sPlaceholder, aFilterName ); - std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), - VclMessageType::Info, VclButtonsType::Ok, - aMsg)); - xInfoBox->run(); } + else + { + aMsg = XsltResId(STR_FILTERS_INSTALLED); + aMsg = aMsg.replaceFirst( sPlaceholder, OUString::number( nFilters ) ); + } + + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), + VclMessageType::Info, VclButtonsType::Ok, + aMsg)); + xInfoBox->run(); } void XMLFilterSettingsDialog::disposeFilterList() diff --git a/filter/source/xsltdialog/xmlfiltertabpagebasic.cxx b/filter/source/xsltdialog/xmlfiltertabpagebasic.cxx index c7516a1e484b..63b969a2fa80 100644 --- a/filter/source/xsltdialog/xmlfiltertabpagebasic.cxx +++ b/filter/source/xsltdialog/xmlfiltertabpagebasic.cxx @@ -73,56 +73,56 @@ static OUString checkExtensions( const OUString& rExtensions ) void XMLFilterTabPageBasic::FillInfo( filter_info_impl* pInfo ) { - if( pInfo ) - { - if( !m_xEDFilterName->get_text().isEmpty() ) - pInfo->maFilterName = m_xEDFilterName->get_text(); + if( !pInfo ) + return; + + if( !m_xEDFilterName->get_text().isEmpty() ) + pInfo->maFilterName = m_xEDFilterName->get_text(); + + if( !m_xCBApplication->get_active_text().isEmpty() ) + pInfo->maDocumentService = m_xCBApplication->get_active_text(); - if( !m_xCBApplication->get_active_text().isEmpty() ) - pInfo->maDocumentService = m_xCBApplication->get_active_text(); + if( !m_xEDInterfaceName->get_text().isEmpty() ) + pInfo->maInterfaceName = m_xEDInterfaceName->get_text(); - if( !m_xEDInterfaceName->get_text().isEmpty() ) - pInfo->maInterfaceName = m_xEDInterfaceName->get_text(); + if( !m_xEDExtension->get_text().isEmpty() ) + pInfo->maExtension = checkExtensions( m_xEDExtension->get_text() ); - if( !m_xEDExtension->get_text().isEmpty() ) - pInfo->maExtension = checkExtensions( m_xEDExtension->get_text() ); + pInfo->maComment = string_encode( m_xEDDescription->get_text() ); - pInfo->maComment = string_encode( m_xEDDescription->get_text() ); + if( pInfo->maDocumentService.isEmpty() ) + return; - if( !pInfo->maDocumentService.isEmpty() ) + std::vector< application_info_impl > const & rInfos = getApplicationInfos(); + for (auto const& info : rInfos) + { + if( pInfo->maDocumentService == info.maDocumentUIName ) { - std::vector< application_info_impl > const & rInfos = getApplicationInfos(); - for (auto const& info : rInfos) - { - if( pInfo->maDocumentService == info.maDocumentUIName ) - { - pInfo->maDocumentService = info.maDocumentService; - pInfo->maExportService = info.maXMLExporter; - pInfo->maImportService = info.maXMLImporter; - break; - } - } + pInfo->maDocumentService = info.maDocumentService; + pInfo->maExportService = info.maXMLExporter; + pInfo->maImportService = info.maXMLImporter; + break; } } } void XMLFilterTabPageBasic::SetInfo(const filter_info_impl* pInfo) { - if( pInfo ) - { - m_xEDFilterName->set_text( string_decode(pInfo->maFilterName) ); - /* - if( pInfo->maDocumentService.getLength() ) - maCBApplication.set_text( getApplicationUIName( pInfo->maDocumentService ) ); - */ - if( !pInfo->maExportService.isEmpty() ) - m_xCBApplication->set_entry_text( getApplicationUIName( pInfo->maExportService ) ); - else - m_xCBApplication->set_entry_text( getApplicationUIName( pInfo->maImportService ) ); - m_xEDInterfaceName->set_text( string_decode(pInfo->maInterfaceName) ); - m_xEDExtension->set_text( pInfo->maExtension ); - m_xEDDescription->set_text( string_decode( pInfo->maComment ) ); - } + if( !pInfo ) + return; + + m_xEDFilterName->set_text( string_decode(pInfo->maFilterName) ); + /* + if( pInfo->maDocumentService.getLength() ) + maCBApplication.set_text( getApplicationUIName( pInfo->maDocumentService ) ); + */ + if( !pInfo->maExportService.isEmpty() ) + m_xCBApplication->set_entry_text( getApplicationUIName( pInfo->maExportService ) ); + else + m_xCBApplication->set_entry_text( getApplicationUIName( pInfo->maImportService ) ); + m_xEDInterfaceName->set_text( string_decode(pInfo->maInterfaceName) ); + m_xEDExtension->set_text( pInfo->maExtension ); + m_xEDDescription->set_text( string_decode( pInfo->maComment ) ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/xsltdialog/xmlfiltertestdialog.cxx b/filter/source/xsltdialog/xmlfiltertestdialog.cxx index f2f237c31c30..e4a659a3653c 100644 --- a/filter/source/xsltdialog/xmlfiltertestdialog.cxx +++ b/filter/source/xsltdialog/xmlfiltertestdialog.cxx @@ -219,34 +219,34 @@ void XMLFilterTestDialog::updateCurrentDocumentButtonState( Reference< XComponen m_xPBCurrentDocument->set_sensitive( bExport && xCurrentDocument.is() ); m_xFTNameOfCurrentFile->set_sensitive( bExport && xCurrentDocument.is() ); - if( xCurrentDocument.is() ) + if( !xCurrentDocument.is() ) + return; + + OUString aTitle; + Reference< XDocumentPropertiesSupplier > xDPS( xCurrentDocument, UNO_QUERY ); + if( xDPS.is() ) { - OUString aTitle; - Reference< XDocumentPropertiesSupplier > xDPS( xCurrentDocument, UNO_QUERY ); - if( xDPS.is() ) + Reference< XDocumentProperties > xProps( xDPS->getDocumentProperties() ); + if( xProps.is() ) { - Reference< XDocumentProperties > xProps( xDPS->getDocumentProperties() ); - if( xProps.is() ) - { - aTitle = xProps->getTitle(); - } + aTitle = xProps->getTitle(); } + } - if( aTitle.isEmpty() ) + if( aTitle.isEmpty() ) + { + Reference< XStorable > xStorable( xCurrentDocument, UNO_QUERY ); + if( xStorable.is() ) { - Reference< XStorable > xStorable( xCurrentDocument, UNO_QUERY ); - if( xStorable.is() ) + if( xStorable->hasLocation() ) { - if( xStorable->hasLocation() ) - { - OUString aURL( xStorable->getLocation() ); - aTitle = getFileNameFromURL( aURL ); - } + OUString aURL( xStorable->getLocation() ); + aTitle = getFileNameFromURL( aURL ); } } - - m_xFTNameOfCurrentFile->set_label( aTitle ); } + + m_xFTNameOfCurrentFile->set_label( aTitle ); } void XMLFilterTestDialog::initDialog() |