diff options
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/flash/swfwriter.cxx | 13 | ||||
-rw-r--r-- | filter/source/flash/swfwriter.hxx | 3 | ||||
-rw-r--r-- | filter/source/flash/swfwriter1.cxx | 83 | ||||
-rw-r--r-- | filter/source/flash/swfwriter2.cxx | 6 | ||||
-rw-r--r-- | filter/source/pdf/pdfexport.cxx | 38 | ||||
-rw-r--r-- | filter/source/svg/svgwriter.cxx | 168 | ||||
-rw-r--r-- | filter/source/svg/svgwriter.hxx | 5 |
7 files changed, 287 insertions, 29 deletions
diff --git a/filter/source/flash/swfwriter.cxx b/filter/source/flash/swfwriter.cxx index 0ec6e6d3cb4a..968c7b513ea5 100644 --- a/filter/source/flash/swfwriter.cxx +++ b/filter/source/flash/swfwriter.cxx @@ -33,6 +33,7 @@ #include "swfwriter.hxx" #include <vcl/virdev.hxx> #include <vcl/gdimtf.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> using namespace ::swf; using namespace ::std; @@ -248,8 +249,10 @@ void Writer::placeShape( sal_uInt16 nID, sal_uInt16 nDepth, sal_Int32 x, sal_Int mpTag->addUI16( nDepth ); // depth mpTag->addUI16( nID ); // character Id - ::basegfx::B2DHomMatrix aMatrix; // #i73264# - aMatrix.translate( _Int16(static_cast<long>(map100thmm(x)*mnDocXScale)), _Int16(static_cast<long>(map100thmm(y)*mnDocYScale))); + // #i73264# + const basegfx::B2DHomMatrix aMatrix(basegfx::tools::createTranslateB2DHomMatrix( + _Int16(static_cast<long>(map100thmm(x)*mnDocXScale)), + _Int16(static_cast<long>(map100thmm(y)*mnDocYScale)))); mpTag->addMatrix( aMatrix ); // transformation matrix if( pName ) @@ -280,8 +283,10 @@ void Writer::moveShape( sal_uInt16 nDepth, sal_Int32 x, sal_Int32 y ) mpTag->addBits( aBits ); mpTag->addUI16( nDepth ); // depth - ::basegfx::B2DHomMatrix aMatrix; // #i73264# - aMatrix.translate( _Int16(static_cast<long>(map100thmm(x)*mnDocXScale)), _Int16(static_cast<long>(map100thmm(y)*mnDocYScale))); + // #i73264# + const basegfx::B2DHomMatrix aMatrix(basegfx::tools::createTranslateB2DHomMatrix( + _Int16(static_cast<long>(map100thmm(x)*mnDocXScale)), + _Int16(static_cast<long>(map100thmm(y)*mnDocYScale)))); mpTag->addMatrix( aMatrix ); // transformation matrix endTag(); diff --git a/filter/source/flash/swfwriter.hxx b/filter/source/flash/swfwriter.hxx index d91410c36b98..e8c75b8095b6 100644 --- a/filter/source/flash/swfwriter.hxx +++ b/filter/source/flash/swfwriter.hxx @@ -63,6 +63,8 @@ class PolyPolygon; class Gradient; class SvtGraphicFill; class SvtGraphicStroke; +class LineInfo; +namespace basegfx { class B2DPolygon; } inline sal_uInt16 _uInt16( sal_Int32 nValue ) { @@ -363,6 +365,7 @@ private: void Impl_writeBmp( sal_uInt16 nBitmapId, sal_uInt32 width, sal_uInt32 height, sal_uInt8 *pCompressed, sal_uInt32 compressed_size ); void Impl_writeImage( const BitmapEx& rBmpEx, const Point& rPt, const Size& rSz, const Point& rSrcPt, const Size& rSrcSz, const Rectangle& rClipRect, bool bMap ); void Impl_writeJPEG(sal_uInt16 nBitmapId, const sal_uInt8* pJpgData, sal_uInt32 nJpgDataLength, sal_uInt8 *pCompressed, sal_uInt32 compressed_size ); + void Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon); void Impl_writeActions( const GDIMetaFile& rMtf ); void Impl_writePolygon( const Polygon& rPoly, sal_Bool bFilled ); void Impl_writePolygon( const Polygon& rPoly, sal_Bool bFilled, const Color& rFillColor, const Color& rLineColor ); diff --git a/filter/source/flash/swfwriter1.cxx b/filter/source/flash/swfwriter1.cxx index 6718cc4be8be..ffe26c35699b 100644 --- a/filter/source/flash/swfwriter1.cxx +++ b/filter/source/flash/swfwriter1.cxx @@ -33,7 +33,6 @@ #include <com/sun/star/i18n/ScriptType.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> - #include <comphelper/processfactory.hxx> #include "swfwriter.hxx" #include <vcl/metaact.hxx> @@ -41,8 +40,7 @@ #include <vcl/bmpacc.hxx> #include <vcl/virdev.hxx> #include <vcl/metric.hxx> - - +#include <basegfx/matrix/b2dhommatrixtools.hxx> #include <svtools/filter.hxx> #include <vcl/graphictools.hxx> @@ -53,7 +51,10 @@ #include <external/zlib/zlib.h> #endif #endif + #include <vcl/salbtype.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> using namespace ::swf; using namespace ::std; @@ -640,9 +641,6 @@ void Writer::Impl_writeText( const Point& rPos, const String& rText, const sal_I // CL: This is still a hack until we figure out how to calculate a correct bound rect // for rotatet text Rectangle textBounds( 0, 0, static_cast<long>(mnDocWidth*mnDocXScale), static_cast<long>(mnDocHeight*mnDocYScale) ); - - ::basegfx::B2DHomMatrix m; // #i73264# - double scale = 1.0; // scale width if we have a stretched text @@ -660,7 +658,7 @@ void Writer::Impl_writeText( const Point& rPos, const String& rText, const sal_I scale = (double)n1 / (double)n2; } - m.rotate( static_cast<double>(nOrientation) * F_PI1800 ); + basegfx::B2DHomMatrix m(basegfx::tools::createRotateB2DHomMatrix(static_cast<double>(nOrientation) * F_PI1800)); m.translate( double(aPt.X() / scale), double(aPt.Y()) ); m.scale( scale, scale ); @@ -1240,6 +1238,12 @@ bool Writer::Impl_writeStroke( SvtGraphicStroke& rStroke ) Rectangle aNewRect( aPolyPolygon.GetBoundRect() ); + // as log as not LINESTYLE2 and DefineShape4 is used (which + // added support for LineJoin), only round LineJoins are + // supported. Fallback to META_POLYLINE_ACTION and META_LINE_ACTION + if(SvtGraphicStroke::joinRound != rStroke.getJoinType()) + return false; + PolyPolygon aStartArrow; rStroke.getStartArrow( aStartArrow ); if( 0 != aStartArrow.Count() ) @@ -1395,6 +1399,46 @@ 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; + + rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon); + + if(aLinePolyPolygon.count()) + { + for(sal_uInt32 a(0); a < aLinePolyPolygon.count(); a++) + { + const basegfx::B2DPolygon aCandidate(aLinePolyPolygon.getB2DPolygon(a)); + Impl_writePolygon(Polygon(aCandidate), sal_False ); + } + } + + if(aFillPolyPolygon.count()) + { + const Color aOldLineColor(mpVDev->GetLineColor()); + const Color aOldFillColor(mpVDev->GetFillColor()); + + mpVDev->SetLineColor(); + mpVDev->SetFillColor(aOldLineColor); + + for(sal_uInt32 a(0); a < aFillPolyPolygon.count(); a++) + { + const Polygon aPolygon(aFillPolyPolygon.getB2DPolygon(a)); + Impl_writePolyPolygon(PolyPolygon(Polygon(aPolygon)), sal_True ); + } + + mpVDev->SetLineColor(aOldLineColor); + mpVDev->SetFillColor(aOldFillColor); + } + } +} + +// ----------------------------------------------------------------------------- + void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) { Rectangle clipRect; @@ -1426,7 +1470,18 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) { const MetaLineAction* pA = (const MetaLineAction*) pAction; - Impl_writeLine( pA->GetStartPoint(), pA->GetEndPoint() ); + if(pA->GetLineInfo().IsDefault()) + { + Impl_writeLine( pA->GetStartPoint(), pA->GetEndPoint() ); + } + else + { + // LineInfo used; handle Dash/Dot and fat lines + basegfx::B2DPolygon aPolygon; + aPolygon.append(basegfx::B2DPoint(pA->GetStartPoint().X(), pA->GetStartPoint().Y())); + aPolygon.append(basegfx::B2DPoint(pA->GetEndPoint().X(), pA->GetEndPoint().Y())); + Impl_handleLineInfoPolyPolygons(pA->GetLineInfo(), aPolygon); + } } break; @@ -1501,7 +1556,17 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) const Polygon& rPoly = pA->GetPolygon(); if( rPoly.GetSize() ) - Impl_writePolygon( rPoly, sal_False ); + { + if(pA->GetLineInfo().IsDefault()) + { + Impl_writePolygon( rPoly, sal_False ); + } + else + { + // LineInfo used; handle Dash/Dot and fat lines + Impl_handleLineInfoPolyPolygons(pA->GetLineInfo(), rPoly.getB2DPolygon()); + } + } } break; diff --git a/filter/source/flash/swfwriter2.cxx b/filter/source/flash/swfwriter2.cxx index bbc5746cf2cd..891439668c91 100644 --- a/filter/source/flash/swfwriter2.cxx +++ b/filter/source/flash/swfwriter2.cxx @@ -32,6 +32,7 @@ #include "precompiled_filter.hxx" #include "swfwriter.hxx" #include <vcl/virdev.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> #include <math.h> @@ -608,10 +609,7 @@ struct GradRecord void FillStyle::Impl_addGradient( Tag* pTag ) const { vector< struct GradRecord > aGradientRecords; - - ::basegfx::B2DHomMatrix m; // #i73264# - - m.rotate( (maGradient.GetAngle() - 900) * F_PI1800 ); + basegfx::B2DHomMatrix m(basegfx::tools::createRotateB2DHomMatrix((maGradient.GetAngle() - 900) * F_PI1800)); switch( maGradient.GetStyle() ) { diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index 714ed9df7dc4..ab746ff725e8 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -1365,7 +1365,6 @@ sal_Bool PDFExport::ImplWriteActions( PDFWriter& rWriter, PDFExtOutDevData* pPDF PolyPolygon aEndArrow; double fTransparency( aStroke.getTransparency() ); double fStrokeWidth( aStroke.getStrokeWidth() ); - SvtGraphicStroke::JoinType eJT( aStroke.getJoinType() ); SvtGraphicStroke::DashArray aDashArray; aStroke.getStartArrow( aStartArrow ); @@ -1375,8 +1374,6 @@ sal_Bool PDFExport::ImplWriteActions( PDFWriter& rWriter, PDFExtOutDevData* pPDF bSkipSequence = sal_True; if ( aStartArrow.Count() || aEndArrow.Count() ) bSkipSequence = sal_False; - if ( (sal_uInt32)eJT > 2 ) - bSkipSequence = sal_False; if ( aDashArray.size() && ( fStrokeWidth != 0.0 ) && ( fTransparency == 0.0 ) ) bSkipSequence = sal_False; if ( bSkipSequence ) @@ -1404,7 +1401,40 @@ sal_Bool PDFExport::ImplWriteActions( PDFWriter& rWriter, PDFExtOutDevData* pPDF break; } aInfo.m_aDashArray = aDashArray; - rWriter.DrawPolyLine( aPath, aInfo ); + + if(SvtGraphicStroke::joinNone == aStroke.getJoinType() + && fStrokeWidth > 0.0) + { + // emulate no edge rounding by handling single edges + const sal_uInt16 nPoints(aPath.GetSize()); + const bool bCurve(aPath.HasFlags()); + + for(sal_uInt16 a(0); a + 1 < nPoints; a++) + { + if(bCurve + && POLY_NORMAL != aPath.GetFlags(a + 1) + && a + 2 < nPoints + && POLY_NORMAL != aPath.GetFlags(a + 2) + && a + 3 < nPoints) + { + const Polygon aSnippet(4, + aPath.GetConstPointAry() + a, + aPath.GetConstFlagAry() + a); + rWriter.DrawPolyLine( aSnippet, aInfo ); + a += 2; + } + else + { + const Polygon aSnippet(2, + aPath.GetConstPointAry() + a); + rWriter.DrawPolyLine( aSnippet, aInfo ); + } + } + } + else + { + rWriter.DrawPolyLine( aPath, aInfo ); + } } } else if ( pA->GetComment().Equals( "XPATHFILL_SEQ_BEGIN" ) ) diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index b66118c53473..fca8f8d48a3d 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -330,7 +330,7 @@ NMSP_RTL::OUString SVGAttributeWriter::GetFontStyle( const Font& rFont ) // ----------------------------------------------------------------------------- -NMSP_RTL::OUString SVGAttributeWriter::GetPaintStyle( const Color& rLineColor, const Color& rFillColor ) +NMSP_RTL::OUString SVGAttributeWriter::GetPaintStyle( const Color& rLineColor, const Color& rFillColor, const LineInfo* pLineInfo ) { FastString aStyle; @@ -357,6 +357,68 @@ NMSP_RTL::OUString SVGAttributeWriter::GetPaintStyle( const Color& rLineColor, c aStyle += B2UCONST( "stroke-opacity:" ); aStyle += NMSP_RTL::OUString::valueOf( ( 255 - (double) rLineColor.GetTransparency() ) / 255.0 ); } + + if(pLineInfo) + { + // more infos for line needed + if(pLineInfo->GetWidth() > 1) + { + aStyle += B2UCONST( ";" ); + aStyle += B2UCONST( "stroke-width:" ); + aStyle += NMSP_RTL::OUString::valueOf(pLineInfo->GetWidth()); + } + + if(LINE_DASH == pLineInfo->GetStyle()) + { + aStyle += B2UCONST( ";" ); + aStyle += B2UCONST( "stroke-dasharray:" ); + const long nDashLen(pLineInfo->GetDashLen()); + const long nDotLen(pLineInfo->GetDotLen()); + const long nDistance(pLineInfo->GetDistance()); + bool bIsFirst(true); + + for(sal_uInt16 a(0); a < pLineInfo->GetDashCount(); a++) + { + if(bIsFirst) + aStyle += B2UCONST(" "), bIsFirst = false; + else + aStyle += B2UCONST(","); + aStyle += NMSP_RTL::OUString::valueOf(nDashLen); + aStyle += B2UCONST(","); + aStyle += NMSP_RTL::OUString::valueOf(nDistance); + } + + for(sal_uInt16 b(0); b < pLineInfo->GetDotCount(); b++) + { + if(bIsFirst) + aStyle += B2UCONST(" "), bIsFirst = false; + else + aStyle += B2UCONST(","); + aStyle += NMSP_RTL::OUString::valueOf(nDotLen); + aStyle += B2UCONST(","); + aStyle += NMSP_RTL::OUString::valueOf(nDistance); + } + } + + if(basegfx::B2DLINEJOIN_MITER != pLineInfo->GetLineJoin()) + { + aStyle += B2UCONST( ";" ); + aStyle += B2UCONST( "stroke-linejoin:" ); + + switch(pLineInfo->GetLineJoin()) + { + default: // B2DLINEJOIN_NONE, B2DLINEJOIN_MIDDLE, B2DLINEJOIN_MITER + aStyle += B2UCONST( "miter" ); + break; + case basegfx::B2DLINEJOIN_ROUND: + aStyle += B2UCONST( "round" ); + break; + case basegfx::B2DLINEJOIN_BEVEL: + aStyle += B2UCONST( "bevel" ); + break; + } + } + } } // fill color @@ -403,12 +465,12 @@ void SVGAttributeWriter::SetFontAttr( const Font& rFont ) // ----------------------------------------------------------------------------- -void SVGAttributeWriter::SetPaintAttr( const Color& rLineColor, const Color& rFillColor ) +void SVGAttributeWriter::SetPaintAttr( const Color& rLineColor, const Color& rFillColor, const LineInfo* pLineInfo ) { if( !mpElemPaint || ( rLineColor != maCurLineColor ) || ( rFillColor != maCurFillColor ) ) { delete mpElemPaint; - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, GetPaintStyle( maCurLineColor = rLineColor, maCurFillColor = rFillColor ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, GetPaintStyle( maCurLineColor = rLineColor, maCurFillColor = rFillColor, pLineInfo ) ); mpElemPaint = new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemG, TRUE, TRUE ); } } @@ -460,6 +522,48 @@ Size SVGActionWriter::ImplMap( const Size& rSz ) const // ----------------------------------------------------------------------------- +LineInfo SVGActionWriter::ImplMap( const LineInfo& rLineInfo ) const +{ + LineInfo aInfo(rLineInfo); + long aTemp(0); + + if(aInfo.GetStyle() == LINE_DASH) + { + if(aInfo.GetDotCount() && aInfo.GetDotLen()) + { + aTemp = aInfo.GetDotLen(); + mpVDev->LogicToLogic(&aTemp, 1, &mpVDev->GetMapMode(), &maTargetMapMode); + aInfo.SetDotLen(Max(aTemp, 1L)); + } + else + aInfo.SetDotCount(0); + + if(aInfo.GetDashCount() && aInfo.GetDashLen()) + { + aTemp = aInfo.GetDashLen(); + mpVDev->LogicToLogic(&aTemp, 1, &mpVDev->GetMapMode(), &maTargetMapMode); + aInfo.SetDashLen(Max(aTemp, 1L)); + } + else + aInfo.SetDashCount(0); + + aTemp = aInfo.GetDistance(); + mpVDev->LogicToLogic(&aTemp, 1, &mpVDev->GetMapMode(), &maTargetMapMode); + aInfo.SetDistance(aTemp); + + if((!aInfo.GetDashCount() && !aInfo.GetDotCount()) || !aInfo.GetDistance()) + aInfo.SetStyle(LINE_SOLID); + } + + aTemp = aInfo.GetWidth(); + mpVDev->LogicToLogic(&aTemp, 1, &mpVDev->GetMapMode(), &maTargetMapMode); + aInfo.SetWidth(aTemp); + + return aInfo; +} + +// ----------------------------------------------------------------------------- + NMSP_RTL::OUString SVGActionWriter::GetValueString( sal_Int32 nVal ) { return ::rtl::OUString::valueOf( nVal ); @@ -1017,7 +1121,16 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, { const MetaLineAction* pA = (const MetaLineAction*) pAction; - mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetLineColor() ); + if(pA->GetLineInfo().IsDefault()) + { + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetLineColor() ); + } + else + { + const LineInfo aMappedLineInfo(ImplMap(pA->GetLineInfo())); + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetLineColor(), &aMappedLineInfo ); + } + ImplWriteLine( pA->GetStartPoint(), pA->GetEndPoint(), NULL, pStyle ); } } @@ -1113,8 +1226,51 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( rPoly.GetSize() ) { - mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); - ImplWritePolyPolygon( rPoly, sal_True, pStyle ); + bool bNoLineJoin(false); + + if(pA->GetLineInfo().IsDefault()) + { + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + } + else + { + const LineInfo aMappedLineInfo(ImplMap(pA->GetLineInfo())); + bNoLineJoin = basegfx::B2DLINEJOIN_NONE == aMappedLineInfo.GetLineJoin(); + mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor(), &aMappedLineInfo ); + } + + if(bNoLineJoin) + { + // emulate B2DLINEJOIN_NONE by creating single edges + const sal_uInt16 nPoints(rPoly.GetSize()); + const bool bCurve(rPoly.HasFlags()); + + for(sal_uInt16 a(0); a + 1 < nPoints; a++) + { + if(bCurve + && POLY_NORMAL != rPoly.GetFlags(a + 1) + && a + 2 < nPoints + && POLY_NORMAL != rPoly.GetFlags(a + 2) + && a + 3 < nPoints) + { + const Polygon aSnippet(4, + rPoly.GetConstPointAry() + a, + rPoly.GetConstFlagAry() + a); + ImplWritePolyPolygon( aSnippet, sal_True, pStyle ); + a += 2; + } + else + { + const Polygon aSnippet(2, + rPoly.GetConstPointAry() + a); + ImplWritePolyPolygon( aSnippet, sal_True, pStyle ); + } + } + } + else + { + ImplWritePolyPolygon( rPoly, sal_True, pStyle ); + } } } } diff --git a/filter/source/svg/svgwriter.hxx b/filter/source/svg/svgwriter.hxx index 2a1e5a9ee514..658fc19b0322 100644 --- a/filter/source/svg/svgwriter.hxx +++ b/filter/source/svg/svgwriter.hxx @@ -156,10 +156,10 @@ public: virtual ~SVGAttributeWriter(); ::rtl::OUString GetFontStyle( const Font& rFont ); - ::rtl::OUString GetPaintStyle( const Color& rLineColor, const Color& rFillColor ); + ::rtl::OUString GetPaintStyle( const Color& rLineColor, const Color& rFillColor, const LineInfo* pLineInfo ); void SetFontAttr( const Font& rFont ); - void SetPaintAttr( const Color& rLineColor, const Color& rFillColor ); + void SetPaintAttr( const Color& rLineColor, const Color& rFillColor, const LineInfo* pLineInfo = 0); }; // ------------------- @@ -192,6 +192,7 @@ private: long ImplMap( sal_Int32 nVal ) const; Point ImplMap( const Point& rPt ) const; Size ImplMap( const Size& rSz ) const; + LineInfo ImplMap( const LineInfo& rLineInfo ) const; inline Rectangle ImplMap( const Rectangle& rRect ) const { return Rectangle( ImplMap( rRect.TopLeft() ), ImplMap( rRect.GetSize() ) ); } void ImplWriteLine( const Point& rPt1, const Point& rPt2, const Color* pLineColor = NULL, const ::rtl::OUString* pStyle = NULL ); |