summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
Diffstat (limited to 'vcl')
-rw-r--r--vcl/Library_vcl.mk2
-rw-r--r--vcl/inc/impgraph.hxx6
-rw-r--r--vcl/source/app/brand.cxx2
-rw-r--r--vcl/source/filter/graphicfilter.cxx65
-rw-r--r--vcl/source/gdi/graph.cxx8
-rw-r--r--vcl/source/gdi/impgraph.cxx110
-rw-r--r--vcl/source/gdi/vectorgraphicdata.cxx (renamed from vcl/source/gdi/svgdata.cxx)74
7 files changed, 159 insertions, 108 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index a0113a2e85d4..9735c606a1a8 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -298,7 +298,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/gdi/sallayout \
vcl/source/gdi/salmisc \
vcl/source/gdi/salnativewidgets-none \
- vcl/source/gdi/svgdata \
+ vcl/source/gdi/vectorgraphicdata \
vcl/source/gdi/textlayout \
vcl/source/gdi/virdev \
vcl/source/gdi/wall \
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 6260a62e874e..f5982f84cb2d 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -48,7 +48,7 @@ private:
mutable sal_uLong mnSizeBytes;
bool mbSwapOut;
bool mbDummyContext;
- SvgDataPtr maSvgData;
+ VectorGraphicDataPtr maVectorGraphicData;
css::uno::Sequence<sal_Int8> maPdfData;
private:
@@ -58,7 +58,7 @@ private:
ImpGraphic( ImpGraphic&& rImpGraphic );
ImpGraphic( const Bitmap& rBmp );
ImpGraphic( const BitmapEx& rBmpEx );
- ImpGraphic(const SvgDataPtr& rSvgDataPtr);
+ ImpGraphic(const VectorGraphicDataPtr& rVectorGraphicDataPtr);
ImpGraphic( const Animation& rAnimation );
ImpGraphic( const GDIMetaFile& rMtf );
public:
@@ -145,7 +145,7 @@ private:
friend void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic);
friend void ReadImpGraphic(SvStream& rIStm, ImpGraphic& rImpGraphic);
- const SvgDataPtr& getSvgData() const { return maSvgData; }
+ const VectorGraphicDataPtr& getVectorGraphicData() const { return maVectorGraphicData; }
};
#endif // INCLUDED_VCL_INC_IMPGRAPH_HXX
diff --git a/vcl/source/app/brand.cxx b/vcl/source/app/brand.cxx
index a4bf268739fe..0d3a7752e2fa 100644
--- a/vcl/source/app/brand.cxx
+++ b/vcl/source/app/brand.cxx
@@ -26,7 +26,7 @@
#include <tools/stream.hxx>
#include <vcl/pngread.hxx>
#include <vcl/svapp.hxx>
-#include <vcl/svgdata.hxx>
+#include <vcl/vectorgraphicdata.hxx>
namespace {
bool loadPng( const OUString & rPath, BitmapEx &rBitmap)
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 3027c25062c8..98655baffa4a 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -35,7 +35,7 @@
#include <vcl/salctype.hxx>
#include <vcl/pngread.hxx>
#include <vcl/pngwrite.hxx>
-#include <vcl/svgdata.hxx>
+#include <vcl/vectorgraphicdata.hxx>
#include <vcl/virdev.hxx>
#include <vcl/svapp.hxx>
#include <osl/file.hxx>
@@ -1679,7 +1679,7 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath,
if (!rIStream.GetError() && nMemoryLength >= 0)
{
- SvgDataArray aNewData(nMemoryLength);
+ VectorGraphicDataArray aNewData(nMemoryLength);
aMemStream.Seek(STREAM_SEEK_TO_BEGIN);
aMemStream.ReadBytes(aNewData.begin(), nMemoryLength);
@@ -1690,22 +1690,22 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath,
if(!aMemStream.GetError() )
{
- SvgDataPtr aSvgDataPtr(new SvgData(aNewData, rPath));
- rGraphic = Graphic(aSvgDataPtr);
+ VectorGraphicDataPtr aVectorGraphicDataPtr(new VectorGraphicData(aNewData, rPath, VectorGraphicDataType::Svg));
+ rGraphic = Graphic(aVectorGraphicDataPtr);
bOkay = true;
}
}
}
else
{
- SvgDataArray aNewData(nStreamLength);
+ VectorGraphicDataArray aNewData(nStreamLength);
rIStream.Seek(nStreamPosition);
rIStream.ReadBytes(aNewData.begin(), nStreamLength);
if(!rIStream.GetError())
{
- SvgDataPtr aSvgDataPtr(new SvgData(aNewData, rPath));
- rGraphic = Graphic(aSvgDataPtr);
+ VectorGraphicDataPtr aVectorGraphicDataPtr(new VectorGraphicData(aNewData, rPath, VectorGraphicDataType::Svg));
+ rGraphic = Graphic(aVectorGraphicDataPtr);
bOkay = true;
}
}
@@ -1766,13 +1766,46 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath,
else if( aFilterName.equalsIgnoreAsciiCase( IMP_WMF ) ||
aFilterName.equalsIgnoreAsciiCase( IMP_EMF ) )
{
- GDIMetaFile aMtf;
- if( !ConvertWMFToGDIMetaFile( rIStream, aMtf, nullptr, pExtHeader ) )
- nStatus = ERRCODE_GRFILTER_FORMATERROR;
+ static bool bCheckEmf = false;
+ if (bCheckEmf)
+ {
+ if (rGraphic.IsDummyContext())
+ rGraphic.SetDummyContext(false);
+
+ const sal_uInt32 nStreamPosition(rIStream.Tell());
+ const sal_uInt32 nStreamLength(rIStream.Seek(STREAM_SEEK_TO_END) - nStreamPosition);
+ VectorGraphicDataArray aNewData(nStreamLength);
+ bool bOkay(false);
+
+ rIStream.Seek(nStreamPosition);
+ rIStream.ReadBytes(aNewData.begin(), nStreamLength);
+
+ if (!rIStream.GetError())
+ {
+ VectorGraphicDataPtr aVectorGraphicDataPtr(new VectorGraphicData(aNewData, rPath, VectorGraphicDataType::Emf));
+ rGraphic = Graphic(aVectorGraphicDataPtr);
+ bOkay = true;
+ }
+
+ if (bOkay)
+ {
+ eLinkType = GfxLinkType::NativeSvg;
+ }
+ else
+ {
+ nStatus = ERRCODE_GRFILTER_FILTERERROR;
+ }
+ }
else
{
- rGraphic = aMtf;
- eLinkType = GfxLinkType::NativeWmf;
+ GDIMetaFile aMtf;
+ if (!ConvertWMFToGDIMetaFile(rIStream, aMtf, nullptr, pExtHeader))
+ nStatus = ERRCODE_GRFILTER_FORMATERROR;
+ else
+ {
+ rGraphic = aMtf;
+ eLinkType = GfxLinkType::NativeWmf;
+ }
}
}
else if( aFilterName.equalsIgnoreAsciiCase( IMP_SVSGF )
@@ -2163,12 +2196,12 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r
{
bool bDone(false);
- // do we have a native SVG RenderGraphic, whose data can be written directly?
- const SvgDataPtr& aSvgDataPtr(rGraphic.getSvgData());
+ // do we have a native Vector Graphic Data RenderGraphic, whose data can be written directly?
+ const VectorGraphicDataPtr& aVectorGraphicDataPtr(rGraphic.getVectorGraphicData());
- if (aSvgDataPtr.get() && aSvgDataPtr->getSvgDataArrayLength())
+ if (aVectorGraphicDataPtr.get() && aVectorGraphicDataPtr->getVectorGraphicDataArrayLength())
{
- rOStm.WriteBytes(aSvgDataPtr->getSvgDataArray().getConstArray(), aSvgDataPtr->getSvgDataArrayLength());
+ rOStm.WriteBytes(aVectorGraphicDataPtr->getVectorGraphicDataArray().getConstArray(), aVectorGraphicDataPtr->getVectorGraphicDataArrayLength());
if( rOStm.GetError() )
{
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index d863a2413506..b36c5300f4d5 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -211,8 +211,8 @@ Graphic::Graphic(const BitmapEx& rBmpEx)
{
}
-Graphic::Graphic(const SvgDataPtr& rSvgDataPtr)
- : mxImpGraphic(new ImpGraphic(rSvgDataPtr))
+Graphic::Graphic(const VectorGraphicDataPtr& rVectorGraphicDataPtr)
+ : mxImpGraphic(new ImpGraphic(rVectorGraphicDataPtr))
{
}
@@ -581,9 +581,9 @@ void WriteGraphic( SvStream& rOStream, const Graphic& rGraphic )
WriteImpGraphic(rOStream, *rGraphic.mxImpGraphic);
}
-const SvgDataPtr& Graphic::getSvgData() const
+const VectorGraphicDataPtr& Graphic::getVectorGraphicData() const
{
- return mxImpGraphic->getSvgData();
+ return mxImpGraphic->getVectorGraphicData();
}
void Graphic::setPdfData(const uno::Sequence<sal_Int8>& rPdfData)
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index f5f05e06f1a8..dfacf2ca49d5 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -114,7 +114,7 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic)
, mnSizeBytes(rImpGraphic.mnSizeBytes)
, mbSwapOut(rImpGraphic.mbSwapOut)
, mbDummyContext(rImpGraphic.mbDummyContext)
- , maSvgData(rImpGraphic.maSvgData)
+ , maVectorGraphicData(rImpGraphic.maVectorGraphicData)
, maPdfData(rImpGraphic.maPdfData)
{
if( rImpGraphic.mpGfxLink )
@@ -139,7 +139,7 @@ ImpGraphic::ImpGraphic(ImpGraphic&& rImpGraphic)
, mnSizeBytes(rImpGraphic.mnSizeBytes)
, mbSwapOut(rImpGraphic.mbSwapOut)
, mbDummyContext(rImpGraphic.mbDummyContext)
- , maSvgData(std::move(rImpGraphic.maSvgData))
+ , maVectorGraphicData(std::move(rImpGraphic.maVectorGraphicData))
, maPdfData(std::move(rImpGraphic.maPdfData))
{
rImpGraphic.ImplClear();
@@ -164,12 +164,12 @@ ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) :
{
}
-ImpGraphic::ImpGraphic(const SvgDataPtr& rSvgDataPtr)
-: meType( rSvgDataPtr.get() ? GraphicType::Bitmap : GraphicType::NONE ),
+ImpGraphic::ImpGraphic(const VectorGraphicDataPtr& rVectorGraphicDataPtr)
+: meType( rVectorGraphicDataPtr.get() ? GraphicType::Bitmap : GraphicType::NONE ),
mnSizeBytes( 0UL ),
mbSwapOut( false ),
mbDummyContext ( false ),
- maSvgData(rSvgDataPtr)
+ maVectorGraphicData(rVectorGraphicDataPtr)
{
}
@@ -228,7 +228,7 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic )
if( rImpGraphic.mpGfxLink )
mpGfxLink = o3tl::make_unique<GfxLink>( *rImpGraphic.mpGfxLink );
- maSvgData = rImpGraphic.maSvgData;
+ maVectorGraphicData = rImpGraphic.maVectorGraphicData;
maPdfData = rImpGraphic.maPdfData;
}
@@ -248,7 +248,7 @@ ImpGraphic& ImpGraphic::operator=(ImpGraphic&& rImpGraphic)
mbSwapOut = rImpGraphic.mbSwapOut;
mpSwapFile = std::move(rImpGraphic.mpSwapFile);
mpGfxLink = std::move(rImpGraphic.mpGfxLink);
- maSvgData = std::move(rImpGraphic.maSvgData);
+ maVectorGraphicData = std::move(rImpGraphic.maVectorGraphicData);
maPdfData = std::move(rImpGraphic.maPdfData);
rImpGraphic.ImplClear();
@@ -280,20 +280,20 @@ bool ImpGraphic::operator==( const ImpGraphic& rImpGraphic ) const
case GraphicType::Bitmap:
{
- if(maSvgData.get())
+ if(maVectorGraphicData.get())
{
- if(maSvgData == rImpGraphic.maSvgData)
+ if(maVectorGraphicData == rImpGraphic.maVectorGraphicData)
{
bRet = true;
}
- else if(rImpGraphic.maSvgData)
+ else if(rImpGraphic.maVectorGraphicData)
{
- if(maSvgData->getSvgDataArrayLength() == rImpGraphic.maSvgData->getSvgDataArrayLength())
+ if(maVectorGraphicData->getVectorGraphicDataArrayLength() == rImpGraphic.maVectorGraphicData->getVectorGraphicDataArrayLength())
{
if(0 == memcmp(
- maSvgData->getSvgDataArray().getConstArray(),
- rImpGraphic.maSvgData->getSvgDataArray().getConstArray(),
- maSvgData->getSvgDataArrayLength()))
+ maVectorGraphicData->getVectorGraphicDataArray().getConstArray(),
+ rImpGraphic.maVectorGraphicData->getVectorGraphicDataArray().getConstArray(),
+ maVectorGraphicData->getVectorGraphicDataArrayLength()))
{
bRet = true;
}
@@ -339,7 +339,7 @@ void ImpGraphic::ImplClearGraphics()
maMetaFile.Clear();
mpAnimation.reset();
mpGfxLink.reset();
- maSvgData.reset();
+ maVectorGraphicData.reset();
maPdfData = uno::Sequence<sal_Int8>();
}
@@ -393,7 +393,7 @@ bool ImpGraphic::ImplIsTransparent() const
{
bool bRet(true);
- if( meType == GraphicType::Bitmap && !maSvgData.get())
+ if( meType == GraphicType::Bitmap && !maVectorGraphicData.get())
{
bRet = ( mpAnimation ? mpAnimation->IsTransparent() : maEx.IsTransparent() );
}
@@ -405,7 +405,7 @@ bool ImpGraphic::ImplIsAlpha() const
{
bool bRet(false);
- if(maSvgData.get())
+ if(maVectorGraphicData.get())
{
bRet = true;
}
@@ -435,10 +435,10 @@ Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters)
if( meType == GraphicType::Bitmap )
{
- if(maSvgData.get() && maEx.IsEmpty())
+ if(maVectorGraphicData.get() && maEx.IsEmpty())
{
// use maEx as local buffer for rendered svg
- const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement();
+ const_cast< ImpGraphic* >(this)->maEx = maVectorGraphicData->getReplacement();
}
const BitmapEx& rRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maEx );
@@ -543,10 +543,10 @@ BitmapEx ImpGraphic::ImplGetBitmapEx(const GraphicConversionParameters& rParamet
if( meType == GraphicType::Bitmap )
{
- if(maSvgData.get() && maEx.IsEmpty())
+ if(maVectorGraphicData.get() && maEx.IsEmpty())
{
// use maEx as local buffer for rendered svg
- const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement();
+ const_cast< ImpGraphic* >(this)->maEx = maVectorGraphicData->getReplacement();
}
aRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maEx );
@@ -601,10 +601,10 @@ const GDIMetaFile& ImpGraphic::ImplGetGDIMetaFile() const
// survive copying (change this if not wanted)
ImpGraphic* pThat = const_cast< ImpGraphic* >(this);
- if(maSvgData.get() && !maEx)
+ if(maVectorGraphicData.get() && !maEx)
{
// use maEx as local buffer for rendered svg
- pThat->maEx = maSvgData->getReplacement();
+ pThat->maEx = maVectorGraphicData->getReplacement();
}
// #123983# directly create a metafile with the same PrefSize and PrefMapMode
@@ -643,10 +643,10 @@ Size ImpGraphic::ImplGetPrefSize() const
case GraphicType::Bitmap:
{
- if(maSvgData.get() && maEx.IsEmpty())
+ if(maVectorGraphicData.get() && maEx.IsEmpty())
{
// svg not yet buffered in maEx, return size derived from range
- const basegfx::B2DRange& rRange = maSvgData->getRange();
+ const basegfx::B2DRange& rRange = maVectorGraphicData->getRange();
aSize = Size(basegfx::fround(rRange.getWidth()), basegfx::fround(rRange.getHeight()));
}
@@ -686,10 +686,10 @@ void ImpGraphic::ImplSetPrefSize( const Size& rPrefSize )
{
// used when importing a writer FlyFrame with SVG as graphic, added conversion
// to allow setting the PrefSize at the BitmapEx to hold it
- if(maSvgData.get() && maEx.IsEmpty())
+ if(maVectorGraphicData.get() && maEx.IsEmpty())
{
// use maEx as local buffer for rendered svg
- maEx = maSvgData->getReplacement();
+ maEx = maVectorGraphicData->getReplacement();
}
// #108077# Push through pref size to animation object,
@@ -728,7 +728,7 @@ MapMode ImpGraphic::ImplGetPrefMapMode() const
case GraphicType::Bitmap:
{
- if(maSvgData.get() && maEx.IsEmpty())
+ if(maVectorGraphicData.get() && maEx.IsEmpty())
{
// svg not yet buffered in maEx, return default PrefMapMode
aMapMode = MapMode(MapUnit::Map100thMM);
@@ -765,10 +765,10 @@ void ImpGraphic::ImplSetPrefMapMode( const MapMode& rPrefMapMode )
case GraphicType::Bitmap:
{
- if(maSvgData.get())
+ if(maVectorGraphicData.get())
{
- // ignore for Svg. If this is really used (except the grfcache)
- // it can be extended by using maEx as buffer for maSvgData->getReplacement()
+ // ignore for Vector Graphic Data. If this is really used (except the grfcache)
+ // it can be extended by using maEx as buffer for maVectorGraphicData->getReplacement()
}
else
{
@@ -799,12 +799,12 @@ sal_uLong ImpGraphic::ImplGetSizeBytes() const
{
if( meType == GraphicType::Bitmap )
{
- if(maSvgData.get())
+ if(maVectorGraphicData.get())
{
- std::pair<SvgData::State, size_t> tmp(maSvgData->getSizeBytes());
- if (SvgData::State::UNPARSED == tmp.first)
+ std::pair<VectorGraphicData::State, size_t> tmp(maVectorGraphicData->getSizeBytes());
+ if (VectorGraphicData::State::UNPARSED == tmp.first)
{
- return tmp.second; // don't cache it until SVG is parsed
+ return tmp.second; // don't cache it until Vector Graphic Data is parsed
}
mnSizeBytes = tmp.second;
}
@@ -833,10 +833,10 @@ void ImpGraphic::ImplDraw( OutputDevice* pOutDev, const Point& rDestPt ) const
case GraphicType::Bitmap:
{
- if(maSvgData.get() && !maEx)
+ if(maVectorGraphicData.get() && !maEx)
{
// use maEx as local buffer for rendered svg
- const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement();
+ const_cast< ImpGraphic* >(this)->maEx = maVectorGraphicData->getReplacement();
}
if ( mpAnimation )
@@ -869,10 +869,10 @@ void ImpGraphic::ImplDraw( OutputDevice* pOutDev,
case GraphicType::Bitmap:
{
- if(maSvgData.get() && maEx.IsEmpty())
+ if(maVectorGraphicData.get() && maEx.IsEmpty())
{
// use maEx as local buffer for rendered svg
- const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement();
+ const_cast< ImpGraphic* >(this)->maEx = maVectorGraphicData->getReplacement();
}
if( mpAnimation )
@@ -1004,10 +1004,10 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm )
{
if( meType == GraphicType::Bitmap )
{
- if(maSvgData.get() && maEx.IsEmpty())
+ if(maVectorGraphicData.get() && maEx.IsEmpty())
{
// use maEx as local buffer for rendered svg
- maEx = maSvgData->getReplacement();
+ maEx = maVectorGraphicData->getReplacement();
}
maEx.aBitmapSize = aSize;
@@ -1351,10 +1351,10 @@ BitmapChecksum ImpGraphic::ImplGetChecksum() const
case GraphicType::Bitmap:
{
- if(maSvgData.get() && maEx.IsEmpty())
+ if(maVectorGraphicData.get() && maEx.IsEmpty())
{
// use maEx as local buffer for rendered svg
- const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement();
+ const_cast< ImpGraphic* >(this)->maEx = maVectorGraphicData->getReplacement();
}
if( mpAnimation )
@@ -1520,20 +1520,20 @@ void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
if (nSvgMagic == nMagic)
{
- sal_uInt32 nSvgDataArrayLength(0);
- rIStm.ReadUInt32(nSvgDataArrayLength);
+ sal_uInt32 nVectorGraphicDataArrayLength(0);
+ rIStm.ReadUInt32(nVectorGraphicDataArrayLength);
- if (nSvgDataArrayLength)
+ if (nVectorGraphicDataArrayLength)
{
- SvgDataArray aNewData(nSvgDataArrayLength);
+ VectorGraphicDataArray aNewData(nVectorGraphicDataArrayLength);
- rIStm.ReadBytes(aNewData.getArray(), nSvgDataArrayLength);
+ rIStm.ReadBytes(aNewData.getArray(), nVectorGraphicDataArrayLength);
OUString aPath = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet());
if (!rIStm.GetError())
{
- SvgDataPtr aSvgDataPtr(new SvgData(aNewData, aPath));
- rImpGraphic = aSvgDataPtr;
+ VectorGraphicDataPtr aVectorGraphicDataPtr(new VectorGraphicData(aNewData, aPath, VectorGraphicDataType::Svg));
+ rImpGraphic = aVectorGraphicDataPtr;
}
}
}
@@ -1604,7 +1604,7 @@ void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic)
case GraphicType::Bitmap:
{
- if(rImpGraphic.getSvgData().get())
+ if(rImpGraphic.getVectorGraphicData().get())
{
// stream out Svg defining data (length, byte array and evtl. path)
// this is used e.g. in swapping out graphic data and in transporting it over UNO API
@@ -1613,10 +1613,10 @@ void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic)
const sal_uInt32 nSvgMagic((sal_uInt32('s') << 24) | (sal_uInt32('v') << 16) | (sal_uInt32('g') << 8) | sal_uInt32('0'));
rOStm.WriteUInt32( nSvgMagic );
- rOStm.WriteUInt32( rImpGraphic.getSvgData()->getSvgDataArrayLength() );
- rOStm.WriteBytes(rImpGraphic.getSvgData()->getSvgDataArray().getConstArray(),
- rImpGraphic.getSvgData()->getSvgDataArrayLength());
- rOStm.WriteUniOrByteString(rImpGraphic.getSvgData()->getPath(),
+ rOStm.WriteUInt32( rImpGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength() );
+ rOStm.WriteBytes(rImpGraphic.getVectorGraphicData()->getVectorGraphicDataArray().getConstArray(),
+ rImpGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength());
+ rOStm.WriteUniOrByteString(rImpGraphic.getVectorGraphicData()->getPath(),
rOStm.GetStreamCharSet());
}
else if (rImpGraphic.maPdfData.hasElements())
diff --git a/vcl/source/gdi/svgdata.cxx b/vcl/source/gdi/vectorgraphicdata.cxx
index d15e56aa494a..bb18ccc925bf 100644
--- a/vcl/source/gdi/svgdata.cxx
+++ b/vcl/source/gdi/vectorgraphicdata.cxx
@@ -18,10 +18,11 @@
*/
#include <tools/stream.hxx>
-#include <vcl/svgdata.hxx>
+#include <vcl/vectorgraphicdata.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/graphic/SvgTools.hpp>
+#include <com/sun/star/graphic/EmfTools.hpp>
#include <com/sun/star/graphic/Primitive2DTools.hpp>
#include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp>
#include <com/sun/star/util/XAccounting.hpp>
@@ -105,7 +106,7 @@ size_t estimateSize(
return nRet;
}
-void SvgData::ensureReplacement()
+void VectorGraphicData::ensureReplacement()
{
ensureSequenceAndRange();
@@ -115,15 +116,15 @@ void SvgData::ensureReplacement()
}
}
-void SvgData::ensureSequenceAndRange()
+void VectorGraphicData::ensureSequenceAndRange()
{
- if(maSequence.empty() && maSvgDataArray.hasElements())
+ if(maSequence.empty() && maVectorGraphicDataArray.hasElements())
{
// import SVG to maSequence, also set maRange
maRange.reset();
// create stream
- const uno::Reference< io::XInputStream > myInputStream(new comphelper::SequenceInputStream(maSvgDataArray));
+ const uno::Reference< io::XInputStream > myInputStream(new comphelper::SequenceInputStream(maVectorGraphicDataArray));
if(myInputStream.is())
{
@@ -131,9 +132,19 @@ void SvgData::ensureSequenceAndRange()
try
{
uno::Reference<uno::XComponentContext> xContext(::comphelper::getProcessComponentContext());
- const uno::Reference< graphic::XSvgParser > xSvgParser = graphic::SvgTools::create(xContext);
- maSequence = comphelper::sequenceToContainer<std::deque<css::uno::Reference< css::graphic::XPrimitive2D >>>(xSvgParser->getDecomposition(myInputStream, maPath));
+ if (VectorGraphicDataType::Emf == getVectorGraphicDataType())
+ {
+ const uno::Reference< graphic::XEmfParser > xEmfParser = graphic::EmfTools::create(xContext);
+
+ maSequence = comphelper::sequenceToContainer<std::deque<css::uno::Reference< css::graphic::XPrimitive2D >>>(xEmfParser->getDecomposition(myInputStream, maPath));
+ }
+ else
+ {
+ const uno::Reference< graphic::XSvgParser > xSvgParser = graphic::SvgTools::create(xContext);
+
+ maSequence = comphelper::sequenceToContainer<std::deque<css::uno::Reference< css::graphic::XPrimitive2D >>>(xSvgParser->getDecomposition(myInputStream, maPath));
+ }
}
catch(const uno::Exception&)
{
@@ -169,35 +180,42 @@ void SvgData::ensureSequenceAndRange()
}
}
-auto SvgData::getSizeBytes() -> std::pair<State, size_t>
+auto VectorGraphicData::getSizeBytes() -> std::pair<State, size_t>
{
- if (maSequence.empty() && maSvgDataArray.hasElements())
+ if (maSequence.empty() && maVectorGraphicDataArray.hasElements())
{
- return std::make_pair(State::UNPARSED, maSvgDataArray.getLength());
+ return std::make_pair(State::UNPARSED, maVectorGraphicDataArray.getLength());
}
else
{
- return std::make_pair(State::PARSED, maSvgDataArray.getLength() + mNestedBitmapSize);
+ return std::make_pair(State::PARSED, maVectorGraphicDataArray.getLength() + mNestedBitmapSize);
}
}
-SvgData::SvgData(const SvgDataArray& rSvgDataArray, const OUString& rPath)
-: maSvgDataArray(rSvgDataArray),
+VectorGraphicData::VectorGraphicData(
+ const VectorGraphicDataArray& rVectorGraphicDataArray,
+ const OUString& rPath,
+ VectorGraphicDataType eVectorDataType)
+: maVectorGraphicDataArray(rVectorGraphicDataArray),
maPath(rPath),
maRange(),
maSequence(),
- maReplacement()
-, mNestedBitmapSize(0)
+ maReplacement(),
+ mNestedBitmapSize(0),
+ meVectorGraphicDataType(eVectorDataType)
{
}
-SvgData::SvgData(const OUString& rPath):
- maSvgDataArray(),
+VectorGraphicData::VectorGraphicData(
+ const OUString& rPath,
+ VectorGraphicDataType eVectorDataType)
+: maVectorGraphicDataArray(),
maPath(rPath),
maRange(),
maSequence(),
- maReplacement()
-, mNestedBitmapSize(0)
+ maReplacement(),
+ mNestedBitmapSize(0),
+ meVectorGraphicDataType(eVectorDataType)
{
SvFileStream rIStm(rPath, StreamMode::STD_READ);
if(rIStm.GetError())
@@ -205,33 +223,33 @@ SvgData::SvgData(const OUString& rPath):
const sal_uInt32 nStmLen(rIStm.remainingSize());
if (nStmLen)
{
- maSvgDataArray.realloc(nStmLen);
- rIStm.ReadBytes(maSvgDataArray.begin(), nStmLen);
+ maVectorGraphicDataArray.realloc(nStmLen);
+ rIStm.ReadBytes(maVectorGraphicDataArray.begin(), nStmLen);
if (rIStm.GetError())
{
- maSvgDataArray = SvgDataArray();
+ maVectorGraphicDataArray = VectorGraphicDataArray();
}
}
}
-const basegfx::B2DRange& SvgData::getRange() const
+const basegfx::B2DRange& VectorGraphicData::getRange() const
{
- const_cast< SvgData* >(this)->ensureSequenceAndRange();
+ const_cast< VectorGraphicData* >(this)->ensureSequenceAndRange();
return maRange;
}
-const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& SvgData::getPrimitive2DSequence() const
+const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& VectorGraphicData::getPrimitive2DSequence() const
{
- const_cast< SvgData* >(this)->ensureSequenceAndRange();
+ const_cast< VectorGraphicData* >(this)->ensureSequenceAndRange();
return maSequence;
}
-const BitmapEx& SvgData::getReplacement() const
+const BitmapEx& VectorGraphicData::getReplacement() const
{
- const_cast< SvgData* >(this)->ensureReplacement();
+ const_cast< VectorGraphicData* >(this)->ensureReplacement();
return maReplacement;
}