filter/source/svg/svgfilter.component | 4 +++- filter/source/svg/svgfilter.cxx | 5 ++--- svtools/source/filter/filter.cxx | 13 +++++-------- svx/inc/svx/xmlgrhlp.hxx | 3 ++- svx/source/svdraw/svdograf.cxx | 7 +++++-- svx/source/xml/xmlgrhlp.cxx | 24 ++++++++++++++++++++---- 6 files changed, 37 insertions(+), 19 deletions(-)
New commits: commit f3c43171f8e9e04c4a6e6f5833fbe1a0ef098d2b Author: Thorsten Behrens <tbehr...@novell.com> Date: Fri Oct 21 11:10:29 2011 +0200 Fix fdo#41995 fallout - recognize .svg in odf container Seems the graphic load code is stupid and not using the path name / file extension to guess file type, but only "magic byte" detection. Giving filter framework the path now, so that .svg actually loads. diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index ff24d2a..d1eadd0 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -1286,8 +1286,11 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO ) mbIsPreview = sal_True; } - if( !GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, String(), *pStream, - GRFILTER_FORMAT_DONTKNOW, NULL, 0, pFilterData ) ) + if( !GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, + aStreamInfo.maUserData, + *pStream, + GRFILTER_FORMAT_DONTKNOW, + NULL, 0, pFilterData ) ) { const String aUserData( pGraphic->GetUserData() ); commit 1d9c6bc38089dbb52931e54493c39e4e33309a90 Author: Thorsten Behrens <tbehr...@novell.com> Date: Wed Oct 19 14:12:15 2011 +0200 Fix svg document import Merge of dev300 broke this - we *do* want import to call this implImport() actually. Also, the service names were bogus previously. diff --git a/filter/source/svg/svgfilter.component b/filter/source/svg/svgfilter.component index 82db624..c4d5bff 100644 --- a/filter/source/svg/svgfilter.component +++ b/filter/source/svg/svgfilter.component @@ -29,6 +29,8 @@ <component loader="com.sun.star.loader.SharedLibrary" xmlns="http://openoffice.org/2010/uno-components"> <implementation name="com.sun.star.comp.Draw.SVGFilter"> - <service name="com.sun.star.document.SVGFilter"/> + <service name="com.sun.star.document.ImportFilter"/> + <service name="com.sun.star.document.ExportFilter"/> + <service name="com.sun.star.document.ExtendedTypeDetection"/> </implementation> </component> diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx index 42f48a2..b5f9b07 100644 --- a/filter/source/svg/svgfilter.cxx +++ b/filter/source/svg/svgfilter.cxx @@ -113,9 +113,8 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto pFocusWindow->EnterWait(); if( mxDstDoc.is() ) - bRet = sal_False;//implImport( rDescriptor ); - else - if( mxSrcDoc.is() ) + bRet = implImport( rDescriptor ); + else if( mxSrcDoc.is() ) { if( !mbExportAll ) { commit 716c052a1c62d5acacab202e8f0ee88b4f70d8c2 Author: Thorsten Behrens <tbehr...@novell.com> Date: Wed Oct 19 13:25:35 2011 +0200 Fix fdo#41995 - true embedding of svg images. Previously, svg images were always wrapped as .svm metafiles with a preview graphic. Sucks for interop - so now, we save true svgs at least for bleeding edge extended odf1.2 diff --git a/svtools/source/filter/filter.cxx b/svtools/source/filter/filter.cxx index 5c9edab..226b48d 100644 --- a/svtools/source/filter/filter.cxx +++ b/svtools/source/filter/filter.cxx @@ -1501,17 +1501,14 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, GDIMetaFile aSVGMtf; if( 0 == aSVGReader.Read( aSVGMtf ).GetActionSize() ) + { nStatus = GRFILTER_FILTERERROR; + } else + { rGraphic = Graphic( aSVGMtf ); - - // Dont set any GfxLink here, since the MetaRenderGraphicAction - // inside the just read MetaFile contains excatly this native data; - // setting a Ç´fxLink would also affect other program parts, since - // GfxLinks are preferably written to the file format in general, - // which would be a bad idea in case of SVG files, since earlier - // implementations are not able to handle native SVG data in any - // case. (KA 01/19/2011) + eLinkType = GFX_LINK_TYPE_NATIVE_SVG; + } } else if( aFilterName.EqualsIgnoreCaseAscii( IMP_XBM ) ) { diff --git a/svx/inc/svx/xmlgrhlp.hxx b/svx/inc/svx/xmlgrhlp.hxx index f8260b9..fef8af5 100644 --- a/svx/inc/svx/xmlgrhlp.hxx +++ b/svx/inc/svx/xmlgrhlp.hxx @@ -92,7 +92,8 @@ private: const ::rtl::OUString& rPictureStreamName ); SVX_DLLPRIVATE sal_Bool ImplWriteGraphic( const ::rtl::OUString& rPictureStorageName, const ::rtl::OUString& rPictureStreamName, - const ::rtl::OUString& rGraphicId ); + const ::rtl::OUString& rGraphicId, + bool bUseGfxLink ); SVX_DLLPRIVATE void ImplInsertGraphicURL( const ::rtl::OUString& rURLStr, sal_uInt32 nInsertPos, rtl::OUString& rRequestedFileName ); protected: diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx index 78e458c..9c47a21 100644 --- a/svx/source/xml/xmlgrhlp.cxx +++ b/svx/source/xml/xmlgrhlp.cxx @@ -40,6 +40,7 @@ #include <unotools/ucbstreamhelper.hxx> #include <unotools/streamwrap.hxx> #include <unotools/tempfile.hxx> +#include <unotools/saveopt.hxx> #include <tools/debug.hxx> #include <vcl/cvtgrf.hxx> #include <vcl/gfxlink.hxx> @@ -581,7 +582,8 @@ Graphic SvXMLGraphicHelper::ImplReadGraphic( const ::rtl::OUString& rPictureStor sal_Bool SvXMLGraphicHelper::ImplWriteGraphic( const ::rtl::OUString& rPictureStorageName, const ::rtl::OUString& rPictureStreamName, - const ::rtl::OUString& rGraphicId ) + const ::rtl::OUString& rGraphicId, + bool bUseGfxLink ) { String aGraphicId( rGraphicId ); GraphicObject aGrfObject( ByteString( aGraphicId, RTL_TEXTENCODING_ASCII_US ) ); @@ -610,7 +612,7 @@ sal_Bool SvXMLGraphicHelper::ImplWriteGraphic( const ::rtl::OUString& rPictureSt xProps->setPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "Compressed" ) ), aAny ); SvStream* pStream = utl::UcbStreamHelper::CreateStream( aStream.xStream ); - if( aGfxLink.GetDataSize() && aGfxLink.GetData() ) + if( bUseGfxLink && aGfxLink.GetDataSize() && aGfxLink.GetData() ) pStream->Write( aGfxLink.GetData(), aGfxLink.GetDataSize() ); else { @@ -716,6 +718,7 @@ void SvXMLGraphicHelper::ImplInsertGraphicURL( const ::rtl::OUString& rURLStr, s Graphic aGraphic( (Graphic&) aGrfObject.GetGraphic() ); const GfxLink aGfxLink( aGraphic.GetLink() ); String aExtension; + bool bUseGfxLink( true ); if( aGfxLink.GetDataSize() ) { @@ -729,7 +732,20 @@ void SvXMLGraphicHelper::ImplInsertGraphicURL( const ::rtl::OUString& rURLStr, s case( GFX_LINK_TYPE_NATIVE_WMF ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".wmf" ) ); break; case( GFX_LINK_TYPE_NATIVE_MET ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".met" ) ); break; case( GFX_LINK_TYPE_NATIVE_PCT ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".pct" ) ); break; - case( GFX_LINK_TYPE_NATIVE_SVG ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".svg" ) ); break; + case( GFX_LINK_TYPE_NATIVE_SVG ): + // backward-compat kludge: since no released OOo + // version to date can handle svg properly, wrap it up + // into an svm. slight catch22 here, since strict ODF + // conformance _recommends_ svg - then again, most old + // ODF consumers are believed to be OOo + if( SvtSaveOptions().GetODFDefaultVersion() <= SvtSaveOptions::ODFVER_012 ) + { + bUseGfxLink = false; + aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".svm" ) ); + } + else + aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".svg" ) ); + break; default: aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".grf" ) ); @@ -779,7 +795,7 @@ void SvXMLGraphicHelper::ImplInsertGraphicURL( const ::rtl::OUString& rURLStr, s aStreamName += aExtension; if( mbDirect && aStreamName.Len() ) - ImplWriteGraphic( aPictureStorageName, aStreamName, aGraphicObjectId ); + ImplWriteGraphic( aPictureStorageName, aStreamName, aGraphicObjectId, bUseGfxLink ); rURLPair.second = sPictures; rURLPair.second += aStreamName;
_______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits