textrendering/textformatting/test/tbandformat/src/helper/bandvalidator.cpp
changeset 24 71313a964664
parent 0 1fb32624e06b
child 49 4d76f1414957
equal deleted inserted replaced
21:f2f7b3284356 24:71313a964664
   152 	return ETrue;
   152 	return ETrue;
   153 	}
   153 	}
   154 	
   154 	
   155 TBool CBandValidator::GetVisibleLineInfosL(const CTextView& aView, RArray<TTmLineInfo>& aVisibleLines)
   155 TBool CBandValidator::GetVisibleLineInfosL(const CTextView& aView, RArray<TTmLineInfo>& aVisibleLines)
   156 	{
   156 	{
       
   157     CleanupClosePushL(aVisibleLines);
   157 	const CTextLayout* layout = aView.Layout();
   158 	const CTextLayout* layout = aView.Layout();
   158 	__ASSERT_ALWAYS(layout, User::Invariant());
   159 	__ASSERT_ALWAYS(layout, User::Invariant());
   159 	const CTmTextLayout& tmLayout = layout->TagmaTextLayout();
   160 	const CTmTextLayout& tmLayout = layout->TagmaTextLayout();
   160 //get first visible line
   161 //get first visible line
   161 //this function usefully returns 0 if the line is not found...that might be a problem
   162 //this function usefully returns 0 if the line is not found...that might be a problem
   162 	TInt firstLineNumber = 0;
   163 	TInt firstLineNumber = 0;
   163 	TTmLineInfo startLine;	
   164 	TTmLineInfo startLine;	
   164 	if(!(tmLayout.LineNumberToLine(firstLineNumber, startLine)))
   165 	if(!(tmLayout.LineNumberToLine(firstLineNumber, startLine)))
   165 		{
   166 		{
       
   167         CleanupStack::Pop(&aVisibleLines);
   166 		return EFalse;
   168 		return EFalse;
   167 		}
   169 		}
   168 //get last visible line
   170 //get last visible line
   169 	TPoint bottom(0, (aView.ViewRect().Height()-1));//-1 is a not nice.
   171 	TPoint bottom(0, (aView.ViewRect().Height()-1));//-1 is a not nice.
   170 	TTmPosInfo2 endPosInfo;
   172 	TTmPosInfo2 endPosInfo;
   177 		if(tmLayout.EndChar() >= tmLayout.Source()->DocumentLength())
   179 		if(tmLayout.EndChar() >= tmLayout.Source()->DocumentLength())
   178 			{
   180 			{
   179 			//it is, so just get the last formatted line
   181 			//it is, so just get the last formatted line
   180 			if(!(tmLayout.LineNumberToLine((tmLayout.Lines())-1, endLine)))
   182 			if(!(tmLayout.LineNumberToLine((tmLayout.Lines())-1, endLine)))
   181 				{
   183 				{
       
   184                 CleanupStack::Pop(&aVisibleLines);
   182 				return EFalse;
   185 				return EFalse;
   183 				}
   186 				}
   184 			}
   187 			}
   185 		else
   188 		else
   186 			{
   189 			{
       
   190             CleanupStack::Pop(&aVisibleLines);
   187 			return EFalse;
   191 			return EFalse;
   188 			}
   192 			}
   189 		}
   193 		}
   190 //add first, last, and everything in between
   194 //add first, last, and everything in between
   191 	User::LeaveIfError(aVisibleLines.Append(startLine));
   195 	User::LeaveIfError(aVisibleLines.Append(startLine));
   194 	while (lineNumber <= lastLineNumber)
   198 	while (lineNumber <= lastLineNumber)
   195 		{
   199 		{
   196 		TTmLineInfo lineInfo;
   200 		TTmLineInfo lineInfo;
   197 		if(!(tmLayout.LineNumberToLine(lineNumber, lineInfo)))
   201 		if(!(tmLayout.LineNumberToLine(lineNumber, lineInfo)))
   198 			{
   202 			{
       
   203             CleanupStack::Pop(&aVisibleLines);
   199 			return EFalse;
   204 			return EFalse;
   200 			}
   205 			}
   201 		User::LeaveIfError(aVisibleLines.Append(lineInfo));
   206 		User::LeaveIfError(aVisibleLines.Append(lineInfo));
   202 		lineNumber++;
   207 		lineNumber++;
   203 		}
   208 		}
       
   209 	
       
   210 	CleanupStack::Pop(&aVisibleLines);
   204 	return ETrue;	
   211 	return ETrue;	
   205 	}
   212 	}
   206 	
   213 	
   207 TBool CBandValidator::GetReferenceLineInfosL(const RArray<TTmLineInfo>& aVisibleLines, RArray<TTmLineInfo>& aReferenceLineInfos)
   214 TBool CBandValidator::GetReferenceLineInfosL(const RArray<TTmLineInfo>& aVisibleLines, RArray<TTmLineInfo>& aReferenceLineInfos)
   208 	{
   215 	{