calendarui/regionalplugins/calenregionalutil/src/calenlunarlocalizer.cpp
branchRCL_3
changeset 30 bd7edf625bdd
parent 29 12af337248b1
equal deleted inserted replaced
29:12af337248b1 30:bd7edf625bdd
    14 * Description:   Calendar Lunar Plugin 
    14 * Description:   Calendar Lunar Plugin 
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 
    19 #include "calendarui_debug.h"
    20 #include <qdatetime.h>
    20 
    21 #include <qstringlist.h>
    21 #include "calenlunarlocalizer.h"
    22 #include <hbi18ndef.h>
    22 
    23 #include <hbglobal.h>
    23 #include "calenlunarinfo.h"
    24 
    24 #include "calenlunarlocalizedinfo.h"
       
    25 #include "calenextrarowformatter.h"
       
    26 #include <calenregionalutil.rsg>
       
    27 
       
    28 #include <AknBidiTextUtils.h>
       
    29 #include <avkon.rsg>
    25 #include <badesca.h> 
    30 #include <badesca.h> 
    26 #include <eikenv.h>
    31 #include <eikenv.h>
       
    32 #include <StringLoader.h>
    27 #include <bautils.h>
    33 #include <bautils.h>
    28 #include <data_caging_path_literals.hrh>
    34 #include <data_caging_path_literals.hrh>
    29 
       
    30 #include "calendarui_debug.h"
       
    31 
       
    32 #include "CalenLunarLocalizer.h"
       
    33 #include "CalenLunarInfo.h"
       
    34 #include "CalenLunarLocalizedInfo.h"
       
    35 #include "CalenExtraRowFormatter.h"
       
    36 #include "OstTraceDefinitions.h"
       
    37 #ifdef OST_TRACE_COMPILER_IN_USE
       
    38 #include "calenlunarlocalizerTraces.h"
       
    39 #endif
       
    40 
    35 
    41 //CONSTANTS
    36 //CONSTANTS
    42 const TInt KCharMonth = 0x6708;
    37 const TInt KCharMonth = 0x6708;
    43 const TInt KCharFirstMonth = 0x6b63;
    38 const TInt KCharFirstMonth = 0x6b63;
    44 const TInt KCharChu = 0x521d;
    39 const TInt KCharChu = 0x521d;
    45 const TInt KCharTen = 0x5341;
    40 const TInt KCharTen = 0x5341;
    46 const TInt KCharTwenty= 0x5eff;
    41 const TInt KCharTwenty= 0x5eff;
    47 _LIT(KChineseDigits, 
    42 _LIT(KChineseDigits, 
    48      "\x0030\x4e00\x4e8c\x4e09\x56db\x4e94\x516d\x4e03\x516b\x4e5d");
    43      "\x0030\x4e00\x4e8c\x4e09\x56db\x4e94\x516d\x4e03\x516b\x4e5d");
    49 
    44 
       
    45 _LIT( KResourceChinesePluginFile, "calenregionalutil.rsc" );
       
    46 #define KResourcePath KDC_RESOURCE_FILES_DIR
    50 
    47 
    51 
    48 
    52 // -----------------------------------------------------------------------------
    49 // -----------------------------------------------------------------------------
    53 // CCalenLunarLocalizer::NewL
    50 // CCalenLunarLocalizer::NewL
    54 // -----------------------------------------------------------------------------
    51 // -----------------------------------------------------------------------------
    55 //
    52 //
    56 EXPORT_C CCalenLunarLocalizer* CCalenLunarLocalizer::NewL()
    53 EXPORT_C CCalenLunarLocalizer* CCalenLunarLocalizer::NewL()
    57     {
    54     {
    58     OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_NEWL_ENTRY );
    55     TRACE_ENTRY_POINT;
       
    56     
    59     CCalenLunarLocalizer* self = new (ELeave) CCalenLunarLocalizer;
    57     CCalenLunarLocalizer* self = new (ELeave) CCalenLunarLocalizer;
    60     CleanupStack::PushL(self);
    58     CleanupStack::PushL(self);
    61     self->ConstructL();
    59     self->ConstructL();
    62     CleanupStack::Pop(self);
    60     CleanupStack::Pop(self);
    63     
    61     
    64     OstTraceFunctionExit0( CCALENLUNARLOCALIZER_NEWL_EXIT );
    62     TRACE_EXIT_POINT;
    65     return self;
    63     return self;
    66     }
    64     }
    67 
    65 
    68 // -----------------------------------------------------------------------------
    66 // -----------------------------------------------------------------------------
    69 // CCalenLunarLocalizer::~CCalenLunarLocalizer
    67 // CCalenLunarLocalizer::~CCalenLunarLocalizer
    70 // -----------------------------------------------------------------------------
    68 // -----------------------------------------------------------------------------
    71 //
    69 //
    72 EXPORT_C CCalenLunarLocalizer::~CCalenLunarLocalizer()
    70 EXPORT_C CCalenLunarLocalizer::~CCalenLunarLocalizer()
    73     {
    71     {
    74     OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_CCALENLUNARLOCALIZER_ENTRY );
    72     TRACE_ENTRY_POINT;
       
    73     
       
    74     delete iFestivalNames;
       
    75     delete iSolarTermNames;
       
    76     delete iHeavenlyStemNames;
       
    77     delete iTerrestialBranchNames;
       
    78     delete iAnimalYearNames;
       
    79     delete iGregorianDateFormat;
    75     delete iRowFormatter;
    80     delete iRowFormatter;
    76     OstTraceFunctionExit0( CCALENLUNARLOCALIZER_CCALENLUNARLOCALIZER_EXIT );
    81     
       
    82     if( iResourceFileOffset )
       
    83         {
       
    84         CCoeEnv::Static()->DeleteResourceFile( iResourceFileOffset );
       
    85         }
       
    86     
       
    87     TRACE_EXIT_POINT;
    77     }
    88     }
    78 
    89 
    79 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
    80 // CCalenLunarLocalizer::CCalenLunarLocalizer
    91 // CCalenLunarLocalizer::CCalenLunarLocalizer
    81 // -----------------------------------------------------------------------------
    92 // -----------------------------------------------------------------------------
    82 //
    93 //
    83 EXPORT_C CCalenLunarLocalizer::CCalenLunarLocalizer() : iEikEnv( CEikonEnv::Static() )
    94 EXPORT_C CCalenLunarLocalizer::CCalenLunarLocalizer() : iEikEnv( CEikonEnv::Static() )
    84     {
    95     {
    85     OstTraceFunctionEntry0( DUP1_CCALENLUNARLOCALIZER_CCALENLUNARLOCALIZER_ENTRY );
    96     TRACE_ENTRY_POINT;
    86     OstTraceFunctionExit0( DUP1_CCALENLUNARLOCALIZER_CCALENLUNARLOCALIZER_EXIT );
    97     TRACE_EXIT_POINT;
    87     }
    98     }
    88 
    99 
    89 // -----------------------------------------------------------------------------
   100 // -----------------------------------------------------------------------------
    90 // CCalenLunarLocalizer::ConstructL
   101 // CCalenLunarLocalizer::ConstructL
    91 // -----------------------------------------------------------------------------
   102 // -----------------------------------------------------------------------------
    92 //
   103 //
    93 EXPORT_C void CCalenLunarLocalizer::ConstructL()
   104 EXPORT_C void CCalenLunarLocalizer::ConstructL()
    94 {
   105     {
    95 	OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_CONSTRUCTL_ENTRY );
   106     TRACE_ENTRY_POINT;
    96 	iRowFormatter = CCalenExtraRowFormatter::NewL();
   107     iRowFormatter = CCalenExtraRowFormatter::NewL();
    97 
   108     
    98 	iFestivalNames.append(hbTrId("txt_calendar_preview_title_spring_fest"));
   109     TFileName dllName;
    99 	iFestivalNames.append(hbTrId("txt_calendar_preview_title_lantern_fest"));
   110     // Get the complate path of the DLL from where it is currently loaded
   100 	iFestivalNames.append(hbTrId("txt_calendar_preview_title_dragon_fest"));
   111     Dll::FileName( dllName );
   101 	iFestivalNames.append(hbTrId("txt_calendar_preview_title_seventh_night_fest"));
   112     
   102 	iFestivalNames.append(hbTrId("txt_calendar_preview_title_ghost_fest"));
   113     TFileName resourceFilename;
   103 	iFestivalNames.append(hbTrId("txt_calendar_preview_title_mid_autumn_fest"));
   114     resourceFilename.Append(dllName.Mid(0,2));
   104 	iFestivalNames.append(hbTrId("txt_calendar_preview_title_double_fest"));
   115     resourceFilename.Append(KResourcePath);
   105 	iFestivalNames.append(hbTrId("txt_calendar_preview_title_eigth_day_fest"));
   116     resourceFilename.Append(KResourceChinesePluginFile);
   106 	iFestivalNames.append(hbTrId("txt_calendar_preview_title_new_year_fest"));
   117     BaflUtils::NearestLanguageFile( CEikonEnv::Static()->FsSession(), resourceFilename );
   107 
   118     // Add the resource file.
   108 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_li_chun"));
   119     iResourceFileOffset = CEikonEnv::Static()->AddResourceFileL( resourceFilename );
   109 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_yu_shui"));
   120     
   110 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_jing_zhe"));
   121 
   111 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_chun_fen"));
   122     iFestivalNames = iEikEnv->ReadDesCArrayResourceL(R_CALEN_CHI_FESTIVALS);
   112 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_qing_ming"));
   123     iSolarTermNames = iEikEnv->ReadDesCArrayResourceL(R_CALEN_CHI_SOLAR_ITEMS);
   113 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_gu_yu"));
   124     iHeavenlyStemNames = iEikEnv->ReadDesCArrayResourceL(R_CALEN_CHI_HEAV_STEMS);
   114 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_li_xia"));
   125     iTerrestialBranchNames = iEikEnv->ReadDesCArrayResourceL(R_CALEN_CHI_TERR_BRANCHES);
   115 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_xiao_man"));
   126     iAnimalYearNames = iEikEnv->ReadDesCArrayResourceL(R_CALEN_CHI_ANIMAL_YEARS);
   116 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_mang_zhong"));
   127 
   117 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_xia_zhi"));
   128     iGregorianDateFormat = StringLoader::LoadL(R_QTN_DATE_USUAL_WITH_ZERO);
   118 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_xiao_shu"));
   129 
   119 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_da_shu"));
   130 
   120 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_li_qiu"));
   131 #ifdef _DEBUG
   121 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_chu_shu"));
   132     // Validate assumptions
   122 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_bai_lu"));
   133     TInt maxStem = -1;
   123 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_qiu_fen"));
   134     for (TInt i = 0; i < iHeavenlyStemNames->Count(); i++)
   124 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_han_lu"));
   135         {
   125 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_shaung_jiang"));
   136         maxStem = Max( maxStem, iHeavenlyStemNames->MdcaPoint(i).Length() );
   126 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_li_dong"));
   137         }
   127 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_xiao_xue"));
   138     
   128 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_da_xue"));
   139     TInt maxBranch = -1;
   129 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_dong_zhi"));
   140     for (TInt i = 0; i < iTerrestialBranchNames->MdcaPoint(i).Length() ; i++)
   130 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_xiao_han"));
   141         {
   131 	iSolarTermNames.append(hbTrId("txt_calendar_preview_title_da_han"));
   142         maxBranch = Max( maxBranch, iTerrestialBranchNames->MdcaPoint(i).Length() );        
   132 
   143         }
   133 	iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_jia"));
   144     ASSERT( maxStem + maxBranch <= 100);
   134 	iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_yi"));
   145 #endif
   135 	iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_bing"));
   146     
   136 	iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_ding"));
   147     TRACE_EXIT_POINT;
   137 	iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_wu"));
   148     }
   138 	iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_ji"));
       
   139 	iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_geng"));
       
   140 	iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_xing"));
       
   141 	iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_reng"));
       
   142 	iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_gui"));
       
   143 
       
   144 	iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_zi"));
       
   145 	iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_chou"));
       
   146 	iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_yin"));
       
   147 	iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_mao"));
       
   148 	iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_chen"));
       
   149 	iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_si"));
       
   150 	iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_wu"));
       
   151 	iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_wei"));
       
   152 	iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_shen"));
       
   153 	iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_you"));
       
   154 	iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_xu"));
       
   155 	iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_hai"));
       
   156 
       
   157 	iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_rat"));
       
   158 	iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_ox"));
       
   159 	iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_tiger"));
       
   160 	iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_rabbit"));
       
   161 	iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_dragon"));
       
   162 	iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_snake"));
       
   163 	iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_horse"));
       
   164 	iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_sheep"));
       
   165 	iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_monkey"));
       
   166 	iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_rooster"));
       
   167 	iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_dog"));
       
   168 	iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_pig"));
       
   169 	
       
   170 	OstTraceFunctionExit0( CCALENLUNARLOCALIZER_CONSTRUCTL_EXIT );
       
   171 }
       
   172 
   149 
   173 // -----------------------------------------------------------------------------
   150 // -----------------------------------------------------------------------------
   174 // CCalenLunarLocalizer::LocalizeL
   151 // CCalenLunarLocalizer::LocalizeL
   175 // -----------------------------------------------------------------------------
   152 // -----------------------------------------------------------------------------
   176 //
   153 //
   177 EXPORT_C CCalenLunarLocalizedInfo* CCalenLunarLocalizer::LocalizeL( TCalenLunarInfo& aInfo )
   154 EXPORT_C CCalenLunarLocalizedInfo* CCalenLunarLocalizer::LocalizeL( TCalenLunarInfo& aInfo )
   178 {
   155     {
   179 	OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_LOCALIZEL_ENTRY );
   156     TRACE_ENTRY_POINT;
   180 	CCalenLunarLocalizedInfo* localized = CCalenLunarLocalizedInfo::NewL();
   157    
   181 	CleanupStack::PushL( localized );
   158     
   182 
   159     CCalenLunarLocalizedInfo* localized = CCalenLunarLocalizedInfo::NewL();
   183 
   160     CleanupStack::PushL( localized );
   184 	if ( aInfo.HasFestival() ) 
   161 
   185 	{
   162     if ( aInfo.HasFestival() ) 
   186 		QString festival = iFestivalNames.at(aInfo.iFestival);
   163         {
   187 		localized->iFestival.Set( static_cast<const TUint16*>(festival.utf16()),festival.length());
   164         localized->iFestival.Set( iFestivalNames->MdcaPoint( aInfo.iFestival ) );
   188 	}
   165         }
   189 
   166     
   190 	if ( aInfo.HasSolarTerm() ) 
   167     if ( aInfo.HasSolarTerm() ) 
   191 	{
   168         {
   192 		QString solarTerm = iSolarTermNames.at(aInfo.iSolarTerm);
   169         localized->iSolarTerm.Set( iSolarTermNames->MdcaPoint( aInfo.iSolarTerm ) );
   193 		localized->iSolarTerm.Set( static_cast<const TUint16*>(solarTerm.utf16()),solarTerm.length());
   170         }
   194 	}
   171 
   195 
   172     // Animal year
   196 	// Animal year
   173     localized->iAnimalYear.Set( iAnimalYearNames->MdcaPoint( aInfo.AnimalYear() ) );
   197 	QString animalYear = iAnimalYearNames.at(aInfo.AnimalYear());
   174     
   198 	localized->iAnimalYear.Set( static_cast<const TUint16*>(animalYear.utf16()),animalYear.length());
   175 
   199 
   176     // Lunar year    
   200 	// Lunar year
   177     CPtrCArray* yearSubs = new (ELeave) CPtrCArray(2);
   201 	QString heavenlyStemNames = iHeavenlyStemNames.at(aInfo.iHeavenlyStem);
   178     CleanupStack::PushL( yearSubs );
   202 	QString terrestialBranchNames = iTerrestialBranchNames.at(aInfo.iTerrestialBranch);
   179     yearSubs->AppendL( iHeavenlyStemNames->MdcaPoint( aInfo.iHeavenlyStem ) );
   203 	QString lunarYear = hbTrId("txt_calendar_info_lunar_year").arg(heavenlyStemNames).arg(terrestialBranchNames);
   180     yearSubs->AppendL( iTerrestialBranchNames->MdcaPoint( aInfo.iTerrestialBranch ) );
   204 	localized->iLunarYear = static_cast<const TUint16*> (lunarYear.utf16()), lunarYear.length();
   181 
   205 
   182     HBufC* tmp = StringLoader::LoadLC( R_CALE_LUNAR_YEAR, *yearSubs, iEikEnv );
   206 	LocalizeMonthAndDayL(localized, aInfo);
   183 #ifdef _DEBUG
   207 
   184     RDebug::Print( *tmp );
   208 	QString monthAndDay = QString::fromUtf16(localized->LunarMonthAndDay().Ptr(),localized->LunarMonthAndDay().Length());
   185 #endif
   209 	QString yearString = QString::fromUtf16(localized->LunarYear().Ptr(),localized->LunarYear().Length());
   186     localized->iLunarYear = *tmp;
   210 	QString fullLunarDate = hbTrId("txt_calendar_info_lunar_full_date").arg(monthAndDay).arg(yearString);
   187     CleanupStack::PopAndDestroy( tmp );
   211 	
   188     CleanupStack::PopAndDestroy( yearSubs );
   212 	localized->iFullLunarDate = static_cast<const TUint16*> (fullLunarDate.utf16()), fullLunarDate.length();
   189 
   213 
   190 #ifdef _DEBUG
   214 	QString format(r_qtn_date_usual_with_zero);
   191     RDebug::Print(     localized->iLunarYear  );
   215 	TBuf<100> gregFormatBuf;
   192 #endif
   216 	gregFormatBuf = static_cast<const TUint16*> (format.utf16()), format.length();
   193     
   217 	
   194     LocalizeMonthAndDayL(localized, aInfo);
   218 	aInfo.iGregorianDate.FormatL( localized->iGregorianDate, gregFormatBuf );
   195     
   219 
   196     // Full lunar date
   220 	CleanupStack::Pop( localized );
   197     CPtrCArray* subs = new (ELeave) CPtrCArray(2);
   221 	
   198     CleanupStack::PushL( subs );
   222 	OstTraceFunctionExit0( CCALENLUNARLOCALIZER_LOCALIZEL_EXIT );
   199     subs->AppendL( localized->LunarMonthAndDay() );
   223 	return localized;
   200     subs->AppendL( localized->LunarYear() );
   224 }
   201     
       
   202     tmp = StringLoader::LoadLC( R_CALE_LUNAR_FULL_DATE, *subs );
       
   203     localized->iFullLunarDate = *tmp;
       
   204     CleanupStack::PopAndDestroy( tmp );
       
   205     CleanupStack::PopAndDestroy( subs );
       
   206     
       
   207     
       
   208     aInfo.iGregorianDate.FormatL( localized->iGregorianDate, 
       
   209                                  *iGregorianDateFormat );
       
   210     CleanupStack::Pop( localized );
       
   211     
       
   212     
       
   213     
       
   214     TRACE_EXIT_POINT;
       
   215     return localized;
       
   216     }
   225 
   217 
   226 
   218 
   227 // -----------------------------------------------------------------------------
   219 // -----------------------------------------------------------------------------
   228 // CCalenLunarLocalizer::GetExtraRowTextL
   220 // CCalenLunarLocalizer::GetExtraRowTextL
   229 // -----------------------------------------------------------------------------
   221 // -----------------------------------------------------------------------------
   230 //
   222 //
   231 EXPORT_C TPtrC CCalenLunarLocalizer::GetExtraRowTextL( 
   223 EXPORT_C TPtrC CCalenLunarLocalizer::GetExtraRowTextL( CCalenLunarLocalizedInfo& aLocInfo, TInt aMaxWidth, 
   232 											CCalenLunarLocalizedInfo& aLocInfo )
   224                                               const CFont& aFont, TBool aTwoLines )
   233     {
   225     {
   234     OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_GETEXTRAROWTEXTL_ENTRY );
   226     TRACE_ENTRY_POINT;
       
   227     
   235     RArray<CCalenLunarLocalizedInfo::TField> fields;
   228     RArray<CCalenLunarLocalizedInfo::TField> fields;
   236     CleanupClosePushL( fields );
   229     CleanupClosePushL( fields );
   237     fields.AppendL( CCalenLunarLocalizedInfo::EFestival );
   230     fields.AppendL( CCalenLunarLocalizedInfo::EFestival );
   238     fields.AppendL( CCalenLunarLocalizedInfo::ESolarTerm );
   231     fields.AppendL( CCalenLunarLocalizedInfo::ESolarTerm );
   239     fields.AppendL( CCalenLunarLocalizedInfo::ELunarMonthAndDay );
   232     fields.AppendL( CCalenLunarLocalizedInfo::ELunarMonthAndDay );
   240     fields.AppendL( CCalenLunarLocalizedInfo::EAnimalYear );
   233     fields.AppendL( CCalenLunarLocalizedInfo::EAnimalYear );
   241     fields.AppendL( CCalenLunarLocalizedInfo::ELunarYear );
   234     fields.AppendL( CCalenLunarLocalizedInfo::ELunarYear );
   242     
   235     
   243     TPtrC text = iRowFormatter->FormatExtraRowInformationL( aLocInfo, fields );
   236     TPtrC text = iRowFormatter->FormatExtraRowInformationL( aLocInfo, fields, aMaxWidth, aFont
       
   237 
       
   238                                                             , aTwoLines 
       
   239 
       
   240                                                             );
   244     CleanupStack::PopAndDestroy( &fields );
   241     CleanupStack::PopAndDestroy( &fields );
   245 
   242     
   246     OstTraceFunctionExit0( CCALENLUNARLOCALIZER_GETEXTRAROWTEXTL_EXIT );
   243     
       
   244     TRACE_EXIT_POINT;
   247     return text;
   245     return text;
   248     }
   246     }
   249 
   247 
   250 // -----------------------------------------------------------------------------
   248 // -----------------------------------------------------------------------------
   251 // CCalenLunarLocalizer::LocalizeMonthAndDayL
   249 // CCalenLunarLocalizer::LocalizeMonthAndDayL
   252 // -----------------------------------------------------------------------------
   250 // -----------------------------------------------------------------------------
   253 //
   251 //
   254 void CCalenLunarLocalizer::LocalizeMonthAndDayL(CCalenLunarLocalizedInfo* aLocInfo,
   252 void CCalenLunarLocalizer::LocalizeMonthAndDayL(CCalenLunarLocalizedInfo* aLocInfo,
   255                                                 TCalenLunarInfo& aInfo)
   253                                                 TCalenLunarInfo& aInfo)
   256 {
   254     {
   257 	OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_LOCALIZEMONTHANDDAYL_ENTRY );
   255     // Lunar Month and Day
   258 	TBuf<10> month;
   256     TInt dateResource = aInfo.iLunarDate.iLeapMonth ? R_CALE_LUNAR_LEAP_DATE : R_CALE_LUNAR_DATE;
   259 	TBuf<10> day;
   257     TBuf<10> month;
   260 	GetChineseMonth(aInfo.iLunarDate, month);
   258     TBuf<10> day;
   261 	GetChineseDay(aInfo.iLunarDate, day);
   259     GetChineseMonth(aInfo.iLunarDate, month);
   262 
   260     GetChineseDay(aInfo.iLunarDate, day);
   263 	QString formattedString;
   261 
   264 	if(aInfo.iLunarDate.iLeapMonth) {
   262     CPtrCArray* monthAndDaySubs = new (ELeave) CPtrCArray(2);
   265 		formattedString = hbTrId(
   263     CleanupStack::PushL( monthAndDaySubs );
   266 						"txt_calendar_info_lunar_leap_date").arg(
   264     monthAndDaySubs->AppendL(month);
   267 						QString((QChar*)month.Ptr(),month.Length())).arg(
   265     monthAndDaySubs->AppendL(day);
   268 						QString((QChar*)day.Ptr(),day.Length()));
   266     
   269 	}else {
   267     HBufC* tmp = StringLoader::LoadLC( dateResource, *monthAndDaySubs );
   270 		formattedString = hbTrId(
   268     aLocInfo->iLunarMonthAndDay = *tmp;
   271 						"txt_calendar_info_lunar_date").arg(
   269     CleanupStack::PopAndDestroy( tmp );
   272 						QString((QChar*)month.Ptr(),month.Length())).arg(
   270     CleanupStack::PopAndDestroy( monthAndDaySubs );
   273 						QString((QChar*)day.Ptr(),day.Length()));
   271     }
   274 	}
       
   275 	aLocInfo->iLunarMonthAndDay = static_cast<const TUint16*> (
       
   276 							formattedString.utf16()), formattedString.length();
       
   277 	OstTraceFunctionExit0( CCALENLUNARLOCALIZER_LOCALIZEMONTHANDDAYL_EXIT );
       
   278 }
       
   279 
   272 
   280 // -----------------------------------------------------------------------------
   273 // -----------------------------------------------------------------------------
   281 // CCalenLunarLocalizer::GetChineseMonth
   274 // CCalenLunarLocalizer::GetChineseMonth
   282 // -----------------------------------------------------------------------------
   275 // -----------------------------------------------------------------------------
   283 //
   276 //
   284 void CCalenLunarLocalizer::GetChineseMonth(const TChineseDate& aChineseDate,
   277 void CCalenLunarLocalizer::GetChineseMonth(const TChineseDate& aChineseDate,
   285                                            TDes& aDes)
   278                                            TDes& aDes)
   286     {
   279     {
   287     OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_GETCHINESEMONTH_ENTRY );
   280     TRACE_ENTRY_POINT;
       
   281 
   288     if (aChineseDate.iMonth == 1)
   282     if (aChineseDate.iMonth == 1)
   289         {
   283         {
   290         aDes.Append(KCharFirstMonth); // Special character for first month
   284         aDes.Append(KCharFirstMonth); // Special character for first month
   291         }
   285         }
   292     else
   286     else
   293         {
   287         {
   294         GetChineseDigits(aChineseDate.iMonth, aDes);
   288         GetChineseDigits(aChineseDate.iMonth, aDes);
   295         }
   289         }
   296     
   290     
   297     aDes.Append(KCharMonth);
   291     aDes.Append(KCharMonth);
   298     OstTraceFunctionExit0( CCALENLUNARLOCALIZER_GETCHINESEMONTH_EXIT );
   292     
       
   293     TRACE_EXIT_POINT;
   299     }
   294     }
   300     
   295     
   301 // -----------------------------------------------------------------------------
   296 // -----------------------------------------------------------------------------
   302 // CCalenLunarLocalizer::GetChineseDay
   297 // CCalenLunarLocalizer::GetChineseDay
   303 // -----------------------------------------------------------------------------
   298 // -----------------------------------------------------------------------------
   304 //
   299 //
   305 void CCalenLunarLocalizer::GetChineseDay(const TChineseDate& aChineseDate,
   300 void CCalenLunarLocalizer::GetChineseDay(const TChineseDate& aChineseDate,
   306                                          TDes& aDes)
   301                                          TDes& aDes)
   307     {
   302     {
   308     OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_GETCHINESEDAY_ENTRY );
   303     TRACE_ENTRY_POINT;
       
   304     
   309     if (aChineseDate.iDay <= 10) // day
   305     if (aChineseDate.iDay <= 10) // day
   310         {
   306         {
   311         aDes.Append(KCharChu); 
   307         aDes.Append(KCharChu); 
   312         }
   308         }
   313     
   309     
   314     GetChineseDigits(aChineseDate.iDay, aDes);
   310     GetChineseDigits(aChineseDate.iDay, aDes);
   315     OstTraceFunctionExit0( CCALENLUNARLOCALIZER_GETCHINESEDAY_EXIT );
   311     
       
   312     TRACE_EXIT_POINT;
   316     }
   313     }
   317 
   314 
   318 // -----------------------------------------------------------------------------
   315 // -----------------------------------------------------------------------------
   319 // CCalenLunarLocalizer::GetChineseDigits
   316 // CCalenLunarLocalizer::GetChineseDigits
   320 // -----------------------------------------------------------------------------
   317 // -----------------------------------------------------------------------------
   321 //
   318 //
   322 void CCalenLunarLocalizer::GetChineseDigits(TInt aNum, TDes& aDes)
   319 void CCalenLunarLocalizer::GetChineseDigits(TInt aNum, TDes& aDes)
   323     {
   320     {
   324     OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_GETCHINESEDIGITS_ENTRY );
   321     TRACE_ENTRY_POINT;
       
   322     
   325     ASSERT( 0 < aNum && aNum <= 30 );
   323     ASSERT( 0 < aNum && aNum <= 30 );
   326     TInt tens = aNum / 10;
   324     TInt tens = aNum / 10;
   327     TInt ones = aNum % 10;
   325     TInt ones = aNum % 10;
   328     if (aNum < 10) 
   326     if (aNum < 10) 
   329         {
   327         {
   355         }
   353         }
   356     else 
   354     else 
   357         {
   355         {
   358         __ASSERT_DEBUG(EFalse, User::Invariant());
   356         __ASSERT_DEBUG(EFalse, User::Invariant());
   359         }
   357         }
   360     OstTraceFunctionExit0( CCALENLUNARLOCALIZER_GETCHINESEDIGITS_EXIT );
   358     
       
   359     TRACE_EXIT_POINT;
   361     }
   360     }
   362 
   361 
   363 //EOF
   362 //EOF
   364 
   363 
   365 
   364