textinput/peninputgenericitut/src/peninputgenericitutconverter.cpp
changeset 0 eb1f2e154e89
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 #include "peninputgenericitutconverter.h"
       
    18 
       
    19 const TUint16 KSegment = 0x0020;
       
    20 
       
    21 TInt TItutDataConverter::AnyToInt(TAny* aOriginal)
       
    22     {
       
    23     return *(reinterpret_cast<TInt*>(aOriginal));
       
    24     }
       
    25     
       
    26 TRect TItutDataConverter::AnyToRect(TAny* aOriginal)
       
    27     {
       
    28     return *(reinterpret_cast<TRect*>(aOriginal));
       
    29     }
       
    30     
       
    31 CFont* TItutDataConverter::AnyToFont(TAny* aOriginal)
       
    32     {
       
    33     return reinterpret_cast<CFont*>(aOriginal);
       
    34     }
       
    35     
       
    36 TPoint TItutDataConverter::AnyToPoint(TAny* aOriginal)
       
    37     {
       
    38     return *(reinterpret_cast<TPoint*>(aOriginal));
       
    39     }
       
    40     
       
    41 TRgb TItutDataConverter::AnyToRgb(TAny* aOriginal)
       
    42     {
       
    43     return *(reinterpret_cast<TRgb*>(aOriginal));
       
    44     }
       
    45     
       
    46 TSize TItutDataConverter::AnyToSize(TAny* aOriginal)
       
    47     {
       
    48     return *(reinterpret_cast<TSize*>(aOriginal));
       
    49     }
       
    50     
       
    51 RPointerArray<HBufC>& TItutDataConverter::AnyToRptrArray(TAny* aOriginal)    
       
    52     {
       
    53     return *(reinterpret_cast<RPointerArray<HBufC>*>(aOriginal));
       
    54     }
       
    55 
       
    56 RArray<TRect>& TItutDataConverter::AnyToRectArray(TAny* aOriginal)
       
    57     {
       
    58     return *(reinterpret_cast<RArray<TRect>*>(aOriginal));
       
    59     }
       
    60 
       
    61 TAknTextLineLayout TItutDataConverter::AnyToTextLine(TAny* aOriginal)
       
    62     {
       
    63     return *(reinterpret_cast<TAknTextLineLayout*>(aOriginal));
       
    64     }
       
    65 
       
    66 void TItutDataConverter::ConvertChnPhraseCandidateL(const TDesC& aSource, 
       
    67                                                     RPointerArray<HBufC>& aList)
       
    68     {
       
    69     TInt start = 0;
       
    70     TInt length = 0;
       
    71 
       
    72     for (TInt ii = 0; ii < aSource.Length(); ii++)
       
    73         {
       
    74         if (aSource[ii] == KSegment)
       
    75             {
       
    76             TPtrC segment(aSource.Ptr() + start, length);
       
    77             aList.AppendL(segment.AllocL());
       
    78             start += (length + 1);
       
    79             length = 0;
       
    80             }
       
    81         else
       
    82             {
       
    83             length++;
       
    84             }
       
    85         }
       
    86 
       
    87     if (length)
       
    88         {
       
    89         TPtrC segm(aSource.Ptr() + start, length);
       
    90         aList.AppendL(segm.AllocL());
       
    91         }
       
    92     }
       
    93 
       
    94 void TItutDataConverter::ConvertNonPhraseCandidateL(const TDesC& aSource, 
       
    95                                                     RPointerArray<HBufC>& aList)
       
    96     {
       
    97     TBuf<1> str;
       
    98     for (TInt ii = 0; ii < aSource.Length(); ii++)
       
    99         {
       
   100         str.Zero();
       
   101         str.Append(aSource[ii]);
       
   102         aList.AppendL(str.AllocL());
       
   103         }
       
   104     }
       
   105 
       
   106 // End Of File