From 78c83032b266fbb6fc20ddca86df80affaff7c24 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 30 Sep 2015 09:40:16 +0100 Subject: maSvgDataArray only populates a uno::Sequence, so use that instead Change-Id: I335d5ee70e95e1a3b204d34f6df4cb62f3fb3cad --- vcl/source/filter/graphicfilter.cxx | 16 ++++++++-------- vcl/source/gdi/impgraph.cxx | 16 +++++++--------- vcl/source/gdi/svgdata.cxx | 20 ++++++++------------ 3 files changed, 23 insertions(+), 29 deletions(-) (limited to 'vcl') diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 7d79078450ca..49f3b65eeaae 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -1533,18 +1533,18 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPat if (!rIStream.GetError() && nMemoryLength >= 0) { - SvgDataArray aNewData(new sal_uInt8[nMemoryLength]); + SvgDataArray aNewData(nMemoryLength); aMemStream.Seek(STREAM_SEEK_TO_BEGIN); - aMemStream.Read(aNewData.get(), nMemoryLength); + aMemStream.Read(aNewData.begin(), nMemoryLength); // Make a uncompressed copy for GfxLink nGraphicContentSize = nMemoryLength; pGraphicContent = new sal_uInt8[nGraphicContentSize]; - std::copy(aNewData.get(), aNewData.get() + nMemoryLength, pGraphicContent); + std::copy(aNewData.begin(), aNewData.end(), pGraphicContent); if(!aMemStream.GetError() ) { - SvgDataPtr aSvgDataPtr(new SvgData(aNewData, nMemoryLength, rPath)); + SvgDataPtr aSvgDataPtr(new SvgData(aNewData, rPath)); rGraphic = Graphic(aSvgDataPtr); bOkay = true; } @@ -1552,20 +1552,20 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPat } else { - SvgDataArray aNewData(new sal_uInt8[nStreamLength]); + SvgDataArray aNewData(nStreamLength); rIStream.Seek(nStreamPosition); - rIStream.Read(aNewData.get(), nStreamLength); + rIStream.Read(aNewData.begin(), nStreamLength); if(!rIStream.GetError()) { - SvgDataPtr aSvgDataPtr(new SvgData(aNewData, nStreamLength, rPath)); + SvgDataPtr aSvgDataPtr(new SvgData(aNewData, rPath)); rGraphic = Graphic(aSvgDataPtr); bOkay = true; } } } - if(bOkay) + if (bOkay) { eLinkType = GFX_LINK_TYPE_NATIVE_SVG; } diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 4050efe38fc0..735eab157792 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -1542,23 +1542,21 @@ SvStream& ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic ) } else { - sal_uInt32 mnSvgDataArrayLength(0); - rIStm.ReadUInt32( mnSvgDataArrayLength ); + sal_uInt32 nSvgDataArrayLength(0); + rIStm.ReadUInt32(nSvgDataArrayLength); - if(mnSvgDataArrayLength) + if (nSvgDataArrayLength) { - SvgDataArray aNewData(new sal_uInt8[mnSvgDataArrayLength]); - OUString aPath; + SvgDataArray aNewData(nSvgDataArrayLength); - rIStm.Read(aNewData.get(), mnSvgDataArrayLength); - aPath = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet()); + rIStm.Read(aNewData.begin(), nSvgDataArrayLength); + OUString aPath = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet()); - if(!rIStm.GetError()) + if (!rIStm.GetError()) { SvgDataPtr aSvgDataPtr( new SvgData( aNewData, - mnSvgDataArrayLength, OUString(aPath))); rImpGraphic = aSvgDataPtr; diff --git a/vcl/source/gdi/svgdata.cxx b/vcl/source/gdi/svgdata.cxx index d86fc8dbcef5..cd1614e6328c 100644 --- a/vcl/source/gdi/svgdata.cxx +++ b/vcl/source/gdi/svgdata.cxx @@ -99,14 +99,13 @@ void SvgData::ensureReplacement() void SvgData::ensureSequenceAndRange() { - if(!maSequence.hasElements() && mnSvgDataArrayLength) + if(!maSequence.hasElements() && maSvgDataArray.hasElements()) { // import SVG to maSequence, also set maRange maRange.reset(); // create stream - const uno::Sequence< sal_Int8 > aPostData(reinterpret_cast(maSvgDataArray.get()), mnSvgDataArrayLength); - const uno::Reference< io::XInputStream > myInputStream(new comphelper::SequenceInputStream(aPostData)); + const uno::Reference< io::XInputStream > myInputStream(new comphelper::SequenceInputStream(maSvgDataArray)); if(myInputStream.is()) { @@ -152,9 +151,8 @@ void SvgData::ensureSequenceAndRange() } } -SvgData::SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength, const OUString& rPath) +SvgData::SvgData(const SvgDataArray& rSvgDataArray, const OUString& rPath) : maSvgDataArray(rSvgDataArray), - mnSvgDataArrayLength(nSvgDataArrayLength), maPath(rPath), maRange(), maSequence(), @@ -164,7 +162,6 @@ SvgData::SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLeng SvgData::SvgData(const OUString& rPath): maSvgDataArray(), - mnSvgDataArrayLength(0), maPath(rPath), maRange(), maSequence(), @@ -174,15 +171,14 @@ SvgData::SvgData(const OUString& rPath): if(rIStm.GetError()) return; const sal_uInt32 nStmLen(rIStm.remainingSize()); - if(nStmLen) + if (nStmLen) { - SvgDataArray aNewData(new sal_uInt8[nStmLen]); - rIStm.Read(aNewData.get(), nStmLen); + maSvgDataArray.realloc(nStmLen); + rIStm.Read(maSvgDataArray.begin(), nStmLen); - if(!rIStm.GetError()) + if (rIStm.GetError()) { - maSvgDataArray = aNewData; - mnSvgDataArrayLength = nStmLen; + maSvgDataArray = SvgDataArray(); } } } -- cgit