diff options
author | Armin Le Grand <Armin.Le.Grand@Sun.COM> | 2009-10-22 11:10:27 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@Sun.COM> | 2009-10-22 11:10:27 +0200 |
commit | 6016d7a2007f3f09e10c17b61b7aa979391cc3b7 (patch) | |
tree | 5142c0a9717dc114afe50104562bdda7ec43a190 /filter | |
parent | 4324965f99217790136cb79160f8449f18ff3975 (diff) |
#i105655# most changes for MetaFile consumers done
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/flash/swfwriter1.cxx | 97 | ||||
-rw-r--r-- | filter/source/pdf/pdfexport.cxx | 3 | ||||
-rw-r--r-- | filter/source/svg/svgwriter.cxx | 170 | ||||
-rw-r--r-- | filter/source/svg/svgwriter.hxx | 5 |
4 files changed, 191 insertions, 84 deletions
diff --git a/filter/source/flash/swfwriter1.cxx b/filter/source/flash/swfwriter1.cxx index 8038abb2f268..ffe26c35699b 100644 --- a/filter/source/flash/swfwriter1.cxx +++ b/filter/source/flash/swfwriter1.cxx @@ -41,11 +41,8 @@ #include <vcl/virdev.hxx> #include <vcl/metric.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> -#include <basegfx/polygon/b2dpolygontools.hxx> -#include <basegfx/polygon/b2dlinegeometry.hxx> #include <svtools/filter.hxx> #include <vcl/graphictools.hxx> -#include <numeric> #ifndef _ZLIB_H #ifdef SYSTEM_ZLIB @@ -54,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; @@ -1401,90 +1401,39 @@ bool Writer::Impl_writePageField( Rectangle& rTextBounds ) void Writer::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon) { - basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon); - basegfx::B2DPolyPolygon aFillPolyPolygon; - const bool bDashUsed(LINE_DASH == rInfo.GetStyle()); - const bool bLineWidthUsed(rInfo.GetWidth() > 1); - - if(bDashUsed && aLinePolyPolygon.count()) + if(rLinePolygon.count()) { - ::std::vector< double > fDotDashArray; - const double fDashLen(rInfo.GetDashLen()); - const double fDotLen(rInfo.GetDotLen()); - const double fDistance(rInfo.GetDistance()); + basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon); + basegfx::B2DPolyPolygon aFillPolyPolygon; - for(sal_uInt16 a(0); a < rInfo.GetDashCount(); a++) - { - fDotDashArray.push_back(fDashLen); - fDotDashArray.push_back(fDistance); - } + rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon); - for(sal_uInt16 b(0); b < rInfo.GetDotCount(); b++) + if(aLinePolyPolygon.count()) { - fDotDashArray.push_back(fDotLen); - fDotDashArray.push_back(fDistance); - } - - const double fAccumulated(::std::accumulate(fDotDashArray.begin(), fDotDashArray.end(), 0.0)); - - if(fAccumulated > 0.0) - { - basegfx::B2DPolyPolygon aResult; - - for(sal_uInt32 c(0); c < aLinePolyPolygon.count(); c++) + for(sal_uInt32 a(0); a < aLinePolyPolygon.count(); a++) { - basegfx::B2DPolyPolygon aLineTraget; - basegfx::tools::applyLineDashing( - aLinePolyPolygon.getB2DPolygon(c), - fDotDashArray, - &aLineTraget); - aResult.append(aLineTraget); + const basegfx::B2DPolygon aCandidate(aLinePolyPolygon.getB2DPolygon(a)); + Impl_writePolygon(Polygon(aCandidate), sal_False ); } - - aLinePolyPolygon = aResult; - } - } - - if(bLineWidthUsed && aLinePolyPolygon.count()) - { - const double fHalfLineWidth((rInfo.GetWidth() * 0.5) + 0.5); - - for(sal_uInt32 a(0); a < aLinePolyPolygon.count(); a++) - { - aFillPolyPolygon.append(basegfx::tools::createAreaGeometry( - aLinePolyPolygon.getB2DPolygon(a), - fHalfLineWidth, - rInfo.GetLineJoin())); } - aLinePolyPolygon.clear(); - } - - if(aLinePolyPolygon.count()) - { - for(sal_uInt32 a(0); a < aLinePolyPolygon.count(); a++) + if(aFillPolyPolygon.count()) { - const basegfx::B2DPolygon aCandidate(aLinePolyPolygon.getB2DPolygon(a)); - Impl_writePolygon(Polygon(aCandidate), sal_False ); - } - } + const Color aOldLineColor(mpVDev->GetLineColor()); + const Color aOldFillColor(mpVDev->GetFillColor()); - if(aFillPolyPolygon.count()) - { - const Color aOldLineColor(mpVDev->GetLineColor()); - const Color aOldFillColor(mpVDev->GetFillColor()); + mpVDev->SetLineColor(); + mpVDev->SetFillColor(aOldLineColor); - 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 ); + } - 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); } - - mpVDev->SetLineColor(aOldLineColor); - mpVDev->SetFillColor(aOldFillColor); } } diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index ca40914b076f..14b7ab29219d 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -1388,7 +1388,8 @@ sal_Bool PDFExport::ImplWriteActions( PDFWriter& rWriter, PDFExtOutDevData* pPDF } aInfo.m_aDashArray = aDashArray; - if(SvtGraphicStroke::joinNone == aStroke.getJoinType()) + if(SvtGraphicStroke::joinNone == aStroke.getJoinType() + && fStrokeWidth > 0.0) { // emulate no edge rounding by handling single edges const sal_uInt16 nPoints(aPath.GetSize()); diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index 08f2ffb856f2..466d494ae445 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 ); @@ -620,7 +724,7 @@ void SVGActionWriter::ImplWritePolyPolygon( const PolyPolygon& rPolyPoly, sal_Bo { const Polygon& rPoly = rPolyPoly[ i ]; const USHORT nSize = rPoly.GetSize(); - Polygon aMappedPoly( nSize ); + Polygon aMappedPoly(rPoly); // do copy the flag values, too for( USHORT n = 0; n < nSize; n++ ) aMappedPoly[ n ] = ImplMap( rPoly[ n ] ); @@ -1009,7 +1113,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 ); } } @@ -1105,8 +1218,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 ); |