summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lotuswordpro/source/filter/bencont.cxx18
-rw-r--r--lotuswordpro/source/filter/bento.hxx2
-rw-r--r--lotuswordpro/source/filter/lwpgrfobj.cxx25
3 files changed, 15 insertions, 30 deletions
diff --git a/lotuswordpro/source/filter/bencont.cxx b/lotuswordpro/source/filter/bencont.cxx
index 71eda29213bd..c4125971d089 100644
--- a/lotuswordpro/source/filter/bencont.cxx
+++ b/lotuswordpro/source/filter/bencont.cxx
@@ -267,11 +267,12 @@ sal_uInt64 GetSvStreamSize(SvStream * pStream)
* Find hazily according to object ID
* @param pObjectname - format as "GrXX,XXXXXXXX" wherein XX is high part of object ID, and XXXXXXXX is low part
*/
-SvMemoryStream* LtcBenContainer::CreateGraphicStream(const char *pObjectName)
+std::vector<sal_uInt8> LtcBenContainer::GetGraphicData(const char *pObjectName)
{
+ std::vector<sal_uInt8> aData;
if (!pObjectName)
{
- return nullptr;
+ return aData;
}
// construct the string of property name
char sSName[64]="";
@@ -300,12 +301,11 @@ SvMemoryStream* LtcBenContainer::CreateGraphicStream(const char *pObjectName)
// the 'D' stream is NULL or it has invalid length
if (nLen <= 0)
{
- return nullptr;
+ return aData;
}
- char * pBuf = new char[nLen];
- assert(pBuf != nullptr);
- char * pPointer = pBuf;
+ aData.resize(nLen);
+ sal_uInt8* pPointer = aData.data();
if (xD)
{
xD->ReadBytes(pPointer, nDLen);
@@ -318,11 +318,7 @@ SvMemoryStream* LtcBenContainer::CreateGraphicStream(const char *pObjectName)
xS.reset();
}
- SvMemoryStream* pMemStream = new SvMemoryStream(pBuf, nLen, StreamMode::READ);
- assert(pMemStream != nullptr);
- pMemStream->ObjectOwnsMemory(true);
-
- return pMemStream;
+ return aData;
}
sal_uLong LtcBenContainer::remainingSize() const
diff --git a/lotuswordpro/source/filter/bento.hxx b/lotuswordpro/source/filter/bento.hxx
index f1cd48b4abae..4608b9b21996 100644
--- a/lotuswordpro/source/filter/bento.hxx
+++ b/lotuswordpro/source/filter/bento.hxx
@@ -221,7 +221,7 @@ public: // Internal methods
LtcUtBenValueStream * FindNextValueStreamWithPropertyName(const char * sPropertyName);
LtcUtBenValueStream * FindValueStreamWithPropertyName(const char * sPropertyName);
- SvMemoryStream* CreateGraphicStream(const char *pObjectName);
+ std::vector<sal_uInt8> GetGraphicData(const char *pObjectName);
sal_uLong GetSize() const { return m_ulLength; }
private: // Data
diff --git a/lotuswordpro/source/filter/lwpgrfobj.cxx b/lotuswordpro/source/filter/lwpgrfobj.cxx
index 30431b7a1bb3..f0e355125249 100644
--- a/lotuswordpro/source/filter/lwpgrfobj.cxx
+++ b/lotuswordpro/source/filter/lwpgrfobj.cxx
@@ -302,14 +302,13 @@ void LwpGraphicObject::CreateDrawObjects()
GetBentoNamebyID(rMyID, aGrfObjName);
// get bento stream by the name
- SvStream* pDrawObjStream = pBentoContainer->CreateGraphicStream(aGrfObjName.c_str());
- if (pDrawObjStream)
+ std::vector<sal_uInt8> aData = pBentoContainer->GetGraphicData(aGrfObjName.c_str());
+ if (!aData.empty())
{
- LwpSdwFileLoader fileLoader(pDrawObjStream, this);
- fileLoader.CreateDrawObjects(&m_vXFDrawObjects);
+ SvMemoryStream aDrawObjStream(aData.data(), aData.size(), StreamMode::READ);
- delete pDrawObjStream;
- pDrawObjStream = nullptr;
+ LwpSdwFileLoader fileLoader(&aDrawObjStream, this);
+ fileLoader.CreateDrawObjects(&m_vXFDrawObjects);
}
}
@@ -352,18 +351,8 @@ std::vector<sal_uInt8> LwpGraphicObject::GetRawGrafData()
std::string aGrfObjName;
GetBentoNamebyID(rMyID, aGrfObjName);
- // get bento stream by the name
- SvMemoryStream* pMemGrafStream = pBentoContainer->CreateGraphicStream(aGrfObjName.c_str());
- if (pMemGrafStream)
- {
- // read image data
- aGrafData.resize(pMemGrafStream->GetEndOfData());
- pMemGrafStream->ReadBytes(aGrafData.data(), aGrafData.size());
-
- delete pMemGrafStream;
- }
-
- return aGrafData;
+ // get bento stream by the name and read image data
+ return pBentoContainer->GetGraphicData(aGrfObjName.c_str());
}
/**