diff options
author | Ciorba Edmond <edmond_ciorba@yahoo.com> | 2013-07-03 16:14:45 +0300 |
---|---|---|
committer | Andras Timar <atimar@suse.com> | 2013-07-11 12:36:20 +0200 |
commit | 5dd1b3da57862a6577717544dde56482add89170 (patch) | |
tree | 59a18786309d0f1d49b41f06485457cba7d6e5da /svx | |
parent | 31144904919cf386f7ef6941a2932bc00497ed13 (diff) |
fdo#63211 - embed images in HTML export.
Change-Id: I585c85d2cee13ee8954623bd981cb372d78b7952
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/xoutdev/_xoutbmp.cxx | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx index 535d6b3299dc..40f9f7f1bdd0 100644 --- a/svx/source/xoutdev/_xoutbmp.cxx +++ b/svx/source/xoutdev/_xoutbmp.cxx @@ -29,6 +29,9 @@ #include <vcl/dibtools.hxx> #include <vcl/FilterConfigItem.hxx> #include <vcl/graphicfilter.hxx> +#include <vcl/cvtgrf.hxx> +#include <sax/tools/converter.hxx> +#include <svtools/htmlkywd.hxx> #define FORMAT_BMP OUString("bmp") #define FORMAT_GIF OUString("gif") @@ -314,6 +317,46 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, String& rFileName, } } +sal_uLong XOutBitmap::GraphicToBase64(const Graphic& rGraphic, OUString& rOUString) +{ + SvMemoryStream aOStm; + OUString aMimeType; + GfxLink aLink = rGraphic.GetLink(); + sal_uLong aCvtType; + switch( aLink.GetType() ) + { + case( GFX_LINK_TYPE_NATIVE_JPG ): + aCvtType = CVT_JPG; + aMimeType = "image/jpeg"; + break; + case( GFX_LINK_TYPE_NATIVE_PNG ): + aCvtType = CVT_PNG; + aMimeType = "image/png"; + break; + case( GFX_LINK_TYPE_NATIVE_SVG ): + aCvtType = CVT_SVG; + aMimeType = "image/svg+xml"; + break; + default: + // save everything else (including gif) into png + aCvtType = CVT_PNG; + aMimeType = "image/png"; + break; + } + sal_uLong nErr = GraphicConverter::Export(aOStm,rGraphic,aCvtType); + if ( nErr ) + { + SAL_WARN("svx", "XOutBitmap::GraphicToBase64() invalid Graphic? error: " << nErr ); + return nErr; + } + aOStm.Seek(STREAM_SEEK_TO_END); + css::uno::Sequence<sal_Int8> aOStmSeq( (sal_Int8*) aOStm.GetData(),aOStm.Tell() ); + OUStringBuffer aStrBuffer; + ::sax::Converter::encodeBase64(aStrBuffer,aOStmSeq); + rOUString = aMimeType + ";base64," + aStrBuffer.makeStringAndClear(); + return 0; +} + sal_uInt16 XOutBitmap::ExportGraphic( const Graphic& rGraphic, const INetURLObject& rURL, GraphicFilter& rFilter, const sal_uInt16 nFormat, const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData ) |