[Libreoffice-commits] .: Branch 'libreoffice-3-5-6' - editeng/source sw/source
Petr Mladek
pmladek at kemper.freedesktop.org
Tue Aug 7 01:00:17 PDT 2012
editeng/source/rtf/svxrtf.cxx | 6 +++++-
sw/source/core/doc/docnum.cxx | 8 ++++++++
sw/source/filter/rtf/rtffld.cxx | 19 ++++++++++++++-----
sw/source/filter/rtf/rtffly.cxx | 8 +++++++-
sw/source/filter/rtf/rtftbl.cxx | 24 ++++++++++--------------
sw/source/filter/rtf/swparrtf.cxx | 7 ++++---
sw/source/filter/rtf/swparrtf.hxx | 1 -
7 files changed, 48 insertions(+), 25 deletions(-)
New commits:
commit b8f2e4e8ef900c61cd07e805eb90fdea294883b4
Author: Michael Stahl <mst at openoffice.org>
Date: Thu Aug 2 15:54:46 2012 +0200
some tweaks in RTF filter
Signed-off-by: Petr Mladek <pmladek at suse.cz>
Signed-off-by: Miklos Vajna <vmiklos at frugalware.org>
Signed-off-by: Cedric Bosdonnat <CBosdonnat at suse.com>
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index 240fccd..0c0f156 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -29,6 +29,7 @@
#include <ctype.h>
#include <tools/datetime.hxx>
+#include <tools/diagnose_ex.h>
#include <rtl/tencinfo.h>
#include <svl/itemiter.hxx>
#include <svl/whiter.hxx>
@@ -801,12 +802,14 @@ void SvxRTFParser::ClearFontTbl()
{
for( sal_uInt32 nCnt = aFontTbl.Count(); nCnt; )
delete aFontTbl.GetObject( --nCnt );
+ aFontTbl.Clear();
}
void SvxRTFParser::ClearStyleTbl()
{
for( sal_uInt32 nCnt = aStyleTbl.Count(); nCnt; )
delete aStyleTbl.GetObject( --nCnt );
+ aStyleTbl.Clear();
}
void SvxRTFParser::ClearAttrStack()
@@ -1263,7 +1266,8 @@ bool SvxRTFParser::UncompressableStackEntry(const SvxRTFItemStackType &) const
void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser )
{
- DBG_ASSERT( pChildList, "There is no child list" );
+ ENSURE_OR_RETURN_VOID(pChildList, "Compress: no ChildList" );
+ ENSURE_OR_RETURN_VOID(pChildList->Count(), "Compress: ChildList empty");
sal_uInt16 n;
SvxRTFItemStackType* pTmp = (*pChildList)[0];
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index d5a609a..9970743 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -89,6 +89,9 @@ namespace {
}
}
+#include <stdlib.h>
+
+
inline sal_uInt8 GetUpperLvlChg( sal_uInt8 nCurLvl, sal_uInt8 nLevel, sal_uInt16 nMask )
{
if( 1 < nLevel )
@@ -2169,6 +2172,11 @@ SwNumRule* SwDoc::FindNumRulePtr( const String& rName ) const
void SwDoc::AddNumRule(SwNumRule * pRule)
{
+ if ((SAL_MAX_UINT16 - 1) <= pNumRuleTbl->Count())
+ {
+ OSL_ENSURE(false, "SwDoc::AddNumRule: table full.");
+ abort(); // this should never happen on real documents
+ }
pNumRuleTbl->Insert(pRule, pNumRuleTbl->Count());
maNumRuleMap[pRule->GetName()] = pRule;
pRule->SetNumRuleMap(&maNumRuleMap);
diff --git a/sw/source/filter/rtf/rtffld.cxx b/sw/source/filter/rtf/rtffld.cxx
index 51741e1..c42a6a5 100644
--- a/sw/source/filter/rtf/rtffld.cxx
+++ b/sw/source/filter/rtf/rtffld.cxx
@@ -156,7 +156,10 @@ static RTF_FLD_TYPES _WhichFld( String& rName, String& rNext )
{
rName = rName.Copy( nFndPos, static_cast< xub_StrLen >(nLen) );
nFndPos += nTokenStt + static_cast< xub_StrLen >(nLen);
- while( rNext.GetChar( nFndPos ) == ' ' ) ++nFndPos;
+ while ((nFndPos < rNext.Len()) && (rNext.GetChar(nFndPos) == ' '))
+ {
+ ++nFndPos;
+ }
rNext.Erase( 0, nFndPos );
rNext = comphelper::string::stripEnd(rNext, ' ');
return aFldNmArr[n].eFldType;
@@ -388,8 +391,10 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr )
{
xub_StrLen nStartDel = nPos;
nPos += 2;
- while (aSaveStr.GetChar(nPos) == ' ')
+ while ((nPos < aSaveStr.Len()) && (aSaveStr.GetChar(nPos) == ' '))
+ {
++nPos;
+ }
if (aSaveStr.EqualsIgnoreCaseAscii("MERGEFORMAT", nPos, 11))
{
xub_StrLen nNoDel = (nPos + 11 ) - nStartDel;
@@ -431,7 +436,9 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr )
if( STRING_NOTFOUND != ( nPos = aSaveStr.SearchAscii( "\\*" )) )
{
nPos += 2;
- while( aSaveStr.GetChar(nPos) == ' ' ) nPos++;
+ while ((nPos < aSaveStr.Len()) &&
+ (aSaveStr.GetChar(nPos) == ' '))
+ { nPos++; }
aSaveStr.Erase( 0, nPos );
// steht jetzt geanu auf dem Format-Namen
@@ -450,7 +457,9 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr )
if( STRING_NOTFOUND != ( nPos = aSaveStr.SearchAscii( "\\*" )) )
{
nPos += 2;
- while( aSaveStr.GetChar(nPos) == ' ' ) nPos++;
+ while ((nPos < aSaveStr.Len()) &&
+ (aSaveStr.GetChar(nPos) == ' '))
+ { nPos++; }
aSaveStr.Erase( 0, nPos );
// steht jetzt geanu auf dem Format-Namen
@@ -530,7 +539,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr )
// werden:
// \\data -> Datenbank-Name als Field
// DATA -> Datenbank-Info
- sal_Bool bField = rFieldStr.GetChar( 0 ) != 'D';
+ bool const bField = rFieldStr.Len() && rFieldStr.GetChar(0) != 'D';
// nur der Name interressiert
if( STRING_NOTFOUND != (nPos = aSaveStr.Search( '.' )) )
diff --git a/sw/source/filter/rtf/rtffly.cxx b/sw/source/filter/rtf/rtffly.cxx
index b4c6573..ea58864 100644
--- a/sw/source/filter/rtf/rtffly.cxx
+++ b/sw/source/filter/rtf/rtffly.cxx
@@ -276,7 +276,8 @@ void SwRTFParser::SetFlysInDoc()
// liegt Ende und Start vom Naechsten im gleichen Node, dann muss
// gesplittet werden
- if( n + 1 < aFlyArr.Count() && pFlySave->nEndCnt &&
+ if (((static_cast<size_t>(n) + 1) < aFlyArr.Count()) &&
+ pFlySave->nEndCnt &&
pFlySave->nEndNd == aFlyArr[ n + 1 ]->nSttNd )
{
SwCntntNode *const pCNd = pFlySave->nEndNd.GetNode().GetCntntNode();
@@ -1226,6 +1227,10 @@ void SwRTFParser::InsPicture( const String& rGrfNm, const Graphic* pGrf,
// #i83368# - Assure that graphic node is enclosed by fly frame node.
if ( bReadSwFly && !mbReadCellWhileReadSwFly )
{
+ OSL_ENSURE(aFlyArr.Count(),
+ "SwRTFParser::InsPicture: fly array empty.");
+ if (aFlyArr.Count())
+ {
// erzeuge nur einen normalen GrafikNode und ersetze diesen gegen
// den vorhandenen Textnode
SwNodeIndex& rIdx = pPam->GetPoint()->nNode;
@@ -1246,6 +1251,7 @@ void SwRTFParser::InsPicture( const String& rGrfNm, const Graphic* pGrf,
if( pFlySave->nEndNd == rIdx )
pFlySave->nEndNd = rIdx.GetIndex() - 1;
}
+ }
}
else
{
diff --git a/sw/source/filter/rtf/rtftbl.cxx b/sw/source/filter/rtf/rtftbl.cxx
index 2fa62f0..2cfdcfc 100644
--- a/sw/source/filter/rtf/rtftbl.cxx
+++ b/sw/source/filter/rtf/rtftbl.cxx
@@ -216,6 +216,11 @@ void SwRTFParser::ReadTable( int nToken )
sal_Int16 eVerOrient = text::VertOrientation::NONE;
long nLineHeight = 0;
+ if (aMergeBoxes.empty()) // can this actually happen?
+ {
+ OSL_ASSERT(false);
+ aMergeBoxes.push_back(sal_False);
+ }
SwBoxFrmFmts aBoxFmts;
SwTableBoxFmt* pBoxFmt = pDoc->MakeTableBoxFmt();
SvxFrameDirection eDir = FRMDIR_HORI_LEFT_TOP;
@@ -305,8 +310,11 @@ void SwRTFParser::ReadTable( int nToken )
{
--m_nCurrentBox;
}
- pFmt = static_cast<SwTableBoxFmt*>(
- pLine->GetTabBoxes()[ m_nCurrentBox ]->GetFrmFmt());
+ if (m_nCurrentBox < pLine->GetTabBoxes().Count())
+ {
+ pFmt = static_cast<SwTableBoxFmt*>(
+ pLine->GetTabBoxes()[m_nCurrentBox]->GetFrmFmt());
+ }
}
else
pFmt = aBoxFmts[ aBoxFmts.Count()-1 ];
@@ -575,12 +583,6 @@ void SwRTFParser::ReadTable( int nToken )
pOldTblNd = pTableNode;
bNewTbl = sal_False;
-
- {
- //TabellenUmrandungen optimieren
- void* p = pFmt;
- aTblFmts.Insert( p, aTblFmts.Count() );
- }
}
else
{
@@ -675,12 +677,6 @@ void SwRTFParser::ReadTable( int nToken )
m_nCurrentBox = 0;
pOldTblNd = pTableNode;
-
- {
- // TabellenUmrandungen optimieren
- void* p = pFmt;
- aTblFmts.Insert( p, aTblFmts.Count() );
- }
}
}
diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx
index 35d4f8d..88ab7a0 100644
--- a/sw/source/filter/rtf/swparrtf.cxx
+++ b/sw/source/filter/rtf/swparrtf.cxx
@@ -232,7 +232,6 @@ SwRTFParser::SwRTFParser(SwDoc* pD,
maCharStyleMapper(*pD),
maSegments(*this),
maInsertedTables(*pD),
- aTblFmts(0, 10),
mpBookmarkStart(0),
mpRedlineStack(0),
pAuthorInfos(0),
@@ -600,7 +599,9 @@ bool rtfSections::SetCols(SwFrmFmt &rFmt, const rtfSection &rSection,
{
aCol._SetOrtho(false);
sal_uInt16 nWishWidth = 0, nHalfPrev = 0;
- for(sal_uInt16 n=0, i=0; n < rSection.maPageInfo.maColumns.size() && i < nCols; n += 2, ++i )
+ for (sal_uInt16 n=0, i=0;
+ (static_cast<size_t>(n)+1) < rSection.maPageInfo.maColumns.size() && i < nCols;
+ n += 2, ++i)
{
SwColumn* pCol = aCol.GetColumns()[ i ];
pCol->SetLeft( nHalfPrev );
@@ -2781,7 +2782,7 @@ sal_Bool lcl_SetFmtCol( SwFmt& rFmt, sal_uInt16 nCols, sal_uInt16 nColSpace,
{
aCol._SetOrtho( sal_False );
sal_uInt16 nWishWidth = 0, nHalfPrev = 0;
- for( sal_uInt16 n = 0, i = 0; n < rColumns.size(); n += 2, ++i )
+ for (sal_uInt16 n = 0, i = 0; static_cast<size_t>(n+1) < rColumns.size(); n += 2, ++i)
{
SwColumn* pCol = aCol.GetColumns()[ i ];
pCol->SetLeft( nHalfPrev );
diff --git a/sw/source/filter/rtf/swparrtf.hxx b/sw/source/filter/rtf/swparrtf.hxx
index b908bf6..e6a94a3 100644
--- a/sw/source/filter/rtf/swparrtf.hxx
+++ b/sw/source/filter/rtf/swparrtf.hxx
@@ -290,7 +290,6 @@ class SwRTFParser : public SvxRTFParser
SwFlySaveArr aFlyArr; // Flys als Letzes im Doc setzen
std::vector<bool> aMergeBoxes; // Flags fuer gemergte Zellen
SwListArr aListArr;
- SvPtrarr aTblFmts;
SvPtrarr aRubyCharFmts;
BookmarkPosition* mpBookmarkStart;
sw::util::RedlineStack *mpRedlineStack;
More information about the Libreoffice-commits
mailing list