Commits

Thomas Lange [tl]  committed c6ea739

cws tl77: fix for RTF crash (provided by OS)

  • Participants
  • Parent commits d498344

Comments (0)

Files changed (4)

File editeng/inc/editeng/svxrtf.hxx

 inline SfxItemSet& SvxRTFParser::GetAttrSet()
 {
 	SvxRTFItemStackTypePtr pTmp;
-	if( bNewGroup || 0 == ( pTmp = aAttrStack.back()) )
+    if( bNewGroup || 0 == ( pTmp = aAttrStack.empty() ? 0 : aAttrStack.back()) )
 		pTmp = _GetAttrSet();
 	return pTmp->aAttrSet;
 }

File editeng/source/rtf/rtfitem.cxx

 	RTF_CharTypeDef eCharType = NOTDEF_CHARTYPE;
 	USHORT nFontAlign;
 
-	int bChkStkPos = !bNewGroup && aAttrStack.back();
+	int bChkStkPos = !bNewGroup && !aAttrStack.empty();
 
 	while( bWeiter && IsParserWorking() )			// solange bekannte Attribute erkannt werden
 	{
 				if( !bChkStkPos )
 					break;
 
-				SvxRTFItemStackType* pAkt = aAttrStack.back();
+				SvxRTFItemStackType* pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();
 				if( !pAkt || (pAkt->pSttNd->GetIdx() == pInsPos->GetNodeIdx() &&
 					pAkt->nSttCnt == pInsPos->GetCntIdx() ))
 					break;
 
 					// alle bis hierher gueltigen Attribute "setzen"
 					AttrGroupEnd();
-					pAkt = aAttrStack.back();  // can be changed after AttrGroupEnd!
+					pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();  // can be changed after AttrGroupEnd!
 					pNew->aAttrSet.SetParent( pAkt ? &pAkt->aAttrSet : 0 );
 
 					aAttrStack.push_back( pNew );
 					nStyleNo = -1 == nTokenValue ? 0 : USHORT(nTokenValue);
 					// setze am akt. auf dem AttrStack stehenden Style die
 					// StyleNummer
-					SvxRTFItemStackType* pAkt = aAttrStack.back();
+					SvxRTFItemStackType* pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();
 					if( !pAkt )
 						break;
 
 // pard / plain abarbeiten
 void SvxRTFParser::RTFPardPlain( int bPard, SfxItemSet** ppSet )
 {
-	if( !bNewGroup && aAttrStack.back() )	// not at the beginning of a new group
+	if( !bNewGroup && !aAttrStack.empty() )	// not at the beginning of a new group
 	{
-		SvxRTFItemStackType* pAkt = aAttrStack.back();
+        SvxRTFItemStackType* pAkt = aAttrStack.back();
 
 		int nLastToken = GetStackPtr(-1)->nTokenId;
 		int bNewStkEntry = TRUE;
 
 				// alle bis hierher gueltigen Attribute "setzen"
 				AttrGroupEnd();
-				pAkt = aAttrStack.back();  // can be changed after AttrGroupEnd!
+				pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();  // can be changed after AttrGroupEnd!
 				pNew->aAttrSet.SetParent( pAkt ? &pAkt->aAttrSet : 0 );
 				aAttrStack.push_back( pNew );
 				pAkt = pNew;

File editeng/source/rtf/svxrtf.cxx

 
 SvxRTFItemStackType* SvxRTFParser::_GetAttrSet( int bCopyAttr )
 {
-	SvxRTFItemStackType* pAkt = aAttrStack.back();
+    SvxRTFItemStackType* pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();
 	SvxRTFItemStackType* pNew;
 	if( pAkt )
 		pNew = new SvxRTFItemStackType( *pAkt, *pInsPos, bCopyAttr );
 {
 	if( !aAttrStack.empty() )
 	{
-		SvxRTFItemStackType *pOld = aAttrStack.back();
+        SvxRTFItemStackType *pOld = aAttrStack.empty() ? 0 : aAttrStack.back();
 		aAttrStack.pop_back();
-		SvxRTFItemStackType *pAkt = aAttrStack.back();
+		SvxRTFItemStackType *pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();
 
 		do {		// middle check loop
 			ULONG nOldSttNdIdx = pOld->pSttNd->GetIdx();
 
 						// alle bis hierher gueltigen Attribute "setzen"
 						AttrGroupEnd();
-						pAkt = aAttrStack.back();  // can be changed after AttrGroupEnd!
+                        pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();  // can be changed after AttrGroupEnd!
 						pNew->aAttrSet.SetParent( pAkt ? &pAkt->aAttrSet : 0 );
 						aAttrStack.push_back( pNew );
 						pAkt = pNew;
 	// Is text wasn't inserted? (Get SttPos from the top of stack!)
 int	SvxRTFParser::IsAttrSttPos()
 {
-	SvxRTFItemStackType* pAkt = aAttrStack.back();
+    SvxRTFItemStackType* pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();
 	return !pAkt || (pAkt->pSttNd->GetIdx() == pInsPos->GetNodeIdx() &&
 		pAkt->nSttCnt == pInsPos->GetCntIdx());
 }

File sw/source/filter/rtf/swparrtf.cxx

 
             // wurde an der Position ein Escapement aufgespannt, so entferne
             // das jetzt. Fussnoten sind bei uns immer hochgestellt.
-            SvxRTFItemStackTypePtr pTmp = aSaveStack.back();
+            SvxRTFItemStackTypePtr pTmp = aSaveStack.empty() ? 0 : aSaveStack.back();
             if( pTmp && pTmp->GetSttNodeIdx() ==
                 pPam->GetPoint()->nNode.GetIndex() &&
                 pTmp->GetSttCnt() == nPos )