incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1362925 - in /incubator/ooo/trunk/main: editeng/source/rtf/ sw/source/core/doc/ sw/source/filter/rtf/
Date Wed, 18 Jul 2012 12:58:38 GMT
Author: alg
Date: Wed Jul 18 12:58:38 2012
New Revision: 1362925

URL: http://svn.apache.org/viewvc?rev=1362925&view=rev
Log:
RTF import filter review
Patch by: Michael Stahl

Modified:
    incubator/ooo/trunk/main/editeng/source/rtf/svxrtf.cxx
    incubator/ooo/trunk/main/sw/source/core/doc/docnum.cxx
    incubator/ooo/trunk/main/sw/source/filter/rtf/rtffld.cxx
    incubator/ooo/trunk/main/sw/source/filter/rtf/rtffly.cxx
    incubator/ooo/trunk/main/sw/source/filter/rtf/rtftbl.cxx
    incubator/ooo/trunk/main/sw/source/filter/rtf/swparrtf.cxx
    incubator/ooo/trunk/main/sw/source/filter/rtf/swparrtf.hxx

Modified: incubator/ooo/trunk/main/editeng/source/rtf/svxrtf.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/editeng/source/rtf/svxrtf.cxx?rev=1362925&r1=1362924&r2=1362925&view=diff
==============================================================================
--- incubator/ooo/trunk/main/editeng/source/rtf/svxrtf.cxx (original)
+++ incubator/ooo/trunk/main/editeng/source/rtf/svxrtf.cxx Wed Jul 18 12:58:38 2012
@@ -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>
@@ -823,12 +824,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()
@@ -1348,7 +1351,8 @@ bool SvxRTFParser::UncompressableStackEn
 
 void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser )
 {
-	DBG_ASSERT( pChildList, "es gibt keine ChildListe" );
+    ENSURE_OR_RETURN_VOID(pChildList, "Compress: no ChildList" );
+    ENSURE_OR_RETURN_VOID(pChildList->Count(), "Compress: ChildList empty");
 
 	sal_uInt16 n;
 	SvxRTFItemStackType* pTmp = (*pChildList)[0];

Modified: incubator/ooo/trunk/main/sw/source/core/doc/docnum.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/doc/docnum.cxx?rev=1362925&r1=1362924&r2=1362925&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/doc/docnum.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/doc/docnum.cxx Wed Jul 18 12:58:38 2012
@@ -60,6 +60,9 @@
 
 #include <map>
 
+#include <stdlib.h>
+
+
 inline sal_uInt8 GetUpperLvlChg( sal_uInt8 nCurLvl, sal_uInt8 nLevel, sal_uInt16 nMask )
 {
 	if( 1 < nLevel )
@@ -2466,6 +2469,11 @@ SwNumRule* SwDoc::FindNumRulePtr( const 
 // #i36749#
 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);

Modified: incubator/ooo/trunk/main/sw/source/filter/rtf/rtffld.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/filter/rtf/rtffld.cxx?rev=1362925&r1=1362924&r2=1362925&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/filter/rtf/rtffld.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/filter/rtf/rtffld.cxx Wed Jul 18 12:58:38 2012
@@ -159,7 +159,10 @@ static RTF_FLD_TYPES _WhichFld( String& 
 //			rName = sNm.Copy( nFndPos, nLen );
             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.EraseTrailingChars();
 			return aFldNmArr[n].eFldType;
@@ -391,8 +394,10 @@ int SwRTFParser::MakeFieldInst( String& 
 	{
         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;
@@ -437,7 +442,9 @@ int SwRTFParser::MakeFieldInst( String& 
 			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
@@ -456,7 +463,9 @@ int SwRTFParser::MakeFieldInst( String& 
 			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
@@ -536,7 +545,7 @@ int SwRTFParser::MakeFieldInst( String& 
 			// 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( '.' )) )

Modified: incubator/ooo/trunk/main/sw/source/filter/rtf/rtffly.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/filter/rtf/rtffly.cxx?rev=1362925&r1=1362924&r2=1362925&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/filter/rtf/rtffly.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/filter/rtf/rtffly.cxx Wed Jul 18 12:58:38 2012
@@ -280,7 +280,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();
@@ -1249,6 +1250,10 @@ void SwRTFParser::InsPicture( const Stri
     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;
@@ -1386,6 +1391,7 @@ void SwRTFParser::_SetPictureSize( const
 			if( aSize.Width() > nBoxWidth )
 				aSize.Width() = nBoxWidth;
 		}
+        }
 	}
 
 	//JP 8.11.2001: bug 94450 - if no size exist, then the size is set by

Modified: incubator/ooo/trunk/main/sw/source/filter/rtf/rtftbl.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/filter/rtf/rtftbl.cxx?rev=1362925&r1=1362924&r2=1362925&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/filter/rtf/rtftbl.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/filter/rtf/rtftbl.cxx Wed Jul 18 12:58:38 2012
@@ -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);
+    }
 	size_t nBoxCnt = aMergeBoxes.size()-1;
 	SwBoxFrmFmts aBoxFmts;
 	SwTableBoxFmt* pBoxFmt = pDoc->MakeTableBoxFmt();
@@ -306,8 +311,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 ];
@@ -646,12 +654,6 @@ void SwRTFParser::ReadTable( int nToken 
 
 		pOldTblNd = pTableNode;
 		bNewTbl = sal_False;
-
-		{
-			// JP 13.08.98: TabellenUmrandungen optimieren - Bug 53525
-			void* p = pFmt;
-			aTblFmts.Insert( p, aTblFmts.Count() );
-		}
 	}
 	else
 	{
@@ -746,12 +748,6 @@ void SwRTFParser::ReadTable( int nToken 
 
             m_nCurrentBox = 0;
 			pOldTblNd = pTableNode;
-
-			{
-				// JP 13.08.98: TabellenUmrandungen optimieren - Bug 53525
-				void* p = pFmt;
-				aTblFmts.Insert( p, aTblFmts.Count() );
-			}
 		}
 	}
 
@@ -911,7 +907,7 @@ void SwRTFParser::GotoNextBox()
 		}
 
         if (bMove &&
-                (static_cast<size_t>(m_nCurrentBox + 1) == aMergeBoxes.size()))
+               ((static_cast<size_t>(m_nCurrentBox) + 1) == aMergeBoxes.size()))
 			// dann hinter die Tabelle
 			pPam->Move( fnMoveForward, fnGoNode );
 	}

Modified: incubator/ooo/trunk/main/sw/source/filter/rtf/swparrtf.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/filter/rtf/swparrtf.cxx?rev=1362925&r1=1362924&r2=1362925&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/filter/rtf/swparrtf.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/filter/rtf/swparrtf.cxx Wed Jul 18 12:58:38 2012
@@ -190,7 +190,6 @@ SwRTFParser::SwRTFParser(SwDoc* pD,
     maCharStyleMapper(*pD),
     maSegments(*this),
     maInsertedTables(*pD),
-    aTblFmts(0, 10),
     mpBookmarkStart(0),
     mpRedlineStack(0),
     pAuthorInfos(0),
@@ -562,7 +561,9 @@ bool rtfSections::SetCols(SwFrmFmt &rFmt
     {
         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 );
@@ -2782,7 +2783,7 @@ sal_Bool lcl_SetFmtCol( SwFmt& rFmt, sal
         {
             aCol._SetOrtho( sal_False );
             sal_uInt16 nWishWidth = 0, nHalfPrev = 0;
-            for( sal_uInt16 n = 0, i = 0; n < rColumns.Count(); n += 2, ++i )
+            for (sal_uInt16 n = 0, i = 0; (n+1) < rColumns.Count(); n += 2, ++i)
             {
                 SwColumn* pCol = aCol.GetColumns()[ i ];
                 pCol->SetLeft( nHalfPrev );

Modified: incubator/ooo/trunk/main/sw/source/filter/rtf/swparrtf.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/filter/rtf/swparrtf.hxx?rev=1362925&r1=1362924&r2=1362925&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/filter/rtf/swparrtf.hxx (original)
+++ incubator/ooo/trunk/main/sw/source/filter/rtf/swparrtf.hxx Wed Jul 18 12:58:38 2012
@@ -295,7 +295,6 @@ class SwRTFParser : public SvxRTFParser
 	SwFlySaveArr aFlyArr;				// Flys als Letzes im Doc setzen
 	SvBools aMergeBoxes;				// Flags fuer gemergte Zellen
 	SwListArr aListArr;
-	SvPtrarr aTblFmts;
 	SvPtrarr aRubyCharFmts;
 	BookmarkPosition* mpBookmarkStart;
     sw::util::RedlineStack *mpRedlineStack;



Mime
View raw message