diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-01-20 21:03:31 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-01-21 21:15:34 +0100 |
commit | 398b0195b7833ca8fab29a600954c84527b25cf9 (patch) | |
tree | 0206b0743498386e2d5dac051cc9ab15715ac5cb | |
parent | just return SvMemoryStream* (diff) | |
download | core-398b0195b7833ca8fab29a600954c84527b25cf9.tar.gz core-398b0195b7833ca8fab29a600954c84527b25cf9.zip |
just return a vector
Change-Id: Id6a75dee04c836ca28299dc6b3ab0b93361684c4
Reviewed-on: https://gerrit.libreoffice.org/48256
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | lotuswordpro/source/filter/lwpgrfobj.cxx | 31 | ||||
-rw-r--r-- | lotuswordpro/source/filter/lwpgrfobj.hxx | 2 | ||||
-rw-r--r-- | lotuswordpro/source/filter/lwplayout.cxx | 10 |
3 files changed, 13 insertions, 30 deletions
diff --git a/lotuswordpro/source/filter/lwpgrfobj.cxx b/lotuswordpro/source/filter/lwpgrfobj.cxx index 5731b34acdff..30431b7a1bb3 100644 --- a/lotuswordpro/source/filter/lwpgrfobj.cxx +++ b/lotuswordpro/source/filter/lwpgrfobj.cxx @@ -225,17 +225,8 @@ void LwpGraphicObject::XFConvert (XFContentContainer* pCont) } else { - sal_uInt8* pGrafData = nullptr; - sal_uInt32 nDataLen = GetRawGrafData(pGrafData); - - if (pGrafData) - { - pImage->SetImageData(pGrafData, nDataLen); - - // delete used image data - delete [] pGrafData; - pGrafData = nullptr; - } + std::vector<sal_uInt8> aGrafData = GetRawGrafData(); + pImage->SetImageData(aGrafData.data(), aGrafData.size()); } pCont->Add(pImage); @@ -337,11 +328,12 @@ void LwpGraphicObject::GetBentoNamebyID(LwpObjectID const & rMyID, std::string& /** * @descr get the image data read from bento stream according to the VO_GRAPHIC ID. - * @param pGrafData the array to store the image data. the pointer need to be deleted outside. - * @return the length of the image data. + * @return the image data. */ -sal_uInt32 LwpGraphicObject::GetRawGrafData(sal_uInt8*& pGrafData) +std::vector<sal_uInt8> LwpGraphicObject::GetRawGrafData() { + std::vector<sal_uInt8> aGrafData; + // create graphic object // if small file, use the compressed stream for BENTO LwpSvStream* pStream = m_pStrm->GetCompressedStream() ? m_pStrm->GetCompressedStream(): m_pStrm; @@ -352,7 +344,7 @@ sal_uInt32 LwpGraphicObject::GetRawGrafData(sal_uInt8*& pGrafData) sal_uLong ulRet = OpenStormBento::BenOpenContainer(pStream, &pTmp); pBentoContainer.reset(pTmp); if (ulRet != OpenStormBento::BenErr_OK) - return 0; + return aGrafData; } // get graphic object's bento object name @@ -365,16 +357,13 @@ sal_uInt32 LwpGraphicObject::GetRawGrafData(sal_uInt8*& pGrafData) if (pMemGrafStream) { // read image data - sal_uInt32 nDataLen = pMemGrafStream->GetEndOfData(); - pGrafData = new sal_uInt8 [nDataLen]; - pMemGrafStream->ReadBytes(pGrafData, nDataLen); + aGrafData.resize(pMemGrafStream->GetEndOfData()); + pMemGrafStream->ReadBytes(aGrafData.data(), aGrafData.size()); delete pMemGrafStream; - - return nDataLen; } - return 0; + return aGrafData; } /** diff --git a/lotuswordpro/source/filter/lwpgrfobj.hxx b/lotuswordpro/source/filter/lwpgrfobj.hxx index 03d017a74a4d..726d8ec049cc 100644 --- a/lotuswordpro/source/filter/lwpgrfobj.hxx +++ b/lotuswordpro/source/filter/lwpgrfobj.hxx @@ -118,7 +118,7 @@ public: void CreateDrawObjects(); void CreateGrafObject(); static void GetBentoNamebyID(LwpObjectID const & rMyID, std::string& rName); - sal_uInt32 GetRawGrafData(sal_uInt8*& pGrafData); + std::vector<sal_uInt8> GetRawGrafData(); sal_uInt32 GetGrafData(sal_uInt8*& pGrafData); void GetGrafOrgSize(long& rWidth, long& rHeight) { rWidth = m_Cache.Width; rHeight = m_Cache.Height; } void GetGrafOrgSize(double& rWidth, double& rHeight) override; diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx index 00ab92c6a4b3..73f0c3114640 100644 --- a/lotuswordpro/source/filter/lwplayout.cxx +++ b/lotuswordpro/source/filter/lwplayout.cxx @@ -1364,14 +1364,8 @@ XFBGImage* LwpMiddleLayout::GetXFBGImage() } else { - sal_uInt8* pGrafData = nullptr; - sal_uInt32 nDataLen = pGrfObj->GetRawGrafData(pGrafData); - pXFBGImage->SetImageData(pGrafData, nDataLen); - if(pGrafData) - { - delete[] pGrafData; - pGrafData = nullptr; - } + std::vector<sal_uInt8> aGrafData = pGrfObj->GetRawGrafData(); + pXFBGImage->SetImageData(aGrafData.data(), aGrafData.size()); } //automatic, top left |