diff options
author | Takeshi Kurosawa <taken.spc@gmail.com> | 2011-01-04 13:31:47 +0900 |
---|---|---|
committer | Thorsten Behrens <tbehrens@novell.com> | 2011-01-07 23:48:37 +0100 |
commit | 24e68935fb621eb6d30e30407f7b62deaede28a3 (patch) | |
tree | 3825c204754b23197a5ab5dc3422b61eec847ceb | |
parent | 4bdef1a10b2d2c76519961e1b85e16954f8b66ea (diff) |
Export text color
The color selection logic is what flash export filter does.
-rw-r--r-- | filter/source/svg/svgwriter.cxx | 97 | ||||
-rw-r--r-- | filter/source/svg/svgwriter.hxx | 1 |
2 files changed, 94 insertions, 4 deletions
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index 608f6b551..7765ea58e 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -809,6 +809,97 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const String& rText, const sal_Int32* pDXArray, long nWidth, const NMSP_RTL::OUString* pStyle ) { + const FontMetric aMetric( mpVDev->GetFontMetric() ); + + bool bTextSpecial = aMetric.IsShadow() || aMetric.IsOutline() || (aMetric.GetRelief() != RELIEF_NONE); + + if( !bTextSpecial ) + { + ImplWriteText( rPos, rText, pDXArray, nWidth, pStyle, mpVDev->GetTextColor() ); + } + else + { + if( aMetric.GetRelief() != RELIEF_NONE ) + { + Color aReliefColor( COL_LIGHTGRAY ); + Color aTextColor( mpVDev->GetTextColor() ); + + if ( aTextColor.GetColor() == COL_BLACK ) + aTextColor = Color( COL_WHITE ); + + if ( aTextColor.GetColor() == COL_WHITE ) + aReliefColor = Color( COL_BLACK ); + + + Point aPos( rPos ); + Point aOffset( 6, 6 ); + + if ( aMetric.GetRelief() == RELIEF_ENGRAVED ) + { + aPos -= aOffset; + } + else + { + aPos += aOffset; + } + + ImplWriteText( aPos, rText, pDXArray, nWidth, pStyle, aReliefColor ); + ImplWriteText( rPos, rText, pDXArray, nWidth, pStyle, aTextColor ); + } + else + { + if( aMetric.IsShadow() ) + { + long nOff = 1 + ((aMetric.GetLineHeight()-24)/24); + if ( aMetric.IsOutline() ) + nOff += 6; + + Color aTextColor( mpVDev->GetTextColor() ); + Color aShadowColor = Color( COL_BLACK ); + + if ( (aTextColor.GetColor() == COL_BLACK) || (aTextColor.GetLuminance() < 8) ) + aShadowColor = Color( COL_LIGHTGRAY ); + + Point aPos( rPos ); + aPos += Point( nOff, nOff ); + ImplWriteText( aPos, rText, pDXArray, nWidth, pStyle, aShadowColor ); + + if( !aMetric.IsOutline() ) + { + ImplWriteText( rPos, rText, pDXArray, nWidth, pStyle, aTextColor ); + } + } + + if( aMetric.IsOutline() ) + { + Point aPos = rPos + Point( -6, -6 ); + ImplWriteText( aPos, rText, pDXArray, nWidth, pStyle, mpVDev->GetTextColor() ); + aPos = rPos + Point( +6, +6); + ImplWriteText( aPos, rText, pDXArray, nWidth, pStyle, mpVDev->GetTextColor() ); + aPos = rPos + Point( -6, +0); + ImplWriteText( aPos, rText, pDXArray, nWidth, pStyle, mpVDev->GetTextColor() ); + aPos = rPos + Point( -6, +6); + ImplWriteText( aPos, rText, pDXArray, nWidth, pStyle, mpVDev->GetTextColor() ); + aPos = rPos + Point( +0, +6); + ImplWriteText( aPos, rText, pDXArray, nWidth, pStyle, mpVDev->GetTextColor() ); + aPos = rPos + Point( +0, -6); + ImplWriteText( aPos, rText, pDXArray, nWidth, pStyle, mpVDev->GetTextColor() ); + aPos = rPos + Point( +6, -1); + ImplWriteText( aPos, rText, pDXArray, nWidth, pStyle, mpVDev->GetTextColor() ); + aPos = rPos + Point( +6, +0); + ImplWriteText( aPos, rText, pDXArray, nWidth, pStyle, mpVDev->GetTextColor() ); + + ImplWriteText( rPos, rText, pDXArray, nWidth, pStyle, Color( COL_WHITE ) ); + } + } + } +} + +void SVGActionWriter::ImplWriteText( const Point& rPos, const String& rText, + const sal_Int32* pDXArray, long nWidth, + const NMSP_RTL::OUString* pStyle, + Color aTextColor ) +{ long nLen = rText.Len(), i; if( nLen ) @@ -864,6 +955,8 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const String& rText, break; } + mpContext->SetPaintAttr( COL_TRANSPARENT, aTextColor ); + // get mapped text position const Point aPt( ImplMap( aBaseLinePos ) ); @@ -1528,7 +1621,6 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, aFont.SetHeight( ImplMap( Size( 0, aFont.GetHeight() ) ).Height() ); mpContext->SetFontAttr( aFont ); - mpContext->SetPaintAttr( COL_TRANSPARENT, aFont.GetColor() ); ImplWriteText( pA->GetPoint(), String( pA->GetText(), pA->GetIndex(), pA->GetLen() ), NULL, 0, pStyle ); } } @@ -1543,7 +1635,6 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, aFont.SetHeight( ImplMap( Size( 0, aFont.GetHeight() ) ).Height() ); mpContext->SetFontAttr( aFont ); - mpContext->SetPaintAttr( COL_TRANSPARENT, aFont.GetColor() ); ImplWriteText( pA->GetRect().TopLeft(), pA->GetText(), NULL, 0, pStyle ); } } @@ -1559,7 +1650,6 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, aFont.SetHeight( ImplMap( Size( 0, aFont.GetHeight() ) ).Height() ); mpContext->SetFontAttr( aFont ); - mpContext->SetPaintAttr( COL_TRANSPARENT, aFont.GetColor() ); ImplWriteText( pA->GetPoint(), String( pA->GetText(), pA->GetIndex(), pA->GetLen() ), pA->GetDXArray(), 0, pStyle ); } } @@ -1574,7 +1664,6 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, aFont.SetHeight( ImplMap( Size( 0, aFont.GetHeight() ) ).Height() ); mpContext->SetFontAttr( aFont ); - mpContext->SetPaintAttr( COL_TRANSPARENT, aFont.GetColor() ); ImplWriteText( pA->GetPoint(), String( pA->GetText(), pA->GetIndex(), pA->GetLen() ), NULL, pA->GetWidth(), pStyle ); } } diff --git a/filter/source/svg/svgwriter.hxx b/filter/source/svg/svgwriter.hxx index 1bd786731..e1467c34d 100644 --- a/filter/source/svg/svgwriter.hxx +++ b/filter/source/svg/svgwriter.hxx @@ -187,6 +187,7 @@ private: void ImplWritePolyPolygon( const PolyPolygon& rPolyPoly, sal_Bool bLineOnly, const ::rtl::OUString* pStyle = NULL ); void ImplWriteGradientEx( const PolyPolygon& rPolyPoly, const Gradient& rGradient, const ::rtl::OUString* pStyle, sal_uInt32 nWriteFlags ); void ImplWriteText( const Point& rPos, const String& rText, const sal_Int32* pDXArray, long nWidth, const ::rtl::OUString* pStyle = NULL ); + void ImplWriteText( const Point& rPos, const String& rText, const sal_Int32* pDXArray, long nWidth, const ::rtl::OUString* pStyle, Color aTextColor ); void ImplWriteBmp( const BitmapEx& rBmpEx, const Point& rPt, const Size& rSz, const Point& rSrcPt, const Size& rSrcSz, const ::rtl::OUString* pStyle = NULL ); void ImplCheckFontAttributes(); |