diff -r eb1f2e154e89 -r f5a1e66df979 textinput/ptihangulcore/src/OssCombination.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/textinput/ptihangulcore/src/OssCombination.cpp Fri Feb 19 23:09:27 2010 +0200 @@ -0,0 +1,146 @@ +/* +* Copyright (c) 2005,2006 Choe Hwanjin +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "OssCombination.h" +#include "hangul.h" + +TInt CombinationOrderFunction( + const TOssCombinationItem& aFirst, + const TOssCombinationItem& aSecond) + { + TUint keyFirst=aFirst.iFirst<<16|aFirst.iSecond; + TUint keySecond=aSecond.iFirst<<16|aSecond.iSecond; + return keyFirst-keySecond; + } + +TBool TOssCombinationItem::operator == (const TOssCombinationItem& aCombination) const + { + return iFirst==aCombination.iFirst && iSecond==aCombination.iSecond; + } + +EXPORT_C COssCombination* COssCombination::NewLC() + { + COssCombination* self = new (ELeave) COssCombination(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +EXPORT_C COssCombination* COssCombination::NewL() + { + COssCombination* self = COssCombination::NewLC(); + CleanupStack::Pop(); // self; + return self; + } + +COssCombination::COssCombination() + : iHangulCombination(NULL) + { + } + +void COssCombination::ConstructL() + { + } + +EXPORT_C COssCombination::~COssCombination() + { + iCombinationList.Reset(); + iCombinationList.Close(); + if (iHangulCombination) + hangul_combination_delete(iHangulCombination); + } + +EXPORT_C TInt COssCombination::AddCombinationL( + const TOssCombinationItem& aCombination) + { + TInt ret(KErrAlreadyExists); + + TInt index=FindCombination(aCombination); + TLinearOrder orderCombination(CombinationOrderFunction); + + if (index==KErrNotFound) + { + //iCombinationList.Append(aCombination); + iCombinationList.InsertInOrderL(aCombination,orderCombination); + ret=KErrNone; + } + + return ret; + } + +EXPORT_C TInt COssCombination::RemoveCombination( + const TOssCombinationItem& aCombination) + { + TInt ret(KErrNotFound); + + TInt index=FindCombination(aCombination); + if (index!=KErrNotFound) + { + iCombinationList.Remove(index); + ret=KErrNone; + } + return ret; + } + +EXPORT_C TInt COssCombination::FindCombination( + const TOssCombinationItem& aCombination) + { + TInt ret(KErrNotFound); + for (TInt i=0;i