[Libreoffice-commits] .: Branch 'libreoffice-3-4' - lotuswordpro/source lotuswordpro/util
Caolán McNamara
caolan at kemper.freedesktop.org
Tue Apr 12 03:25:44 PDT 2011
lotuswordpro/source/filter/LotusWordProImportFilter.cxx | 47 +--
lotuswordpro/source/filter/benlist.cxx | 5
lotuswordpro/source/filter/lwp9reader.cxx | 33 +-
lotuswordpro/source/filter/lwpbulletstylemgr.cxx | 6
lotuswordpro/source/filter/lwpcelllayout.cxx | 37 --
lotuswordpro/source/filter/lwpchangemgr.cxx | 40 --
lotuswordpro/source/filter/lwpchartstreamtools.cxx | 6
lotuswordpro/source/filter/lwpcontent.hxx | 2
lotuswordpro/source/filter/lwpdivinfo.hxx | 2
lotuswordpro/source/filter/lwpdoc.cxx | 98 +++---
lotuswordpro/source/filter/lwpdoc.hxx | 4
lotuswordpro/source/filter/lwpfilter.cxx | 94 ++----
lotuswordpro/source/filter/lwpfilter.hxx | 3
lotuswordpro/source/filter/lwpfont.cxx | 17 -
lotuswordpro/source/filter/lwpfootnote.cxx | 10
lotuswordpro/source/filter/lwpfoundry.cxx | 15 -
lotuswordpro/source/filter/lwpfoundry.hxx | 1
lotuswordpro/source/filter/lwpframelayout.cxx | 15 -
lotuswordpro/source/filter/lwpfrib.cxx | 36 +-
lotuswordpro/source/filter/lwpfribframe.cxx | 27 +
lotuswordpro/source/filter/lwpfribmark.cxx | 10
lotuswordpro/source/filter/lwpfribptr.cxx | 30 --
lotuswordpro/source/filter/lwpgrfobj.cxx | 48 ---
lotuswordpro/source/filter/lwpidxmgr.cxx | 25 +
lotuswordpro/source/filter/lwplayout.cxx | 240 ++++++++--------
lotuswordpro/source/filter/lwplayout.hxx | 2
lotuswordpro/source/filter/lwpmarker.cxx | 5
lotuswordpro/source/filter/lwpmarker.hxx | 1
lotuswordpro/source/filter/lwpobjfactory.cxx | 54 +--
lotuswordpro/source/filter/lwpobjfactory.hxx | 4
lotuswordpro/source/filter/lwpobjhdr.cxx | 7
lotuswordpro/source/filter/lwpobjhdr.hxx | 2
lotuswordpro/source/filter/lwpobjstrm.cxx | 21 +
lotuswordpro/source/filter/lwpoverride.cxx | 2
lotuswordpro/source/filter/lwppagelayout.cxx | 42 +-
lotuswordpro/source/filter/lwppara.cxx | 36 --
lotuswordpro/source/filter/lwppara.hxx | 2
lotuswordpro/source/filter/lwppara1.cxx | 118 +------
lotuswordpro/source/filter/lwpparaproperty.cxx | 86 ++---
lotuswordpro/source/filter/lwpparastyle.cxx | 116 ++++---
lotuswordpro/source/filter/lwprowlayout.cxx | 18 -
lotuswordpro/source/filter/lwprowlayout.hxx | 2
lotuswordpro/source/filter/lwpsection.hxx | 2
lotuswordpro/source/filter/lwpsilverbullet.cxx | 20 +
lotuswordpro/source/filter/lwpstory.cxx | 67 ++--
lotuswordpro/source/filter/lwptable.cxx | 4
lotuswordpro/source/filter/lwptablelayout.cxx | 40 +-
lotuswordpro/source/filter/lwptabrack.cxx | 2
lotuswordpro/source/filter/lwptoc.cxx | 8
lotuswordpro/source/filter/lwptools.hxx | 13
lotuswordpro/source/filter/utlist.cxx | 7
lotuswordpro/source/filter/utlist.hxx | 5
lotuswordpro/source/filter/xfilter/xfimage.cxx | 2
lotuswordpro/source/filter/xfilter/xfsaxstream.cxx | 15 -
lotuswordpro/util/makefile.mk | 8
55 files changed, 751 insertions(+), 811 deletions(-)
New commits:
commit 3fbdebc686d5c2369f42d4e62a23e52d60d7ce7d
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Apr 11 21:19:54 2011 +0100
fix what there is to fix
(cherry picked from commit 278831e37a23e9e2e29ca811c3a5398b7c67464d)
diff --git a/lotuswordpro/source/filter/LotusWordProImportFilter.cxx b/lotuswordpro/source/filter/LotusWordProImportFilter.cxx
index b32888a..d7aa6f8 100644
--- a/lotuswordpro/source/filter/LotusWordProImportFilter.cxx
+++ b/lotuswordpro/source/filter/LotusWordProImportFilter.cxx
@@ -256,23 +256,13 @@ sal_Bool SAL_CALL LotusWordProImportFilter::importImpl( const Sequence< ::com::s
sal_Int32 nLength = aDescriptor.getLength();
const PropertyValue * pValue = aDescriptor.getConstArray();
OUString sURL;
- uno::Reference < XInputStream > xInputStream;
for ( sal_Int32 i = 0 ; i < nLength; i++)
{
- if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "InputStream" ) ) )
- pValue[i].Value >>= xInputStream;
- else if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "URL" ) ) )
- pValue[i].Value >>= sURL;
- }
- if ( !xInputStream.is() )
- {
- OSL_ASSERT( 0 );
- return sal_False;
+ //Note, we should attempt to use InputStream here first!
+ if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "URL" ) ) )
+ pValue[i].Value >>= sURL;
}
- OString sFileName;
- sFileName = OUStringToOString(sURL, RTL_TEXTENCODING_INFO_ASCII);
-
SvFileStream inputStream( sURL, STREAM_READ );
if ( inputStream.IsEof() || ( inputStream.GetError() != SVSTREAM_OK ) )
return sal_False;
@@ -282,13 +272,10 @@ sal_Bool SAL_CALL LotusWordProImportFilter::importImpl( const Sequence< ::com::s
uno::Reference< XDocumentHandler > xInternalHandler( mxMSF->createInstance( sXMLImportService ), UNO_QUERY );
uno::Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
+ if (xImporter.is())
xImporter->setTargetDocument(mxDoc);
-/*
- SimpleXMLImporter xmlImporter( xInternalHandler, inputStream );
- xmlImporter.import();
- return sal_True;
-*/
- return ( ReadWordproFile( &inputStream, xInternalHandler) == 0 );
+
+ return ( ReadWordproFile( inputStream, xInternalHandler) == 0 );
}
@@ -333,18 +320,18 @@ OUString SAL_CALL LotusWordProImportFilter::detect( com::sun::star::uno::Sequenc
uno::Reference< com::sun::star::ucb::XCommandEnvironment > xEnv;
if (!xInputStream.is())
{
- try
- {
- ::ucbhelper::Content aContent(sURL, xEnv);
- xInputStream = aContent.openStream();
- }
- catch ( Exception& )
- {
- return ::rtl::OUString();
- }
+ try
+ {
+ ::ucbhelper::Content aContent(sURL, xEnv);
+ xInputStream = aContent.openStream();
+ }
+ catch ( Exception& )
+ {
+ return ::rtl::OUString();
+ }
- if (!xInputStream.is())
- return ::rtl::OUString();
+ if (!xInputStream.is())
+ return ::rtl::OUString();
}
Sequence< ::sal_Int8 > aData;
diff --git a/lotuswordpro/source/filter/benlist.cxx b/lotuswordpro/source/filter/benlist.cxx
index 506bb8f..c2ec123 100644
--- a/lotuswordpro/source/filter/benlist.cxx
+++ b/lotuswordpro/source/filter/benlist.cxx
@@ -68,14 +68,9 @@ FindNamedObject(pCUtList pList, const char * sName,
pCBenNamedObjectListElmt pCurrNamedObjectListElmt =
(pCBenNamedObjectListElmt) pCurr;
-
- //Old code
-// int Comp = strcmp(sName, pCurrNamedObjectListElmt->GetNamedObject()->
-// GetName());
int Comp = strcmp(sName, pCurrNamedObjectListElmt->GetNamedObject()->
GetNameCStr());
-
if (Comp == 0)
return pCurrNamedObjectListElmt->GetNamedObject();
else if (Comp < 0)
diff --git a/lotuswordpro/source/filter/lwp9reader.cxx b/lotuswordpro/source/filter/lwp9reader.cxx
index ac9ca62..5cbce8d 100644
--- a/lotuswordpro/source/filter/lwp9reader.cxx
+++ b/lotuswordpro/source/filter/lwp9reader.cxx
@@ -77,18 +77,22 @@ Lwp9Reader::Lwp9Reader (LwpSvStream* pInputStream, IXFStream* pStream)
void Lwp9Reader::Read()
{
LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance(m_pDocStream);
- m_pObjMgr = pGlobal->GetLwpObjFactory();
-
- //Commented out by , 10/26/2005
- //Read Ole object in LwpOleObject::XFConverter to support Ole in Linux
- //ReadOleObjects();
+ try
+ {
+ m_pObjMgr = pGlobal->GetLwpObjFactory();
- ReadFileHeader();
- //Does not support Word Pro 96 and previous versions
- if(LwpFileHeader::m_nFileRevision>=0x000B)
+ ReadFileHeader();
+ //Does not support Word Pro 96 and previous versions
+ if(LwpFileHeader::m_nFileRevision>=0x000B)
+ {
+ ReadIndex();
+ ParseDocument();
+ }
+ }
+ catch(...)
{
- ReadIndex();
- ParseDocument();
+ LwpGlobalMgr::DeleteInstance();
+ throw;
}
LwpGlobalMgr::DeleteInstance();
}
@@ -181,14 +185,15 @@ void Lwp9Reader::ParseDocument()
WriteDocHeader();
//Get root document
- LwpDocument* doc = static_cast<LwpDocument*> ( m_LwpFileHdr.GetDocID()->obj() );
+ LwpDocument* doc = dynamic_cast<LwpDocument*> ( m_LwpFileHdr.GetDocID()->obj() );
+
+ if (!doc)
+ return;
//Parse Doc Data
- LwpDocData *pDocData = static_cast<LwpDocData*>((doc->GetDocData())->obj());
+ LwpDocData *pDocData = dynamic_cast<LwpDocData*>((doc->GetDocData())->obj());
if (pDocData!=NULL)
- {
pDocData->Parse(m_pStream);
- }
//Register Styles
RegisteArrowStyles();
diff --git a/lotuswordpro/source/filter/lwpbulletstylemgr.cxx b/lotuswordpro/source/filter/lwpbulletstylemgr.cxx
index 08304de..4fc74cd 100644
--- a/lotuswordpro/source/filter/lwpbulletstylemgr.cxx
+++ b/lotuswordpro/source/filter/lwpbulletstylemgr.cxx
@@ -547,7 +547,9 @@ rtl::OUString LwpBulletStyleMgr::GetDivisionName()
LwpObjectID* pID = pDoc->GetDivInfoID();
if (!pID->IsNull())
{
- aRet = static_cast<LwpDivInfo*>(pID->obj(VO_DIVISIONINFO))->GetDivName();
+ LwpDivInfo *pInfo = dynamic_cast<LwpDivInfo*>(pID->obj(VO_DIVISIONINFO));
+ if (pInfo)
+ aRet = pInfo->GetDivName();
}
}
@@ -562,7 +564,7 @@ rtl::OUString LwpBulletStyleMgr::GetSectionName(LwpPara* pPara)
return rtl::OUString();
}
- LwpStory* pStory = static_cast<LwpStory*>(pStoryID->obj(VO_STORY));
+ LwpStory* pStory = dynamic_cast<LwpStory*>(pStoryID->obj(VO_STORY));
if (!pStory)
{
return rtl::OUString();
diff --git a/lotuswordpro/source/filter/lwpcelllayout.cxx b/lotuswordpro/source/filter/lwpcelllayout.cxx
index 9c10b6d..434cd32 100644
--- a/lotuswordpro/source/filter/lwpcelllayout.cxx
+++ b/lotuswordpro/source/filter/lwpcelllayout.cxx
@@ -91,7 +91,7 @@ LwpCellLayout::~LwpCellLayout()
*/
LwpTableLayout * LwpCellLayout::GetTableLayout()
{
- LwpRowLayout * pRow = static_cast<LwpRowLayout *>(GetParent()->obj());
+ LwpRowLayout * pRow = dynamic_cast<LwpRowLayout *>(GetParent()->obj());
if(!pRow)
{
return NULL;
@@ -265,14 +265,14 @@ void LwpCellLayout::ApplyBackColor(XFCellStyle *pCellStyle)
*/
void LwpCellLayout::ApplyFmtStyle(XFCellStyle *pCellStyle)
{
- LwpLayoutNumerics* pLayoutNumerics =(LwpLayoutNumerics*)cLayNumerics.obj();
+ LwpLayoutNumerics* pLayoutNumerics = dynamic_cast<LwpLayoutNumerics*>(cLayNumerics.obj());
if (!pLayoutNumerics)
{
// if current layout doesn't have format, go to based on layout
- LwpCellLayout* pCellLayout = (LwpCellLayout*)m_BasedOnStyle.obj();
+ LwpCellLayout* pCellLayout = dynamic_cast<LwpCellLayout*>(m_BasedOnStyle.obj());
if (pCellLayout)
{
- pLayoutNumerics = (LwpLayoutNumerics*)pCellLayout->GetNumericsObject()->obj();
+ pLayoutNumerics = dynamic_cast<LwpLayoutNumerics*>(pCellLayout->GetNumericsObject()->obj());
}
}
@@ -314,7 +314,7 @@ XFCell* LwpCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uI
{
// if cell layout is aTableID's default cell layout
// it can't have any content, bypass these code
- LwpTable * pTable = static_cast<LwpTable *>(aTableID.obj());
+ LwpTable * pTable = dynamic_cast<LwpTable *>(aTableID.obj());
if (!pTable)
{
assert(sal_False);
@@ -331,7 +331,7 @@ XFCell* LwpCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uI
}
// content of cell
- LwpStory* pStory =(LwpStory*) m_Content.obj();
+ LwpStory* pStory = dynamic_cast<LwpStory*>(m_Content.obj());
if (pStory)
{
pStory->XFConvert(pXFCell);
@@ -347,8 +347,8 @@ LwpPara* LwpCellLayout::GetLastParaOfPreviousStory()
LwpObjectID* pPreStoryID = this->GetPreviousCellStory();
if (pPreStoryID && !(pPreStoryID->IsNull()))
{
- LwpStory* pPreStory = static_cast<LwpStory*>(pPreStoryID->obj(VO_STORY));
- return static_cast<LwpPara*>(pPreStory->GetLastPara()->obj(VO_PARA));
+ LwpStory* pPreStory = dynamic_cast<LwpStory*>(pPreStoryID->obj(VO_STORY));
+ return dynamic_cast<LwpPara*>(pPreStory->GetLastPara()->obj(VO_PARA));
}
else
{
@@ -571,7 +571,7 @@ void LwpCellLayout::RegisterDefaultCell()
*/
void LwpCellLayout::RegisterStyle()
{
- LwpVirtualLayout * pParent = static_cast<LwpVirtualLayout *>(GetParent()->obj());
+ LwpVirtualLayout * pParent = dynamic_cast<LwpVirtualLayout *>(GetParent()->obj());
if (!pParent || pParent->GetLayoutType() != LWP_ROW_LAYOUT)
{
// default cell layout, we must register 4 styles for it
@@ -604,15 +604,6 @@ void LwpCellLayout::RegisterStyle()
//register child layout style
RegisterChildStyle();
- /*
- LwpVirtualLayout* pLayout = static_cast<LwpVirtualLayout*>(GetChildHead()->obj());
- while(pLayout)
- {
- pLayout->SetFoundry(m_pFoundry);
- pLayout->RegisterStyle();
- pLayout = static_cast<LwpVirtualLayout*>(pLayout->GetNext()->obj());
- }
- */
}
/**
* @short Read cell layout
@@ -687,7 +678,7 @@ void LwpCellLayout::ApplyProtect(XFCell * pCell, LwpObjectID aTableID)
else
{
// judge base on
- LwpCellLayout * pBase = static_cast<LwpCellLayout *>(m_BasedOnStyle.obj());
+ LwpCellLayout * pBase = dynamic_cast<LwpCellLayout *>(m_BasedOnStyle.obj());
if (pBase && pBase->IsProtected())
{
bProtected = sal_True;
@@ -695,7 +686,7 @@ void LwpCellLayout::ApplyProtect(XFCell * pCell, LwpObjectID aTableID)
else
{
// judge whole table
- LwpTable * pTable = static_cast<LwpTable *>(aTableID.obj());
+ LwpTable * pTable = dynamic_cast<LwpTable *>(aTableID.obj());
LwpTableLayout * pTableLayout = static_cast<LwpTableLayout *>(pTable->GetTableLayout());
LwpSuperTableLayout * pSuper = pTableLayout->GetSuperTableLayout();
if (pSuper && pSuper->IsProtected())
@@ -907,17 +898,17 @@ XFCell* LwpHiddenCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow,
{
if (!cconnectedlayout.obj())
return NULL;
- LwpConnectedCellLayout* pConnCell = static_cast<LwpConnectedCellLayout* >(cconnectedlayout.obj());
+ LwpConnectedCellLayout* pConnCell = dynamic_cast<LwpConnectedCellLayout* >(cconnectedlayout.obj());
if (nRow < (pConnCell->GetNumrows()+pConnCell->GetRowID()))
return NULL;
// if the hidden cell should be displayed for limit of SODC
// use the default cell layout
XFCell* pXFCell = NULL;
- LwpTable *pTable = static_cast<LwpTable *>(aTableID.obj());
+ LwpTable *pTable = dynamic_cast<LwpTable *>(aTableID.obj());
if (pTable)
{
- LwpCellLayout *pDefault = static_cast<LwpCellLayout *>(pTable->GetDefaultCellStyle()->obj());
+ LwpCellLayout *pDefault = dynamic_cast<LwpCellLayout *>(pTable->GetDefaultCellStyle()->obj());
if (pDefault)
{
pXFCell = pDefault->ConvertCell(aTableID, nRow, nCol);
diff --git a/lotuswordpro/source/filter/lwpchangemgr.cxx b/lotuswordpro/source/filter/lwpchangemgr.cxx
index c43a50b..37036df 100644
--- a/lotuswordpro/source/filter/lwpchangemgr.cxx
+++ b/lotuswordpro/source/filter/lwpchangemgr.cxx
@@ -229,45 +229,7 @@ void LwpChangeMgr::ConvertFribContent(XFContentContainer* pCont, LwpFrib* pFrib)
}
}
break;
-/* case FRIB_TAG_SECTION:
- {
- delete pXFPara;
- LwpFribSection* pSectionFrib = static_cast<LwpFribSection*>(pFrib);
- pSectionFrib->ParseSection();
- }
- break;
- case FRIB_TAG_PAGEBREAK:
- {
- LwpFribPageBreak* pPageBreak = static_cast<LwpFribPageBreak*>(pFrib);
- LwpPageLayout* pLayout = static_cast<LwpPageLayout*>(pPageBreak->GetLayout()->obj());
- if(pLayout)
- {
- pPageBreak->ParseLayout();
- }
- else
- {
- if (pPageBreak->IsLastFrib() == sal_True)
- {
- pXFPara->SetStyleName( pPageBreak->GetStyleName() );
- }
- else
- {
- //parse pagebreak
- XFParagraph *pNewPara = new XFParagraph();
- pNewPara->SetStyleName(pFrib->GetStyleName());
- pPara->AddXFContent(pNewPara);
- }
- }
- }
- break;
- case FRIB_TAG_COLBREAK:
- {
- XFParagraph *pNewPara = new XFParagraph();
- pNewPara->SetStyleName(pFrib->GetStyleName());
- pPara->AddXFContent(pNewPara);
- }
- break;
-*/ case FRIB_TAG_LINEBREAK:
+ case FRIB_TAG_LINEBREAK:
{
XFLineBreak *pLineBreak = new XFLineBreak();
pXFPara->Add(pLineBreak);
diff --git a/lotuswordpro/source/filter/lwpchartstreamtools.cxx b/lotuswordpro/source/filter/lwpchartstreamtools.cxx
index a50e861..3dfb962 100644
--- a/lotuswordpro/source/filter/lwpchartstreamtools.cxx
+++ b/lotuswordpro/source/filter/lwpchartstreamtools.cxx
@@ -85,11 +85,9 @@ SvStream* LwpChartStreamTools::GetChartStream(LwpSvStream* pDocStream, const cha
SvStream* pStream = NULL;
pSvStream->Seek(0);
OpenStormBento::LtcBenContainer* pContainer = NULL;;
- ULONG nRet = OpenStormBento::BenOpenContainer(pSvStream,&pContainer);
- if ( 0==nRet )
- {
+ sal_uLong nRet = OpenStormBento::BenOpenContainer(pSvStream,&pContainer);
+ if (nRet != OpenStormBento::BenErr_OK)
pStream = pContainer->FindValueStreamWithPropertyName(pChartName);
- }
return pStream;
}
diff --git a/lotuswordpro/source/filter/lwpcontent.hxx b/lotuswordpro/source/filter/lwpcontent.hxx
index eeaf7c2..d447d9c 100644
--- a/lotuswordpro/source/filter/lwpcontent.hxx
+++ b/lotuswordpro/source/filter/lwpcontent.hxx
@@ -141,7 +141,7 @@ inline OUString LwpContent::GetClassName()
inline LwpContent* LwpContent::GetNextEnumerated()
{
- return static_cast<LwpContent*>(m_NextEnumerated.obj());
+ return dynamic_cast<LwpContent*>(m_NextEnumerated.obj());
}
/**
* @brief
diff --git a/lotuswordpro/source/filter/lwpdivinfo.hxx b/lotuswordpro/source/filter/lwpdivinfo.hxx
index 459d56c..1e3c931 100644
--- a/lotuswordpro/source/filter/lwpdivinfo.hxx
+++ b/lotuswordpro/source/filter/lwpdivinfo.hxx
@@ -162,7 +162,7 @@ inline sal_Bool LwpDivInfo::IsGotoable()
inline LwpDocument* LwpDivInfo::GetDivision()
{
- return static_cast<LwpDocument*>(m_ParentID.obj());
+ return dynamic_cast<LwpDocument*>(m_ParentID.obj());
}
#endif
diff --git a/lotuswordpro/source/filter/lwpdoc.cxx b/lotuswordpro/source/filter/lwpdoc.cxx
index 1444440..ebe9822 100644
--- a/lotuswordpro/source/filter/lwpdoc.cxx
+++ b/lotuswordpro/source/filter/lwpdoc.cxx
@@ -71,7 +71,7 @@
#endif
LwpDocument::LwpDocument(LwpObjectHeader& objHdr, LwpSvStream* pStrm)
- : LwpDLNFPVList(objHdr, pStrm), m_pLnOpts(NULL)
+ : LwpDLNFPVList(objHdr, pStrm), m_pOwnedFoundry(NULL), m_pLnOpts(NULL)
{}
LwpDocument::~LwpDocument()
@@ -80,9 +80,9 @@ LwpDocument::~LwpDocument()
{
delete m_pLnOpts;
}
- if(m_pFoundry)
+ if(m_pOwnedFoundry)
{
- delete m_pFoundry;
+ delete m_pOwnedFoundry;
}
}
/**
@@ -115,7 +115,7 @@ void LwpDocument::Read()
LwpPrinterInfo m_PrtInfo( m_pObjStrm );
}
- m_pFoundry = new LwpFoundry(m_pObjStrm, this);
+ m_pFoundry = m_pOwnedFoundry = new LwpFoundry(m_pObjStrm, this);
m_DivOpts.ReadIndexed(m_pObjStrm);
@@ -171,7 +171,7 @@ sal_Bool LwpDocument::IsSkippedDivision()
{
OUString sDivName;
sal_uInt8 ret = sal_False;
- LwpDivInfo* pDiv = static_cast<LwpDivInfo*>(GetDivInfoID()->obj(VO_DIVISIONINFO));
+ LwpDivInfo* pDiv = dynamic_cast<LwpDivInfo*>(GetDivInfoID()->obj(VO_DIVISIONINFO));
if (pDiv == NULL)
return sal_True;
sDivName = pDiv->GetDivName();
@@ -183,10 +183,10 @@ sal_Bool LwpDocument::IsSkippedDivision()
|| strClassName.equals(A2OUSTR(STR_DivisionGroupEndnote))
|| strClassName.equals(A2OUSTR(STR_DocumentEndnote)))
{
- LwpPageLayout* pPageLayout =static_cast<LwpPageLayout*>(pDiv->GetInitialLayoutID()->obj(VO_PAGELAYOUT));
+ LwpPageLayout* pPageLayout = dynamic_cast<LwpPageLayout*>(pDiv->GetInitialLayoutID()->obj(VO_PAGELAYOUT));
if(pPageLayout)
{
- LwpStory* pStory = static_cast<LwpStory*>(pPageLayout->GetContent()->obj(VO_STORY));
+ LwpStory* pStory = dynamic_cast<LwpStory*>(pPageLayout->GetContent()->obj(VO_STORY));
if(pStory)
{
//This judgement maybe have problem. If there is only one para in the story,
@@ -230,15 +230,15 @@ void LwpDocument::RegisterStyle()
void LwpDocument::RegisterTextStyles()
{
//Register all text styles: para styles, character styles
- LwpDLVListHeadHolder* pParaStyleHolder = static_cast<LwpDLVListHeadHolder*>(m_pFoundry->GetTextStyleHead()->obj());
+ LwpDLVListHeadHolder* pParaStyleHolder = dynamic_cast<LwpDLVListHeadHolder*>(m_pFoundry->GetTextStyleHead()->obj());
if(pParaStyleHolder)
{
- LwpTextStyle* pParaStyle = static_cast<LwpTextStyle*> (pParaStyleHolder->GetHeadID()->obj());
+ LwpTextStyle* pParaStyle = dynamic_cast<LwpTextStyle*> (pParaStyleHolder->GetHeadID()->obj());
while(pParaStyle)
{
pParaStyle->SetFoundry(m_pFoundry);
pParaStyle->RegisterStyle();
- pParaStyle = static_cast<LwpParaStyle*>(pParaStyle->GetNext()->obj());
+ pParaStyle = dynamic_cast<LwpParaStyle*>(pParaStyle->GetNext()->obj());
}
}
ChangeStyleName();//add by ,for click here block,05/5/26
@@ -253,15 +253,15 @@ void LwpDocument::RegisterLayoutStyles()
m_pFoundry->RegisterAllLayouts();
//set initial pagelayout in story for parsing pagelayout
- LwpDivInfo* pDivInfo = static_cast<LwpDivInfo*> (m_DivInfo.obj( VO_DIVISIONINFO));
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*> (m_DivInfo.obj( VO_DIVISIONINFO));
LwpPageLayout* pPageLayout = NULL;
if(pDivInfo)
{
- pPageLayout =static_cast<LwpPageLayout*>(pDivInfo->GetInitialLayoutID()->obj(VO_PAGELAYOUT));
+ pPageLayout = dynamic_cast<LwpPageLayout*>(pDivInfo->GetInitialLayoutID()->obj(VO_PAGELAYOUT));
if(pPageLayout)
{
//In Ole division, the content of pagelayout is VO_OLEOBJECT
- LwpStory* pStory = static_cast<LwpStory*>(pPageLayout->GetContent()->obj(VO_STORY));
+ LwpStory* pStory = dynamic_cast<LwpStory*>(pPageLayout->GetContent()->obj(VO_STORY));
if(pStory)
{
//add all the pagelayout in order into the pagelayout list;
@@ -277,16 +277,16 @@ void LwpDocument::RegisterLayoutStyles()
void LwpDocument::RegisterStylesInPara()
{
//Register all automatic styles in para
- LwpHeadContent* pContent = static_cast<LwpHeadContent*> (m_pFoundry->GetContentManager()->GetContentList()->obj());
+ LwpHeadContent* pContent = dynamic_cast<LwpHeadContent*> (m_pFoundry->GetContentManager()->GetContentList()->obj());
if(pContent)
{
- LwpStory* pStory = static_cast<LwpStory*>(pContent->GetChildHead()->obj(VO_STORY));
+ LwpStory* pStory = dynamic_cast<LwpStory*>(pContent->GetChildHead()->obj(VO_STORY));
while(pStory)
{
//Register the child para
pStory->SetFoundry(m_pFoundry);
pStory->RegisterStyle();
- pStory = static_cast<LwpStory*>(pStory->GetNext()->obj(VO_STORY));
+ pStory = dynamic_cast<LwpStory*>(pStory->GetNext()->obj(VO_STORY));
}
}
}
@@ -296,17 +296,17 @@ void LwpDocument::RegisterStylesInPara()
void LwpDocument::RegisterBulletStyles()
{
//Register bullet styles
- LwpDLVListHeadHolder* mBulletHead = static_cast<LwpDLVListHeadHolder*>
+ LwpDLVListHeadHolder* mBulletHead = dynamic_cast<LwpDLVListHeadHolder*>
(m_pFoundry->GetBulletManagerID()->obj(VO_HEADHOLDER));
if( mBulletHead )
{
- LwpSilverBullet* pBullet = static_cast<LwpSilverBullet*>
+ LwpSilverBullet* pBullet = dynamic_cast<LwpSilverBullet*>
(mBulletHead->GetHeadID()->obj());
while(pBullet)
{
pBullet->SetFoundry(m_pFoundry);
pBullet->RegisterStyle();
- pBullet = static_cast<LwpSilverBullet*> (pBullet->GetNext()->obj());
+ pBullet = dynamic_cast<LwpSilverBullet*> (pBullet->GetNext()->obj());
}
}
}
@@ -341,7 +341,7 @@ void LwpDocument::RegisterFootnoteStyles()
//Register footnote and endnote configuration for the entire document
if(!m_FootnoteOpts.IsNull())
{
- LwpFootnoteOptions* pFootnoteOpts = static_cast<LwpFootnoteOptions*>(m_FootnoteOpts.obj());
+ LwpFootnoteOptions* pFootnoteOpts = dynamic_cast<LwpFootnoteOptions*>(m_FootnoteOpts.obj());
if (pFootnoteOpts)
{
pFootnoteOpts->SetMasterPage(A2OUSTR("Endnote"));
@@ -353,13 +353,13 @@ void LwpDocument::RegisterFootnoteStyles()
LwpDocument* pEndnoteDiv = GetLastDivisionThatHasEndnote();
if(this == pEndnoteDiv)
{
- LwpDLVListHeadTailHolder* pHeadTail = static_cast<LwpDLVListHeadTailHolder*>(GetPageHintsID()->obj());
+ LwpDLVListHeadTailHolder* pHeadTail = dynamic_cast<LwpDLVListHeadTailHolder*>(GetPageHintsID()->obj());
if(pHeadTail)
{
- LwpPageHint* pPageHint =static_cast<LwpPageHint*>(pHeadTail->GetTail()->obj());
+ LwpPageHint* pPageHint = dynamic_cast<LwpPageHint*>(pHeadTail->GetTail()->obj());
if(pPageHint && !pPageHint->GetPageLayoutID()->IsNull())
{
- LwpPageLayout* pPageLayout = static_cast<LwpPageLayout*>(pPageHint->GetPageLayoutID()->obj());
+ LwpPageLayout* pPageLayout = dynamic_cast<LwpPageLayout*>(pPageHint->GetPageLayoutID()->obj());
if(pPageLayout)
{
pPageLayout->SetFoundry(GetFoundry());
@@ -383,7 +383,7 @@ void LwpDocument::RegisterDefaultParaStyles()
LwpDocument* pFirstDoc = GetFirstDivisionWithContentsThatIsNotOLE();
if(pFirstDoc)
{
- LwpVerDocument* pVerDoc = static_cast<LwpVerDocument*>(pFirstDoc->GetVerDoc()->obj());
+ LwpVerDocument* pVerDoc = dynamic_cast<LwpVerDocument*>(pFirstDoc->GetVerDoc()->obj());
if(pVerDoc)
{
pVerDoc->RegisterStyle();
@@ -400,7 +400,7 @@ void LwpDocument::RegisterDefaultParaStyles()
void LwpDocument::ParseDocContent(IXFStream* pOutputStream)
{
//Parse content in PageLayout
- LwpDivInfo* pDivInfo = static_cast<LwpDivInfo*> (m_DivInfo.obj());
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*> (m_DivInfo.obj());
if(pDivInfo==NULL) return;
LwpObject* pLayoutObj = pDivInfo->GetInitialLayoutID()->obj();
@@ -419,7 +419,7 @@ void LwpDocument::ParseDocContent(IXFStream* pOutputStream)
*/
void LwpDocument::ParseMasterDoc(IXFStream* pOutputStream)
{
- LwpDivInfo* pDivInfo = static_cast<LwpDivInfo*> (m_DivInfo.obj());
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*> (m_DivInfo.obj());
if(pDivInfo==NULL) return;
LwpAtomHolder* pExternal = pDivInfo->GetExternalName();
if(pExternal && pExternal->HasValue())
@@ -450,7 +450,7 @@ LwpObjectID* LwpDocument::GetValidFootnoteOpts()
*/
sal_uInt16 LwpDocument::GetEndnoteType()
{
- LwpDivInfo* pDivInfo =static_cast<LwpDivInfo*>(GetDivInfoID()->obj());
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(GetDivInfoID()->obj());
if (!pDivInfo)
return FN_DONTCARE;
OUString strClassName = pDivInfo->GetClassName();
@@ -467,10 +467,10 @@ sal_uInt16 LwpDocument::GetEndnoteType()
*/
LwpDocument* LwpDocument::GetPreviousDivision()
{
- LwpDocSock* pDocSock = static_cast<LwpDocSock*>(GetSocket()->obj());
+ LwpDocSock* pDocSock = dynamic_cast<LwpDocSock*>(GetSocket()->obj());
if(pDocSock)
{
- return static_cast<LwpDocument*>(pDocSock->GetPrevious()->obj());
+ return dynamic_cast<LwpDocument*>(pDocSock->GetPrevious()->obj());
}
return NULL;
}
@@ -479,10 +479,10 @@ LwpDocument* LwpDocument::GetPreviousDivision()
*/
LwpDocument* LwpDocument::GetNextDivision()
{
- LwpDocSock* pDocSock = static_cast<LwpDocSock*>(GetSocket()->obj());
+ LwpDocSock* pDocSock = dynamic_cast<LwpDocSock*>(GetSocket()->obj());
if(pDocSock)
{
- return static_cast<LwpDocument*>(pDocSock->GetNext()->obj());
+ return dynamic_cast<LwpDocument*>(pDocSock->GetNext()->obj());
}
return NULL;
}
@@ -491,10 +491,10 @@ LwpDocument* LwpDocument::GetPreviousDivision()
*/
LwpDocument* LwpDocument::GetParentDivision()
{
- LwpDocSock* pDocSock = static_cast<LwpDocSock*>(GetSocket()->obj());
+ LwpDocSock* pDocSock = dynamic_cast<LwpDocSock*>(GetSocket()->obj());
if(pDocSock)
{
- return static_cast<LwpDocument*>(pDocSock->GetParent()->obj());
+ return dynamic_cast<LwpDocument*>(pDocSock->GetParent()->obj());
}
return NULL;
}
@@ -507,7 +507,7 @@ LwpDocument* LwpDocument::GetPreviousDivision()
for (pPrev = GetPreviousDivision(); pPrev; pPrev = pPrev->GetPreviousDivision())
{
- LwpDivInfo* pDivInfo =static_cast<LwpDivInfo*>(pPrev->GetDivInfoID()->obj());
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(pPrev->GetDivInfoID()->obj());
if(pDivInfo && pDivInfo->HasContents())
return pPrev;
}
@@ -522,7 +522,7 @@ LwpDocument* LwpDocument::GetPreviousDivision()
for (pNext = GetNextDivision(); pNext; pNext = pNext->GetNextDivision())
{
- LwpDivInfo* pDivInfo =static_cast<LwpDivInfo*>(pNext->GetDivInfoID()->obj());
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(pNext->GetDivInfoID()->obj());
if(pDivInfo && pDivInfo->HasContents())
return pNext;
}
@@ -549,7 +549,7 @@ LwpDocument* LwpDocument::GetPreviousDivision()
*/
LwpDocument* LwpDocument::GetLastDivisionWithContents()
{
- LwpDivInfo* pDivInfo =static_cast<LwpDivInfo*>(GetDivInfoID()->obj());
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(GetDivInfoID()->obj());
if(pDivInfo && pDivInfo->HasContents())
{
return this;
@@ -580,7 +580,7 @@ LwpDocument* LwpDocument::GetPreviousDivision()
while (pNext)
{
- LwpDivInfo* pDivInfo =static_cast<LwpDivInfo*>(pNext->GetDivInfoID()->obj());
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(pNext->GetDivInfoID()->obj());
if (pDivInfo && pDivInfo->HasContents())
pLast = pNext;
pNext = pNext->GetNextInGroup();
@@ -594,9 +594,9 @@ LwpDocument* LwpDocument::GetPreviousDivision()
*/
LwpDocument* LwpDocument::GetLastDivision()
{
- LwpDocSock* pDocSock = static_cast<LwpDocSock*>(GetSocket()->obj());
+ LwpDocSock* pDocSock = dynamic_cast<LwpDocSock*>(GetSocket()->obj());
if(pDocSock)
- return static_cast<LwpDocument*>(pDocSock->GetChildTail()->obj());
+ return dynamic_cast<LwpDocument*>(pDocSock->GetChildTail()->obj());
return NULL;
}
@@ -605,9 +605,9 @@ LwpDocument* LwpDocument::GetPreviousDivision()
*/
LwpDocument* LwpDocument::GetFirstDivision()
{
- LwpDocSock* pDocSock = static_cast<LwpDocSock*>(GetSocket()->obj());
+ LwpDocSock* pDocSock = dynamic_cast<LwpDocSock*>(GetSocket()->obj());
if(pDocSock)
- return static_cast<LwpDocument*>(pDocSock->GetChildHead()->obj());
+ return dynamic_cast<LwpDocument*>(pDocSock->GetChildHead()->obj());
return NULL;
}
@@ -630,7 +630,7 @@ LwpDocument* LwpDocument::GetPreviousDivision()
*/
LwpDocument* LwpDocument::GetFirstDivisionWithContentsThatIsNotOLE()
{
- LwpDivInfo* pDivInfo =static_cast<LwpDivInfo*>(GetDivInfoID()->obj());
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(GetDivInfoID()->obj());
if(pDivInfo && pDivInfo->HasContents()
&& !pDivInfo->IsOleDivision())
return this;
@@ -669,7 +669,7 @@ LwpDocument* LwpDocument::GetPreviousDivision()
*/
LwpVirtualLayout* LwpDocument::GetEnSuperTableLayout()
{
- LwpHeadLayout* pHeadLayout =static_cast<LwpHeadLayout*>(GetFoundry()->GetLayout()->obj());
+ LwpHeadLayout* pHeadLayout = dynamic_cast<LwpHeadLayout*>(GetFoundry()->GetLayout()->obj());
if(pHeadLayout)
{
return pHeadLayout->FindEnSuperTableLayout();
@@ -685,7 +685,7 @@ LwpDocument* LwpDocument::GetPreviousDivision()
if(this == pEndDivision)
return sal_True;
- LwpDivInfo* pDivInfo = static_cast<LwpDivInfo*>(m_DivInfo.obj());
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(m_DivInfo.obj());
if(pDivInfo)
{
pDivInfo->GetNumberOfPages(nCount);
@@ -728,7 +728,7 @@ sal_uInt16 LwpDocument::GetNumberOfPagesBefore()
{
LwpDocument* pDivision = GetFirstDivision();
- LwpDivInfo* pDivInfo = static_cast<LwpDivInfo*>(m_DivInfo.obj());
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(m_DivInfo.obj());
if(pDivInfo)
nNumPages += pDivInfo->GetMaxNumberOfPages();
while(pDivision)
@@ -761,13 +761,13 @@ void LwpDocument::XFConvertFrameInPage(XFContentContainer * pCont)
{
LwpDocument* pDivision = GetFirstDivision();
- LwpDivInfo* pDivInfo = static_cast<LwpDivInfo*> (GetDivInfoID()->obj());
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*> (GetDivInfoID()->obj());
if(pDivInfo)
{
- LwpPageLayout* pPageLayout =static_cast<LwpPageLayout*>(pDivInfo->GetInitialLayoutID()->obj());
+ LwpPageLayout* pPageLayout = dynamic_cast<LwpPageLayout*>(pDivInfo->GetInitialLayoutID()->obj());
if(pPageLayout)
{
- LwpStory* pStory = static_cast<LwpStory*>(pPageLayout->GetContent()->obj());
+ LwpStory* pStory = dynamic_cast<LwpStory*>(pPageLayout->GetContent()->obj());
if(pStory)
pStory->XFConvertFrameInPage(pCont);
}
@@ -784,7 +784,7 @@ void LwpDocument::XFConvertFrameInPage(XFContentContainer * pCont)
void LwpDocument::ChangeStyleName()
{
XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
- XFTextStyle* pStyle = static_cast<XFTextStyle*>(pXFStyleManager->FindStyle(A2OUSTR("ClickHere")));
+ XFTextStyle* pStyle = dynamic_cast<XFTextStyle*>(pXFStyleManager->FindStyle(A2OUSTR("ClickHere")));
if (pStyle)
{
pStyle->SetStyleName(A2OUSTR("Placeholder"));
diff --git a/lotuswordpro/source/filter/lwpdoc.hxx b/lotuswordpro/source/filter/lwpdoc.hxx
index 1ed45d3..fdceee7 100644
--- a/lotuswordpro/source/filter/lwpdoc.hxx
+++ b/lotuswordpro/source/filter/lwpdoc.hxx
@@ -89,6 +89,8 @@ public:
~LwpDocument();
private:
+ LwpFoundry* m_pOwnedFoundry;
+
//Data members in file format
LwpObjectID m_DocSockID;
sal_uInt16 m_nFlags;
@@ -185,7 +187,7 @@ private:
void MaxNumberOfPages(sal_uInt16& nNumPages);
void XFConvertFrameInPage(XFContentContainer* pCont);
void ChangeStyleName();
- sal_Bool IsSkippedDivision();//add by
+ sal_Bool IsSkippedDivision();
};
inline sal_Bool LwpDocument::IsChildDoc()
diff --git a/lotuswordpro/source/filter/lwpfilter.cxx b/lotuswordpro/source/filter/lwpfilter.cxx
index 7701a60..37db2dd 100644
--- a/lotuswordpro/source/filter/lwpfilter.cxx
+++ b/lotuswordpro/source/filter/lwpfilter.cxx
@@ -82,6 +82,8 @@
#include <tools/stream.hxx>
#include <sfx2/docfile.hxx>
+#include <boost/scoped_ptr.hpp>
+
using namespace ::cppu;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::frame;
@@ -109,31 +111,19 @@ LWPFilterReader::~LWPFilterReader()
sal_Bool LWPFilterReader::filter( const Sequence< PropertyValue >& aDescriptor )
throw( RuntimeException )
{
- uno::Reference< XInputStream> xInputStream;
- ::rtl::OUString sURL;
+ ::rtl::OUString sURL;
for( sal_Int32 i = 0; i < aDescriptor.getLength(); i++ )
{
- if( aDescriptor[i].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream")) )
- aDescriptor[i].Value >>= xInputStream;
+ //Note we should attempt to use "InputStream" if it exists first!
if( aDescriptor[i].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("URL")) )
aDescriptor[i].Value >>= sURL;
}
- if ( !xInputStream.is() )
- {
- OSL_ASSERT( 0 );
- return sal_False;
- }
-
- OString sFileName;
- sFileName = ::rtl::OUStringToOString(sURL, RTL_TEXTENCODING_INFO_ASCII);
-
SvFileStream inputStream( sURL, STREAM_READ );
if ( inputStream.IsEof() || ( inputStream.GetError() != SVSTREAM_OK ) )
return sal_False;
-
- return (ReadWordproFile( &inputStream ,m_DocumentHandler) == 0);
+ return (ReadWordproFile(inputStream, m_DocumentHandler) == 0);
}
void LWPFilterReader::cancel() throw (com::sun::star::uno::RuntimeException)
@@ -332,41 +322,39 @@ Sequence< OUString> LWPFilterImportFilter::getSupportedServiceNames( void ) thro
#include "bento.hxx"
using namespace OpenStormBento;
#include "explode.hxx"
- sal_Bool Decompress(SvStream *pCompressed, SvStream * & pDecompressed)
+ sal_Bool Decompress(SvStream *pCompressed, SvStream * & pOutDecompressed)
{
pCompressed->Seek(0);
- pDecompressed = new SvMemoryStream(4096, 4096);
+ std::auto_ptr<SvStream> aDecompressed(new SvMemoryStream(4096, 4096));
unsigned char buffer[512];
pCompressed->Read(buffer, 16);
- pDecompressed->Write(buffer, 16);
+ aDecompressed->Write(buffer, 16);
- LwpSvStream * pLwpStream = new LwpSvStream(pCompressed);
+ boost::scoped_ptr<LwpSvStream> aLwpStream(new LwpSvStream(pCompressed));
LtcBenContainer* pBentoContainer;
- /*ULONG ulRet = */ BenOpenContainer(pLwpStream, &pBentoContainer);
- LtcUtBenValueStream * pWordProData = (LtcUtBenValueStream *)pBentoContainer->FindValueStreamWithPropertyName("WordProData");
+ sal_uLong ulRet = BenOpenContainer(aLwpStream.get(), &pBentoContainer);
+ if (ulRet != BenErr_OK)
+ return sal_False;
+
+ boost::scoped_ptr<LtcUtBenValueStream> aWordProData((LtcUtBenValueStream *)pBentoContainer->FindValueStreamWithPropertyName("WordProData"));
+
+ if (!aWordProData.get())
+ return sal_False;
// decompressing
- Decompression decompress(pWordProData, pDecompressed);
+ Decompression decompress(aWordProData.get(), aDecompressed.get());
if (0!= decompress.explode())
- {
- delete pDecompressed;
- pDecompressed = NULL;
- delete pWordProData;
- delete pLwpStream;
return sal_False;
- }
- sal_uInt32 nPos = pWordProData->GetSize();
+ sal_uInt32 nPos = aWordProData->GetSize();
nPos += 0x10;
pCompressed->Seek(nPos);
while (sal_uInt32 iRead = pCompressed->Read(buffer, 512))
- {
- pDecompressed->Write(buffer, iRead);
- }
+ aDecompressed->Write(buffer, iRead);
- delete pWordProData;
- delete pLwpStream;
+ //transfer ownership of aDecompressed's ptr
+ pOutDecompressed = aDecompressed.release();
return sal_True;
}
@@ -410,40 +398,38 @@ using namespace OpenStormBento;
}
return bCompressed;
}
-int ReadWordproFile(SvStream* pStream, uno::Reference<XDocumentHandler>& xHandler)
+int ReadWordproFile(SvStream &rStream, uno::Reference<XDocumentHandler>& xHandler)
{
try
{
- LwpSvStream *pLwpSvStream = NULL;
- SvStream * pDecompressed = NULL;
- if ( GetLwpSvStream(pStream, pLwpSvStream) && pLwpSvStream)
+ LwpSvStream *pRawLwpSvStream = NULL;
+ boost::scoped_ptr<LwpSvStream> aLwpSvStream;
+ boost::scoped_ptr<LwpSvStream> aCompressedLwpSvStream;
+ boost::scoped_ptr<SvStream> aDecompressed;
+ if (GetLwpSvStream(&rStream, pRawLwpSvStream) && pRawLwpSvStream)
{
- pDecompressed = pLwpSvStream->GetStream();
+ SvStream *pDecompressed = pRawLwpSvStream->GetStream();
+ if (pDecompressed)
+ {
+ aDecompressed.reset(pDecompressed);
+ aCompressedLwpSvStream.reset(pRawLwpSvStream->GetCompressedStream());
+ }
}
- if (!pLwpSvStream)
+
+ if (!pRawLwpSvStream)
{
// nothing returned, fail when uncompressing
return 1;
}
- IXFStream *pStrm = new XFSaxStream(xHandler);
- Lwp9Reader reader(pLwpSvStream, pStrm);
+ aLwpSvStream.reset(pRawLwpSvStream);
+
+ boost::scoped_ptr<IXFStream> pStrm(new XFSaxStream(xHandler));
+ Lwp9Reader reader(aLwpSvStream.get(), pStrm.get());
//Reset all static objects,because this function may be called many times.
XFGlobalReset();
reader.Read();
- // added by
-
- if (pDecompressed)
- {
- delete pDecompressed;
- LwpSvStream * pTemp = pLwpSvStream->GetCompressedStream();
- delete pTemp;
- }
- delete pLwpSvStream;
- // end added by
-
- delete pStrm;
return 0;
}
catch (...)
diff --git a/lotuswordpro/source/filter/lwpfilter.hxx b/lotuswordpro/source/filter/lwpfilter.hxx
index ebd0fd4..866d3a0 100644
--- a/lotuswordpro/source/filter/lwpfilter.hxx
+++ b/lotuswordpro/source/filter/lwpfilter.hxx
@@ -174,9 +174,8 @@ public:
uno::Reference< XImporter > rImporter;
};
-int ReadWordproFile(String& strName,uno::Reference<XDocumentHandler>& XDoc);
//test code
-int ReadWordproFile(SvStream* pStream, uno::Reference<XDocumentHandler>& XDoc);
+int ReadWordproFile(SvStream &rStream, uno::Reference<XDocumentHandler>& XDoc);
#endif
diff --git a/lotuswordpro/source/filter/lwpfont.cxx b/lotuswordpro/source/filter/lwpfont.cxx
index 4e2903b..cc28d06 100644
--- a/lotuswordpro/source/filter/lwpfont.cxx
+++ b/lotuswordpro/source/filter/lwpfont.cxx
@@ -247,7 +247,8 @@ void LwpFontTableEntry::RegisterFontDecl()
}
LwpFontTable::LwpFontTable()
- : m_pFontEntries(NULL)
+ : m_nCount(0)
+ , m_pFontEntries(NULL)
{}
void LwpFontTable::Read(LwpObjectStream *pStrm)
@@ -267,10 +268,8 @@ void LwpFontTable::Read(LwpObjectStream *pStrm)
OUString LwpFontTable::GetFaceName(sal_uInt16 index) //index: start from 1
{
- assert(index>0);
- if (index < 1)//add for fix crash
- return OUString();
- return m_pFontEntries[index-1].GetFaceName();
+ assert(index <= m_nCount && index > 0);
+ return (index <= m_nCount && index > 0) ? m_pFontEntries[index-1].GetFaceName() : OUString();
}
LwpFontTable::~LwpFontTable()
@@ -398,7 +397,9 @@ void LwpFontNameManager::Read(LwpObjectStream *pStrm)
void LwpFontNameManager::Override(sal_uInt16 index, XFFont* pFont)
//index: start from 1
{
- if(index<1) return;
+ if (index > m_nCount || index < 1)
+ return ;
+
m_pFontNames[index-1].Override(pFont);
if(m_pFontNames[index-1].IsFaceNameOverridden())
pFont->SetFontName(m_FontTbl.GetFaceName(m_pFontNames[index-1].GetFaceID()));
@@ -436,7 +437,9 @@ void LwpFontAttrManager::Read(LwpObjectStream *pStrm) {
void LwpFontAttrManager::Override(sal_uInt16 index, XFFont* pFont)
//index: start from 1
{
- if(index<1) return;
+ if (index > m_nCount || index < 1)
+ return ;
+
m_pFontAttrs[index-1].Override(pFont);
}
diff --git a/lotuswordpro/source/filter/lwpfootnote.cxx b/lotuswordpro/source/filter/lwpfootnote.cxx
index be3888d..b9af6da 100644
--- a/lotuswordpro/source/filter/lwpfootnote.cxx
+++ b/lotuswordpro/source/filter/lwpfootnote.cxx
@@ -141,7 +141,7 @@ void LwpFribFootnote::XFConvert(XFContentContainer* pCont)
*/
LwpFootnote* LwpFribFootnote::GetFootnote()
{
- return static_cast<LwpFootnote*>(m_Footnote.obj());
+ return dynamic_cast<LwpFootnote*>(m_Footnote.obj());
}
@@ -211,7 +211,7 @@ LwpCellLayout* LwpFootnote::GetCellLayout()
LwpRowLayout* pRowLayout = pTableLayout->GetRowLayout(m_nRow);
if(pRowLayout)
{
- return static_cast<LwpCellLayout*>(pRowLayout->GetChildHead()->obj());
+ return dynamic_cast<LwpCellLayout*>(pRowLayout->GetChildHead()->obj());
}
}
}
@@ -410,7 +410,7 @@ LwpTable* LwpFootnote::GetFootnoteTable(LwpEnSuperTableLayout * pLayout)
{
LwpEndnoteLayout* pEndnoteLayout = static_cast<LwpEndnoteLayout*>(pLayout->GetMainTableLayout());
if(pEndnoteLayout)
- return static_cast<LwpTable*>(pEndnoteLayout->GetContent()->obj());
+ return dynamic_cast<LwpTable*>(pEndnoteLayout->GetContent()->obj());
}
return NULL;
}
@@ -420,7 +420,7 @@ LwpTable* LwpFootnote::GetFootnoteTable(LwpEnSuperTableLayout * pLayout)
*/
LwpContent* LwpFootnote::FindFootnoteContent()
{
- LwpContent* pContent = static_cast<LwpContent*>(m_Content.obj());
+ LwpContent* pContent = dynamic_cast<LwpContent*>(m_Content.obj());
//if the content has layout, the content has footnote contents;
//or looking for the celllayout and return the footnote contents.
if(pContent && pContent->GetLayout(NULL))
@@ -429,7 +429,7 @@ LwpContent* LwpFootnote::FindFootnoteContent()
LwpCellLayout* pCellLayout = GetCellLayout();
if(pCellLayout)
{
- pContent =static_cast<LwpContent*>(pCellLayout->GetContent()->obj());
+ pContent = dynamic_cast<LwpContent*>(pCellLayout->GetContent()->obj());
}
return pContent;
diff --git a/lotuswordpro/source/filter/lwpfoundry.cxx b/lotuswordpro/source/filter/lwpfoundry.cxx
index e009f18..8754469 100644
--- a/lotuswordpro/source/filter/lwpfoundry.cxx
+++ b/lotuswordpro/source/filter/lwpfoundry.cxx
@@ -75,7 +75,10 @@
#include "lwpglobalmgr.hxx"
LwpFoundry::LwpFoundry(LwpObjectStream *pStrm, LwpDocument* pDoc)
- : m_pDoc(pDoc), m_pPieceMgr(NULL), m_pStyleMgr(NULL)
+ : m_pDoc(pDoc)
+ , m_bRegisteredAll(false)
+ , m_pPieceMgr(NULL)
+ , m_pStyleMgr(NULL)
{
Read(pStrm);
m_pDropcapMgr = new LwpDropcapMgr;
@@ -184,6 +187,14 @@ void LwpFoundry::ReadStyles(LwpObjectStream *pStrm)
void LwpFoundry::RegisterAllLayouts()
{
+ if (m_bRegisteredAll)
+ {
+ OSL_FAIL("recursive LwpFoundry::RegisterAllLayouts!\n");
+ return;
+ }
+
+ m_bRegisteredAll = true;
+
//Register CellStyle
LwpObject* pStyle = m_CellStyle.obj();
if( pStyle )
@@ -193,7 +204,7 @@ void LwpFoundry::RegisterAllLayouts()
}
//register content page layout list: Layout
- pStyle = m_Layout.obj();
+ pStyle = m_Layout.obj();
if( pStyle )
{
pStyle->SetFoundry(this);
diff --git a/lotuswordpro/source/filter/lwpfoundry.hxx b/lotuswordpro/source/filter/lwpfoundry.hxx
index 563c689..e10b6c1 100644
--- a/lotuswordpro/source/filter/lwpfoundry.hxx
+++ b/lotuswordpro/source/filter/lwpfoundry.hxx
@@ -221,6 +221,7 @@ public:
void RegisterAllLayouts();
private:
LwpDocument* m_pDoc;
+ bool m_bRegisteredAll;
private: //file members
LwpVersionManager m_VerMgr;
LwpObjectManager m_ObjMgr;
diff --git a/lotuswordpro/source/filter/lwpframelayout.cxx b/lotuswordpro/source/filter/lwpframelayout.cxx
index 6f427af..efc863f 100644
--- a/lotuswordpro/source/filter/lwpframelayout.cxx
+++ b/lotuswordpro/source/filter/lwpframelayout.cxx
@@ -888,11 +888,16 @@ OUString LwpFrameLayout::GetNextLinkName()
LwpObjectID* pObjectID = m_Link.GetNextLayout();
if(!pObjectID->IsNull())
{
- LwpLayout* pLayout = static_cast<LwpLayout*>(pObjectID->obj());
- aName = pLayout->GetName()->str();
- //for division name confict
- if(pLayout->GetStyleName().getLength() > 0)
- aName = pLayout->GetStyleName();
+ LwpLayout* pLayout = dynamic_cast<LwpLayout*>(pObjectID->obj());
+ if (pLayout)
+ {
+ LwpAtomHolder *pHolder = pLayout->GetName();
+ if (pHolder)
+ aName = pHolder->str();
+ //for division name confict
+ if(pLayout->GetStyleName().getLength() > 0)
+ aName = pLayout->GetStyleName();
+ }
}
return aName;
}
diff --git a/lotuswordpro/source/filter/lwpfrib.cxx b/lotuswordpro/source/filter/lwpfrib.cxx
index 583eab5..ad9dbc0 100644
--- a/lotuswordpro/source/filter/lwpfrib.cxx
+++ b/lotuswordpro/source/filter/lwpfrib.cxx
@@ -337,26 +337,33 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry)
void LwpFrib::ReadModifiers(LwpObjectStream* pObjStrm,ModifierInfo* pModInfo)
{
- sal_uInt8 Modifier;
- sal_uInt8 len;
-// sal_Bool ModifyFlag = sal_False;
-
for(;;)
{
+ sal_uInt8 Modifier(0);
+ sal_uInt8 len(0);
+
// Get the modifier type
- pObjStrm->QuickRead(&Modifier, sizeof(Modifier));
+ if (pObjStrm->QuickRead(&Modifier, sizeof(Modifier)) != sizeof(Modifier))
+ break;
// Stop when we hit the last modifier
if (Modifier == FRIB_MTAG_NONE)
break;
-// ModifyFlag = sal_True;
+
// Get the modifier length
- pObjStrm->QuickRead(&len, sizeof(len));
+ if (pObjStrm->QuickRead(&len, sizeof(len)) != sizeof(len))
+ break;
switch (Modifier)
{
case FRIB_MTAG_FONT:
- pObjStrm->QuickRead(&pModInfo->FontID,len);
+ if (len > sizeof(pModInfo->FontID))
+ {
+ OSL_FAIL("FRIB_MTAG_FONT entry wrong size\n");
+ pObjStrm->SeekRel(len);
+ }
+ else
+ pObjStrm->QuickRead(&pModInfo->FontID,len);
break;
case FRIB_MTAG_CHARSTYLE:
pModInfo->HasCharStyle = sal_True;
@@ -367,15 +374,19 @@ void LwpFrib::ReadModifiers(LwpObjectStream* pObjStrm,ModifierInfo* pModInfo)
pModInfo->Language.Read(pObjStrm);
break;
case FRIB_MTAG_CODEPAGE:
- pObjStrm->QuickRead(&pModInfo->CodePage,len);
+ if (len > sizeof(pModInfo->CodePage))
+ {
+ OSL_FAIL("FRIB_MTAG_CODEPAGE entry wrong size\n");
+ pObjStrm->SeekRel(len);
+ }
+ else
+ pObjStrm->QuickRead(&pModInfo->CodePage,len);
break;
- //add by , 02/22/2005
case FRIB_MTAG_ATTRIBUTE:
pModInfo->aTxtAttrOverride.Read(pObjStrm);
if (pModInfo->aTxtAttrOverride.IsHighLight())
pModInfo->HasHighLight = sal_True;
break;
- //end add
case FRIB_MTAG_REVISION:
pModInfo->RevisionType = pObjStrm->QuickReaduInt8();
pModInfo->RevisionFlag = sal_True;
@@ -385,10 +396,7 @@ void LwpFrib::ReadModifiers(LwpObjectStream* pObjStrm,ModifierInfo* pModInfo)
break;
}
// TODO: read the modifier data
- // pObjStrm->SeekRel(len);
-
}
-
}
//do nothing
diff --git a/lotuswordpro/source/filter/lwpfribframe.cxx b/lotuswordpro/source/filter/lwpfribframe.cxx
index f3fa7a1..e95190e 100644
--- a/lotuswordpro/source/filter/lwpfribframe.cxx
+++ b/lotuswordpro/source/filter/lwpfribframe.cxx
@@ -92,14 +92,21 @@ LwpObject* LwpFribFrame::GetLayout()
*/
void LwpFribFrame::RegisterStyle(LwpFoundry* pFoundry)
{
- if (m_objLayout.obj()->GetTag() == VO_DROPCAPLAYOUT)
+ LwpObject *pObject = m_objLayout.obj();
+
+ if (pObject && pObject->GetTag() == VO_DROPCAPLAYOUT)
{
- static_cast<LwpDropcapLayout*>(m_objLayout.obj())->RegisterStyle(pFoundry);
+ LwpDropcapLayout *pLayout = dynamic_cast<LwpDropcapLayout*>(pObject);
+ if (!pLayout)
+ return;
+ pLayout->RegisterStyle(pFoundry);
}
else
{
- //register frame style, , 04/07/2005
- LwpPlacableLayout* pLayout = static_cast<LwpPlacableLayout*>(m_objLayout.obj());
+ //register frame style
+ LwpPlacableLayout* pLayout = dynamic_cast<LwpPlacableLayout*>(pObject);
+ if (!pLayout)
+ return;
pLayout->SetFoundry(pFoundry);
pLayout->RegisterStyle();
@@ -125,10 +132,12 @@ void LwpFribFrame::RegisterStyle(LwpFoundry* pFoundry)
}
void LwpFribFrame::SetParaDropcap(LwpPara* pPara)
{
- if (m_objLayout.obj()->GetTag() == VO_DROPCAPLAYOUT)
+ LwpObject *pObject = m_objLayout.obj();
+
+ if (pObject && pObject->GetTag() == VO_DROPCAPLAYOUT)
{
pPara->SetParaDropcap(sal_True);
- pPara->SetDropcapLayout(static_cast<LwpDropcapLayout*>(m_objLayout.obj()));
+ pPara->SetDropcapLayout(dynamic_cast<LwpDropcapLayout*>(pObject));
}
else
pPara->SetParaDropcap(sal_False);
@@ -141,7 +150,9 @@ void LwpFribFrame::SetParaDropcap(LwpPara* pPara)
void LwpFribFrame::XFConvert(XFContentContainer* pCont)
{
XFContentContainer* pXFContentContainer = pCont;
- LwpVirtualLayout* pLayout = static_cast<LwpVirtualLayout*>(GetLayout());
+ LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetLayout());
+ if (!pLayout)
+ return;
sal_uInt8 nType = pLayout->GetRelativeType();
if( LwpLayoutRelativityGuts::LAY_PARA_RELATIVE == nType)
{
@@ -232,7 +243,7 @@ void LwpFribRubyFrame::XFConvert(XFContentContainer* /*pCont*/)
LwpRubyLayout* LwpFribRubyFrame::GetLayout()
{
- return static_cast<LwpRubyLayout*>(m_objLayout.obj());
+ return dynamic_cast<LwpRubyLayout*>(m_objLayout.obj());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribmark.cxx b/lotuswordpro/source/filter/lwpfribmark.cxx
index 3499f79..3d377a1 100644
--- a/lotuswordpro/source/filter/lwpfribmark.cxx
+++ b/lotuswordpro/source/filter/lwpfribmark.cxx
@@ -94,7 +94,7 @@ void LwpFribCHBlock::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
LwpCHBlkMarker* LwpFribCHBlock::GetMarker()
{
- return static_cast<LwpCHBlkMarker*>(m_objMarker.obj());
+ return dynamic_cast<LwpCHBlkMarker*>(m_objMarker.obj());
}
void LwpFribCHBlock::XFConvert(XFContentContainer* pXFPara,LwpStory* pStory)
@@ -147,7 +147,9 @@ void LwpFribBookMark::RegisterStyle(LwpFoundry* pFoundry)
LwpObjectID* pID = pDoc->GetDivInfoID();
if (!pID->IsNull())
{
- sDivision = static_cast<LwpDivInfo*>(pID->obj(VO_DIVISIONINFO))->GetDivName();
+ LwpDivInfo *pDivInvo = dynamic_cast<LwpDivInfo*>(pID->obj(VO_DIVISIONINFO));
+ if (pDivInvo)
+ sDivision = pDivInvo->GetDivName();
}
}
@@ -230,7 +232,7 @@ void LwpFribField::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
LwpFieldMark* LwpFribField::GetMarker()
{
- return static_cast<LwpFieldMark*>(m_objMarker.obj());
+ return dynamic_cast<LwpFieldMark*>(m_objMarker.obj());
}
void LwpFribField::XFConvert(XFContentContainer* pXFPara)
@@ -1421,7 +1423,7 @@ LwpFribRubyMarker::LwpFribRubyMarker( LwpPara* pPara ): LwpFrib(pPara)
LwpRubyMarker* LwpFribRubyMarker::GetMarker()
{
- return static_cast<LwpRubyMarker*>(m_objMarker.obj(VO_RUBYMARKER));
+ return dynamic_cast<LwpRubyMarker*>(m_objMarker.obj(VO_RUBYMARKER));
}
void LwpFribRubyMarker::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
diff --git a/lotuswordpro/source/filter/lwpfribptr.cxx b/lotuswordpro/source/filter/lwpfribptr.cxx
index 61e3113..b58e269 100644
--- a/lotuswordpro/source/filter/lwpfribptr.cxx
+++ b/lotuswordpro/source/filter/lwpfribptr.cxx
@@ -90,7 +90,8 @@
LwpFribPtr::LwpFribPtr()
: m_pFribs(NULL),m_pXFPara(NULL),m_pPara(NULL)
-{}
+{
+}
LwpFribPtr::~LwpFribPtr()
{
@@ -226,7 +227,7 @@ void LwpFribPtr::XFConvert()
case FRIB_TAG_PAGEBREAK:
{
LwpFribPageBreak* pPageBreak = static_cast<LwpFribPageBreak*>(pFrib);
- LwpPageLayout* pLayout = static_cast<LwpPageLayout*>(pPageBreak->GetLayout()->obj());
+ LwpPageLayout* pLayout = dynamic_cast<LwpPageLayout*>(pPageBreak->GetLayout()->obj());
if(pLayout)
{
pPageBreak->ParseLayout();
@@ -291,13 +292,8 @@ void LwpFribPtr::XFConvert()
{
LwpFribFrame* frameFrib= static_cast<LwpFribFrame*>(pFrib);
LwpObject* pLayout = frameFrib->GetLayout();
- if (pLayout->GetTag() == VO_DROPCAPLAYOUT)
- {
+ if (pLayout && pLayout->GetTag() == VO_DROPCAPLAYOUT)
m_pPara->GetFoundry()->GetDropcapMgr()->SetXFPara(m_pXFPara);
- //LwpObject* pDropCap = frameFrib->GetLayout();
- //pDropCap ->XFConvert(m_pXFPara);
- }
- //pLayout->XFConvert(m_pXFPara);
frameFrib->XFConvert(m_pXFPara);
}
break;
@@ -406,8 +402,9 @@ void LwpFribPtr::FindLayouts()
//StartWithinColume type not support now
break;
}
- LwpStory* pStory = static_cast<LwpStory*>(m_pPara->GetStoryID()->obj());
- pStory->AddPageLayout(pSection->GetPageLayout());
+ LwpStory* pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID()->obj());
+ if (pStory)
+ pStory->AddPageLayout(pSection->GetPageLayout());
}
}
@@ -416,11 +413,12 @@ void LwpFribPtr::FindLayouts()
case FRIB_TAG_PAGEBREAK:
{
LwpFribPageBreak* pPageBreak = static_cast<LwpFribPageBreak*>(pFrib);
- LwpPageLayout* pLayout = static_cast<LwpPageLayout*>(pPageBreak->GetLayout()->obj());
+ LwpPageLayout* pLayout = dynamic_cast<LwpPageLayout*>(pPageBreak->GetLayout()->obj());
if(pLayout)
{
- LwpStory* pStory = static_cast<LwpStory*>(m_pPara->GetStoryID()->obj());
- pStory->AddPageLayout(pLayout);
+ LwpStory* pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID()->obj());
+ if (pStory)
+ pStory->AddPageLayout(pLayout);
}
break;
}
@@ -614,9 +612,9 @@ void LwpFribPtr::ProcessDropcap(LwpStory* pStory,LwpFrib* pFrib,sal_uInt32 nLen)
XFTextStyle* pFribStyle = pXFStyleManager->FindTextStyle(pFrib->GetStyleName());
pFribStyle->GetFont()->SetFontSize(0);
- LwpObject* pObj= pStory->GetLayoutsWithMe()->GetOnlyLayout()->obj();
+ LwpDropcapLayout* pObj = dynamic_cast<LwpDropcapLayout*>(pStory->GetLayoutsWithMe()->GetOnlyLayout()->obj());
if (pObj)
- static_cast<LwpDropcapLayout*>(pObj)->SetChars(nLen);
+ pObj->SetChars(nLen);
}
}
}
@@ -649,7 +647,7 @@ sal_Bool LwpFribPtr::ComparePagePosition(LwpVirtualLayout* pPreLayout, LwpVirtua
case FRIB_TAG_PAGEBREAK:
{
LwpFribPageBreak* pPageBreak = static_cast<LwpFribPageBreak*>(pFrib);
- pLayout = static_cast<LwpVirtualLayout*>(pPageBreak->GetLayout()->obj());
+ pLayout = dynamic_cast<LwpVirtualLayout*>(pPageBreak->GetLayout()->obj());
break;
}
default:
diff --git a/lotuswordpro/source/filter/lwpgrfobj.cxx b/lotuswordpro/source/filter/lwpgrfobj.cxx
index efc8a0e..72503aa 100644
--- a/lotuswordpro/source/filter/lwpgrfobj.cxx
+++ b/lotuswordpro/source/filter/lwpgrfobj.cxx
@@ -94,6 +94,8 @@ LwpGraphicObject::LwpGraphicObject(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
, m_bIsLinked(0)
, m_bCompressed(0)
{
+ memset(m_sDataFormat, 0, sizeof(m_sDataFormat));
+ memset(m_sServerContextFormat, 0, sizeof(m_sServerContextFormat));
}
LwpGraphicObject::~LwpGraphicObject()
{
@@ -207,21 +209,6 @@ void LwpGraphicObject::XFConvert (XFContentContainer* pCont)
{
if ((m_sServerContextFormat[1]=='s'&&m_sServerContextFormat[2]=='d'&&m_sServerContextFormat[3]=='w'))
{
-/* LwpSvStream* pStream = m_pStrm;
- //test code
- OpenStormBento::LtcBenContainer* pBentoContainer;
- ULONG ulRet = OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
- std::vector<SvStream*> vStream;
- std::vector<SvStream*>::iterator iter;
- pBentoContainer->CreateGraphicStreams(&vStream);
- for (iter=vStream.begin();iter!=vStream.end();iter++)
- {
- LwpSdwFileLoader fileLoader(*iter,pOutputStream);
- fileLoader.LoadObjectList();
- delete *iter;
- }
- vStream.clear();*/
-
//XFParagraph* pPara = new XFParagraph();
std::vector <XFFrame*>::iterator iter;
for (iter = m_vXFDrawObjects.begin(); iter != m_vXFDrawObjects.end(); ++iter)
@@ -375,24 +362,7 @@ void LwpGraphicObject::RegisterStyle()
{
this->CreateGrafObject();
}
-/* if (m_sServerContextFormat[1]=='s'&&m_sServerContextFormat[2]=='d'&&m_sServerContextFormat[3]=='w')
- {
- LwpSvStream* pStream = m_pStrm;
- //test code
- OpenStormBento::LtcBenContainer* pBentoContainer;
- ULONG ulRet = OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
- std::vector<SvStream*> vStream;
- std::vector<SvStream*>::iterator iter;
- pBentoContainer->CreateGraphicStreams(&vStream);
- for (iter=vStream.begin();iter!=vStream.end();iter++)
- {
- LwpSdwFileLoader fileLoader(*iter);
- fileLoader.RegisterStyle();
- delete *iter;
- }
- vStream.clear();
- }*/
if (m_sServerContextFormat[1]=='l'&&m_sServerContextFormat[2]=='c'&&m_sServerContextFormat[3]=='h')
{
LwpVirtualLayout* pMyLayout = GetLayout(NULL);
@@ -418,7 +388,10 @@ void LwpGraphicObject::CreateDrawObjects()
LwpSvStream* pStream = m_pStrm->GetCompressedStream() ? m_pStrm->GetCompressedStream(): m_pStrm;
OpenStormBento::LtcBenContainer* pBentoContainer;
- /*ULONG ulRet =*/ OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
+ sal_uLong ulRet = OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
+ if (ulRet != OpenStormBento::BenErr_OK)
+ return;
+
SvStream* pDrawObjStream = NULL;
// get graphic object's bento objet name
@@ -463,7 +436,10 @@ sal_uInt32 LwpGraphicObject::GetRawGrafData(sal_uInt8*& pGrafData)
LwpSvStream* pStream = m_pStrm->GetCompressedStream() ? m_pStrm->GetCompressedStream(): m_pStrm;
OpenStormBento::LtcBenContainer* pBentoContainer;
- /*ULONG ulRet =*/ OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
+ sal_uLong ulRet = OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
+ if (ulRet != OpenStormBento::BenErr_OK)
+ return 0;
+
SvStream* pGrafStream = NULL;
// get graphic object's bento objet name
@@ -503,7 +479,9 @@ sal_uInt32 LwpGraphicObject::GetGrafData(sal_uInt8*& pGrafData)
LwpSvStream* pStream = m_pStrm->GetCompressedStream() ? m_pStrm->GetCompressedStream(): m_pStrm;
OpenStormBento::LtcBenContainer* pBentoContainer;
- /*ULONG ulRet =*/ OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
+ sal_uLong ulRet = OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
+ if (ulRet != OpenStormBento::BenErr_OK)
+ return 0;
SvStream* pGrafStream = NULL;
diff --git a/lotuswordpro/source/filter/lwpidxmgr.cxx b/lotuswordpro/source/filter/lwpidxmgr.cxx
index da9ca4f..f4b68c6 100644
--- a/lotuswordpro/source/filter/lwpidxmgr.cxx
+++ b/lotuswordpro/source/filter/lwpidxmgr.cxx
@@ -69,6 +69,7 @@
**********************************************************************************************************************/
#include "lwpidxmgr.hxx"
+#include "lwptools.hxx"
const sal_uInt8 LwpIndexManager::MAXOBJECTIDS = 255;
@@ -122,8 +123,11 @@ void LwpIndexManager::Read(LwpSvStream* pStrm)
for (sal_uInt16 k = 0; k < m_nLeafCount; k++)
{
//Read leaf
- pStrm->Seek(m_ChildIndex[k]+LwpSvStream::LWP_STREAM_BASE);
+ sal_Int64 nPos = m_ChildIndex[k]+LwpSvStream::LWP_STREAM_BASE;
+ sal_Int64 nActualPos = pStrm->Seek(nPos);
+ if (nPos != nActualPos)
+ throw BadSeek();
//Old Code
//ReadLeafIndex(pStrm);
@@ -150,7 +154,7 @@ void LwpIndexManager::ReadRootData(LwpObjectStream* pObjStrm)
sal_uInt16 KeyCount = 0;
pObjStrm->QuickRead(&KeyCount, sizeof(KeyCount));
- m_nLeafCount = KeyCount + 1;
+ m_nLeafCount = KeyCount ? KeyCount + 1 : 0;
if(KeyCount)
{
@@ -160,7 +164,6 @@ void LwpIndexManager::ReadRootData(LwpObjectStream* pObjStrm)
m_RootObjs.push_back(akey);
- //sal_uInt8 k = 0;
sal_uInt16 k = 0;
for (k = 1; k < KeyCount; k++)
@@ -216,7 +219,9 @@ void LwpIndexManager::ReadObjIndexData(LwpObjectStream* pObjStrm)
}
for (k = 0; k < KeyCount; k++)
+ {
pObjStrm->QuickRead(&(vObjIndexs[k]->offset), sizeof(sal_uInt32));
+ }
for (k = 0; k < LeafCount; k++)
pObjStrm->QuickRead(&(m_TempVec[k]), sizeof(sal_uInt32));
@@ -224,7 +229,13 @@ void LwpIndexManager::ReadObjIndexData(LwpObjectStream* pObjStrm)
for( sal_uInt16 j=0; j<LeafCount; j++ )
{
- pObjStrm->GetStream()->Seek( m_TempVec[j]+LwpSvStream::LWP_STREAM_BASE);
+ sal_Int64 nPos = m_TempVec[j]+LwpSvStream::LWP_STREAM_BASE;
+ sal_Int64 nActualPos = pObjStrm->GetStream()->Seek(nPos);
+
+ if (nPos != nActualPos)
+ throw BadSeek();
+
+
ReadLeafIndex(pObjStrm->GetStream());
if(j!=LeafCount-1)
@@ -283,7 +294,7 @@ void LwpIndexManager::ReadLeafIndex( LwpSvStream *pStrm )
*/
void LwpIndexManager::ReadLeafData( LwpObjectStream *pObjStrm )
{
- sal_uInt16 KeyCount;
+ sal_uInt16 KeyCount=0;
pObjStrm->QuickRead(&KeyCount, sizeof(KeyCount));
if(KeyCount)
@@ -296,13 +307,13 @@ void LwpIndexManager::ReadLeafData( LwpObjectStream *pObjStrm )
for (sal_uInt8 k = 1; k < KeyCount; k++)
{
akey = new LwpKey();
- akey->id.ReadCompressed(pObjStrm, m_ObjectKeys[m_nKeyCount+k-1]->id);
+ akey->id.ReadCompressed(pObjStrm, m_ObjectKeys.at(m_nKeyCount+k-1)->id);
m_ObjectKeys.push_back(akey);
}
for (sal_uInt8 j = 0; j < KeyCount; j++)
{
- pObjStrm->QuickRead(&(m_ObjectKeys[m_nKeyCount+j]->offset), sizeof(sal_uInt32));
+ pObjStrm->QuickRead(&(m_ObjectKeys.at(m_nKeyCount+j)->offset), sizeof(sal_uInt32));
}
}
m_nKeyCount += KeyCount;
diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx
index 0100489..f4f3472 100644
--- a/lotuswordpro/source/filter/lwplayout.cxx
+++ b/lotuswordpro/source/filter/lwplayout.cxx
@@ -80,7 +80,8 @@
LwpVirtualLayout::LwpVirtualLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
: LwpDLNFPVList(objHdr, pStrm)
-{}
+{
+}
void LwpVirtualLayout::Read()
{
@@ -138,7 +139,7 @@ sal_Bool LwpVirtualLayout::HonorProtection()
if(!(m_nAttributes2 & STYLE2_HONORPROTECTION))
return sal_False;
- LwpVirtualLayout* pParent = static_cast<LwpVirtualLayout*> (GetParent()->obj());
+ LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
if(pParent && !pParent->IsHeader())
{
return pParent->HonorProtection();
@@ -166,7 +167,7 @@ sal_Bool LwpVirtualLayout::IsProtected()
{
sal_Bool bProtected = (m_nAttributes & STYLE_PROTECTED)!=0;
- LwpVirtualLayout* pParent = static_cast<LwpVirtualLayout*> (GetParent()->obj());
+ LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
if(pParent && !pParent->IsHeader())
{
if(pParent->HonorProtection()&&(pParent->HasProtection()||bProtected))
@@ -198,7 +199,7 @@ sal_Bool LwpVirtualLayout::HasProtection()
if(m_nAttributes & STYLE_PROTECTED)
return sal_True;
- LwpVirtualLayout* pParent = static_cast<LwpVirtualLayout*> (GetParent()->obj());
+ LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
if(pParent && !pParent->IsHeader())
{
return pParent->HasProtection();
@@ -229,7 +230,7 @@ LwpUseWhen* LwpVirtualLayout::GetUseWhen()
if(GetLayoutType()!=LWP_PAGE_LAYOUT)
{
//get parent
- LwpVirtualLayout* pParent = static_cast<LwpVirtualLayout*> (GetParent()->obj());
+ LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
if(pParent && !pParent->IsHeader()&& (pParent->GetLayoutType()!=LWP_PAGE_LAYOUT))
return pParent->GetUseWhen();
@@ -341,7 +342,7 @@ sal_Bool LwpVirtualLayout::IsMinimumHeight()
*/
LwpVirtualLayout* LwpVirtualLayout::GetParentLayout()
{
- return static_cast<LwpVirtualLayout*> (GetParent()->obj());
+ return dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
}
/**
@@ -351,12 +352,12 @@ LwpVirtualLayout* LwpVirtualLayout::GetParentLayout()
void LwpVirtualLayout::RegisterChildStyle()
{
//Register all children styles
- LwpVirtualLayout* pLayout = static_cast<LwpVirtualLayout*>(GetChildHead()->obj());
+ LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj());
while(pLayout)
{
pLayout->SetFoundry(m_pFoundry);
pLayout->RegisterStyle();
- pLayout = static_cast<LwpVirtualLayout*>(pLayout->GetNext()->obj());
+ pLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext()->obj());
}
}
@@ -370,7 +371,7 @@ sal_Bool LwpVirtualLayout::IsStyleLayout()
if (m_nAttributes3 & STYLE3_STYLELAYOUT)
return sal_True;
- LwpVirtualLayout* pParent =static_cast<LwpVirtualLayout*>(GetParent()->obj());
+ LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*>(GetParent()->obj());
if (pParent)
return pParent->IsStyleLayout();
return sal_False;
@@ -386,7 +387,7 @@ LwpVirtualLayout* LwpVirtualLayout::FindChildByType(LWP_LAYOUT_TYPE eType)
while(pID && !pID->IsNull())
{
- LwpVirtualLayout * pLayout = static_cast<LwpVirtualLayout *>(pID->obj());
+ LwpVirtualLayout * pLayout = dynamic_cast<LwpVirtualLayout *>(pID->obj());
if(!pLayout)
{
break;
@@ -446,30 +447,30 @@ LwpVirtualLayout* LwpAssociatedLayouts::GetLayout(LwpVirtualLayout *pStartLayout
if (!pStartLayout && !m_OnlyLayout.IsNull())
/* Looking for the first layout and there's only one layout in the list.*/
- return static_cast<LwpVirtualLayout*>(m_OnlyLayout.obj());
+ return dynamic_cast<LwpVirtualLayout*>(m_OnlyLayout.obj());
- LwpObjectHolder* pObjHolder =static_cast<LwpObjectHolder*>(m_Layouts.GetHead()->obj());
+ LwpObjectHolder* pObjHolder = dynamic_cast<LwpObjectHolder*>(m_Layouts.GetHead()->obj());
if(pObjHolder)
{
- pLayout = static_cast<LwpVirtualLayout*>(pObjHolder->GetObject()->obj());
+ pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject()->obj());
if(!pStartLayout )
return pLayout;
while(pObjHolder && pStartLayout != pLayout)
{
- pObjHolder = static_cast<LwpObjectHolder*>(pObjHolder->GetNext()->obj());
+ pObjHolder = dynamic_cast<LwpObjectHolder*>(pObjHolder->GetNext()->obj());
if(pObjHolder)
{
- pLayout = static_cast<LwpVirtualLayout*>(pObjHolder->GetObject()->obj());
+ pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject()->obj());
}
}
if(pObjHolder)
{
- pObjHolder = static_cast<LwpObjectHolder*>(pObjHolder->GetNext()->obj());
+ pObjHolder = dynamic_cast<LwpObjectHolder*>(pObjHolder->GetNext()->obj());
if(pObjHolder)
{
- pLayout = static_cast<LwpVirtualLayout*>(pObjHolder->GetObject()->obj());
+ pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject()->obj());
return pLayout;
}
}
@@ -496,16 +497,27 @@ void LwpHeadLayout::Read()
void LwpHeadLayout::RegisterStyle()
{
//Register all children styles
- LwpVirtualLayout* pLayout = static_cast<LwpVirtualLayout*>(GetChildHead()->obj());
+ LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj());
while(pLayout)
{
pLayout->SetFoundry(m_pFoundry);
//if the layout is relative to para, the layout will be registered in para
if(!pLayout->IsRelativeAnchored())
{
+ if (pLayout == this)
+ {
+ OSL_FAIL("Layout points to itself");
+ break;
+ }
pLayout->RegisterStyle();
}
- pLayout = static_cast<LwpVirtualLayout*>(pLayout->GetNext()->obj());
+ LwpVirtualLayout *pNext = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext()->obj());
+ if (pNext == pLayout)
+ {
+ OSL_FAIL("Layout points to itself");
+ break;
+ }
+ pLayout = pNext;
}
}
@@ -515,14 +527,14 @@ void LwpHeadLayout::RegisterStyle()
*/
LwpVirtualLayout* LwpHeadLayout::FindEnSuperTableLayout()
{
- LwpVirtualLayout* pLayout = static_cast<LwpVirtualLayout*>(GetChildHead()->obj());
+ LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj());
while(pLayout)
{
if(pLayout->GetLayoutType() == LWP_ENDNOTE_SUPERTABLE_LAYOUT)
{
return pLayout;
}
- pLayout = static_cast<LwpVirtualLayout*>(pLayout->GetNext()->obj());
+ pLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext()->obj());
}
return NULL;
}
@@ -645,12 +657,12 @@ LwpLayoutGeometry* LwpMiddleLayout::GetGeometry()
{
if( !m_LayGeometry.IsNull() )
{
- return ( static_cast<LwpLayoutGeometry*> (m_LayGeometry.obj()) );
+ return ( dynamic_cast<LwpLayoutGeometry*> (m_LayGeometry.obj()) );
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
- return pLay->GetGeometry();
+ LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
+ return pLay ? pLay->GetGeometry() : NULL;
}
return NULL;
}
@@ -697,8 +709,9 @@ sal_Bool LwpMiddleLayout::MarginsSameAsParent()
}
if(!m_BasedOnStyle.IsNull())
{
- LwpVirtualLayout* play = static_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
- play->MarginsSameAsParent();
+ LwpVirtualLayout* pLay = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
+ if (pLay)
+ pLay->MarginsSameAsParent();
}
return LwpVirtualLayout::MarginsSameAsParent();
@@ -715,7 +728,7 @@ double LwpMiddleLayout::GetMarginsValue(const sal_uInt8 &nWhichSide)
{
if ( MarginsSameAsParent() )
{
- LwpVirtualLayout* pParent = static_cast<LwpVirtualLayout*> (GetParent()->obj());
+ LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
if(pParent && !pParent->IsHeader())
{
fValue = pParent->GetMarginsValue(nWhichSide);
@@ -726,14 +739,14 @@ double LwpMiddleLayout::GetMarginsValue(const sal_uInt8 &nWhichSide)
if(m_nOverrideFlag & OVER_MARGINS)
{
- LwpLayoutMargins* pMar1 = static_cast<LwpLayoutMargins*> (m_LayMargins.obj());
+ LwpLayoutMargins* pMar1 = dynamic_cast<LwpLayoutMargins*> (m_LayMargins.obj());
if(pMar1)
{
fValue = pMar1->GetMargins()->GetMarginsValue(nWhichSide);
return fValue;
}
}
- LwpVirtualLayout* pStyle = static_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
+ LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
if(pStyle)
{
fValue = pStyle->GetMarginsValue(nWhichSide);
@@ -752,14 +765,14 @@ double LwpMiddleLayout::GetExtMarginsValue(const sal_uInt8 &nWhichSide)
double fValue = 0;
if(m_nOverrideFlag & OVER_MARGINS)
{
- LwpLayoutMargins* pMar1 = static_cast<LwpLayoutMargins*> (m_LayMargins.obj());
+ LwpLayoutMargins* pMar1 = dynamic_cast<LwpLayoutMargins*> (m_LayMargins.obj());
if(pMar1)
{
fValue = pMar1->GetExtMargins()->GetMarginsValue(nWhichSide);
return fValue;
}
}
- LwpVirtualLayout* pStyle = static_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
+ LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
if(pStyle)
{
fValue = pStyle->GetExtMarginsValue(nWhichSide);
@@ -777,13 +790,13 @@ LwpBorderStuff* LwpMiddleLayout::GetBorderStuff()
{
if(m_nOverrideFlag & OVER_BORDERS)
{
- LwpLayoutBorder* pLayoutBorder = static_cast<LwpLayoutBorder*>(m_LayBorderStuff.obj());
- return pLayoutBorder->GetBorderStuff();
+ LwpLayoutBorder* pLayoutBorder = dynamic_cast<LwpLayoutBorder*>(m_LayBorderStuff.obj());
+ return pLayoutBorder ? pLayoutBorder->GetBorderStuff() : NULL;
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
- return pLay->GetBorderStuff();
+ LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
+ return pLay ? pLay->GetBorderStuff() : NULL;
}
return NULL;
}
@@ -798,13 +811,13 @@ LwpBackgroundStuff* LwpMiddleLayout::GetBackgroundStuff()
{
if(m_nOverrideFlag & OVER_BACKGROUND)
{
- LwpLayoutBackground* pLayoutBackground = static_cast<LwpLayoutBackground*>(m_LayBackgroundStuff.obj());
- return pLayoutBackground->GetBackgoudStuff();
+ LwpLayoutBackground* pLayoutBackground = dynamic_cast<LwpLayoutBackground*>(m_LayBackgroundStuff.obj());
+ return pLayoutBackground ? pLayoutBackground->GetBackgoudStuff() : NULL;
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
- return pLay->GetBackgroundStuff();
+ LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
+ return pLay ? pLay->GetBackgroundStuff() : NULL;
}
return NULL;
}
@@ -905,13 +918,13 @@ LwpTabOverride* LwpMiddleLayout::GetTabOverride()
if(m_nAttributes & OVER_TABS)
{
if(!m_TabPiece.IsNull())
- return (LwpTabOverride*)static_cast<LwpTabPiece*>(m_TabPiece.obj())->GetOverride();
+ return (LwpTabOverride*) dynamic_cast<LwpTabPiece*>(m_TabPiece.obj())->GetOverride();
return NULL;
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
- return pLay->GetTabOverride();
+ LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
+ return pLay ? pLay->GetTabOverride() : NULL;
}
return NULL;
}
@@ -927,7 +940,7 @@ sal_uInt16 LwpMiddleLayout::GetScaleMode(void)
if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
return GetLayoutScale()->GetScaleMode();
else if (m_BasedOnStyle.obj())
- return static_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleMode();
+ return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleMode();
else
return (LwpLayoutScale::FIT_IN_FRAME | LwpLayoutScale::MAINTAIN_ASPECT_RATIO);
}
@@ -945,7 +958,7 @@ sal_uInt16 LwpMiddleLayout::GetScaleTile(void)
return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::TILED)
? 1 : 0;
else if (m_BasedOnStyle.obj())
- return static_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleTile();
+ return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleTile();
else
return 0;
}
@@ -965,7 +978,7 @@ sal_uInt16 LwpMiddleLayout::GetScaleCenter(void)
return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::CENTERED)
? 1 : 0;
else if (m_BasedOnStyle.obj())
- return static_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleCenter();
+ return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleCenter();
else
return 0;
}
@@ -984,7 +997,7 @@ sal_uInt32 LwpMiddleLayout::GetScalePercentage(void)
if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
return GetLayoutScale()->GetScalePercentage()/10;//m_nScalePercentage 1000 = 100%
else if (m_BasedOnStyle.obj())
- return static_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScalePercentage();
+ return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScalePercentage();
else
return 100;
}
@@ -1000,7 +1013,7 @@ double LwpMiddleLayout::GetScaleWidth(void)
if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleWidth());
else if (m_BasedOnStyle.obj())
- return static_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleWidth();
+ return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleWidth();
else
return 0;
}
@@ -1016,7 +1029,7 @@ double LwpMiddleLayout::GetScaleHeight(void)
if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleHeight());
else if (m_BasedOnStyle.obj())
- return static_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleHeight();
+ return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleHeight();
else
return 0;
}
@@ -1073,8 +1086,8 @@ sal_Bool LwpMiddleLayout::IsSizeRightToContainer(void)
}
else if (m_BasedOnStyle.obj())
{
- LwpMiddleLayout * pLayout = static_cast<LwpMiddleLayout *>(m_BasedOnStyle.obj());
- return pLayout->IsSizeRightToContainer();
+ LwpMiddleLayout * pLayout = dynamic_cast<LwpMiddleLayout *>(m_BasedOnStyle.obj());
+ return pLayout ? pLayout->IsSizeRightToContainer() : sal_False;
}
else
return sal_False;
@@ -1092,8 +1105,8 @@ sal_Bool LwpMiddleLayout::IsSizeRightToContent(void)
}
else if (m_BasedOnStyle.obj())
{
- LwpMiddleLayout * pLayout = static_cast<LwpMiddleLayout *>(m_BasedOnStyle.obj());
- return pLayout->IsSizeRightToContent();
+ LwpMiddleLayout * pLayout = dynamic_cast<LwpMiddleLayout *>(m_BasedOnStyle.obj());
+ return pLayout ? pLayout->IsSizeRightToContent() : sal_False;
}
else
return sal_False;
@@ -1191,8 +1204,8 @@ sal_Bool LwpMiddleLayout::IsAutoGrow()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
- return pLay->IsAutoGrow();
+ LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
+ return pLay ? pLay->IsAutoGrow() : sal_False;
}
return LwpVirtualLayout::IsAutoGrow();
}
@@ -1209,8 +1222,8 @@ sal_Bool LwpMiddleLayout::IsAutoGrowDown()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
- return pLay->IsAutoGrowDown();
+ LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
+ return pLay ? pLay->IsAutoGrowDown() : sal_False;
}
return LwpVirtualLayout::IsAutoGrowDown();
}
@@ -1227,8 +1240,8 @@ sal_Bool LwpMiddleLayout::IsAutoGrowUp()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
- return pLay->IsAutoGrowUp();
+ LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
+ return pLay ? pLay->IsAutoGrowUp() : sal_False;
}
return LwpVirtualLayout::IsAutoGrowUp();
}
@@ -1245,8 +1258,9 @@ sal_Bool LwpMiddleLayout::IsAutoGrowLeft()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
- return pLay->IsAutoGrowLeft();
+ LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
+ if (pLay)
+ return pLay->IsAutoGrowLeft();
}
return LwpVirtualLayout::IsAutoGrowLeft();
}
@@ -1263,8 +1277,8 @@ sal_Bool LwpMiddleLayout::IsAutoGrowRight()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
- return pLay->IsAutoGrowRight();
+ LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
+ return pLay ? pLay->IsAutoGrowRight() : sal_False;
}
return LwpVirtualLayout::IsAutoGrowRight();
}
@@ -1279,13 +1293,15 @@ sal_uInt8 LwpMiddleLayout::GetContentOrientation()
//content orientation in Graphic objects and OLE objects not supported now
if((m_nOverrideFlag & OVER_ROTATION)&& !m_LayGeometry.IsNull())
{
- LwpLayoutGeometry* pLayGeometry = static_cast<LwpLayoutGeometry*> (m_LayGeometry.obj());
- return pLayGeometry->GetContentOrientation();
+ LwpLayoutGeometry* pLayGeometry = dynamic_cast<LwpLayoutGeometry*> (m_LayGeometry.obj());
+ if (pLayGeometry)
+ return pLayGeometry->GetContentOrientation();
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
- return pLay->GetContentOrientation();
+ LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
+ if (pLay)
+ return pLay->GetContentOrientation();
}
return LwpVirtualLayout::GetContentOrientation();
}
@@ -1301,7 +1317,7 @@ sal_Bool LwpMiddleLayout::HonorProtection()
if(!(m_nAttributes2 & STYLE2_HONORPROTECTION))
return sal_False;
- LwpVirtualLayout* pParent = static_cast<LwpVirtualLayout*> (GetParent()->obj());
+ LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
if(pParent && !pParent->IsHeader())
{
return pParent->HonorProtection();
@@ -1318,8 +1334,9 @@ sal_Bool LwpMiddleLayout::HonorProtection()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
- return pLay->HonorProtection();
+ LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
+ if (pLay)
+ return pLay->HonorProtection();
}
return LwpVirtualLayout::HonorProtection();
@@ -1338,13 +1355,13 @@ sal_Bool LwpMiddleLayout::IsProtected()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
- bProtected = pLay->IsProtected();
+ LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
+ bProtected = pLay ? pLay->IsProtected() : sal_False;
}
else
bProtected = LwpVirtualLayout::IsProtected();
- LwpVirtualLayout* pParent = static_cast<LwpVirtualLayout*> (GetParent()->obj());
+ LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
if(pParent && !pParent->IsHeader())
{
/* If a parent's protected then none of its children can be accessed. */
@@ -1380,14 +1397,14 @@ sal_Bool LwpMiddleLayout::IsProtected()
*/
LwpVirtualLayout* LwpMiddleLayout::GetWaterMarkLayout()
{
- LwpVirtualLayout* pLay = static_cast<LwpVirtualLayout*>(GetChildHead()->obj());
+ LwpVirtualLayout* pLay = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj());
while(pLay)
{
if( pLay->IsForWaterMark())
{
return pLay;
}
- pLay = static_cast<LwpVirtualLayout*> (pLay->GetNext()->obj());
+ pLay = dynamic_cast<LwpVirtualLayout*> (pLay->GetNext()->obj());
}
return NULL;
}
@@ -1402,7 +1419,7 @@ XFBGImage* LwpMiddleLayout::GetXFBGImage()
if(pLay)
{
//test BGImage
- LwpGraphicObject* pGrfObj = static_cast<LwpGraphicObject*>(pLay->GetContent()->obj());
+ LwpGraphicObject* pGrfObj = dynamic_cast<LwpGraphicObject*>(pLay->GetContent()->obj());
if(pGrfObj)
{
XFBGImage* pXFBGImage = new XFBGImage();
@@ -1465,8 +1482,8 @@ sal_Bool LwpMiddleLayout::GetUsePrinterSettings()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
- return pLay->GetUsePrinterSettings();
+ LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
+ return pLay ? pLay->GetUsePrinterSettings() : sal_False;
}
return sal_False;
}
@@ -1541,14 +1558,14 @@ sal_uInt16 LwpLayout::GetNumCols()
{
if(m_nOverrideFlag & OVER_COLUMNS)
{
- LwpLayoutColumns* pLayColumns = static_cast<LwpLayoutColumns*>(m_LayColumns.obj());
+ LwpLayoutColumns* pLayColumns = dynamic_cast<LwpLayoutColumns*>(m_LayColumns.obj());
if(pLayColumns)
{
return pLayColumns->GetNumCols();
}
}
- LwpVirtualLayout* pStyle = static_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
+ LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
if(pStyle)
{
return pStyle->GetNumCols();
@@ -1566,14 +1583,14 @@ double LwpLayout::GetColWidth(sal_uInt16 nIndex)
{
if((m_nOverrideFlag & OVER_COLUMNS)||(m_nAttributes2 & STYLE2_LOCALCOLUMNINFO))
{
- LwpLayoutColumns* pLayColumns = static_cast<LwpLayoutColumns*>(m_LayColumns.obj());
+ LwpLayoutColumns* pLayColumns = dynamic_cast<LwpLayoutColumns*>(m_LayColumns.obj());
if(pLayColumns)
{
return pLayColumns->GetColWidth(nIndex);
}
}
- LwpVirtualLayout* pStyle = static_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
+ LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
if(pStyle)
{
return pStyle->GetColWidth(nIndex);
@@ -1591,14 +1608,14 @@ double LwpLayout::GetColGap(sal_uInt16 nIndex)
{
if((m_nOverrideFlag & OVER_COLUMNS)||(m_nAttributes2 & STYLE2_LOCALCOLUMNINFO))
{
- LwpLayoutColumns* pLayColumns = static_cast<LwpLayoutColumns*>(m_LayColumns.obj());
+ LwpLayoutColumns* pLayColumns = dynamic_cast<LwpLayoutColumns*>(m_LayColumns.obj());
if(pLayColumns)
{
return pLayColumns->GetColGap(nIndex);
}
}
- LwpVirtualLayout* pStyle = static_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
+ LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
if(pStyle)
{
return pStyle->GetColGap(nIndex);
@@ -1667,7 +1684,7 @@ XFColumnSep* LwpLayout::GetColumnSep()
{
//Get LwpLayoutGutters
- LwpLayoutGutters* pLayoutGutters = static_cast<LwpLayoutGutters*>(m_LayGutterStuff.obj());
+ LwpLayoutGutters* pLayoutGutters = dynamic_cast<LwpLayoutGutters*>(m_LayGutterStuff.obj());
if(!pLayoutGutters)
{
return NULL;
@@ -1750,8 +1767,8 @@ sal_uInt16 LwpLayout::GetUsePage()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpLayout* pLay = static_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
- return pLay->GetUsePage();
+ LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
+ return pLay ? pLay->GetUsePage() : 0;
}
return 0;
}
@@ -1768,8 +1785,8 @@ LwpUseWhen* LwpLayout::VirtualGetUseWhen()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpLayout* pLay = static_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
- return pLay->VirtualGetUseWhen();
+ LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
+ return pLay ? pLay->VirtualGetUseWhen() : NULL;
}
return LwpVirtualLayout::VirtualGetUseWhen();
}
@@ -1790,8 +1807,9 @@ sal_Bool LwpLayout::IsUseOnAllPages()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpLayout* pLay = static_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
- return pLay->IsUseOnAllPages();
+ LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
+ if (pLay)
+ return pLay->IsUseOnAllPages();
}
return LwpVirtualLayout::IsUseOnAllPages();
}
@@ -1812,8 +1830,9 @@ sal_Bool LwpLayout::IsUseOnAllEvenPages()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpLayout* pLay = static_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
- return pLay->IsUseOnAllEvenPages();
+ LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
+ if (pLay)
+ return pLay->IsUseOnAllEvenPages();
}
return LwpVirtualLayout::IsUseOnAllEvenPages();
}
@@ -1834,8 +1853,9 @@ sal_Bool LwpLayout::IsUseOnAllOddPages()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpLayout* pLay = static_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
- return pLay->IsUseOnAllOddPages();
+ LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
+ if (pLay)
+ return pLay->IsUseOnAllOddPages();
}
return LwpVirtualLayout::IsUseOnAllOddPages();
}
@@ -1856,8 +1876,9 @@ sal_Bool LwpLayout::IsUseOnPage()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpLayout* pLay = static_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
- return pLay->IsUseOnPage();
+ LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
+ if (pLay)
+ return pLay->IsUseOnPage();
}
return LwpVirtualLayout::IsUseOnPage();
}
@@ -1872,13 +1893,13 @@ LwpShadow* LwpLayout::GetShadow()
{
if(m_nOverrideFlag & OVER_SHADOW)
{
- LwpLayoutShadow* pLayoutShadow = static_cast<LwpLayoutShadow*>(m_LayShadow.obj());
- return pLayoutShadow->GetShadow();
+ LwpLayoutShadow* pLayoutShadow = dynamic_cast<LwpLayoutShadow*>(m_LayShadow.obj());
+ return pLayoutShadow ? pLayoutShadow->GetShadow() : NULL;
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpLayout* pLay = static_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
- return pLay->GetShadow();
+ LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
+ return pLay ? pLay->GetShadow() : NULL;
}
return NULL;
}
@@ -1946,11 +1967,11 @@ LwpVirtualLayout* LwpLayout::GetContainerLayout()
if(IsRelativeAnchored())
{
//get position
- LwpPara* pPara = static_cast<LwpPara*>(GetPosition()->obj());
+ LwpPara* pPara = dynamic_cast<LwpPara*>(GetPosition()->obj());
if(pPara)
{
LwpStory* pStory = pPara->GetStory();
- return pStory->GetTabLayout();
+ return pStory ? pStory->GetTabLayout() : NULL;
}
}
return GetParentLayout();
@@ -2022,8 +2043,9 @@ sal_uInt8 LwpPlacableLayout::GetWrapType()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpPlacableLayout* pLay = static_cast<LwpPlacableLayout*> ( m_BasedOnStyle.obj() );
- return pLay->GetWrapType();
+ LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*> ( m_BasedOnStyle.obj() );
+ if (pLay)
+ return pLay->GetWrapType();
}
return LAY_WRAP_AROUND;
}
@@ -2039,13 +2061,13 @@ LwpLayoutRelativity* LwpPlacableLayout::GetRelativityPiece()
{
if(m_nOverrideFlag & OVER_PLACEMENT)
{
- return static_cast<LwpLayoutRelativity*>(m_LayRelativity.obj());
+ return dynamic_cast<LwpLayoutRelativity*>(m_LayRelativity.obj());
}
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpPlacableLayout* pLay = static_cast<LwpPlacableLayout*> ( m_BasedOnStyle.obj() );
- return pLay->GetRelativityPiece();
+ LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*> ( m_BasedOnStyle.obj() );
+ return pLay ? pLay->GetRelativityPiece() : NULL;
}
return NULL;
}
@@ -2139,8 +2161,8 @@ sal_Int32 LwpPlacableLayout::GetBaseLineOffset()
}
else if( !m_BasedOnStyle.IsNull() )
{
- LwpPlacableLayout* pLay = static_cast<LwpPlacableLayout*> ( m_BasedOnStyle.obj() );
- return pLay->GetBaseLineOffset();
+ LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*> ( m_BasedOnStyle.obj() );
+ return pLay ? pLay->GetBaseLineOffset() : 0;
}
return 0;
diff --git a/lotuswordpro/source/filter/lwplayout.hxx b/lotuswordpro/source/filter/lwplayout.hxx
index 509d3e6..12e3832 100644
--- a/lotuswordpro/source/filter/lwplayout.hxx
+++ b/lotuswordpro/source/filter/lwplayout.hxx
@@ -303,7 +303,7 @@ public:
XFBGImage* GetXFBGImage();
virtual sal_Bool GetUsePrinterSettings();
- LwpLayoutScale* GetLayoutScale(){return static_cast<LwpLayoutScale*>(m_LayScale.obj());}
+ LwpLayoutScale* GetLayoutScale(){return dynamic_cast<LwpLayoutScale*>(m_LayScale.obj());}
sal_uInt16 GetScaleMode(void);
void SetScaleMode(sal_uInt16 nVal);
sal_uInt16 GetScaleTile(void);
diff --git a/lotuswordpro/source/filter/lwpmarker.cxx b/lotuswordpro/source/filter/lwpmarker.cxx
index b32737d..155dc32 100644
--- a/lotuswordpro/source/filter/lwpmarker.cxx
+++ b/lotuswordpro/source/filter/lwpmarker.cxx
@@ -137,7 +137,7 @@ OUString LwpCHBlkMarker::GetPromptText()
{
LwpStory* pStory = NULL;
if (m_objPromptStory.obj())
- pStory = static_cast<LwpStory*>(m_objPromptStory.obj());
+ pStory = dynamic_cast<LwpStory*>(m_objPromptStory.obj());
if (pStory)
return pStory->GetContentText();
return A2OUSTR("");
@@ -380,6 +380,9 @@ sal_Bool LwpBookMark::IsRightName(OUString sName)
LwpFieldMark::LwpFieldMark(LwpObjectHeader &objHdr, LwpSvStream *pStrm)
: LwpStoryMarker(objHdr,pStrm)
+ , m_nExtra(0)
+ , m_nFlag(0)
+ , m_nFieldType(0)
, m_bHasStyle(sal_False)
, m_bHasStart(sal_False)
, m_pFrib(NULL)
diff --git a/lotuswordpro/source/filter/lwpmarker.hxx b/lotuswordpro/source/filter/lwpmarker.hxx
index a687d71..772e655 100644
--- a/lotuswordpro/source/filter/lwpmarker.hxx
+++ b/lotuswordpro/source/filter/lwpmarker.hxx
@@ -203,7 +203,6 @@ public:
void Read();
void ParseIndex(OUString& sKey1,OUString& sKey2);
void ParseTOC(OUString& sLevel,OUString& sText);
-// sal_uInt8 ParseCrossRef(OUString& sMarkName);
sal_uInt16 GetFieldType(){return m_nFieldType;}
sal_Bool IsFormulaInsert();
sal_Bool IsDateTimeField(sal_uInt8& type,OUString& formula);
diff --git a/lotuswordpro/source/filter/lwpobjfactory.cxx b/lotuswordpro/source/filter/lwpobjfactory.cxx
index 0f53e28..2043c31 100644
--- a/lotuswordpro/source/filter/lwpobjfactory.cxx
+++ b/lotuswordpro/source/filter/lwpobjfactory.cxx
@@ -110,44 +110,28 @@
LwpObjectFactory::LwpObjectFactory(LwpSvStream* pSvStream)
: m_nNumObjs(0), m_pSvStream(pSvStream)
{
- m_ObjList.clear();
+ m_IdToObjList.clear();
}
LwpObjectFactory::~LwpObjectFactory()
{
-// m_pMgr = NULL;
- if(!m_ObjList.empty())
+ if(!m_IdToObjList.empty())
ClearObjectMap();
}
/**
- * @descr create the single object factory
-*/
-/*
-LwpObjectFactory* LwpObjectFactory::Instance(LwpSvStream* pStream)
-{
- if(m_pMgr == NULL)
- {
- if(pStream)
- {
- m_pMgr = new LwpObjectFactory(pStream);
- }
- }
- return(m_pMgr);
-}*/
-/**
* @descr clear object map and delete all objects
*/
void LwpObjectFactory::ClearObjectMap()
{
- LwpObjMap::iterator it = m_ObjList.begin();
- while( it!=m_ObjList.end() )
+ LwpIdToObjMap::iterator it = m_IdToObjList.begin();
+ while( it!=m_IdToObjList.end() )
{
- delete (*it).second;
- (*it).second = NULL;
+ delete it->second;
+ it->second = NULL;
++it;
}
- m_ObjList.clear();
+ m_IdToObjList.clear();
}
/**
* @descr read the index manager
@@ -713,7 +697,7 @@ LwpObject* LwpObjectFactory::CreateObject(sal_uInt32 type, LwpObjectHeader &objH
if(newObj)
{
newObj->QuickRead();
- m_ObjList.insert(LwpObjMap::value_type(*objHdr.GetID(), newObj));
+ m_IdToObjList.insert(LwpIdToObjMap::value_type(*objHdr.GetID(), newObj));
}
return(newObj);
@@ -730,12 +714,22 @@ LwpObject* LwpObjectFactory::QueryObject(const LwpObjectID &objID)
//Read the object from file
sal_uInt32 nStreamOffset = m_IndexMgr.GetObjOffset(objID);
if(nStreamOffset == BAD_OFFSET) //does not find the offset in index manager
+ return NULL;
+
+ sal_Int64 nDesiredPos = nStreamOffset + LwpSvStream::LWP_STREAM_BASE;
+ if (nDesiredPos != m_pSvStream->Seek(nDesiredPos))
+ return NULL;
+ LwpObjectHeader objHdr;
+ if (!objHdr.Read(*m_pSvStream))
+ return NULL;
+
+ LwpObjectID* pId = objHdr.GetID();
+ if (pId && (*pId != objID))
{
+ OSL_FAIL("apparently incorrect objid, invalidating");
return NULL;
}
- m_pSvStream->Seek( nStreamOffset + LwpSvStream::LWP_STREAM_BASE );
- LwpObjectHeader objHdr;
- objHdr.Read(*m_pSvStream);
+
obj = CreateObject(objHdr.GetTag(), objHdr);
}
return obj;
@@ -746,8 +740,8 @@ LwpObject* LwpObjectFactory::QueryObject(const LwpObjectID &objID)
*/
LwpObject* LwpObjectFactory::FindObject(const LwpObjectID &objID)
{
- LwpObjMap::const_iterator it = m_ObjList.find(objID);
- if (it != m_ObjList.end()) {
+ LwpIdToObjMap::const_iterator it = m_IdToObjList.find(objID);
+ if (it != m_IdToObjList.end()) {
return((*it).second);
}
else
@@ -761,7 +755,7 @@ LwpObject* LwpObjectFactory::FindObject(const LwpObjectID &objID)
void LwpObjectFactory::ReleaseObject(const LwpObjectID &objID)
{
LwpObject* obj = FindObject( objID );
- m_ObjList.erase(objID);
+ m_IdToObjList.erase(objID);
if( obj )
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list