diff options
Diffstat (limited to 'filter/source')
23 files changed, 2328 insertions, 1045 deletions
diff --git a/filter/source/config/fragments/fcfg_drawgraphics.mk b/filter/source/config/fragments/fcfg_drawgraphics.mk index 7038e27e8ae4..948423a3e3ef 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 ae978f0ca06c..d1f628a6be4f 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 000000000000..69ad0d0cbca2 --- /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 000000000000..5e21c033947f --- /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 37643df4c7ec..2ed05926671d 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 e406bdd22df4..c259f4db6364 100644 --- a/filter/source/flash/swfwriter1.cxx +++ b/filter/source/flash/swfwriter1.cxx @@ -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 @@ -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; diff --git a/filter/source/graphicfilter/eos2met/eos2met.cxx b/filter/source/graphicfilter/eos2met/eos2met.cxx index e2afa820e167..7c42aea31518 100644 --- a/filter/source/graphicfilter/eos2met/eos2met.cxx +++ b/filter/source/graphicfilter/eos2met/eos2met.cxx @@ -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; } } @@ -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 dac202b6ee1c..960690a0f9c7 100644 --- a/filter/source/graphicfilter/epict/epict.cxx +++ b/filter/source/graphicfilter/epict/epict.cxx @@ -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; } @@ -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; @@ -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++; diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx index e9a00bc4df0c..5f93d15ca72c 100644 --- a/filter/source/graphicfilter/eps/eps.cxx +++ b/filter/source/graphicfilter/eps/eps.cxx @@ -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> @@ -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; @@ -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; @@ -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; } } } diff --git a/filter/source/pdf/impdialog.src b/filter/source/pdf/impdialog.src index 35cfa93dd854..e65e4dd5da57 100644 --- a/filter/source/pdf/impdialog.src +++ b/filter/source/pdf/impdialog.src @@ -615,7 +615,7 @@ TabPage RID_PDF_TAB_SECURITY String STR_USER_PWD_PDFA { - Text [en-US] = "PDF doument will not be encrypted due to PDF/A export."; + Text [en-US] = "PDF document will not be encrypted due to PDF/A export."; }; FixedText FT_OWNER_PWD @@ -646,7 +646,7 @@ TabPage RID_PDF_TAB_SECURITY String STR_OWNER_PWD_PDFA { - Text [en-US] = "PDF doument will not be restricted due to PDF/A export."; + Text [en-US] = "PDF document will not be restricted due to PDF/A export."; }; ////////////////////////////// diff --git a/filter/source/svg/impsvgdialog.cxx b/filter/source/svg/impsvgdialog.cxx new file mode 100644 index 000000000000..7a4f083160a3 --- /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 000000000000..f7849c994b9e --- /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 44bac23381f5..b742b75e1d02 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 000000000000..a3054537b7b4 --- /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 000000000000..e0eff6494fb7 --- /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 b1063b0d8682..1d8c437b2e25 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 ) ); @@ -129,6 +240,9 @@ sal_Bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) 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,8 +258,64 @@ 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() ) { @@ -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; @@ -292,8 +461,15 @@ sal_Bool SVGFilter::implExportDocument( const Reference< XDrawPages >& rxMasterP 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,10 +501,11 @@ 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 ); while( ( nCurPage <= nLastPage ) && ( -1 == nVisible ) ) @@ -372,9 +552,10 @@ 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; - { - SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "desc", sal_True, sal_True ); - Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY ); + aId += ::rtl::OUString::valueOf( ++mnDrawingGroupId ); - xExtDocHandler->unknown( B2UCONST( "Group" ) ); - } + if( aObjName.getLength() ) + ( ( aId += B2UCONST( "(" ) ) += aObjName ) += B2UCONST( ")" ); + + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aId ); - 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 ); + OUString aId( B2UCONST( "Drawing_" ) ); + OUString aObjName( implGetValidIDFromInterface( rxShape, sal_True ) ), aObjDesc; - { - SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "desc", sal_True, sal_True ); - Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY ); + aId += ::rtl::OUString::valueOf( ++mnDrawingId ); - xExtDocHandler->unknown( implGetDescriptionFromShape( rxShape ) ); - } + if( aObjName.getLength() ) + ( ( aId += B2UCONST( "(" ) ) += aObjName ) += B2UCONST( ")" ); - if( rMtf.GetActionCount() ) { 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 ); + if( implHasText( rMtf ) ) + { + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aId ); - // write text separately - SvXMLElementExport aTextExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); - mpSVGWriter->WriteMetaFile( aTopLeft, aSize, rMtf, SVGWRITER_WRITE_TEXT ); + { + 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 ); + } } } } @@ -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 118474bbe2b0..3888a4c4b473 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 bc25fcf35011..c515504bbf4f 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: + 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 ); - SVGExport(); + 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; } +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: +private: + + const Sequence< PropertyValue >& mrFilterData; + B2DPolyPolygonList maClipList; - SVGExport( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, - const Reference< XDocumentHandler >& rxHandler ); - virtual ~SVGExport(); + 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* ); diff --git a/filter/source/svg/svgfontexport.cxx b/filter/source/svg/svgfontexport.cxx index cad55e4e670c..99d8692fa3df 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(); + 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; - for( sal_uInt32 j = 0, nLen = aText.getLength(); j < nLen; ++j ) - maGlyphs[ rFontName ].insert( pStr[ j ] ); + 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 ) ); + GlyphSet& rGlyphSet = implGetGlyphSet( rFont ); - aVDev.SetMapMode( MAP_100TH_MM ); - aFont.SetAlign( ALIGN_BASELINE ); - aVDev.SetFont( aFont ); + if( !rGlyphSet.empty() ) + { + GlyphSet::const_iterator aIter( rGlyphSet.begin() ); + const ::rtl::OUString aEmbeddedFontStr( B2UCONST( "EmbeddedFont_" ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", aCurIdStr += SVGActionWriter::GetValueString( ++mnCurFontId ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", aUnitsPerEM ); + { + 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 ); - { - SvXMLElementExport aExp2( mrExport, XML_NAMESPACE_NONE, "font", sal_True, sal_True ); - Point aPos; - Size aSize( nFontEM, nFontEM ); - PolyPolygon aMissingGlyphPolyPoly( Rectangle( aPos, aSize ) ); + aFont.SetSize( Size( 0, nFontEM ) ); + aFont.SetAlign( ALIGN_BASELINE ); - aMissingGlyphPolyPoly.Move( 0, -nFontEM ); - aMissingGlyphPolyPoly.Scale( 1.0, -1.0 ); + aVDev.SetMapMode( MAP_100TH_MM ); + aVDev.SetFont( aFont ); - 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() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", aCurIdStr += ::rtl::OUString::valueOf( ++mnCurFontId ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", aUnitsPerEM ); - { - SvXMLElementExport aExp3( mrExport, XML_NAMESPACE_NONE, "font-face", 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() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", SVGActionWriter::GetValueString( aSize.Width() ) ); + { + SvXMLElementExport aExp3( mrExport, XML_NAMESPACE_NONE, "font-face", sal_True, sal_True ); + } - { - SvXMLElementExport aExp3( mrExport, XML_NAMESPACE_NONE, "missing-glyph", sal_True, sal_True ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, "horiz-adv-x", ::rtl::OUString::valueOf( aSize.Width() ) ); - 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 ) ); + { + const Point aPos; + const PolyPolygon aMissingGlyphPolyPoly( Rectangle( aPos, aSize ) ); - { - SvXMLElementExport aExp4( mrExport, XML_NAMESPACE_NONE, "path", sal_True, sal_True ); - } - } + mrExport.AddAttribute( XML_NAMESPACE_NONE, "d", SVGActionWriter::GetPathString( aMissingGlyphPolyPoly, sal_False ) ); - while( aIter != rGlyphs.end() ) - { - implEmbedGlyph( aVDev, ::rtl::OUString( *aIter ) ); - ++aIter; + { + SvXMLElementExport aExp4( mrExport, XML_NAMESPACE_NONE, "missing-glyph", sal_True, sal_True ); + } + } + + while( aIter != rGlyphSet.end() ) + { + implEmbedGlyph( aVDev, *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() ) ); - { - SvXMLElementExport aExp( mrExport, XML_NAMESPACE_NONE, "glyph", sal_True, sal_True ); - const ::rtl::OUString aPathString( SVGActionWriter::GetPathString( aPolyPoly, sal_False ) ); + const ::rtl::OUString aPathString( SVGActionWriter::GetPathString( aPolyPoly, sal_False ) ); - if( aPathString.getLength() ) - { - mrExport.AddAttribute( XML_NAMESPACE_NONE, "d", aPathString ); + if( aPathString.getLength() ) + { + mrExport.AddAttribute( XML_NAMESPACE_NONE, "d", aPathString ); + } - { - SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, B2UCONST( "path" ), sal_True, sal_True ); - } - } + { + SvXMLElementExport aExp( mrExport, XML_NAMESPACE_NONE, "glyph", sal_True, sal_True ); } } } @@ -234,12 +302,35 @@ void SVGFontExport::EmbedFonts() { implCollectGlyphs(); - GlyphMap::const_iterator aIter( maGlyphs.begin() ); + GlyphTree::const_iterator aGlyphTreeIter( maGlyphTree.begin() ); - while( aIter != maGlyphs.end() ) + 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 9147efb27a55..9929dbc162c4 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 f20bfb6a526d..08dcd4bda21a 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 4ba55ca277ae..9e6ac04188e6 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 +void SVGAttributeWriter::AddColorAttr( const char* pColorAttrName, + const char* pColorOpacityAttrName, + const Color& rColor ) { - if( !maString.getLength() && mnCurLen ) - ( (FastString*) this )->maString = NMSP_RTL::OUString( mpBuffer, mnCurLen ); - - return maString; -} - -// ----------------------------------------------------------------------------- + ::rtl::OUString aColor, aColorOpacity; -sal_Bool FastString::GetFirstPartString( const sal_uInt32 nPartLen, NMSP_RTL::OUString& rPartString ) -{ - const sal_uInt32 nLength = Min( mnCurLen, nPartLen ); + ImplGetColorStr( rColor, aColor ); - mnPartPos = 0; + if( rColor.GetTransparency() > 0 && rColor.GetTransparency() < 255 ) + aColorOpacity = ::rtl::OUString::valueOf( ImplRound( ( 255.0 - rColor.GetTransparency() ) / 255.0 ) ); - if( nLength ) - { - rPartString = NMSP_RTL::OUString( mpBuffer, nLength ); - mnPartPos = nLength; - } + mrExport.AddAttribute( XML_NAMESPACE_NONE, pColorAttrName, aColor ); - return( rPartString.getLength() > 0 ); + 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; - } - else - rPartString = NMSP_RTL::OUString(); + ::rtl::OUString aGradientId; - return( rPartString.getLength() > 0 ); -} + AddGradientDef( *pObjBoundRect, *pFillGradient, aGradientId ); -// ---------------------- -// - SVGAttributeWriter - -// ---------------------- + if( aGradientId.getLength() ) + { + ::rtl::OUString aGradientURL( B2UCONST( "url(#" ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFill, ( aGradientURL += aGradientId ) += B2UCONST( ")" ) ); + } + } + else + AddColorAttr( aXMLAttrFill, aXMLAttrFillOpacity, rFillColor ); -SVGAttributeWriter::SVGAttributeWriter( SvXMLExport& rExport, SVGFontExport& rFontExport ) : - mrExport( rExport ), - mrFontExport( rFontExport ), - mpElemFont( NULL ), - mpElemPaint( NULL ) -{ + // Stroke + AddColorAttr( aXMLAttrStroke, aXMLAttrStrokeOpacity, rLineColor ); } // ----------------------------------------------------------------------------- -SVGAttributeWriter::~SVGAttributeWriter() +void SVGAttributeWriter::AddGradientDef( const Rectangle& rObjRect, const Gradient& rGradient, ::rtl::OUString& rGradientId ) { - delete mpElemPaint; - delete mpElemFont; -} + if( rObjRect.GetWidth() && rObjRect.GetHeight() && + ( rGradient.GetStyle() == GRADIENT_LINEAR || rGradient.GetStyle() == GRADIENT_AXIAL || + rGradient.GetStyle() == GRADIENT_RADIAL || rGradient.GetStyle() == GRADIENT_ELLIPTICAL ) ) + { + 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() ); -NMSP_RTL::OUString SVGAttributeWriter::GetFontStyle( const Font& rFont ) -{ - FastString aStyle; + // 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 ); - // font family - aStyle += B2UCONST( "font-family:" ); - aStyle += mrFontExport.GetMappedFontName( rFont.GetName() ); + 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 ); - // font size - aStyle += B2UCONST( ";" ); - aStyle += B2UCONST( "font-size:" ); - aStyle += SVGActionWriter::GetValueString( rFont.GetHeight() ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, + ( rGradientId = B2UCONST( "Gradient_" ) ) += ::rtl::OUString::valueOf( nCurGradientId++ ) ); - // font style -/* - if( rFont.GetItalic() != ITALIC_NONE ) - { - aStyle += B2UCONST( ";" ); - aStyle += B2UCONST( "font-style:" ); + { + ::std::auto_ptr< SvXMLElementExport > apGradient; + ::rtl::OUString aColorStr; - if( rFont.GetItalic() == ITALIC_OBLIQUE ) - aStyle += B2UCONST( "oblique" ); - else - aStyle += B2UCONST( "italic" ); - } -*/ + if( rGradient.GetStyle() == GRADIENT_LINEAR || rGradient.GetStyle() == GRADIENT_AXIAL ) + { + Polygon aLinePoly( 2 ); - // font weight - sal_Int32 nFontWeight; + aLinePoly[ 0 ] = Point( aObjRectCenter.X(), aRect.Top() ); + aLinePoly[ 1 ] = Point( aObjRectCenter.X(), aRect.Bottom() ); - 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 ); + aLinePoly.Rotate( aObjRectCenter, nAngle ); - // !!! - // font-variant - // font-stretch - // font-size-adjust + 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() ) ); -#ifdef _SVG_USE_NATIVE_TEXTDECORATION + apGradient.reset( new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemLinearGradient, sal_True, sal_True ) ); - if( rFont.GetUnderline() != UNDERLINE_NONE || rFont.GetStrikeout() != STRIKEOUT_NONE ) - { - aStyle += B2UCONST( ";" ); - aStyle += B2UCONST( "text-decoration:" ); + // write stop values + double fBorder = static_cast< double >( rGradient.GetBorder() ) * + ( ( rGradient.GetStyle() == GRADIENT_AXIAL ) ? 0.005 : 0.01 ); - if( rFont.GetUnderline() != UNDERLINE_NONE ) - aStyle += B2UCONST( " underline" ); + 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( rFont.GetStrikeout() != STRIKEOUT_NONE ) - aStyle += B2UCONST( " line-through" ); - } + { + SvXMLElementExport aDesc2( mrExport, XML_NAMESPACE_NONE, aXMLElemStop, sal_True, sal_True ); + } -#endif // _SVG_USE_NATIVE_TEXTDECORATION + 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 ); - return aStyle.GetString(); -} + { + SvXMLElementExport aDesc3( mrExport, XML_NAMESPACE_NONE, aXMLElemStop, sal_True, sal_True ); + } + } -// ----------------------------------------------------------------------------- + if( rGradient.GetStyle() != GRADIENT_AXIAL ) + fBorder = 0.0; -NMSP_RTL::OUString SVGAttributeWriter::GetPaintStyle( const Color& rLineColor, const Color& rFillColor, const LineInfo* pLineInfo ) -{ - FastString aStyle; + ImplGetColorStr( aEndColor, aColorStr ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrOffset, ::rtl::OUString::valueOf( ImplRound( 1.0 - fBorder ) ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStopColor, aColorStr ); - // line color - aStyle += B2UCONST( "stroke:" ); + { + SvXMLElementExport aDesc4( mrExport, XML_NAMESPACE_NONE, aXMLElemStop, sal_True, sal_True ); + } + } + else + { + 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; - if( rLineColor.GetTransparency() == 255 ) - aStyle += B2UCONST( "none" ); - else - { - // 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 ); - } + 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 ) ) ); - if(pLineInfo) - { - // more infos for line needed - if(pLineInfo->GetWidth() > 1) - { - aStyle += B2UCONST( ";" ); - aStyle += B2UCONST( "stroke-width:" ); - aStyle += NMSP_RTL::OUString::valueOf(pLineInfo->GetWidth()); - } + apGradient.reset( new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemRadialGradient, sal_True, sal_True ) ); - if(LINE_DASH == pLineInfo->GetStyle()) - { - aStyle += B2UCONST( ";" ); - aStyle += B2UCONST( "stroke-dasharray:" ); - const long nDashLen(pLineInfo->GetDashLen()); - const long nDotLen(pLineInfo->GetDotLen()); - const long nDistance(pLineInfo->GetDistance()); - bool bIsFirst(true); - - for(sal_uInt16 a(0); a < pLineInfo->GetDashCount(); a++) - { - if(bIsFirst) - aStyle += B2UCONST(" "), bIsFirst = false; - else - aStyle += B2UCONST(","); - aStyle += NMSP_RTL::OUString::valueOf(nDashLen); - aStyle += B2UCONST(","); - aStyle += NMSP_RTL::OUString::valueOf(nDistance); - } + // write stop values + ImplGetColorStr( aEndColor, aColorStr ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrOffset, ::rtl::OUString::valueOf( 0.0 ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStopColor, aColorStr ); - for(sal_uInt16 b(0); b < pLineInfo->GetDotCount(); b++) { - if(bIsFirst) - aStyle += B2UCONST(" "), bIsFirst = false; - else - aStyle += B2UCONST(","); - aStyle += NMSP_RTL::OUString::valueOf(nDotLen); - aStyle += B2UCONST(","); - aStyle += NMSP_RTL::OUString::valueOf(nDistance); + SvXMLElementExport aDesc5( mrExport, XML_NAMESPACE_NONE, aXMLElemStop, sal_True, sal_True ); } - } - if(basegfx::B2DLINEJOIN_MITER != pLineInfo->GetLineJoin()) - { - aStyle += B2UCONST( ";" ); - aStyle += B2UCONST( "stroke-linejoin:" ); + 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 ); - switch(pLineInfo->GetLineJoin()) { - default: // B2DLINEJOIN_NONE, B2DLINEJOIN_MIDDLE, B2DLINEJOIN_MITER - aStyle += B2UCONST( "miter" ); - break; - case basegfx::B2DLINEJOIN_ROUND: - aStyle += B2UCONST( "round" ); - break; - case basegfx::B2DLINEJOIN_BEVEL: - aStyle += B2UCONST( "bevel" ); - break; + 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() ) ); -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 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 ); + + // 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() ); - aTemp = aInfo.GetWidth(); - mpVDev->LogicToLogic(&aTemp, 1, &mpVDev->GetMapMode(), &maTargetMapMode); - aInfo.SetWidth(aTemp); + for( sal_uInt16 i = 0, nSize = rPoly.GetSize(); i < nSize; ++i ) + { + ImplMap( rPoly[ i ], rDstPoly[ i ] ); + rDstPoly.SetFlags( i, rPoly.GetFlags( i ) ); + } - 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 ) ); + Point aPt1, aPt2; - 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() ) ); + 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; - 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() ) ); + if( bApplyMapping ) + ImplMap( rRect, aRect ); + else + aRect = rRect; + + 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 ) ); + Point aCenter; - 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 ) ) ); + 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 aPolyPoly; + + if( bApplyMapping ) + ImplMap( rPolyPoly, aPolyPoly ); + else + aPolyPoly = rPolyPoly; + + if( mrExport.hasClip() ) { - PolyPolygon aMappedPolyPoly; - FastString aStyle; + const ::basegfx::B2DPolyPolygon aB2DPolyPoly( ::basegfx::tools::correctOrientations( aPolyPoly.getB2DPolyPolygon() ) ); - for( sal_uInt16 i = 0, nCount = rPolyPoly.Count(); i < nCount; i++ ) - { - const Polygon& rPoly = rPolyPoly[ i ]; - const sal_uInt16 nSize = rPoly.GetSize(); + aPolyPoly = PolyPolygon( ::basegfx::tools::clipPolyPolygonOnPolyPolygon( + *mrExport.getCurClip(), aB2DPolyPoly, sal_False, sal_False ) ); + } - // #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 + // add path data attribute + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrD, GetPathString( aPolyPoly, bLineOnly ) ); - // old: Polygon aMappedPoly( nSize ); - // new: - Polygon aMappedPoly(rPoly); + { + // write polyline/polygon element + SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemPath, sal_True, sal_True ); + } +} - for( sal_uInt16 n = 0; n < nSize; n++ ) - aMappedPoly[ n ] = ImplMap( rPoly[ n ] ); +// ----------------------------------------------------------------------------- - aMappedPolyPoly.Insert( aMappedPoly ); - } +void SVGActionWriter::ImplWriteShape( const SVGShapeDescriptor& rShape, sal_Bool bApplyMapping ) +{ + PolyPolygon aPolyPoly; - if( bLineOnly ) - { - aStyle += B2UCONST( "fill:none" ); - if( pStyle ) - aStyle += B2UCONST( ";" ); - } - if( pStyle ) - aStyle += *pStyle; + if( bApplyMapping ) + ImplMap( rShape.maShapePolyPoly, aPolyPoly ); + else + aPolyPoly = rShape.maShapePolyPoly; + + 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 ); - // add style attribute - if( aStyle.GetLength() ) - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aStyle.GetString() ); + 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; - // add path data attribute - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrD, GetPathString( aMappedPolyPoly, bLineOnly ) ); + 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 ) + sal_uInt32 nWriteFlags, sal_Bool bApplyMapping ) { - if( rPolyPoly.Count() ) - { - SvXMLElementExport aElemG( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_True ); - FastString aClipId; - FastString aClipStyle; + PolyPolygon aPolyPoly; - aClipId += B2UCONST( "clip" ); - aClipId += NMSP_RTL::OUString::valueOf( ImplGetNextClipId() ); - - { - SvXMLElementExport aElemDefs( mrExport, XML_NAMESPACE_NONE, aXMLElemDefs, sal_True, sal_True ); + if( bApplyMapping ) + ImplMap( rPolyPoly, aPolyPoly ); + else + aPolyPoly = rPolyPoly; - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, aClipId.GetString() ); + if( rGradient.GetStyle() == GRADIENT_LINEAR || rGradient.GetStyle() == GRADIENT_AXIAL || + rGradient.GetStyle() == GRADIENT_RADIAL || rGradient.GetStyle() == GRADIENT_ELLIPTICAL ) + { + SVGShapeDescriptor aShapeDesc; - { - SvXMLElementExport aElemClipPath( mrExport, XML_NAMESPACE_NONE, aXMLElemClipPath, sal_True, sal_True ); - ImplWritePolyPolygon( rPolyPoly, sal_False ); - } - } + aShapeDesc.maShapePolyPoly = aPolyPoly; + aShapeDesc.mapShapeGradient.reset( new Gradient( rGradient ) ); - // create new context with clippath set - aClipStyle += B2UCONST( "clip-path:URL(#" ); - aClipStyle += aClipId.GetString(); - aClipStyle += B2UCONST( ")" ); + ImplWriteShape( aShapeDesc, sal_False ); + } + else + { + GDIMetaFile aTmpMtf; - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aClipStyle.GetString() ); + mrExport.pushClip( aPolyPoly.getB2DPolyPolygon() ); + mpVDev->AddGradientActions( rPolyPoly.GetBoundRect(), rGradient, aTmpMtf ); + ++mnInnerMtfCount; - { - GDIMetaFile aTmpMtf; - SvXMLElementExport aElemG2( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_True ); + ImplWriteActions( aTmpMtf, nWriteFlags, NULL ); - mpVDev->AddGradientActions( rPolyPoly.GetBoundRect(), rGradient, aTmpMtf ); - ImplWriteActions( aTmpMtf, pStyle, nWriteFlags ); - } + --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; + 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( bApplyMapping ) + ImplMap( rPos, aPos ); + else + aPos = rPos; - if( nLen ) + // get text sizes + if( pDXArray ) { - 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; - } - - if( nLen > 1 ) - { - aNormSize.Width() = pDX[ nLen - 2 ] + mpVDev->GetTextWidth( rText.GetChar( sal::static_int_cast<sal_uInt16>( nLen - 1 ) ) ); - - if( nWidth && aNormSize.Width() && ( nWidth != aNormSize.Width() ) ) - { - const double fFactor = (double) nWidth / aNormSize.Width(); + 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; - - case( ALIGN_BOTTOM ): - aBaseLinePos.Y() -= aMetric.GetDescent(); - break; + const double fFactor = (double) nWidth / aNormSize.Width(); - 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 += ')'; + ::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.GetOrientation() ) + // write single glyphs at absolute text positions + for( sal_Bool bCont = sal_True; bCont; ) { - aTransform += String( NMSP_RTL::OUString::createFromAscii( " rotate" ) ); - aTransform += '('; - aTransform += String( NMSP_RTL::OUString::valueOf( rFont.GetOrientation() * -0.1 ) ); - aTransform += ')'; - } - - if( rFont.GetItalic() != ITALIC_NONE ) - { - 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 ) ); - if( nCurPos < nLen ) - aOutputText.Erase( sal::static_int_cast<sal_uInt16>( nCurPos ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( nX ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aPos.Y() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, aTSpanX.GetString() ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, GetValueString( aPt.Y() ) ); + { + SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False ); + mrExport.GetDocHandler()->characters( aGlyph ); + } - { - SvXMLElementExport aElem2( mrExport, XML_NAMESPACE_NONE, aXMLElemTSpan, sal_True, sal_True ); - mrExport.GetDocHandler()->characters( aOutputText ); + if( bCont ) + nX = aPos.X() + pDXArray[ nCurPos - 1 ]; + } } -#else - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, GetValueString( aPt.X() ) ); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, GetValueString( aPt.Y() ) ); + } + } + else + { + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( aPos.X() ) ); + mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aPos.Y() ) ); - { - SvXMLElementExport aElem2( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_True ); - mrExport.GetDocHandler()->characters( rText ); - } -#endif + { + 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 ); 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,56 +925,112 @@ 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," ); - if( aImageData.GetFirstPartString( nPartLen, aImageString ) ) + xExtDocHandler->unknown( aString ); + + const sal_uInt32 nQuadCount = aImageData.getLength() / 3; + const sal_uInt32 nRest = aImageData.getLength() % 3; + + 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 ]; + } - while( aImageData.GetNextPartString( nPartLen, aImageString ) ) + 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++ = '='; + } + + *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() ); + 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( 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 ); + 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() ); + const MetaTextRectAction* pA = (const MetaTextRectAction*) pAction; + + if( pA->GetText().Len() ) + { + Font aFont( mpVDev->GetFont() ); + Size aSz; + + ImplMap( Size( 0, aFont.GetHeight() ), aSz ); - 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 ); + 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() ); + const String aText( pA->GetText(), pA->GetIndex(), pA->GetLen() ); + + if( aText.Len() ) + { + Font aFont( mpVDev->GetFont() ); + Size aSz; - 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 ); + 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,7 +1733,8 @@ 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() ); @@ -1650,8 +1751,19 @@ void SVGActionWriter::WriteMetaFile( const Point& rPos100thmm, aMapMode.SetOrigin( aOffset += aMapMode.GetOrigin() ); mpVDev->SetMapMode( aMapMode ); + ImplAcquireContext(); + + mapCurShape.reset(); + + ImplWriteActions( rMtf, nWriteFlags, pElementId ); - ImplWriteActions( rMtf, NULL, nWriteFlags ); + // 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 113448a551d5..58ee67538171 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 ); - void SetPaintAttr( const Color& rLineColor, const Color& rFillColor, const LineInfo* pLineInfo = 0); +}; + +// ---------------------- +// - SVGShapeDescriptor - +// ---------------------- + +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 |