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