diff options
author | Armin Le Grand <alg@apache.org> | 2012-06-11 08:38:23 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-04-14 21:33:59 +0100 |
commit | 4fa8df7320f6bdc8333f5936537d2ed93e8892ce (patch) | |
tree | 3b3d06d3ba0dd698e1fb168171e4de1b4d60c12a /filter | |
parent | 9bc0ca091b7037f7c8f4782103a81b7287bc1de3 (diff) |
Resolves: #i119735# missing css.svg.SVGWriter when using GraphicProvider
missing implementation for com.sun.star.svg.SVGWriter when using
GraphicProvider
Adapted patch provided by Sven Jacobi (thanks), added some fixes/cleanups to
make it work with all kind of graphics (SVG, Bitmap, Metafile)
(cherry picked from commit 891011181285d7ad54984ffd05ed44d825a70647)
Conflicts:
filter/inc/filter/msfilter/msdffimp.hxx
filter/source/graphicfilter/epict/epict.cxx
filter/source/svg/svgexport.cxx
filter/source/svg/svguno.cxx
filter/source/svg/svgwriter.cxx
filter/source/svg/svgwriter.hxx
svtools/source/filter/filter.cxx
Change-Id: Ie53f995614060a00c709f620f89d132913a25c5c
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/graphicfilter/eos2met/eos2met.cxx | 16 | ||||
-rw-r--r-- | filter/source/graphicfilter/epict/epict.cxx | 21 | ||||
-rw-r--r-- | filter/source/svg/svgexport.cxx | 42 | ||||
-rw-r--r-- | filter/source/svg/svgfilter.component | 3 | ||||
-rw-r--r-- | filter/source/svg/svgfilter.cxx | 27 | ||||
-rw-r--r-- | filter/source/svg/svgfilter.hxx | 2 | ||||
-rw-r--r-- | filter/source/svg/svgwriter.cxx | 38 | ||||
-rw-r--r-- | filter/source/svg/svgwriter.hxx | 22 |
8 files changed, 133 insertions, 38 deletions
diff --git a/filter/source/graphicfilter/eos2met/eos2met.cxx b/filter/source/graphicfilter/eos2met/eos2met.cxx index 1fe92ac9806d..9e5ae3bf20e3 100644 --- a/filter/source/graphicfilter/eos2met/eos2met.cxx +++ b/filter/source/graphicfilter/eos2met/eos2met.cxx @@ -2560,20 +2560,8 @@ extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL GraphicExport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* pFilterConfigItem, sal_Bool ) { METWriter aMETWriter; - if ( rGraphic.GetType() == GRAPHIC_GDIMETAFILE ) - return aMETWriter.WriteMET( rGraphic.GetGDIMetaFile(), rStream, pFilterConfigItem ); - else - { - Bitmap aBmp=rGraphic.GetBitmap(); - GDIMetaFile aMTF; - VirtualDevice aVirDev; - - aMTF.Record(&aVirDev); - aVirDev.DrawBitmap(Point(),aBmp); - aMTF.Stop(); - aMTF.SetPrefSize(aBmp.GetSizePixel()); - return aMETWriter.WriteMET( aMTF, rStream, pFilterConfigItem ); - } + // #119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically + return aMETWriter.WriteMET( rGraphic.GetGDIMetaFile(), rStream, pFilterConfigItem ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/graphicfilter/epict/epict.cxx b/filter/source/graphicfilter/epict/epict.cxx index c68d400ffa2c..3c02e0ae98fc 100644 --- a/filter/source/graphicfilter/epict/epict.cxx +++ b/filter/source/graphicfilter/epict/epict.cxx @@ -2275,23 +2275,10 @@ GraphicExport(SvStream & rStream, Graphic & rGraphic, FilterConfigItem* pFilterC { PictWriter aPictWriter; - if (rGraphic.GetType()==GRAPHIC_GDIMETAFILE) - { - GDIMetaFile aScaledMtf( rGraphic.GetGDIMetaFile() ); - return aPictWriter.WritePict( aScaledMtf, rStream, pFilterConfigItem ); - } - else - { - Bitmap aBmp=rGraphic.GetBitmap(); - GDIMetaFile aMTF; - VirtualDevice aVirDev; - - aMTF.Record(&aVirDev); - aVirDev.DrawBitmap(Point(),aBmp); - aMTF.Stop(); - aMTF.SetPrefSize(aBmp.GetSizePixel()); - return aPictWriter.WritePict( aMTF, rStream, pFilterConfigItem ); - } + // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically + GDIMetaFile aScaledMtf( rGraphic.GetGDIMetaFile() ); + + return aPictWriter.WritePict( aScaledMtf, rStream, pFilterConfigItem ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx index 918ef4830e58..27a7125b0e61 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -2343,4 +2343,46 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo ) return ( bFieldProcessed ? 0 : maOldFieldHdl.Call( pInfo ) ); } +// ----------------------------------------------------------------------------- + +void SVGExport::writeMtf( const GDIMetaFile& rMtf ) +{ + const Size aSize( OutputDevice::LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_MM ) ); + rtl::OUString aAttr; + Reference< XExtendedDocumentHandler> xExtDocHandler( GetDocHandler(), UNO_QUERY ); + + if( xExtDocHandler.is() ) + xExtDocHandler->unknown( SVG_DTD_STRING ); + + aAttr = rtl::OUString::valueOf( aSize.Width() ); + aAttr += "mm"; + AddAttribute( XML_NAMESPACE_NONE, "width", aAttr ); + + aAttr = rtl::OUString::valueOf( aSize.Height() ); + aAttr += "mm"; + AddAttribute( XML_NAMESPACE_NONE, "height", aAttr ); + + aAttr = "0 0 "; + aAttr += rtl::OUString::valueOf( aSize.Width() * 100L ); + aAttr += " "; + aAttr += rtl::OUString::valueOf( aSize.Height() * 100L ); + AddAttribute( XML_NAMESPACE_NONE, "viewBox", aAttr ); + + { + SvXMLElementExport aSVG( *this, XML_NAMESPACE_NONE, "svg", sal_True, sal_True ); + + std::vector< ObjectRepresentation > aObjects; + + aObjects.push_back( ObjectRepresentation( Reference< XInterface >(), rMtf ) ); + SVGFontExport aSVGFontExport( *this, aObjects ); + + Point aPoint100thmm( OutputDevice::LogicToLogic( rMtf.GetPrefMapMode().GetOrigin(), rMtf.GetPrefMapMode(), MAP_100TH_MM ) ); + Size aSize100thmm( OutputDevice::LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_100TH_MM ) ); + + SVGActionWriter aWriter( *this, aSVGFontExport ); + aWriter.WriteMetaFile( aPoint100thmm, aSize100thmm, rMtf, + SVGWRITER_WRITE_FILL | SVGWRITER_WRITE_TEXT, NULL ); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/svg/svgfilter.component b/filter/source/svg/svgfilter.component index 51fd50d6895e..1bf7b47f8413 100644 --- a/filter/source/svg/svgfilter.component +++ b/filter/source/svg/svgfilter.component @@ -24,4 +24,7 @@ <service name="com.sun.star.document.ExportFilter"/> <service name="com.sun.star.document.ExtendedTypeDetection"/> </implementation> + <implementation name="com.sun.star.comp.Draw.SVGWriter"> + <service name="com.sun.star.svg.SVGWriter"/> + </implementation> </component> diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx index eb22854abca8..755684091bc0 100644 --- a/filter/source/svg/svgfilter.cxx +++ b/filter/source/svg/svgfilter.cxx @@ -43,6 +43,7 @@ #include <osl/mutex.hxx> #include "svgfilter.hxx" +#include "svgwriter.hxx" using namespace ::com::sun::star; @@ -306,23 +307,39 @@ OUString SAL_CALL SVGFilter::detect( Sequence< PropertyValue >& io_rDescriptor ) // ----------------------------------------------------------------------------- +#define SVG_FILTER_IMPL_NAME "com.sun.star.comp.Draw.SVGFilter" +#define SVG_WRITER_IMPL_NAME "com.sun.star.comp.Draw.SVGWriter" + namespace sdecl = comphelper::service_decl; - sdecl::class_<SVGFilter> serviceImpl; + sdecl::class_<SVGFilter> serviceFilterImpl; const sdecl::ServiceDecl svgFilter( - serviceImpl, - "com.sun.star.comp.Draw.SVGFilter", + serviceFilterImpl, + SVG_FILTER_IMPL_NAME, "com.sun.star.document.ImportFilter;" "com.sun.star.document.ExportFilter;" "com.sun.star.document.ExtendedTypeDetection" ); + sdecl::class_<SVGWriter> serviceWriterImpl; + const sdecl::ServiceDecl svgWriter( + serviceWriterImpl, + SVG_WRITER_IMPL_NAME, + "com.sun.star.svg.SVGWriter" ); + // The C shared lib entry points extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL svgfilter_component_getFactory( sal_Char const* pImplName, ::com::sun::star::lang::XMultiServiceFactory* pServiceManager, ::com::sun::star::registry::XRegistryKey* pRegistryKey ) { - return component_getFactoryHelper( pImplName, pServiceManager, - pRegistryKey, svgFilter ); + if ( rtl_str_compare (pImplName, SVG_FILTER_IMPL_NAME) == 0 ) + { + return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, svgFilter ); + } + else if ( rtl_str_compare (pImplName, SVG_WRITER_IMPL_NAME) == 0 ) + { + return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, svgWriter ); + } + return NULL; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx index 3c8e5a88156a..b0a6546af601 100644 --- a/filter/source/svg/svgfilter.hxx +++ b/filter/source/svg/svgfilter.hxx @@ -119,6 +119,8 @@ public: sal_Bool IsUseNativeTextDecoration() const; sal_Bool IsUseOpacity() const; + void writeMtf( const GDIMetaFile& rMtf ); + protected: virtual void _ExportStyles( sal_Bool /* bUsed */ ) {} diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index cbb33e358307..80cd9ca509d9 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -2679,7 +2679,10 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const String& rText, if( bCont ) { // #118796# do NOT access pDXArray, it may be zero (!) - nX = aPos.X() + pDX[ nCurPos - 1 ]; + sal_Int32 nDXWidth = pDX[ nCurPos - 1 ]; + if ( bApplyMapping ) + nDXWidth = ImplMap( nDXWidth ); + nX = aPos.X() + nDXWidth; } } } @@ -3728,4 +3731,37 @@ void SVGActionWriter::WriteMetaFile( const Point& rPos100thmm, mpVDev->Pop(); } +// ------------- +// - SVGWriter - +// ------------- + +SVGWriter::SVGWriter( const Reference< XComponentContext >& rxCtx ) + : mxContext(rxCtx) +{ +} + +// ----------------------------------------------------------------------------- + +SVGWriter::~SVGWriter() +{ +} + +// ----------------------------------------------------------------------------- + +void SAL_CALL SVGWriter::write( const Reference<XDocumentHandler>& rxDocHandler, + const Sequence<sal_Int8>& rMtfSeq ) throw( RuntimeException ) +{ + SvMemoryStream aMemStm( (char*) rMtfSeq.getConstArray(), rMtfSeq.getLength(), STREAM_READ ); + GDIMetaFile aMtf; + + aMemStm >> aMtf; + + const Reference< XDocumentHandler > xDocumentHandler( rxDocHandler ); + const Sequence< PropertyValue > aFilterData; + + SVGExport* pWriter = new SVGExport( mxContext, xDocumentHandler, aFilterData ); + pWriter->writeMtf( aMtf ); + delete pWriter; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/svg/svgwriter.hxx b/filter/source/svg/svgwriter.hxx index dbce63487b74..31ef4239c334 100644 --- a/filter/source/svg/svgwriter.hxx +++ b/filter/source/svg/svgwriter.hxx @@ -21,7 +21,7 @@ #define SVGWRITER_HXX #include <stack> -#include <cppuhelper/weak.hxx> +#include <cppuhelper/implbase1.hxx> #include <rtl/ustring.hxx> #include <tools/stream.hxx> #include <tools/string.hxx> @@ -58,6 +58,7 @@ #include <com/sun/star/text/XTextRange.hpp> #include <com/sun/star/text/XTextField.hpp> #include <com/sun/star/style/NumberingType.hpp> +#include <com/sun/star/svg/XSVGWriter.hpp> // ----------------------------------------------------------------------------- @@ -68,6 +69,8 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::text; using namespace ::com::sun::star::drawing; using namespace ::com::sun::star::style; +using namespace ::com::sun::star::svg; +using namespace ::com::sun::star::xml::sax; // ----------------------------------------------------------------------------- @@ -152,6 +155,7 @@ struct SVGShapeDescriptor class SVGAttributeWriter; +class SVGExport; class GDIMetaFile; @@ -400,6 +404,22 @@ public: const GDIMetaFile* pTextEmbeddedBitmapMtf = NULL ); }; +class SVGWriter : public cppu::WeakImplHelper1< XSVGWriter > +{ +private: + Reference< XComponentContext > mxContext; + + SVGWriter(); + +public: + explicit SVGWriter( const Reference< XComponentContext >& rxCtx ); + virtual ~SVGWriter(); + + // XSVGWriter + virtual void SAL_CALL write( const Reference<XDocumentHandler>& rxDocHandler, + const Sequence<sal_Int8>& rMtfSeq ) throw( RuntimeException ); +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |