textrendering/texthandling/stext/TXTIXSTR.CPP
branchRCL_3
changeset 55 336bee5c2d35
parent 54 748ec5531811
equal deleted inserted replaced
54:748ec5531811 55:336bee5c2d35
    25 #include "TXTMRTSR.H"
    25 #include "TXTMRTSR.H"
    26 #include "TXTRICH.H"
    26 #include "TXTRICH.H"
    27 #include "TXTINDEX.H"
    27 #include "TXTINDEX.H"
    28 #include "TXTSTD.H"
    28 #include "TXTSTD.H"
    29 
    29 
    30 #include "OstTraceDefinitions.h"
       
    31 #ifdef OST_TRACE_COMPILER_IN_USE
       
    32 #include "TXTIXSTRTraces.h"
       
    33 #endif
       
    34 
       
    35 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    30 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    36 #include "TXTFMLYR_INTERNAL.H"
    31 #include "TXTFMLYR_INTERNAL.H"
    37 #endif
    32 #endif
    38 
    33 
    39 const TUint8 KRegisterItemPresent=1;
    34 const TUint8 KRegisterItemPresent=1;
   145 		GetCurrentRecords(current);
   140 		GetCurrentRecords(current);
   146 		if (current.iPhrase && current.iPhrase->IsPicturePhrase())
   141 		if (current.iPhrase && current.iPhrase->IsPicturePhrase())
   147 			{
   142 			{
   148 			RPhraseAttribsEntry& phrase=*current.iPhrase;
   143 			RPhraseAttribsEntry& phrase=*current.iPhrase;
   149 			TPictureHeader* hdr=phrase.PictureHeaderPtr();
   144 			TPictureHeader* hdr=phrase.PictureHeaderPtr();
   150 			if (!hdr)
       
   151 			    {
       
   152 			    OstTrace0( TRACE_DUMP, CRICHTEXTINDEX_STOREPICTURESL, "ERichTextStorePictureIntegrityError" );
       
   153 			    }
       
   154 			__ASSERT_DEBUG(hdr,Panic(ERichTextStorePictureIntegrityError));
   145 			__ASSERT_DEBUG(hdr,Panic(ERichTextStorePictureIntegrityError));
   155 			TBool pictureInMemory=(hdr->iPicture.IsPtr() && hdr->iPicture.AsPtr());
   146 			TBool pictureInMemory=(hdr->iPicture.IsPtr() && hdr->iPicture.AsPtr());
   156 			if (pictureInMemory)
   147 			if (pictureInMemory)
   157 				{// Store the picture
   148 				{// Store the picture
   158 				CPicture& picture=*hdr->iPicture;
   149 				CPicture& picture=*hdr->iPicture;
   201 			{
   192 			{
   202 			RPhraseAttribsEntry& phrase=*current.iPhrase;
   193 			RPhraseAttribsEntry& phrase=*current.iPhrase;
   203 			if (phrase.IsPicturePhrase())
   194 			if (phrase.IsPicturePhrase())
   204 				{
   195 				{
   205 				TPictureHeader* hdr=phrase.PictureHeaderPtr();
   196 				TPictureHeader* hdr=phrase.PictureHeaderPtr();
   206 				if (!hdr)
       
   207 				    {
       
   208 				    OstTrace0( TRACE_DUMP, CRICHTEXTINDEX_DETACHFROMSTOREL, "ERichTextStorePictureIntegrityError" );
       
   209 				    }
       
   210 				__ASSERT_DEBUG(hdr,Panic(ERichTextStorePictureIntegrityError));
   197 				__ASSERT_DEBUG(hdr,Panic(ERichTextStorePictureIntegrityError));
   211 				//
   198 				//
   212 				if (hdr->iPicture.IsId())
   199 				if (hdr->iPicture.IsId())
   213 					{
   200 					{
   214 					TRAPD(r,
   201 					TRAPD(r,
   215 					phrase.PictureHandleL(iText.PictureFactory(),iText.StoreResolver(),iPos.iDocPos,MLayDoc::EForceLoadTrue));  // swizzles
   202 					phrase.PictureHandleL(iText.PictureFactory(),iText.StoreResolver(),iPos.iDocPos,MLayDoc::EForceLoadTrue));  // swizzles
   216 					if (r!=KErrNone && !hdr->iPicture.IsId())
       
   217 					    {
       
   218 					    OstTrace0( TRACE_DUMP, DUP1_CRICHTEXTINDEX_DETACHFROMSTOREL, "ERichTextStorePictureIntegrityError" );    
       
   219 					    }
       
   220 					__ASSERT_DEBUG(r==KErrNone || hdr->iPicture.IsId(),Panic(ERichTextStorePictureIntegrityError));
   203 					__ASSERT_DEBUG(r==KErrNone || hdr->iPicture.IsId(),Panic(ERichTextStorePictureIntegrityError));
   221 					if (r==KErrNotSupported)  // we don't recognise the picture type
   204 					if (r==KErrNotSupported)  // we don't recognise the picture type
   222 						{
   205 						{
   223 						TInt offsetIntoUnit=(current.iPhrase)?iPos.iPhraseElementOffset:iPos.iParaElementOffset;
   206 						TInt offsetIntoUnit=(current.iPhrase)?iPos.iPhraseElementOffset:iPos.iParaElementOffset;
   224 						currentPos+=CurrentPhraseLength()-offsetIntoUnit;
   207 						currentPos+=CurrentPhraseLength()-offsetIntoUnit;
   225 						continue;
   208 						continue;
   226 						}
   209 						}
   227 					
       
   228 					OstTrace1( TRACE_FATAL, DUP3_CRICHTEXTINDEX_DETACHFROMSTOREL, "Leave code=%d", r );
       
   229 					User::LeaveIfError(r);
   210 					User::LeaveIfError(r);
   230 					}
   211 					}
   231 				//
   212 				//
   232 				// recurse the call to detach the picture from the store
   213 				// recurse the call to detach the picture from the store
   233 				if (!hdr->iPicture.IsPtr())
       
   234 				    {
       
   235 				    OstTrace0( TRACE_DUMP, DUP2_CRICHTEXTINDEX_DETACHFROMSTOREL, "ERichTextStorePictureIntegrityError" );
       
   236 				    }
       
   237 				__ASSERT_DEBUG(hdr->iPicture.IsPtr(),Panic(ERichTextStorePictureIntegrityError));
   214 				__ASSERT_DEBUG(hdr->iPicture.IsPtr(),Panic(ERichTextStorePictureIntegrityError));
   238 				hdr->iPicture->DetachFromStoreL(aDegree);
   215 				hdr->iPicture->DetachFromStoreL(aDegree);
   239 				}
   216 				}
   240 			}
   217 			}
   241 		//
   218 		//
   278 // Load a rich text index.  Has construct semantics only!
   255 // Load a rich text index.  Has construct semantics only!
   279 // Restores this object from the specified stream.  As specific format layers are restored, they are based
   256 // Restores this object from the specified stream.  As specific format layers are restored, they are based
   280 // on the specified global format layers. 
   257 // on the specified global format layers. 
   281 //
   258 //
   282 	{
   259 	{
   283 	if (iParaIx->Count()!=1 || (*iParaIx)[0].iLength!=1)
       
   284 	    {
       
   285 	    OstTrace0( TRACE_FATAL, CRICHTEXTINDEX_INTERNALIZEL, "ERtIndexInternalizeCalledOnNonEmptySource" );
       
   286 	    }
       
   287 	__ASSERT_ALWAYS(iParaIx->Count()==1 && (*iParaIx)[0].iLength==1,Panic(ERtIndexInternalizeCalledOnNonEmptySource));
   260 	__ASSERT_ALWAYS(iParaIx->Count()==1 && (*iParaIx)[0].iLength==1,Panic(ERtIndexInternalizeCalledOnNonEmptySource));
   288 	TRtPasteContext context(NULL,aGlobalParaLayer,aGlobalCharLayer,aStyleList);
   261 	TRtPasteContext context(NULL,aGlobalParaLayer,aGlobalCharLayer,aStyleList);
   289 	InternalizeRtiHeaderL(aStream,context);
   262 	InternalizeRtiHeaderL(aStream,context);
   290 	InternalizeSharedFormatsL(aStream,context);
   263 	InternalizeSharedFormatsL(aStream,context);
   291 	InternalizeParaIxL(aStream,context);
   264 	InternalizeParaIxL(aStream,context);
   320 
   293 
   321 			GeneratePhraseLink(paraAttribs.iCharFormat,base);  // constant character formatting
   294 			GeneratePhraseLink(paraAttribs.iCharFormat,base);  // constant character formatting
   322 			}
   295 			}
   323 		else
   296 		else
   324 			{
   297 			{
   325 			if (phraseCount<=1)
       
   326 			    {
       
   327 			    OstTrace0( TRACE_DUMP, CRICHTEXTINDEX_GENERATEALLPHRASELINKSL, "EDebug" );
       
   328 			    }
       
   329 			 __ASSERT_DEBUG(phraseCount>1,Panic(EDebug));
   298 			 __ASSERT_DEBUG(phraseCount>1,Panic(EDebug));
   330 
   299 
   331 			// If the phrase count is too great the CParaAttribs object is corrupt.
   300 			// If the phrase count is too great the CParaAttribs object is corrupt.
   332 			if (phraseElement + phraseCount > iPhraseIx->Count())
   301 			if (phraseElement + phraseCount > iPhraseIx->Count())
   333 				User::Leave(KErrCorrupt);
   302 				User::Leave(KErrCorrupt);
   424 												  const TLogicalPosition& aEnd) const
   393 												  const TLogicalPosition& aEnd) const
   425 // Write those styles that are referenced by the paragraphs in the range aStart to aEnd.
   394 // Write those styles that are referenced by the paragraphs in the range aStart to aEnd.
   426 //
   395 //
   427 	{
   396 	{
   428 	CStyleList* list = iText.StyleList();
   397 	CStyleList* list = iText.StyleList();
   429 	if (!list)
       
   430 	    {
       
   431 	    OstTrace0( TRACE_DUMP, CRICHTEXTINDEX_EXTERNALIZEREFERENCEDSTYLESL, "EStyleClipboardIntegrityError" );
       
   432 	    }
       
   433 	__ASSERT_DEBUG(list,Panic(EStyleClipboardIntegrityError));
   398 	__ASSERT_DEBUG(list,Panic(EStyleClipboardIntegrityError));
   434 	if (aStart.iParaElement > aEnd.iParaElement)
       
   435 	    {
       
   436 	    OstTrace0( TRACE_DUMP, DUP1_CRICHTEXTINDEX_EXTERNALIZEREFERENCEDSTYLESL, "EStyleClipboardIntegrityError" );
       
   437 	    }
       
   438 	__ASSERT_DEBUG(aStart.iParaElement <= aEnd.iParaElement,Panic(EStyleClipboardIntegrityError));
   399 	__ASSERT_DEBUG(aStart.iParaElement <= aEnd.iParaElement,Panic(EStyleClipboardIntegrityError));
   439 
   400 
   440 	TUint8 numStyles = 0;
   401 	TUint8 numStyles = 0;
   441 	if (list) 
   402 	if (list) 
   442 		numStyles = (TUint8)list->Count();
   403 		numStyles = (TUint8)list->Count();
   553 		{
   514 		{
   554 		para=(*iParaIx)[item].iParaAttribs;
   515 		para=(*iParaIx)[item].iParaAttribs;
   555 		TInt index=iText.StyleList()->IndexByPtr(STATIC_CAST(const CParaFormatLayer*,para->iParaFormat->SenseBase()));
   516 		TInt index=iText.StyleList()->IndexByPtr(STATIC_CAST(const CParaFormatLayer*,para->iParaFormat->SenseBase()));
   556 		if (index!=KErrNotFound)
   517 		if (index!=KErrNotFound)
   557 			{
   518 			{
   558 			if (index>=aBuf.Length())
       
   559 			    {
       
   560 			    OstTrace0( TRACE_DUMP, CRICHTEXTINDEX_MARKSTYLEREGISTER, "EStyleClipboardIntegrityError" );
       
   561 			    }
       
   562 			__ASSERT_DEBUG(index<aBuf.Length(),Panic(EStyleClipboardIntegrityError));
   519 			__ASSERT_DEBUG(index<aBuf.Length(),Panic(EStyleClipboardIntegrityError));
   563 			if (aBuf[index]!=KRegisterItemPresent)
   520 			if (aBuf[index]!=KRegisterItemPresent)
   564 				{
   521 				{
   565 				aBuf[index]=KRegisterItemPresent;  // mark item as needing to be stored
   522 				aBuf[index]=KRegisterItemPresent;  // mark item as needing to be stored
   566 		
   523 		
   575 void CRichTextIndex::ExternalizeItemsPresentInRegisterL(RWriteStream& aStream,TInt aSharedCount,const TDes8& aBuf,const CStyleList* aStyleList)const
   532 void CRichTextIndex::ExternalizeItemsPresentInRegisterL(RWriteStream& aStream,TInt aSharedCount,const TDes8& aBuf,const CStyleList* aStyleList)const
   576 // Externalize each object from the shared list that has a corresponding mark in the
   533 // Externalize each object from the shared list that has a corresponding mark in the
   577 // register, aBuf.
   534 // register, aBuf.
   578 //
   535 //
   579 	{
   536 	{
   580 	if (aSharedCount>(TInt)KMaxTUint8)
       
   581 	    {
       
   582 	    OstTrace0( TRACE_DUMP, CRICHTEXTINDEX_EXTERNALIZEITEMSPRESENTINREGISTERL, "ESharedParaCountStreamOverflow" );
       
   583 	    }
       
   584 	__ASSERT_DEBUG(aSharedCount<=(TInt)KMaxTUint8,Panic(ESharedParaCountStreamOverflow));
   537 	__ASSERT_DEBUG(aSharedCount<=(TInt)KMaxTUint8,Panic(ESharedParaCountStreamOverflow));
   585 	aStream.WriteUint8L(aSharedCount);
   538 	aStream.WriteUint8L(aSharedCount);
   586 	CParaAttribs* currentSharedPara=NULL;
   539 	CParaAttribs* currentSharedPara=NULL;
   587 	TDblQueIter<CParaAttribs> iterator(((CRichTextIndex*)this)->iSharedParaQueHead);
   540 	TDblQueIter<CParaAttribs> iterator(((CRichTextIndex*)this)->iSharedParaQueHead);
   588 	TInt offset=0;
   541 	TInt offset=0;
   602 void CRichTextIndex::ExternalizeItemsPresentInStyleRegisterL(RWriteStream& aStream,TInt aRefStyleCount,
   555 void CRichTextIndex::ExternalizeItemsPresentInStyleRegisterL(RWriteStream& aStream,TInt aRefStyleCount,
   603 															 const TDes8& aBuf) const
   556 															 const TDes8& aBuf) const
   604 // Externalize each object from the paragraph style list that has a corresponding mark in the register aBuf.
   557 // Externalize each object from the paragraph style list that has a corresponding mark in the register aBuf.
   605 //
   558 //
   606 	{
   559 	{
   607 	if (aRefStyleCount > (TInt)KMaxTUint8)
       
   608 	    {
       
   609 	    OstTrace0( TRACE_DUMP, CRICHTEXTINDEX_EXTERNALIZEITEMSPRESENTINSTYLEREGISTERL, "EStyleClipboardIntegrityError" );
       
   610 	    }
       
   611 	__ASSERT_DEBUG(aRefStyleCount <= (TInt)KMaxTUint8,Panic(EStyleClipboardIntegrityError));
   560 	__ASSERT_DEBUG(aRefStyleCount <= (TInt)KMaxTUint8,Panic(EStyleClipboardIntegrityError));
   612 	aStream.WriteUint8L(aRefStyleCount);
   561 	aStream.WriteUint8L(aRefStyleCount);
   613 	TInt count=aBuf.Length();
   562 	TInt count=aBuf.Length();
   614 
   563 
   615 	for (TInt ii=0;ii<count;ii++)
   564 	for (TInt ii=0;ii<count;ii++)
   677 		TInt phraseCount=0;
   626 		TInt phraseCount=0;
   678 		if (aStart.iParaElement==aEnd.iParaElement)
   627 		if (aStart.iParaElement==aEnd.iParaElement)
   679 			phraseCount=(aEnd.iPhraseElement-aStart.iPhraseElement)+1;  // copied text contained within 1 para
   628 			phraseCount=(aEnd.iPhraseElement-aStart.iPhraseElement)+1;  // copied text contained within 1 para
   680 		else
   629 		else
   681 			phraseCount=(aEnd.iPhraseElement-aEnd.iParaBasePhraseElement)+1;
   630 			phraseCount=(aEnd.iPhraseElement-aEnd.iParaBasePhraseElement)+1;
   682 		if (phraseCount>lastParaAttribs->iPhraseCount)
       
   683 		    {
       
   684 		    OstTrace0( TRACE_DUMP, CRICHTEXTINDEX_EXTERNALIZEPARAIXL, "ERtExternalizeParaIx" );
       
   685 		    }
       
   686 		__ASSERT_DEBUG(phraseCount<=lastParaAttribs->iPhraseCount,Panic(ERtExternalizeParaIx));
   631 		__ASSERT_DEBUG(phraseCount<=lastParaAttribs->iPhraseCount,Panic(ERtExternalizeParaIx));
   687 		aStream.WriteInt32L(phraseCount);
   632 		aStream.WriteInt32L(phraseCount);
   688 		if (refNo>0)
   633 		if (refNo>0)
   689 			{// Set the virtual phrase representing the trailing text from the shared paragraph.
   634 			{// Set the virtual phrase representing the trailing text from the shared paragraph.
   690 			virtualTextPhrase=new(ELeave) RPhraseAttribsEntry(lastParaAttribs->iCharFormat,lastParaEntry.iLength);
   635 			virtualTextPhrase=new(ELeave) RPhraseAttribsEntry(lastParaAttribs->iCharFormat,lastParaEntry.iLength);
   976 	CParaAttribs* currentSharedPara;
   921 	CParaAttribs* currentSharedPara;
   977 	TDblQueIter<CParaAttribs> iterator(iSharedParaQueHead);
   922 	TDblQueIter<CParaAttribs> iterator(iSharedParaQueHead);
   978 	TInt match=1;
   923 	TInt match=1;
   979 	while ((currentSharedPara=iterator++)!=NULL && aOrdinal!=match)
   924 	while ((currentSharedPara=iterator++)!=NULL && aOrdinal!=match)
   980 		match++;
   925 		match++;
   981 	if (currentSharedPara==NULL)
       
   982 	    {
       
   983 	    OstTrace0( TRACE_FATAL, CRICHTEXTINDEX_SHAREDPARAATTRIBS, "EEndOfSharedParaListEncountered" );
       
   984 	    }
       
   985 	__ASSERT_ALWAYS(currentSharedPara!=NULL,Panic(EEndOfSharedParaListEncountered));
   926 	__ASSERT_ALWAYS(currentSharedPara!=NULL,Panic(EEndOfSharedParaListEncountered));
   986 	return currentSharedPara;
   927 	return currentSharedPara;
   987 	}
   928 	}
   988 
   929 
   989 
   930 
  1367 		para=DoPasteIntoParaL(aStream,aMap,aContext,aStyleMap);
  1308 		para=DoPasteIntoParaL(aStream,aMap,aContext,aStyleMap);
  1368 		(*iParaIx)[aContext.iPastePos.iParaElement+paraItem]=para;
  1309 		(*iParaIx)[aContext.iPastePos.iParaElement+paraItem]=para;
  1369 		characterCount+=para.iLength;
  1310 		characterCount+=para.iLength;
  1370 		}
  1311 		}
  1371 	CleanupStack::Pop();  // firstParaVirtualPhrase
  1312 	CleanupStack::Pop();  // firstParaVirtualPhrase
  1372 // ASSERT: At this point we have pasted all paras that were in the stream.
  1313 // ASSERT: At this point we have pasted all paras that were in the stream.	
  1373 	if (aContext.iParasPasted!=aCompleteParaCount)
       
  1374 	    {
       
  1375 	    OstTrace0( TRACE_DUMP, CRICHTEXTINDEX_PASTEPARAIXL, "EPasteParaIxError" );
       
  1376 	    }
       
  1377 	__ASSERT_DEBUG(aContext.iParasPasted==aCompleteParaCount,Panic(EPasteParaIxError));
  1314 	__ASSERT_DEBUG(aContext.iParasPasted==aCompleteParaCount,Panic(EPasteParaIxError));
  1378 	return characterCount;
  1315 	return characterCount;
  1379 	}
  1316 	}
  1380 			
  1317 			
  1381 			
  1318 			
  1395 		CleanupStack::PushL(layer);
  1332 		CleanupStack::PushL(layer);
  1396 		aFirstParaVirtualPhrase=new(ELeave) RPhraseAttribsEntry(layer,para.iLength);
  1333 		aFirstParaVirtualPhrase=new(ELeave) RPhraseAttribsEntry(layer,para.iLength);
  1397 		CleanupStack::Pop(2);  // layer & specificParaAttribs
  1334 		CleanupStack::Pop(2);  // layer & specificParaAttribs
  1398 		//
  1335 		//
  1399 		para.iParaAttribs=specificParaAttribs;
  1336 		para.iParaAttribs=specificParaAttribs;
  1400 		if (para.iParaAttribs==NULL)
       
  1401 		    {
       
  1402 		    OstTrace0( TRACE_FATAL, CRICHTEXTINDEX_DOPASTEFIRSTINTOPARAL, "ESharedFormatsMapIntegrityError" );
       
  1403 		    }
       
  1404 		__ASSERT_ALWAYS(para.iParaAttribs!=NULL,Panic(ESharedFormatsMapIntegrityError));
  1337 		__ASSERT_ALWAYS(para.iParaAttribs!=NULL,Panic(ESharedFormatsMapIntegrityError));
  1405 		}
  1338 		}
  1406 	else
  1339 	else
  1407 		{// Have to build up the specific para attribs
  1340 		{// Have to build up the specific para attribs
  1408 		CParaFormatLayer* paraLayer=PasteParagraphFormatL(aStream,aContext,aStyleMap);
  1341 		CParaFormatLayer* paraLayer=PasteParagraphFormatL(aStream,aContext,aStyleMap);
  1424 	para.iLength=aStream.ReadInt32L();
  1357 	para.iLength=aStream.ReadInt32L();
  1425 	TUint8 refNo=aStream.ReadUint8L();
  1358 	TUint8 refNo=aStream.ReadUint8L();
  1426 	if (refNo>0)
  1359 	if (refNo>0)
  1427 		{// Link to para attribs in shared list & up its reference count
  1360 		{// Link to para attribs in shared list & up its reference count
  1428 		para.iParaAttribs=aMap.Item(refNo);
  1361 		para.iParaAttribs=aMap.Item(refNo);
  1429 		if (para.iParaAttribs==NULL)
       
  1430 		    {
       
  1431 		    OstTrace0( TRACE_FATAL, CRICHTEXTINDEX_DOPASTEINTOPARAL, "ESharedFormatsMapIntegrityError" );
       
  1432 		    }
       
  1433 		__ASSERT_ALWAYS(para.iParaAttribs!=NULL,Panic(ESharedFormatsMapIntegrityError));
  1362 		__ASSERT_ALWAYS(para.iParaAttribs!=NULL,Panic(ESharedFormatsMapIntegrityError));
  1434 		para.iParaAttribs->iRefCount++;
  1363 		para.iParaAttribs->iRefCount++;
  1435 		}
  1364 		}
  1436 	else
  1365 	else
  1437 		{// Have to build up the specific para attribs
  1366 		{// Have to build up the specific para attribs
  1460 void CRichTextIndex::PastePhraseIxL(RReadStream& aStream,TRtPasteContext& aContext,const RPhraseAttribsEntry* aFirstParaVirtualPhrase)
  1389 void CRichTextIndex::PastePhraseIxL(RReadStream& aStream,TRtPasteContext& aContext,const RPhraseAttribsEntry* aFirstParaVirtualPhrase)
  1461 // The character position to paste at should now fall on a phrase boundary.
  1390 // The character position to paste at should now fall on a phrase boundary.
  1462 //
  1391 //
  1463 	{
  1392 	{
  1464 // ASSERT: Having pasted the paraIx, the para containig pastePos has had the containing phrase split at that point.
  1393 // ASSERT: Having pasted the paraIx, the para containig pastePos has had the containing phrase split at that point.
  1465 	if (aContext.iPastePos.iPhraseElementOffset!=0)
       
  1466 	    {
       
  1467 	    OstTrace0( TRACE_FATAL, CRICHTEXTINDEX_PASTEPHRASEIXL, "EPastePhraseIxErr" );
       
  1468 	    }
       
  1469 	__ASSERT_ALWAYS(aContext.iPastePos.iPhraseElementOffset==0,Panic(EPastePhraseIxErr));
  1394 	__ASSERT_ALWAYS(aContext.iPastePos.iPhraseElementOffset==0,Panic(EPastePhraseIxErr));
  1470 
  1395 
  1471 	TInt offset=0;
  1396 	TInt offset=0;
  1472 	TInt phraseCount=aStream.ReadInt32L();  // leave caught by calling function.  No state change yet.
  1397 	TInt phraseCount=aStream.ReadInt32L();  // leave caught by calling function.  No state change yet.
  1473 	if (aFirstParaVirtualPhrase)
  1398 	if (aFirstParaVirtualPhrase)
  1495 //
  1420 //
  1496 	{
  1421 	{
  1497 	TBool isPicture=(TBool)aStream.ReadUint8L();
  1422 	TBool isPicture=(TBool)aStream.ReadUint8L();
  1498 	TInt phraseLength=aStream.ReadInt32L();
  1423 	TInt phraseLength=aStream.ReadInt32L();
  1499 
  1424 
  1500 	if (!(isPicture && phraseLength==1 || !isPicture))
       
  1501 	    {
       
  1502 	    OstTrace0( TRACE_FATAL, CRICHTEXTINDEX_DOPASTEPHRASEL, "KErrCorrupt" );
       
  1503 	    }
       
  1504 	__ASSERT_ALWAYS(isPicture && phraseLength==1 || !isPicture,User::Leave(KErrCorrupt));
  1425 	__ASSERT_ALWAYS(isPicture && phraseLength==1 || !isPicture,User::Leave(KErrCorrupt));
  1505 	
  1426 	
  1506 	CCharFormatLayer* charLayer=CCharFormatLayer::NewL(aStream);
  1427 	CCharFormatLayer* charLayer=CCharFormatLayer::NewL(aStream);
  1507 /// Change this character format if style formatting is to be applied
  1428 /// Change this character format if style formatting is to be applied
  1508 
  1429 
  1541 				default:
  1462 				default:
  1542 					pictureLoadError=ETrue;
  1463 					pictureLoadError=ETrue;
  1543 					picPhrase->iCharFormat=NULL;
  1464 					picPhrase->iCharFormat=NULL;
  1544 					CleanupStack::PopAndDestroy(picPhrase);
  1465 					CleanupStack::PopAndDestroy(picPhrase);
  1545 					if (r!=KErrNotSupported)
  1466 					if (r!=KErrNotSupported)
  1546 					    {
  1467 						User::Leave(r);
  1547 						OstTrace1( TRACE_FATAL, DUP2_CRICHTEXTINDEX_DOPASTEPHRASEL, "Leave code=%d", r );
       
  1548 					    User::Leave(r);
       
  1549 					    }
       
  1550 				}
  1468 				}
  1551 			}
  1469 			}
  1552 		}
  1470 		}
  1553 	if (isPicture && factory && !pictureLoadError)
  1471 	if (isPicture && factory && !pictureLoadError)
  1554 		new(&aPhrase) RPhraseAttribsEntry(picPhrase);
  1472 		new(&aPhrase) RPhraseAttribsEntry(picPhrase);
  1569 // For each para attribs that has been read in, release all shares on it, if it
  1487 // For each para attribs that has been read in, release all shares on it, if it
  1570 // does not already exist in shared list.
  1488 // does not already exist in shared list.
  1571 //
  1489 //
  1572 	{
  1490 	{
  1573 	NormalizeSharedList();
  1491 	NormalizeSharedList();
  1574 	OstTrace1( TRACE_FATAL, CRICHTEXTINDEX_RBPASTESHAREDFORMATSL, "Leave code=%d", aRet );
       
  1575 	User::Leave(aRet);
  1492 	User::Leave(aRet);
  1576 	}
  1493 	}
  1577 		
  1494 		
  1578 	
  1495 	
  1579 void CRichTextIndex::NormalizeSharedList()
  1496 void CRichTextIndex::NormalizeSharedList()
  1624 		{
  1541 		{
  1625 		RemoveFromPhraseIx(iPos.iPhraseElement,1);  // Removes the phrase created from ResquestReclaim on para
  1542 		RemoveFromPhraseIx(iPos.iPhraseElement,1);  // Removes the phrase created from ResquestReclaim on para
  1626 		(*iParaIx)[aPos.iParaElement].iParaAttribs=iRollbackParaAttribsHandle;
  1543 		(*iParaIx)[aPos.iParaElement].iParaAttribs=iRollbackParaAttribsHandle;
  1627 		iRollbackParaAttribsHandle=NULL;
  1544 		iRollbackParaAttribsHandle=NULL;
  1628 		}
  1545 		}
  1629 	OstTrace1( TRACE_FATAL, CRICHTEXTINDEX_RBPASTEPARAIXL, "Leave code=%d", aRet );
       
  1630 	User::Leave(aRet);
  1546 	User::Leave(aRet);
  1631 	}
  1547 	}
  1632 
  1548 
  1633 
  1549 
  1634 void CRichTextIndex::RbRemoveInsertedPhraseAttribsEntries(TInt aFirstPhraseInsertPos,TInt aInsertedPhraseCount)
  1550 void CRichTextIndex::RbRemoveInsertedPhraseAttribsEntries(TInt aFirstPhraseInsertPos,TInt aInsertedPhraseCount)
  1652 // Rollback on leaving part way through the pasting of the phrase index.
  1568 // Rollback on leaving part way through the pasting of the phrase index.
  1653 // For all pasted phrases, discard their components.
  1569 // For all pasted phrases, discard their components.
  1654 //
  1570 //
  1655 	{
  1571 	{
  1656 	RbRemoveInsertedPhraseAttribsEntries(aPos.iPhraseElement,aPhraseCount);
  1572 	RbRemoveInsertedPhraseAttribsEntries(aPos.iPhraseElement,aPhraseCount);
  1657 	OstTrace1( TRACE_FATAL, CRICHTEXTINDEX_RBPASTEPHRASEIXL, "Leave code=%d", aRet );
       
  1658 	User::Leave(aRet);
  1573 	User::Leave(aRet);
  1659 	}
  1574 	}