diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2011-03-29 15:25:13 +0200 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2011-03-29 15:25:13 +0200 |
commit | 0ec3a97b80519a1046056aa607deeb0fd5668798 (patch) | |
tree | ba3d5093ee191af6e961f779a3bc967552a0e351 | |
parent | fdbcb97a0fd206351ac15af49480715dbc969255 (diff) | |
parent | 95211ffc55b30c7e289e81d05dacd5775a35e13a (diff) |
CWS-TOOLING: integrate CWS ka102
23 files changed, 2515 insertions, 1232 deletions
diff --git a/filter/prj/build.lst b/filter/prj/build.lst index c8e839dce..b2182d762 100644 --- a/filter/prj/build.lst +++ b/filter/prj/build.lst @@ -9,11 +9,11 @@ fl filter\source\msfilter\powerpoint nmake - all fl_powerpoint fl_inc NULL fl filter\source\pdf nmake - all fl_pdf fl_svg fl_inc NULL fl filter\source\svg nmake - all fl_svg fl_inc NULL fl filter\source\placeware nmake - all fl_placeware fl_inc NULL -fl filter\source\flash nmake - all fl_flash fl_pdf fl_inc NULL +fl filter\source\flash nmake - all fl_flash fl_pdf fl_inc NULL fl filter\source\filtertracer nmake - all fl_filtertracer fl_inc NULL fl filter\source\xsltfilter nmake - all fl_xsltfilter fl_inc NULL -fl filter\source\xsltvalidate nmake - all fl_xsltvalidate fl_xsltfilter fl_inc NULL -fl filter\source\xsltdialog nmake - all fl_xsltdialog fl_flash fl_inc NULL +fl filter\source\xsltvalidate nmake - all fl_xsltvalidate fl_xsltfilter fl_inc NULL +fl filter\source\xsltdialog nmake - all fl_xsltdialog fl_flash fl_inc NULL fl filter\source\docbook nmake - all fl_docbook fl_inc NULL fl filter\source\t602 nmake - all fl_t602 fl_inc NULL fl filter\source\graphicfilter\eos2met nmake - all g_vfeom fl_inc NULL diff --git a/filter/source/config/fragments/fcfg_drawgraphics.mk b/filter/source/config/fragments/fcfg_drawgraphics.mk index 7038e27e8..948423a3e 100644 --- a/filter/source/config/fragments/fcfg_drawgraphics.mk +++ b/filter/source/config/fragments/fcfg_drawgraphics.mk @@ -53,6 +53,7 @@ F4_DRAWGRAPHICS = \ RAS___Sun_Rasterfile \ SGF___StarOffice_Writer_SGF \ SGV___StarDraw_2_0 \ + SVG___Scalable_Vector_Graphics \ SVM___StarView_Metafile \ TGA___Truevision_TARGA \ TIF___Tag_Image_File \ diff --git a/filter/source/config/fragments/fcfg_internalgraphics.mk b/filter/source/config/fragments/fcfg_internalgraphics.mk index ae978f0ca..d1f628a6b 100644 --- a/filter/source/config/fragments/fcfg_internalgraphics.mk +++ b/filter/source/config/fragments/fcfg_internalgraphics.mk @@ -68,6 +68,7 @@ F4_INTERNALGRAPHICS = \ sgf_Import \ sgv_Import \ svg_Export \ + svg_Import \ svm_Export \ svm_Import \ tga_Import \ diff --git a/filter/source/config/fragments/filters/SVG___Scalable_Vector_Graphics.xcu b/filter/source/config/fragments/filters/SVG___Scalable_Vector_Graphics.xcu new file mode 100644 index 000000000..69ad0d0cb --- /dev/null +++ b/filter/source/config/fragments/filters/SVG___Scalable_Vector_Graphics.xcu @@ -0,0 +1,13 @@ + <node oor:name="SVG - Scalable Vector Graphics" oor:op="replace"> + <prop oor:name="Flags"><value>IMPORT ALIEN</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="FilterService"/> + <prop oor:name="UserData"><value></value></prop> + <prop oor:name="UIName"> + <value xml:lang="x-default">SVG - Scalable Vector Graphics</value> + </prop> + <prop oor:name="FileFormatVersion"><value>0</value></prop> + <prop oor:name="Type"><value>svg_Scalable_Vector_Graphics</value></prop> + <prop oor:name="TemplateName"/> + <prop oor:name="DocumentService"><value>com.sun.star.drawing.DrawingDocument</value></prop> + </node> diff --git a/filter/source/config/fragments/internalgraphicfilters/svg_Import.xcu b/filter/source/config/fragments/internalgraphicfilters/svg_Import.xcu new file mode 100644 index 000000000..5e21c0339 --- /dev/null +++ b/filter/source/config/fragments/internalgraphicfilters/svg_Import.xcu @@ -0,0 +1,10 @@ + <node oor:name="svg_Import" oor:op="replace" > + <prop oor:name="Type"><value>svg_Scalable_Vector_Graphics</value></prop> + <prop oor:name="FormatName"><value>SVISVG</value></prop> + <prop oor:name="RealFilterName"><value>SVG - Scalable Vector Graphics</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="UIName"> + <value xml:lang="en-US">SVG - Scalable Vector Graphics</value> + </prop> + <prop oor:name="Flags"><value>IMPORT</value></prop> + </node> diff --git a/filter/source/config/fragments/types/svg_Scalable_Vector_Graphics.xcu b/filter/source/config/fragments/types/svg_Scalable_Vector_Graphics.xcu index 37643df4c..2ed059266 100644 --- a/filter/source/config/fragments/types/svg_Scalable_Vector_Graphics.xcu +++ b/filter/source/config/fragments/types/svg_Scalable_Vector_Graphics.xcu @@ -1,10 +1,10 @@ <node oor:name="svg_Scalable_Vector_Graphics" oor:op="replace" > - <prop oor:name="DetectService"/> + <prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop> <prop oor:name="URLPattern"/> <prop oor:name="Extensions"><value>svg</value></prop> <prop oor:name="MediaType"><value>image/svg+xml</value></prop> <prop oor:name="Preferred"><value>false</value></prop> - <prop oor:name="PreferredFilter"/> + <prop oor:name="PreferredFilter"><value>SVG - Scalable Vector Graphics</value></prop> <prop oor:name="UIName"> <value>SVG - Scalable Vector Graphics</value> </prop> diff --git a/filter/source/flash/swfwriter1.cxx b/filter/source/flash/swfwriter1.cxx index e0ca2ef58..2c9e55163 100644 --- a/filter/source/flash/swfwriter1.cxx +++ b/filter/source/flash/swfwriter1.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -40,6 +40,7 @@ #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <svtools/filter.hxx> #include <vcl/graphictools.hxx> +#include <vcl/rendergraphicrasterizer.hxx> #ifndef _ZLIB_H #ifdef SYSTEM_ZLIB @@ -150,7 +151,7 @@ void Writer::Impl_addPolygon( BitStream& rBits, const Polygon& rPoly, sal_Bool b while( ( i + 1 ) < nSize ) { if( ( i + 3 ) < nSize ) - { + { PolyFlags P1( rPoly.GetFlags( i ) ); PolyFlags P4( rPoly.GetFlags( i + 3 ) ); @@ -159,7 +160,7 @@ void Writer::Impl_addPolygon( BitStream& rBits, const Polygon& rPoly, sal_Bool b ( POLY_CONTROL == rPoly.GetFlags( i + 2 ) ) && ( POLY_NORMAL == P4 || POLY_SMOOTH == P4 || POLY_SYMMTR == P4 ) ) { - Impl_quadBezierApprox( rBits, aLastPoint, d*d, + Impl_quadBezierApprox( rBits, aLastPoint, d*d, rPoly.GetPoint( i ).X(), rPoly.GetPoint( i ).Y(), rPoly.GetPoint( i+1 ).X(), rPoly.GetPoint( i+1 ).Y(), rPoly.GetPoint( i+2 ).X(), rPoly.GetPoint( i+2 ).Y(), @@ -167,8 +168,8 @@ void Writer::Impl_addPolygon( BitStream& rBits, const Polygon& rPoly, sal_Bool b i += 3; continue; } - } - + } + ++i; const Point aPolyPoint( rPoly[ i ] ); @@ -227,7 +228,7 @@ void Writer::Impl_addStraightEdgeRecord( BitStream& rBits, sal_Int16 dx, sal_Int if( (dx != 0) && (dy != 0) ) { - rBits.writeUB( 1, 1 ); // GeneralLineFlag + rBits.writeUB( 1, 1 ); // GeneralLineFlag rBits.writeSB( dx, nBits ); // DeltaX rBits.writeSB( dy, nBits ); // DeltaY } @@ -256,8 +257,8 @@ void Writer::Impl_addCurvedEdgeRecord( BitStream& rBits, sal_Int16 control_dx, s rBits.writeUB( 0, 1 ); // CurvedFlag sal_uInt8 nBits = static_cast<sal_uInt8>( - max( getMaxBitsSigned( control_dx ), - max( getMaxBitsSigned( control_dy ), + max( getMaxBitsSigned( control_dx ), + max( getMaxBitsSigned( control_dy ), max( getMaxBitsSigned( anchor_dx ), max( getMaxBitsSigned( anchor_dy ), (sal_uInt16)3 ) ) ) ) ); @@ -557,7 +558,7 @@ void Writer::Impl_writeText( const Point& rPos, const String& rText, const sal_I pDX = (sal_Int32*) pDXArray; } else - { + { pOwnArray = new sal_Int32[ nLen ]; aNormSize = Size( mpVDev->GetTextArray( rText, pOwnArray ), 0 ); pDX = pOwnArray; @@ -590,7 +591,7 @@ void Writer::Impl_writeText( const Point& rPos, const String& rText, const sal_I const FontMetric aMetric( mpVDev->GetFontMetric() ); FlashFont& rFlashFont = Impl_getFont( aFont ); - + // always adjust text position to match baseline alignment switch( aOldFont.GetAlign() ) { @@ -635,7 +636,7 @@ void Writer::Impl_writeText( const Point& rPos, const String& rText, const sal_I } #endif - // CL: This is still a hack until we figure out how to calculate a correct bound rect + // 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) ); double scale = 1.0; @@ -656,7 +657,7 @@ void Writer::Impl_writeText( const Point& rPos, const String& rText, const sal_I } basegfx::B2DHomMatrix m(basegfx::tools::createRotateB2DHomMatrix(static_cast<double>(nOrientation) * F_PI1800)); - m.translate( double(aPt.X() / scale), double(aPt.Y()) ); + m.translate( double(aPt.X() / scale), double(aPt.Y()) ); m.scale( scale, scale ); sal_Int16 nHeight = _Int16( map( Size( 0, aFont.GetHeight() ) ).Height() ); @@ -718,7 +719,7 @@ void Writer::Impl_writeText( const Point& rPos, const String& rText, const sal_I // export facility, although the positioning had to be tweaked a little. I can't explain the // numbers, but the flash lines up very well with the original OOo document. All of this should // probably be converted to polygons as part of the meta file, though, as we don't handle any - // fancy lines (like dashes). + // fancy lines (like dashes). if( ( aOldFont.GetStrikeout() != STRIKEOUT_NONE ) || ( aOldFont.GetUnderline() != UNDERLINE_NONE ) ) { Polygon aPoly( 4 ); @@ -726,15 +727,15 @@ void Writer::Impl_writeText( const Point& rPos, const String& rText, const sal_I if( aOldFont.GetStrikeout() != STRIKEOUT_NONE ) { - aPoly[ 0 ].X() = aBaseLinePos.X(); + aPoly[ 0 ].X() = aBaseLinePos.X(); aPoly[ 0 ].Y() = aBaseLinePos.Y() - FRound( aMetric.GetAscent() * 0.26 ) - nLineHeight; - aPoly[ 1 ].X() = aPoly[ 0 ].X() + aNormSize.Width() - 1; + aPoly[ 1 ].X() = aPoly[ 0 ].X() + aNormSize.Width() - 1; aPoly[ 1 ].Y() = aPoly[ 0 ].Y(); - aPoly[ 2 ].X() = aPoly[ 1 ].X(); + aPoly[ 2 ].X() = aPoly[ 1 ].X(); aPoly[ 2 ].Y() = aPoly[ 1 ].Y() + nLineHeight - 1; - aPoly[ 3 ].X() = aPoly[ 0 ].X(); + aPoly[ 3 ].X() = aPoly[ 0 ].X(); aPoly[ 3 ].Y() = aPoly[ 2 ].Y(); - + Impl_writePolygon( aPoly, sal_True, aTextColor, aTextColor ); } @@ -742,13 +743,13 @@ void Writer::Impl_writeText( const Point& rPos, const String& rText, const sal_I // but it looks good to me. if( aOldFont.GetUnderline() != UNDERLINE_NONE ) { - aPoly[ 0 ].X() = aBaseLinePos.X(); + aPoly[ 0 ].X() = aBaseLinePos.X(); aPoly[ 0 ].Y() = static_cast<long>(aBaseLinePos.Y() + 1.5*nLineHeight); - aPoly[ 1 ].X() = aPoly[ 0 ].X() + aNormSize.Width() - 1; + aPoly[ 1 ].X() = aPoly[ 0 ].X() + aNormSize.Width() - 1; aPoly[ 1 ].Y() = aPoly[ 0 ].Y(); - aPoly[ 2 ].X() = aPoly[ 1 ].X(); + aPoly[ 2 ].X() = aPoly[ 1 ].X(); aPoly[ 2 ].Y() = aPoly[ 1 ].Y() + nLineHeight - 1; - aPoly[ 3 ].X() = aPoly[ 0 ].X(); + aPoly[ 3 ].X() = aPoly[ 0 ].X(); aPoly[ 3 ].Y() = aPoly[ 2 ].Y(); Impl_writePolygon( aPoly, sal_True, aTextColor, aTextColor ); @@ -863,7 +864,7 @@ sal_uInt16 Writer::defineBitmap( const BitmapEx &bmpSource, sal_Int32 nJPEGQuali compress2(pCompressed, &compressed_size, pImageData, raw_size, Z_BEST_COMPRESSION); #endif - // AS: SWF files let you provide an Alpha mask for JPEG images, but we have + // AS: SWF files let you provide an Alpha mask for JPEG images, but we have // to ZLIB compress the alpha channel seperately. uLong alpha_compressed_size = 0; sal_uInt8 *pAlphaCompressed = NULL; @@ -872,7 +873,7 @@ sal_uInt16 Writer::defineBitmap( const BitmapEx &bmpSource, sal_Int32 nJPEGQuali alpha_compressed_size = uLongf(width * height + (sal_uInt32)(raw_size/100) + 12); pAlphaCompressed = new sal_uInt8[ compressed_size ]; -#ifdef DBG_UTIL +#ifdef DBG_UTIL if(compress2(pAlphaCompressed, &alpha_compressed_size, pAlphaData, width * height, Z_BEST_COMPRESSION) != Z_OK) { DBG_ASSERT( false, "compress2 failed!" ); ((void)0); @@ -948,14 +949,14 @@ void Writer::Impl_writeImage( const BitmapEx& rBmpEx, const Point& rPt, const Si // However, I can't explain why exactly. I got some of this by trial and error. double XScale = static_cast<double>(originalPixelRect.GetWidth())/destRect.GetWidth(); double YScale = static_cast<double>(originalPixelRect.GetHeight())/destRect.GetHeight(); - + // 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 + // 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() ); @@ -967,9 +968,9 @@ void Writer::Impl_writeImage( const BitmapEx& rBmpEx, const Point& rPt, const Si // AS: The bmp origion 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... - Rectangle cropPixelRect(static_cast<long>(cropRect.Left()*XScale), - static_cast<long>(cropRect.Top()*YScale), - static_cast<long>(cropRect.Right()*XScale), + 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); @@ -1053,7 +1054,7 @@ void Writer::Impl_writeJPEG(sal_uInt16 nBitmapId, const sal_uInt8* pJpgData, sal // the header and the image need start and stop (D8 and D9), // so that's why you see those written to both. I don't // really know what the rest of these are, I got it to work - // kind of by trial and error and by comparing with known + // kind of by trial and error and by comparing with known // good SWF files. sal_uInt8 cType = 0x01; const sal_uInt8* pJpgSearch = pJpgData; @@ -1089,7 +1090,7 @@ void Writer::Impl_writeJPEG(sal_uInt16 nBitmapId, const sal_uInt8* pJpgData, sal { // AS: Lengths are big endian. - // Beware. pJpgSearch is not necessarily word-aligned, + // Beware. pJpgSearch is not necessarily word-aligned, // so we access it byte-wise. // AS: Add 2 to the length to include the 0xFFXX itself. @@ -1202,7 +1203,7 @@ void Writer::Impl_writeRect( const Rectangle& rRect, long nRadX, long nRadY ) if( (rRect.nTop == rRect.nBottom) || (rRect.nLeft == rRect.nRight) ) { Color aColor( mpVDev->GetFillColor() ); - Impl_writeLine( rRect.TopLeft(), rRect.BottomRight(), &aColor ); + Impl_writeLine( rRect.TopLeft(), rRect.BottomRight(), &aColor ); } else { @@ -1323,9 +1324,9 @@ bool Writer::Impl_writeFilling( SvtGraphicFill& rFilling ) aMatrix.set(a, b, aTransform.matrix[a*3+b]); } } - aMatrix.set(2, 0, 0.0); - aMatrix.set(2, 1, 0.0); - aMatrix.set(2, 2, 1.0); + aMatrix.set(2, 0, 0.0); + aMatrix.set(2, 1, 0.0); + aMatrix.set(2, 2, 1.0); // scale bitmap Rectangle originalPixelRect = Rectangle(Point(), aGraphic.GetBitmapEx().GetSizePixel()); @@ -1347,7 +1348,7 @@ bool Writer::Impl_writeFilling( SvtGraphicFill& rFilling ) // ----------------------------------------------------------------------------- -/* CL: The idea was to export page fields as text fields that get theire +/* CL: The idea was to export page fields as text fields that get theire string from a variable set with actionscript by each page. This didn't work out since the formating is always wrong when text follows the page number field since pages greater one may require more space than @@ -1466,7 +1467,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) case( META_LINE_ACTION ): { const MetaLineAction* pA = (const MetaLineAction*) pAction; - + if(pA->GetLineInfo().IsDefault()) { Impl_writeLine( pA->GetStartPoint(), pA->GetEndPoint() ); @@ -1534,7 +1535,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_CHORD ); } break; - + case( META_POLYGON_ACTION ): aPoly = ( (const MetaPolygonAction*) pAction )->GetPolygon(); break; @@ -1664,13 +1665,13 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) for( sal_uLong j = 0, nC = aGDIMetaFile.GetActionCount(); ( j < nC ) && !bFound; j++ ) { const MetaAction* pSubstAct = aGDIMetaFile.GetAction( j ); - + if( pSubstAct->GetType() == META_BMPSCALE_ACTION ) { bFound = sal_True; const MetaBmpScaleAction* pBmpScaleAction = (const MetaBmpScaleAction*) pSubstAct; - Impl_writeImage( pBmpScaleAction->GetBitmap(), - pA->GetPoint(), pA->GetSize(), + Impl_writeImage( pBmpScaleAction->GetBitmap(), + pA->GetPoint(), pA->GetSize(), Point(), pBmpScaleAction->GetBitmap().GetSizePixel(), clipRect, 1 == bMap ); } } @@ -1694,7 +1695,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) if( pAction->GetType() == META_GRADIENTEX_ACTION ) pGradAction = (const MetaGradientExAction*) pAction; - else if( ( pAction->GetType() == META_COMMENT_ACTION ) && + else if( ( pAction->GetType() == META_COMMENT_ACTION ) && ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_END" ) == COMPARE_EQUAL ) ) { bDone = sal_True; @@ -1704,7 +1705,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) if( pGradAction ) Impl_writeGradientEx( pGradAction->GetPolyPolygon(), pGradAction->GetGradient()); } - else if( pA->GetComment().CompareIgnoreCaseToAscii( "XPATHFILL_SEQ_BEGIN" ) == COMPARE_EQUAL && + else if( pA->GetComment().CompareIgnoreCaseToAscii( "XPATHFILL_SEQ_BEGIN" ) == COMPARE_EQUAL && pData ) { @@ -1727,7 +1728,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) { pAction = rMtf.GetAction( i ); - if( ( pAction->GetType() == META_COMMENT_ACTION ) && + if( ( pAction->GetType() == META_COMMENT_ACTION ) && ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "XPATHFILL_SEQ_END" ) == COMPARE_EQUAL ) ) { bDone = sal_True; @@ -1735,7 +1736,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) } } } - else if( pA->GetComment().CompareIgnoreCaseToAscii( "XPATHSTROKE_SEQ_BEGIN" ) == COMPARE_EQUAL && + else if( pA->GetComment().CompareIgnoreCaseToAscii( "XPATHSTROKE_SEQ_BEGIN" ) == COMPARE_EQUAL && pData ) { @@ -1758,7 +1759,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) { pAction = rMtf.GetAction( i ); - if( ( pAction->GetType() == META_COMMENT_ACTION ) && + if( ( pAction->GetType() == META_COMMENT_ACTION ) && ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "XPATHSTROKE_SEQ_END" ) == COMPARE_EQUAL ) ) { bDone = sal_True; @@ -1782,7 +1783,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) Impl_writePageField( aRect ); } - if( ( pAction->GetType() == META_COMMENT_ACTION ) && + if( ( pAction->GetType() == META_COMMENT_ACTION ) && ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "FIELD_SEQ_END" ) == COMPARE_EQUAL ) ) { bDone = sal_True; @@ -1797,8 +1798,8 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) { const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*) pAction; - Impl_writeImage( pA->GetBitmap(), - pA->GetPoint(), pA->GetSize(), + Impl_writeImage( pA->GetBitmap(), + pA->GetPoint(), pA->GetSize(), Point(), pA->GetBitmap().GetSizePixel(), clipRect, 1 == bMap ); } break; @@ -1806,8 +1807,8 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) case( META_BMP_ACTION ): { const MetaBmpAction* pA = (const MetaBmpAction*) pAction; - Impl_writeImage( pA->GetBitmap(), - pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmap().GetSizePixel()), + Impl_writeImage( pA->GetBitmap(), + pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmap().GetSizePixel()), Point(), pA->GetBitmap().GetSizePixel(), clipRect, 1 ==bMap ); } break; @@ -1815,8 +1816,8 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) case( META_BMPSCALEPART_ACTION ): { const MetaBmpScalePartAction* pA = (const MetaBmpScalePartAction*) pAction; - Impl_writeImage( pA->GetBitmap(), - pA->GetDestPoint(), pA->GetDestSize(), + Impl_writeImage( pA->GetBitmap(), + pA->GetDestPoint(), pA->GetDestSize(), pA->GetSrcPoint(), pA->GetSrcSize(), clipRect, 1 == bMap ); } break; @@ -1824,8 +1825,8 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) case( META_BMPEX_ACTION ): { const MetaBmpExAction* pA = (const MetaBmpExAction*) pAction; - Impl_writeImage( pA->GetBitmapEx(), - pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmapEx().GetSizePixel() ), + Impl_writeImage( pA->GetBitmapEx(), + pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmapEx().GetSizePixel() ), Point(), pA->GetBitmapEx().GetSizePixel(), clipRect, 1 == bMap ); } break; @@ -1833,8 +1834,8 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) case( META_BMPEXSCALE_ACTION ): { const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*) pAction; - Impl_writeImage( pA->GetBitmapEx(), - pA->GetPoint(), pA->GetSize(), + Impl_writeImage( pA->GetBitmapEx(), + pA->GetPoint(), pA->GetSize(), Point(), pA->GetBitmapEx().GetSizePixel(), clipRect, 1 == bMap ); } break; @@ -1842,8 +1843,8 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) case( META_BMPEXSCALEPART_ACTION ): { const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*) pAction; - Impl_writeImage( pA->GetBitmapEx(), - pA->GetDestPoint(), pA->GetDestSize(), + Impl_writeImage( pA->GetBitmapEx(), + pA->GetDestPoint(), pA->GetDestSize(), pA->GetSrcPoint(), pA->GetSrcSize(), clipRect, 1 == bMap ); } break; @@ -1852,7 +1853,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) { const MetaTextAction* pA = (const MetaTextAction*) pAction; Impl_writeText( pA->GetPoint(), String( pA->GetText(), pA->GetIndex(), pA->GetLen() ), NULL, 0); - } + } break; case( META_TEXTRECT_ACTION ): @@ -1890,6 +1891,19 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf ) } break; + case( META_RENDERGRAPHIC_ACTION ): + { + const MetaRenderGraphicAction* pA = (const MetaRenderGraphicAction*) pAction; + const ::vcl::RenderGraphicRasterizer aRasterizer( pA->GetRenderGraphic() ); + const Point aPointPixel; + const Size aSizePixel( mpVDev->LogicToPixel( pA->GetSize() ) ); + const BitmapEx aBmpEx( aRasterizer.Rasterize( aSizePixel ) ); + + Impl_writeImage( aBmpEx, pA->GetPoint(), pA->GetSize(), + aPointPixel, aBmpEx.GetSizePixel(), clipRect, 1 == bMap ); + } + break; + case( META_MAPMODE_ACTION ): { // const MetaMapModeAction *pA = (const MetaMapModeAction*) pAction; @@ -1983,7 +1997,7 @@ void Writer::Impl_quadBezierApprox( BitStream& rBits, P4y == 3.0*P3y - 3.0*P2y + P1y ) { Impl_addQuadBezier( rBits, rLastPoint, - 3.0/2.0*P2x - 1.0/2.0*P1x, 3.0/2.0*P2y - 1.0/2.0*P1y, + 3.0/2.0*P2x - 1.0/2.0*P1x, 3.0/2.0*P2y - 1.0/2.0*P1y, P4x, P4y); } else @@ -1997,8 +2011,8 @@ void Writer::Impl_quadBezierApprox( BitStream& rBits, // Intersection of P2P1 and P4P3 // (P2y-P4y)(P3x-P4x)-(P2x-P4x)(P3y-P4y) - // lambda = ------------------------------------- - // (P1x-P2x)(P3y-P4y)-(P1y-P2y)(P3x-P4x) + // lambda = ------------------------------------- + // (P1x-P2x)(P3y-P4y)-(P1y-P2y)(P3x-P4x) // // Intersection point IP is now // IP = P2 + lambda(P1-P2) @@ -2006,7 +2020,7 @@ void Writer::Impl_quadBezierApprox( BitStream& rBits, const double nominator( (P2y-P4y)*(P3x-P4x) - (P2x-P4x)*(P3y-P4y) ); const double denominator( (P1x-P2x)*(P3y-P4y) - (P1y-P2y)*(P3x-P4x) ); const double lambda( nominator / denominator ); - + const double IPx( P2x + lambda*( P1x - P2x) ); const double IPy( P2y + lambda*( P1y - P2y) ); @@ -2050,14 +2064,14 @@ void Writer::Impl_quadBezierApprox( BitStream& rBits, // Should denominator be 0: then P1P2 and P3P4 are parallel (P1P2^T R[90,P3P4] = 0.0), // meaning that either we have a straight line or an inflexion point (see else block below) if( 0.0 != denominator && - ::std::max( fJ1x*fJ1x + fJ1y*fJ1y, + ::std::max( fJ1x*fJ1x + fJ1y*fJ1y, fJ2x*fJ2x + fJ2y*fJ2y) < d2 ) { // requested resolution reached. // Add end points to output file. // order is preserved, since this is so to say depth first traversal. Impl_addQuadBezier( rBits, rLastPoint, - QP2x, QP2y, + QP2x, QP2y, QP3x, QP3y); } else @@ -2069,7 +2083,7 @@ void Writer::Impl_quadBezierApprox( BitStream& rBits, // straight line. If the given cubic bezier does not deviate by // more than d/4 from a straight line, either: // - take the line (that's what we do here) - // - express the line by a quadratic bezier + // - express the line by a quadratic bezier // Perform bezier flatness test (lecture notes from R. Schaback, // Mathematics of Computer-Aided Design, Uni Goettingen, 2000) @@ -2087,7 +2101,7 @@ void Writer::Impl_quadBezierApprox( BitStream& rBits, const double fJ2y2( P3y - P1y - 2.0/3.0*(P4y - P1y) ); // stop if distance from line is guaranteed to be bounded by d/4 - if( ::std::max( fJ1x2*fJ1x2 + fJ1y2*fJ1y2, + if( ::std::max( fJ1x2*fJ1x2 + fJ1y2*fJ1y2, fJ2x2*fJ2x2 + fJ2y2*fJ2y2) < d2/16.0 ) { // do not subdivide further, add straight line instead diff --git a/filter/source/graphicfilter/eos2met/eos2met.cxx b/filter/source/graphicfilter/eos2met/eos2met.cxx index 2163e7418..c831685cb 100644 --- a/filter/source/graphicfilter/eos2met/eos2met.cxx +++ b/filter/source/graphicfilter/eos2met/eos2met.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -44,8 +44,10 @@ #include <vcl/virdev.hxx> #include <vcl/svapp.hxx> #include <vcl/msgbox.hxx> +#include <vcl/rendergraphicrasterizer.hxx> #include <svl/solar.hrc> + // -----------------------------Feld-Typen------------------------------- #define BegDocumnMagic 0xA8A8 /* Begin Document */ @@ -164,6 +166,9 @@ private: sal_uLong nWrittenBitmaps; // Anzahl der bereits geschriebenen Bitmaps sal_uLong nActBitmapPercent; // Wieviel Prozent die naechste Bitmap schon geschrieben ist. + ::std::auto_ptr< VirtualDevice > apDummyVDev; + OutputDevice* pCompDev; + com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator; void MayCallback(); @@ -203,7 +208,7 @@ private: void METSetAndPushLineInfo( const LineInfo& rLineInfo ); void METPopLineInfo( const LineInfo& rLineInfo ); - void METBitBlt(Point aPt, Size aSize, const Bitmap & rBitmap); + void METBitBlt(Point aPt, Size aSize, const Size& rSizePixel); void METBeginArea(sal_Bool bBoundaryLine); void METEndArea(); void METBeginPath(sal_uInt32 nPathId); @@ -242,7 +247,18 @@ private: public: - METWriter() {} + METWriter() : + pCompDev( NULL ) + { +#ifndef NO_GETAPPWINDOW + pCompDev = reinterpret_cast< OutputDevice* >( Application::GetAppWindow() ); +#endif + if( !pCompDev ) + { + apDummyVDev.reset( new VirtualDevice ); + pCompDev = apDummyVDev.get(); + } + } sal_Bool WriteMET( const GDIMetaFile & rMTF, SvStream & rTargetStream, FilterConfigItem* pConfigItem ); @@ -311,6 +327,7 @@ void METWriter::CountActionsAndBitmaps(const GDIMetaFile * pMTF) case META_BMPEX_ACTION: case META_BMPEXSCALE_ACTION: case META_BMPEXSCALEPART_ACTION: + case META_RENDERGRAPHIC_ACTION: nNumberOfBitmaps++; break; } @@ -334,7 +351,7 @@ void METWriter::WriteBigEndianLong(sal_uLong nLong) void METWriter::WritePoint(Point aPt) { - Point aNewPt = OutputDevice::LogicToLogic( aPt, aPictureMapMode, aTargetMapMode ); + Point aNewPt = pCompDev->LogicToLogic( aPt, aPictureMapMode, aTargetMapMode ); *pMET << (long) ( aNewPt.X() - aPictureRect.Left() ) << (long) ( aPictureRect.Bottom() - aNewPt.Y() ); @@ -783,6 +800,17 @@ void METWriter::WriteImageObjects(const GDIMetaFile * pMTF) } } break; + + case( META_RENDERGRAPHIC_ACTION ): + { + const MetaRenderGraphicAction* pA = (const MetaRenderGraphicAction*) pMA; + const ::vcl::RenderGraphicRasterizer aRasterizer( pA->GetRenderGraphic() ); + const BitmapEx aBmpEx( aRasterizer.Rasterize( pCompDev->LogicToPixel( pA->GetSize() ) ) ); + + METSetMix( eGDIRasterOp ); + WriteImageObject( Graphic( aBmpEx ).GetBitmap() ); + } + break; } if (bStatus==sal_False) @@ -1127,7 +1155,7 @@ void METWriter::WillWriteOrder(sal_uLong nNextOrderMaximumLength) -void METWriter::METBitBlt(Point aPt, Size aSize, const Bitmap & rBitmap) +void METWriter::METBitBlt(Point aPt, Size aSize, const Size& rBmpSizePixel) { WillWriteOrder(46); *pMET << (sal_uInt8)0xd6 << (sal_uInt8)44 << (sal_uInt16)0 << (sal_uInt16) 0x00cc; @@ -1136,13 +1164,13 @@ void METWriter::METBitBlt(Point aPt, Size aSize, const Bitmap & rBitmap) WritePoint(Point(aPt.X(),aPt.Y()+aSize.Height())); WritePoint(Point(aPt.X()+aSize.Width(),aPt.Y())); *pMET << (sal_uInt32)0 << (sal_uInt32)0 - << (sal_uInt32)(rBitmap.GetSizePixel().Width()) - << (sal_uInt32)(rBitmap.GetSizePixel().Height()); + << (sal_uInt32)(rBmpSizePixel.Width()) + << (sal_uInt32)(rBmpSizePixel.Height()); } void METWriter::METSetAndPushLineInfo( const LineInfo& rLineInfo ) { - sal_Int32 nWidth = OutputDevice::LogicToLogic( Size( rLineInfo.GetWidth(),0 ), aPictureMapMode, aTargetMapMode ).Width(); + sal_Int32 nWidth = pCompDev->LogicToLogic( Size( rLineInfo.GetWidth(),0 ), aPictureMapMode, aTargetMapMode ).Width(); WillWriteOrder( 8 ); // set stroke linewidth *pMET << (sal_uInt8)0x15 @@ -1968,10 +1996,11 @@ void METWriter::WriteOrders( const GDIMetaFile* pMTF ) case META_BMP_ACTION: { - const MetaBmpAction* pA = (const MetaBmpAction*) pMA; + const MetaBmpAction* pA = (const MetaBmpAction*) pMA; + const Size aSizePixel( pA->GetBitmap().GetSizePixel() ); METSetMix(eGDIRasterOp); - METBitBlt( pA->GetPoint(), pA->GetBitmap().GetSizePixel(), pA->GetBitmap() ); + METBitBlt( pA->GetPoint(), pCompDev->PixelToLogic( aSizePixel, aPictureMapMode ), aSizePixel ); } break; @@ -1980,7 +2009,7 @@ void METWriter::WriteOrders( const GDIMetaFile* pMTF ) const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*) pMA; METSetMix(eGDIRasterOp); - METBitBlt( pA->GetPoint(), pA->GetSize(), pA->GetBitmap() ); + METBitBlt( pA->GetPoint(), pA->GetSize(), pA->GetBitmap().GetSizePixel() ); } break; @@ -1991,27 +2020,27 @@ void METWriter::WriteOrders( const GDIMetaFile* pMTF ) aTmp.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ); METSetMix( eGDIRasterOp ); - METBitBlt( pA->GetDestPoint(), pA->GetDestSize(), aTmp ); + METBitBlt( pA->GetDestPoint(), pA->GetDestSize(), pA->GetBitmap().GetSizePixel() ); } break; case META_BMPEX_ACTION: { const MetaBmpExAction* pA = (const MetaBmpExAction*) pMA; - Bitmap aTmp( Graphic( pA->GetBitmapEx() ).GetBitmap() ); + const Size aSizePixel( pA->GetBitmapEx().GetSizePixel() ); - METSetMix(eGDIRasterOp); - METBitBlt( pA->GetPoint(), aTmp.GetSizePixel(), aTmp ); + METSetMix( eGDIRasterOp ); + METBitBlt( pA->GetPoint(), pCompDev->PixelToLogic( aSizePixel, aPictureMapMode ), aSizePixel ); } break; case META_BMPEXSCALE_ACTION: { const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*) pMA; - Bitmap aTmp( Graphic( pA->GetBitmapEx() ).GetBitmap() ); + const Size aSizePixel( pA->GetBitmapEx().GetSizePixel() ); - METSetMix(eGDIRasterOp); - METBitBlt( pA->GetPoint(), pA->GetSize(), aTmp ); + METSetMix( eGDIRasterOp ); + METBitBlt( pA->GetPoint(), pA->GetSize(), aSizePixel ); } break; @@ -2021,8 +2050,8 @@ void METWriter::WriteOrders( const GDIMetaFile* pMTF ) Bitmap aTmp( Graphic( pA->GetBitmapEx() ).GetBitmap() ); aTmp.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ); - METSetMix(eGDIRasterOp); - METBitBlt( pA->GetDestPoint(), pA->GetDestSize(), aTmp ); + METSetMix( eGDIRasterOp ); + METBitBlt( pA->GetDestPoint(), pA->GetDestSize(), aTmp.GetSizePixel() ); } break; @@ -2039,7 +2068,7 @@ void METWriter::WriteOrders( const GDIMetaFile* pMTF ) { const MetaBmpScaleAction* pBmpScaleAction = (const MetaBmpScaleAction*)pMetaAct; METSetMix(eGDIRasterOp); - METBitBlt( pA->GetPoint(), pA->GetSize(), pBmpScaleAction->GetBitmap() ); + METBitBlt( pA->GetPoint(), pA->GetSize(), pBmpScaleAction->GetBitmap().GetSizePixel() ); break; } } @@ -2262,7 +2291,7 @@ void METWriter::WriteOrders( const GDIMetaFile* pMTF ) aGDILineColor=pGS->aLineColor; aGDIFillColor=pGS->aFillColor; eGDIRasterOp=pGS->eRasterOp; - aGDIFont=pGS->aFont; + aGDIFont=pGS->aFont; if ( pGS->aClipRect != aGDIClipRect ) WriteClipRect( pGS->aClipRect ); aPictureMapMode=pGS->aMapMode; @@ -2305,7 +2334,7 @@ void METWriter::WriteOrders( const GDIMetaFile* pMTF ) case META_FLOATTRANSPARENT_ACTION: { const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*) pMA; - + GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() ); Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() ); const Size aSrcSize( aTmpMtf.GetPrefSize() ); @@ -2329,6 +2358,15 @@ void METWriter::WriteOrders( const GDIMetaFile* pMTF ) WriteOrders( &aTmpMtf ); } break; + + case( META_RENDERGRAPHIC_ACTION ): + { + const MetaRenderGraphicAction* pA = (const MetaRenderGraphicAction*) pMA; + + METSetMix( eGDIRasterOp ); + METBitBlt( pA->GetPoint(), pA->GetSize(), pCompDev->LogicToPixel( pA->GetSize(), pMTF->GetPrefMapMode() ) ); + } + break; } nWrittenActions++; @@ -2591,4 +2629,3 @@ extern "C" sal_Bool __LOADONCALLAPI GraphicExport( SvStream & rStream, Graphic & return aMETWriter.WriteMET( aMTF, rStream, pFilterConfigItem ); } } - diff --git a/filter/source/graphicfilter/epict/epict.cxx b/filter/source/graphicfilter/epict/epict.cxx index f9fcdb50b..eb238a3af 100644 --- a/filter/source/graphicfilter/epict/epict.cxx +++ b/filter/source/graphicfilter/epict/epict.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -46,6 +46,7 @@ #include <vcl/svapp.hxx> #include <vcl/msgbox.hxx> #include <vcl/gdimtf.hxx> +#include <vcl/rendergraphicrasterizer.hxx> #include <tools/bigint.hxx> @@ -226,6 +227,7 @@ void PictWriter::CountActionsAndBitmaps(const GDIMetaFile & rMTF) case META_BMPEX_ACTION: case META_BMPEXSCALE_ACTION: case META_BMPEXSCALEPART_ACTION: + case META_RENDERGRAPHIC_ACTION: nNumberOfBitmaps++; break; } @@ -444,7 +446,7 @@ void PictWriter::ConvertLinePattern(PictPattern & rPat, sal_Bool bVisible) { if( bVisible ) { - rPat.nHi=0xffffffff; + rPat.nHi=0xffffffff; rPat.nLo=0xffffffff; } else @@ -458,7 +460,7 @@ void PictWriter::ConvertFillPattern(PictPattern & rPat, sal_Bool bVisible) { if( bVisible ) { - rPat.nHi=0xffffffff; + rPat.nHi=0xffffffff; rPat.nLo=0xffffffff; } else @@ -713,7 +715,7 @@ void PictWriter::WriteOpcode_FontName(const Font & rFont) if (bDstFontNameValid==sal_False || nDstFontNameId!=nFontId || aDstFontName!=rFont.GetName()) { - ByteString aByteString( rFont.GetName(), gsl_getSystemTextEncoding() ); + ByteString aByteString( rFont.GetName(), gsl_getSystemTextEncoding() ); sal_uInt16 nFontNameLen = aByteString.Len(); if ( nFontNameLen ) { @@ -735,8 +737,8 @@ void PictWriter::WriteOpcode_ClipRect( const Rectangle& rRect ) Rectangle aRect( MapRectangle( rRect ) ); aRect.nBottom++; aRect.nRight++; - *pPict << (sal_uInt16)1 // opcode 1 - << (sal_uInt16)10 // data size + *pPict << (sal_uInt16)1 // opcode 1 + << (sal_uInt16)10 // data size << (sal_Int16)aRect.Top() << (sal_Int16)aRect.Left() << (sal_Int16)aRect.Bottom() << (sal_Int16)aRect.Right(); aClipRect = aRect; @@ -914,7 +916,7 @@ void PictWriter::WriteOpcode_BitsRect(const Point & rPoint, const Size & rSize, nBitsPerPixel = aBitmap.GetBitCount(); // export code below only handles four discrete cases - nBitsPerPixel = + nBitsPerPixel = nBitsPerPixel <= 1 ? 1 : nBitsPerPixel <= 4 ? 4 : nBitsPerPixel <= 8 ? 8 : 24; nWidth = pAcc->Width(); @@ -1438,7 +1440,7 @@ void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF ) nACount=rMTF.GetActionCount(); - for (nA=0; nA<nACount; nA++) + for (nA=0; nA<nACount; nA++) { pMA = rMTF.GetAction(nA); @@ -1702,7 +1704,7 @@ void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF ) { const MetaPolyPolygonAction* pA = (const MetaPolyPolygonAction*) pMA; - const PolyPolygon& rPolyPoly = pA->GetPolyPolygon(); + const PolyPolygon& rPolyPoly = pA->GetPolyPolygon(); sal_uInt16 nPolyCount = rPolyPoly.Count(); PolyPolygon aSimplePolyPoly( rPolyPoly ); for ( sal_uInt16 i = 0; i < nPolyCount; i++ ) @@ -1807,8 +1809,11 @@ void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF ) case META_BMP_ACTION: { - const MetaBmpAction* pA = (const MetaBmpAction*) pMA; - WriteOpcode_BitsRect( pA->GetPoint(),pA->GetBitmap().GetSizePixel(), pA->GetBitmap() ); + const MetaBmpAction* pA = (const MetaBmpAction*) pMA; + const Bitmap aBmp( pA->GetBitmap() ); + VirtualDevice aVirDev; + + WriteOpcode_BitsRect( pA->GetPoint(), aVirDev.PixelToLogic( aBmp.GetSizePixel(), aSrcMapMode ), aBmp ); } break; @@ -1833,8 +1838,9 @@ void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF ) { const MetaBmpExAction* pA = (const MetaBmpExAction*) pMA; const Bitmap aBmp( Graphic( pA->GetBitmapEx() ).GetBitmap() ); + VirtualDevice aVirDev; - WriteOpcode_BitsRect( pA->GetPoint(), aBmp.GetSizePixel(), aBmp ); + WriteOpcode_BitsRect( pA->GetPoint(), aVirDev.PixelToLogic( aBmp.GetSizePixel(), aSrcMapMode ), aBmp ); } break; @@ -2085,8 +2091,8 @@ void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF ) if ( pAt->aClipRect != aClipRect ) { Rectangle aRect( pAt->aClipRect ); - *pPict << (sal_uInt16)1 // opcode 1 - << (sal_uInt16)10 // data size + *pPict << (sal_uInt16)1 // opcode 1 + << (sal_uInt16)10 // data size << (sal_Int16)aRect.Top() << (sal_Int16)aRect.Left() << (sal_Int16)aRect.Bottom() << (sal_Int16)aRect.Right(); } @@ -2126,7 +2132,7 @@ void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF ) case META_FLOATTRANSPARENT_ACTION: { const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*) pMA; - + GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() ); Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() ); const Size aSrcSize( aTmpMtf.GetPrefSize() ); @@ -2150,6 +2156,18 @@ void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF ) WriteOpcodes( aTmpMtf ); } break; + + case( META_RENDERGRAPHIC_ACTION ): + { + const MetaRenderGraphicAction* pA = (const MetaRenderGraphicAction*) pMA; + const ::vcl::RenderGraphicRasterizer aRasterizer( pA->GetRenderGraphic() ); + VirtualDevice aVirDev; + const Bitmap aBmp( Graphic( aRasterizer.Rasterize( + aVirDev.LogicToPixel( pA->GetSize() ) ) ).GetBitmap() ); + + WriteOpcode_BitsRect( pA->GetPoint(), pA->GetSize(), aBmp ); + } + break; } nWrittenActions++; @@ -2168,7 +2186,7 @@ void PictWriter::WriteHeader(const GDIMetaFile & rMTF) { sal_uInt16 i; Size aSize( rMTF.GetPrefSize() ); - Point aPoint; + Point aPoint; Rectangle aRect( aPoint, aSize ); // 512 Bytes "Muell" am Anfang: @@ -2194,7 +2212,7 @@ void PictWriter::WriteHeader(const GDIMetaFile & rMTF) // viele Import-Filter verlangen die Angabe eines // Clipping-Bereichs am Anfang - + WriteOpcode_ClipRect( aRect ); } diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx index c1d513069..ef5b0e30a 100644 --- a/filter/source/graphicfilter/eps/eps.cxx +++ b/filter/source/graphicfilter/eps/eps.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -47,6 +47,7 @@ #include <svtools/fltcall.hxx> #include <svtools/FilterConfigItem.hxx> #include <vcl/graphictools.hxx> +#include <vcl/rendergraphicrasterizer.hxx> #include "strings.hrc" #include <math.h> @@ -128,7 +129,7 @@ private: double nBoundingY1; double nBoundingX2; double nBoundingY2; - // + // StackMember* pGDIStack; sal_uLong mnCursorPos; // aktuelle Cursorposition im Output Color aColor; // aktuelle Farbe die fuer den Output benutzt wird @@ -214,7 +215,7 @@ private: void ImplIntersect( const PolyPolygon& rPolyPoly ); void ImplPolyPoly( const PolyPolygon & rPolyPolygon, sal_Bool bTextOutline = sal_False ); void ImplPolyLine( const Polygon & rPolygon ); - + void ImplSetClipRegion( Region& rRegion ); void ImplBmp( Bitmap*, Bitmap*, const Point &, double nWidth, double nHeight ); void ImplText( const String& rUniString, const Point& rPos, const sal_Int32* pDXArry, sal_Int32 nWidth, VirtualDevice& rVDev ); @@ -306,14 +307,14 @@ sal_Bool PSWriter::WritePS( const Graphic& rGraphic, SvStream& rTargetStream, Fi { String aPreviewStr( RTL_CONSTASCII_USTRINGPARAM( "Preview" ) ); String aVersionStr( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ); - String aColorStr( RTL_CONSTASCII_USTRINGPARAM( "ColorFormat" ) ); + String aColorStr( RTL_CONSTASCII_USTRINGPARAM( "ColorFormat" ) ); String aComprStr( RTL_CONSTASCII_USTRINGPARAM( "CompressionMode" ) ); mnPreview = pFilterConfigItem->ReadInt32( aPreviewStr, 1 ); mnLevel = pFilterConfigItem->ReadInt32( aVersionStr, 2 ); if ( mnLevel != 1 ) mnLevel = 2; mbGrayScale = pFilterConfigItem->ReadInt32( aColorStr, 1 ) == 2; - mbCompression = pFilterConfigItem->ReadInt32( aComprStr, 1 ) == 1; + mbCompression = pFilterConfigItem->ReadInt32( aComprStr, 1 ) == 1; String sTextMode( RTL_CONSTASCII_USTRINGPARAM( "TextMode" ) ); mnTextMode = pFilterConfigItem->ReadInt32( sTextMode, 0 ); if ( mnTextMode > 2 ) @@ -500,7 +501,7 @@ void PSWriter::ImplWriteProlog( const Graphic* pPreview ) *mpPS << "%"; nCount2 = 312; } - nVal <<= 1; + nVal <<= 1; if ( pAcc->GetPixel( nY, nX ) == aBlack ) nVal |= 1; if ( ! ( --nCount ) ) @@ -519,7 +520,7 @@ void PSWriter::ImplWriteProlog( const Graphic* pPreview ) aTmpBitmap.ReleaseAccess( pAcc ); ImplExecMode( PS_RET ); ImplWriteLine( "%%EndPreview" ); - } + } } ImplWriteLine( "%%BeginProlog" ); ImplWriteLine( "%%BeginResource: procset SDRes-Prolog 1.0 0" ); @@ -696,7 +697,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) Polygon aPoly( ( (const MetaPolyLineAction*) pMA )->GetPolygon() ); const LineInfo& rLineInfo = ( ( const MetaPolyLineAction*)pMA )->GetLineInfo(); ImplWriteLineInfo( rLineInfo ); - + if(basegfx::B2DLINEJOIN_NONE == rLineInfo.GetLineJoin() && rLineInfo.GetWidth() > 1) { @@ -706,21 +707,21 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) for(sal_uInt16 a(0); a + 1 < nPoints; a++) { - if(bCurve + if(bCurve && POLY_NORMAL != aPoly.GetFlags(a + 1) && a + 2 < nPoints && POLY_NORMAL != aPoly.GetFlags(a + 2) && a + 3 < nPoints) { - const Polygon aSnippet(4, - aPoly.GetConstPointAry() + a, + const Polygon aSnippet(4, + aPoly.GetConstPointAry() + a, aPoly.GetConstFlagAry() + a); ImplPolyLine(aSnippet); a += 2; } else { - const Polygon aSnippet(2, + const Polygon aSnippet(2, aPoly.GetConstPointAry() + a); ImplPolyLine(aSnippet); } @@ -789,7 +790,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) if ( mbGrayScale ) aBitmap.Convert( BMP_CONVERSION_8BIT_GREYS ); Point aPoint = ( (const MetaBmpAction*) pMA )->GetPoint(); - Size aSize = aBitmap.GetSizePixel(); + Size aSize( rVDev.PixelToLogic( aBitmap.GetSizePixel() ) ); ImplBmp( &aBitmap, NULL, aPoint, aSize.Width(), aSize.Height() ); } break; @@ -825,8 +826,8 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) if ( mbGrayScale ) aBitmap.Convert( BMP_CONVERSION_8BIT_GREYS ); Bitmap aMask( aBitmapEx.GetMask() ); - Point aPoint = ( (const MetaBmpExAction*) pMA)->GetPoint(); - Size aSize = ( aBitmap.GetSizePixel() ); + Point aPoint( ( (const MetaBmpExAction*) pMA )->GetPoint() ); + Size aSize( rVDev.PixelToLogic( aBitmap.GetSizePixel() ) ); ImplBmp( &aBitmap, &aMask, aPoint, aSize.Width(), aSize.Height() ); } break; @@ -886,9 +887,9 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) { VirtualDevice l_aVDev; GDIMetaFile aTmpMtf; - + l_aVDev.SetMapMode( rVDev.GetMapMode() ); - l_aVDev.AddHatchActions( ( (const MetaHatchAction*)pMA)->GetPolyPolygon(), + l_aVDev.AddHatchActions( ( (const MetaHatchAction*)pMA)->GetPolyPolygon(), ( (const MetaHatchAction*)pMA )->GetHatch(), aTmpMtf ); ImplWriteActions( aTmpMtf, rVDev ); } @@ -1177,7 +1178,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) case META_FLOATTRANSPARENT_ACTION: { const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*) pMA; - + GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() ); Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() ); const Size aSrcSize( aTmpMtf.GetPrefSize() ); @@ -1203,7 +1204,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) break; case META_COMMENT_ACTION: - { + { const MetaCommentAction* pA = (const MetaCommentAction*) pMA; if ( pA->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL ) { @@ -1213,14 +1214,14 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) MetaAction* pAction = rMtf.GetAction( nCurAction ); if( pAction->GetType() == META_GRADIENTEX_ACTION ) pGradAction = (const MetaGradientExAction*) pAction; - else if( ( pAction->GetType() == META_COMMENT_ACTION ) && + else if( ( pAction->GetType() == META_COMMENT_ACTION ) && ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_END" ) == COMPARE_EQUAL ) ) { break; } } if( pGradAction ) - ImplWriteGradient( pGradAction->GetPolyPolygon(), pGradAction->GetGradient(), rVDev ); + ImplWriteGradient( pGradAction->GetPolyPolygon(), pGradAction->GetGradient(), rVDev ); } else if ( pA->GetComment().Equals( "XPATHFILL_SEQ_END" ) ) { @@ -1236,7 +1237,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) if ( pData ) { SvMemoryStream aMemStm( (void*)pData, pA->GetDataSize(), STREAM_READ ); - sal_Bool bSkipSequence = sal_False; + sal_Bool bSkipSequence = sal_False; ByteString sSeqEnd; if( pA->GetComment().Equals( "XPATHSTROKE_SEQ_BEGIN" ) ) @@ -1319,8 +1320,8 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) MetaBitmapAction using RasterOp xor Because RasterOps cannot been used in Postscript, we have to - replace these actions. The MetaComment "XPATHFILL_SEQ_BEGIN" is - providing the clippath of the object. The following loop is + replace these actions. The MetaComment "XPATHFILL_SEQ_BEGIN" is + providing the clippath of the object. The following loop is trying to find the bitmap that is matching the clippath, so that only one bitmap is exported, otherwise if the bitmap is not locatable, all metaactions are played normally. @@ -1339,6 +1340,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) case META_BMPSCALEPART_ACTION : case META_BMPEXSCALE_ACTION : case META_BMPEXSCALEPART_ACTION : + case META_RENDERGRAPHIC_ACTION : { nBitmapCount++; nBitmapAction = nCurAction; @@ -1387,7 +1389,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) pMA = rMtf.GetAction( nCurAction ); if ( pMA->GetType() == META_COMMENT_ACTION ) { - ByteString sComment( ((MetaCommentAction*)pMA)->GetComment() ); + ByteString sComment( ((MetaCommentAction*)pMA)->GetComment() ); if ( sComment.Equals( sSeqEnd ) ) break; } @@ -1397,6 +1399,23 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) } } break; + + case( META_RENDERGRAPHIC_ACTION ): + { + const MetaRenderGraphicAction* pA = (const MetaRenderGraphicAction*) pMA; + const ::vcl::RenderGraphicRasterizer aRasterizer( pA->GetRenderGraphic() ); + const BitmapEx aBmpEx( aRasterizer.Rasterize( rVDev.LogicToPixel( pA->GetSize() ) ) ); + Bitmap aBmp( aBmpEx.GetBitmap() ); + + if ( mbGrayScale ) + aBmp.Convert( BMP_CONVERSION_8BIT_GREYS ); + + Bitmap aMask( aBmpEx.GetMask() ); + Size aSize( pA->GetSize() ); + + ImplBmp( &aBmp, &aMask, pA->GetPoint(), aSize.Width(), aSize.Height() ); + } + break; } } } @@ -1588,7 +1607,7 @@ void PSWriter::ImplPolyPoly( const PolyPolygon & rPolyPoly, sal_Bool bTextOutlin } if ( bLineColor ) { - ImplWriteLineColor( PS_SPACE ); + ImplWriteLineColor( PS_SPACE ); for ( i = 0; i < nPolyCount; i++ ) ImplAddPath( rPolyPoly.GetObject( i ) ); ImplClosePathDraw( PS_RET ); @@ -1607,7 +1626,7 @@ void PSWriter::ImplPolyLine( const Polygon & rPoly ) if ( nPointCount ) { if ( nPointCount > 1 ) - { + { ImplMoveTo( rPoly.GetPoint( 0 ) ); i = 1; while ( i < nPointCount ) @@ -1624,7 +1643,7 @@ void PSWriter::ImplPolyLine( const Polygon & rPoly ) ImplLineTo( rPoly.GetPoint( i++ ), PS_SPACE | PS_WRAP ); } } - + // #104645# explicitely close path if polygon is closed if( rPoly[ 0 ] == rPoly[ nPointCount-1 ] ) ImplClosePathDraw( PS_RET ); @@ -2026,10 +2045,10 @@ void PSWriter::ImplText( const String& rUniString, const Point& rPos, const sal_ if ( !nLen ) return; if ( mnTextMode == 0 ) // using glpyh outlines - { + { Font aNotRotatedFont( maFont ); aNotRotatedFont.SetOrientation( 0 ); - + VirtualDevice aVirDev( 1 ); aVirDev.SetMapMode( rVDev.GetMapMode() ); aVirDev.SetFont( aNotRotatedFont ); @@ -2037,7 +2056,7 @@ void PSWriter::ImplText( const String& rUniString, const Point& rPos, const sal_ sal_Int16 nRotation = maFont.GetOrientation(); Polygon aPolyDummy( 1 ); - + PolyPolygon aPolyPoly; Point aPos( rPos ); if ( nRotation ) @@ -2378,7 +2397,7 @@ void PSWriter::ImplWriteLineInfo( const LineInfo& rLineInfo ) { default: // B2DLINEJOIN_NONE, B2DLINEJOIN_MIDDLE // do NOT use SvtGraphicStroke::joinNone here - // since it will be written as numerical value directly + // since it will be written as numerical value directly // and is NOT a valid EPS value break; case basegfx::B2DLINEJOIN_MITER: diff --git a/filter/source/svg/impsvgdialog.cxx b/filter/source/svg/impsvgdialog.cxx new file mode 100644 index 000000000..b465752da --- /dev/null +++ b/filter/source/svg/impsvgdialog.cxx @@ -0,0 +1,150 @@ + /************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: impsvgdialog.cxx,v $ + * + * $Revision: 1.1.2.3 $ + * + * last change: $Author: ka $ $Date: 2007/06/15 14:36:19 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_filter.hxx" + +#include "impsvgdialog.hxx" +#include <cstdio> + +using namespace rtl; +using namespace com::sun::star::uno; +using namespace com::sun::star::beans; + +inline sal_Int32 implMap( Window& /*rWnd*/, sal_Int32 nVal ) +{ + //return( rWnd.LogicToLogic( Size( nVal, nVal ) ).Height(), MAP_APPFONT, MAP_APPFONT ); + return( nVal << 1 ); +} + +// ---------------- +// - ImpSVGDialog - +// ---------------- + +ImpSVGDialog::ImpSVGDialog( Window* pParent/*, ResMgr& rResMgr*/, Sequence< PropertyValue >& rFilterData ) : + ModalDialog( pParent/*KA, ResId( DLG_OPTIONS, &rResMgr*/ ), + maFI( this ), + maCBTinyProfile( this ), + maCBEmbedFonts( this ), + maCBUseNativeDecoration( this ), + maBTOK( this, WB_DEF_OK ), + maBTCancel( this ), + maBTHelp( this ), + maConfigItem( String( RTL_CONSTASCII_USTRINGPARAM( SVG_EXPORTFILTER_CONFIGPATH ) ), &rFilterData ), + mbOldNativeDecoration( sal_False ) +{ + SetText( String( RTL_CONSTASCII_USTRINGPARAM( "SVG Export Options" ) ) ); + SetOutputSizePixel( Size( implMap( *this, 177 ), implMap( *this, 77 ) ) ); + + maFI.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Export" ) ) ); + maFI.SetPosSizePixel( Point( implMap( *this, 6 ), implMap( *this, 3 ) ), + Size( implMap( *this, 165 ), implMap( *this, 8 ) ) ); + + maCBTinyProfile.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Use SVG Tiny profile" ) ) ); + maCBTinyProfile.SetPosSizePixel( Point( implMap( *this, 12 ), implMap( *this, 14 ) ), + Size( implMap( *this, 142 ), implMap( *this, 10 ) ) ); + + maCBEmbedFonts.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Embed fonts" ) ) ); + maCBEmbedFonts.SetPosSizePixel( Point( implMap( *this, 12 ), implMap( *this, 27 ) ), + Size( implMap( *this, 142 ), implMap( *this, 10 ) ) ); + + maCBUseNativeDecoration.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Use SVG native text decoration" ) ) ); + maCBUseNativeDecoration.SetPosSizePixel( Point( implMap( *this, 12 ), implMap( *this, 41 ) ), + Size( implMap( *this, 142 ), implMap( *this, 10 ) ) ); + + maCBTinyProfile.Check( maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_TINYPROFILE ) ), sal_False ) ); + maCBEmbedFonts.Check( maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_EMBEDFONTS ) ), sal_True ) ); + maCBUseNativeDecoration.Check( maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_NATIVEDECORATION ) ), sal_True ) ); + + maBTOK.SetPosSizePixel( Point( implMap( *this, 12 ), implMap( *this, 57 ) ), + Size( implMap( *this, 50 ), implMap( *this, 14 ) ) ); + maBTCancel.SetPosSizePixel( Point( implMap( *this, 65 ), implMap( *this, 57 ) ), + Size( implMap( *this, 50 ), implMap( *this, 14 ) ) ); + maBTHelp.SetPosSizePixel( Point( implMap( *this, 121 ), implMap( *this, 57 ) ), + Size( implMap( *this, 50 ), implMap( *this, 14 ) ) ); + + maCBTinyProfile.SetToggleHdl( LINK( this, ImpSVGDialog, OnToggleCheckbox ) ); + OnToggleCheckbox( &maCBTinyProfile ); + + maFI.Show(); + + maCBTinyProfile.Show(); + maCBEmbedFonts.Show(); + maCBUseNativeDecoration.Show(); + + maBTOK.Show(); + maBTCancel.Show(); + maBTHelp.Show(); +} + +// ----------------------------------------------------------------------------- + +ImpSVGDialog::~ImpSVGDialog() +{ +} + +// ----------------------------------------------------------------------------- + +Sequence< PropertyValue > ImpSVGDialog::GetFilterData() +{ + maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_TINYPROFILE ) ), maCBTinyProfile.IsChecked() ); + maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_EMBEDFONTS ) ), maCBEmbedFonts.IsChecked() ); + maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_NATIVEDECORATION ) ), maCBUseNativeDecoration.IsChecked() ); + + return( maConfigItem.GetFilterData() ); +} + +// ----------------------------------------------------------------------------- + +IMPL_LINK( ImpSVGDialog, OnToggleCheckbox, CheckBox*, pBox ) +{ + if( pBox == &maCBTinyProfile ) + { + if( pBox->IsChecked() ) + { + mbOldNativeDecoration = maCBUseNativeDecoration.IsChecked(); + + maCBUseNativeDecoration.Check( sal_False ); + maCBUseNativeDecoration.Disable(); + } + else + { + maCBUseNativeDecoration.Enable(); + maCBUseNativeDecoration.Check( mbOldNativeDecoration ); + } + } + + return 0; +} diff --git a/filter/source/svg/impsvgdialog.hxx b/filter/source/svg/impsvgdialog.hxx new file mode 100644 index 000000000..c5eb0ff79 --- /dev/null +++ b/filter/source/svg/impsvgdialog.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: impsvgdialog.hxx,v $ + * + * $Revision: 1.1.2.5 $ + * + * last change: $Author: ka $ $Date: 2006/03/24 10:57:24 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef IMPSVGDIALOG_HXX +#define IMPSVGDIALOG_HXX + +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ +#include <com/sun/star/uno/Sequence.h> +#endif + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif + +#include <vcl/dialog.hxx> +#include <vcl/button.hxx> +#include <vcl/fixed.hxx> +#include <vcl/field.hxx> +#include <svtools/stdctrl.hxx> +#include <svtools/FilterConfigItem.hxx> + +#define SVG_EXPORTFILTER_CONFIGPATH "Office.Common/Filter/SVG/Export/" +#define SVG_PROP_TINYPROFILE "TinyMode" +#define SVG_PROP_EMBEDFONTS "EmbedFonts" +#define SVG_PROP_NATIVEDECORATION "UseNativeTextDecoration" +#define SVG_PROP_GLYPHPLACEMENT "GlyphPlacement" +#define SVG_PROP_OPACITY "Opacity" +#define SVG_PROP_GRADIENT "Gradient" + +// ---------------- +// - ImpSVGDialog - +// ---------------- + +class ResMgr; +class Window; + +class ImpSVGDialog : public ModalDialog +{ +private: + + FixedLine maFI; + CheckBox maCBTinyProfile; + CheckBox maCBEmbedFonts; + CheckBox maCBUseNativeDecoration; + + OKButton maBTOK; + CancelButton maBTCancel; + HelpButton maBTHelp; + + FilterConfigItem maConfigItem; + sal_Bool mbOldNativeDecoration; + + DECL_LINK( OnToggleCheckbox, CheckBox* ); + +public: + + ImpSVGDialog( Window* pParent, /*ResMgr& rResMgr,*/ + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rFilterData ); + ~ImpSVGDialog(); + + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > GetFilterData(); +}; + +#endif // IMPSVGDIALOG_HXX diff --git a/filter/source/svg/makefile.mk b/filter/source/svg/makefile.mk index 44bac2338..b742b75e1 100644 --- a/filter/source/svg/makefile.mk +++ b/filter/source/svg/makefile.mk @@ -2,10 +2,14 @@ # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # -# Copyright 2000, 2010 Oracle and/or its affiliates. +# Copyright 2008 by Sun Microsystems, Inc. # # OpenOffice.org - a multi-platform office productivity suite # +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.10.110.6 $ +# # This file is part of OpenOffice.org. # # OpenOffice.org is free software: you can redistribute it and/or modify @@ -39,6 +43,8 @@ VISIBILITY_HIDDEN=TRUE # --- Types ------------------------------------- SLOFILES= $(SLO)$/svguno.obj \ + $(SLO)$/svgdialog.obj \ + $(SLO)$/impsvgdialog.obj \ $(SLO)$/svgfilter.obj \ $(SLO)$/svgexport.obj \ $(SLO)$/svgfontexport.obj \ @@ -52,17 +58,18 @@ SLOFILES+= $(SLO)$/svgimport.obj SHL1TARGET=$(TARGET)$(DLLPOSTFIX) SHL1STDLIBS=\ - $(EDITENGLIB) \ $(SVXCORELIB) \ + $(EDITENGLIB) \ $(XMLOFFLIB) \ - $(SVTOOLLIB) \ $(VCLLIB) \ $(UNOTOOLSLIB) \ $(TOOLSLIB) \ $(COMPHELPERLIB) \ $(CPPUHELPERLIB) \ $(CPPULIB) \ - $(SALLIB) + $(SALLIB) \ + $(BASEGFXLIB) \ + $(SVTOOLLIB) .IF "$(SOLAR_JAVA)"!="" SHL1STDLIBS+=\ diff --git a/filter/source/svg/svgdialog.cxx b/filter/source/svg/svgdialog.cxx new file mode 100644 index 000000000..eda20bdea --- /dev/null +++ b/filter/source/svg/svgdialog.cxx @@ -0,0 +1,275 @@ + /************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: svgdialog.cxx,v $ + * + * $Revision: 1.1.2.3 $ + * + * last change: $Author: ka $ $Date: 2008/05/19 10:12:43 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_filter.hxx" + +#include "svgdialog.hxx" +#include "impsvgdialog.hxx" + +#include <vcl/svapp.hxx> +#include <vcl/dialog.hxx> + +#ifndef _COM_SUN_STAR_VIEW_XRENDERABLE_HPP_ +#include <com/sun/star/view/XRenderable.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_ +#include <com/sun/star/frame/XController.hpp> +#endif +#ifndef _COM_SUN_STAR_VIEW_XSELECTIONSUPPLIER_HPP_ +#include <com/sun/star/view/XSelectionSupplier.hpp> +#endif + +#define SVG_DIALOG_SERVICE_NAME "com.sun.star.comp.Draw.SVGFilterDialog" +#define SVG_DIALOG_IMPLEMENTATION_NAME SVG_DIALOG_SERVICE_NAME +#define SVG_FILTER_DATA_NAME "FilterData" + +using namespace ::rtl; +using namespace ::vcl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::view; +using namespace ::com::sun::star::document; + +// ----------------------- +// - SVGDialog functions - +// ----------------------- + +OUString SVGDialog_getImplementationName () + throw (RuntimeException) +{ + return OUString ( RTL_CONSTASCII_USTRINGPARAM ( SVG_DIALOG_IMPLEMENTATION_NAME ) ); +} + +// ----------------------------------------------------------------------------- + +Sequence< sal_Int8 > SAL_CALL SVGDialog_getImplementationId() + throw(RuntimeException) +{ + static const ::cppu::OImplementationId aId; + + return( aId.getImplementationId() ); +} + +// ----------------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL SVGDialog_getSupportedServiceNames() + throw (RuntimeException) +{ + Sequence< OUString > aRet( 1 ); + + aRet.getArray()[ 0 ] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SVG_DIALOG_SERVICE_NAME ) ); + + return aRet; +} + +// ----------------------------------------------------------------------------- + +Reference< XInterface > SAL_CALL SVGDialog_createInstance( const Reference< XMultiServiceFactory > & rSMgr ) + throw( Exception ) +{ + return( static_cast< cppu::OWeakObject* >( new SVGDialog( rSMgr ) ) ); +} + +// ------------- +// - SVGDialog - +// ------------- + +SVGDialog::SVGDialog( const Reference< XMultiServiceFactory > &rxMSF ) : + OGenericUnoDialog( rxMSF ) +{ + ByteString aResMgrName( "svgfilter" ); + + aResMgrName.Append( ByteString::CreateFromInt32( 0/*SOLARUPD*/ ) ); + + // !!! KA: enable ResMgr + // mapResMgr.reset( ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() ) ); +} + +// ----------------------------------------------------------------------------- + +SVGDialog::~SVGDialog() +{ +} + +// ----------------------------------------------------------------------------- + +Any SAL_CALL SVGDialog::queryInterface( const Type& rType ) + throw (RuntimeException) +{ + Any aReturn( OGenericUnoDialog::queryInterface( rType ) ); + + if( !aReturn.hasValue() ) + { + aReturn = ::cppu::queryInterface( rType, static_cast< XPropertyAccess* >( this ), + static_cast< XExporter* >( this ) ); + } + + return( aReturn ); +} + +// ----------------------------------------------------------------------------- + +void SAL_CALL SVGDialog::acquire() + throw () +{ + OWeakObject::acquire(); +} + +// ----------------------------------------------------------------------------- + +void SAL_CALL SVGDialog::release() + throw () +{ + OWeakObject::release(); +} + +// ----------------------------------------------------------------------------- + +Sequence< sal_Int8 > SAL_CALL SVGDialog::getImplementationId() + throw(RuntimeException) +{ + return SVGDialog_getImplementationId(); +} + +// ----------------------------------------------------------------------------- + +OUString SAL_CALL SVGDialog::getImplementationName() + throw (RuntimeException) +{ + return SVGDialog_getImplementationName(); +} + +// ----------------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL SVGDialog::getSupportedServiceNames() + throw (RuntimeException) +{ + return SVGDialog_getSupportedServiceNames(); +} + +// ----------------------------------------------------------------------------- + +Dialog* SVGDialog::createDialog( Window* pParent ) +{ + return( ( /*KA: *mapResMgr.get() &&*/ mxSrcDoc.is() ) ? + new ImpSVGDialog( pParent/*KA: , *mapResMgr*/, maFilterData ) : + NULL ); +} + +// ----------------------------------------------------------------------------- + +void SVGDialog::executedDialog( sal_Int16 nExecutionResult ) +{ + if( nExecutionResult && m_pDialog ) + maFilterData = static_cast< ImpSVGDialog* >( m_pDialog )->GetFilterData(); + + destroyDialog(); +} + +// ----------------------------------------------------------------------------- + +Reference< XPropertySetInfo > SAL_CALL SVGDialog::getPropertySetInfo() + throw(RuntimeException) +{ + return( Reference< XPropertySetInfo >( createPropertySetInfo( getInfoHelper() ) ) ); +} + +//------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper& SVGDialog::getInfoHelper() +{ + return( *const_cast< SVGDialog *>(this)->getArrayHelper() ); +} + +//------------------------------------------------------------------------------ +::cppu::IPropertyArrayHelper* SVGDialog::createArrayHelper() const +{ + Sequence< Property > aProps; + + describeProperties(aProps); + + return new ::cppu::OPropertyArrayHelper( aProps ); +} + +// ----------------------------------------------------------------------------- + +Sequence< PropertyValue > SAL_CALL SVGDialog::getPropertyValues() + throw ( RuntimeException ) +{ + sal_Int32 i, nCount; + + for( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; ++i ) + { + if( maMediaDescriptor[ i ].Name.equalsAscii( SVG_FILTER_DATA_NAME ) ) + break; + } + + if( i == nCount ) + { + maMediaDescriptor.realloc( ++nCount ); + maMediaDescriptor[ i ].Name = String( RTL_CONSTASCII_USTRINGPARAM( SVG_FILTER_DATA_NAME ) ); + } + + maMediaDescriptor[ i ].Value <<= maFilterData; + + return( maMediaDescriptor ); +} + +// ----------------------------------------------------------------------------- + +void SAL_CALL SVGDialog::setPropertyValues( const Sequence< PropertyValue >& rProps ) + throw ( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException ) +{ + maMediaDescriptor = rProps; + + for( sal_Int32 i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ ) + { + if( maMediaDescriptor[ i ].Name.equalsAscii( SVG_FILTER_DATA_NAME ) ) + { + maMediaDescriptor[ i ].Value >>= maFilterData; + break; + } + } +} + +// ----------------------------------------------------------------------------- + +void SAL_CALL SVGDialog::setSourceDocument( const Reference< XComponent >& xDoc ) + throw(IllegalArgumentException, RuntimeException) +{ + mxSrcDoc = xDoc; +} diff --git a/filter/source/svg/svgdialog.hxx b/filter/source/svg/svgdialog.hxx new file mode 100644 index 000000000..49993390f --- /dev/null +++ b/filter/source/svg/svgdialog.hxx @@ -0,0 +1,120 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: svgdialog.hxx,v $ + * + * $Revision: 1.1.2.1 $ + * + * last change: $Author: ka $ $Date: 2006/03/08 08:18:10 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef SVGDIALOG_HXX +#define SVGDIALOG_HXX + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYACCESS_HPP_ +#include <com/sun/star/beans/XPropertyAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XEXPORTER_HPP_ +#include <com/sun/star/document/XExporter.hpp> +#endif + +#include <svtools/genericunodialog.hxx> +#include <memory> + +// ------------- +// - SVGDialog - +// ------------- + +class ResMgr; + +class SVGDialog : public ::svt::OGenericUnoDialog, + public ::comphelper::OPropertyArrayUsageHelper< SVGDialog >, + public ::com::sun::star::beans::XPropertyAccess, + public ::com::sun::star::document::XExporter +{ +private: + + ::std::auto_ptr< ResMgr > mapResMgr; + com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > maMediaDescriptor; + com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > maFilterData; + com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxSrcDoc; + +protected: + + // XInterface + virtual com::sun::star::uno::Any SAL_CALL queryInterface( const com::sun::star::uno::Type& aType ) throw (com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw (); + virtual void SAL_CALL release() throw (); + + // OGenericUnoDialog + virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(com::sun::star::uno::RuntimeException); + virtual rtl::OUString SAL_CALL getImplementationName() throw (com::sun::star::uno::RuntimeException); + virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException); + virtual Dialog* createDialog( Window* pParent ); + virtual void executedDialog( sal_Int16 nExecutionResult ); + virtual com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(com::sun::star::uno::RuntimeException); + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + + // XPropertyAccess + using cppu::OPropertySetHelper::getPropertyValues; + virtual com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPropertyValues( ) throw (com::sun::star::uno::RuntimeException); + using cppu::OPropertySetHelper::setPropertyValues; + virtual void SAL_CALL setPropertyValues( const com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProps ) throw (com::sun::star::beans::UnknownPropertyException, com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException, com::sun::star::lang::WrappedTargetException, com::sun::star::uno::RuntimeException); + + // XExporter + virtual void SAL_CALL setSourceDocument( const com::sun::star::uno::Reference< com::sun::star::lang::XComponent >& xDoc ) throw(com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException); + +public: + + SVGDialog( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxMSF ); + virtual ~SVGDialog(); +}; + +// ----------------------------------------------------------------------------- + +::rtl::OUString SVGDialog_getImplementationName () + throw ( ::com::sun::star::uno::RuntimeException ); + +// ----------------------------------------------------------------------------- + +sal_Bool SAL_CALL SVGDialog_supportsService( const ::rtl::OUString& ServiceName ) + throw ( ::com::sun::star::uno::RuntimeException ); + +// ----------------------------------------------------------------------------- + +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL SVGDialog_getSupportedServiceNames( ) + throw ( ::com::sun::star::uno::RuntimeException ); + +// ----------------------------------------------------------------------------- + +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + SAL_CALL SVGDialog_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr) + throw ( ::com::sun::star::uno::Exception ); + +#endif // SVGDialog_HXX diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx index 348efd312..62b198aff 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -2,10 +2,13 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * + * $RCSfile: svgexport.cxx,v $ + * $Revision: 1.12.62.15 $ + * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -33,8 +36,11 @@ #include "svgwriter.hxx" #include "svgfontexport.hxx" #include "svgfilter.hxx" +#include "impsvgdialog.hxx" +#include <svtools/FilterConfigItem.hxx> #include <svx/unopage.hxx> +#include <svx/unoshape.hxx> #include <svx/svdpage.hxx> #include <svx/svdoutl.hxx> #include <editeng/outliner.hxx> @@ -47,12 +53,14 @@ using ::rtl::OUString; // - SVGExport - // ------------- -// #110680# SVGExport::SVGExport( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, - const Reference< XDocumentHandler >& rxHandler ) -: SvXMLExport( xServiceFactory, OUString(), rxHandler ) + const Reference< XDocumentHandler >& rxHandler, + const Sequence< PropertyValue >& rFilterData ) : + SvXMLExport( xServiceFactory, MAP_100TH_MM ), + mrFilterData( rFilterData ) { + SetDocHandler( rxHandler ); GetDocHandler()->startDocument(); } @@ -63,6 +71,109 @@ SVGExport::~SVGExport() GetDocHandler()->endDocument(); } +// ----------------------------------------------------------------------------- + +sal_Bool SVGExport::IsUseTinyProfile() const +{ + sal_Bool bRet = sal_False; + + if( mrFilterData.getLength() > 0 ) + mrFilterData[ 0 ].Value >>= bRet; + + return bRet; +} + +// ----------------------------------------------------------------------------- + +sal_Bool SVGExport::IsEmbedFonts() const +{ + sal_Bool bRet = sal_False; + + if( mrFilterData.getLength() > 1 ) + mrFilterData[ 1 ].Value >>= bRet; + + return bRet; +} + +// ----------------------------------------------------------------------------- + +sal_Bool SVGExport::IsUseNativeTextDecoration() const +{ + sal_Bool bRet = !IsUseTinyProfile(); + + if( bRet && ( mrFilterData.getLength() > 2 ) ) + mrFilterData[ 2 ].Value >>= bRet; + + return bRet; +} + +// ----------------------------------------------------------------------------- + +::rtl::OUString SVGExport::GetGlyphPlacement() const +{ + ::rtl::OUString aRet; + + if( mrFilterData.getLength() > 3 ) + mrFilterData[ 3 ].Value >>= aRet; + else + aRet = B2UCONST( "abs" ); + + return aRet; +} + +// ----------------------------------------------------------------------------- + +sal_Bool SVGExport::IsUseOpacity() const +{ + sal_Bool bRet = !IsUseTinyProfile(); + + if( !bRet && ( mrFilterData.getLength() > 4 ) ) + mrFilterData[ 4 ].Value >>= bRet; + + return bRet; +} + +// ----------------------------------------------------------------------------- + +sal_Bool SVGExport::IsUseGradient() const +{ + sal_Bool bRet = !IsUseTinyProfile(); + + if( !bRet && ( mrFilterData.getLength() > 5 ) ) + mrFilterData[ 5 ].Value >>= bRet; + + return bRet; +} + +// ----------------------------------------------------------------------------- + +void SVGExport::pushClip( const ::basegfx::B2DPolyPolygon& rPolyPoly ) +{ + maClipList.push_front( ::basegfx::tools::correctOrientations( rPolyPoly ) ); +} + +// ----------------------------------------------------------------------------- + +void SVGExport::popClip() +{ + if( !maClipList.empty() ) + maClipList.pop_front(); +} + +// ----------------------------------------------------------------------------- + +sal_Bool SVGExport::hasClip() const +{ + return( !maClipList.empty() ); +} + +// ----------------------------------------------------------------------------- + +const ::basegfx::B2DPolyPolygon* SVGExport::getCurClip() const +{ + return( maClipList.empty() ? NULL : &( *maClipList.begin() ) ); +} + // ------------------------ // - ObjectRepresentation - // ------------------------ @@ -108,7 +219,7 @@ ObjectRepresentation& ObjectRepresentation::operator=( const ObjectRepresentatio // ----------------------------------------------------------------------------- -bool ObjectRepresentation::operator==( const ObjectRepresentation& rPresentation ) const +sal_Bool ObjectRepresentation::operator==( const ObjectRepresentation& rPresentation ) const { return( ( mxObject == rPresentation.mxObject ) && ( *mpMtf == *rPresentation.mpMtf ) ); @@ -128,7 +239,10 @@ sal_Bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) sal_Int32 nPageToExport = SVG_EXPORT_ALLPAGES; const PropertyValue* pValue = rDescriptor.getConstArray(); sal_Bool bRet = sal_False; - + + mnMasterSlideId = mnSlideId = mnDrawingGroupId = mnDrawingId = 0; + maFilterData.realloc( 0 ); + for ( sal_Int32 i = 0 ; i < nLength; ++i) { if( pValue[ i ].Name.equalsAscii( "OutputStream" ) ) @@ -144,9 +258,65 @@ sal_Bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) xOStm = Reference< XOutputStream >( new ::utl::OOutputStreamWrapper ( *pOStm ) ); } else if( pValue[ i ].Name.equalsAscii( "PagePos" ) ) + { pValue[ i ].Value >>= nPageToExport; - } + } + else if( pValue[ i ].Name.equalsAscii( "FilterData" ) ) + { + pValue[ i ].Value >>= maFilterData; + } + } + + // if no filter data is given use stored/prepared ones + if( !maFilterData.getLength() ) + { +#ifdef _SVG_USE_CONFIG + FilterConfigItem aCfgItem( String( RTL_CONSTASCII_USTRINGPARAM( SVG_EXPORTFILTER_CONFIGPATH ) ) ); + + aCfgItem.ReadBool( String( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_TINYPROFILE ) ), sal_True ); + aCfgItem.ReadBool( String( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_EMBEDFONTS ) ), sal_True ); + aCfgItem.ReadBool( String( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_NATIVEDECORATION ) ), sal_False ); + aCfgItem.ReadString( String( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_NATIVEDECORATION ) ), B2UCONST( "xlist" ) ); + aCfgItem.ReadString( String( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_OPACITY ) ), sal_True ); + aCfgItem.ReadString( String( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_GRADIENT ) ), sal_True ); + + maFilterData = aCfgItem.GetFilterData(); +#else + maFilterData.realloc( 6 ); + + maFilterData[ 0 ].Name = B2UCONST( SVG_PROP_TINYPROFILE ); + maFilterData[ 0 ].Value <<= (sal_Bool) sal_True; + + // font embedding + const char* pSVGDisableFontEmbedding = getenv( "SVG_DISABLE_FONT_EMBEDDING" ); + + maFilterData[ 1 ].Name = B2UCONST( SVG_PROP_EMBEDFONTS ); + maFilterData[ 1 ].Value <<= (sal_Bool) ( pSVGDisableFontEmbedding ? sal_False : sal_True ); + + // Native decoration + maFilterData[ 2 ].Name = B2UCONST( SVG_PROP_NATIVEDECORATION ); + maFilterData[ 2 ].Value <<= (sal_Bool) sal_False; + // glyph placement + const char* pSVGGlyphPlacement = getenv( "SVG_GLYPH_PLACEMENT" ); + + maFilterData[ 3 ].Name = B2UCONST( SVG_PROP_GLYPHPLACEMENT ); + + if( pSVGGlyphPlacement ) + maFilterData[ 3 ].Value <<= ::rtl::OUString::createFromAscii( pSVGGlyphPlacement ); + else + maFilterData[ 3 ].Value <<= B2UCONST( "xlist" ); + + // Tiny Opacity + maFilterData[ 4 ].Name = B2UCONST( SVG_PROP_OPACITY ); + maFilterData[ 4 ].Value <<= (sal_Bool) sal_True; + + // Tiny Gradient + maFilterData[ 5 ].Name = B2UCONST( SVG_PROP_GRADIENT ); + maFilterData[ 5 ].Value <<= (sal_Bool) sal_False; +#endif + } + if( xOStm.is() && xServiceFactory.is() ) { Reference< XMasterPagesSupplier > xMasterPagesSupplier( mxSrcDoc, UNO_QUERY ); @@ -157,8 +327,7 @@ sal_Bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY ); Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY ); - if( xMasterPages.is() && xDrawPages->getCount() && - xDrawPages.is() && xDrawPages->getCount() ) + if( xMasterPages.is() && xMasterPages->getCount() && xDrawPages.is() && xDrawPages->getCount() ) { Reference< XDocumentHandler > xDocHandler( implCreateExportDocumentHandler( xOStm ) ); @@ -169,7 +338,7 @@ sal_Bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) // #110680# // mpSVGExport = new SVGExport( xDocHandler ); - mpSVGExport = new SVGExport( xServiceFactory, xDocHandler ); + mpSVGExport = new SVGExport( xServiceFactory, xDocHandler, maFilterData ); if( nPageToExport < 0 || nPageToExport >= xDrawPages->getCount() ) nPageToExport = SVG_EXPORT_ALLPAGES; @@ -283,17 +452,24 @@ sal_Bool SVGFilter::implExportDocument( const Reference< XDrawPages >& rxMasterP const sal_Int32 nFirstPage = ( ( SVG_EXPORT_ALLPAGES == nPageToExport ) ? 0 : nPageToExport ); sal_Int32 nCurPage = nFirstPage, nLastPage = ( bSinglePage ? nFirstPage : ( rxDrawPages->getCount() - 1 ) ); - const Reference< XPropertySet > xDefaultPagePropertySet( mxDefaultPage, UNO_QUERY ); + const Reference< XPropertySet > xDefaultPagePropertySet( mxDefaultPage, UNO_QUERY ); const Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY ); - + if( xDefaultPagePropertySet.is() ) { xDefaultPagePropertySet->getPropertyValue( B2UCONST( "Width" ) ) >>= nDocWidth; xDefaultPagePropertySet->getPropertyValue( B2UCONST( "Height" ) ) >>= nDocHeight; } - - if( xExtDocHandler.is() ) + + if( xExtDocHandler.is() && !mpSVGExport->IsUseTinyProfile() ) + { xExtDocHandler->unknown( SVG_DTD_STRING ); + } + + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "version", B2UCONST( "1.2" ) ); + + if( mpSVGExport->IsUseTinyProfile() ) + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "baseProfile", B2UCONST( "tiny" ) ); #ifdef _SVG_WRITE_EXTENTS aAttr = OUString::valueOf( nDocWidth * 0.01 ); @@ -310,11 +486,14 @@ sal_Bool SVGFilter::implExportDocument( const Reference< XDrawPages >& rxMasterP aAttr += B2UCONST( " " ); aAttr += OUString::valueOf( nDocHeight ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "version", B2UCONST( "1.1" ) ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "viewBox", aAttr ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "preserveAspectRatio", B2UCONST( "xMidYMid" ) ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "fill-rule", B2UCONST( "evenodd" ) ); + // standard line width is based on 1 pixel on a 90 DPI device (0.28222mmm) + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "stroke-width", OUString::valueOf( 28.222 ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "stroke-linejoin", B2UCONST( "round" ) ); + if( !bSinglePage ) { mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:ooo", B2UCONST( "http://xml.openoffice.org/svg/export" ) ); @@ -322,9 +501,10 @@ sal_Bool SVGFilter::implExportDocument( const Reference< XDrawPages >& rxMasterP mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "onkeypress", B2UCONST( "onKeyPress(evt)" ) ); } - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns", B2UCONST( "http://www.w3.org/2000/svg" ) ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:xlink", B2UCONST( "http://www.w3.org/1999/xlink" ) ); + + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xml:space", B2UCONST( "preserve" ) ); mpSVGDoc = new SvXMLElementExport( *mpSVGExport, XML_NAMESPACE_NONE, "svg", sal_True, sal_True ); @@ -371,10 +551,11 @@ sal_Bool SVGFilter::implExportDocument( const Reference< XDrawPages >& rxMasterP ++nCurPage; } - -#ifdef _SVG_EMBED_FONTS - mpSVGFontExport->EmbedFonts(); -#endif + + if( mpSVGExport->IsEmbedFonts() ) + { + mpSVGFontExport->EmbedFonts(); + } if( -1 != nVisible ) { @@ -498,20 +679,32 @@ sal_Bool SVGFilter::implExportPages( const Reference< XDrawPages >& rxPages, if( xShapes.is() ) { - OUString aAttr; + OUString aVisibility, aId, aSlideName( implGetValidIDFromInterface( xShapes, sal_True ) ); + // add visibility attribute if( i == nVisiblePage ) - aAttr = B2UCONST( "visible" ); + aVisibility = B2UCONST( "visible" ); else - aAttr = B2UCONST( "hidden" ); + aVisibility = B2UCONST( "hidden" ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", aAttr ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", implGetValidIDFromInterface( xShapes ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", aVisibility ); + + // add id attribute + if( bMaster ) + aId = ( B2UCONST( "MasterSlide_" ) ) += ::rtl::OUString::valueOf( ++mnMasterSlideId ); + else + aId = ( B2UCONST( "Slide_" ) ) += ::rtl::OUString::valueOf( ++mnSlideId ); + + if( aSlideName.getLength() ) + ( ( aId += B2UCONST( "(" ) ) += aSlideName ) += B2UCONST( ")" ); + + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aId ); { SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); const Point aNullPt; + if( mpObjects->find( xDrawPage ) != mpObjects->end() ) { Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY ); @@ -572,7 +765,7 @@ sal_Bool SVGFilter::implExportShape( const Reference< XShape >& rxShape ) if( xShapePropSet.is() ) { const ::rtl::OUString aShapeType( rxShape->getShapeType() ); - bool bHideObj = false; + sal_Bool bHideObj = sal_False; if( mbPresentation ) { @@ -585,41 +778,41 @@ sal_Bool SVGFilter::implExportShape( const Reference< XShape >& rxShape ) if( xPagePropSetInfo.is() ) { - static const ::rtl::OUString aHeaderString( B2UCONST( "IsHeaderVisible" ) ); - static const ::rtl::OUString aFooterString( B2UCONST( "IsFooterVisible" ) ); - static const ::rtl::OUString aDateTimeString( B2UCONST( "IsDateTimeVisible" ) ); - static const ::rtl::OUString aPageNumberString( B2UCONST( "IsPageNumberVisible" ) ); + const ::rtl::OUString aHeaderString( B2UCONST( "IsHeaderVisible" ) ); + const ::rtl::OUString aFooterString( B2UCONST( "IsFooterVisible" ) ); + const ::rtl::OUString aDateTimeString( B2UCONST( "IsDateTimeVisible" ) ); + const ::rtl::OUString aPageNumberString( B2UCONST( "IsPageNumberVisible" ) ); Any aProperty; - bool bValue = sal_False; + sal_Bool bValue = sal_False; if( ( aShapeType.lastIndexOf( B2UCONST( "presentation.HeaderShape" ) ) != -1 ) && xPagePropSetInfo->hasPropertyByName( aHeaderString ) && ( ( aProperty = xDefaultPagePropertySet->getPropertyValue( aHeaderString ) ) >>= bValue ) && !bValue ) { - bHideObj = true; + bHideObj = sal_True; } else if( ( aShapeType.lastIndexOf( B2UCONST( "presentation.FooterShape" ) ) != -1 ) && xPagePropSetInfo->hasPropertyByName( aFooterString ) && ( ( aProperty = xDefaultPagePropertySet->getPropertyValue( aFooterString ) ) >>= bValue ) && !bValue ) { - bHideObj = true; + bHideObj = sal_True; } else if( ( aShapeType.lastIndexOf( B2UCONST( "presentation.DateTimeShape" ) ) != -1 ) && xPagePropSetInfo->hasPropertyByName( aDateTimeString ) && ( ( aProperty = xDefaultPagePropertySet->getPropertyValue( aDateTimeString ) ) >>= bValue ) && !bValue ) { - bHideObj = true; + bHideObj = sal_True; } else if( ( aShapeType.lastIndexOf( B2UCONST( "presentation.SlideNumberShape" ) ) != -1 ) && xPagePropSetInfo->hasPropertyByName( aPageNumberString ) && ( ( aProperty = xDefaultPagePropertySet->getPropertyValue( aPageNumberString ) ) >>= bValue ) && !bValue ) { - bHideObj = true; + bHideObj = sal_True; } } } @@ -627,67 +820,78 @@ sal_Bool SVGFilter::implExportShape( const Reference< XShape >& rxShape ) if( !bHideObj ) { - OUString aObjName( implGetValidIDFromInterface( rxShape ) ), aObjDesc; - - if( aObjName.getLength() ) - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aObjName ); - if( aShapeType.lastIndexOf( B2UCONST( "drawing.GroupShape" ) ) != -1 ) { Reference< XShapes > xShapes( rxShape, UNO_QUERY ); if( xShapes.is() ) { - SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); + OUString aId( B2UCONST( "DrawingGroup_" ) ); + OUString aObjName( implGetValidIDFromInterface( rxShape, sal_True ) ), aObjDesc; + + aId += ::rtl::OUString::valueOf( ++mnDrawingGroupId ); + if( aObjName.getLength() ) + ( ( aId += B2UCONST( "(" ) ) += aObjName ) += B2UCONST( ")" ); + + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aId ); + { - SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "desc", sal_True, sal_True ); - Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY ); - - xExtDocHandler->unknown( B2UCONST( "Group" ) ); - } - - bRet = implExportShapes( xShapes ); + SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); + bRet = implExportShapes( xShapes ); + } } } - if( !bRet ) + if( !bRet && mpObjects->find( rxShape ) != mpObjects->end() ) { Reference< XText > xText( rxShape, UNO_QUERY ); ::com::sun::star::awt::Rectangle aBoundRect; const GDIMetaFile& rMtf = (*mpObjects)[ rxShape ].GetRepresentation(); xShapePropSet->getPropertyValue( B2UCONST( "BoundRect" ) ) >>= aBoundRect; + const Point aTopLeft( aBoundRect.X, aBoundRect.Y ); const Size aSize( aBoundRect.Width, aBoundRect.Height ); + if( rMtf.GetActionCount() ) { - SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); - - { - SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "desc", sal_True, sal_True ); - Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY ); + OUString aId( B2UCONST( "Drawing_" ) ); + OUString aObjName( implGetValidIDFromInterface( rxShape, sal_True ) ), aObjDesc; - xExtDocHandler->unknown( implGetDescriptionFromShape( rxShape ) ); - } + aId += ::rtl::OUString::valueOf( ++mnDrawingId ); - if( rMtf.GetActionCount() ) + if( aObjName.getLength() ) + ( ( aId += B2UCONST( "(" ) ) += aObjName ) += B2UCONST( ")" ); + { if( ( aShapeType.lastIndexOf( B2UCONST( "drawing.OLE2Shape" ) ) != -1 ) || ( aShapeType.lastIndexOf( B2UCONST( "drawing.GraphicObjectShape" ) ) != -1 ) ) { - SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); - mpSVGWriter->WriteMetaFile( aTopLeft, aSize, rMtf, SVGWRITER_WRITE_ALL); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aId ); + + { + SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); + mpSVGWriter->WriteMetaFile( aTopLeft, aSize, rMtf, SVGWRITER_WRITE_FILL | SVGWRITER_WRITE_TEXT ); + } } else { - // write geometries - SvXMLElementExport aGeometryExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); - mpSVGWriter->WriteMetaFile( aTopLeft, aSize, rMtf, SVGWRITER_WRITE_FILL ); - - // write text separately - SvXMLElementExport aTextExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); - mpSVGWriter->WriteMetaFile( aTopLeft, aSize, rMtf, SVGWRITER_WRITE_TEXT ); + if( implHasText( rMtf ) ) + { + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aId ); + + { + SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); + mpSVGWriter->WriteMetaFile( aTopLeft, aSize, rMtf, SVGWRITER_WRITE_FILL ); + mpSVGWriter->WriteMetaFile( aTopLeft, aSize, rMtf, SVGWRITER_WRITE_TEXT ); + } + } + else + { + SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); + mpSVGWriter->WriteMetaFile( aTopLeft, aSize, rMtf, SVGWRITER_WRITE_FILL | SVGWRITER_WRITE_TEXT, &aId ); + } } } } @@ -835,7 +1039,7 @@ sal_Bool SVGFilter::implCreateObjectsFromShape( const Reference< XShape >& rxSha } else (*mpObjects)[ rxShape ] = ObjectRepresentation( rxShape, aGraphic.GetGDIMetaFile() ); - + bRet = sal_True; } } @@ -908,30 +1112,75 @@ OUString SVGFilter::implGetDescriptionFromShape( const Reference< XShape >& rxSh // ----------------------------------------------------------------------------- -OUString SVGFilter::implGetValidIDFromInterface( const Reference< XInterface >& rxIf ) +OUString SVGFilter::implGetValidIDFromInterface( const Reference< XInterface >& rxIf, sal_Bool bUnique ) { Reference< XNamed > xNamed( rxIf, UNO_QUERY ); OUString aRet; if( xNamed.is() ) - aRet = xNamed->getName().replace( ' ', '_' ); + { + aRet = xNamed->getName().replace( ' ', '_' ). + replace( ':', '_' ). + replace( ',', '_' ). + replace( ';', '_' ). + replace( '&', '_' ). + replace( '!', '_' ). + replace( '|', '_' ); + } + + if( ( aRet.getLength() > 0 ) && bUnique ) + { + while( ::std::find( maUniqueIdVector.begin(), maUniqueIdVector.end(), aRet ) != maUniqueIdVector.end() ) + { + aRet += B2UCONST( "_" ); + } + + maUniqueIdVector.push_back( aRet ); + } return aRet; } // ----------------------------------------------------------------------------- +sal_Bool SVGFilter::implHasText( const GDIMetaFile& rMtf ) const +{ + sal_Bool bRet = sal_False; + + for( sal_uInt32 nCurAction = 0, nCount = rMtf.GetActionCount(); ( nCurAction < nCount ) && !bRet; ++nCurAction ) + { + switch( rMtf.GetAction( nCurAction )->GetType() ) + { + case( META_TEXT_ACTION ): + case( META_TEXTRECT_ACTION ): + case( META_TEXTARRAY_ACTION ): + case( META_STRETCHTEXT_ACTION ): + { + bRet = sal_True; + } + break; + + default: + break; + } + } + + return bRet; +} + +// ----------------------------------------------------------------------------- + IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo ) { OUString aRepresentation; - bool bFieldProcessed = false; + sal_Bool bFieldProcessed = sal_False; if( pInfo ) { - static const ::rtl::OUString aHeaderText( B2UCONST( "HeaderText" ) ); - static const ::rtl::OUString aFooterText( B2UCONST( "FooterText" ) ); - static const ::rtl::OUString aDateTimeText( B2UCONST( "DateTimeText" ) ); - static const ::rtl::OUString aPageNumberText( B2UCONST( "Number" ) ); + const ::rtl::OUString aHeaderText( B2UCONST( "HeaderText" ) ); + const ::rtl::OUString aFooterText( B2UCONST( "FooterText" ) ); + const ::rtl::OUString aDateTimeText( B2UCONST( "DateTimeText" ) ); + const ::rtl::OUString aPageNumberText( B2UCONST( "Number" ) ); const Reference< XPropertySet > xDefaultPagePropertySet( mxDefaultPage, UNO_QUERY ); Reference< XPropertySetInfo > xDefaultPagePropSetInfo( xDefaultPagePropertySet->getPropertySetInfo() ); @@ -945,19 +1194,19 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo ) xDefaultPagePropSetInfo->hasPropertyByName( aHeaderText ) ) { xDefaultPagePropertySet->getPropertyValue( aHeaderText ) >>= aRepresentation; - bFieldProcessed = true; + bFieldProcessed = sal_True; } else if( pField->ISA( SvxFooterField ) && xDefaultPagePropSetInfo->hasPropertyByName( aFooterText ) ) { xDefaultPagePropertySet->getPropertyValue( aFooterText ) >>= aRepresentation; - bFieldProcessed = true; + bFieldProcessed = sal_True; } else if( pField->ISA( SvxDateTimeField ) && xDefaultPagePropSetInfo->hasPropertyByName( aDateTimeText ) ) { xDefaultPagePropertySet->getPropertyValue( aDateTimeText ) >>= aRepresentation; - bFieldProcessed = true; + bFieldProcessed = sal_True; } else if( pField->ISA( SvxPageField ) && xDefaultPagePropSetInfo->hasPropertyByName( aPageNumberText ) ) @@ -969,7 +1218,7 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo ) if( mpSdrModel ) { - bool bUpper = false; + sal_Bool bUpper = sal_False; switch( mpSdrModel->GetPageNumType() ) { @@ -980,7 +1229,7 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo ) aPageNumValue += (sal_Unicode)(char)( ( nPageNumber- 1 ) % 26 + 'a' ); break; case SVX_ROMAN_UPPER: - bUpper = true; + bUpper = sal_True; case SVX_ROMAN_LOWER: aPageNumValue += SvxNumberFormat::CreateRomanString( nPageNumber, bUpper ); break; @@ -996,7 +1245,7 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo ) aPageNumValue += String::CreateFromInt32( nPageNumber ); aRepresentation = aPageNumValue; - bFieldProcessed = true; + bFieldProcessed = sal_True; } } diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx index ab912347d..b222eb6a0 100644 --- a/filter/source/svg/svgfilter.cxx +++ b/filter/source/svg/svgfilter.cxx @@ -29,13 +29,16 @@ #include "precompiled_filter.hxx" #include <cstdio> - #include "svgfilter.hxx" +#include <vos/mutex.hxx> + #include <com/sun/star/drawing/XDrawPage.hpp> #include <com/sun/star/drawing/XDrawView.hpp> #include <com/sun/star/frame/XDesktop.hdl> #include <com/sun/star/frame/XController.hdl> -#include <vos/mutex.hxx> + +#define SVG_FILTER_SERVICE_NAME "com.sun.star.comp.Draw.SVGFilter" +#define SVG_FILTER_IMPLEMENTATION_NAME SVG_FILTER_SERVICE_NAME using ::rtl::OUString; using namespace ::com::sun::star; @@ -82,7 +85,7 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto #ifdef SOLAR_JAVA if( mxDstDoc.is() ) - bRet = implImport( rDescriptor ); + bRet = sal_False;//implImport( rDescriptor ); else #endif if( mxSrcDoc.is() ) @@ -115,18 +118,18 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto } } - Sequence< PropertyValue > aNewDescritor( rDescriptor ); + Sequence< PropertyValue > aNewDescriptor( rDescriptor ); if( nCurrentPageNumber > 0 ) { const sal_uInt32 nOldLength = rDescriptor.getLength(); - aNewDescritor.realloc( nOldLength + 1 ); - aNewDescritor[ nOldLength ].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PagePos" ) ); - aNewDescritor[ nOldLength ].Value <<= static_cast< sal_Int16 >( nCurrentPageNumber - 1 ); + aNewDescriptor.realloc( nOldLength + 1 ); + aNewDescriptor[ nOldLength ].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PagePos" ) ); + aNewDescriptor[ nOldLength ].Value <<= static_cast< sal_Int16 >( nCurrentPageNumber - 1 ); } - bRet = implExport( aNewDescritor ); + bRet = implExport( aNewDescriptor ); } else bRet = sal_False; @@ -173,17 +176,15 @@ void SAL_CALL SVGFilter::initialize( const ::com::sun::star::uno::Sequence< ::co OUString SVGFilter_getImplementationName () throw (RuntimeException) { - return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.SVGFilter" ) ); + return OUString ( RTL_CONSTASCII_USTRINGPARAM ( SVG_FILTER_IMPLEMENTATION_NAME ) ); } // ----------------------------------------------------------------------------- -#define SERVICE_NAME "com.sun.star.document.SVGFilter" - -sal_Bool SAL_CALL SVGFilter_supportsService( const OUString& ServiceName ) +sal_Bool SAL_CALL SVGFilter_supportsService( const OUString& rServiceName ) throw (RuntimeException) { - return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) ); + return( rServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SVG_FILTER_SERVICE_NAME ) ) ); } // ----------------------------------------------------------------------------- @@ -192,12 +193,10 @@ Sequence< OUString > SAL_CALL SVGFilter_getSupportedServiceNames( ) throw (Runt { Sequence < OUString > aRet(1); OUString* pArray = aRet.getArray(); - pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SVG_FILTER_SERVICE_NAME ) ); return aRet; } -#undef SERVICE_NAME - // ----------------------------------------------------------------------------- Reference< XInterface > SAL_CALL SVGFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr) throw( Exception ) diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx index ce14199aa..be02e098a 100644 --- a/filter/source/svg/svgfilter.hxx +++ b/filter/source/svg/svgfilter.hxx @@ -2,10 +2,13 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * + * $RCSfile: svgfilter.hxx,v $ + * $Revision: 1.10.110.11 $ + * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -64,6 +67,9 @@ #include <hash_map> #include <osl/diagnose.h> #include <rtl/process.h> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/polygon/b2dpolygonclipper.hxx> +#include <basegfx/polygon/b2dpolypolygontools.hxx> #include <tools/debug.hxx> #include <comphelper/processfactory.hxx> #include <unotools/tempfile.hxx> @@ -84,6 +90,8 @@ #include "svgfilter.hxx" #include "svgscript.hxx" +#include <cstdio> + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; @@ -110,25 +118,42 @@ using namespace ::std; // #110680# class SVGExport : public SvXMLExport { -private: - - SVGExport(); + typedef ::std::list< ::basegfx::B2DPolyPolygon > B2DPolyPolygonList; +public: + + SVGExport( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + const Reference< XDocumentHandler >& rxHandler, + const Sequence< PropertyValue >& rFilterData ); + + virtual ~SVGExport(); + + sal_Bool IsUseTinyProfile() const; + sal_Bool IsEmbedFonts() const; + sal_Bool IsUseNativeTextDecoration() const; + ::rtl::OUString GetGlyphPlacement() const; + sal_Bool IsUseOpacity() const; + sal_Bool IsUseGradient() const; + + void pushClip( const ::basegfx::B2DPolyPolygon& rPolyPoly ); + void popClip(); + sal_Bool hasClip() const; + const ::basegfx::B2DPolyPolygon* getCurClip() const; + protected: - virtual void _ExportMeta() {} - virtual void _ExportStyles( sal_Bool /* bUsed */ ) {} - virtual void _ExportAutoStyles() {} - virtual void _ExportContent() {} - virtual void _ExportMasterStyles() {} - virtual sal_uInt32 exportDoc( enum ::xmloff::token::XMLTokenEnum /* eClass */ ) { return 0; } - -public: - - SVGExport( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, - const Reference< XDocumentHandler >& rxHandler ); - virtual ~SVGExport(); +virtual void _ExportStyles( sal_Bool /* bUsed */ ) {} +virtual void _ExportAutoStyles() {} +virtual void _ExportContent() {} +virtual void _ExportMasterStyles() {} +virtual sal_uInt32 exportDoc( enum ::xmloff::token::XMLTokenEnum /* eClass */ ) { return 0; } + +private: + + const Sequence< PropertyValue >& mrFilterData; + B2DPolyPolygonList maClipList; + + SVGExport(); }; // ------------------------ @@ -151,7 +176,7 @@ public: ~ObjectRepresentation(); ObjectRepresentation& operator=( const ObjectRepresentation& rPresentation ); - bool operator==( const ObjectRepresentation& rPresentation ) const; + sal_Bool operator==( const ObjectRepresentation& rPresentation ) const; const Reference< XInterface >& GetObject() const { return mxObject; } sal_Bool HasRepresentation() const { return mpMtf != NULL; } @@ -164,7 +189,10 @@ public: struct HashReferenceXInterface { - size_t operator()( const Reference< XInterface >& rxIf ) const { return reinterpret_cast< size_t >( rxIf.get() ); } + size_t operator()( const Reference< XInterface >& rxIf ) const + { + return reinterpret_cast< size_t >( rxIf.get() ); + } }; // ------------- @@ -189,6 +217,7 @@ class SVGFilter : public cppu::WeakImplHelper4 < XFilter, #endif { typedef ::std::hash_map< Reference< XInterface >, ObjectRepresentation, HashReferenceXInterface > ObjectMap; + typedef ::std::vector< ::rtl::OUString > UniqueIdVector; private: @@ -207,6 +236,12 @@ private: Reference< XComponent > mxDstDoc; #endif Reference< XDrawPage > mxDefaultPage; + Sequence< PropertyValue > maFilterData; + UniqueIdVector maUniqueIdVector; + sal_Int32 mnMasterSlideId; + sal_Int32 mnSlideId; + sal_Int32 mnDrawingGroupId; + sal_Int32 mnDrawingId; Link maOldFieldHdl; #ifdef SOLAR_JAVA @@ -240,7 +275,9 @@ private: sal_Bool implCreateObjectsFromBackground( const Reference< XDrawPage >& rxMasterPage ); ::rtl::OUString implGetDescriptionFromShape( const Reference< XShape >& rxShape ); - ::rtl::OUString implGetValidIDFromInterface( const Reference< XInterface >& rxIf ); + ::rtl::OUString implGetValidIDFromInterface( const Reference< XInterface >& rxIf, sal_Bool bUnique = sal_False ); + + sal_Bool implHasText( const GDIMetaFile& rMtf ) const; DECL_LINK( CalcFieldHdl, EditFieldInfo* ); @@ -292,5 +329,5 @@ sal_Bool SAL_CALL SVGFilter_supportsService( const ::rtl::OUString& ServiceName ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SVGFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr) throw ( ::com::sun::star::uno::Exception ); - + #endif // SVGFILTER_HXX diff --git a/filter/source/svg/svgfontexport.cxx b/filter/source/svg/svgfontexport.cxx index 0de876d71..d45667f61 100644 --- a/filter/source/svg/svgfontexport.cxx +++ b/filter/source/svg/svgfontexport.cxx @@ -2,10 +2,13 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * + * $RCSfile: svgfontexport.cxx,v $ + * $Revision: 1.6.64.10 $ + * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -28,16 +31,16 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_filter.hxx" - #include "svgfontexport.hxx" +#include <vcl/unohelp.hxx> -static const sal_Int32 nFontEM = 2048; +static const sal_Int32 nFontEM = 2048; // ----------------- // - SVGFontExport - // ----------------- -SVGFontExport::SVGFontExport( SvXMLExport& rExport, const ::std::vector< ObjectRepresentation >& rObjects ) : +SVGFontExport::SVGFontExport( SVGExport& rExport, const ::std::vector< ObjectRepresentation >& rObjects ) : mrExport( rExport ), maObjects( rObjects ), mnCurFontId( 0 ) @@ -52,6 +55,33 @@ SVGFontExport::~SVGFontExport() // ----------------------------------------------------------------------------- +SVGFontExport::GlyphSet& SVGFontExport::implGetGlyphSet( const Font& rFont ) +{ + FontWeight eWeight( WEIGHT_NORMAL ); + FontItalic eItalic( ITALIC_NONE ); + ::rtl::OUString aFontName( rFont.GetName() ); + sal_Int32 nNextTokenPos( 0 ); + + switch( rFont.GetWeight() ) + { + case WEIGHT_BOLD: + case WEIGHT_ULTRABOLD: + case WEIGHT_BLACK: + eWeight = WEIGHT_BOLD; + break; + + default: + break; + } + + if( rFont.GetItalic() != ITALIC_NONE ) + eItalic = ITALIC_NORMAL; + + return( maGlyphTree[ aFontName.getToken( 0, ';', nNextTokenPos ) ][ eWeight ][ eItalic ] ); +} + +// ----------------------------------------------------------------------------- + void SVGFontExport::implCollectGlyphs() { VirtualDevice aVDev; @@ -71,7 +101,7 @@ void SVGFontExport::implCollectGlyphs() { ::rtl::OUString aText; MetaAction* pAction = rMtf.GetAction( i ); - const sal_uInt16 nType = pAction->GetType(); + const sal_uInt16 nType = pAction->GetType(); switch( nType ) { @@ -110,11 +140,34 @@ void SVGFontExport::implCollectGlyphs() if( aText.getLength() ) { - const String& rFontName = aVDev.GetFont().GetName(); - const sal_Unicode* pStr = aText.getStr(); - - for( sal_uInt32 j = 0, nLen = aText.getLength(); j < nLen; ++j ) - maGlyphs[ rFontName ].insert( pStr[ j ] ); + GlyphSet& rGlyphSet = implGetGlyphSet( aVDev.GetFont() ); + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > xBI( + ::vcl::unohelper::CreateBreakIterator() ); + + if( xBI.is() ) + { + const ::com::sun::star::lang::Locale& rLocale = Application::GetSettings().GetLocale(); + sal_Int32 nCurPos = 0, nLastPos = -1; + + while( ( nCurPos < aText.getLength() ) && ( nCurPos > nLastPos ) ) + { + sal_Int32 nCount2 = 1; + + nLastPos = nCurPos; + nCurPos = xBI->nextCharacters( aText, nCurPos, rLocale, + ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, + nCount2, nCount2 ); + + rGlyphSet.insert( aText.copy( nLastPos, nCurPos - nLastPos ) ); + } + } + else + { + const sal_Unicode* pStr = aText.getStr(); + + for( sal_uInt32 k = 0, nLen = aText.getLength(); k < nLen; ++k ) + rGlyphSet.insert( rtl::OUString( pStr[ k ] ) ); + } } } @@ -127,103 +180,118 @@ void SVGFontExport::implCollectGlyphs() // ----------------------------------------------------------------------------- -void SVGFontExport::implEmbedFont( const ::rtl::OUString& rFontName, const ::std::set< sal_Unicode >& rGlyphs ) +void SVGFontExport::implEmbedFont( const Font& rFont ) { -#ifdef _SVG_EMBED_FONTS - ::std::set< sal_Unicode >::const_iterator aIter( rGlyphs.begin() ); - const ::rtl::OUString aEmbeddedFontStr( B2UCONST( "EmbeddedFont_" ) ); - + if( mrExport.IsEmbedFonts() ) { - SvXMLElementExport aExp( mrExport, XML_NAMESPACE_NONE, "defs", sal_True, sal_True ); - ::rtl::OUString aCurIdStr( aEmbeddedFontStr ); - ::rtl::OUString aUnitsPerEM( SVGActionWriter::GetValueString( nFontEM ) ); - VirtualDevice aVDev; - Font aFont( rFontName, Size( 0, nFontEM ) ); - - aVDev.SetMapMode( MAP_100TH_MM ); - aFont.SetAlign( ALIGN_BASELINE ); - aVDev.SetFont( aFont ); - - mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", aCurIdStr += SVGActionWriter::GetValueString( ++mnCurFontId ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", aUnitsPerEM ); - + GlyphSet& rGlyphSet = implGetGlyphSet( rFont ); + + if( !rGlyphSet.empty() ) { - SvXMLElementExport aExp2( mrExport, XML_NAMESPACE_NONE, "font", sal_True, sal_True ); - Point aPos; - Size aSize( nFontEM, nFontEM ); - PolyPolygon aMissingGlyphPolyPoly( Rectangle( aPos, aSize ) ); - - aMissingGlyphPolyPoly.Move( 0, -nFontEM ); - aMissingGlyphPolyPoly.Scale( 1.0, -1.0 ); - - mrExport.AddAttribute( XML_NAMESPACE_NONE, "font-family", GetMappedFontName( rFontName ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "units-per-em", aUnitsPerEM ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "ascent", SVGActionWriter::GetValueString( aVDev.GetFontMetric().GetAscent() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "descent", SVGActionWriter::GetValueString( aVDev.GetFontMetric().GetDescent() ) ); - - { - SvXMLElementExport aExp3( mrExport, XML_NAMESPACE_NONE, "font-face", sal_True, sal_True ); - } - - mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", SVGActionWriter::GetValueString( aSize.Width() ) ); - + GlyphSet::const_iterator aIter( rGlyphSet.begin() ); + const ::rtl::OUString aEmbeddedFontStr( B2UCONST( "EmbeddedFont_" ) ); + { - SvXMLElementExport aExp3( mrExport, XML_NAMESPACE_NONE, "missing-glyph", sal_True, sal_True ); - - mrExport.AddAttribute( XML_NAMESPACE_NONE, "style", B2UCONST( "fill:none;stroke:black;stroke-width:33" ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "d", SVGActionWriter::GetPathString( aMissingGlyphPolyPoly, sal_False ) ); - + SvXMLElementExport aExp( mrExport, XML_NAMESPACE_NONE, "defs", sal_True, sal_True ); + ::rtl::OUString aCurIdStr( aEmbeddedFontStr ); + ::rtl::OUString aUnitsPerEM( ::rtl::OUString::valueOf( nFontEM ) ); + VirtualDevice aVDev; + Font aFont( rFont ); + + aFont.SetSize( Size( 0, nFontEM ) ); + aFont.SetAlign( ALIGN_BASELINE ); + + aVDev.SetMapMode( MAP_100TH_MM ); + aVDev.SetFont( aFont ); + + mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", aCurIdStr += ::rtl::OUString::valueOf( ++mnCurFontId ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", aUnitsPerEM ); + { - SvXMLElementExport aExp4( mrExport, XML_NAMESPACE_NONE, "path", sal_True, sal_True ); + SvXMLElementExport aExp2( mrExport, XML_NAMESPACE_NONE, "font", sal_True, sal_True ); + ::rtl::OUString aFontWeight; + ::rtl::OUString aFontStyle; + const Size aSize( nFontEM, nFontEM ); + + // Font Weight + if( aFont.GetWeight() != WEIGHT_NORMAL ) + aFontWeight = B2UCONST( "bold" ); + else + aFontWeight = B2UCONST( "normal" ); + + // Font Italic + if( aFont.GetItalic() != ITALIC_NONE ) + aFontStyle = B2UCONST( "italic" ); + else + aFontStyle = B2UCONST( "normal" ); + + mrExport.AddAttribute( XML_NAMESPACE_NONE, "font-family", GetMappedFontName( rFont.GetName() ) ); + 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", ::rtl::OUString::valueOf( aVDev.GetFontMetric().GetAscent() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "descent", ::rtl::OUString::valueOf( aVDev.GetFontMetric().GetDescent() ) ); + + { + SvXMLElementExport aExp3( mrExport, XML_NAMESPACE_NONE, "font-face", sal_True, sal_True ); + } + + mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", ::rtl::OUString::valueOf( aSize.Width() ) ); + + { + const Point aPos; + const PolyPolygon aMissingGlyphPolyPoly( Rectangle( aPos, aSize ) ); + + mrExport.AddAttribute( XML_NAMESPACE_NONE, "d", SVGActionWriter::GetPathString( aMissingGlyphPolyPoly, sal_False ) ); + + { + SvXMLElementExport aExp4( mrExport, XML_NAMESPACE_NONE, "missing-glyph", sal_True, sal_True ); + } + } + + while( aIter != rGlyphSet.end() ) + { + implEmbedGlyph( aVDev, *aIter ); + ++aIter; + } } } - - while( aIter != rGlyphs.end() ) - { - implEmbedGlyph( aVDev, ::rtl::OUString( *aIter ) ); - ++aIter; - } } } -#endif } // ----------------------------------------------------------------------------- -void SVGFontExport::implEmbedGlyph( OutputDevice& rOut, const ::rtl::OUString& rGlyphs ) +void SVGFontExport::implEmbedGlyph( OutputDevice& rOut, const ::rtl::OUString& rCellStr ) { PolyPolygon aPolyPoly; - ::rtl::OUString aStr( rGlyphs ); const sal_Unicode nSpace = ' '; - if( rOut.GetTextOutline( aPolyPoly, aStr ) ) + if( rOut.GetTextOutline( aPolyPoly, rCellStr ) ) { Rectangle aBoundRect; aPolyPoly.Scale( 1.0, -1.0 ); - if( !rOut.GetTextBoundRect( aBoundRect, aStr ) ) - aBoundRect = Rectangle( Point( 0, 0 ), Size( rOut.GetTextWidth( aStr ), 0 ) ); + if( !rOut.GetTextBoundRect( aBoundRect, rCellStr ) ) + aBoundRect = Rectangle( Point( 0, 0 ), Size( rOut.GetTextWidth( rCellStr ), 0 ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "unicode", aStr ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "unicode", rCellStr ); - if( rGlyphs[ 0 ] == nSpace ) - aBoundRect = Rectangle( Point( 0, 0 ), Size( rOut.GetTextWidth( sal_Unicode( 'x' ) ), 0 ) ); + if( rCellStr[ 0 ] == nSpace && rCellStr.getLength() == 1 ) + aBoundRect = Rectangle( Point( 0, 0 ), Size( rOut.GetTextWidth( sal_Unicode( ' ' ) ), 0 ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", SVGActionWriter::GetValueString( aBoundRect.GetWidth() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", ::rtl::OUString::valueOf( aBoundRect.GetWidth() ) ); + const ::rtl::OUString aPathString( SVGActionWriter::GetPathString( aPolyPoly, sal_False ) ); + + if( aPathString.getLength() ) { - SvXMLElementExport aExp( mrExport, XML_NAMESPACE_NONE, "glyph", sal_True, sal_True ); - const ::rtl::OUString aPathString( SVGActionWriter::GetPathString( aPolyPoly, sal_False ) ); - - if( aPathString.getLength() ) - { - mrExport.AddAttribute( XML_NAMESPACE_NONE, "d", aPathString ); - - { - SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, B2UCONST( "path" ), sal_True, sal_True ); - } - } + mrExport.AddAttribute( XML_NAMESPACE_NONE, "d", aPathString ); + } + + { + SvXMLElementExport aExp( mrExport, XML_NAMESPACE_NONE, "glyph", sal_True, sal_True ); } } } @@ -233,13 +301,36 @@ void SVGFontExport::implEmbedGlyph( OutputDevice& rOut, const ::rtl::OUString& r void SVGFontExport::EmbedFonts() { implCollectGlyphs(); - - GlyphMap::const_iterator aIter( maGlyphs.begin() ); - - while( aIter != maGlyphs.end() ) + + GlyphTree::const_iterator aGlyphTreeIter( maGlyphTree.begin() ); + + while( aGlyphTreeIter != maGlyphTree.end() ) { - implEmbedFont( (*aIter).first, (*aIter).second ); - ++aIter; + const FontWeightMap& rFontWeightMap = (*aGlyphTreeIter).second; + FontWeightMap::const_iterator aFontWeightIter( rFontWeightMap.begin() ); + + while( aFontWeightIter != rFontWeightMap.end() ) + { + const FontItalicMap& rFontItalicMap = (*aFontWeightIter).second; + FontItalicMap::const_iterator aFontItalicIter( rFontItalicMap.begin() ); + + while( aFontItalicIter != rFontItalicMap.end() ) + { + Font aFont; + + aFont.SetName( (*aGlyphTreeIter).first ); + aFont.SetWeight( (*aFontWeightIter).first ); + aFont.SetItalic( (*aFontItalicIter).first ); + + implEmbedFont( aFont ); + + ++aFontItalicIter; + } + + ++aFontWeightIter; + } + + ++aGlyphTreeIter; } } @@ -247,12 +338,11 @@ void SVGFontExport::EmbedFonts() ::rtl::OUString SVGFontExport::GetMappedFontName( const ::rtl::OUString& rFontName ) const { - ::rtl::OUString aRet( String( rFontName ).GetToken( 0, ';' ) ); + sal_Int32 nNextTokenPos( 0 ); + ::rtl::OUString aRet( rFontName.getToken( 0, ';', nNextTokenPos ) ); -#ifdef _SVG_EMBED_FONTS if( mnCurFontId ) aRet += B2UCONST( " embedded" ); -#endif return aRet; } diff --git a/filter/source/svg/svgfontexport.hxx b/filter/source/svg/svgfontexport.hxx index c44b653bc..36debdc12 100644 --- a/filter/source/svg/svgfontexport.hxx +++ b/filter/source/svg/svgfontexport.hxx @@ -2,10 +2,13 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * + * $RCSfile: svgfontexport.hxx,v $ + * $Revision: 1.2.110.3 $ + * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -38,23 +41,28 @@ class SVGFontExport { - typedef ::std::hash_map< ::rtl::OUString, ::std::set< sal_Unicode >, ::comphelper::UStringHash > GlyphMap; - typedef ::std::vector< ObjectRepresentation > ObjectVector; - + typedef ::std::vector< ObjectRepresentation > ObjectVector; + typedef ::std::set< ::rtl::OUString, ::std::greater< ::rtl::OUString > > GlyphSet; + typedef ::std::map< FontItalic, GlyphSet > FontItalicMap; + typedef ::std::map< FontWeight, FontItalicMap > FontWeightMap; + typedef ::std::map< ::rtl::OUString, FontWeightMap > FontNameMap; + typedef FontNameMap GlyphTree; + private: - SvXMLExport& mrExport; - GlyphMap maGlyphs; + SVGExport& mrExport; + GlyphTree maGlyphTree; ObjectVector maObjects; - sal_uInt32 mnCurFontId; + sal_Int32 mnCurFontId; + GlyphSet& implGetGlyphSet( const Font& rFont ); void implCollectGlyphs(); - void implEmbedFont( const ::rtl::OUString& rFontName, const ::std::set< sal_Unicode >& rGlyphs ); - void implEmbedGlyph( OutputDevice& rOut, const ::rtl::OUString& rGlyphs ); + void implEmbedFont( const Font& rFont ); + void implEmbedGlyph( OutputDevice& rOut, const ::rtl::OUString& rCellStr ); public: - SVGFontExport( SvXMLExport& rExport, const ::std::vector< ObjectRepresentation >& rObjects ); + SVGFontExport( SVGExport& rExport, const ::std::vector< ObjectRepresentation >& rObjects ); ~SVGFontExport(); void EmbedFonts(); diff --git a/filter/source/svg/svguno.cxx b/filter/source/svg/svguno.cxx index 41b23918b..01a414cfe 100644 --- a/filter/source/svg/svguno.cxx +++ b/filter/source/svg/svguno.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <svgfilter.hxx> +#include <svgdialog.hxx> using ::rtl::OUString; using namespace ::cppu; @@ -56,13 +57,26 @@ extern "C" { void * pRet = 0; - OUString implName = OUString::createFromAscii( pImplName ); - if ( pServiceManager && implName.equals(SVGFilter_getImplementationName()) ) + const OUString aImplName = OUString::createFromAscii( pImplName ); + + if( pServiceManager ) { - Reference< XSingleServiceFactory > xFactory( createSingleFactory( - reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), - OUString::createFromAscii( pImplName ), - SVGFilter_createInstance, SVGFilter_getSupportedServiceNames() ) ); + Reference< XSingleServiceFactory > xFactory; + + if( aImplName.equals( SVGFilter_getImplementationName() ) ) + { + xFactory = Reference< XSingleServiceFactory >( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + SVGFilter_createInstance, SVGFilter_getSupportedServiceNames() ) ); + } + else if( aImplName.equals( SVGDialog_getImplementationName() ) ) + { + xFactory = Reference< XSingleServiceFactory >( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + SVGDialog_createInstance, SVGDialog_getSupportedServiceNames() ) ); + } if (xFactory.is()) { diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index a6621ff1d..d22ab3f38 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -2,10 +2,13 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * + * $RCSfile: svgwriter.cxx,v $ + * $Revision: 1.7.64.23 $ + * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -30,6 +33,7 @@ #include "svgfontexport.hxx" #include "svgwriter.hxx" +#include <vcl/unohelp.hxx> // ----------- // - statics - @@ -37,7 +41,6 @@ static const char aXMLElemG[] = "g"; static const char aXMLElemDefs[] = "defs"; -static const char aXMLElemClipPath[] = "clipPath"; static const char aXMLElemLine[] = "line"; static const char aXMLElemRect[] = "rect"; static const char aXMLElemEllipse[] = "ellipse"; @@ -47,6 +50,11 @@ static const char aXMLElemPolyLine[] = "polyline"; static const char aXMLElemText[] = "text"; static const char aXMLElemTSpan[] = "tspan"; static const char aXMLElemImage[] = "image"; +static const char aXMLElemLinearGradient[] = "linearGradient"; +static const char aXMLElemRadialGradient[] = "radialGradient"; +static const char aXMLElemStop[] = "stop"; + +// ----------------------------------------------------------------------------- static const char aXMLAttrTransform[] = "transform"; static const char aXMLAttrStyle[] = "style"; @@ -60,12 +68,29 @@ static const char aXMLAttrX2[] = "x2"; static const char aXMLAttrY2[] = "y2"; static const char aXMLAttrCX[] = "cx"; static const char aXMLAttrCY[] = "cy"; +static const char aXMLAttrR[] = "r"; static const char aXMLAttrRX[] = "rx"; static const char aXMLAttrRY[] = "ry"; static const char aXMLAttrWidth[] = "width"; static const char aXMLAttrHeight[] = "height"; static const char aXMLAttrPoints[] = "points"; +static const char aXMLAttrStroke[] = "stroke"; +static const char aXMLAttrStrokeOpacity[] = "stroke-opacity"; +static const char aXMLAttrStrokeWidth[] = "stroke-width"; +static const char aXMLAttrStrokeDashArray[] = "stroke-dasharray"; +static const char aXMLAttrFill[] = "fill"; +static const char aXMLAttrFillOpacity[] = "fill-opacity"; +static const char aXMLAttrFontFamily[] = "font-family"; +static const char aXMLAttrFontSize[] = "font-size"; +static const char aXMLAttrFontStyle[] = "font-style"; +static const char aXMLAttrFontWeight[] = "font-weight"; +static const char aXMLAttrTextDecoration[] = "text-decoration"; static const char aXMLAttrXLinkHRef[] = "xlink:href"; +static const char aXMLAttrGradientUnits[] = "gradientUnits"; +static const char aXMLAttrOffset[] = "offset"; +static const char aXMLAttrStopColor[] = "stop-color"; + +// ----------------------------------------------------------------------------- static const sal_Unicode pBase64[] = { @@ -80,371 +105,216 @@ static const sal_Unicode pBase64[] = '4','5','6','7','8','9','+','/' // 7 }; -// -------------- -// - FastString - -// -------------- +// ---------------------- +// - SVGAttributeWriter - +// ---------------------- -FastString::FastString( sal_uInt32 nInitLen, sal_uInt32 nIncrement ) : - mnBufLen( nInitLen ), - mnCurLen( 0 ), - mnBufInc( nIncrement ), - mpBuffer( new sal_Unicode[ nInitLen * sizeof( sal_Unicode ) ] ), - mnPartPos( 0 ) +SVGAttributeWriter::SVGAttributeWriter( SVGExport& rExport, SVGFontExport& rFontExport ) : + mrExport( rExport ), + mrFontExport( rFontExport ), + mpElemFont( NULL ), + mpElemPaint( NULL ) { - DBG_ASSERT( nInitLen, "invalid initial length" ); - DBG_ASSERT( nIncrement, "invalid increment" ); } // ----------------------------------------------------------------------------- -FastString::FastString( sal_Char* pBufferForBase64Encoding, sal_uInt32 nBufLen ) : - mnBufInc( 2048 ), - mnPartPos( 0 ) +SVGAttributeWriter::~SVGAttributeWriter() { - DBG_ASSERT( pBufferForBase64Encoding && nBufLen, "invalid arguments" ); - - const sal_uInt32 nQuadCount = nBufLen / 3; - const sal_uInt32 nRest = nBufLen % 3; - - if( nQuadCount || nRest ) - { - mnBufLen = mnCurLen = ( ( nQuadCount + ( nRest ? 1 : 0 ) ) << 2 ); - mpBuffer = new sal_Unicode[ mnBufLen * sizeof( sal_Unicode ) ]; - - sal_Char* pTmpSrc = pBufferForBase64Encoding; - sal_Unicode* pTmpDst = mpBuffer; - - for( sal_uInt32 i = 0; i < nQuadCount; i++ ) - { - const sal_Int32 nA = *pTmpSrc++; - const sal_Int32 nB = *pTmpSrc++; - const sal_Int32 nC = *pTmpSrc++; - - *pTmpDst++ = pBase64[ ( nA >> 2 ) & 0x3f ]; - *pTmpDst++ = pBase64[ ( ( nA << 4 ) & 0x30 ) + ( ( nB >> 4 ) & 0xf ) ]; - *pTmpDst++ = pBase64[ ( ( nB << 2 ) & 0x3c ) + ( ( nC >> 6 ) & 0x3 ) ]; - *pTmpDst++ = pBase64[ nC & 0x3f ]; - } - - if( 1 == nRest ) - { - const sal_Int32 nA = *pTmpSrc; - - *pTmpDst++ = pBase64[ ( nA >> 2 ) & 0x3f ]; - *pTmpDst++ = pBase64[ ( nA << 4 ) & 0x30 ]; - *pTmpDst++ = '='; - *pTmpDst = '='; - } - else if( 2 == nRest ) - { - const sal_Int32 nA = *pTmpSrc++; - const sal_Int32 nB = *pTmpSrc; - - *pTmpDst++ = pBase64[ ( nA >> 2 ) & 0x3f ]; - *pTmpDst++ = pBase64[ ( ( nA << 4 ) & 0x30 ) + ( ( nB >> 4 ) & 0xf ) ]; - *pTmpDst++ = pBase64[ ( nB << 2 ) & 0x3c ]; - *pTmpDst = '='; - } - } - else - { - mpBuffer = new sal_Unicode[ ( mnBufLen = 1 ) * sizeof( sal_Unicode ) ]; - mnCurLen = 0; - } + delete mpElemPaint; + delete mpElemFont; } // ----------------------------------------------------------------------------- -FastString::~FastString() +double SVGAttributeWriter::ImplRound( double fValue, sal_Int32 nDecs ) { - delete[] mpBuffer; + return( floor( fValue * pow( 10.0, (int)nDecs ) + 0.5 ) / pow( 10.0, (int)nDecs ) ); } // ----------------------------------------------------------------------------- -FastString& FastString::operator+=( const NMSP_RTL::OUString& rStr ) +void SVGAttributeWriter::ImplGetColorStr( const Color& rColor, ::rtl::OUString& rColorStr ) { - if( rStr.getLength() ) + if( rColor.GetTransparency() == 255 ) + rColorStr = B2UCONST( "none" ); + else { - if( ( mnCurLen + rStr.getLength() ) > mnBufLen ) - { - const sal_uInt32 nNewBufLen = ( mnBufLen + ( ( ( mnCurLen + rStr.getLength() ) - mnBufLen ) / mnBufInc + 1 ) * mnBufInc ); - sal_Unicode* pNewBuffer = new sal_Unicode[ nNewBufLen * sizeof( sal_Unicode ) ]; - - memcpy( pNewBuffer, mpBuffer, mnBufLen * sizeof( sal_Unicode ) ); - delete[] mpBuffer; - mpBuffer = pNewBuffer; - mnBufLen = nNewBufLen; - } - - memcpy( mpBuffer + mnCurLen, rStr.getStr(), rStr.getLength() * sizeof( sal_Unicode ) ); - mnCurLen += rStr.getLength(); - - if( maString.getLength() ) - maString = NMSP_RTL::OUString(); + rColorStr = B2UCONST( "rgb(" ); + rColorStr += ::rtl::OUString::valueOf( static_cast< sal_Int32 >( rColor.GetRed() ) ); + rColorStr += B2UCONST( "," ); + rColorStr += ::rtl::OUString::valueOf( static_cast< sal_Int32 >( rColor.GetGreen() ) ); + rColorStr += B2UCONST( "," ); + rColorStr += ::rtl::OUString::valueOf( static_cast< sal_Int32 >( rColor.GetBlue() ) ); + rColorStr += B2UCONST( ")" ); } - - return *this; -} - -// ----------------------------------------------------------------------------- - -const NMSP_RTL::OUString& FastString::GetString() const -{ - if( !maString.getLength() && mnCurLen ) - ( (FastString*) this )->maString = NMSP_RTL::OUString( mpBuffer, mnCurLen ); - - return maString; } // ----------------------------------------------------------------------------- -sal_Bool FastString::GetFirstPartString( const sal_uInt32 nPartLen, NMSP_RTL::OUString& rPartString ) +void SVGAttributeWriter::AddColorAttr( const char* pColorAttrName, + const char* pColorOpacityAttrName, + const Color& rColor ) { - const sal_uInt32 nLength = Min( mnCurLen, nPartLen ); - - mnPartPos = 0; - - if( nLength ) - { - rPartString = NMSP_RTL::OUString( mpBuffer, nLength ); - mnPartPos = nLength; - } + ::rtl::OUString aColor, aColorOpacity; + + ImplGetColorStr( rColor, aColor ); + + if( rColor.GetTransparency() > 0 && rColor.GetTransparency() < 255 ) + aColorOpacity = ::rtl::OUString::valueOf( ImplRound( ( 255.0 - rColor.GetTransparency() ) / 255.0 ) ); - return( rPartString.getLength() > 0 ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, pColorAttrName, aColor ); + + if( aColorOpacity.getLength() && mrExport.IsUseOpacity() ) + mrExport.AddAttribute( XML_NAMESPACE_NONE, pColorOpacityAttrName, aColorOpacity ); } // ----------------------------------------------------------------------------- -sal_Bool FastString::GetNextPartString( const sal_uInt32 nPartLen, NMSP_RTL::OUString& rPartString ) +void SVGAttributeWriter::AddPaintAttr( const Color& rLineColor, const Color& rFillColor, + const Rectangle* pObjBoundRect, const Gradient* pFillGradient ) { - if( mnPartPos < mnCurLen ) + // Fill + if( pObjBoundRect && pFillGradient ) { - const sal_uInt32 nLength = Min( mnCurLen - mnPartPos, nPartLen ); - rPartString = NMSP_RTL::OUString( mpBuffer + mnPartPos, nLength ); - mnPartPos += nLength; + ::rtl::OUString aGradientId; + + AddGradientDef( *pObjBoundRect, *pFillGradient, aGradientId ); + + if( aGradientId.getLength() ) + { + ::rtl::OUString aGradientURL( B2UCONST( "url(#" ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFill, ( aGradientURL += aGradientId ) += B2UCONST( ")" ) ); + } } else - rPartString = NMSP_RTL::OUString(); - - return( rPartString.getLength() > 0 ); -} - -// ---------------------- -// - SVGAttributeWriter - -// ---------------------- - -SVGAttributeWriter::SVGAttributeWriter( SvXMLExport& rExport, SVGFontExport& rFontExport ) : - mrExport( rExport ), - mrFontExport( rFontExport ), - mpElemFont( NULL ), - mpElemPaint( NULL ) -{ -} - -// ----------------------------------------------------------------------------- - -SVGAttributeWriter::~SVGAttributeWriter() -{ - delete mpElemPaint; - delete mpElemFont; -} - -// ----------------------------------------------------------------------------- - -NMSP_RTL::OUString SVGAttributeWriter::GetFontStyle( const Font& rFont ) -{ - FastString aStyle; - - // font family - aStyle += B2UCONST( "font-family:" ); - aStyle += mrFontExport.GetMappedFontName( rFont.GetName() ); - - // font size - aStyle += B2UCONST( ";" ); - aStyle += B2UCONST( "font-size:" ); - aStyle += SVGActionWriter::GetValueString( rFont.GetHeight() ); - - // font style -/* - if( rFont.GetItalic() != ITALIC_NONE ) - { - aStyle += B2UCONST( ";" ); - aStyle += B2UCONST( "font-style:" ); - - if( rFont.GetItalic() == ITALIC_OBLIQUE ) - aStyle += B2UCONST( "oblique" ); - else - aStyle += B2UCONST( "italic" ); - } -*/ - - // font weight - sal_Int32 nFontWeight; - - 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; - } - - aStyle += B2UCONST( ";" ); - aStyle += B2UCONST( "font-weight:" ); - aStyle += NMSP_RTL::OUString::valueOf( nFontWeight ); - - // !!! - // font-variant - // font-stretch - // font-size-adjust - -#ifdef _SVG_USE_NATIVE_TEXTDECORATION - - if( rFont.GetUnderline() != UNDERLINE_NONE || rFont.GetStrikeout() != STRIKEOUT_NONE ) - { - aStyle += B2UCONST( ";" ); - aStyle += B2UCONST( "text-decoration:" ); - - if( rFont.GetUnderline() != UNDERLINE_NONE ) - aStyle += B2UCONST( " underline" ); - - if( rFont.GetStrikeout() != STRIKEOUT_NONE ) - aStyle += B2UCONST( " line-through" ); - } + AddColorAttr( aXMLAttrFill, aXMLAttrFillOpacity, rFillColor ); -#endif // _SVG_USE_NATIVE_TEXTDECORATION - - return aStyle.GetString(); + // Stroke + AddColorAttr( aXMLAttrStroke, aXMLAttrStrokeOpacity, rLineColor ); } // ----------------------------------------------------------------------------- -NMSP_RTL::OUString SVGAttributeWriter::GetPaintStyle( const Color& rLineColor, const Color& rFillColor, const LineInfo* pLineInfo ) +void SVGAttributeWriter::AddGradientDef( const Rectangle& rObjRect, const Gradient& rGradient, ::rtl::OUString& rGradientId ) { - FastString aStyle; - - // line color - aStyle += B2UCONST( "stroke:" ); - - if( rLineColor.GetTransparency() == 255 ) - aStyle += B2UCONST( "none" ); - else + if( rObjRect.GetWidth() && rObjRect.GetHeight() && + ( rGradient.GetStyle() == GRADIENT_LINEAR || rGradient.GetStyle() == GRADIENT_AXIAL || + rGradient.GetStyle() == GRADIENT_RADIAL || rGradient.GetStyle() == GRADIENT_ELLIPTICAL ) ) { - // line color value in rgb - aStyle += B2UCONST( "rgb(" ); - aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rLineColor.GetRed() ); - aStyle += B2UCONST( "," ); - aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rLineColor.GetGreen() ); - aStyle += B2UCONST( "," ); - aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rLineColor.GetBlue() ); - aStyle += B2UCONST( ")" ); - - // line color opacity in percent if neccessary - if( rLineColor.GetTransparency() ) - { - aStyle += B2UCONST( ";" ); - aStyle += B2UCONST( "stroke-opacity:" ); - aStyle += NMSP_RTL::OUString::valueOf( ( 255 - (double) rLineColor.GetTransparency() ) / 255.0 ); - } - - if(pLineInfo) + SvXMLElementExport aDesc( mrExport, XML_NAMESPACE_NONE, aXMLElemDefs, sal_True, sal_True ); + Color aStartColor( rGradient.GetStartColor() ), aEndColor( rGradient.GetEndColor() ); + sal_uInt16 nAngle = rGradient.GetAngle() % 3600; + Point aObjRectCenter( rObjRect.Center() ); + Polygon aPoly( rObjRect ); + static sal_Int32 nCurGradientId = 1; + + aPoly.Rotate( aObjRectCenter, nAngle ); + Rectangle aRect( aPoly.GetBoundRect() ); + + // adjust start/end colors with intensities + aStartColor.SetRed( (sal_uInt8)( (long) aStartColor.GetRed() * rGradient.GetStartIntensity() ) / 100 ); + aStartColor.SetGreen( (sal_uInt8)( (long) aStartColor.GetGreen() * rGradient.GetStartIntensity() ) / 100 ); + aStartColor.SetBlue( (sal_uInt8)( (long) aStartColor.GetBlue() * rGradient.GetStartIntensity() ) / 100 ); + + aEndColor.SetRed( (sal_uInt8)( (long) aEndColor.GetRed() * rGradient.GetEndIntensity() ) / 100 ); + aEndColor.SetGreen( (sal_uInt8)( (long) aEndColor.GetGreen() * rGradient.GetEndIntensity() ) / 100 ); + aEndColor.SetBlue( (sal_uInt8)( (long) aEndColor.GetBlue() * rGradient.GetEndIntensity() ) / 100 ); + + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, + ( rGradientId = B2UCONST( "Gradient_" ) ) += ::rtl::OUString::valueOf( nCurGradientId++ ) ); + { - // 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()) + ::std::auto_ptr< SvXMLElementExport > apGradient; + ::rtl::OUString aColorStr; + + if( rGradient.GetStyle() == GRADIENT_LINEAR || rGradient.GetStyle() == GRADIENT_AXIAL ) { - 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++) + Polygon aLinePoly( 2 ); + + aLinePoly[ 0 ] = Point( aObjRectCenter.X(), aRect.Top() ); + aLinePoly[ 1 ] = Point( aObjRectCenter.X(), aRect.Bottom() ); + + aLinePoly.Rotate( aObjRectCenter, nAngle ); + + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrGradientUnits, B2UCONST( "userSpaceOnUse" ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX1, ::rtl::OUString::valueOf( aLinePoly[ 0 ].X() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY1, ::rtl::OUString::valueOf( aLinePoly[ 0 ].Y() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX2, ::rtl::OUString::valueOf( aLinePoly[ 1 ].X() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY2, ::rtl::OUString::valueOf( aLinePoly[ 1 ].Y() ) ); + + apGradient.reset( new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemLinearGradient, sal_True, sal_True ) ); + + // write stop values + double fBorder = static_cast< double >( rGradient.GetBorder() ) * + ( ( rGradient.GetStyle() == GRADIENT_AXIAL ) ? 0.005 : 0.01 ); + + ImplGetColorStr( ( rGradient.GetStyle() == GRADIENT_AXIAL ) ? aEndColor : aStartColor, aColorStr ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrOffset, ::rtl::OUString::valueOf( fBorder ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStopColor, aColorStr ); + { - if(bIsFirst) - aStyle += B2UCONST(" "), bIsFirst = false; - else - aStyle += B2UCONST(","); - aStyle += NMSP_RTL::OUString::valueOf(nDashLen); - aStyle += B2UCONST(","); - aStyle += NMSP_RTL::OUString::valueOf(nDistance); + SvXMLElementExport aDesc2( mrExport, XML_NAMESPACE_NONE, aXMLElemStop, sal_True, sal_True ); } - - for(sal_uInt16 b(0); b < pLineInfo->GetDotCount(); b++) + + if( rGradient.GetStyle() == GRADIENT_AXIAL ) + { + ImplGetColorStr( aStartColor, aColorStr ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrOffset, ::rtl::OUString::valueOf( 0.5 ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStopColor, aColorStr ); + + { + SvXMLElementExport aDesc3( mrExport, XML_NAMESPACE_NONE, aXMLElemStop, sal_True, sal_True ); + } + } + + if( rGradient.GetStyle() != GRADIENT_AXIAL ) + fBorder = 0.0; + + ImplGetColorStr( aEndColor, aColorStr ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrOffset, ::rtl::OUString::valueOf( ImplRound( 1.0 - fBorder ) ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStopColor, aColorStr ); + { - if(bIsFirst) - aStyle += B2UCONST(" "), bIsFirst = false; - else - aStyle += B2UCONST(","); - aStyle += NMSP_RTL::OUString::valueOf(nDotLen); - aStyle += B2UCONST(","); - aStyle += NMSP_RTL::OUString::valueOf(nDistance); + SvXMLElementExport aDesc4( mrExport, XML_NAMESPACE_NONE, aXMLElemStop, sal_True, sal_True ); } } - - if(basegfx::B2DLINEJOIN_MITER != pLineInfo->GetLineJoin()) + else { - aStyle += B2UCONST( ";" ); - aStyle += B2UCONST( "stroke-linejoin:" ); + const double fCenterX = rObjRect.Left() + rObjRect.GetWidth() * rGradient.GetOfsX() * 0.01; + const double fCenterY = rObjRect.Top() + rObjRect.GetHeight() * rGradient.GetOfsY() * 0.01; + const double fRadius = sqrt( static_cast< double >( rObjRect.GetWidth() ) * rObjRect.GetWidth() + + rObjRect.GetHeight() * rObjRect.GetHeight() ) * 0.5; - switch(pLineInfo->GetLineJoin()) + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrGradientUnits, B2UCONST( "userSpaceOnUse" ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrCX, ::rtl::OUString::valueOf( ImplRound( fCenterX ) ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrCY, ::rtl::OUString::valueOf( ImplRound( fCenterY ) ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrR, ::rtl::OUString::valueOf( ImplRound( fRadius ) ) ); + + apGradient.reset( new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemRadialGradient, sal_True, sal_True ) ); + + // write stop values + ImplGetColorStr( aEndColor, aColorStr ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrOffset, ::rtl::OUString::valueOf( 0.0 ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStopColor, aColorStr ); + { - 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; + SvXMLElementExport aDesc5( mrExport, XML_NAMESPACE_NONE, aXMLElemStop, sal_True, sal_True ); + } + + ImplGetColorStr( aStartColor, aColorStr ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrOffset, + ::rtl::OUString::valueOf( ImplRound( 1.0 - rGradient.GetBorder() * 0.01 ) ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStopColor, aColorStr ); + + { + SvXMLElementExport aDesc6( mrExport, XML_NAMESPACE_NONE, aXMLElemStop, sal_True, sal_True ); } } } } - - // fill color - aStyle += B2UCONST( ";" ); - aStyle += B2UCONST( "fill:" ); - - if( rFillColor.GetTransparency() == 255 ) - aStyle += B2UCONST( "none" ); else - { - // fill color value in rgb - aStyle += B2UCONST( "rgb(" ); - aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rFillColor.GetRed() ); - aStyle += B2UCONST( "," ); - aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rFillColor.GetGreen() ); - aStyle += B2UCONST( "," ); - aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rFillColor.GetBlue() ); - aStyle += B2UCONST( ")" ); - - // fill color opacity in percent if neccessary - if( rFillColor.GetTransparency() ) - { - aStyle += B2UCONST( ";" ); - aStyle += B2UCONST( "fill-opacity:" ); - aStyle += NMSP_RTL::OUString::valueOf( ( 255 - (double) rFillColor.GetTransparency() ) / 255.0 ); - } - } - - return aStyle.GetString(); + rGradientId = ::rtl::OUString(); } // ----------------------------------------------------------------------------- @@ -453,22 +323,67 @@ void SVGAttributeWriter::SetFontAttr( const Font& rFont ) { if( !mpElemFont || ( rFont != maCurFont ) ) { + ::rtl::OUString aFontStyle, aFontWeight, aTextDecoration; + sal_Int32 nFontWeight; + delete mpElemPaint, mpElemPaint = NULL; delete mpElemFont; - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, GetFontStyle( maCurFont = rFont ) ); - mpElemFont = new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_True ); - } -} + maCurFont = rFont; + + // Font Family + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontFamily, mrFontExport.GetMappedFontName( rFont.GetName() ) ); + + // Font Size + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontSize, ::rtl::OUString::valueOf( rFont.GetHeight() ) ); + + // Font Style + if( rFont.GetItalic() != ITALIC_NONE ) + { + if( rFont.GetItalic() == ITALIC_OBLIQUE ) + aFontStyle = B2UCONST( "oblique" ); + else + aFontStyle = B2UCONST( "italic" ); + } + else + aFontStyle = B2UCONST( "normal" ); -// ----------------------------------------------------------------------------- + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontStyle, aFontStyle ); -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, pLineInfo ) ); - mpElemPaint = new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_True ); + // 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, ::rtl::OUString::valueOf( nFontWeight ) ); + + if( mrExport.IsUseNativeTextDecoration() ) + { + if( rFont.GetUnderline() != UNDERLINE_NONE || rFont.GetStrikeout() != STRIKEOUT_NONE ) + { + if( rFont.GetUnderline() != UNDERLINE_NONE ) + aTextDecoration = B2UCONST( "underline " ); + + if( rFont.GetStrikeout() != STRIKEOUT_NONE ) + aTextDecoration += B2UCONST( "line-through " ); + } + else + aTextDecoration = B2UCONST( "none" ); + + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTextDecoration, aTextDecoration ); + } + + mpElemFont = new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_True ); } } @@ -476,12 +391,12 @@ void SVGAttributeWriter::SetPaintAttr( const Color& rLineColor, const Color& rFi // - SVGActionWriter - // ------------------- -SVGActionWriter::SVGActionWriter( SvXMLExport& rExport, SVGFontExport& rFontExport ) : +SVGActionWriter::SVGActionWriter( SVGExport& rExport, SVGFontExport& rFontExport ) : mrExport( rExport ), mrFontExport( rFontExport ), mpContext( NULL ), - mbClipAttrChanged( sal_False ), - mnCurClipId( 1 ) + mnInnerMtfCount( 0 ), + mbClipAttrChanged( sal_False ) { mpVDev = new VirtualDevice; mpVDev->EnableOutput( sal_False ); @@ -500,97 +415,94 @@ SVGActionWriter::~SVGActionWriter() long SVGActionWriter::ImplMap( sal_Int32 nVal ) const { - return ImplMap( Size( nVal, nVal ) ).Width(); + Size aSz( nVal, nVal ); + + return( ImplMap( aSz, aSz ).Width() ); } // ----------------------------------------------------------------------------- -Point SVGActionWriter::ImplMap( const Point& rPt ) const +Point& SVGActionWriter::ImplMap( const Point& rPt, Point& rDstPt ) const { - return mpVDev->LogicToLogic( rPt, mpVDev->GetMapMode(), maTargetMapMode ); + return( rDstPt = mpVDev->LogicToLogic( rPt, mpVDev->GetMapMode(), maTargetMapMode ) ); } // ----------------------------------------------------------------------------- -Size SVGActionWriter::ImplMap( const Size& rSz ) const +Size& SVGActionWriter::ImplMap( const Size& rSz, Size& rDstSz ) const { - return mpVDev->LogicToLogic( rSz, mpVDev->GetMapMode(), maTargetMapMode ); + return( rDstSz = mpVDev->LogicToLogic( rSz, mpVDev->GetMapMode(), maTargetMapMode ) ); } // ----------------------------------------------------------------------------- -LineInfo SVGActionWriter::ImplMap( const LineInfo& rLineInfo ) const +Rectangle& SVGActionWriter::ImplMap( const Rectangle& rRect, Rectangle& rDstRect ) const { - LineInfo aInfo(rLineInfo); - long aTemp(0); + Point aTL( rRect.TopLeft() ); + Size aSz( rRect.GetSize() ); - 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); + return( rDstRect = Rectangle( ImplMap( aTL, aTL ), ImplMap( aSz, aSz ) ) ); +} - 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); +Polygon& SVGActionWriter::ImplMap( const Polygon& rPoly, Polygon& rDstPoly ) const +{ + rDstPoly = Polygon( rPoly.GetSize() ); + + for( sal_uInt16 i = 0, nSize = rPoly.GetSize(); i < nSize; ++i ) + { + ImplMap( rPoly[ i ], rDstPoly[ i ] ); + rDstPoly.SetFlags( i, rPoly.GetFlags( i ) ); } - - aTemp = aInfo.GetWidth(); - mpVDev->LogicToLogic(&aTemp, 1, &mpVDev->GetMapMode(), &maTargetMapMode); - aInfo.SetWidth(aTemp); - - return aInfo; + + return( rDstPoly ); } // ----------------------------------------------------------------------------- -NMSP_RTL::OUString SVGActionWriter::GetValueString( sal_Int32 nVal ) +PolyPolygon& SVGActionWriter::ImplMap( const PolyPolygon& rPolyPoly, PolyPolygon& rDstPolyPoly ) const { - return ::rtl::OUString::valueOf( nVal ); + Polygon aPoly; + + rDstPolyPoly = PolyPolygon(); + + for( sal_uInt16 i = 0, nCount = rPolyPoly.Count(); i < nCount; ++i ) + { + rDstPolyPoly.Insert( ImplMap( rPolyPoly[ i ], aPoly ) ); + } + + return( rDstPolyPoly ); } // ----------------------------------------------------------------------------- -NMSP_RTL::OUString SVGActionWriter::GetPathString( const PolyPolygon& rPolyPoly, sal_Bool bLine ) +::rtl::OUString SVGActionWriter::GetPathString( const PolyPolygon& rPolyPoly, sal_Bool bLine ) { - FastString aPathData; - const NMSP_RTL::OUString aBlank( B2UCONST( " " ) ); - const NMSP_RTL::OUString aComma( B2UCONST( "," ) ); - Point aPolyPoint; + ::rtl::OUString aPathData; + const ::rtl::OUString aBlank( B2UCONST( " " ) ); + const ::rtl::OUString aComma( B2UCONST( "," ) ); + Point aPolyPoint; for( long i = 0, nCount = rPolyPoly.Count(); i < nCount; i++ ) { const Polygon& rPoly = rPolyPoly[ (sal_uInt16) i ]; - sal_uInt16 n = 1, nSize = rPoly.GetSize(); + sal_uInt16 n = 1, nSize = rPoly.GetSize(); if( nSize > 1 ) { aPathData += B2UCONST( "M " ); - aPathData += GetValueString( ( aPolyPoint = rPoly[ 0 ] ).X() ); + aPathData += ::rtl::OUString::valueOf( ( aPolyPoint = rPoly[ 0 ] ).X() ); aPathData += aComma; - aPathData += GetValueString( aPolyPoint.Y() ); + aPathData += ::rtl::OUString::valueOf( aPolyPoint.Y() ); + sal_Char nCurrentMode = 0; while( n < nSize ) { aPathData += aBlank; + if ( ( rPoly.GetFlags( n ) == POLY_CONTROL ) && ( ( n + 2 ) < nSize ) ) { if ( nCurrentMode != 'C' ) @@ -602,9 +514,9 @@ NMSP_RTL::OUString SVGActionWriter::GetPathString( const PolyPolygon& rPolyPoly, { if ( j ) aPathData += aBlank; - aPathData += GetValueString( ( aPolyPoint = rPoly[ n++ ] ).X() ); + aPathData += ::rtl::OUString::valueOf( ( aPolyPoint = rPoly[ n++ ] ).X() ); aPathData += aComma; - aPathData += GetValueString( aPolyPoint.Y() ); + aPathData += ::rtl::OUString::valueOf( aPolyPoint.Y() ); } } else @@ -614,9 +526,9 @@ NMSP_RTL::OUString SVGActionWriter::GetPathString( const PolyPolygon& rPolyPoly, nCurrentMode = 'L'; aPathData += B2UCONST( "L " ); } - aPathData += GetValueString( ( aPolyPoint = rPoly[ n++ ] ).X() ); + aPathData += ::rtl::OUString::valueOf( ( aPolyPoint = rPoly[ n++ ] ).X() ); aPathData += aComma; - aPathData += GetValueString( aPolyPoint.Y() ); + aPathData += ::rtl::OUString::valueOf( aPolyPoint.Y() ); } } @@ -628,25 +540,31 @@ NMSP_RTL::OUString SVGActionWriter::GetPathString( const PolyPolygon& rPolyPoly, } } - return aPathData.GetString(); + return aPathData; } // ----------------------------------------------------------------------------- -void SVGActionWriter::ImplWriteLine( const Point& rPt1, const Point& rPt2, const Color* pLineColor, - const NMSP_RTL::OUString* pStyle ) +void SVGActionWriter::ImplWriteLine( const Point& rPt1, const Point& rPt2, + const Color* pLineColor, sal_Bool bApplyMapping ) { - const Point aPt1( ImplMap( rPt1 ) ); - const Point aPt2( ImplMap( rPt2 ) ); - - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX1, GetValueString( aPt1.X() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY1, GetValueString( aPt1.Y() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX2, GetValueString( aPt2.X() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY2, GetValueString( aPt2.Y() ) ); + Point aPt1, aPt2; + + if( bApplyMapping ) + { + ImplMap( rPt1, aPt1 ); + ImplMap( rPt2, aPt2 ); + } + else + { + aPt1 = rPt1; + aPt2 = rPt2; + } - // add additional style if requested - if( pStyle ) - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, *pStyle ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX1, ::rtl::OUString::valueOf( aPt1.X() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY1, ::rtl::OUString::valueOf( aPt1.Y() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX2, ::rtl::OUString::valueOf( aPt2.X() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY2, ::rtl::OUString::valueOf( aPt2.Y() ) ); if( pLineColor ) { @@ -662,24 +580,25 @@ void SVGActionWriter::ImplWriteLine( const Point& rPt1, const Point& rPt2, const // ----------------------------------------------------------------------------- void SVGActionWriter::ImplWriteRect( const Rectangle& rRect, long nRadX, long nRadY, - const NMSP_RTL::OUString* pStyle ) + sal_Bool bApplyMapping ) { - const Rectangle aRect( ImplMap( rRect ) ); + Rectangle aRect; + + if( bApplyMapping ) + ImplMap( rRect, aRect ); + else + aRect = rRect; - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, GetValueString( aRect.Left() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, GetValueString( aRect.Top() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, GetValueString( aRect.GetWidth() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, GetValueString( aRect.GetHeight() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( aRect.Left() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aRect.Top() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, ::rtl::OUString::valueOf( aRect.GetWidth() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, ::rtl::OUString::valueOf( aRect.GetHeight() ) ); if( nRadX ) - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRX, GetValueString( ImplMap( nRadX ) ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRX, ::rtl::OUString::valueOf( bApplyMapping ? ImplMap( nRadX ) : nRadX ) ); if( nRadY ) - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRY, GetValueString( ImplMap( nRadY ) ) ); - - // add additional style if requested - if( pStyle ) - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, *pStyle ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRY, ::rtl::OUString::valueOf( bApplyMapping ? ImplMap( nRadY ) : nRadY ) ); { SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemRect, sal_True, sal_True ); @@ -689,18 +608,19 @@ void SVGActionWriter::ImplWriteRect( const Rectangle& rRect, long nRadX, long nR // ----------------------------------------------------------------------------- void SVGActionWriter::ImplWriteEllipse( const Point& rCenter, long nRadX, long nRadY, - const NMSP_RTL::OUString* pStyle ) + sal_Bool bApplyMapping ) { - const Point aCenter( ImplMap( rCenter ) ); - - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrCX, GetValueString( aCenter.X() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrCY, GetValueString( aCenter.Y() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRX, GetValueString( ImplMap( nRadX ) ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRY, GetValueString( ImplMap( nRadY ) ) ); + Point aCenter; + + if( bApplyMapping ) + ImplMap( rCenter, aCenter ); + else + aCenter = rCenter; - // add additional style if requested - if( pStyle ) - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, *pStyle ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrCX, ::rtl::OUString::valueOf( aCenter.X() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrCY, ::rtl::OUString::valueOf( aCenter.Y() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRX, ::rtl::OUString::valueOf( bApplyMapping ? ImplMap( nRadX ) : nRadX ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRY, ::rtl::OUString::valueOf( bApplyMapping ? ImplMap( nRadY ) : nRadY ) ); { SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemEllipse, sal_True, sal_True ); @@ -710,94 +630,114 @@ void SVGActionWriter::ImplWriteEllipse( const Point& rCenter, long nRadX, long n // ----------------------------------------------------------------------------- void SVGActionWriter::ImplWritePolyPolygon( const PolyPolygon& rPolyPoly, sal_Bool bLineOnly, - const NMSP_RTL::OUString* pStyle ) + sal_Bool bApplyMapping ) { - if( rPolyPoly.Count() ) - { - PolyPolygon aMappedPolyPoly; - FastString aStyle; - - for( sal_uInt16 i = 0, nCount = rPolyPoly.Count(); i < nCount; i++ ) - { - const Polygon& rPoly = rPolyPoly[ i ]; - const sal_uInt16 nSize = rPoly.GetSize(); - - // #i102224# congratulations, this throws away the curve flags - // and makes ANY curved polygon look bad. The Flags HAVE to be - // copied, too. It's NOT enough to copy the mapped points. Just - // copy the original polygon completely and REPLACE the points - - // old: Polygon aMappedPoly( nSize ); - // new: - Polygon aMappedPoly(rPoly); - - for( sal_uInt16 n = 0; n < nSize; n++ ) - aMappedPoly[ n ] = ImplMap( rPoly[ n ] ); + PolyPolygon aPolyPoly; + + if( bApplyMapping ) + ImplMap( rPolyPoly, aPolyPoly ); + else + aPolyPoly = rPolyPoly; - aMappedPolyPoly.Insert( aMappedPoly ); - } + if( mrExport.hasClip() ) + { + const ::basegfx::B2DPolyPolygon aB2DPolyPoly( ::basegfx::tools::correctOrientations( aPolyPoly.getB2DPolyPolygon() ) ); + + aPolyPoly = PolyPolygon( ::basegfx::tools::clipPolyPolygonOnPolyPolygon( + *mrExport.getCurClip(), aB2DPolyPoly, sal_False, sal_False ) ); + } + + // add path data attribute + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrD, GetPathString( aPolyPoly, bLineOnly ) ); + + { + // write polyline/polygon element + SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemPath, sal_True, sal_True ); + } +} - if( bLineOnly ) - { - aStyle += B2UCONST( "fill:none" ); - if( pStyle ) - aStyle += B2UCONST( ";" ); - } - if( pStyle ) - aStyle += *pStyle; +// ----------------------------------------------------------------------------- - // add style attribute - if( aStyle.GetLength() ) - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aStyle.GetString() ); +void SVGActionWriter::ImplWriteShape( const SVGShapeDescriptor& rShape, sal_Bool bApplyMapping ) +{ + PolyPolygon aPolyPoly; + + if( bApplyMapping ) + ImplMap( rShape.maShapePolyPoly, aPolyPoly ); + else + aPolyPoly = rShape.maShapePolyPoly; - // add path data attribute - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrD, GetPathString( aMappedPolyPoly, bLineOnly ) ); + const sal_Bool bLineOnly = ( rShape.maShapeFillColor == Color( COL_TRANSPARENT ) ) && ( !rShape.mapShapeGradient.get() ); + Rectangle aBoundRect( aPolyPoly.GetBoundRect() ); + + mpContext->AddPaintAttr( rShape.maShapeLineColor, rShape.maShapeFillColor, &aBoundRect, rShape.mapShapeGradient.get() ); + + if( rShape.maId.getLength() ) + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, rShape.maId ); + + if( rShape.mnStrokeWidth ) + { + sal_Int32 nStrokeWidth = ( bApplyMapping ? ImplMap( rShape.mnStrokeWidth ) : rShape.mnStrokeWidth ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStrokeWidth, ::rtl::OUString::valueOf( nStrokeWidth ) ); + } + + if( rShape.maDashArray.size() ) + { + const ::rtl::OUString aComma( B2UCONST( "," ) ); + ::rtl::OUString aDashArrayStr; + + for( unsigned int k = 0; k < rShape.maDashArray.size(); ++k ) { - // write polyline/polygon element - SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemPath, sal_True, sal_True ); + const sal_Int32 nDash = ( bApplyMapping ? + ImplMap( FRound( rShape.maDashArray[ k ] ) ) : + FRound( rShape.maDashArray[ k ] ) ); + + if( k ) + aDashArrayStr += aComma; + + aDashArrayStr += ::rtl::OUString::valueOf( nDash ); } + + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStrokeDashArray, aDashArrayStr ); } + + ImplWritePolyPolygon( aPolyPoly, bLineOnly, sal_False ); } // ----------------------------------------------------------------------------- -void SVGActionWriter::ImplWriteGradientEx( const PolyPolygon& rPolyPoly, const Gradient& rGradient, - const NMSP_RTL::OUString* pStyle, sal_uInt32 nWriteFlags ) +void SVGActionWriter::ImplWriteGradientEx( const PolyPolygon& rPolyPoly, const Gradient& rGradient, + sal_uInt32 nWriteFlags, sal_Bool bApplyMapping ) { - if( rPolyPoly.Count() ) + PolyPolygon aPolyPoly; + + if( bApplyMapping ) + ImplMap( rPolyPoly, aPolyPoly ); + else + aPolyPoly = rPolyPoly; + + if( rGradient.GetStyle() == GRADIENT_LINEAR || rGradient.GetStyle() == GRADIENT_AXIAL || + rGradient.GetStyle() == GRADIENT_RADIAL || rGradient.GetStyle() == GRADIENT_ELLIPTICAL ) { - SvXMLElementExport aElemG( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_True ); - FastString aClipId; - FastString aClipStyle; - - aClipId += B2UCONST( "clip" ); - aClipId += NMSP_RTL::OUString::valueOf( ImplGetNextClipId() ); - - { - SvXMLElementExport aElemDefs( mrExport, XML_NAMESPACE_NONE, aXMLElemDefs, sal_True, sal_True ); - - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, aClipId.GetString() ); - - { - SvXMLElementExport aElemClipPath( mrExport, XML_NAMESPACE_NONE, aXMLElemClipPath, sal_True, sal_True ); - ImplWritePolyPolygon( rPolyPoly, sal_False ); - } - } - - // create new context with clippath set - aClipStyle += B2UCONST( "clip-path:URL(#" ); - aClipStyle += aClipId.GetString(); - aClipStyle += B2UCONST( ")" ); - - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aClipStyle.GetString() ); - - { - GDIMetaFile aTmpMtf; - SvXMLElementExport aElemG2( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_True ); - - mpVDev->AddGradientActions( rPolyPoly.GetBoundRect(), rGradient, aTmpMtf ); - ImplWriteActions( aTmpMtf, pStyle, nWriteFlags ); - } + SVGShapeDescriptor aShapeDesc; + + aShapeDesc.maShapePolyPoly = aPolyPoly; + aShapeDesc.mapShapeGradient.reset( new Gradient( rGradient ) ); + + ImplWriteShape( aShapeDesc, sal_False ); + } + else + { + GDIMetaFile aTmpMtf; + + mrExport.pushClip( aPolyPoly.getB2DPolyPolygon() ); + mpVDev->AddGradientActions( rPolyPoly.GetBoundRect(), rGradient, aTmpMtf ); + ++mnInnerMtfCount; + + ImplWriteActions( aTmpMtf, nWriteFlags, NULL ); + + --mnInnerMtfCount; + mrExport.popClip(); } } @@ -805,164 +745,139 @@ void SVGActionWriter::ImplWriteGradientEx( const PolyPolygon& rPolyPoly, const G void SVGActionWriter::ImplWriteText( const Point& rPos, const String& rText, const sal_Int32* pDXArray, long nWidth, - const NMSP_RTL::OUString* pStyle ) + sal_Bool bApplyMapping ) { - long nLen = rText.Len(), i; - - if( nLen ) - { - Size aNormSize; - sal_Int32* pOwnArray; - sal_Int32* pDX; - - // get text sizes - if( pDXArray ) - { - pOwnArray = NULL; - aNormSize = Size( mpVDev->GetTextWidth( rText ), 0 ); - pDX = (sal_Int32*) pDXArray; - } - else - { - pOwnArray = new sal_Int32[ nLen ]; - aNormSize = Size( mpVDev->GetTextArray( rText, pOwnArray ), 0 ); - pDX = pOwnArray; - } + sal_Int32 nLen = rText.Len(), i; + Size aNormSize; + ::std::auto_ptr< sal_Int32 > apTmpArray; + ::std::auto_ptr< SvXMLElementExport > apTransform; + sal_Int32* pDX; + Point aPos; + Point aBaseLinePos( rPos ); + const FontMetric aMetric( mpVDev->GetFontMetric() ); + const Font& rFont = mpVDev->GetFont(); + + if( rFont.GetAlign() == ALIGN_TOP ) + aBaseLinePos.Y() += aMetric.GetAscent(); + else if( rFont.GetAlign() == ALIGN_BOTTOM ) + aBaseLinePos.Y() -= aMetric.GetDescent(); - if( nLen > 1 ) - { - aNormSize.Width() = pDX[ nLen - 2 ] + mpVDev->GetTextWidth( rText.GetChar( sal::static_int_cast<sal_uInt16>( nLen - 1 ) ) ); + if( bApplyMapping ) + ImplMap( rPos, aPos ); + else + aPos = rPos; - if( nWidth && aNormSize.Width() && ( nWidth != aNormSize.Width() ) ) - { - const double fFactor = (double) nWidth / aNormSize.Width(); + // get text sizes + if( pDXArray ) + { + aNormSize = Size( mpVDev->GetTextWidth( rText ), 0 ); + pDX = const_cast< sal_Int32* >( pDXArray ); + } + else + { + apTmpArray.reset( new sal_Int32[ nLen ] ); + aNormSize = Size( mpVDev->GetTextArray( rText, apTmpArray.get() ), 0 ); + pDX = apTmpArray.get(); + } - for( i = 0; i < ( nLen - 1 ); i++ ) - pDX[ i ] = FRound( pDX[ i ] * fFactor ); - } - } + // if text is rotated, set transform matrix at new g element + if( rFont.GetOrientation() ) + { + Point aRot( aPos ); + String aTransform; + + aTransform = String( ::rtl::OUString::createFromAscii( "translate" ) ); + aTransform += '('; + aTransform += String( ::rtl::OUString::valueOf( aRot.X() ) ); + aTransform += ','; + aTransform += String( ::rtl::OUString::valueOf( aRot.Y() ) ); + aTransform += ')'; + + aTransform += String( ::rtl::OUString::createFromAscii( " rotate" ) ); + aTransform += '('; + aTransform += String( ::rtl::OUString::valueOf( rFont.GetOrientation() * -0.1 ) ); + aTransform += ')'; + + aTransform += String( ::rtl::OUString::createFromAscii( " translate" ) ); + aTransform += '('; + aTransform += String( ::rtl::OUString::valueOf( -aRot.X() ) ); + aTransform += ','; + aTransform += String( ::rtl::OUString::valueOf( -aRot.Y() ) ); + aTransform += ')'; + + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTransform, aTransform ); + apTransform.reset( new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_True ) ); + } - FastString aStyle; - const Font& rFont = mpVDev->GetFont(); - const FontMetric aMetric( mpVDev->GetFontMetric() ); - Point aBaseLinePos( rPos ); - SvXMLElementExport* pTransform = NULL; + if( nLen > 1 ) + { + aNormSize.Width() = pDX[ nLen - 2 ] + mpVDev->GetTextWidth( rText.GetChar( nLen - 1 ) ); - // always adjust text position to match baseline alignment - switch( rFont.GetAlign() ) + if( nWidth && aNormSize.Width() && ( nWidth != aNormSize.Width() ) ) { - case( ALIGN_TOP ): - aBaseLinePos.Y() += aMetric.GetAscent(); - break; + const double fFactor = (double) nWidth / aNormSize.Width(); - case( ALIGN_BOTTOM ): - aBaseLinePos.Y() -= aMetric.GetDescent(); - break; - - default: - break; + for( i = 0; i < ( nLen - 1 ); i++ ) + pDX[ i ] = FRound( pDX[ i ] * fFactor ); } - - // get mapped text position - const Point aPt( ImplMap( aBaseLinePos ) ); - - // if text is italic, set transform at new g element - if( ( rFont.GetItalic() != ITALIC_NONE ) || rFont.GetOrientation() ) + else { - String aTransform; - - aTransform = NMSP_RTL::OUString::createFromAscii( "translate" ); - aTransform += '('; - aTransform += String( GetValueString( aPt.X() ) ); - aTransform += ','; - aTransform += String( GetValueString( aPt.Y() ) ); - aTransform += ')'; - - if( rFont.GetOrientation() ) - { - aTransform += String( NMSP_RTL::OUString::createFromAscii( " rotate" ) ); - aTransform += '('; - aTransform += String( NMSP_RTL::OUString::valueOf( rFont.GetOrientation() * -0.1 ) ); - aTransform += ')'; - } + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > xBI( ::vcl::unohelper::CreateBreakIterator() ); + const ::com::sun::star::lang::Locale& rLocale = Application::GetSettings().GetLocale(); + sal_Int32 nCurPos = 0, nLastPos = 0, nX = aPos.X(); - if( rFont.GetItalic() != ITALIC_NONE ) + // write single glyphs at absolute text positions + for( sal_Bool bCont = sal_True; bCont; ) { - aTransform += String( NMSP_RTL::OUString::createFromAscii( " skewX" ) ); - aTransform += '('; - aTransform += String( NMSP_RTL::OUString::valueOf( (sal_Int32) -10 ) ); - aTransform += ')'; - } - - aTransform += String( NMSP_RTL::OUString::createFromAscii( " translate" ) ); - aTransform += '('; - aTransform += String( GetValueString( -aPt.X() ) ); - aTransform += ','; - aTransform += String( GetValueString( -aPt.Y() ) ); - aTransform += ')'; - - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTransform, aTransform ); - pTransform = new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_True ); - } + sal_Int32 nCount = 1; - // add additional style if requested - if( pStyle && pStyle->getLength() ) - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, *pStyle ); + nLastPos = nCurPos; + nCurPos = xBI->nextCharacters( rText, nCurPos, rLocale, + ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, + nCount, nCount ); - // write text element - { -#ifdef _SVG_USE_TSPANS - SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_True ); - FastString aTSpanX; - const NMSP_RTL::OUString aSpace( ' ' ); - String aOutputText( rText ); - long nCurPos = 0; - bool bIgnoreWhitespace = true; - - for( long j = 0, nX = aPt.X(); j < nLen; ++j ) - { - const sal_Unicode cCode = rText.GetChar( sal::static_int_cast<sal_uInt16>( j ) ); + nCount = nCurPos - nLastPos; + bCont = ( nCurPos < rText.Len() ) && nCount; - // don't take more than one whitespace into account - if( !bIgnoreWhitespace || ( ' ' != cCode ) ) + if( nCount ) { - aOutputText.SetChar( sal::static_int_cast<sal_uInt16>( nCurPos++ ), cCode ); - ( aTSpanX += GetValueString( nX + ( ( j > 0 ) ? pDX[ j - 1 ] : 0 ) ) ) += aSpace; - bIgnoreWhitespace = ( ' ' == cCode ); + const ::rtl::OUString aGlyph( rText.Copy( nLastPos, nCount ) ); + + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( nX ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aPos.Y() ) ); + + { + SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False ); + mrExport.GetDocHandler()->characters( aGlyph ); + } + + if( bCont ) + nX = aPos.X() + pDXArray[ nCurPos - 1 ]; } } - - if( nCurPos < nLen ) - aOutputText.Erase( sal::static_int_cast<sal_uInt16>( nCurPos ) ); - - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, aTSpanX.GetString() ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, GetValueString( aPt.Y() ) ); - - { - SvXMLElementExport aElem2( mrExport, XML_NAMESPACE_NONE, aXMLElemTSpan, sal_True, sal_True ); - mrExport.GetDocHandler()->characters( aOutputText ); - } -#else - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, GetValueString( aPt.X() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, GetValueString( aPt.Y() ) ); - - { - SvXMLElementExport aElem2( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_True ); - mrExport.GetDocHandler()->characters( rText ); - } -#endif } + } + else + { + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( aPos.X() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aPos.Y() ) ); + + { + SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False ); + mrExport.GetDocHandler()->characters( rText ); + } + } -#ifndef _SVG_USE_NATIVE_TEXTDECORATION - // write strikeout if neccessary - if( rFont.GetStrikeout() || rFont.GetUnderline() ) + if( !mrExport.IsUseNativeTextDecoration() ) + { + if( rFont.GetStrikeout() != STRIKEOUT_NONE || rFont.GetUnderline() != UNDERLINE_NONE ) { - Polygon aPoly( 4 ); - const long nLineHeight = Max( (long) FRound( aMetric.GetLineHeight() * 0.05 ), (long) 1 ); + Polygon aPoly( 4 ); + const long nLineHeight = Max( (long) FRound( aMetric.GetLineHeight() * 0.05 ), (long) 1 ); if( rFont.GetStrikeout() ) { - const long nYLinePos = aBaseLinePos.Y() - FRound( aMetric.GetAscent() * 0.26 ); + const long nYLinePos = aBaseLinePos.Y() - FRound( aMetric.GetAscent() * 0.26 ); aPoly[ 0 ].X() = aBaseLinePos.X(); aPoly[ 0 ].Y() = nYLinePos - ( nLineHeight >> 1 ); aPoly[ 1 ].X() = aBaseLinePos.X() + aNormSize.Width() - 1; aPoly[ 1 ].Y() = aPoly[ 0 ].Y(); @@ -984,10 +899,6 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const String& rText, ImplWritePolyPolygon( aPoly, sal_False ); } } -#endif // _SVG_USE_NATIVE_TEXTDECORATION - - delete[] pOwnArray; - delete pTransform; } } @@ -996,7 +907,7 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const String& rText, void SVGActionWriter::ImplWriteBmp( const BitmapEx& rBmpEx, const Point& rPt, const Size& rSz, const Point& rSrcPt, const Size& rSrcSz, - const NMSP_RTL::OUString* /* pStyle */ ) + sal_Bool bApplyMapping ) { if( !!rBmpEx ) { @@ -1014,58 +925,114 @@ void SVGActionWriter::ImplWriteBmp( const BitmapEx& rBmpEx, if( GraphicConverter::Export( aOStm, rBmpEx, CVT_PNG ) == ERRCODE_NONE ) { - const Point aPt( ImplMap( rPt ) ); - const Size aSz( ImplMap( rSz ) ); - FastString aImageData( (sal_Char*) aOStm.GetData(), aOStm.Tell() ); + Point aPt; + Size aSz; + ::rtl::OUString aImageData( (sal_Char*) aOStm.GetData(), aOStm.Tell(), RTL_TEXTENCODING_ASCII_US ); REF( NMSP_SAX::XExtendedDocumentHandler ) xExtDocHandler( mrExport.GetDocHandler(), NMSP_UNO::UNO_QUERY ); + + if( bApplyMapping ) + { + ImplMap( rPt, aPt ); + ImplMap( rSz, aSz ); + } + else + { + aPt = rPt; + aSz = rSz; + } if( xExtDocHandler.is() ) { static const sal_uInt32 nPartLen = 64; - const NMSP_RTL::OUString aSpace( ' ' ); - const NMSP_RTL::OUString aLineFeed( NMSP_RTL::OUString::valueOf( (sal_Unicode) 0x0a ) ); - NMSP_RTL::OUString aString; - NMSP_RTL::OUString aImageString; + const ::rtl::OUString aSpace( ' ' ); + const ::rtl::OUString aLineFeed( ::rtl::OUString::valueOf( (sal_Unicode) 0x0a ) ); + ::rtl::OUString aString; aString = aLineFeed; aString += B2UCONST( "<" ); - aString += NMSP_RTL::OUString::createFromAscii( aXMLElemImage ); + aString += ::rtl::OUString::createFromAscii( aXMLElemImage ); aString += aSpace; - aString += NMSP_RTL::OUString::createFromAscii( aXMLAttrX ); + aString += ::rtl::OUString::createFromAscii( aXMLAttrX ); aString += B2UCONST( "=\"" ); - aString += GetValueString( aPt.X() ); + aString += ::rtl::OUString::valueOf( aPt.X() ); aString += B2UCONST( "\" " ); - aString += NMSP_RTL::OUString::createFromAscii( aXMLAttrY ); + aString += ::rtl::OUString::createFromAscii( aXMLAttrY ); aString += B2UCONST( "=\"" ); - aString += GetValueString( aPt.Y() ); + aString += ::rtl::OUString::valueOf( aPt.Y() ); aString += B2UCONST( "\" " ); - aString += NMSP_RTL::OUString::createFromAscii( aXMLAttrWidth ); + aString += ::rtl::OUString::createFromAscii( aXMLAttrWidth ); aString += B2UCONST( "=\"" ); - aString += GetValueString( aSz.Width() ); + aString += ::rtl::OUString::valueOf( aSz.Width() ); aString += B2UCONST( "\" " ); - aString += NMSP_RTL::OUString::createFromAscii( aXMLAttrHeight ); + aString += ::rtl::OUString::createFromAscii( aXMLAttrHeight ); aString += B2UCONST( "=\"" ); - aString += GetValueString( aSz.Height() ); + aString += ::rtl::OUString::valueOf( aSz.Height() ); aString += B2UCONST( "\" " ); - aString += NMSP_RTL::OUString::createFromAscii( aXMLAttrXLinkHRef ); + aString += ::rtl::OUString::createFromAscii( aXMLAttrXLinkHRef ); aString += B2UCONST( "=\"data:image/png;base64," ); + + xExtDocHandler->unknown( aString ); + + const sal_uInt32 nQuadCount = aImageData.getLength() / 3; + const sal_uInt32 nRest = aImageData.getLength() % 3; - if( aImageData.GetFirstPartString( nPartLen, aImageString ) ) + if( nQuadCount || nRest ) { - xExtDocHandler->unknown( aString += aImageString ); + sal_Int32 nBufLen = ( ( nQuadCount + ( nRest ? 1 : 0 ) ) << 2 ); + const sal_Unicode* pSrc = (const sal_Unicode*) aImageData; + sal_Unicode* pBuffer = new sal_Unicode[ nBufLen * sizeof( sal_Unicode ) ]; + sal_Unicode* pTmpDst = pBuffer; + + for( sal_uInt32 i = 0; i < nQuadCount; ++i ) + { + const sal_Int32 nA = *pSrc++; + const sal_Int32 nB = *pSrc++; + const sal_Int32 nC = *pSrc++; + + *pTmpDst++ = pBase64[ ( nA >> 2 ) & 0x3f ]; + *pTmpDst++ = pBase64[ ( ( nA << 4 ) & 0x30 ) + ( ( nB >> 4 ) & 0xf ) ]; + *pTmpDst++ = pBase64[ ( ( nB << 2 ) & 0x3c ) + ( ( nC >> 6 ) & 0x3 ) ]; + *pTmpDst++ = pBase64[ nC & 0x3f ]; + } + + if( nRest ) + { + const sal_Int32 nA = *pSrc++; + + *pTmpDst++ = pBase64[ ( nA >> 2 ) & 0x3f ]; + + if( 2 == nRest ) + { + const sal_Int32 nB = *pSrc; + + *pTmpDst++ = pBase64[ ( ( nA << 4 ) & 0x30 ) + ( ( nB >> 4 ) & 0xf ) ]; + *pTmpDst++ = pBase64[ ( nB << 2 ) & 0x3c ]; + } + else + { + *pTmpDst++ = pBase64[ ( nA << 4 ) & 0x30 ]; + *pTmpDst++ = '='; + } - while( aImageData.GetNextPartString( nPartLen, aImageString ) ) + *pTmpDst = '='; + } + + for( sal_Int32 nCurPos = 0; nCurPos < nBufLen; nCurPos += nPartLen ) { + const ::rtl::OUString aPart( pBuffer + nCurPos, ::std::min< sal_Int32 >( nPartLen, nBufLen - nCurPos ) ); + xExtDocHandler->unknown( aLineFeed ); - xExtDocHandler->unknown( aImageString ); + xExtDocHandler->unknown( aPart ); } + + delete[] pBuffer; } - + xExtDocHandler->unknown( B2UCONST( "\"/>" ) ); } } @@ -1076,14 +1043,15 @@ void SVGActionWriter::ImplWriteBmp( const BitmapEx& rBmpEx, // ----------------------------------------------------------------------------- void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, - const NMSP_RTL::OUString* pStyle, - sal_uInt32 nWriteFlags ) + sal_uInt32 nWriteFlags, + const ::rtl::OUString* pElementId ) { - ImplAcquireContext(); + if( mnInnerMtfCount ) + nWriteFlags |= SVGWRITER_NO_SHAPE_COMMENTS; - for( sal_uLong i = 0, nCount = rMtf.GetActionCount(); i < nCount; i++ ) + for( sal_uLong nCurAction = 0, nCount = rMtf.GetActionCount(); nCurAction < nCount; nCurAction++ ) { - const MetaAction* pAction = rMtf.GetAction( i ); + const MetaAction* pAction = rMtf.GetAction( nCurAction ); const sal_uInt16 nType = pAction->GetType(); switch( nType ) @@ -1094,8 +1062,8 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, { const MetaPixelAction* pA = (const MetaPixelAction*) pAction; - mpContext->SetPaintAttr( pA->GetColor(), pA->GetColor() ); - ImplWriteLine( pA->GetPoint(), pA->GetPoint(), &pA->GetColor(), pStyle ); + mpContext->AddPaintAttr( pA->GetColor(), pA->GetColor() ); + ImplWriteLine( pA->GetPoint(), pA->GetPoint(), &pA->GetColor() ); } } break; @@ -1106,8 +1074,8 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, { const MetaPointAction* pA = (const MetaPointAction*) pAction; - mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetLineColor() ); - ImplWriteLine( pA->GetPoint(), pA->GetPoint(), NULL, pStyle ); + mpContext->AddPaintAttr( mpVDev->GetLineColor(), mpVDev->GetLineColor() ); + ImplWriteLine( pA->GetPoint(), pA->GetPoint(), NULL ); } } break; @@ -1118,17 +1086,8 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, { const MetaLineAction* pA = (const MetaLineAction*) pAction; - 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 ); + mpContext->AddPaintAttr( mpVDev->GetLineColor(), mpVDev->GetLineColor() ); + ImplWriteLine( pA->GetStartPoint(), pA->GetEndPoint(), NULL ); } } break; @@ -1137,8 +1096,8 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, { if( nWriteFlags & SVGWRITER_WRITE_FILL ) { - mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); - ImplWriteRect( ( (const MetaRectAction*) pAction )->GetRect(), 0, 0, pStyle ); + mpContext->AddPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWriteRect( ( (const MetaRectAction*) pAction )->GetRect(), 0, 0 ); } } break; @@ -1149,8 +1108,8 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, { const MetaRoundRectAction* pA = (const MetaRoundRectAction*) pAction; - mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); - ImplWriteRect( pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound(), pStyle ); + mpContext->AddPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWriteRect( pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound() ); } } break; @@ -1162,8 +1121,8 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, const MetaEllipseAction* pA = (const MetaEllipseAction*) pAction; const Rectangle& rRect = pA->GetRect(); - mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); - ImplWriteEllipse( rRect.Center(), rRect.GetWidth() >> 1, rRect.GetHeight() >> 1, pStyle ); + mpContext->AddPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWriteEllipse( rRect.Center(), rRect.GetWidth() >> 1, rRect.GetHeight() >> 1 ); } } break; @@ -1207,8 +1166,8 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( aPoly.GetSize() ) { - mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); - ImplWritePolyPolygon( aPoly, sal_False, pStyle ); + mpContext->AddPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWritePolyPolygon( aPoly, sal_False ); } } } @@ -1223,51 +1182,8 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( rPoly.GetSize() ) { - 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 ); - } + mpContext->AddPaintAttr( mpVDev->GetLineColor(), Color( COL_TRANSPARENT ) ); + ImplWritePolyPolygon( rPoly, sal_True ); } } } @@ -1282,8 +1198,8 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( rPolyPoly.Count() ) { - mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); - ImplWritePolyPolygon( rPolyPoly, sal_False, pStyle ); + mpContext->AddPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); + ImplWritePolyPolygon( rPolyPoly, sal_False ); } } } @@ -1297,7 +1213,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, const Polygon aRectPoly( pA->GetRect() ); const PolyPolygon aRectPolyPoly( aRectPoly ); - ImplWriteGradientEx( aRectPolyPoly, pA->GetGradient(), pStyle, nWriteFlags ); + ImplWriteGradientEx( aRectPolyPoly, pA->GetGradient(), nWriteFlags ); } } break; @@ -1307,7 +1223,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( nWriteFlags & SVGWRITER_WRITE_FILL ) { const MetaGradientExAction* pA = (const MetaGradientExAction*) pAction; - ImplWriteGradientEx( pA->GetPolyPolygon(), pA->GetGradient(), pStyle, nWriteFlags ); + ImplWriteGradientEx( pA->GetPolyPolygon(), pA->GetGradient(), nWriteFlags ); } } break; @@ -1320,7 +1236,12 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, GDIMetaFile aTmpMtf; mpVDev->AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf ); - ImplWriteActions( aTmpMtf, pStyle, nWriteFlags ); + + ++mnInnerMtfCount; + + ImplWriteActions( aTmpMtf, nWriteFlags, NULL ); + + --mnInnerMtfCount; } } break; @@ -1334,15 +1255,13 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( rPolyPoly.Count() ) { - const Color aOldLineColor( mpVDev->GetLineColor() ), aOldFillColor( mpVDev->GetFillColor() ); - Color aNewLineColor( aOldLineColor ), aNewFillColor( aOldFillColor ); + Color aNewLineColor( mpVDev->GetLineColor() ), aNewFillColor( mpVDev->GetFillColor() ); aNewLineColor.SetTransparency( sal::static_int_cast<sal_uInt8>( FRound( pA->GetTransparence() * 2.55 ) ) ); aNewFillColor.SetTransparency( sal::static_int_cast<sal_uInt8>( FRound( pA->GetTransparence() * 2.55 ) ) ); - mpContext->SetPaintAttr( aNewLineColor, aNewFillColor ); - ImplWritePolyPolygon( rPolyPoly, sal_False, pStyle ); - mpContext->SetPaintAttr( aOldLineColor, aOldFillColor ); + mpContext->AddPaintAttr( aNewLineColor, aNewFillColor ); + ImplWritePolyPolygon( rPolyPoly, sal_False ); } } } @@ -1374,7 +1293,11 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, aTmpMtf.Move( nMoveX, nMoveY ); mpVDev->Push(); - ImplWriteActions( aTmpMtf, pStyle, nWriteFlags ); + ++mnInnerMtfCount; + + ImplWriteActions( aTmpMtf, nWriteFlags, NULL ); + + --mnInnerMtfCount; mpVDev->Pop(); } } @@ -1388,18 +1311,17 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, const GDIMetaFile aGDIMetaFile( pA->GetSubstitute() ); sal_Bool bFound = sal_False; - for( sal_uLong j = 0, nC = aGDIMetaFile.GetActionCount(); ( j < nC ) && !bFound; j++ ) + for( sal_uInt32 k = 0, nCount2 = aGDIMetaFile.GetActionCount(); ( k < nCount2 ) && !bFound; ++k ) { - const MetaAction* pSubstAct = aGDIMetaFile.GetAction( j ); + const MetaAction* pSubstAct = aGDIMetaFile.GetAction( k ); if( pSubstAct->GetType() == META_BMPSCALE_ACTION ) { bFound = sal_True; const MetaBmpScaleAction* pBmpScaleAction = (const MetaBmpScaleAction*) pSubstAct; - mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); ImplWriteBmp( pBmpScaleAction->GetBitmap(), pA->GetPoint(), pA->GetSize(), - Point(), pBmpScaleAction->GetBitmap().GetSizePixel(), pStyle ); + Point(), pBmpScaleAction->GetBitmap().GetSizePixel() ); } } } @@ -1417,21 +1339,159 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, const MetaGradientExAction* pGradAction = NULL; sal_Bool bDone = sal_False; - while( !bDone && ( ++i < nCount ) ) + while( !bDone && ( ++nCurAction < nCount ) ) { - pAction = rMtf.GetAction( i ); + pAction = rMtf.GetAction( nCurAction ); if( pAction->GetType() == META_GRADIENTEX_ACTION ) pGradAction = (const MetaGradientExAction*) pAction; else if( ( pAction->GetType() == META_COMMENT_ACTION ) && - ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_END" ) == COMPARE_EQUAL ) ) + ( ( (const MetaCommentAction*) pAction )->GetComment(). + CompareIgnoreCaseToAscii( "XGRAD_SEQ_END" ) == COMPARE_EQUAL ) ) { bDone = sal_True; } } if( pGradAction ) - ImplWriteGradientEx( pGradAction->GetPolyPolygon(), pGradAction->GetGradient(), pStyle, nWriteFlags ); + ImplWriteGradientEx( pGradAction->GetPolyPolygon(), pGradAction->GetGradient(), nWriteFlags ); + } + else if( ( pA->GetComment().CompareIgnoreCaseToAscii( "XPATHFILL_SEQ_BEGIN" ) == COMPARE_EQUAL ) && + ( nWriteFlags & SVGWRITER_WRITE_FILL ) && !( nWriteFlags & SVGWRITER_NO_SHAPE_COMMENTS ) && + pA->GetDataSize() ) + { + // write open shape in every case + if( mapCurShape.get() ) + { + ImplWriteShape( *mapCurShape ); + mapCurShape.reset(); + } + + SvMemoryStream aMemStm( (void*) pA->GetData(), pA->GetDataSize(), STREAM_READ ); + SvtGraphicFill aFill; + + aMemStm >> aFill; + + sal_Bool bGradient = SvtGraphicFill::fillGradient == aFill.getFillType() && + ( SvtGraphicFill::gradientLinear == aFill.getGradientType() || + SvtGraphicFill::gradientRadial == aFill.getGradientType() ); + sal_Bool bSkip = ( SvtGraphicFill::fillSolid == aFill.getFillType() || bGradient ); + + if( bSkip ) + { + PolyPolygon aShapePolyPoly; + + aFill.getPath( aShapePolyPoly ); + + if( aShapePolyPoly.Count() ) + { + mapCurShape.reset( new SVGShapeDescriptor ); + + if( pElementId ) + mapCurShape->maId = *pElementId; + + mapCurShape->maShapePolyPoly = aShapePolyPoly; + mapCurShape->maShapeFillColor = aFill.getFillColor(); + mapCurShape->maShapeFillColor.SetTransparency( (sal_uInt8) FRound( 255.0 * aFill.getTransparency() ) ); + + if( bGradient ) + { + // step through following actions until the first Gradient/GradientEx action is found + while( !mapCurShape->mapShapeGradient.get() && bSkip && ( ++nCurAction < nCount ) ) + { + pAction = rMtf.GetAction( nCurAction ); + + if( ( pAction->GetType() == META_COMMENT_ACTION ) && + ( ( (const MetaCommentAction*) pAction )->GetComment(). + CompareIgnoreCaseToAscii( "XPATHFILL_SEQ_END" ) == COMPARE_EQUAL ) ) + { + bSkip = sal_False; + } + else if( pAction->GetType() == META_GRADIENTEX_ACTION ) + { + mapCurShape->mapShapeGradient.reset( new Gradient( + static_cast< const MetaGradientExAction* >( pAction )->GetGradient() ) ); + } + else if( pAction->GetType() == META_GRADIENT_ACTION ) + { + mapCurShape->mapShapeGradient.reset( new Gradient( + static_cast< const MetaGradientAction* >( pAction )->GetGradient() ) ); + } + } + } + } + else + bSkip = sal_False; + } + + // skip rest of comment + while( bSkip && ( ++nCurAction < nCount ) ) + { + pAction = rMtf.GetAction( nCurAction ); + + if( ( pAction->GetType() == META_COMMENT_ACTION ) && + ( ( (const MetaCommentAction*) pAction )->GetComment(). + CompareIgnoreCaseToAscii( "XPATHFILL_SEQ_END" ) == COMPARE_EQUAL ) ) + { + bSkip = sal_False; + } + } + } + else if( ( pA->GetComment().CompareIgnoreCaseToAscii( "XPATHSTROKE_SEQ_BEGIN" ) == COMPARE_EQUAL ) && + ( nWriteFlags & SVGWRITER_WRITE_FILL ) && !( nWriteFlags & SVGWRITER_NO_SHAPE_COMMENTS ) && + pA->GetDataSize() ) + { + SvMemoryStream aMemStm( (void*) pA->GetData(), pA->GetDataSize(), STREAM_READ ); + SvtGraphicStroke aStroke; + PolyPolygon aStartArrow, aEndArrow; + + aMemStm >> aStroke; + aStroke.getStartArrow( aStartArrow ); + aStroke.getEndArrow( aEndArrow ); + + // Currently no support for strokes with start/end arrow(s) + sal_Bool bSkip = ( !aStartArrow.Count() && !aEndArrow.Count() ); + + if( bSkip ) + { + if( !mapCurShape.get() ) + { + Polygon aPoly; + + mapCurShape.reset( new SVGShapeDescriptor ); + + if( pElementId ) + mapCurShape->maId = *pElementId; + + aStroke.getPath( aPoly ); + mapCurShape->maShapePolyPoly = aPoly; + } + + mapCurShape->maShapeLineColor = mpVDev->GetLineColor(); + mapCurShape->maShapeLineColor.SetTransparency( (sal_uInt8) FRound( aStroke.getTransparency() * 255.0 ) ); + mapCurShape->mnStrokeWidth = FRound( aStroke.getStrokeWidth() ); + aStroke.getDashArray( mapCurShape->maDashArray ); + } + + // write open shape in every case + if( mapCurShape.get() ) + { + ImplWriteShape( *mapCurShape ); + mapCurShape.reset(); + } + + // skip rest of comment + while( bSkip && ( ++nCurAction < nCount ) ) + { + pAction = rMtf.GetAction( nCurAction ); + + if( ( pAction->GetType() == META_COMMENT_ACTION ) && + ( ( (const MetaCommentAction*) pAction )->GetComment(). + CompareIgnoreCaseToAscii( "XPATHSTROKE_SEQ_END" ) == COMPARE_EQUAL ) ) + { + bSkip = sal_False; + } + } } } break; @@ -1442,10 +1502,9 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, { const MetaBmpAction* pA = (const MetaBmpAction*) pAction; - mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); ImplWriteBmp( pA->GetBitmap(), pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmap().GetSizePixel() ), - Point(), pA->GetBitmap().GetSizePixel(), pStyle ); + Point(), pA->GetBitmap().GetSizePixel() ); } } break; @@ -1456,10 +1515,9 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, { const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*) pAction; - mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); ImplWriteBmp( pA->GetBitmap(), pA->GetPoint(), pA->GetSize(), - Point(), pA->GetBitmap().GetSizePixel(), pStyle ); + Point(), pA->GetBitmap().GetSizePixel() ); } } break; @@ -1470,10 +1528,9 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, { const MetaBmpScalePartAction* pA = (const MetaBmpScalePartAction*) pAction; - mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); ImplWriteBmp( pA->GetBitmap(), pA->GetDestPoint(), pA->GetDestSize(), - pA->GetSrcPoint(), pA->GetSrcSize(), pStyle ); + pA->GetSrcPoint(), pA->GetSrcSize() ); } } break; @@ -1484,10 +1541,9 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, { const MetaBmpExAction* pA = (const MetaBmpExAction*) pAction; - mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); ImplWriteBmp( pA->GetBitmapEx(), pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmapEx().GetSizePixel() ), - Point(), pA->GetBitmapEx().GetSizePixel(), pStyle ); + Point(), pA->GetBitmapEx().GetSizePixel() ); } } break; @@ -1498,10 +1554,9 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, { const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*) pAction; - mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); ImplWriteBmp( pA->GetBitmapEx(), pA->GetPoint(), pA->GetSize(), - Point(), pA->GetBitmapEx().GetSizePixel(), pStyle ); + Point(), pA->GetBitmapEx().GetSizePixel() ); } } break; @@ -1512,10 +1567,9 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, { const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*) pAction; - mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() ); ImplWriteBmp( pA->GetBitmapEx(), pA->GetDestPoint(), pA->GetDestSize(), - pA->GetSrcPoint(), pA->GetSrcSize(), pStyle ); + pA->GetSrcPoint(), pA->GetSrcSize() ); } } break; @@ -1525,12 +1579,20 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( nWriteFlags & SVGWRITER_WRITE_TEXT ) { const MetaTextAction* pA = (const MetaTextAction*) pAction; - Font aFont( mpVDev->GetFont() ); - - 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 ); + const String aText( pA->GetText(), pA->GetIndex(), pA->GetLen() ); + + if( aText.Len() ) + { + Font aFont( mpVDev->GetFont() ); + Size aSz; + + ImplMap( Size( 0, aFont.GetHeight() ), aSz ); + + aFont.SetHeight( aSz.Height() ); + mpContext->AddPaintAttr( COL_TRANSPARENT, mpVDev->GetTextColor() ); + mpContext->SetFontAttr( aFont ); + ImplWriteText( pA->GetPoint(), aText, NULL, 0 ); + } } } break; @@ -1539,13 +1601,20 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, { if( nWriteFlags & SVGWRITER_WRITE_TEXT ) { - const MetaTextRectAction* pA = (const MetaTextRectAction*) pAction; - Font aFont( mpVDev->GetFont() ); - - 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 ); + const MetaTextRectAction* pA = (const MetaTextRectAction*) pAction; + + if( pA->GetText().Len() ) + { + Font aFont( mpVDev->GetFont() ); + Size aSz; + + ImplMap( Size( 0, aFont.GetHeight() ), aSz ); + + aFont.SetHeight( aSz.Height() ); + mpContext->AddPaintAttr( COL_TRANSPARENT, mpVDev->GetTextColor() ); + mpContext->SetFontAttr( aFont ); + ImplWriteText( pA->GetRect().TopLeft(), pA->GetText(), NULL, 0 ); + } } } break; @@ -1555,13 +1624,20 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( nWriteFlags & SVGWRITER_WRITE_TEXT ) { const MetaTextArrayAction* pA = (const MetaTextArrayAction*) pAction; - const Point aPos( ImplMap( pA->GetPoint() ) ); - Font aFont( mpVDev->GetFont() ); - - 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 ); + const String aText( pA->GetText(), pA->GetIndex(), pA->GetLen() ); + + if( aText.Len() ) + { + Font aFont( mpVDev->GetFont() ); + Size aSz; + + ImplMap( Size( 0, aFont.GetHeight() ), aSz ); + + aFont.SetHeight( aSz.Height() ); + mpContext->AddPaintAttr( COL_TRANSPARENT, mpVDev->GetTextColor() ); + mpContext->SetFontAttr( aFont ); + ImplWriteText( pA->GetPoint(), aText, pA->GetDXArray(), 0 ); + } } } break; @@ -1571,12 +1647,38 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, if( nWriteFlags & SVGWRITER_WRITE_TEXT ) { const MetaStretchTextAction* pA = (const MetaStretchTextAction*) pAction; - Font aFont( mpVDev->GetFont() ); + const String aText( pA->GetText(), pA->GetIndex(), pA->GetLen() ); + + if( aText.Len() ) + { + Font aFont( mpVDev->GetFont() ); + Size aSz; + + ImplMap( Size( 0, aFont.GetHeight() ), aSz ); + + aFont.SetHeight( aSz.Height() ); + mpContext->AddPaintAttr( COL_TRANSPARENT, mpVDev->GetTextColor() ); + mpContext->SetFontAttr( aFont ); + ImplWriteText( pA->GetPoint(), aText, NULL, pA->GetWidth() ); + } + } + } + break; - 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 ); + case( META_RENDERGRAPHIC_ACTION ): + { + if( nWriteFlags & SVGWRITER_WRITE_FILL ) + { + // TODO KA: try to embed the native data in case the RenderGraphic + // contains valid SVG data (MimeType "image/svg+xml") + // => incorporate 'use' or 'image' element (KA 01/2011) + const MetaRenderGraphicAction* pA = (const MetaRenderGraphicAction*) pAction; + const ::vcl::RenderGraphicRasterizer aRasterizer( pA->GetRenderGraphic() ); + const Point aPointPixel; + const Size aSizePixel( mpVDev->LogicToPixel( pA->GetSize() ) ); + const BitmapEx aBmpEx( aRasterizer.Rasterize( aSizePixel ) ); + + ImplWriteBmp( aBmpEx, pA->GetPoint(), pA->GetSize(), aPointPixel, aBmpEx.GetSizePixel() ); } } break; @@ -1624,8 +1726,6 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, break; } } - - ImplReleaseContext(); } // ----------------------------------------------------------------------------- @@ -1633,13 +1733,14 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, void SVGActionWriter::WriteMetaFile( const Point& rPos100thmm, const Size& rSize100thmm, const GDIMetaFile& rMtf, - sal_uInt32 nWriteFlags ) + sal_uInt32 nWriteFlags, + const ::rtl::OUString* pElementId ) { MapMode aMapMode( rMtf.GetPrefMapMode() ); Size aPrefSize( rMtf.GetPrefSize() ); Fraction aFractionX( aMapMode.GetScaleX() ); Fraction aFractionY( aMapMode.GetScaleY() ); - + mpVDev->Push(); Size aSize( OutputDevice::LogicToLogic( rSize100thmm, MAP_100TH_MM, aMapMode ) ); @@ -1650,8 +1751,19 @@ void SVGActionWriter::WriteMetaFile( const Point& rPos100thmm, aMapMode.SetOrigin( aOffset += aMapMode.GetOrigin() ); mpVDev->SetMapMode( aMapMode ); + ImplAcquireContext(); - ImplWriteActions( rMtf, NULL, nWriteFlags ); + mapCurShape.reset(); + ImplWriteActions( rMtf, nWriteFlags, pElementId ); + + // draw open shape that doesn't have a border + if( mapCurShape.get() ) + { + ImplWriteShape( *mapCurShape ); + mapCurShape.reset(); + } + + ImplReleaseContext(); mpVDev->Pop(); } diff --git a/filter/source/svg/svgwriter.hxx b/filter/source/svg/svgwriter.hxx index 4b76376c7..32c66488d 100644 --- a/filter/source/svg/svgwriter.hxx +++ b/filter/source/svg/svgwriter.hxx @@ -2,10 +2,13 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * + * $RCSfile: svgwriter.hxx,v $ + * $Revision: 1.5.86.14 $ + * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -53,6 +56,8 @@ #ifndef _CVTGRF_HXX #include <vcl/cvtgrf.hxx> #endif +#include <vcl/graphictools.hxx> +#include <vcl/rendergraphicrasterizer.hxx> #include <xmloff/xmlexp.hxx> #include <xmloff/nmspmap.hxx> @@ -66,18 +71,18 @@ #include <com/sun/star/io/XOutputStream.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> +#include <com/sun/star/i18n/CharacterIteratorMode.hpp> +#include <com/sun/star/i18n/XBreakIterator.hpp> // ----------------------------------------------------------------------------- -#define _SVG_USE_NATIVE_TEXTDECORATION -#define _SVG_USE_TSPANS 1 -#undef _SVG_WRITE_EXTENTS -#define _SVG_EMBED_FONTS 1 +#define _SVG_WRITE_EXTENTS 1 +#undef _SVG_WRITE_TEXT_DESC +#undef _SVG_USE_CONFIG // ----------------------------------------------------------------------------- #define NMSP_CPPU cppu -#define NMSP_RTL rtl #define NMSP_UNO com::sun::star::uno #define NMSP_LANG com::sun::star::lang #define NMSP_SAX com::sun::star::xml::sax @@ -87,50 +92,21 @@ #define REF( _def_Obj ) NMSP_UNO::Reference< _def_Obj > #define SEQ( _def_Obj ) NMSP_UNO::Sequence< _def_Obj > -#define B2UCONST( _def_pChar ) (NMSP_RTL::OUString(RTL_CONSTASCII_USTRINGPARAM(_def_pChar ))) +#define B2UCONST( _def_pChar ) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(_def_pChar ))) #define SVG_DTD_STRING B2UCONST( "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">" ) +#define SVG_TINY_DTD_STRING B2UCONST( "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG Tiny 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd\">" ) -#define SVGWRITER_WRITE_NONE 0x00000000 -#define SVGWRITER_WRITE_FILL 0x00000001 -#define SVGWRITER_WRITE_TEXT 0x00000002 -#define SVGWRITER_WRITE_ALL 0xFFFFFFFF - -// -------------- -// - FastString - -// -------------- - -class FastString -{ -private: - - sal_uInt32 mnBufLen; - sal_uInt32 mnCurLen; - sal_uInt32 mnBufInc; - sal_Unicode* mpBuffer; - sal_uInt32 mnPartPos; - rtl::OUString maString; - -public: - - FastString( sal_uInt32 nInitLen = 2048, sal_uInt32 nIncrement = 2048 ); - FastString( sal_Char* pBufferForBase64Encoding, sal_uInt32 nBufLen ); - ~FastString(); - - FastString& operator+=( const ::rtl::OUString& rStr ); - - const ::rtl::OUString& GetString() const; - sal_Bool GetFirstPartString( const sal_uInt32 nPartLen, ::rtl::OUString& rPartString ); - sal_Bool GetNextPartString( const sal_uInt32 nPartLen, ::rtl::OUString& rPartString ); - - sal_uInt32 GetLength() const { return mnCurLen; } - void Clear() { mnCurLen = 0, maString = ::rtl::OUString(); } -}; +#define SVGWRITER_WRITE_NONE 0x00000000 +#define SVGWRITER_WRITE_FILL 0x00000001 +#define SVGWRITER_WRITE_TEXT 0x00000002 +#define SVGWRITER_NO_SHAPE_COMMENTS 0x01000000 // ---------------------- // - SVGAttributeWriter - // ---------------------- class SVGActionWriter; +class SVGExport; class SVGFontExport; class SVGAttributeWriter @@ -140,23 +116,51 @@ private: Font maCurFont; Color maCurLineColor; Color maCurFillColor; - SvXMLExport& mrExport; + SVGExport& mrExport; SVGFontExport& mrFontExport; SvXMLElementExport* mpElemFont; SvXMLElementExport* mpElemPaint; - + SVGAttributeWriter(); - + + void ImplGetColorStr( const Color& rColor, ::rtl::OUString& rColorStr ); + double ImplRound( double fVal, sal_Int32 nDecs = 3 ); + public: - SVGAttributeWriter( SvXMLExport& rExport, SVGFontExport& rFontExport ); + SVGAttributeWriter( SVGExport& rExport, SVGFontExport& rFontExport ); virtual ~SVGAttributeWriter(); - ::rtl::OUString GetFontStyle( const Font& rFont ); - ::rtl::OUString GetPaintStyle( const Color& rLineColor, const Color& rFillColor, const LineInfo* pLineInfo ); + void AddColorAttr( const char* pColorAttrName, const char* pColorOpacityAttrName, const Color& rColor ); + void AddGradientDef( const Rectangle& rObjRect,const Gradient& rGradient, ::rtl::OUString& rGradientId ); + void AddPaintAttr( const Color& rLineColor, const Color& rFillColor, + const Rectangle* pObjBoundRect = NULL, const Gradient* pFillGradient = NULL ); + + void SetFontAttr( const Font& rFont ); +}; + +// ---------------------- +// - SVGShapeDescriptor - +// ---------------------- - void SetFontAttr( const Font& rFont ); - void SetPaintAttr( const Color& rLineColor, const Color& rFillColor, const LineInfo* pLineInfo = 0); +struct SVGShapeDescriptor +{ + PolyPolygon maShapePolyPoly; + Color maShapeFillColor; + Color maShapeLineColor; + sal_Int32 mnStrokeWidth; + SvtGraphicStroke::DashArray maDashArray; + ::std::auto_ptr< Gradient > mapShapeGradient; + ::rtl::OUString maId; + + // ------------------------------------------------------------------------- + + SVGShapeDescriptor() : + maShapeFillColor( Color( COL_TRANSPARENT ) ), + maShapeLineColor( Color( COL_TRANSPARENT ) ), + mnStrokeWidth( 0 ) + { + } }; // ------------------- @@ -171,55 +175,64 @@ class SVGActionWriter { private: - SvXMLExport& mrExport; - SVGFontExport& mrFontExport; - SVGAttributeWriter* mpContext; - sal_Bool mbClipAttrChanged; - sal_Int32 mnCurClipId; - Stack maContextStack; - VirtualDevice* mpVDev; - MapMode maTargetMapMode; - sal_Bool mbDestroyVDev; - sal_Bool mbPaintAttrChanged; - sal_Bool mbFontAttrChanged; + Stack maContextStack; + ::std::auto_ptr< SVGShapeDescriptor > mapCurShape; + SVGExport& mrExport; + SVGFontExport& mrFontExport; + SVGAttributeWriter* mpContext; + VirtualDevice* mpVDev; + MapMode maTargetMapMode; + sal_uInt32 mnInnerMtfCount; + sal_Bool mbDestroyVDev; + sal_Bool mbPaintAttrChanged; + sal_Bool mbFontAttrChanged; + sal_Bool mbClipAttrChanged; SVGAttributeWriter* ImplAcquireContext() { maContextStack.Push( mpContext = new SVGAttributeWriter( mrExport, mrFontExport ) ); return mpContext; } void ImplReleaseContext() { delete (SVGAttributeWriter*) maContextStack.Pop(); mpContext = (SVGAttributeWriter*) maContextStack.Top(); } 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 ); - void ImplWriteRect( const Rectangle& rRect, long nRadX = 0, long nRadY = 0, const ::rtl::OUString* pStyle = NULL ); - void ImplWriteEllipse( const Point& rCenter, long nRadX, long nRadY, const ::rtl::OUString* pStyle = NULL ); - 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 ImplWriteBmp( const BitmapEx& rBmpEx, const Point& rPt, const Size& rSz, const Point& rSrcPt, const Size& rSrcSz, const ::rtl::OUString* pStyle = NULL ); + Point& ImplMap( const Point& rPt, Point& rDstPt ) const; + Size& ImplMap( const Size& rSz, Size& rDstSz ) const; + Rectangle& ImplMap( const Rectangle& rRect, Rectangle& rDstRect ) const; + Polygon& ImplMap( const Polygon& rPoly, Polygon& rDstPoly ) const; + PolyPolygon& ImplMap( const PolyPolygon& rPolyPoly, PolyPolygon& rDstPolyPoly ) const; + + void ImplWriteLine( const Point& rPt1, const Point& rPt2, const Color* pLineColor = NULL, + sal_Bool bApplyMapping = sal_True ); + void ImplWriteRect( const Rectangle& rRect, long nRadX = 0, long nRadY = 0, + sal_Bool bApplyMapping = sal_True ); + void ImplWriteEllipse( const Point& rCenter, long nRadX, long nRadY, + sal_Bool bApplyMapping = sal_True ); + void ImplWritePolyPolygon( const PolyPolygon& rPolyPoly, sal_Bool bLineOnly, + sal_Bool bApplyMapping = sal_True ); + void ImplWriteShape( const SVGShapeDescriptor& rShape, sal_Bool bApplyMapping = sal_True ); + void ImplWriteGradientEx( const PolyPolygon& rPolyPoly, const Gradient& rGradient, sal_uInt32 nWriteFlags, + sal_Bool bApplyMapping = sal_True ); + void ImplWriteText( const Point& rPos, const String& rText, const sal_Int32* pDXArray, long nWidth, + sal_Bool bApplyMapping = sal_True ); + void ImplWriteBmp( const BitmapEx& rBmpEx, const Point& rPt, const Size& rSz, const Point& rSrcPt, const Size& rSrcSz, + sal_Bool bApplyMapping = sal_True ); void ImplCheckFontAttributes(); void ImplCheckPaintAttributes(); - void ImplWriteActions( const GDIMetaFile& rMtf, const ::rtl::OUString* pStyle, sal_uInt32 nWriteFlags ); - sal_Int32 ImplGetNextClipId() { return mnCurClipId++; } + void ImplWriteActions( const GDIMetaFile& rMtf, sal_uInt32 nWriteFlags, const ::rtl::OUString* pElementId ); public: - static ::rtl::OUString GetValueString( sal_Int32 nVal ); static ::rtl::OUString GetPathString( const PolyPolygon& rPolyPoly, sal_Bool bLine ); public: - SVGActionWriter( SvXMLExport& rExport, SVGFontExport& rFontExport ); + SVGActionWriter( SVGExport& rExport, SVGFontExport& rFontExport ); virtual ~SVGActionWriter(); void WriteMetaFile( const Point& rPos100thmm, const Size& rSize100thmm, const GDIMetaFile& rMtf, - sal_uInt32 nWriteFlags = SVGWRITER_WRITE_ALL ); + sal_uInt32 nWriteFlags, + const ::rtl::OUString* pElementId = NULL ); }; #endif |