Revision: 201019
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 14 May 2010 17:40:32 +0300
changeset 24 71313a964664
parent 21 f2f7b3284356
child 26 ca9e7f922e8b
child 31 b9ad20498fb4
Revision: 201019 Kit: 201019
charconvfw/numbergrouping/Src/NumberGrouping.cpp
fontservices/fontstore/inc/openfontrasterizer.h
group/bld.inf
textandloc_info/textandloc_metadata/textandloc_metadata.mrp
textandloc_plat/japanese_language_utilities_api/inc/jplangutil.h
textrendering/textformatting/tagma/TmChunk.cpp
textrendering/textformatting/tbox/LAYEMU.CPP
textrendering/textformatting/test/tbandformat/src/helper/bandvalidator.cpp
textrendering/texthandling/stext/TXTETEXT.CPP
textrendering/texthandling/stext/TXTRICH.CPP
--- a/charconvfw/numbergrouping/Src/NumberGrouping.cpp	Mon May 03 14:13:26 2010 +0300
+++ b/charconvfw/numbergrouping/Src/NumberGrouping.cpp	Fri May 14 17:40:32 2010 +0300
@@ -698,7 +698,7 @@
     RPointerArray<TDesC>& aGroupingPatternsList,
     TInt& aMaxExtraCharacters )
     {
-
+	CleanupResetAndDestroyPushL(aGroupingPatternsList);
     TPNGGroupingInfo* groupingInfo = new (ELeave) TPNGGroupingInfo;
     CleanupStack::PushL( groupingInfo );
 
@@ -762,7 +762,11 @@
         User::Leave(err);
         }
     else
