textrendering/textformatting/tbox/FRMTVIEW.CPP
changeset 44 601ab138ba0b
parent 0 1fb32624e06b
child 55 336bee5c2d35
equal deleted inserted replaced
37:6be019398652 44:601ab138ba0b
    17 
    17 
    18 
    18 
    19 #include "FRMTLAY.H"
    19 #include "FRMTLAY.H"
    20 #include "FRMTVIEW.H"
    20 #include "FRMTVIEW.H"
    21 #include "FRMCONST.H"
    21 #include "FRMCONST.H"
       
    22 
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "FRMTVIEWTraces.h"
       
    26 #endif
    22 
    27 
    23 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    28 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    24 #include "FRMCONST_INTERNAL.H"
    29 #include "FRMCONST_INTERNAL.H"
    25 #include "FRMCONST_PARTNER.H"
    30 #include "FRMCONST_PARTNER.H"
    26 #include "TAGMA_INTERNAL.H"
    31 #include "TAGMA_INTERNAL.H"
   263 		}
   268 		}
   264 	}
   269 	}
   265 
   270 
   266 void TCursor::DrawLineCursor(TInt aHeight)
   271 void TCursor::DrawLineCursor(TInt aHeight)
   267 	{
   272 	{
       
   273 	if (!iLineCursorBitmap)
       
   274 	    {
       
   275 	    OstTrace0( TRACE_FATAL, DUP1_TCURSOR_DRAWLINECURSOR, "EFLineCursorBitmapNotSet" );
       
   276 	    }
   268 	__ASSERT_ALWAYS(iLineCursorBitmap,FormPanic(EFLineCursorBitmapNotSet));
   277 	__ASSERT_ALWAYS(iLineCursorBitmap,FormPanic(EFLineCursorBitmapNotSet));
   269 	TRect cursorMargin=iDisplay.LineCursorMargin();
   278 	TRect cursorMargin=iDisplay.LineCursorMargin();
   270 	TRect bitmapRect;
   279 	TRect bitmapRect;
   271 	
   280 	
   272 	bitmapRect.iTl.iX=cursorMargin.iTl.iX+ELineCursorToLabelGap;
   281 	bitmapRect.iTl.iX=cursorMargin.iTl.iX+ELineCursorToLabelGap;
   405 	iCursorPos(),
   414 	iCursorPos(),
   406 	iFlags(EFEverythingVisible | EFFlickerFreeRedraw | EFTextVisible),
   415 	iFlags(EFEverythingVisible | EFFlickerFreeRedraw | EFTextVisible),
   407 	iHorizontalScroll(EFNoPreviousHorizontalScroll),
   416 	iHorizontalScroll(EFNoPreviousHorizontalScroll),
   408 	iContextIsNavigation(ETrue)
   417 	iContextIsNavigation(ETrue)
   409 	{
   418 	{
       
   419 	if (EFMemoryOK == EFRecovering)
       
   420 	    {
       
   421 	    OstTrace0( TRACE_DUMP, CTEXTVIEW_CTEXTVIEW, "EFSystemConstantsChanged" );
       
   422 	    }
   410 	__ASSERT_DEBUG(EFMemoryOK != EFRecovering,FormPanic(EFSystemConstantsChanged));
   423 	__ASSERT_DEBUG(EFMemoryOK != EFRecovering,FormPanic(EFSystemConstantsChanged));
   411 	}
   424 	}
   412 
   425 
   413 EXPORT_C void CTextView::ConstructL(CTextLayout *aLayout,const TRect &aDisplay,CBitmapDevice *aGd,
   426 EXPORT_C void CTextView::ConstructL(CTextLayout *aLayout,const TRect &aDisplay,CBitmapDevice *aGd,
   414 									MGraphicsDeviceMap *aDeviceMap,RWindow *aWin,RWindowGroup *aGroupWin,
   427 									MGraphicsDeviceMap *aDeviceMap,RWindow *aWin,RWindowGroup *aGroupWin,
   415 									RWsSession *aSession)
   428 									RWsSession *aSession)
   416 	{
   429 	{
       
   430 	if (!aLayout)
       
   431 	    {
       
   432 	    OstTrace0( TRACE_FATAL, CTEXTVIEW_CONSTRUCTL, "EFInvalidLayout" );
       
   433 	    }
   417 	__ASSERT_ALWAYS(aLayout,FormPanic(EFInvalidLayout));
   434 	__ASSERT_ALWAYS(aLayout,FormPanic(EFInvalidLayout));
   418 	iHorizontalScrollJump=EFDefaultHorizontalScrollJump;
   435 	iHorizontalScrollJump=EFDefaultHorizontalScrollJump;
   419 	iWrap = CIdle::NewL(EFBackgroundFormattingPriority);
   436 	iWrap = CIdle::NewL(EFBackgroundFormattingPriority);
   420 	SetLayout(aLayout);
   437 	SetLayout(aLayout);
   421 	SetViewRect(aDisplay);
   438 	SetViewRect(aDisplay);
   436 
   453 
   437 @param aLayout Pointer to the text layout object used by the text view. Must 
   454 @param aLayout Pointer to the text layout object used by the text view. Must 
   438 not be NULL or a panic occurs. */
   455 not be NULL or a panic occurs. */
   439 EXPORT_C void CTextView::SetLayout(CTextLayout *aLayout)
   456 EXPORT_C void CTextView::SetLayout(CTextLayout *aLayout)
   440 	{
   457 	{
       
   458 	if (!aLayout)
       
   459 	    {
       
   460 	    OstTrace0( TRACE_FATAL, CTEXTVIEW_SETLAYOUT, "EFInvalidLayout" );
       
   461 	    }
   441 	__ASSERT_ALWAYS(aLayout,FormPanic(EFInvalidLayout));
   462 	__ASSERT_ALWAYS(aLayout,FormPanic(EFInvalidLayout));
   442 	iLayout = aLayout;
   463 	iLayout = aLayout;
   443 	iCursorPos.SetLayout(aLayout);
   464 	iCursorPos.SetLayout(aLayout);
   444 	iDisplay.SetLayout(aLayout);
   465 	iDisplay.SetLayout(aLayout);
   445 	}
   466 	}
   752 	TInt fontHeight = 0;
   773 	TInt fontHeight = 0;
   753 	TInt fontAscent = 0;
   774 	TInt fontAscent = 0;
   754 	TRAPD(err,iLayout->GetFontHeightAndAscentL(aFontSpec,fontHeight,fontAscent));
   775 	TRAPD(err,iLayout->GetFontHeightAndAscentL(aFontSpec,fontHeight,fontAscent));
   755 	if (!err)
   776 	if (!err)
   756 		iCursor.SetAscentAndDescent(fontAscent,fontHeight - fontAscent);
   777 		iCursor.SetAscentAndDescent(fontAscent,fontHeight - fontAscent);
   757 	User::LeaveIfError(err);
   778 	if (err)
       
   779 	    {
       
   780         OstTrace1( TRACE_FATAL, CTEXTVIEW_MATCHCURSORHEIGHTL, "Leave code=%d", err );
       
   781         User::Leave(err);
       
   782 	    }
   758 	}
   783 	}
   759 
   784 
   760 /** Gets the current selection.
   785 /** Gets the current selection.
   761 @return The current selection. */
   786 @return The current selection. */
   762 EXPORT_C TCursorSelection CTextView::Selection() const
   787 EXPORT_C TCursorSelection CTextView::Selection() const
   780 position. EFalse if not. */
   805 position. EFalse if not. */
   781 EXPORT_C TBool CTextView::IsPictureFrameSelected(TRect& aPictureFrameRect,TInt& aDocPos) const
   806 EXPORT_C TBool CTextView::IsPictureFrameSelected(TRect& aPictureFrameRect,TInt& aDocPos) const
   782 	{
   807 	{
   783 	if (iCursorPos.IsPictureFrame())
   808 	if (iCursorPos.IsPictureFrame())
   784 		{
   809 		{
       
   810 		if (!iPictureFrame)
       
   811 		    {
       
   812 		    OstTrace0( TRACE_DUMP, CTEXTVIEW_ISPICTUREFRAMESELECTED, "EFNoPictureFrame" );
       
   813 		    }
   785 		__ASSERT_DEBUG(iPictureFrame,FormPanic(EFNoPictureFrame));
   814 		__ASSERT_DEBUG(iPictureFrame,FormPanic(EFNoPictureFrame));
   786 		aPictureFrameRect=iPictureFrame->Rect();
   815 		aPictureFrameRect=iPictureFrame->Rect();
   787 		aDocPos=Selection().LowerPos();
   816 		aDocPos=Selection().LowerPos();
   788 		return ETrue;
   817 		return ETrue;
   789 		}
   818 		}
   933 		{
   962 		{
   934 		selection.iAnchorPos = iLayout->DocumentLength();
   963 		selection.iAnchorPos = iLayout->DocumentLength();
   935 		return selection;
   964 		return selection;
   936 		}
   965 		}
   937 
   966 
       
   967 	if (selection.iCursorPos >= anchor)
       
   968 	    {
       
   969 	    OstTrace0( TRACE_DUMP, CTEXTVIEW_GETFORWARDDELETEPOSITIONL, "selection.iCursorPos >= anchor" );
       
   970 	    }
   938 	__ASSERT_DEBUG(selection.iCursorPos < anchor, User::Invariant());
   971 	__ASSERT_DEBUG(selection.iCursorPos < anchor, User::Invariant());
       
   972 	if (selection.Length())
       
   973 	    {
       
   974 	    OstTrace0( TRACE_DUMP, DUP1_CTEXTVIEW_GETFORWARDDELETEPOSITIONL, "selection.Length()!=0" );
       
   975 	    }
   939 	__ASSERT_DEBUG(selection.Length() == 0, User::Invariant());
   976 	__ASSERT_DEBUG(selection.Length() == 0, User::Invariant());
   940 
   977 
   941 	// Now we have found the next formatted position. However, this
   978 	// Now we have found the next formatted position. However, this
   942 	// may have skipped a ligature. We should only delete the first character
   979 	// may have skipped a ligature. We should only delete the first character
   943 	// in any ligature.
   980 	// in any ligature.
   946 	CTextLayout::TUtf32SourceCache sourceCache(*iLayout);
   983 	CTextLayout::TUtf32SourceCache sourceCache(*iLayout);
   947 	TInt graphicalSpacingCharactersFound = 0;
   984 	TInt graphicalSpacingCharactersFound = 0;
   948 	TBool ignoreNextSpacingCharacter = EFalse;
   985 	TBool ignoreNextSpacingCharacter = EFalse;
   949 	for (TInt i = selection.iCursorPos; i != anchor; ++i)
   986 	for (TInt i = selection.iCursorPos; i != anchor; ++i)
   950 		{
   987 		{
       
   988 		if (i >= anchor)
       
   989 		    {
       
   990 		    OstTrace0( TRACE_DUMP, DUP2_CTEXTVIEW_GETFORWARDDELETEPOSITIONL, "i >= anchor" );
       
   991 		    }
   951 		__ASSERT_DEBUG(i < anchor, User::Invariant());
   992 		__ASSERT_DEBUG(i < anchor, User::Invariant());
   952 		TChar c = sourceCache.GetUtf32(i);
   993 		TChar c = sourceCache.GetUtf32(i);
   953 		if ( IsGraphicalSpacing(c) )
   994 		if ( IsGraphicalSpacing(c) )
   954 			{
   995 			{
   955 			if (!ignoreNextSpacingCharacter)
   996 			if (!ignoreNextSpacingCharacter)
  1012 	if (anchor==KErrNotFound)
  1053 	if (anchor==KErrNotFound)
  1013 		{
  1054 		{
  1014 		selection.iAnchorPos = 0;
  1055 		selection.iAnchorPos = 0;
  1015 		return selection;
  1056 		return selection;
  1016 		}
  1057 		}
  1017 
  1058 	if (anchor >= selection.iCursorPos)
       
  1059 	    {
       
  1060 	    OstTrace0( TRACE_DUMP, CTEXTVIEW_GETBACKWARDDELETEPOSITIONL, "anchor >= selection.iCursorPos" );
       
  1061 	    }
  1018 	__ASSERT_DEBUG(anchor < selection.iCursorPos, User::Invariant());
  1062 	__ASSERT_DEBUG(anchor < selection.iCursorPos, User::Invariant());
       
  1063 	if (selection.Length() != 0)
       
  1064 	    {
       
  1065 	    OstTrace0( TRACE_DUMP, DUP1_CTEXTVIEW_GETBACKWARDDELETEPOSITIONL, "selection.Length() != 0" );
       
  1066 	    }
  1019 	__ASSERT_DEBUG(selection.Length() == 0, User::Invariant());
  1067 	__ASSERT_DEBUG(selection.Length() == 0, User::Invariant());
  1020 
  1068 
  1021 	// If this cluster is a ligature, it needs to be split.
  1069 	// If this cluster is a ligature, it needs to be split.
  1022 	// Note that an indic syllable (where consonants are glued
  1070 	// Note that an indic syllable (where consonants are glued
  1023 	// together with viramas) does not count as a ligature.
  1071 	// together with viramas) does not count as a ligature.
  1086 
  1134 
  1087 /** Draws good parts of the screen that have recently been formatted by
  1135 /** Draws good parts of the screen that have recently been formatted by
  1088 background formatting. Enters OOM before leaving. */
  1136 background formatting. Enters OOM before leaving. */
  1089 void CTextView::DisplayNewLinesL(TInt aFrom,TInt aTo)
  1137 void CTextView::DisplayNewLinesL(TInt aFrom,TInt aTo)
  1090 	{
  1138 	{
       
  1139 	if (iNoMemory)
       
  1140 	    {
       
  1141 	    OstTrace0( TRACE_DUMP, CTEXTVIEW_DISPLAYNEWLINESL, "EFNoMemory" );
       
  1142 	    }
  1091 	__ASSERT_DEBUG(!iNoMemory,FormPanic(EFNoMemory));
  1143 	__ASSERT_DEBUG(!iNoMemory,FormPanic(EFNoMemory));
  1092 	if (aTo>iGood)
  1144 	if (aTo>iGood)
  1093 		{
  1145 		{
  1094 		ScrollTextL(aTo - iGood,iGood,0,FALSE);
  1146 		ScrollTextL(aTo - iGood,iGood,0,FALSE);
  1095 		iGood=aTo;
  1147 		iGood=aTo;
  1417 	TInt formattedFrom = 0;   
  1469 	TInt formattedFrom = 0;   
  1418 	TInt from = 0;
  1470 	TInt from = 0;
  1419  	TBool formatting = IsFormatting();
  1471  	TBool formatting = IsFormatting();
  1420 	TBool moreToDo = ETrue;
  1472 	TBool moreToDo = ETrue;
  1421 
  1473 
       
  1474 	if (iCursorPos.IsSelection())
       
  1475 	    {
       
  1476 	    OstTrace0( TRACE_DUMP, CTEXTVIEW_HANDLECHAREDITL, "EFSelectionCannotCharEdit" );
       
  1477 	    }
  1422 	__ASSERT_DEBUG(!iCursorPos.IsSelection(),FormPanic(EFSelectionCannotCharEdit));
  1478 	__ASSERT_DEBUG(!iCursorPos.IsSelection(),FormPanic(EFSelectionCannotCharEdit));
       
  1479 	if (aType>CTextLayout::EFRightDelete)
       
  1480 	    {
       
  1481 	    OstTrace0( TRACE_DUMP, DUP1_CTEXTVIEW_HANDLECHAREDITL, "EFBadCharacterEditType" );
       
  1482 	    }
  1423 	__ASSERT_DEBUG(aType<=CTextLayout::EFRightDelete,FormPanic(EFBadCharacterEditType));
  1483 	__ASSERT_DEBUG(aType<=CTextLayout::EFRightDelete,FormPanic(EFBadCharacterEditType));
       
  1484 	if ( !(!aFormatChanged || aType==CTextLayout::EFRightDelete 
       
  1485                             || aType==CTextLayout::EFLeftDelete) )
       
  1486 	    {
       
  1487 	    OstTrace0( TRACE_DUMP, DUP2_CTEXTVIEW_HANDLECHAREDITL, "EFBadCharacterEditType" );
       
  1488 	    }
  1424 	__ASSERT_DEBUG(!aFormatChanged || aType==CTextLayout::EFRightDelete 
  1489 	__ASSERT_DEBUG(!aFormatChanged || aType==CTextLayout::EFRightDelete 
  1425 							|| aType==CTextLayout::EFLeftDelete,FormPanic(EFBadCharacterEditType));
  1490 							|| aType==CTextLayout::EFLeftDelete,FormPanic(EFBadCharacterEditType));
  1426 	TBool recovered=NoMemoryCheckL();
  1491 	TBool recovered=NoMemoryCheckL();
  1427 	iCursor.MatchCursorHeightToAdjacentChar();
  1492 	iCursor.MatchCursorHeightToAdjacentChar();
  1428 	TPoint dummyPoint;
  1493 	TPoint dummyPoint;
       
  1494 	if ( !(iLayout->PosInBand(iCursorPos.TmDocPos(),dummyPoint)
       
  1495 	        || !formatting) )
       
  1496 	    {
       
  1497 	    OstTrace0( TRACE_DUMP, DUP3_CTEXTVIEW_HANDLECHAREDITL, "EFBackgroundFormatting" );
       
  1498 	    }
  1429 	__ASSERT_DEBUG(iLayout->PosInBand(iCursorPos.TmDocPos(),dummyPoint)
  1499 	__ASSERT_DEBUG(iLayout->PosInBand(iCursorPos.TmDocPos(),dummyPoint)
  1430 		|| !formatting, FormPanic(EFBackgroundFormatting));
  1500 		|| !formatting, FormPanic(EFBackgroundFormatting));
  1431 	TTmDocPos doc_pos = iCursorPos.TmDocPos();
  1501 	TTmDocPos doc_pos = iCursorPos.TmDocPos();
  1432 	if ((!formatting && !iLayout->PosInBand(doc_pos,dummyPoint)) || recovered)
  1502 	if ((!formatting && !iLayout->PosInBand(doc_pos,dummyPoint)) || recovered)
  1433 		{
  1503 		{
  1548 		if (viewChanges.iScrollAtBottom<0 && viewChanges.iFormattedTo<to)
  1618 		if (viewChanges.iScrollAtBottom<0 && viewChanges.iFormattedTo<to)
  1549 			ScrollRect(viewChanges.iScrollAtBottom,viewChanges.iFormattedTo,to);
  1619 			ScrollRect(viewChanges.iScrollAtBottom,viewChanges.iFormattedTo,to);
  1550 		iDisplay.DeactivateContext();
  1620 		iDisplay.DeactivateContext();
  1551 		}
  1621 		}
  1552 	iDisplay.SetRects(RScreenDisplay::EFClipViewRect);
  1622 	iDisplay.SetRects(RScreenDisplay::EFClipViewRect);
       
  1623 	if (from>viewChanges.iFormattedFrom && from>0)
       
  1624 	    {
       
  1625 	    OstTrace0( TRACE_DUMP, DUP1_CTEXTVIEW_HANDLEBLOCKCHANGEL, "EFScrollError" );
       
  1626 	    }
  1553 	__ASSERT_DEBUG(from<=viewChanges.iFormattedFrom || from<=0,FormPanic(EFScrollError));
  1627 	__ASSERT_DEBUG(from<=viewChanges.iFormattedFrom || from<=0,FormPanic(EFScrollError));
       
  1628 	if (to<viewChanges.iFormattedTo && to<iDrawTextLayoutContext.DisplayHeight())
       
  1629 	    {
       
  1630 	    OstTrace0( TRACE_DUMP, DUP2_CTEXTVIEW_HANDLEBLOCKCHANGEL, "EFScrollError" );
       
  1631 	    }
  1554 	__ASSERT_DEBUG(to>=viewChanges.iFormattedTo || to>=iDrawTextLayoutContext.DisplayHeight(),FormPanic(EFScrollError));
  1632 	__ASSERT_DEBUG(to>=viewChanges.iFormattedTo || to>=iDrawTextLayoutContext.DisplayHeight(),FormPanic(EFScrollError));
  1555 	if (from>0)
  1633 	if (from>0)
  1556 		DisplayLineRangeL(0,from);
  1634 		DisplayLineRangeL(0,from);
  1557 	DisplayLineRangeL(viewChanges.iFormattedFrom,viewChanges.iFormattedTo);
  1635 	DisplayLineRangeL(viewChanges.iFormattedFrom,viewChanges.iFormattedTo);
  1558 	if (to<iDrawTextLayoutContext.DisplayHeight())
  1636 	if (to<iDrawTextLayoutContext.DisplayHeight())
  2181 void CTextView::ScrollTextL(TInt aScrollY,TInt aFrom,TInt aScrollX,TBool aScrollBackground)
  2259 void CTextView::ScrollTextL(TInt aScrollY,TInt aFrom,TInt aScrollX,TBool aScrollBackground)
  2182 	{
  2260 	{
  2183 	TRect rect;
  2261 	TRect rect;
  2184 	TInt height=iDrawTextLayoutContext.DisplayHeight();
  2262 	TInt height=iDrawTextLayoutContext.DisplayHeight();
  2185 
  2263 
       
  2264 	if (aScrollX==0 && aScrollY==0)
       
  2265 	    {
       
  2266 	    OstTrace0( TRACE_DUMP, CTEXTVIEW_SCROLLTEXTL, "EFScrollByZero2" );
       
  2267 	    }
  2186 	__ASSERT_DEBUG(aScrollX!=0 || aScrollY!=0,FormPanic(EFScrollByZero2));
  2268 	__ASSERT_DEBUG(aScrollX!=0 || aScrollY!=0,FormPanic(EFScrollByZero2));
       
  2269 	if (aFrom!=0 && aScrollX!=0)
       
  2270 	    {
       
  2271 	    OstTrace0( TRACE_DUMP, DUP1_CTEXTVIEW_SCROLLTEXTL, "EFScrollError" );
       
  2272 	    }
  2187 	__ASSERT_DEBUG(aFrom==0 || aScrollX==0,FormPanic(EFScrollError));       //Can only scroll the whole of the ViewRect Horizontally
  2273 	__ASSERT_DEBUG(aFrom==0 || aScrollX==0,FormPanic(EFScrollError));       //Can only scroll the whole of the ViewRect Horizontally
  2188 	if (aScrollX==0)
  2274 	if (aScrollX==0)
  2189 		rect=iDrawTextLayoutContext.iViewRect;
  2275 		rect=iDrawTextLayoutContext.iViewRect;
  2190 	else
  2276 	else
  2191 		rect=iDrawTextLayoutContext.TextArea();
  2277 		rect=iDrawTextLayoutContext.TextArea();
  2235 		AdjustRectForScrolling(rect,aScrollY,0);
  2321 		AdjustRectForScrolling(rect,aScrollY,0);
  2236 		}
  2322 		}
  2237 
  2323 
  2238 	TInt top=rect.iTl.iY;
  2324 	TInt top=rect.iTl.iY;
  2239 
  2325 
       
  2326 	if (aTo<0 || aTo<=aFrom)
       
  2327 	    {
       
  2328 	    OstTrace0( TRACE_DUMP, CTEXTVIEW_SCROLLRECT, "EFScrollError" );
       
  2329 	    }
  2240 	__ASSERT_DEBUG(aTo>=0 && aTo>aFrom,FormPanic(EFScrollError));
  2330 	__ASSERT_DEBUG(aTo>=0 && aTo>aFrom,FormPanic(EFScrollError));
  2241 	aFrom-=aScrollY;
  2331 	aFrom-=aScrollY;
  2242 	if (aFrom>0)
  2332 	if (aFrom>0)
  2243 		{
  2333 		{
  2244 		rect.iTl.iY+=aFrom;
  2334 		rect.iTl.iY+=aFrom;
  2333 	NoMemoryCheckL();
  2423 	NoMemoryCheckL();
  2334 	TBool needInverting=((!aVisible)!=(!(iFlags & EFSelectionVisible))); //Extra '!' needed to cope with aVisible>1
  2424 	TBool needInverting=((!aVisible)!=(!(iFlags & EFSelectionVisible))); //Extra '!' needed to cope with aVisible>1
  2335 	if (needInverting && !iDrawTextLayoutContext.TextOverrideColor() && (iFlags & EFTextVisible))
  2425 	if (needInverting && !iDrawTextLayoutContext.TextOverrideColor() && (iFlags & EFTextVisible))
  2336 		{
  2426 		{
  2337 	 	TCursorSelection selection;
  2427 	 	TCursorSelection selection;
  2338 
       
  2339 		__ASSERT_DEBUG(iLayout->__DbgIsFormattingUpToDate(),FormPanic(EFFormatOutOfDate));
  2428 		__ASSERT_DEBUG(iLayout->__DbgIsFormattingUpToDate(),FormPanic(EFFormatOutOfDate));
  2340 		iFlags |= EFSelectionVisible;
  2429 		iFlags |= EFSelectionVisible;
  2341 		iCursorPos.GetSelection(selection);
  2430 		iCursorPos.GetSelection(selection);
  2342 		TBool isPictureFrame=iCursorPos.IsPictureFrame();
  2431 		TBool isPictureFrame=iCursorPos.IsPictureFrame();
  2343 		iDisplay.SetRects(RScreenDisplay::EFClipTextArea);
  2432 		iDisplay.SetRects(RScreenDisplay::EFClipTextArea);
  2495 EXPORT_C TPoint CTextView::SetViewL(TInt aDocPos,TInt& aYPos,TViewYPosQualifier aYPosQualifier,
  2584 EXPORT_C TPoint CTextView::SetViewL(TInt aDocPos,TInt& aYPos,TViewYPosQualifier aYPosQualifier,
  2496 									TDiscard aDiscardFormat,TDoHorizontalScroll aDoHorizontalScroll)
  2585 									TDiscard aDiscardFormat,TDoHorizontalScroll aDoHorizontalScroll)
  2497 	{
  2586 	{
  2498 	if (NoMemoryCheckL())
  2587 	if (NoMemoryCheckL())
  2499 		aDiscardFormat = CTextView::EFViewDontDiscardFullRedraw;
  2588 		aDiscardFormat = CTextView::EFViewDontDiscardFullRedraw;
       
  2589 	if (aDocPos < 0 || aDocPos > iLayout->DocumentLength())
       
  2590 	    {
       
  2591 	    OstTrace0( TRACE_DUMP, CTEXTVIEW_SETVIEWL, "EFInvalidDocPos" );
       
  2592 	    }
  2500 	__ASSERT_ALWAYS(aDocPos >= 0 && aDocPos <= iLayout->DocumentLength(),FormPanic(EFInvalidDocPos));
  2593 	__ASSERT_ALWAYS(aDocPos >= 0 && aDocPos <= iLayout->DocumentLength(),FormPanic(EFInvalidDocPos));
  2501 	aYPos -= TopViewRect();
  2594 	aYPos -= TopViewRect();
  2502 	TTmDocPos pos(aDocPos,
  2595 	TTmDocPos pos(aDocPos,
  2503 		aDocPos == iLayout->DocumentLength()? EFalse : ETrue);
  2596 		aDocPos == iLayout->DocumentLength()? EFalse : ETrue);
  2504 	TPoint scroll = ViewL(pos,aYPos,aYPosQualifier,aDiscardFormat,aDoHorizontalScroll);
  2597 	TPoint scroll = ViewL(pos,aYPos,aYPosQualifier,aDiscardFormat,aDoHorizontalScroll);
  2624 This function should not be used to handle the situation where text is added to
  2717 This function should not be used to handle the situation where text is added to
  2625 the final paragraph. In this case, use HandleInsertDeleteL() or
  2718 the final paragraph. In this case, use HandleInsertDeleteL() or
  2626 HandleCharEditL() instead. */
  2719 HandleCharEditL() instead. */
  2627 EXPORT_C void CTextView::HandleAdditionalCharactersAtEndL()
  2720 EXPORT_C void CTextView::HandleAdditionalCharactersAtEndL()
  2628 	{
  2721 	{
       
  2722 	if (IsFormatting())
       
  2723 	    {
       
  2724 	    OstTrace0( TRACE_DUMP, CTEXTVIEW_HANDLEADDITIONALCHARACTERSATENDL, "EFBackgroundFormatting" );
       
  2725 	    }
  2629 	__ASSERT_DEBUG(!IsFormatting(),FormPanic(EFBackgroundFormatting));
  2726 	__ASSERT_DEBUG(!IsFormatting(),FormPanic(EFBackgroundFormatting));
  2630 	if (!NoMemoryCheckL())
  2727 	if (!NoMemoryCheckL())
  2631 		{
  2728 		{
  2632 		TInt from = 0;
  2729 		TInt from = 0;
  2633 		TInt to = 0;
  2730 		TInt to = 0;
  2721 
  2818 
  2722 void CTextView::HighlightUsingExtensions(CTextLayout::TRangeChange aOptimizedRange, CTextLayout::TRangeChange aOriginalRange)
  2819 void CTextView::HighlightUsingExtensions(CTextLayout::TRangeChange aOptimizedRange, CTextLayout::TRangeChange aOriginalRange)
  2723 	{
  2820 	{
  2724 	TInt visPos;
  2821 	TInt visPos;
  2725 	TInt visLen=iLayout->PosRangeInBand(visPos);
  2822 	TInt visLen=iLayout->PosRangeInBand(visPos);
  2726 
  2823 	
       
  2824 	if (visLen<0)
       
  2825 	    {
       
  2826 	    OstTrace0( TRACE_DUMP, CTEXTVIEW_HIGHLIGHTUSINGEXTENSIONS, "EFNoMemory" );
       
  2827 	    }
  2727 	__ASSERT_DEBUG(visLen>=0,FormPanic(EFNoMemory));  //  Shouldn't be in OOM here.
  2828 	__ASSERT_DEBUG(visLen>=0,FormPanic(EFNoMemory));  //  Shouldn't be in OOM here.
       
  2829 	if (!SelectionVisible())
       
  2830 	    {
       
  2831 	    OstTrace0( TRACE_DUMP, DUP1_CTEXTVIEW_HIGHLIGHTUSINGEXTENSIONS, "EFSelectionNotVisible" );
       
  2832 	    }
  2728 	__ASSERT_DEBUG(SelectionVisible(),FormPanic(EFSelectionNotVisible));
  2833 	__ASSERT_DEBUG(SelectionVisible(),FormPanic(EFSelectionNotVisible));
  2729 
  2834 
  2730 	if (!aOptimizedRange.Clip(visPos, visPos + visLen))
  2835 	if (!aOptimizedRange.Clip(visPos, visPos + visLen))
  2731 		return;
  2836 		return;
  2732 	(void)aOriginalRange.Clip(visPos, visPos + visLen);
  2837 	(void)aOriginalRange.Clip(visPos, visPos + visLen);
  2831 					 and the background already has been drawn. So we can use the EDrawModePEN 
  2936 					 and the background already has been drawn. So we can use the EDrawModePEN 
  2832 					 without problems. 
  2937 					 without problems. 
  2833 */
  2938 */
  2834 void CTextView::DrawPictureFrameL(TRect& aClipRect)
  2939 void CTextView::DrawPictureFrameL(TRect& aClipRect)
  2835 	{
  2940 	{
       
  2941 	if (!iCursorPos.IsPictureFrame())
       
  2942 	    {
       
  2943 	    OstTrace0( TRACE_DUMP, CTEXTVIEW_DRAWPICTUREFRAMEL, "EFNoPictureFrame" );
       
  2944 	    }
  2836 	__ASSERT_DEBUG(iCursorPos.IsPictureFrame(),FormPanic(EFNoPictureFrame));
  2945 	__ASSERT_DEBUG(iCursorPos.IsPictureFrame(),FormPanic(EFNoPictureFrame));
  2837 	TCursorSelection selection;
  2946 	TCursorSelection selection;
  2838 	iCursorPos.GetSelection(selection);
  2947 	iCursorPos.GetSelection(selection);
  2839 	if(iLayout->PosIsFormatted(selection.LowerPos()))
  2948 	if(iLayout->PosIsFormatted(selection.LowerPos()))
  2840 		{
  2949 		{
  2856 	}
  2965 	}
  2857 
  2966 
  2858 /** Enters the OOM state. */
  2967 /** Enters the OOM state. */
  2859 void CTextView::NoMemoryL(TInt aError)
  2968 void CTextView::NoMemoryL(TInt aError)
  2860 	{
  2969 	{
       
  2970 	if (iNoMemory==EFOutOfMemory)
       
  2971 	    {
       
  2972 	    OstTrace0( TRACE_DUMP, CTEXTVIEW_NOMEMORYL, "EFNoMemory" );
       
  2973 	    }
  2861 	__ASSERT_DEBUG(iNoMemory!=EFOutOfMemory,FormPanic(EFNoMemory));
  2974 	__ASSERT_DEBUG(iNoMemory!=EFOutOfMemory,FormPanic(EFNoMemory));
  2862 	iLayout->DiscardFormat();
  2975 	iLayout->DiscardFormat();
  2863 	if (iNoMemory==EFMemoryOK)
  2976 	if (iNoMemory==EFMemoryOK)
  2864 		{
  2977 		{
  2865 		TTmPosInfo2 pos_info;
  2978 		TTmPosInfo2 pos_info;
  2883 before leaving */
  2996 before leaving */
  2884 TBool CTextView::NoMemoryCheckL()
  2997 TBool CTextView::NoMemoryCheckL()
  2885 	{
  2998 	{
  2886 	TBool recovered=iNoMemory;
  2999 	TBool recovered=iNoMemory;
  2887 
  3000 
       
  3001 	if (iNoMemory==EFRecovering)
       
  3002 	    {
       
  3003 	    OstTrace0( TRACE_DUMP, CTEXTVIEW_NOMEMORYCHECKL, "EFRecoverNoMemory" );
       
  3004 	    }
  2888 	__ASSERT_DEBUG(iNoMemory!=EFRecovering,FormPanic(EFRecoverNoMemory));
  3005 	__ASSERT_DEBUG(iNoMemory!=EFRecovering,FormPanic(EFRecoverNoMemory));
  2889 	if (iNoMemory)
  3006 	if (iNoMemory)
  2890 		RecoverNoMemoryL();
  3007 		RecoverNoMemoryL();
  2891 	return recovered;
  3008 	return recovered;
  2892 	}
  3009 	}
  2893 
  3010 
  2894 /** Make an attempt to recover from no system memory
  3011 /** Make an attempt to recover from no system memory
  2895 Enters OOM before leaving */
  3012 Enters OOM before leaving */
  2896 void CTextView::RecoverNoMemoryL()
  3013 void CTextView::RecoverNoMemoryL()
  2897 	{
  3014 	{
  2898 
  3015 	if (iNoMemory!=EFOutOfMemory)
       
  3016 	    {
       
  3017 	    OstTrace0( TRACE_DUMP, CTEXTVIEW_RECOVERNOMEMORYL, "EFRecoverNoMemory" );
       
  3018 	    }
  2899 	__ASSERT_DEBUG(iNoMemory==EFOutOfMemory,FormPanic(EFRecoverNoMemory));
  3019 	__ASSERT_DEBUG(iNoMemory==EFOutOfMemory,FormPanic(EFRecoverNoMemory));
  2900 	iNoMemory=EFRecovering;
  3020 	iNoMemory=EFRecovering;
  2901 	RecreateWindowServerObjectsL();
  3021 	RecreateWindowServerObjectsL();
  2902 	TTmDocPos end(iLayout->DocumentLength(), EFalse);
  3022 	TTmDocPos end(iLayout->DocumentLength(), EFalse);
  2903 	TTmDocPos pos = iCursorPos.TmDocPos();
  3023 	TTmDocPos pos = iCursorPos.TmDocPos();
  2904 	if (pos.iPos > end.iPos)
  3024 	if (pos.iPos > end.iPos)
  2905 		iCursorPos.SetDocPos(end);
  3025 		iCursorPos.SetDocPos(end);
  2906 	ViewL(iCursorPos.TmDocPos(),iGood);
  3026 	ViewL(iCursorPos.TmDocPos(),iGood);
       
  3027 	if (iNoMemory!=EFRecovering)
       
  3028 	    {
       
  3029 	    OstTrace0( TRACE_DUMP, DUP1_CTEXTVIEW_RECOVERNOMEMORYL, "EFNoMemory" );
       
  3030 	    }
  2907 	__ASSERT_DEBUG(iNoMemory==EFRecovering,FormPanic(EFNoMemory));
  3031 	__ASSERT_DEBUG(iNoMemory==EFRecovering,FormPanic(EFNoMemory));
  2908 	iNoMemory=EFMemoryOK;
  3032 	iNoMemory=EFMemoryOK;
  2909 	iGood=0;
  3033 	iGood=0;
  2910 	if (iLayout->FormattedHeightInPixels() < iLayout->BandHeight() && iLayout->FirstDocPosFullyInBand()>0)
  3034 	if (iLayout->FormattedHeightInPixels() < iLayout->BandHeight() && iLayout->FirstDocPosFullyInBand()>0)
  2911 		{
  3035 		{
  2926 
  3050 
  2927 @param aScrollJump The number of pixels by which a horizontal scroll jump will
  3051 @param aScrollJump The number of pixels by which a horizontal scroll jump will
  2928 cause the view to scroll. Must be a positive value or a panic occurs. */
  3052 cause the view to scroll. Must be a positive value or a panic occurs. */
  2929 EXPORT_C void CTextView::SetHorizontalScrollJump(TInt aScrollJump)
  3053 EXPORT_C void CTextView::SetHorizontalScrollJump(TInt aScrollJump)
  2930 	{
  3054 	{
       
  3055 	if (aScrollJump<0)
       
  3056 	    {
       
  3057 	    OstTrace0( TRACE_DUMP, CTEXTVIEW_SETHORIZONTALSCROLLJUMP, "EFInvalidJumpValue" );
       
  3058 	    }
  2931 	__ASSERT_ALWAYS(aScrollJump>=0,FormPanic(EFInvalidJumpValue));
  3059 	__ASSERT_ALWAYS(aScrollJump>=0,FormPanic(EFInvalidJumpValue));
  2932 	__ASSERT_DEBUG(aScrollJump<EFUnreasonablyLargeHorizontalScrollJump
  3060 	__ASSERT_DEBUG(aScrollJump<EFUnreasonablyLargeHorizontalScrollJump
  2933 																	,FormPanic(EFInvalidJumpValue));
  3061 																	,FormPanic(EFInvalidJumpValue));
  2934 	iHorizontalScrollJump=aScrollJump;
  3062 	iHorizontalScrollJump=aScrollJump;
  2935 	}
  3063 	}
  3236 
  3364 
  3237 	CBitmapContext* screen_gc = iDisplay.BitmapContext();
  3365 	CBitmapContext* screen_gc = iDisplay.BitmapContext();
  3238 	RDrawTextSupport support(&iDisplay, &iDrawTextLayoutContext, bitmap);
  3366 	RDrawTextSupport support(&iDisplay, &iDrawTextLayoutContext, bitmap);
  3239 	CleanupClosePushL(support);
  3367 	CleanupClosePushL(support);
  3240 	if (error)
  3368 	if (error)
  3241 		User::Leave(error);
  3369 	    {
       
  3370 	    OstTrace1( TRACE_DUMP, CTEXTVIEW_DODRAWTEXTSUPPORTL, "Leave code=%d", error );
       
  3371 	    User::Leave(error);
       
  3372 	    }
  3242 
  3373 
  3243 	// If we are flicker-free drawing (and there was enough memory for it) or
  3374 	// If we are flicker-free drawing (and there was enough memory for it) or
  3244 	// drawing to an off screen bitmap for some other reason, set up
  3375 	// drawing to an off screen bitmap for some other reason, set up
  3245 	// iDrawTextLayoutContext to temporarily point to the appropriate place
  3376 	// iDrawTextLayoutContext to temporarily point to the appropriate place
  3246 	if (isDrawingOnABitmap)
  3377 	if (isDrawingOnABitmap)