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