uiutils/Findutil/inc/FindUtilChinese.h
changeset 0 2f259fa3e83a
child 8 71dd06cfe933
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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:         findutilchinese header file.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 #ifndef __FINDUTILCHINESE__
       
    27 #define __FINDUTILCHINESE__
       
    28 
       
    29 // INCLUDES
       
    30 #include <e32base.h>
       
    31 
       
    32 #include "FindUtilBase.h"
       
    33 
       
    34 // FORWARD DECLARATION
       
    35 class CPtiEngine;
       
    36 class CFindRepositoryWatcher;
       
    37 class CRepository;
       
    38 
       
    39 // CONSTANTS
       
    40 const TInt KMaxWordLength = 128;
       
    41 /**
       
    42 
       
    43 Defines flags that can be used to indicate what is the default search method for each language.
       
    44 */
       
    45 enum TDefaultAdaptiveSearchMethod
       
    46     {
       
    47     EAdptSearchPinyin =0,
       
    48     EAdptSearchStroke,
       
    49     EAdptSearchZhuyin,
       
    50     EAdptSearchNormalCangjie,
       
    51     EAdptSearchEasyCangjie,
       
    52     EAdptSearchAdvCangjie
       
    53     };
       
    54 /**
       
    55  *  STRINGINFO struct
       
    56  *
       
    57  *  This data struct is for splited taxt in find pane. 
       
    58  *  It includes two type word, which is Chinese or no-Chinese 
       
    59  *
       
    60  *  @lib FindUtil.dll
       
    61  *  @since S60 v3.2
       
    62  */
       
    63 struct STRINGINFO
       
    64     {
       
    65     TBuf<KMaxWordLength> segmentString; 
       
    66     TBool isChinese;
       
    67     };
       
    68 
       
    69 /**
       
    70  * Factory function at first ordinal to create concrete object of MFindUtil
       
    71  *
       
    72  * @since S60 v3.2
       
    73  * @return Pointer to created MFindUtil object
       
    74  */  
       
    75 IMPORT_C MFindUtil* FindUtilFactoryFunctionL();
       
    76 
       
    77 /**
       
    78  *  CFindUtilChinese utils class
       
    79  *
       
    80  *  This class is Chinese find utils class. It handle Chinese variant find
       
    81  *  in PhoneBook, LandMark, Clock and so on.
       
    82  *
       
    83  *  @lib FindUtil.dll
       
    84  *  @since S60 v3.2
       
    85  */
       
    86 NONSHARABLE_CLASS(CFindUtilChinese) : public CFindUtilBase
       
    87     {
       
    88 public:
       
    89 
       
    90 // From MFindUtil
       
    91 
       
    92     /**
       
    93      * From MFindUtil
       
    94      * Match arithmetic for general search
       
    95      *
       
    96      * @since S60 v3.2
       
    97      * @param aContactsField Reference to the searching target
       
    98      * @param aWord Reference to text in find pane
       
    99      * @return ETrue for the text are matched; otherwise EFalse
       
   100      */
       
   101     virtual TBool Match(const TDesC& aContactsField, const TDesC& aWord);	
       
   102 
       
   103     /**
       
   104      * From MFindUtil
       
   105      * Match arithmetic for accurate search 
       
   106      *
       
   107      * @since S60 v3.2
       
   108      * @param aItemString Reference to the searching target
       
   109      * @param aWord Reference to text in find pane
       
   110      * @return ETrue for the text are matched; otherwise EFalse
       
   111      */
       
   112     virtual TBool MatchRefineL( const TDesC& aItemString, const TDesC &aSearchText);
       
   113     
       
   114     /**
       
   115      * From MFindUtil
       
   116      * Current input text is handled by this model 
       
   117      *
       
   118      * @since S60 v3.2
       
   119      * @param aWord Reference to text in find pane
       
   120      * @return ETrue for handling by this model; otherwise EFalse
       
   121      */
       
   122     virtual TBool IsWordValidForMatching(const TDesC& aWord);
       
   123 
       
   124         /**
       
   125          * From MFindUtil It tests a partial matching.
       
   126          * @since 5.0
       
   127          * @param aItemString is a field string
       
   128          * @param aSearchText is a search string
       
   129          * @param aNextChars is a reference to buffer where next possible characters are saved. 
       
   130          *        The HBufC buffer may be re-allocated by this method. 
       
   131          *        In that case the pointer reference is modified to point to the re-allocated object.                              
       
   132          * @return If aSearchText has been found in aItemString, 
       
   133          *         ETrue is returned.
       
   134          */
       
   135         TBool MatchAdaptiveRefineL( const TDesC& aItemString, 
       
   136         							const TDesC& aSearchText, 
       
   137         							HBufC*& aNextChars);
       
   138 									
       
   139     /**
       
   140      * From MFindUtil
       
   141      * Current input text is handled by this model 
       
   142      *
       
   143      * @since S60 v3.2.3
       
   144      * @param aItemString Reference to the searching target
       
   145      * @param aSearchText Reference to text in find pane
       
   146      * @param aPolicy Reference to identify the different match policy
       
   147      * @param aConverter Reference to the converter interface, with which the aSearchText
       
   148      *  will be converted into other kind of str, such numeric string according to
       
   149      *  the ITUT keyboard key map
       
   150      * @return ETrue for handling by this model; otherwise EFalse
       
   151      */
       
   152     virtual TBool MatchRefineL( const TDesC& aItemString, const TDesC& aSearchText, 
       
   153                                 TMatchPolicy aPolicy, MFindStringConverter* aConverter);									
       
   154 
       
   155 // From CFindUtilBase
       
   156 
       
   157     /**
       
   158      * From CFindUtilBase
       
   159      * Create ptiengine and initialize member data 
       
   160      *
       
   161      * @since S60 v3.2
       
   162      * @return none
       
   163      */
       
   164     virtual void OpenL();
       
   165     
       
   166     /**
       
   167      * From CFindUtilBase
       
   168      * Close ptiEngine 
       
   169      *
       
   170      * @since S60 v3.2
       
   171      * @return none
       
   172      */
       
   173     virtual void Close();
       
   174     
       
   175     /**
       
   176      * Symbian constructor
       
   177      *
       
   178      * @since S60 v3.2
       
   179      * @return Pointer to created CFindUtilChinese object
       
   180      */    
       
   181     static CFindUtilChinese* NewL();
       
   182     
       
   183 public:
       
   184 
       
   185     /**
       
   186      * C++ default constructor
       
   187      *
       
   188      * @since S60 v3.2
       
   189      * @return None
       
   190      */  
       
   191     CFindUtilChinese();
       
   192 
       
   193     /**
       
   194      * Destructor
       
   195      *
       
   196      * @since S60 v3.2
       
   197      * @return None
       
   198      */
       
   199     ~CFindUtilChinese();
       
   200 
       
   201 private:
       
   202 
       
   203     /**
       
   204      * Symbian second-phase constructor
       
   205      *
       
   206      * @since S60 v3.2
       
   207      * @return None
       
   208      */ 
       
   209     void ConstructL();
       
   210     
       
   211     /**
       
   212      * Open ptiengine and active it by input language
       
   213      *
       
   214      * @since S60 v3.2
       
   215      * @param aLanguage Actived language
       
   216      * @return ETrue for opening ptiengine successfully; otherwise EFalse
       
   217      */ 
       
   218     TBool OpenT9InterfaceL(TLanguage aLanguage);
       
   219 
       
   220     /**
       
   221      * Close ptiengine
       
   222      *
       
   223      * @since S60 v3.2
       
   224      * @return none
       
   225      */ 
       
   226     void CloseT9InterfaceL();
       
   227 
       
   228     /**
       
   229      * Translate Chinese word to its spelling
       
   230      *
       
   231      * @since S60 v3.2
       
   232      * @param aHZUnicode For translate word
       
   233      * @param aSpellList Reference to spelling list for polyphonic word
       
   234      * @return ETrue for this word can be translated; otherwise EFalse
       
   235      */ 
       
   236     TBool DoTranslationL(TInt16 aHZUnicode, RPointerArray<HBufC>& aSpellList);
       
   237 
       
   238     /**
       
   239      * This letter is stroke symbol
       
   240      *
       
   241      * @since S60 v3.2
       
   242      * @param aFindWord For analyse
       
   243      * @return ETrue for it is stroke symbol; otherwise EFalse
       
   244      */ 
       
   245     TInt IsStrokeSymbol(const TInt aFindWord);
       
   246 
       
   247     /**
       
   248      * Do translate for Chinese word
       
   249      *
       
   250      * @since S60 v3.2
       
   251      * @param aHZUnicode For translate word
       
   252      * @param aSpellList Reference to spelling list for polyphonic word
       
   253      * @return ETrue for it can be translated; otherwise EFalse
       
   254      */
       
   255     TBool T9ChineseTranslationL(TInt16 aHZUnicode, RPointerArray<HBufC>& aSpellList);
       
   256     
       
   257     /**
       
   258      * Do translate for Chinese word
       
   259      *
       
   260      * @since S60 v5.0.1
       
   261      * @param aHZUnicode For translate word
       
   262      * @param aSpellList Reference to spelling list for polyphonic word
       
   263      * @return ETrue for it can be translated; otherwise EFalse
       
   264      */
       
   265     TBool T9ChineseTranslationAdaptiveL(TInt16 aHZUnicode, RPointerArray<HBufC>& aSpellList);
       
   266 
       
   267     /**
       
   268      * Find pane text is including separator
       
   269      *
       
   270      * @since S60 v3.2
       
   271      * @param aCh Analyze word
       
   272      * @return ETrue it is separator; otherwise EFalse
       
   273      */
       
   274     TBool IsFindWordSeparator(TChar aCh);
       
   275 
       
   276     /**
       
   277      * Find pane text is including Chinese word
       
   278      *
       
   279      * @since S60 v3.2
       
   280      * @param aWord Reference to text for analyse
       
   281      * @return ETrue it includes Chinese; otherwise EFalse
       
   282      */
       
   283     TBool IsChineseWord(const TDesC& aWord);
       
   284     
       
   285     /**
       
   286      * Find pane text is just Chinese word
       
   287      * 
       
   288      * @param aWord Reference to text for analyse
       
   289      * @return ETrue it is a Chinese word; otherwise EFalse
       
   290      */
       
   291     TBool ChineseWord(const TDesC& aWord);
       
   292 
       
   293     /**
       
   294      * Find pane text is including stroke symbol
       
   295      *
       
   296      * @since S60 v3.2
       
   297      * @param aWord Reference to text for analyse
       
   298      * @return ETrue it is stroke symbol; otherwise EFalse
       
   299      */
       
   300     TBool IsStrokeSymbolInString(const TDesC& aWord);
       
   301 
       
   302     /**
       
   303      * Find pane text is including zhuyin symbol
       
   304      *
       
   305      * @since S60 v3.2
       
   306      * @param aWord Reference to text for analyse
       
   307      * @return ETrue it includes zhuyin symbol; otherwise EFalse
       
   308      */
       
   309     TBool IsZhuyinSymbolInString(const TDesC& aWord);
       
   310 
       
   311     /**
       
   312      * This language is support by this model
       
   313      *
       
   314      * @since S60 v3.2
       
   315      * @param aLang Language for support
       
   316      * @return ETrue it supports; otherwise EFalse
       
   317      */
       
   318     TBool IsSupportLanguage(TLanguage aLang);
       
   319     
       
   320     /**
       
   321      * Callback method to notify client about language change.
       
   322      *
       
   323      * @since S60 v3.2
       
   324      * @param aPtr Pointer to the callback data
       
   325      * @return Error code
       
   326      */
       
   327     static TInt HandleFindRepositoryCallBack(TAny* aPtr);
       
   328     
       
   329     /**
       
   330      * Splite the input text to sgement by language
       
   331      *
       
   332      * @since S60 v3.2
       
   333      * @param aStringInfoArr Reference to segment list
       
   334      * @param aItemString Reference to input text
       
   335      * @return none
       
   336      */
       
   337     void SplitItemStringL(RPointerArray<STRINGINFO>& aStringInfoArr, const TDesC &aItemString);
       
   338 
       
   339 
       
   340     /**
       
   341      * Insert segment to list
       
   342      *
       
   343      * @since S60 v3.2
       
   344      * @param aStringInfoArr Reference to segment list
       
   345      * @param aSegmentStr Reference to segment text
       
   346      * @param aChinese The segment is Chinese
       
   347      * @return none
       
   348      */
       
   349     void InsertStrInforArrayL(RPointerArray<STRINGINFO>& aStringInfoArr, TDes &aSegmentStr,
       
   350                               const TBool aChinese);
       
   351                               
       
   352     /**
       
   353      * This segment is matched by search text
       
   354      *
       
   355      * @since S60 v3.2
       
   356      * @param aStringInfoArr Reference to segment list
       
   357      * @param aSearchText Reference to searching text
       
   358      * @return ETrue it is matched; otherwise EFalse
       
   359      */
       
   360     TBool MatchSegmentL(RPointerArray<STRINGINFO>& aStringInfoArr, const TDesC &aSearchText);
       
   361 
       
   362     /**
       
   363      * Search text by reverse
       
   364      *
       
   365      * @since S60 v3.2
       
   366      * @param aFirst Reference to matched text
       
   367      * @param aSecond Reference to matched text
       
   368      * @return Matched count
       
   369      */
       
   370     TInt ReverseMatchString(const TDesC& aFirst, const TDesC& aSecond);
       
   371 
       
   372     /**
       
   373      * Search text in other text 
       
   374      *
       
   375      * @since S60 v3.2
       
   376      * @param aFirst Reference to matched text
       
   377      * @param aSecond Reference to matched text
       
   378      * @return Matched count
       
   379      */
       
   380     TInt MatchString(const TDesC& aFirst, const TDesC& aSecond);
       
   381 
       
   382     /**
       
   383      * Search Chinese word in input text 
       
   384      *
       
   385      * @since S60 v3.2
       
   386      * @param aFirst Reference to matched text
       
   387      * @param aSecond Reference to matched text
       
   388      * @return Matched count
       
   389      */
       
   390     TInt MatchChineseStringL(const TDesC& aFirst, const TDesC& aSecond, TInt& aIndex);
       
   391 
       
   392     /**
       
   393      * Initial character search 
       
   394      *
       
   395      * @since S60 v3.2
       
   396      * @param aStringInfoArr Reference to spelling list
       
   397      * @param aSearchStr Reference to search text
       
   398      * @return ETrue it is matched; otherwise EFalse
       
   399      */
       
   400     TBool MatchChineseInitialStringL(RPointerArray<STRINGINFO>& aStringInfoArr, 
       
   401                                      const TDesC& aSearchStr);
       
   402 
       
   403     /**
       
   404      * Maximal matched count in spelling list  
       
   405      *
       
   406      * @since S60 v3.2
       
   407      * @param spellList Reference to spelling list
       
   408      * @param aSearchStr Reference to search text
       
   409      * @param aPreviouStr Reference to previous matched word
       
   410      * @param aMatchIndex Reference to match index in Search text
       
   411      * @param aFullMatched Previous word is fully matched
       
   412      * @param aMatchedCount Previous word matched count
       
   413      * @param aAgain Search again
       
   414      * @return Matched count
       
   415      */
       
   416     TInt MaxMatchInList(RPointerArray<HBufC> &spellList, TDesC& aSearchStr, TDesC& aPreviouStr, 
       
   417                         TInt& aMatchIndex, const TBool aFullMatched, const TInt aMatchedCount, TBool& aAgain);
       
   418 
       
   419     /**
       
   420      * Search the taxt is include the input text 
       
   421      *
       
   422      * @since S60 v3.2
       
   423      * @param aFirst Reference to matched text
       
   424      * @param aSecond Reference to matched text
       
   425      * @return Matched count
       
   426      */
       
   427     TBool IncludeString(const TDesC& aFirst,  const TDesC& aSecond);    
       
   428 
       
   429     /**
       
   430      * Update input method in ptiengine from find pane
       
   431      *
       
   432      * @since S60 v3.2
       
   433      * @return none
       
   434      */
       
   435     void  UpdateCurrentInputMode();
       
   436 
       
   437     /**
       
   438      * Remove separator from search text
       
   439      *
       
   440      * @since S60 v3.2
       
   441      * @param aSearchText Reference to search text
       
   442      * @return none
       
   443      */
       
   444     void RemoveSeparator(TDes& aSearchText);    
       
   445     
       
   446      /**
       
   447      * From MFindUtil It return next char.
       
   448      * @since 5.0
       
   449      * @param aNextChars is a buffer where next possible characters are saved
       
   450      * @param aCh is a char need to be input to aNextChars
       
   451      * 
       
   452      */
       
   453     void UpdateNextCharsL(HBufC*& aNextChars, TChar aCh);
       
   454      /**
       
   455      * From MFindUtil It return next chars.
       
   456      * @since 5.0
       
   457      * @param aNextChars is a buffer where next possible characters are saved
       
   458      * @param aItemString is a Contact field string
       
   459      */
       
   460     void UpdateNextCharsFromStringL(HBufC*& aNextChars, const TDesC& aItemString);   
       
   461     
       
   462      /**
       
   463      * From MFindUtil It return next chars.
       
   464      * @since 5.0
       
   465      * @param aNextChars is a buffer where next possible characters are saved
       
   466      * @param aItemString is a Contact field string
       
   467      * @param aSearchText Reference to search text
       
   468      * @param aInputLang for the input language 
       
   469      */
       
   470     TBool IsAdaptiveFindMatchL( const TDesC& aItemString, const TDesC& aSearchText,
       
   471                                HBufC*& aNextChars);
       
   472                                
       
   473     
       
   474     /**
       
   475     * Trim chinese charater if it is exist in search text
       
   476     * @since 5.0
       
   477     * @Param aItemString is a contact field string
       
   478     * @param aSearchText is a search  text   
       
   479     * @param aNextChars is a buffer to store the charcaters needed to display.    
       
   480     */ 
       
   481     TBool TrimChineseCharacterL(TDes& aItemString, TDes& aSearchText,HBufC*& aNextChars);
       
   482 
       
   483     /**
       
   484        * Trim chinese charater if it is exist in search text
       
   485        * @since 5.0
       
   486        * @Param aarray is a contact field string which had to segments
       
   487        * @param aSearchText is a search  text
       
   488        * @param aNextChars is a buffer to store the charcaters needed to display.    
       
   489        */ 
       
   490     TBool CheckEnglishFirstL( RPointerArray<STRINGINFO>& aarray, TDes& aSearchText,HBufC*& aNextChars);
       
   491     
       
   492     /**
       
   493      * Trim chinese charater if it is exist in search text
       
   494      * @since 5.0
       
   495      * @Param AstringInfoArr is a contact field string which had to segments
       
   496      * @param aindex is the current find cursor
       
   497      * @param aNextChars is a buffer to store the charcaters needed to display.    
       
   498      */ 
       
   499     void AppendCharInNextSegmentL(const RPointerArray<STRINGINFO>& astringInfoArr ,
       
   500             const TInt aindex,HBufC*& aNextChars);
       
   501     
       
   502     /**
       
   503      * Trim chinese charater if it is exist in search text
       
   504      * @since 5.0
       
   505      * @Param AstringInfoArr is a contact field string which had to segments
       
   506      * @param aindex is the current find cursor
       
   507      * @paran aindexforfind is the temp cursor for find
       
   508      * @param aCurrentBuf the data in this segment
       
   509      * @param aTranSearchBuf is the left search data
       
   510      * @param aNextChars is a buffer to store the charcaters needed to display.    
       
   511      */ 
       
   512     
       
   513     TBool AppendNextSegmentFirstCharL(const RPointerArray<STRINGINFO>& astringInfoArr ,
       
   514             const TInt aindex ,const TInt aindexforfind ,
       
   515             const TDes& aCurrentBuf ,const TDes& aTranSearchBuf ,
       
   516             HBufC*& aNextChars);
       
   517     
       
   518     /**
       
   519          * Check and add next char if existed overlap problem (tang ang)
       
   520          * @since 5.0
       
   521          * @Param AstringInfoArr is a contact field string which had to segments
       
   522          * @param aindex is the current find cursor
       
   523          * @paran aindexforfind is the temp cursor for find
       
   524          * @param aCurrentBuf is the search string
       
   525          * @param aNextChars is a buffer to store the charcaters needed to display.    
       
   526          */ 
       
   527     void AddNextIfOverlapL(const RPointerArray<STRINGINFO>& astringInfoArr ,
       
   528                 const TInt aindex,const TInt aindexforfind ,
       
   529                 const TDes& aCurrentBuf,HBufC*& aNextChars );
       
   530 private:
       
   531 
       
   532     /**
       
   533      * Ptiengine for Chinese translation (Own)
       
   534      */
       
   535     CPtiEngine* iPtiEngine;
       
   536     
       
   537     /**
       
   538      * Ptiengine for Chinese translation in English language (Own)
       
   539      */    
       
   540     CPtiEngine* iPtiEnginePrc;
       
   541     
       
   542     /**
       
   543      * Current text input language 
       
   544      */    
       
   545     TLanguage iLanguage;
       
   546     
       
   547     /**
       
   548      * It is support Chinese Language
       
   549      */      
       
   550     TBool iSupportPRCChinese;
       
   551 
       
   552     /**
       
   553      * Current input mode
       
   554      */     
       
   555     TInt iCurInputMode;	
       
   556 
       
   557     /**
       
   558      * Repository for input mode (Own)
       
   559      */     
       
   560     CRepository* iRepositoryFind;	 
       
   561 
       
   562     /**
       
   563      * The repository watcher(Own);
       
   564      */
       
   565     CFindRepositoryWatcher* iWatcher;
       
   566     
       
   567    
       
   568         /**
       
   569      * Repository for input mode (Own)
       
   570      */     
       
   571     CRepository* iRepositoryFindAdaptive;	 
       
   572 
       
   573     /**
       
   574      * The repository watcher(Own);
       
   575      */
       
   576     CFindRepositoryWatcher* iWatcherAdaptive;
       
   577     
       
   578    
       
   579     /**
       
   580      * The default adaptive search method;
       
   581      */
       
   582     TDefaultAdaptiveSearchMethod iSearchMethodPRC;
       
   583     
       
   584     /**
       
   585      * The default adaptive search method;
       
   586      */
       
   587     TDefaultAdaptiveSearchMethod iSearchMethodTaiWan;
       
   588     
       
   589     /**
       
   590      * The default adaptive search method;
       
   591      */
       
   592     TDefaultAdaptiveSearchMethod iSearchMethodHongKong;
       
   593     
       
   594     
       
   595     /**
       
   596      * The search method;
       
   597      */
       
   598     TBool iSearchMethodAdaptive;
       
   599     
       
   600 	
       
   601 	/**
       
   602      * Numeric Converter interface (Not Own);
       
   603      */
       
   604     MFindStringConverter* iConverter;
       
   605     
       
   606     
       
   607     };
       
   608 
       
   609 #endif // __FINDUTILCHINESE__
       
   610 
       
   611 // End of File