+		{
         CleanupStack::Pop( groupingInfo ); // Success. This object now not owned by the cleanupstack
+		}
+
+	CleanupStack::Pop(&aGroupingPatternsList);
     }
 
 void CPNGNumberGrouping::ParseForAfterPositions(
--- a/fontservices/fontstore/inc/openfontrasterizer.h	Mon May 03 14:13:26 2010 +0300
+++ b/fontservices/fontstore/inc/openfontrasterizer.h	Fri May 14 17:40:32 2010 +0300
@@ -20,6 +20,8 @@
 #ifndef OPENFONTRASTERIZER_H
 #define OPENFONTRASTERIZER_H
 
+#include <ecom/ecom.h>
+
 class COpenFontFile;
 
 /**
--- a/group/bld.inf	Mon May 03 14:13:26 2010 +0300
+++ b/group/bld.inf	Fri May 14 17:40:32 2010 +0300
@@ -2,7 +2,7 @@
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
+* under the terms of the License "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
--- a/textandloc_info/textandloc_metadata/textandloc_metadata.mrp	Mon May 03 14:13:26 2010 +0300
+++ b/textandloc_info/textandloc_metadata/textandloc_metadata.mrp	Fri May 14 17:40:32 2010 +0300
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-# All rights reserved.
-# This component and the accompanying materials are made available
-# under the terms of "Eclipse Public License v1.0"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component           textandloc_metadata
 source   \sf\os\textandloc\textandloc_info\textandloc_metadata 
 source   \sf\os\textandloc\package_definition.xml
--- a/textandloc_plat/japanese_language_utilities_api/inc/jplangutil.h	Mon May 03 14:13:26 2010 +0300
+++ b/textandloc_plat/japanese_language_utilities_api/inc/jplangutil.h	Fri May 14 17:40:32 2010 +0300
@@ -22,7 +22,7 @@
 #define __JPLANGUTIL_H__
 
 // INCLUDES
-#include <E32STD.H>
+#include <e32std.h>
 
 // CONSTANTS
 
--- a/textrendering/textformatting/tagma/TmChunk.cpp	Mon May 03 14:13:26 2010 +0300
+++ b/textrendering/textformatting/tagma/TmChunk.cpp	Fri May 14 17:40:32 2010 +0300
@@ -20,25 +20,6 @@
 #include "InlineText.h"
 #include "frmUtils.h"
 
-inline TBool IsSurrogate(TText a) { return 0xD800 == (a & 0xF800); }
-inline TBool IsHighSurrogate(TText a) { return 0xD800 == (a & 0xFC00); }
-inline TBool IsLowSurrogate(TText a) { return 0xDC00 == (a & 0xFC00); }
-inline TChar JoinSurrogates(TText aHigh, TText aLow)
-	{
-	return ((aHigh - 0xd7f7) << 10) + aLow;
-	}
-
-
-inline TText16 GetHighSurrogate(TUint aChar)
-	{
-	return STATIC_CAST(TText16, 0xD7C0 + (aChar >> 10));
-	}
-
-inline TText16 GetLowSurrogate(TUint aChar)
-	{
-	return STATIC_CAST(TText16, 0xDC00 | (aChar & 0x3FF));
-	}
-
 
 TTmChunk::TTmChunk():
 	iDocPos(0),
@@ -107,7 +88,7 @@
 				}
 			}
 
-		if ( IsLowSurrogate( *current_character ) )
+		if ( TChar::IsLowSurrogate( *current_character ) )
 			{
 			// skip it
 			RDebug::Print(_L("Error: Should not be low surrogate. Skip corrupt low surrogate %X."), *current_character);
@@ -118,21 +99,21 @@
 		const TText *previous_character = current_character;
 		TUint character_to_process = *current_character++;
 		// If it's surrogate, join the high and low together
-		if( IsHighSurrogate( character_to_process ) )
+		if( TChar::IsHighSurrogate( character_to_process ) )
 			{
 			TInt high = character_to_process;
 			if ( current_character < last_character )
 			    {
 	            TInt low = *current_character++;
-	            if ( !IsLowSurrogate( low ) )
+	            if ( !TChar::IsLowSurrogate( low ) )
 	                {
 	                // should be low surrogate
 	                // skip the high surrogate
-	                RDebug::Print(_L("Error: Should be low surrogate. Skip corrupt high surrogate %X."), high);
+	                RDebug::Print(_L("Error: %X should be low surrogate. Skip corrupt high surrogate %X."), low, high);
 	                current_character--;
 	                continue;
 	                }
-	            character_to_process = JoinSurrogates( high, low );			    
+	            character_to_process = TChar::JoinSurrogate( high, low );			    
 			    }
 			}
 
@@ -217,23 +198,23 @@
 				{
 				TUint next_character_to_process = *current_character;
 				// If the next character is surrogate
-		        if( IsHighSurrogate( next_character_to_process ) )
+		        if( TChar::IsHighSurrogate( next_character_to_process ) )
 		            {
 		            TInt high = next_character_to_process;
 		            if ( current_character < last_character )
 		                {
 	                    TInt low = *(++current_character);
 	                    
-	                    if ( !IsLowSurrogate( low ) )
+	                    if ( !TChar::IsLowSurrogate( low ) )
 	                        {
 	                        // should be low surrogate
-	                        RDebug::Print(_L("Error: Should be low surrogate. See TmChunk.cpp, TruncateIfNeeded()."));
+	                        RDebug::Print(_L("Error: %X should be low surrogate. See TmChunk.cpp, TruncateIfNeeded()."), low);
                             // The category of the character is determined by what it's mapped
 	                        next_character_to_process = aContext.iSource.Map( high );
 	                        }
 	                    else
 	                        {
-	                        next_character_to_process = JoinSurrogates( high, low );
+	                        next_character_to_process = TChar::JoinSurrogate( high, low );
 	                        }
 	                    --current_character;		                
 		                }
--- a/textrendering/textformatting/tbox/LAYEMU.CPP	Mon May 03 14:13:26 2010 +0300
+++ b/textrendering/textformatting/tbox/LAYEMU.CPP	Fri May 14 17:40:32 2010 +0300
@@ -47,32 +47,6 @@
  the KNumberOfLinesToKeepVisibleDuringScroll constant.*/
 const TInt KMinProportionOfScreenToScroll = 600;
 
-/**
-Tests for a high surrogate.
-@param a UTF16 value.
-@return ETrue if argument is a high surrogate.
-@internalComponent
-*/
-inline TBool IsHighSurrogate(TText a) { return 0xD800 == (a & 0xFC00); }
-/**
-Tests for a low surrogate.
-@param a UTF16 value.
-@return ETrue if argument is a high surrogate.
-@internalComponent
-*/
-inline TBool IsLowSurrogate(TText a) { return 0xDC00 == (a & 0xFC00); }
-/**
-Adds a high surrogate to a low surrogate to create a supplementary character.
-@param aHigh UTF16 high surrogate.
-@param aLow UTF16 low surrogate.
-@return Supplementary character represented by the pair <aHigh, aLow>.
-@pre aHigh is a high surrogate and aLow is a low surrogate.
-@internalComponent
-*/
-inline TChar PairSurrogates(TText aHigh, TText aLow)
-	{
-	return ((aHigh - 0xd7f7) << 10) + aLow;
-	}
 
 /**
 Constructs an iterator over the text referenced by aSource.
@@ -130,11 +104,11 @@
 TChar CTextLayout::TUtf32SourceCache::GetUtf32(TInt aIndex)
 	{
 	TText code = GetUtf16(aIndex);
-	if (IsHighSurrogate(code) && iSource->DocumentLength() < aIndex + 1)
+	if (TChar::IsHighSurrogate(code) && iSource->DocumentLength() < aIndex + 1)
 		{
 		TText code2 = GetUtf16(aIndex + 1);
-		if (IsLowSurrogate(code2))
-			return PairSurrogates(code, code2);
+		if (TChar::IsLowSurrogate(code2))
+			return TChar::JoinSurrogate(code, code2);
 		}
 	return code;
 	}
@@ -1061,8 +1035,8 @@
 				{
 				TUint highSurrogate = text[0];
 				TUint lowSurrogate = text[1];
-				if ( IsHighSurrogate( highSurrogate ) &&
-				     IsLowSurrogate( lowSurrogate ) )
+				if ( TChar::IsHighSurrogate( highSurrogate ) &&
+				        TChar::IsLowSurrogate( lowSurrogate ) )
 					--r;
 				}
 			}
@@ -2236,17 +2210,75 @@
 		{
 		case EFCharacterInsert:
 		case EFParagraphDelimiter:
+			{
 			reformat_param.iStartChar = aCursorPos++;
 			reformat_param.iNewLength = 1;
+
+			// surrogate support
+			TPtrC textForSurrogate;
+			TTmCharFormat formatForSurrogate;
+		
+			iSource->GetText(aCursorPos-1, textForSurrogate, formatForSurrogate);
+			if ( textForSurrogate.Length() > 1 )
+				{
+				TUint highSurrogate = textForSurrogate[0];
+				TUint lowSurrogate = textForSurrogate[1];
+				if ( TChar::IsHighSurrogate( highSurrogate ) && TChar::IsLowSurrogate( lowSurrogate ) )
+					{
+					// if we are inserting a surrogate pair, do not break the pair
+					aCursorPos++;
+					reformat_param.iNewLength++;
+					}
+				}
 			break;
+			}
 		case EFLeftDelete:
+			{
 			reformat_param.iStartChar = --aCursorPos;
 			reformat_param.iOldLength = 1;
+
+			// surrogate support
+			TPtrC textForSurrogate;
+			TTmCharFormat formatForSurrogate;
+		
+			if (aCursorPos >= 1)
+				{
+				iSource->GetText(aCursorPos-1, textForSurrogate, formatForSurrogate);
+				if ( textForSurrogate.Length() > 1 )
+					{
+					TUint highSurrogate = textForSurrogate[0];
+					TUint lowSurrogate = textForSurrogate[1];
+					if ( TChar::IsHighSurrogate( highSurrogate ) && TChar::IsLowSurrogate( lowSurrogate ) )
+						{
+						// if we are deleting a surrogate pair, do not break the pair
+						reformat_param.iStartChar = --aCursorPos;
+						reformat_param.iOldLength++;
+						}
+					}
+				}
 			break;
+			}
 		case EFRightDelete:
+			{
 			reformat_param.iStartChar = aCursorPos;
 			reformat_param.iOldLength = 1;
+
+			// surrogate support
+			TPtrC textForSurrogate;
+			TTmCharFormat formatForSurrogate;
+		
+			iSource->GetText(aCursorPos, textForSurrogate, formatForSurrogate);
+			if ( textForSurrogate.Length() > 1 )
+				{
+				TUint highSurrogate = textForSurrogate[0];
+				TUint lowSurrogate = textForSurrogate[1];
+				if ( TChar::IsHighSurrogate( highSurrogate ) && TChar::IsLowSurrogate( lowSurrogate ) )
+					{
+					reformat_param.iOldLength++;
+					}
+				}
 			break;
+			}
 		default: break;
 		}
 
--- a/textrendering/textformatting/test/tbandformat/src/helper/bandvalidator.cpp	Mon May 03 14:13:26 2010 +0300
+++ b/textrendering/textformatting/test/tbandformat/src/helper/bandvalidator.cpp	Fri May 14 17:40:32 2010 +0300
@@ -154,6 +154,7 @@
 	
 TBool CBandValidator::GetVisibleLineInfosL(const CTextView& aView, RArray<TTmLineInfo>& aVisibleLines)
 	{
+    CleanupClosePushL(aVisibleLines);
 	const CTextLayout* layout = aView.Layout();
 	__ASSERT_ALWAYS(layout, User::Invariant());
 	const CTmTextLayout& tmLayout = layout->TagmaTextLayout();
@@ -163,6 +164,7 @@
 	TTmLineInfo startLine;	
 	if(!(tmLayout.LineNumberToLine(firstLineNumber, startLine)))
 		{
+        CleanupStack::Pop(&aVisibleLines);
 		return EFalse;
 		}
 //get last visible line
@@ -179,11 +181,13 @@
 			//it is, so just get the last formatted line
 			if(!(tmLayout.LineNumberToLine((tmLayout.Lines())-1, endLine)))
 				{
+                CleanupStack::Pop(&aVisibleLines);
 				return EFalse;
 				}
 			}
 		else
 			{
+            CleanupStack::Pop(&aVisibleLines);
 			return EFalse;
 			}
 		}
@@ -196,11 +200,14 @@
 		TTmLineInfo lineInfo;
 		if(!(tmLayout.LineNumberToLine(lineNumber, lineInfo)))
 			{
+            CleanupStack::Pop(&aVisibleLines);
 			return EFalse;
 			}
 		User::LeaveIfError(aVisibleLines.Append(lineInfo));
 		lineNumber++;
 		}
+	
+	CleanupStack::Pop(&aVisibleLines);
 	return ETrue;	
 	}
 	
--- a/textrendering/texthandling/stext/TXTETEXT.CPP	Mon May 03 14:13:26 2010 +0300
+++ b/textrendering/texthandling/stext/TXTETEXT.CPP	Fri May 14 17:40:32 2010 +0300
@@ -1101,8 +1101,6 @@
 	{return ((iByteStore->Size()/sizeof(TText))-1);}
 
 
-
-
 EXPORT_C void CPlainText::InsertL(TInt aInsertPos,const TChar& aChar)
 /** Inserts either a single character or a descriptor into the text object
 at a specified document position.
@@ -1117,11 +1115,28 @@
 	__TEST_INVARIANT;
 	__ASSERT_ALWAYS(aInsertPos>=0 && aInsertPos<=DocumentLength(),Panic(ECharPosBeyondDocument));
 
-	TBuf<1> content;
-	content.Append(aChar);
-	DoPtInsertL(aInsertPos,content);
+	TInt contentLength = 1;
+	if (aChar < 0x10000)
+		{
+		TBuf<1> content;
+		content.Append(aChar);
+		DoPtInsertL(aInsertPos,content);
+		}
+	else
+		{
+		TText16 high = TChar::GetHighSurrogate(aChar);
+		TText16 low = TChar::GetLowSurrogate(aChar);
+		RDebug::Print(_L("CPlainText::InsertL(%d), %X expand to %X %X."), aInsertPos, aChar, high, low);
+	
+		TBuf<2> content;
+		contentLength = 2;
+		content.Append(high);
+		content.Append(low);
+		DoPtInsertL(aInsertPos,content);
+		}
 	if (FieldSetPresent())
-		iFieldSet->NotifyInsertion(aInsertPos,content.Length()); // length always 1 - optimise???
+		iFieldSet->NotifyInsertion(aInsertPos,contentLength);
+
 	SetHasChanged(ETrue);
 
 	__TEST_INVARIANT;
--- a/textrendering/texthandling/stext/TXTRICH.CPP	Mon May 03 14:13:26 2010 +0300
+++ b/textrendering/texthandling/stext/TXTRICH.CPP	Fri May 14 17:40:32 2010 +0300
@@ -628,9 +628,23 @@
 	__ASSERT_ALWAYS(aPos >= 0 && aPos <= DocumentLength(), Panic(ECharPosBeyondDocument));
 	__ASSERT_ALWAYS(aChar!= EPictureCharacter, Panic(ENonOverloadedInsertCalledWithPictureCharacter));
 
-	TBuf<1> content;
-	content.Append(aChar);
-	RtInsertL(aPos, content);
+	if (aChar < 0x10000)
+		{
+		TBuf<1> content;
+		content.Append(aChar);
+		RtInsertL(aPos, content);
+		}
+	else
+		{
+		TText16 high = TChar::GetHighSurrogate(aChar);
+		TText16 low = TChar::GetLowSurrogate(aChar);
+		RDebug::Print(_L("CRichText::InsertL(), %X expand to %X %X."), aChar, high, low);
+		
+		TBuf<2> content;
+		content.Append(high);
+		content.Append(low);
+		RtInsertL(aPos, content);
+		}
 
 	__TEST_INVARIANT;
 	}