From 5868745db74ae930edb0058490076d82aaeafbe9 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Mon, 12 Jun 2017 15:27:16 +0200 Subject: emfplus: make VectorFormats Emf/Wmf/Svg work make complete turn around and internal buffering for Emf/Wmf/Svg work, including images in ODF and re-save from UI. The correct FileType has to be determined. It has shown that *.wmf exist that really contain *.emf, so this turn around will not alter the binary data, but may change the mimetype Change-Id: I4fd92629236c12114f7b7c30234a3d3a9917dfaf --- svx/source/core/graphichelper.cxx | 21 +++++++++++++++++++++ svx/source/svdraw/svdograf.cxx | 38 ++++++++++++++++++++++++++++++++++++-- svx/source/svdraw/svdstr.src | 19 +++++++++++++++++-- svx/source/xoutdev/_xoutbmp.cxx | 36 +++++++++++++++++++++--------------- 4 files changed, 95 insertions(+), 19 deletions(-) (limited to 'svx') diff --git a/svx/source/core/graphichelper.cxx b/svx/source/core/graphichelper.cxx index 3a6df2b9e7f5..632c6b03efa6 100644 --- a/svx/source/core/graphichelper.cxx +++ b/svx/source/core/graphichelper.cxx @@ -63,6 +63,27 @@ namespace drawing = com::sun::star::drawing; void GraphicHelper::GetPreferredExtension( OUString& rExtension, const Graphic& rGraphic ) { OUString aExtension = "png"; + const VectorGraphicDataPtr& aVectorGraphicDataPtr(rGraphic.getVectorGraphicData()); + + if (aVectorGraphicDataPtr.get() && aVectorGraphicDataPtr->getVectorGraphicDataArrayLength()) + { + switch (aVectorGraphicDataPtr->getVectorGraphicDataType()) + { + case VectorGraphicDataType::Wmf: + aExtension = "wmf"; + break; + case VectorGraphicDataType::Emf: + aExtension = "emf"; + break; + default: // case VectorGraphicDataType::Svg: + aExtension = "svg"; + break; + } + + rExtension = aExtension; + return; + } + switch( rGraphic.GetLink().GetType() ) { case GfxLinkType::NativeGif: diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 0bf050507bd5..82bdf58a2f70 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -748,7 +748,24 @@ OUString SdrGrafObj::TakeObjNameSingul() const if(rVectorGraphicDataPtr.get()) { - sName.append(ImpGetResStr(STR_ObjNameSingulGRAFSVG)); + switch (rVectorGraphicDataPtr->getVectorGraphicDataType()) + { + case VectorGraphicDataType::Wmf: + { + sName.append(ImpGetResStr(STR_ObjNameSingulGRAFWMF)); + break; + } + case VectorGraphicDataType::Emf: + { + sName.append(ImpGetResStr(STR_ObjNameSingulGRAFEMF)); + break; + } + default: // case VectorGraphicDataType::Svg: + { + sName.append(ImpGetResStr(STR_ObjNameSingulGRAFSVG)); + break; + } + } } else { @@ -801,7 +818,24 @@ OUString SdrGrafObj::TakeObjNamePlural() const if(rVectorGraphicDataPtr.get()) { - sName.append(ImpGetResStr(STR_ObjNamePluralGRAFSVG)); + switch (rVectorGraphicDataPtr->getVectorGraphicDataType()) + { + case VectorGraphicDataType::Wmf: + { + sName.append(ImpGetResStr(STR_ObjNamePluralGRAFWMF)); + break; + } + case VectorGraphicDataType::Emf: + { + sName.append(ImpGetResStr(STR_ObjNamePluralGRAFEMF)); + break; + } + default: // case VectorGraphicDataType::Svg: + { + sName.append(ImpGetResStr(STR_ObjNamePluralGRAFSVG)); + break; + } + } } else { diff --git a/svx/source/svdraw/svdstr.src b/svx/source/svdraw/svdstr.src index d704475e0297..79d5726192a6 100644 --- a/svx/source/svdraw/svdstr.src +++ b/svx/source/svdraw/svdstr.src @@ -394,8 +394,7 @@ String STR_ObjNamePluralCUSTOMSHAPE Text [ en-US ] = "Shapes"; }; -// Svg support - +// Vector Data support String STR_ObjNameSingulGRAFSVG { Text [ en-US ] = "SVG" ; @@ -404,6 +403,22 @@ String STR_ObjNamePluralGRAFSVG { Text [ en-US ] = "SVGs" ; }; +String STR_ObjNameSingulGRAFWMF +{ + Text [ en-US ] = "WMF" ; +}; +String STR_ObjNamePluralGRAFWMF +{ + Text [ en-US ] = "WMFs" ; +}; +String STR_ObjNameSingulGRAFEMF +{ + Text [ en-US ] = "EMF" ; +}; +String STR_ObjNamePluralGRAFEMF +{ + Text [ en-US ] = "EMFs" ; +}; String STR_ObjNameSingulOLE2 { diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx index db5474ecf63c..939c5abbbb79 100644 --- a/svx/source/xoutdev/_xoutbmp.cxx +++ b/svx/source/xoutdev/_xoutbmp.cxx @@ -151,26 +151,32 @@ ErrCode XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileName, const VectorGraphicDataPtr& aVectorGraphicDataPtr(rGraphic.getVectorGraphicData()); if(aVectorGraphicDataPtr.get() - && aVectorGraphicDataPtr->getVectorGraphicDataArrayLength() - && rFilterName.equalsIgnoreAsciiCase("svg")) + && aVectorGraphicDataPtr->getVectorGraphicDataArrayLength()) { - if(!(nFlags & XOutFlags::DontAddExtension)) - { - aURL.setExtension(rFilterName); - } + const bool bIsSvg(rFilterName.equalsIgnoreAsciiCase("svg") && VectorGraphicDataType::Svg == aVectorGraphicDataPtr->getVectorGraphicDataType()); + const bool bIsWmf(rFilterName.equalsIgnoreAsciiCase("wmf") && VectorGraphicDataType::Wmf == aVectorGraphicDataPtr->getVectorGraphicDataType()); + const bool bIsEmf(rFilterName.equalsIgnoreAsciiCase("emf") && VectorGraphicDataType::Emf == aVectorGraphicDataPtr->getVectorGraphicDataType()); - rFileName = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE); - SfxMedium aMedium(aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::WRITE|StreamMode::SHARE_DENYNONE|StreamMode::TRUNC); - SvStream* pOStm = aMedium.GetOutStream(); - - if(pOStm) + if (bIsSvg || bIsWmf || bIsEmf) { - pOStm->WriteBytes(aVectorGraphicDataPtr->getVectorGraphicDataArray().getConstArray(), aVectorGraphicDataPtr->getVectorGraphicDataArrayLength()); - aMedium.Commit(); + if (!(nFlags & XOutFlags::DontAddExtension)) + { + aURL.setExtension(rFilterName); + } - if(!aMedium.GetError()) + rFileName = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE); + SfxMedium aMedium(aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::WRITE | StreamMode::SHARE_DENYNONE | StreamMode::TRUNC); + SvStream* pOStm = aMedium.GetOutStream(); + + if (pOStm) { - nErr = ERRCODE_NONE; + pOStm->WriteBytes(aVectorGraphicDataPtr->getVectorGraphicDataArray().getConstArray(), aVectorGraphicDataPtr->getVectorGraphicDataArrayLength()); + aMedium.Commit(); + + if (!aMedium.GetError()) + { + nErr = ERRCODE_NONE; + } } } } -- cgit