diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-04-11 21:19:54 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-04-11 21:41:57 +0100 |
commit | 278831e37a23e9e2e29ca811c3a5398b7c67464d (patch) | |
tree | 203ea28c54dcd469bc8b384053e305c2c775ee92 | |
parent | 03894d18889d7bc79b3d4f000c0df7065ea81ee2 (diff) |
fix what there is to fix
55 files changed, 751 insertions, 811 deletions
diff --git a/lotuswordpro/source/filter/LotusWordProImportFilter.cxx b/lotuswordpro/source/filter/LotusWordProImportFilter.cxx index 374965d58..47bb7a1f9 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 506bb8f21..c2ec12351 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 ac9ca62a1..5cbce8df7 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 08304de47..4fc74cddf 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 9c10b6d7c..434cd3208 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 c43a50be1..37036dfe2 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 a50e86127..3dfb96287 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 eeaf7c241..d447d9ccd 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 459d56c5f..1e3c931a5 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 1444440cc..ebe982248 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 1ed45d3dc..fdceee715 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 7701a600a..37db2dd3f 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 ebd0fd417..866d3a010 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 4e2903b34..cc28d0662 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 be3888d05..b9af6dae5 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 e009f18e4..875446999 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 563c68912..e10b6c1b7 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 6f427afad..efc863f1f 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 583eab525..ad9dbc0aa 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 f3fa7a186..e95190e45 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 3499f7945..3d377a163 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 61e31137f..b58e26970 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 efc8a0e01..72503aa6a 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 da9ca4fe3..f4b68c623 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 01004894b..f4f3472ce 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 509d3e699..12e3832f4 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 b32737d41..155dc32e7 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 a687d71a1..772e65532 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 0f53e2812..2043c31ad 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 ) delete obj; } diff --git a/lotuswordpro/source/filter/lwpobjfactory.hxx b/lotuswordpro/source/filter/lwpobjfactory.hxx index f30e9e346..f9a25e8bb 100644 --- a/lotuswordpro/source/filter/lwpobjfactory.hxx +++ b/lotuswordpro/source/filter/lwpobjfactory.hxx @@ -101,8 +101,8 @@ private: return(rKey1==rKey2); } }; - typedef boost::unordered_map<LwpObjectID, LwpObject *, hashFunc, eqFunc> LwpObjMap; - LwpObjMap m_ObjList; + typedef boost::unordered_map<LwpObjectID, LwpObject *, hashFunc, eqFunc> LwpIdToObjMap; + LwpIdToObjMap m_IdToObjList; LwpIndexManager m_IndexMgr; void ClearObjectMap(); diff --git a/lotuswordpro/source/filter/lwpobjhdr.cxx b/lotuswordpro/source/filter/lwpobjhdr.cxx index 2e706d422..7103b577c 100644 --- a/lotuswordpro/source/filter/lwpobjhdr.cxx +++ b/lotuswordpro/source/filter/lwpobjhdr.cxx @@ -74,9 +74,8 @@ LwpObjectHeader::LwpObjectHeader() /** * @descr read header from stream */ -void LwpObjectHeader::Read(LwpSvStream &rStrm) +bool LwpObjectHeader::Read(LwpSvStream &rStrm) { - sal_uInt8 nFlagBits = 0; sal_uInt32 nVersionID = 0; sal_uInt32 nRefCount = 0; @@ -84,6 +83,8 @@ void LwpObjectHeader::Read(LwpSvStream &rStrm) sal_uInt32 nNextVersionID = 0; sal_uInt32 nHeaderSize = 0; + sal_Int64 nStartPos = rStrm.Tell(); + if ( LwpFileHeader::m_nFileRevision < 0x000B) { rStrm.Read(&m_nTag, sizeof(m_nTag)); @@ -196,6 +197,8 @@ void LwpObjectHeader::Read(LwpSvStream &rStrm) m_bCompressed = sal_True; } } + sal_Int64 nEndPos = rStrm.Tell(); + return (nStartPos + nHeaderSize == nEndPos); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lotuswordpro/source/filter/lwpobjhdr.hxx b/lotuswordpro/source/filter/lwpobjhdr.hxx index a36564acd..bb80a1d13 100644 --- a/lotuswordpro/source/filter/lwpobjhdr.hxx +++ b/lotuswordpro/source/filter/lwpobjhdr.hxx @@ -112,7 +112,7 @@ private: }; public: - void Read(LwpSvStream &pStrm); + bool Read(LwpSvStream &pStrm); inline sal_uInt32 GetTag(); inline sal_uInt32 GetSize(); inline LwpObjectID* GetID(); diff --git a/lotuswordpro/source/filter/lwpobjstrm.cxx b/lotuswordpro/source/filter/lwpobjstrm.cxx index 8e61d444e..9d8f3d23b 100644 --- a/lotuswordpro/source/filter/lwpobjstrm.cxx +++ b/lotuswordpro/source/filter/lwpobjstrm.cxx @@ -100,6 +100,7 @@ void LwpObjectStream::Read2Buffer() if( m_bCompressed ) { sal_uInt8* pCompressBuffer = new sal_uInt8[m_nBufSize]; + memset(pCompressBuffer, 0, m_nBufSize); m_pStrm->Read(pCompressBuffer, m_nBufSize); sal_uInt8 pTempDst[IO_BUFFERSIZE]; @@ -165,6 +166,7 @@ void LwpObjectStream::ReleaseBuffer() */ sal_uInt16 LwpObjectStream::QuickRead(void* buf, sal_uInt16 len) { + memset(buf, 0, len); if( len > m_nBufSize - m_nReadPos ) { assert(false); @@ -304,6 +306,8 @@ sal_uInt16 LwpObjectStream::DecompressBuffer(sal_uInt8* pDst, sal_uInt8* pSrc, s // where zzzzzz is the count - 1 of compressed 0 bytes Cnt = (*pSrc++ & 0x3F) + 1; + if (DstSize+Cnt >= IO_BUFFERSIZE) + throw BadDecompress(); memset(pDst, 0, Cnt); pDst += Cnt; DstSize += Cnt; @@ -317,15 +321,21 @@ sal_uInt16 LwpObjectStream::DecompressBuffer(sal_uInt8* pDst, sal_uInt8* pSrc, s // and nnn is the count - 1 of following non-zero bytes Cnt = ((*pSrc & 0x38) >> 3) + 1; + if (DstSize+Cnt >= IO_BUFFERSIZE) + throw BadDecompress(); memset(pDst, 0, Cnt); pDst += Cnt; DstSize += Cnt; Cnt = (*pSrc++ & 0x07) + 1; + if (Size < Cnt + 1) + throw BadDecompress(); + Size -= Cnt + 1; + if (DstSize+Cnt >= IO_BUFFERSIZE) + throw BadDecompress(); memcpy(pDst, pSrc, Cnt); pDst += Cnt; DstSize += Cnt; pSrc += Cnt; - Size -= Cnt + 1; break; case 0x80: @@ -344,14 +354,21 @@ sal_uInt16 LwpObjectStream::DecompressBuffer(sal_uInt8* pDst, sal_uInt8* pSrc, s // nnnnnn is the count less 1 of following non-zero bytes Cnt = (*pSrc++ & 0x3F) + 1; + if (Size < Cnt + 1) + throw BadDecompress(); + Size -= Cnt + 1; + if (DstSize+Cnt >= IO_BUFFERSIZE) + throw BadDecompress(); memcpy(pDst, pSrc, Cnt); pDst += Cnt; DstSize += Cnt; pSrc += Cnt; - Size -= Cnt + 1; break; } assert(DstSize < IO_BUFFERSIZE); + if (DstSize >= IO_BUFFERSIZE) + throw BadDecompress(); + } return(static_cast<sal_uInt16>(DstSize)); } diff --git a/lotuswordpro/source/filter/lwpoverride.cxx b/lotuswordpro/source/filter/lwpoverride.cxx index 326346149..032ac03b5 100644 --- a/lotuswordpro/source/filter/lwpoverride.cxx +++ b/lotuswordpro/source/filter/lwpoverride.cxx @@ -612,8 +612,6 @@ void LwpIndentOverride::OverrideRelative(sal_uInt16 relative) void LwpSpacingOverride::Override(LwpSpacingOverride* other) { -// if (IsAlwaysOverridden()) -// other->SetAlways(IsAlways());//To be done if (other) { m_pSpacing->Override(other->GetSpacing()); diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx index 296196111..f2cca6176 100644 --- a/lotuswordpro/source/filter/lwppagelayout.cxx +++ b/lotuswordpro/source/filter/lwppagelayout.cxx @@ -269,7 +269,9 @@ void LwpPageLayout::ParseFootNoteSeparator(XFPageMaster * pm1) LwpDocument* pDocument = m_pFoundry->GetDocument(); if(pDocument) { - LwpFootnoteOptions* pFootnoteOpts = static_cast<LwpFootnoteOptions*>(pDocument->GetValidFootnoteOpts()->obj()); + LwpObjectID* pFontnodeId = pDocument->GetValidFootnoteOpts(); + + LwpFootnoteOptions* pFootnoteOpts = pFontnodeId ? dynamic_cast<LwpFootnoteOptions*>(pFontnodeId->obj()) : NULL; if(pFootnoteOpts) { LwpFootnoteSeparatorOptions* pFootnoteSep = pFootnoteOpts->GetFootnoteSeparator(); @@ -476,8 +478,8 @@ void LwpPageLayout::ConvertFillerPageText(XFContentContainer* pCont) { //get filerpage story from division info LwpDocument* pDoc = m_pFoundry->GetDocument(); - LwpDivInfo* pDivInfo = static_cast<LwpDivInfo*>(pDoc->GetDivInfoID()->obj()); - LwpStory* pStory = static_cast<LwpStory*>(pDivInfo->GetFillerPageTextID()->obj()); + LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(pDoc->GetDivInfoID()->obj()); + LwpStory* pStory = dynamic_cast<LwpStory*>(pDivInfo->GetFillerPageTextID()->obj()); //parse fillerpage story if(pStory) @@ -500,24 +502,24 @@ void LwpPageLayout::ResetXFColumns() LwpHeaderLayout* LwpPageLayout::GetHeaderLayout() { - LwpVirtualLayout* pLay = static_cast<LwpVirtualLayout*>(GetChildHead()->obj()); + LwpVirtualLayout* pLay = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj()); while(pLay) { if( pLay->GetLayoutType() == LWP_HEADER_LAYOUT ) return ( static_cast<LwpHeaderLayout*> (pLay) ); - pLay = static_cast<LwpVirtualLayout*> (pLay->GetNext()->obj()); + pLay = dynamic_cast<LwpVirtualLayout*> (pLay->GetNext()->obj()); } return NULL; } LwpFooterLayout* LwpPageLayout::GetFooterLayout() { - LwpVirtualLayout* pLay = static_cast<LwpVirtualLayout*>(GetChildHead()->obj()); + LwpVirtualLayout* pLay = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj()); while(pLay) { if( pLay->GetLayoutType() == LWP_FOOTER_LAYOUT ) return ( static_cast<LwpFooterLayout*> (pLay) ); - pLay = static_cast<LwpVirtualLayout*> (pLay->GetNext()->obj()); + pLay = dynamic_cast<LwpVirtualLayout*> (pLay->GetNext()->obj()); } return NULL; } @@ -530,7 +532,7 @@ LwpPageLayout* LwpPageLayout::GetOddChildLayout() { if(IsComplex()) { - LwpVirtualLayout* pLay = static_cast<LwpVirtualLayout*>(GetChildHead()->obj()); + LwpVirtualLayout* pLay = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj()); while(pLay) { if( pLay->GetLayoutType() == LWP_PAGE_LAYOUT ) @@ -542,7 +544,7 @@ LwpPageLayout* LwpPageLayout::GetOddChildLayout() return pPageLayout; } } - pLay = static_cast<LwpVirtualLayout*> (pLay->GetNext()->obj()); + pLay = dynamic_cast<LwpVirtualLayout*> (pLay->GetNext()->obj()); } } return NULL; @@ -574,11 +576,11 @@ sal_Int32 LwpPageLayout::GetPageNumber(sal_uInt16 nLayoutNumber) sal_Int16 nPageNumber = -1; LwpFoundry* pFoundry = this->GetFoundry(); LwpDocument* pDoc = pFoundry->GetDocument(); - LwpDLVListHeadTailHolder* pHeadTail = static_cast<LwpDLVListHeadTailHolder*>(pDoc->GetPageHintsID()->obj()); + LwpDLVListHeadTailHolder* pHeadTail = dynamic_cast<LwpDLVListHeadTailHolder*>(pDoc->GetPageHintsID()->obj()); if(!pHeadTail) return nPageNumber; //get first pagehint - LwpPageHint* pPageHint =static_cast<LwpPageHint*>(pHeadTail->GetHead()->obj()); + LwpPageHint* pPageHint = dynamic_cast<LwpPageHint*>(pHeadTail->GetHead()->obj()); while(pPageHint) { if(*(this->GetObjectID()) == *(pPageHint->GetPageLayoutID())) @@ -608,7 +610,7 @@ sal_Int32 LwpPageLayout::GetPageNumber(sal_uInt16 nLayoutNumber) } } - pPageHint = static_cast<LwpPageHint*>(pPageHint->GetNext()->obj()); + pPageHint = dynamic_cast<LwpPageHint*>(pPageHint->GetNext()->obj()); } if(nPageNumber>=0) { @@ -709,7 +711,7 @@ sal_Bool LwpPageLayout::operator<(LwpPageLayout& Other) */ LwpPara* LwpPageLayout::GetPagePosition() { - LwpPara* pPara = static_cast<LwpPara*>(GetPosition()->obj()); + LwpPara* pPara = dynamic_cast<LwpPara*>(GetPosition()->obj()); if(pPara) return pPara; //Get the position from its related section @@ -720,7 +722,7 @@ LwpPara* LwpPageLayout::GetPagePosition() while( (pSection = pFoundry->EnumSections(pSection)) ) { if(pSection->GetPageLayout() == this) - return static_cast<LwpPara*>(pSection->GetPosition()->obj()); + return dynamic_cast<LwpPara*>(pSection->GetPosition()->obj()); } } @@ -784,15 +786,15 @@ void LwpHeaderLayout::ParseMargins(XFHeaderStyle* ph1) } //Set left,right,bottom margins - LwpMiddleLayout* parent = static_cast<LwpMiddleLayout*> (GetParent()->obj()); + LwpMiddleLayout* parent = dynamic_cast<LwpMiddleLayout*> (GetParent()->obj()); //left margin in SODC: the space from the left edge of body to the left edge of header - double left = GetMarginsValue(MARGIN_LEFT) - parent->GetMarginsValue(MARGIN_LEFT); + double left = GetMarginsValue(MARGIN_LEFT) - (parent ? parent->GetMarginsValue(MARGIN_LEFT) : 0); if(left<=0) //The left margin in SODC can not be minus value { left = -1; } //left margin in SODC: the space from the right edge of header to the right edge of body - double right = GetMarginsValue(MARGIN_RIGHT) - parent->GetMarginsValue(MARGIN_RIGHT); + double right = GetMarginsValue(MARGIN_RIGHT) - (parent ? parent->GetMarginsValue(MARGIN_RIGHT) : 0); if(right<=0)//The right margin in SODC can not be minus value { right = -1; @@ -952,13 +954,13 @@ void LwpFooterLayout::ParseMargins(XFFooterStyle* pFooterStyle) } //Set left,right,top margins - LwpMiddleLayout* parent = static_cast<LwpMiddleLayout*> (GetParent()->obj()); - double left = GetMarginsValue(MARGIN_LEFT) - parent->GetMarginsValue(MARGIN_LEFT); + LwpMiddleLayout* parent = dynamic_cast<LwpMiddleLayout*> (GetParent()->obj()); + double left = GetMarginsValue(MARGIN_LEFT) - (parent ? parent->GetMarginsValue(MARGIN_LEFT) : 0); if(left<=0) //The left margin in SODC can not be minus value { left = -1; } - double right = GetMarginsValue(MARGIN_RIGHT) - parent->GetMarginsValue(MARGIN_RIGHT); + double right = GetMarginsValue(MARGIN_RIGHT) - (parent ? parent->GetMarginsValue(MARGIN_RIGHT) : 0); if(right<=0)//The left margin in SODC can not be minus value { right = -1; diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx index 358d9da81..2c5d70992 100644 --- a/lotuswordpro/source/filter/lwppara.cxx +++ b/lotuswordpro/source/filter/lwppara.cxx @@ -260,12 +260,11 @@ void LwpPara::XFConvert(XFContentContainer* pCont) { m_pXFContainer = pCont; - if (static_cast<LwpStory*>(m_Story.obj())->GetDropcapFlag() == sal_True) + LwpStory *pStory = dynamic_cast<LwpStory*>(m_Story.obj()); + + if (pStory && pStory->GetDropcapFlag() == sal_True) { ParseDropcapContent(); - /*LwpObject* pNextPara = GetNext()->obj(); - if(pNextPara) - pNextPara->XFConvert(pCont);*/ return; } @@ -280,8 +279,8 @@ void LwpPara::XFConvert(XFContentContainer* pCont) if(m_SectionStyleName.getLength()>0) { XFSection* pSection = CreateXFSection(); - LwpStory* pStory = static_cast<LwpStory*> ( m_Story.obj() ); - pStory->AddXFContent(pSection); + if (pStory) + pStory->AddXFContent(pSection); //pSection->Add(pPara); m_pXFContainer = pSection; } @@ -310,24 +309,15 @@ void LwpPara::XFConvert(XFContentContainer* pCont) if (m_pBreaks) AddBreakAfter(m_pXFContainer); - - // maybe useful for futer version - // deleted by - // AddTabStopForTOC(); - - //Caller is responsible for calling the next para object - /*LwpObject* pNextPara = GetNext()->obj(); - if(pNextPara) - pNextPara->XFConvert( m_pXFContainer );*/ } sal_Bool LwpPara::RegisterMasterPage(XFParaStyle* pBaseStyle) { sal_Bool bSuccess = sal_False; //get story - LwpStory* pStory = static_cast<LwpStory*>(m_Story.obj()); + LwpStory* pStory = dynamic_cast<LwpStory*>(m_Story.obj()); //if pagelayout is modified, register the pagelayout - if(pStory->IsPMModified()) + if(pStory && pStory->IsPMModified()) { sal_Bool bNewSection = sal_False; bNewSection = pStory->IsNeedSection(); @@ -386,7 +376,7 @@ void LwpPara::RegisterStyle() pOverStyle->SetStyleName(A2OUSTR("")); LwpParaProperty* pProps = m_pProps; sal_uInt32 PropType; - LwpParaStyle* pParaStyle = static_cast<LwpParaStyle*>(m_ParaStyle.obj()); + LwpParaStyle* pParaStyle = dynamic_cast<LwpParaStyle*>(m_ParaStyle.obj()); while(pProps) { PropType = pProps->GetType(); @@ -700,7 +690,7 @@ void LwpPara::RegisterStyle() } if (pPara && pPara->GetPrevious()) - pPrePara = static_cast<LwpPara*>(pPara->GetPrevious()->obj(VO_PARA)); + pPrePara = dynamic_cast<LwpPara*>(pPara->GetPrevious()->obj(VO_PARA)); else pPrePara=NULL; @@ -759,7 +749,7 @@ void LwpPara::RegisterStyle() if (noSpacing && GetPrevious()) { - LwpPara* pPrePara = static_cast<LwpPara*>(GetPrevious()->obj()); + LwpPara* pPrePara = dynamic_cast<LwpPara*>(GetPrevious()->obj()); if (pPrePara && pPrePara->GetBelowSpacing()!=0) { pOverStyle = new XFParaStyle; @@ -840,8 +830,8 @@ void LwpPara::RegisterTabStyle(XFParaStyle* pXFParaStyle) LwpTabOverride aFinaOverride; LwpTabOverride* pBase = NULL; //get the tabrack from the current layout - LwpStory* pStory = static_cast<LwpStory*>(m_Story.obj()); - LwpMiddleLayout* pLayout = pStory->GetTabLayout(); + LwpStory* pStory = dynamic_cast<LwpStory*>(m_Story.obj()); + LwpMiddleLayout* pLayout = pStory ? pStory->GetTabLayout() : NULL; if(pLayout) { pBase = pLayout->GetTabOverride(); @@ -925,7 +915,7 @@ LwpVirtualLayout* LwpPara::GetLayoutWithMyStory() LwpStory* pMyStory = NULL; if (!m_Story.IsNull()) { - pMyStory = static_cast<LwpStory*>(m_Story.obj(VO_STORY)); + pMyStory = dynamic_cast<LwpStory*>(m_Story.obj(VO_STORY)); if (!pMyStory) { return NULL; diff --git a/lotuswordpro/source/filter/lwppara.hxx b/lotuswordpro/source/filter/lwppara.hxx index b381d686c..537b72a9f 100644 --- a/lotuswordpro/source/filter/lwppara.hxx +++ b/lotuswordpro/source/filter/lwppara.hxx @@ -386,7 +386,7 @@ inline LwpObjectID* LwpPara::GetStoryID() inline LwpStory* LwpPara::GetStory() { if (m_Story.obj()) - return static_cast<LwpStory*>(m_Story.obj()); + return dynamic_cast<LwpStory*>(m_Story.obj()); return NULL; } diff --git a/lotuswordpro/source/filter/lwppara1.cxx b/lotuswordpro/source/filter/lwppara1.cxx index 957dbea32..6a6184ce8 100644 --- a/lotuswordpro/source/filter/lwppara1.cxx +++ b/lotuswordpro/source/filter/lwppara1.cxx @@ -175,13 +175,13 @@ LwpPara* LwpPara::GetParent() if (level != 1) { - pPara = static_cast<LwpPara*>(GetPrevious()->obj()); + pPara = dynamic_cast<LwpPara*>(GetPrevious()->obj()); while (pPara) { otherlevel = pPara->GetLevel(); if ((otherlevel < level) || (otherlevel && (level == 0))) return pPara; - pPara = static_cast<LwpPara*>(pPara->GetPrevious()->obj()); + pPara = dynamic_cast<LwpPara*>(pPara->GetPrevious()->obj()); } } return NULL; @@ -237,12 +237,12 @@ void LwpPara::GetParaNumber(sal_uInt16 nPosition, ParaNumbering* pParaNumbering) //get suffix text frib if ( (pFrib = pFrib->GetNext()) ) { -// if((pFrib->GetType() == FRIB_TAG_TEXT) && -// (pFrib->GetModifiers()->aTxtAttrOverride.GetHideLevels() == nHideLevels)) if( pFrib->GetType() == FRIB_TAG_TEXT ) { - if ((pFrib->GetNext()->GetType() == FRIB_TAG_TEXT ) || - (pFrib->GetModifiers()->aTxtAttrOverride.GetHideLevels() == nHideLevels)) + if ( + (pFrib->GetNext() && pFrib->GetNext()->GetType() == FRIB_TAG_TEXT) || + (pFrib->GetModifiers()->aTxtAttrOverride.GetHideLevels() == nHideLevels) + ) { pParaNumbering->pSuffix = static_cast<LwpFribText*>(pFrib); } @@ -323,21 +323,21 @@ void LwpPara::OverrideSpacing(LwpSpacingOverride* base,LwpSpacingOverride* over, { if (base)//the latter two parameter never be null { - over->Override(base); + if (over) + over->Override(base); LwpParaStyle::ApplySpacing(this,pOverStyle,base); } else LwpParaStyle::ApplySpacing(this,pOverStyle,over); } -//add by , 01/25/2005 /** * @short: Get parastyle object according to the objID. * @return: pointer to the parastyle. */ LwpParaStyle* LwpPara::GetParaStyle() { - return static_cast<LwpParaStyle*>(m_ParaStyle.obj(VO_PARASTYLE)); + return dynamic_cast<LwpParaStyle*>(m_ParaStyle.obj(VO_PARASTYLE)); } /** @@ -488,8 +488,9 @@ void LwpPara::OverrideParaBullet(LwpParaProperty* pProps) m_pBullOver = pFinalBullet.release(); if (!aSilverBulletID.IsNull()) { - m_pSilverBullet = static_cast<LwpSilverBullet*>(aSilverBulletID.obj(VO_SILVERBULLET)); - m_pSilverBullet->SetFoundry(m_pFoundry); + m_pSilverBullet = dynamic_cast<LwpSilverBullet*>(aSilverBulletID.obj(VO_SILVERBULLET)); + if (m_pSilverBullet) + m_pSilverBullet->SetFoundry(m_pFoundry); } m_aSilverBulletID = aSilverBulletID; @@ -506,8 +507,9 @@ void LwpPara::OverrideParaBullet(LwpParaProperty* pProps) { m_bHasBullet = sal_True; - m_pSilverBullet = static_cast<LwpSilverBullet*>(m_aSilverBulletID.obj(VO_SILVERBULLET)); - m_pSilverBullet->SetFoundry(m_pFoundry); + m_pSilverBullet = dynamic_cast<LwpSilverBullet*>(m_aSilverBulletID.obj(VO_SILVERBULLET)); + if (m_pSilverBullet) + m_pSilverBullet->SetFoundry(m_pFoundry); } std::auto_ptr<LwpBulletOverride> pBulletOverride(pBullOver->clone()); @@ -578,7 +580,7 @@ void LwpPara::FindLayouts() { m_Fribs.SetPara(this); m_Fribs.FindLayouts(); - LwpPara* pNextPara = static_cast<LwpPara*>(GetNext()->obj()); + LwpPara* pNextPara = dynamic_cast<LwpPara*>(GetNext()->obj()); if(pNextPara) { pNextPara->FindLayouts(); @@ -640,96 +642,15 @@ sal_Bool LwpPara::ComparePagePosition(LwpVirtualLayout * pPreLayout, LwpVirtualL m_Fribs.SetPara(this); return m_Fribs.ComparePagePosition(pPreLayout, pNextLayout); } -/* -sal_Bool LwpPara::IsNeedTabForTOC() -{ - LwpStory* pStory = GetStory(); - if(pStory) - { - if(GetNext()->IsNull()) - { - LwpVirtualLayout* pLayout = pStory->GetLayout(NULL); - if(pLayout && pLayout->IsCell()) - { - LwpCellLayout * pCell = static_cast<LwpCellLayout *>(pStory->GetLayout(NULL)); - if (pCell->GetLeaderChar() == 0) - { - return sal_False; - } - return sal_True; - } - } - } - return sal_False; -} - -void LwpPara::AddTabStyleForTOC( ) -{ - if(IsNeedTabForTOC()) - { - XFParaStyle* pParaStyle = new XFParaStyle; - *pParaStyle = *GetXFParaStyle(); - pParaStyle->ClearTabStyles(); - //Add Tab Style; - enumXFTab eType = enumXFTabRight; - - LwpCellLayout * pCell = static_cast<LwpCellLayout *>(GetStory()->GetLayout(NULL)); - double dLen = pCell->GetActualWidth(); /// todo: get from table - sal_Unicode cLeader = static_cast<sal_Unicode>(pCell->GetLeaderChar()); - pParaStyle->AddTabStyle(eType, dLen, cLeader ); - m_StyleName = XFStyleManager::AddStyle(pParaStyle)->GetStyleName(); - - // Get font info of default text style and set into tab style - XFParaStyle* pBaseStyle = static_cast<XFParaStyle*>(m_pFoundry->GetStyleManager()->GetStyle(*m_pFoundry->GetDefaultTextStyle())); - XFTextStyle*pTextStyle = new XFTextStyle; - pTextStyle->SetFont(pBaseStyle->GetFont()); // who delete this font????? - m_TabStyleName = XFStyleManager::AddStyle(pTextStyle)->GetStyleName(); - } -} -void LwpPara::AddTabStopForTOC() -{ - if(IsNeedTabForTOC()) - { - XFParagraph* pXFPara = GetFribs()->GetXFPara(); - pXFPara->SetStyleName(m_StyleName); - - XFParaStyle* pParaStyle = static_cast<XFParaStyle*>(XFStyleManager::FindStyle(m_StyleName)); - if(pParaStyle) - { - XFTextSpan *pSpan = new XFTextSpan; - XFTabStop *pTab = new XFTabStop; - pSpan->Add(pTab); - pSpan->SetStyleName(m_TabStyleName); - enumXFAlignType eType = pParaStyle->GetAlighType(); - - if(eType == enumXFAlignStart || eType == enumXFAlignJustify || eType == enumXFAlignNone) - { - pXFPara->Add(pSpan); - } - else if(eType == enumXFAlignEnd) - { - pXFPara->InsertAtBegin(pSpan); - } - else - { - delete pSpan; // pTabl will be delete inside XFTextSpan - } - - } - - } -} -*/ /** * @short check paragraph alignment */ sal_Bool LwpPara::IsNumberRight() { - LwpObject* pObj = m_ParaStyle.obj(); - if (pObj) + LwpParaStyle* pStyle = dynamic_cast<LwpParaStyle*>(m_ParaStyle.obj()); + if (pStyle) { - LwpParaStyle* pStyle = static_cast<LwpParaStyle*>(pObj); return pStyle->IsNumberRight(); } else @@ -740,7 +661,8 @@ sal_Bool LwpPara::IsNumberRight() */ sal_Bool LwpPara::IsInCell() { - LwpVirtualLayout* pLayout = GetStory()->GetLayout(NULL); + LwpStory *pStory = GetStory(); + LwpVirtualLayout* pLayout = pStory ? pStory->GetLayout(NULL) : NULL; if(pLayout && pLayout->IsCell()) return sal_True; return sal_False; diff --git a/lotuswordpro/source/filter/lwpparaproperty.cxx b/lotuswordpro/source/filter/lwpparaproperty.cxx index 6303244fe..509b06aaa 100644 --- a/lotuswordpro/source/filter/lwpparaproperty.cxx +++ b/lotuswordpro/source/filter/lwpparaproperty.cxx @@ -74,13 +74,19 @@ LwpParaProperty* LwpParaProperty::ReadPropertyList(LwpObjectStream* pFile,LwpObj for(;;) { - pFile->QuickRead(&tag,sizeof(sal_uInt32)); - // Keep reading properties until we hit the end tag - if (tag == TAG_ENDSUBOBJ) + sal_uInt16 nRead; + + nRead = pFile->QuickRead(&tag,sizeof(sal_uInt32)); + // Keep reading properties until we hit the end tag or + // the stream ends + if (tag == TAG_ENDSUBOBJ || nRead != sizeof(sal_uInt32)) break; // Get the length of this property - pFile->QuickRead(&Len,sizeof(sal_uInt16)); + nRead = pFile->QuickRead(&Len,sizeof(sal_uInt16)); + + if (nRead != sizeof(sal_uInt16)) + break; // Create whatever kind of tag we just found switch (tag) @@ -121,21 +127,8 @@ LwpParaProperty* LwpParaProperty::ReadPropertyList(LwpObjectStream* pFile,LwpObj case TAG_PARA_TAB: NewProp = new LwpParaTabRackProperty(pFile); break; -/* -#ifdef KINSOKU - case TAG_PARA_KINSOKU: - NewProp = new CParaKinsokuProperty(pFile); - break; -#endif - case TAG_PARA_PROPLIST: - NewProp = new CParaPropListProperty(pFile,Whole); - break; - - case TAG_PARA_SHOW: - case TAG_PARA_HIDE: - // Ignore these properties -*/ default: + default: pFile->SeekRel(Len); NewProp = NULL; break; @@ -152,24 +145,12 @@ LwpParaProperty* LwpParaProperty::ReadPropertyList(LwpObjectStream* pFile,LwpObj LwpParaAlignProperty::LwpParaAlignProperty(LwpObjectStream* pFile) { -// pFile->SeekRel(3); - LwpObjectID align; - align.ReadIndexed(pFile); - m_pAlignment =static_cast<LwpAlignmentOverride*> - (static_cast<LwpAlignmentPiece*>(align.obj(VO_ALIGNMENTPIECE))->GetOverride()); -/* if(pFile->GetFileRevision() < 0x000b) - { - CAlignmentPieceGuts guts; - CAlignmentPiece::QuickReadGuts(pFile, &guts); - cAlignment = GetPieceManager()->GetAlignmentPiece(&guts); - } - else - { - LwpFoundry* OldFoundry = pFile->GetFoundry(); - pFile->SetFoundry(GetPieceManager()->GetFoundry()); - cAlignment.QuickRead(pFile); - pFile->SetFoundry(OldFoundry); - } */ + LwpObjectID align; + align.ReadIndexed(pFile); + + LwpAlignmentPiece *pAlignmentPiece = dynamic_cast<LwpAlignmentPiece*>(align.obj(VO_ALIGNMENTPIECE)); + m_pAlignment = pAlignmentPiece ? dynamic_cast<LwpAlignmentOverride*>(pAlignmentPiece->GetOverride()) : NULL; + } LwpParaAlignProperty::~LwpParaAlignProperty(void) @@ -183,10 +164,10 @@ sal_uInt32 LwpParaAlignProperty::GetType(void) LwpParaIndentProperty::LwpParaIndentProperty(LwpObjectStream* pFile) { -// LwpObjectID indent; m_aIndentID.ReadIndexed(pFile); - m_pIndent = static_cast<LwpIndentOverride*> - (static_cast<LwpIndentPiece*>(m_aIndentID.obj(VO_INDENTPIECE))->GetOverride()); + + LwpIndentPiece *pIndentPiece = dynamic_cast<LwpIndentPiece*>(m_aIndentID.obj(VO_INDENTPIECE)); + m_pIndent = pIndentPiece ? dynamic_cast<LwpIndentOverride*>(pIndentPiece->GetOverride()) : NULL; } LwpParaIndentProperty::~LwpParaIndentProperty(void) @@ -202,8 +183,9 @@ LwpParaSpacingProperty::LwpParaSpacingProperty(LwpObjectStream* pFile) { LwpObjectID spacing; spacing.ReadIndexed(pFile); - m_pSpacing = static_cast<LwpSpacingOverride*> - (static_cast<LwpSpacingPiece*>(spacing.obj(VO_SPACINGPIECE))->GetOverride()); + + LwpSpacingPiece *pSpacingPiece = dynamic_cast<LwpSpacingPiece*>(spacing.obj(VO_SPACINGPIECE)); + m_pSpacing = pSpacingPiece ? dynamic_cast<LwpSpacingOverride*>(pSpacingPiece->GetOverride()) : NULL; } LwpParaSpacingProperty::~LwpParaSpacingProperty(void) @@ -224,8 +206,8 @@ m_pParaBorderOverride(NULL) if (!aParaBorder.IsNull()) { - m_pParaBorderOverride = static_cast<LwpParaBorderOverride*> - (static_cast<LwpParaBorderPiece*>(aParaBorder.obj())->GetOverride()); + LwpParaBorderPiece *pParaBorderPiece = dynamic_cast<LwpParaBorderPiece*>(aParaBorder.obj()); + m_pParaBorderOverride = pParaBorderPiece ? dynamic_cast<LwpParaBorderOverride*>(pParaBorderPiece->GetOverride()) : NULL; } } @@ -237,8 +219,8 @@ m_pBreaks(NULL) if (!aBreaks.IsNull()) { - m_pBreaks = static_cast<LwpBreaksOverride*> - (static_cast<LwpBreaksPiece*>(aBreaks.obj())->GetOverride()); + LwpBreaksPiece *pBreaksPiece = dynamic_cast<LwpBreaksPiece*>(aBreaks.obj()); + m_pBreaks = pBreaksPiece ? dynamic_cast<LwpBreaksOverride*>(pBreaksPiece->GetOverride()) : NULL; } } @@ -265,9 +247,8 @@ LwpParaNumberingProperty::LwpParaNumberingProperty(LwpObjectStream * pStrm) return; } - m_pNumberingOverride = static_cast<LwpNumberingOverride*> - (static_cast<LwpNumberingPiece*>(aNumberingPiece.obj(VO_NUMBERINGPIECE))->GetOverride()); - + LwpNumberingPiece *pNumberingPiece = dynamic_cast<LwpNumberingPiece*>(aNumberingPiece.obj(VO_NUMBERINGPIECE)); + m_pNumberingOverride = pNumberingPiece ? dynamic_cast<LwpNumberingOverride*>(pNumberingPiece->GetOverride()) : NULL; } //end////////////////////////////////////////////////////////////////////// @@ -275,7 +256,9 @@ LwpParaTabRackProperty::LwpParaTabRackProperty(LwpObjectStream* pFile) { LwpObjectID aTabRack; aTabRack.ReadIndexed(pFile); - m_pTabOverride =static_cast<LwpTabOverride*>(static_cast<LwpTabPiece*>(aTabRack.obj())->GetOverride()); + + LwpTabPiece *pTabPiece = dynamic_cast<LwpTabPiece*>(aTabRack.obj()); + m_pTabOverride = pTabPiece ? dynamic_cast<LwpTabOverride*>(pTabPiece->GetOverride()) : NULL; } LwpParaTabRackProperty::~LwpParaTabRackProperty() @@ -286,8 +269,9 @@ LwpParaBackGroundProperty::LwpParaBackGroundProperty(LwpObjectStream* pFile) { LwpObjectID background; background.ReadIndexed(pFile); - m_pBackground = static_cast<LwpBackgroundOverride*>( - static_cast<LwpBackgroundPiece*>(background.obj())->GetOverride()); + + LwpBackgroundPiece *pBackgroundPiece = dynamic_cast<LwpBackgroundPiece*>(background.obj()); + m_pBackground = pBackgroundPiece ? dynamic_cast<LwpBackgroundOverride*>(pBackgroundPiece->GetOverride()) : NULL; } LwpParaBackGroundProperty::~LwpParaBackGroundProperty() diff --git a/lotuswordpro/source/filter/lwpparastyle.cxx b/lotuswordpro/source/filter/lwpparastyle.cxx index ddc23ac10..392f6dab7 100644 --- a/lotuswordpro/source/filter/lwpparastyle.cxx +++ b/lotuswordpro/source/filter/lwpparastyle.cxx @@ -157,24 +157,27 @@ void LwpParaStyle::Read() } } -void LwpParaStyle::Apply(XFParaStyle *pParaStyle) +void LwpParaStyle::Apply(XFParaStyle *pParaStyle) { assert(pParaStyle); + if (!pParaStyle) + return; + LwpVirtualPiece *pPiece = NULL; //alignment: - pPiece = (LwpVirtualPiece*)m_AlignmentStyle.obj(); + pPiece = dynamic_cast<LwpVirtualPiece*>(m_AlignmentStyle.obj()); if( pPiece ) { - LwpAlignmentOverride *pAlign = (LwpAlignmentOverride*)pPiece->GetOverride(); + LwpAlignmentOverride *pAlign = dynamic_cast<LwpAlignmentOverride*>(pPiece->GetOverride()); if( pAlign ) ApplyAlignment(pParaStyle,pAlign); } //don't known top and bottom indent now. - pPiece = (LwpVirtualPiece*)m_IndentStyle.obj(); + pPiece = dynamic_cast<LwpVirtualPiece*>(m_IndentStyle.obj()); if( pPiece ) { - LwpIndentOverride *pIndent = (LwpIndentOverride*)pPiece->GetOverride(); + LwpIndentOverride *pIndent = dynamic_cast<LwpIndentOverride*>(pPiece->GetOverride()); if( pIndent ) { if (!m_pBulletOverride->IsInValid())//Add by ,for remove bullet indent in named bullet style @@ -189,29 +192,29 @@ void LwpParaStyle::Apply(XFParaStyle *pParaStyle) } } //shadow & borders. - pPiece = (LwpVirtualPiece*)m_BorderStyle.obj(); + pPiece = dynamic_cast<LwpVirtualPiece*>(m_BorderStyle.obj()); if( pPiece ) { - LwpParaBorderOverride *pBorder = (LwpParaBorderOverride*)pPiece->GetOverride(); + LwpParaBorderOverride *pBorder = dynamic_cast<LwpParaBorderOverride*>(pPiece->GetOverride()); if( pBorder ) { this->ApplyParaBorder(pParaStyle, pBorder); } } - pPiece = (LwpVirtualPiece*)m_SpacingStyle.obj(); + pPiece = dynamic_cast<LwpVirtualPiece*>(m_SpacingStyle.obj()); if (pPiece) { - LwpSpacingOverride *pSpacing = (LwpSpacingOverride*)pPiece->GetOverride(); + LwpSpacingOverride *pSpacing = dynamic_cast<LwpSpacingOverride*>(pPiece->GetOverride()); if( pSpacing) ApplySpacing(NULL,pParaStyle,pSpacing); } //paragraph background. - pPiece = (LwpVirtualPiece*)m_BackgroundStyle.obj(); + pPiece = dynamic_cast<LwpVirtualPiece*>(m_BackgroundStyle.obj()); if( pPiece ) { - LwpBackgroundOverride *pBack = (LwpBackgroundOverride*)pPiece->GetOverride(); + LwpBackgroundOverride *pBack = dynamic_cast<LwpBackgroundOverride*>(pPiece->GetOverride()); if( pBack ) { LwpColor color = pBack->GetBackColor(); @@ -222,19 +225,19 @@ void LwpParaStyle::Apply(XFParaStyle *pParaStyle) //add tab style - pPiece = (LwpVirtualPiece*)m_TabStyle.obj(); + pPiece = dynamic_cast<LwpVirtualPiece*>(m_TabStyle.obj()); if( pPiece ) { - LwpTabOverride *pTab=(LwpTabOverride*)pPiece->GetOverride(); + LwpTabOverride *pTab = dynamic_cast<LwpTabOverride*>(pPiece->GetOverride()); if(pTab) { ApplyTab(pParaStyle,pTab); } } - pPiece = (LwpVirtualPiece*)m_BreaksStyle.obj(); + pPiece = dynamic_cast<LwpVirtualPiece*>(m_BreaksStyle.obj()); if( pPiece ) { - LwpBreaksOverride *pBreak=(LwpBreaksOverride*)pPiece->GetOverride(); + LwpBreaksOverride *pBreak = dynamic_cast<LwpBreaksOverride*>(pPiece->GetOverride()); if(pBreak) { ApplyBreaks(pParaStyle,pBreak); @@ -587,7 +590,7 @@ void LwpParaStyle::ApplySpacing(LwpPara* pPara, XFParaStyle* pParaStyle, LwpSpac { if (below_val != -1) pPara->SetBelowSpacing(below_val); - LwpPara* pPrePara = static_cast<LwpPara*>(pPara->GetPrevious()->obj()); + LwpPara* pPrePara = dynamic_cast<LwpPara*>(pPara->GetPrevious()->obj()); if (pPrePara && above_val != -1) { above_val += pPrePara->GetBelowSpacing(); @@ -613,7 +616,7 @@ void LwpParaStyle::ApplyTab(XFParaStyle *pParaStyle, LwpTabOverride *pTabOverRid return; } - LwpTabRack* pTabRack = static_cast<LwpTabRack*>(pTabRackID->obj()); + LwpTabRack* pTabRack = dynamic_cast<LwpTabRack*>(pTabRackID->obj()); if(!pTabRack) { //assert(false); @@ -701,58 +704,61 @@ void LwpParaStyle::RegisterStyle() //Add style LwpStyleManager* pStyleMgr = m_pFoundry->GetStyleManager(); pStyleMgr->AddStyle(*GetObjectID(), pStyle); - -/* // add list style for bullet - if (!m_pBulletOverride) - { - return; - } - LwpSilverBullet* pSilverBullet = static_cast<LwpSilverBullet*>(m_pBulletOverride->GetSilverBullet().obj()); - if (!pSilverBullet) - { - return; - } - - pSilverBullet->SetFoundry(m_pFoundry); - pSilverBullet->RegisterStyle();*/ } LwpAlignmentOverride* LwpParaStyle::GetAlignment() { - if (m_AlignmentStyle.obj()!= NULL) - return static_cast<LwpAlignmentOverride*>(static_cast<LwpAlignmentPiece*>(m_AlignmentStyle.obj())->GetOverride()); - else + if (m_AlignmentStyle.obj() == NULL) return NULL; + + LwpAlignmentPiece *pPiece = dynamic_cast<LwpAlignmentPiece*>(m_AlignmentStyle.obj()); + if (pPiece) + return dynamic_cast<LwpAlignmentOverride*>(pPiece->GetOverride()); + return NULL; } LwpIndentOverride* LwpParaStyle::GetIndent() { - if (m_IndentStyle.obj() != NULL) - return static_cast<LwpIndentOverride*>(static_cast<LwpIndentPiece*>(m_IndentStyle.obj())->GetOverride()); - else + if (m_IndentStyle.obj() == NULL) return NULL; + + LwpIndentPiece *pPiece = dynamic_cast<LwpIndentPiece*>(m_IndentStyle.obj()); + if (pPiece) + return dynamic_cast<LwpIndentOverride*>(pPiece->GetOverride()); + return NULL; } LwpSpacingOverride* LwpParaStyle::GetSpacing() { - if (m_SpacingStyle.obj() != NULL) - return static_cast<LwpSpacingOverride*>(static_cast<LwpSpacingPiece*>(m_SpacingStyle.obj())->GetOverride()); - else + if (m_SpacingStyle.obj() == NULL) return NULL; + + LwpSpacingPiece *pPiece = dynamic_cast<LwpSpacingPiece*>(m_SpacingStyle.obj()); + if (pPiece) + return dynamic_cast<LwpSpacingOverride*>(pPiece->GetOverride()); + return NULL; } LwpParaBorderOverride* LwpParaStyle::GetParaBorder() const { - if(m_BorderStyle.IsNull()) return NULL; - return static_cast<LwpParaBorderOverride*> - (static_cast<LwpParaBorderPiece*>(m_BorderStyle.obj(VO_PARABORDERPIECE))->GetOverride()); + if(m_BorderStyle.IsNull()) + return NULL; + + LwpParaBorderPiece *pPiece = dynamic_cast<LwpParaBorderPiece*>(m_BorderStyle.obj(VO_PARABORDERPIECE)); + if (pPiece) + return dynamic_cast<LwpParaBorderOverride*>(pPiece->GetOverride()); + return NULL; } LwpBreaksOverride* LwpParaStyle::GetBreaks() const { - if(m_BreaksStyle.IsNull()) return NULL; - return static_cast<LwpBreaksOverride*> - (static_cast<LwpBreaksPiece*>(m_BreaksStyle.obj(VO_BREAKSPIECE))->GetOverride()); + if(m_BreaksStyle.IsNull()) + return NULL; + + LwpBreaksPiece *pPiece = dynamic_cast<LwpBreaksPiece*>(m_BreaksStyle.obj(VO_BREAKSPIECE)); + if (pPiece) + return dynamic_cast<LwpBreaksOverride*>(pPiece->GetOverride()); + return NULL; } LwpBulletOverride* LwpParaStyle::GetBulletOverride() const @@ -762,9 +768,13 @@ LwpBulletOverride* LwpParaStyle::GetBulletOverride() const LwpNumberingOverride* LwpParaStyle::GetNumberingOverride() const { - if(m_NumberingStyle.IsNull()) return NULL; - return static_cast<LwpNumberingOverride*> - (static_cast<LwpNumberingPiece*>(m_NumberingStyle.obj(VO_NUMBERINGPIECE))->GetOverride()); + if(m_NumberingStyle.IsNull()) + return NULL; + + LwpNumberingPiece *pPiece = dynamic_cast<LwpNumberingPiece*>(m_NumberingStyle.obj(VO_NUMBERINGPIECE)); + if (pPiece) + return dynamic_cast<LwpNumberingOverride*>(pPiece->GetOverride()); + return NULL; } @@ -777,10 +787,12 @@ LwpNumberingOverride* LwpParaStyle::GetNumberingOverride() const **************************************************************************/ LwpTabOverride* LwpParaStyle::GetTabOverride() const { - if(m_TabStyle.obj() != NULL) - return (LwpTabOverride*)static_cast<LwpTabPiece*>(m_TabStyle.obj())->GetOverride(); - else + if(m_TabStyle.obj() == NULL) return NULL; + LwpTabPiece *pPiece = dynamic_cast<LwpTabPiece*>(m_TabStyle.obj()); + if (pPiece) + return dynamic_cast<LwpTabOverride*>(pPiece->GetOverride()); + return NULL; } sal_Bool LwpParaStyle::IsNumberRight() diff --git a/lotuswordpro/source/filter/lwprowlayout.cxx b/lotuswordpro/source/filter/lwprowlayout.cxx index f97e3d921..7aab8f795 100644 --- a/lotuswordpro/source/filter/lwprowlayout.cxx +++ b/lotuswordpro/source/filter/lwprowlayout.cxx @@ -91,14 +91,14 @@ LwpRowLayout::~LwpRowLayout() void LwpRowLayout::SetRowMap(void) { LwpObjectID *pCellID= GetChildHead(); - LwpCellLayout * pCellLayout = static_cast<LwpCellLayout *>(pCellID->obj()); + LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj()); while(pCellLayout) { pCellLayout->SetCellMap(); pCellID = pCellLayout->GetNext(); - pCellLayout = static_cast<LwpCellLayout *>(pCellID->obj()); + pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj()); } } /** @@ -131,14 +131,14 @@ void LwpRowLayout::RegisterStyle() } // register cells' style LwpObjectID *pCellID= GetChildHead(); - LwpCellLayout * pCellLayout = static_cast<LwpCellLayout *>(pCellID->obj()); + LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj()); while(pCellLayout) { pCellLayout->SetFoundry(m_pFoundry); pCellLayout->RegisterStyle(); pCellID = pCellLayout->GetNext(); - pCellLayout = static_cast<LwpCellLayout *>(pCellID->obj()); + pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj()); } } @@ -375,7 +375,7 @@ void LwpRowLayout::ConvertCommonRow(XFTable* pXFTable,sal_uInt8 nStartCol,sal_uI { // add row to table LwpObjectID *pCellID= GetChildHead(); - LwpCellLayout * pCellLayout = static_cast<LwpCellLayout *>(pCellID->obj()); + LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj()); nCellStartCol = i;//mark the begin position of cell nCellEndCol = i;//mark the end position of cell while(pCellLayout) @@ -392,7 +392,7 @@ void LwpRowLayout::ConvertCommonRow(XFTable* pXFTable,sal_uInt8 nStartCol,sal_uI break; } pCellID = pCellLayout->GetNext(); - pCellLayout = static_cast<LwpCellLayout *>(pCellID->obj()); + pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj()); } if (!pCellLayout) { @@ -423,7 +423,7 @@ void LwpRowLayout::ConvertCommonRow(XFTable* pXFTable,sal_uInt8 nStartCol,sal_uI void LwpRowLayout::CollectMergeInfo() { LwpObjectID *pCellID= GetChildHead(); - LwpCellLayout * pCellLayout = static_cast<LwpCellLayout *>(pCellID->obj()); + LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj()); while(pCellLayout) { @@ -433,7 +433,7 @@ void LwpRowLayout::CollectMergeInfo() m_ConnCellList.push_back(pConnCell); } pCellID = pCellLayout->GetNext(); - pCellLayout = static_cast<LwpCellLayout *>(pCellID->obj()); + pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj()); } } /** @@ -481,7 +481,7 @@ void LwpRowHeadingLayout::Read() LwpRowLayout * LwpRowHeadingLayout::GetRowLayout() { - LwpRowLayout * pRow = static_cast<LwpRowLayout *>(cRowLayout.obj()); + LwpRowLayout * pRow = dynamic_cast<LwpRowLayout *>(cRowLayout.obj()); return pRow; } diff --git a/lotuswordpro/source/filter/lwprowlayout.hxx b/lotuswordpro/source/filter/lwprowlayout.hxx index 8cc58c280..88c4ee67b 100644 --- a/lotuswordpro/source/filter/lwprowlayout.hxx +++ b/lotuswordpro/source/filter/lwprowlayout.hxx @@ -85,7 +85,7 @@ public: virtual LWP_LAYOUT_TYPE GetLayoutType () { return LWP_ROW_LAYOUT;} sal_uInt16 GetRowID() { return crowid;} virtual void RegisterStyle(); - inline LwpTableLayout * GetParentTableLayout(){return static_cast<LwpTableLayout *>(GetParent()->obj());} + inline LwpTableLayout * GetParentTableLayout(){return dynamic_cast<LwpTableLayout *>(GetParent()->obj());} void SetRowMap(void); protected: void Read(); diff --git a/lotuswordpro/source/filter/lwpsection.hxx b/lotuswordpro/source/filter/lwpsection.hxx index d401d826f..0d0109891 100644 --- a/lotuswordpro/source/filter/lwpsection.hxx +++ b/lotuswordpro/source/filter/lwpsection.hxx @@ -127,7 +127,7 @@ inline sal_uInt16 LwpSection::GetFlags() */ inline LwpPageLayout* LwpSection::GetPageLayout() { - return static_cast<LwpPageLayout*>(m_PageLayout.obj()); + return dynamic_cast<LwpPageLayout*>(m_PageLayout.obj()); } /** diff --git a/lotuswordpro/source/filter/lwpsilverbullet.cxx b/lotuswordpro/source/filter/lwpsilverbullet.cxx index ae2904c3e..9f022c855 100644 --- a/lotuswordpro/source/filter/lwpsilverbullet.cxx +++ b/lotuswordpro/source/filter/lwpsilverbullet.cxx @@ -245,13 +245,13 @@ LwpPara* LwpSilverBullet::GetBulletPara() { if (!m_pBulletPara) { - LwpStory* pStory = static_cast<LwpStory*>(m_aStory.obj(VO_STORY)); + LwpStory* pStory = dynamic_cast<LwpStory*>(m_aStory.obj(VO_STORY)); if (!pStory) { return NULL; } - m_pBulletPara = static_cast<LwpPara*>(pStory->GetFirstPara()->obj(VO_PARA)); + m_pBulletPara = dynamic_cast<LwpPara*>(pStory->GetFirstPara()->obj(VO_PARA)); } return m_pBulletPara; @@ -333,7 +333,15 @@ rtl::OUString LwpSilverBullet::GetNumCharByStyleID(LwpFribParaNumber* pParaNumbe */ sal_Bool LwpSilverBullet::IsBulletOrdered() { - return (sal_Bool)(m_pBulletPara->GetFribs()->HasFrib(FRIB_TAG_PARANUMBER) != NULL); + if (!m_pBulletPara) + return sal_False; + + LwpFribPtr* pFribs = m_pBulletPara->GetFribs(); + + if (!pFribs) + return sal_False; + + return (sal_Bool)(pFribs->HasFrib(FRIB_TAG_PARANUMBER) != NULL); } /** @@ -434,7 +442,9 @@ rtl::OUString LwpSilverBullet::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(); } } @@ -443,7 +453,7 @@ rtl::OUString LwpSilverBullet::GetDivisionName() rtl::OUString LwpSilverBullet::GetSectionName() { - LwpStory* pStory = static_cast<LwpStory*>(m_aStory.obj(VO_STORY)); + LwpStory* pStory = dynamic_cast<LwpStory*>(m_aStory.obj(VO_STORY)); if (!pStory) { return rtl::OUString(); diff --git a/lotuswordpro/source/filter/lwpstory.cxx b/lotuswordpro/source/filter/lwpstory.cxx index 9e9109d84..4cbd0ccaf 100644 --- a/lotuswordpro/source/filter/lwpstory.cxx +++ b/lotuswordpro/source/filter/lwpstory.cxx @@ -99,7 +99,7 @@ void LwpStory::XFConvert(XFContentContainer* pCont) XFConvertFrameInFrame(pCont); //process para list XFContentContainer* pParaCont = pCont; - LwpPara* pPara = static_cast<LwpPara*> ( GetFirstPara()->obj() ); + LwpPara* pPara = dynamic_cast<LwpPara*> ( GetFirstPara()->obj() ); while(pPara) { pPara->SetFoundry(m_pFoundry); @@ -107,7 +107,7 @@ void LwpStory::XFConvert(XFContentContainer* pCont) //Get the xfcontainer for the next para pParaCont = pPara->GetXFContainer(); - pPara = static_cast<LwpPara*> ( pPara->GetNext()->obj() ); + pPara = dynamic_cast<LwpPara*> ( pPara->GetNext()->obj() ); } //process frame which anchor is to cell after converter all the para @@ -115,12 +115,12 @@ void LwpStory::XFConvert(XFContentContainer* pCont) XFConvertFrameInHeaderFooter(pCont); //Release Lwp Objects - LwpPara* pCur = static_cast<LwpPara*> (GetFirstPara()->obj()); + LwpPara* pCur = dynamic_cast<LwpPara*> (GetFirstPara()->obj()); LwpPara* pNext; while(pCur) { pCur->Release(); - pNext = static_cast<LwpPara*> ( pCur->GetNext()->obj() ); + pNext = dynamic_cast<LwpPara*> ( pCur->GetNext()->obj() ); LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance(); LwpObjectFactory* pObjMgr = pGlobal->GetLwpObjFactory(); pObjMgr->ReleaseObject(*pCur->GetObjectID()); @@ -130,12 +130,12 @@ void LwpStory::XFConvert(XFContentContainer* pCont) void LwpStory::RegisterStyle() { - LwpPara* pPara = static_cast<LwpPara*>( GetFirstPara()->obj() ); + LwpPara* pPara = dynamic_cast<LwpPara*>( GetFirstPara()->obj() ); while(pPara) { pPara->SetFoundry(m_pFoundry); pPara->RegisterStyle(); - pPara = static_cast<LwpPara*>(pPara->GetNext()->obj()); + pPara = dynamic_cast<LwpPara*>(pPara->GetNext()->obj()); } } @@ -232,7 +232,7 @@ void LwpStory::SortPageLayout() LwpLayout::UseWhenType eSectionType = static_cast<LwpPageLayout*>(pLayout)->GetUseWhenType(); //for mirror page, the child is pagelayout LwpVirtualLayout* pParent = pLayout->GetParentLayout(); - if(eSectionType != LwpLayout::StartWithinColume && !pParent->IsPage()) + if(eSectionType != LwpLayout::StartWithinColume && pParent && !pParent->IsPage()) { aLayoutList.push_back(static_cast<LwpPageLayout*>(pLayout)); } @@ -240,22 +240,23 @@ void LwpStory::SortPageLayout() pLayout = GetLayout(pLayout); } // sort the pagelayout according to their position - LwpPageLayout* pTemp = NULL; std::vector<LwpPageLayout*>::iterator aIt; - std::vector<LwpPageLayout*>::iterator bIt; - for( aIt = aLayoutList.begin(); aIt != aLayoutList.end() -1; ++aIt) + if (!aLayoutList.empty()) { - for( bIt = aIt +1; bIt != aLayoutList.end(); ++bIt ) + for( aIt = aLayoutList.begin(); aIt != aLayoutList.end() -1; ++aIt) { - if(**aIt < **bIt) + for( std::vector<LwpPageLayout*>::iterator bIt = aIt +1; bIt != aLayoutList.end(); ++bIt ) { - continue; - } - else - { - pTemp = *aIt; - *aIt = *bIt; - *bIt = pTemp; + if(**aIt < **bIt) + { + continue; + } + else + { + LwpPageLayout* pTemp = *aIt; + *aIt = *bIt; + *bIt = pTemp; + } } } } @@ -333,7 +334,7 @@ void LwpStory::XFConvertFrame(XFContentContainer* pCont) LwpVirtualLayout* pLayout = GetLayout(NULL); while(pLayout) { - LwpVirtualLayout* pFrameLayout = static_cast<LwpVirtualLayout*>(pLayout->GetChildHead()->obj()); + LwpVirtualLayout* pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetChildHead()->obj()); while(pFrameLayout) { if((pFrameLayout->IsAnchorPage()&&(pFrameLayout->IsFrame()||pFrameLayout->IsSuperTable()||pFrameLayout->IsGroupHead())) @@ -341,7 +342,7 @@ void LwpStory::XFConvertFrame(XFContentContainer* pCont) { pFrameLayout->XFConvert(pCont); } - pFrameLayout = static_cast<LwpVirtualLayout*>(pFrameLayout->GetNext()->obj()); + pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pFrameLayout->GetNext()->obj()); } pLayout = GetLayout(pLayout); } @@ -357,7 +358,7 @@ void LwpStory::XFConvertFrameInCell(XFContentContainer* pCont) LwpVirtualLayout* pLayout = GetLayout(NULL); while(pLayout) { - LwpVirtualLayout* pFrameLayout = static_cast<LwpVirtualLayout*>(pLayout->GetChildHead()->obj()); + LwpVirtualLayout* pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetChildHead()->obj()); while(pFrameLayout) { @@ -369,7 +370,7 @@ void LwpStory::XFConvertFrameInCell(XFContentContainer* pCont) if(pXFFirtPara) pFrameLayout->XFConvert(pXFFirtPara); } - pFrameLayout = static_cast<LwpVirtualLayout*>(pFrameLayout->GetNext()->obj()); + pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pFrameLayout->GetNext()->obj()); } pLayout = GetLayout(pLayout); } @@ -386,7 +387,7 @@ void LwpStory::XFConvertFrameInPage(XFContentContainer* pCont) LwpVirtualLayout* pLayout = GetLayout(NULL); while(pLayout) { - LwpVirtualLayout* pFrameLayout = static_cast<LwpVirtualLayout*>(pLayout->GetChildHead()->obj()); + LwpVirtualLayout* pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetChildHead()->obj()); while(pFrameLayout) { if((pFrameLayout->IsAnchorPage() @@ -396,7 +397,7 @@ void LwpStory::XFConvertFrameInPage(XFContentContainer* pCont) { pFrameLayout->XFConvert(pCont); } - pFrameLayout = static_cast<LwpVirtualLayout*>(pFrameLayout->GetNext()->obj()); + pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pFrameLayout->GetNext()->obj()); } pLayout = GetLayout(pLayout); } @@ -412,14 +413,14 @@ void LwpStory::XFConvertFrameInFrame(XFContentContainer* pCont) LwpVirtualLayout* pLayout = GetLayout(NULL); while(pLayout) { - LwpVirtualLayout* pFrameLayout = static_cast<LwpVirtualLayout*>(pLayout->GetChildHead()->obj()); + LwpVirtualLayout* pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetChildHead()->obj()); while(pFrameLayout) { if(pFrameLayout->IsAnchorFrame()) { pFrameLayout->XFConvert(pCont); } - pFrameLayout = static_cast<LwpVirtualLayout*>(pFrameLayout->GetNext()->obj()); + pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pFrameLayout->GetNext()->obj()); } pLayout = GetLayout(pLayout); } @@ -435,7 +436,7 @@ void LwpStory::XFConvertFrameInHeaderFooter(XFContentContainer* pCont) LwpVirtualLayout* pLayout = GetLayout(NULL); while(pLayout) { - LwpVirtualLayout* pFrameLayout = static_cast<LwpVirtualLayout*>(pLayout->GetChildHead()->obj()); + LwpVirtualLayout* pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetChildHead()->obj()); while(pFrameLayout) { if(pFrameLayout->IsAnchorPage() && (pLayout->IsHeader() || pLayout->IsFooter())) @@ -445,7 +446,7 @@ void LwpStory::XFConvertFrameInHeaderFooter(XFContentContainer* pCont) if(pXFFirtPara) pFrameLayout->XFConvert(pXFFirtPara); } - pFrameLayout = static_cast<LwpVirtualLayout*>(pFrameLayout->GetNext()->obj()); + pFrameLayout = dynamic_cast<LwpVirtualLayout*>(pFrameLayout->GetNext()->obj()); } pLayout = GetLayout(pLayout); } @@ -487,12 +488,12 @@ OUString LwpStory::GetContentText(sal_Bool bAllText) { OUString sText = A2OUSTR(""); //process para list - LwpPara* pPara = static_cast<LwpPara*>(GetFirstPara()->obj()); + LwpPara* pPara = dynamic_cast<LwpPara*>(GetFirstPara()->obj()); while (pPara) { pPara->SetFoundry(m_pFoundry); sText += pPara->GetContentText(sal_True); - pPara = static_cast<LwpPara*>(pPara->GetNext()->obj()); + pPara = dynamic_cast<LwpPara*>(pPara->GetNext()->obj()); } return sText; } @@ -501,7 +502,7 @@ OUString LwpStory::GetContentText(sal_Bool bAllText) LwpObject* pObj = GetFirstPara()->obj(); if(pObj) { - LwpPara* pPara = static_cast<LwpPara*>(pObj); + LwpPara* pPara = dynamic_cast<LwpPara*>(pObj); if (pPara->GetNext()->obj() != NULL) return A2OUSTR(""); pPara->SetFoundry(m_pFoundry); @@ -513,7 +514,7 @@ OUString LwpStory::GetContentText(sal_Bool bAllText) } OUString LwpStory::RegisterFirstFribStyle() { - LwpPara* pPara = static_cast<LwpPara*>(GetFirstPara()->obj()); + LwpPara* pPara = dynamic_cast<LwpPara*>(GetFirstPara()->obj()); pPara->SetFoundry(m_pFoundry); LwpFribPtr* pFribs = pPara->GetFribs(); if (pFribs) diff --git a/lotuswordpro/source/filter/lwptable.cxx b/lotuswordpro/source/filter/lwptable.cxx index 61dca7e92..6d63ee0d0 100644 --- a/lotuswordpro/source/filter/lwptable.cxx +++ b/lotuswordpro/source/filter/lwptable.cxx @@ -135,9 +135,9 @@ void LwpTable::Parse(IXFStream* /*pOutputStream*/) LwpSuperTableLayout* LwpTable::GetSuperTableLayout() { - LwpTableLayout* pLayout = static_cast<LwpTableLayout*>(m_Layout.obj()); + LwpTableLayout* pLayout = dynamic_cast<LwpTableLayout*>(m_Layout.obj()); if(pLayout) - return static_cast<LwpSuperTableLayout*>(pLayout->GetParent()->obj()); + return dynamic_cast<LwpSuperTableLayout*>(pLayout->GetParent()->obj()); return NULL; } diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx index db5e5abd0..f16b74eb8 100644 --- a/lotuswordpro/source/filter/lwptablelayout.cxx +++ b/lotuswordpro/source/filter/lwptablelayout.cxx @@ -118,14 +118,14 @@ LwpTableLayout* LwpSuperTableLayout::GetTableLayout() while(pID && !pID->IsNull()) { - LwpVirtualLayout * pLayout = static_cast<LwpVirtualLayout *>(pID->obj()); + LwpLayout* pLayout = dynamic_cast<LwpLayout*>(pID->obj()); if (!pLayout) { break; } if (pLayout->GetLayoutType() == LWP_TABLE_LAYOUT) { - return static_cast<LwpTableLayout *>(pLayout); + return dynamic_cast<LwpTableLayout *>(pLayout); } pID = pLayout->GetPrevious(); } @@ -142,7 +142,7 @@ LwpTableHeadingLayout* LwpSuperTableLayout::GetTableHeadingLayout() while(pID && !pID->IsNull()) { - LwpVirtualLayout * pLayout = static_cast<LwpVirtualLayout *>(pID->obj()); + LwpLayout * pLayout = dynamic_cast<LwpLayout *>(pID->obj()); if (!pLayout) { break; @@ -150,7 +150,7 @@ LwpTableHeadingLayout* LwpSuperTableLayout::GetTableHeadingLayout() if (pLayout->GetLayoutType() == LWP_TABLE_HEADING_LAYOUT) { - return static_cast<LwpTableHeadingLayout *>(pLayout); + return dynamic_cast<LwpTableHeadingLayout *>(pLayout); } pID = pLayout->GetPrevious(); } @@ -235,7 +235,7 @@ double LwpSuperTableLayout::GetTableWidth() for(sal_uInt16 i =0; i< nCol; i++) { LwpObjectID *pColumnID = pTableLayout->GetColumnLayoutHead(); - LwpColumnLayout * pColumnLayout = static_cast<LwpColumnLayout *>(pColumnID->obj()); + LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj()); double dColumnWidth = dDefaultWidth; while (pColumnLayout) { @@ -245,7 +245,7 @@ double LwpSuperTableLayout::GetTableWidth() break; } pColumnID = pColumnLayout->GetNext(); - pColumnLayout = static_cast<LwpColumnLayout *>(pColumnID->obj()); + pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj()); } dWidth += dColumnWidth; } @@ -476,7 +476,7 @@ void LwpTableLayout::TraverseTable() // set value LwpObjectID *pRowID = GetChildHead(); - LwpRowLayout * pRowLayout = static_cast<LwpRowLayout *>(pRowID->obj()); + LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj()); while (pRowLayout) { pRowLayout->SetRowMap(); @@ -487,7 +487,7 @@ void LwpTableLayout::TraverseTable() // end for 's analysis pRowID = pRowLayout->GetNext(); - pRowLayout = static_cast<LwpRowLayout *>(pRowID->obj()); + pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj()); } } @@ -525,7 +525,7 @@ LwpObjectID * LwpTableLayout::SearchCellStoryMap(sal_uInt16 nRow, sal_uInt16 nCo */ LwpSuperTableLayout * LwpTableLayout::GetSuperTableLayout() { - return static_cast<LwpSuperTableLayout *>(GetParent()->obj()); + return dynamic_cast<LwpSuperTableLayout *>(GetParent()->obj()); } /** * @short Get table pointer @@ -533,7 +533,7 @@ LwpSuperTableLayout * LwpTableLayout::GetSuperTableLayout() */ LwpTable * LwpTableLayout::GetTable() { - LwpTable *pTable = static_cast<LwpTable *>(m_Content.obj()); + LwpTable *pTable = dynamic_cast<LwpTable *>(m_Content.obj()); return pTable; } /** @@ -585,7 +585,7 @@ void LwpTableLayout::RegisterColumns() // Get total width of justifiable columns // NOTICE: all default columns are regarded as justifiable columns LwpObjectID *pColumnID = GetColumnLayoutHead(); - LwpColumnLayout * pColumnLayout = static_cast<LwpColumnLayout *>(pColumnID->obj()); + LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj()); while (pColumnLayout) { m_pColumns[pColumnLayout->GetColumnID()] = pColumnLayout; @@ -597,7 +597,7 @@ void LwpTableLayout::RegisterColumns() } pColumnID = pColumnLayout->GetNext(); - pColumnLayout = static_cast<LwpColumnLayout *>(pColumnID->obj()); + pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj()); } // if all columns are not justifiable, the rightmost column will be changed to justifiable @@ -676,14 +676,14 @@ void LwpTableLayout::RegisterRows() // register style of rows LwpObjectID * pRowID = GetChildHead(); - LwpRowLayout * pRowLayout = static_cast<LwpRowLayout *>(pRowID->obj()); + LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj()); while (pRowLayout) { pRowLayout->SetFoundry(m_pFoundry); pRowLayout->RegisterStyle(); pRowID = pRowLayout->GetNext(); - pRowLayout = static_cast<LwpRowLayout *>(pRowID->obj()); + pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj()); } } /** @@ -716,7 +716,7 @@ void LwpTableLayout::RegisterStyle() LwpObjectID * pID= pTable->GetDefaultCellStyle(); if (pID) { - m_pDefaultCellLayout = static_cast<LwpCellLayout *>(pID->obj()); + m_pDefaultCellLayout = dynamic_cast<LwpCellLayout *>(pID->obj()); } // register columns styles @@ -1261,7 +1261,7 @@ void LwpTableLayout::ConvertColumn(XFTable *pXFTable,sal_uInt8 nStartCol,sal_uIn { // add row to table LwpObjectID *pColID = GetColumnLayoutHead(); - LwpColumnLayout * pColumnLayout = static_cast<LwpColumnLayout *>(pColID->obj()); + LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColID->obj()); while (pColumnLayout) { if (pColumnLayout->GetColumnID() == (iLoop+nStartCol)) @@ -1270,7 +1270,7 @@ void LwpTableLayout::ConvertColumn(XFTable *pXFTable,sal_uInt8 nStartCol,sal_uIn break; } pColID = pColumnLayout->GetNext(); - pColumnLayout = static_cast<LwpColumnLayout *>(pColID->obj()); + pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColID->obj()); } if (!pColumnLayout) { @@ -1403,14 +1403,14 @@ XFCell* LwpTableLayout::GetCellsMap(sal_uInt16 nRow,sal_uInt8 nCol) LwpRowLayout* LwpTableLayout::GetRowLayout(sal_uInt16 nRow) { LwpObjectID *pRowID = GetChildHead(); - LwpRowLayout * pRowLayout = static_cast<LwpRowLayout *>(pRowID->obj()); + LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj()); while (pRowLayout) { if(pRowLayout->GetRowID() == nRow) return pRowLayout; pRowID = pRowLayout->GetNext(); - pRowLayout = static_cast<LwpRowLayout *>(pRowID->obj()); + pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj()); } return NULL; } @@ -1488,7 +1488,7 @@ LwpRowHeadingLayout * LwpTableHeadingLayout::GetFirstRowHeadingLayout() LwpObjectID *pID = GetChildHead(); if(pID && !pID->IsNull()) { - LwpRowHeadingLayout * pHeadingRow = static_cast<LwpRowHeadingLayout *>(pID->obj()); + LwpRowHeadingLayout * pHeadingRow = dynamic_cast<LwpRowHeadingLayout *>(pID->obj()); return pHeadingRow; } return NULL; diff --git a/lotuswordpro/source/filter/lwptabrack.cxx b/lotuswordpro/source/filter/lwptabrack.cxx index ac4a01d94..b29952a6b 100644 --- a/lotuswordpro/source/filter/lwptabrack.cxx +++ b/lotuswordpro/source/filter/lwptabrack.cxx @@ -116,7 +116,7 @@ LwpTab* LwpTabRack::Lookup(sal_uInt16 nIndex) LwpTabRack* LwpTabRack::GetNext() { - LwpTabRack* pTabRack = static_cast<LwpTabRack*>(m_NextID.obj()); + LwpTabRack* pTabRack = dynamic_cast<LwpTabRack*>(m_NextID.obj()); return pTabRack; } diff --git a/lotuswordpro/source/filter/lwptoc.cxx b/lotuswordpro/source/filter/lwptoc.cxx index 143d390a3..6d9c13c0f 100644 --- a/lotuswordpro/source/filter/lwptoc.cxx +++ b/lotuswordpro/source/filter/lwptoc.cxx @@ -377,7 +377,7 @@ sal_uInt16 LwpTocSuperLayout::GetSeparatorType(sal_uInt16 index) LwpTocLevelData * LwpTocSuperLayout::GetSearchLevelPtr(sal_uInt16 index) { LwpObjectID * pID = m_SearchItems.GetHead(); // not necessary to check pID NULL or not - LwpTocLevelData * pObj = static_cast<LwpTocLevelData *>(pID->obj()); + LwpTocLevelData * pObj = dynamic_cast<LwpTocLevelData *>(pID->obj()); while(pObj) { @@ -387,7 +387,7 @@ LwpTocLevelData * LwpTocSuperLayout::GetSearchLevelPtr(sal_uInt16 index) } pID = pObj->GetNext(); // not necessary to check pID NULL or not - pObj = static_cast<LwpTocLevelData *>(pID->obj()); + pObj = dynamic_cast<LwpTocLevelData *>(pID->obj()); } return NULL; @@ -401,7 +401,7 @@ LwpTocLevelData * LwpTocSuperLayout::GetSearchLevelPtr(sal_uInt16 index) LwpTocLevelData * LwpTocSuperLayout::GetNextSearchLevelPtr(sal_uInt16 index, LwpTocLevelData * pCurData) { LwpObjectID * pID = pCurData->GetNext(); - LwpTocLevelData * pObj = static_cast<LwpTocLevelData *>(pID->obj()); + LwpTocLevelData * pObj = dynamic_cast<LwpTocLevelData *>(pID->obj()); while(pObj) { @@ -411,7 +411,7 @@ LwpTocLevelData * LwpTocSuperLayout::GetNextSearchLevelPtr(sal_uInt16 index, Lwp } pID = pObj->GetNext(); // not necessary to check pID NULL or not - pObj = static_cast<LwpTocLevelData *>(pID->obj()); + pObj = dynamic_cast<LwpTocLevelData *>(pID->obj()); } return NULL; diff --git a/lotuswordpro/source/filter/lwptools.hxx b/lotuswordpro/source/filter/lwptools.hxx index 996ec176f..750010d2a 100644 --- a/lotuswordpro/source/filter/lwptools.hxx +++ b/lotuswordpro/source/filter/lwptools.hxx @@ -71,6 +71,7 @@ #include "xfilter/xfdatestyle.hxx" #include "xfilter/xftimestyle.hxx" #include <rtl/textenc.h> +#include <stdexcept> // 01/19/2005 const sal_uInt32 UNITS_PER_INCH = 65536L * 72L; @@ -141,6 +142,18 @@ inline sal_Bool LwpTools::IsEvenNumber(sal_uInt16& nNumber) return nNumber%2? sal_False : sal_True; } +class BadSeek : public std::runtime_error +{ +public: + BadSeek() : std::runtime_error("Lotus Word Pro Bad Seek") { } +}; + +class BadDecompress : public std::runtime_error +{ +public: + BadDecompress() : std::runtime_error("Lotus Word Pro Bad Decompress") { } +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lotuswordpro/source/filter/utlist.cxx b/lotuswordpro/source/filter/utlist.cxx index 0acd2db39..d68b49cbe 100644 --- a/lotuswordpro/source/filter/utlist.cxx +++ b/lotuswordpro/source/filter/utlist.cxx @@ -59,10 +59,11 @@ namespace OpenStormBento { CUtListElmt::CUtListElmt(pCUtList pList) + : cpNext(NULL) + , cpPrev(NULL) { - if (pList == NULL) - cpNext = NULL; - else InsertAfter(pList->GetLast()); + if (pList != NULL) + InsertAfter(pList->GetLast()); } CUtListElmt::~CUtListElmt() diff --git a/lotuswordpro/source/filter/utlist.hxx b/lotuswordpro/source/filter/utlist.hxx index ef76588a3..8f3f90d7b 100644 --- a/lotuswordpro/source/filter/utlist.hxx +++ b/lotuswordpro/source/filter/utlist.hxx @@ -69,7 +69,10 @@ UtDefClassP(CUtComparableListElmt); class CUtListElmt { public: // Methods - CUtListElmt() { cpNext = NULL; } + CUtListElmt() + : cpNext(NULL) + , cpPrev(NULL) + {} CUtListElmt(pCUtListElmt pPrev) { InsertAfter(pPrev); } CUtListElmt(pCUtList pList); virtual ~CUtListElmt(); diff --git a/lotuswordpro/source/filter/xfilter/xfimage.cxx b/lotuswordpro/source/filter/xfilter/xfimage.cxx index aef5459a9..10c21fcfc 100644 --- a/lotuswordpro/source/filter/xfilter/xfimage.cxx +++ b/lotuswordpro/source/filter/xfilter/xfimage.cxx @@ -60,7 +60,7 @@ #include "xfimage.hxx" #include "xfbase64.hxx" -XFImage::XFImage() +XFImage::XFImage() : m_bUseLink(sal_False) { m_eType = enumXFFrameImage; m_strName = XFGlobal::GenImageName(); diff --git a/lotuswordpro/source/filter/xfilter/xfsaxstream.cxx b/lotuswordpro/source/filter/xfilter/xfsaxstream.cxx index ca3150451..1d4986230 100644 --- a/lotuswordpro/source/filter/xfilter/xfsaxstream.cxx +++ b/lotuswordpro/source/filter/xfilter/xfsaxstream.cxx @@ -94,23 +94,27 @@ XFSaxStream::~XFSaxStream() void XFSaxStream::StartDocument() { - m_aHandler->startDocument(); + if (m_aHandler.is()) + m_aHandler->startDocument(); } void XFSaxStream::EndDocument() { - m_aHandler->endDocument(); + if (m_aHandler.is()) + m_aHandler->endDocument(); } void XFSaxStream::StartElement(const rtl::OUString& oustr) { - m_aHandler->startElement( oustr, m_pAttrList->GetAttributeList() ); + if (m_aHandler.is()) + m_aHandler->startElement( oustr, m_pAttrList->GetAttributeList() ); m_pAttrList->Clear(); } void XFSaxStream::EndElement(const rtl::OUString& oustr) { - m_aHandler->endElement(oustr); + if (m_aHandler.is()) + m_aHandler->endElement(oustr); if( m_pAttrList ) m_pAttrList->Clear(); @@ -118,7 +122,8 @@ void XFSaxStream::EndElement(const rtl::OUString& oustr) void XFSaxStream::Characters(const rtl::OUString& oustr) { - m_aHandler->characters(oustr); + if (m_aHandler.is()) + m_aHandler->characters(oustr); } IXFAttrList* XFSaxStream::GetAttrList() diff --git a/lotuswordpro/util/makefile.mk b/lotuswordpro/util/makefile.mk index 640ba297a..b150cc673 100644 --- a/lotuswordpro/util/makefile.mk +++ b/lotuswordpro/util/makefile.mk @@ -36,10 +36,16 @@ DEF1NAME=$(SHL1TARGET) .INCLUDE : target.mk -ALLTAR : $(MISC)/lwpfilter.component +ALLTAR : $(MISC)/lwpfilter.component $(MISC)/qa_lwpfilter.component $(MISC)/lwpfilter.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ lwpfilter.component $(XSLTPROC) --nonet --stringparam uri \ '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ $(SOLARENV)/bin/createcomponent.xslt lwpfilter.component + +$(MISC)/qa_lwpfilter.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + lwpfilter.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_INBUILD_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt lwpfilter.component |