diff options
author | Michael Stahl <mst@openoffice.org> | 2012-07-30 18:15:57 +0200 |
---|---|---|
committer | Petr Mladek <pmladek@suse.cz> | 2012-07-30 18:15:57 +0200 |
commit | cded33647a41a4fe195c7647feed81a08f6bb511 (patch) | |
tree | 436de295c18cf400821e7b33131e219d06315487 | |
parent | do not crash when opening rtf file with unclosed field group (diff) | |
download | core-cded33647a41a4fe195c7647feed81a08f6bb511.tar.gz core-cded33647a41a4fe195c7647feed81a08f6bb511.zip |
better page descriptor handling in RTF
Signed-off-by: Petr Mladek <pmladek@suse.cz>
-rw-r--r-- | sw/source/filter/rtf/swparrtf.cxx | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index 2fc6756bb71f..35d4f8d05561 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -3268,6 +3268,7 @@ void SwRTFParser::ReadPageDescTbl() sal_uInt16 nCols = USHRT_MAX, nColSpace = USHRT_MAX, nAktCol = 0; std::vector<sal_uInt16> aColumns; + ::std::map< const SwPageDesc*, sal_uInt16 > aFollowMap; //store index of following page descriptors while( nNumOpenBrakets && IsParserWorking() ) { @@ -3330,10 +3331,9 @@ void SwRTFParser::ReadPageDescTbl() break; case RTF_PGDSCNXT: - // setze erstmal nur die Nummer als Follow. Am Ende der - // Tabelle wird diese entsprechend korrigiert !! + // store index of follow in map; will be fixed up later if( nTokenValue ) - pPg->SetFollow( (const SwPageDesc*)nTokenValue ); + aFollowMap.insert( ::std::pair<const SwPageDesc*, sal_uInt16>( pPg, nTokenValue )); else pPg->SetFollow( & const_cast<const SwDoc *>(pDoc) ->GetPageDesc( 0 ) ); @@ -3502,10 +3502,13 @@ void SwRTFParser::ReadPageDescTbl() for( nPos = 0; nPos < pDoc->GetPageDescCnt(); ++nPos ) { SwPageDesc* pPgDsc = &pDoc->_GetPageDesc( nPos ); - if( (sal_uInt16)(long)pPgDsc->GetFollow() < pDoc->GetPageDescCnt() ) - pPgDsc->SetFollow(& const_cast<const SwDoc *>(pDoc) - ->GetPageDesc((sal_uInt16)(long) - pPgDsc->GetFollow())); + std::map< const SwPageDesc*, sal_uInt16 >::const_iterator aIter = + aFollowMap.find( pPgDsc ); + if (aIter != aFollowMap.end()) + { + if ((*aIter).second < pDoc->GetPageDescCnt()) + pPgDsc->SetFollow(& const_cast<const SwDoc *>(pDoc)->GetPageDesc((*aIter).second)); + } } SetChkStyleAttr( bSaveChkStyleAttr ); |