diff -r 96907930389d -r 12af337248b1 calendarui/regionalplugins/calenregionalutil/src/calenlunarlocalizer.cpp --- a/calendarui/regionalplugins/calenregionalutil/src/calenlunarlocalizer.cpp Thu Aug 19 09:53:43 2010 +0300 +++ b/calendarui/regionalplugins/calenregionalutil/src/calenlunarlocalizer.cpp Tue Aug 31 15:13:43 2010 +0300 @@ -16,22 +16,27 @@ */ + +#include +#include +#include +#include + +#include +#include +#include +#include + #include "calendarui_debug.h" -#include "calenlunarlocalizer.h" - -#include "calenlunarinfo.h" -#include "calenlunarlocalizedinfo.h" -#include "calenextrarowformatter.h" -#include - -#include -#include -#include -#include -#include -#include -#include +#include "CalenLunarLocalizer.h" +#include "CalenLunarInfo.h" +#include "CalenLunarLocalizedInfo.h" +#include "CalenExtraRowFormatter.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "calenlunarlocalizerTraces.h" +#endif //CONSTANTS const TInt KCharMonth = 0x6708; @@ -42,8 +47,6 @@ _LIT(KChineseDigits, "\x0030\x4e00\x4e8c\x4e09\x56db\x4e94\x516d\x4e03\x516b\x4e5d"); -_LIT( KResourceChinesePluginFile, "calenregionalutil.rsc" ); -#define KResourcePath KDC_RESOURCE_FILES_DIR // ----------------------------------------------------------------------------- @@ -52,14 +55,13 @@ // EXPORT_C CCalenLunarLocalizer* CCalenLunarLocalizer::NewL() { - TRACE_ENTRY_POINT; - + OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_NEWL_ENTRY ); CCalenLunarLocalizer* self = new (ELeave) CCalenLunarLocalizer; CleanupStack::PushL(self); self->ConstructL(); CleanupStack::Pop(self); - TRACE_EXIT_POINT; + OstTraceFunctionExit0( CCALENLUNARLOCALIZER_NEWL_EXIT ); return self; } @@ -69,22 +71,9 @@ // EXPORT_C CCalenLunarLocalizer::~CCalenLunarLocalizer() { - TRACE_ENTRY_POINT; - - delete iFestivalNames; - delete iSolarTermNames; - delete iHeavenlyStemNames; - delete iTerrestialBranchNames; - delete iAnimalYearNames; - delete iGregorianDateFormat; + OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_CCALENLUNARLOCALIZER_ENTRY ); delete iRowFormatter; - - if( iResourceFileOffset ) - { - CCoeEnv::Static()->DeleteResourceFile( iResourceFileOffset ); - } - - TRACE_EXIT_POINT; + OstTraceFunctionExit0( CCALENLUNARLOCALIZER_CCALENLUNARLOCALIZER_EXIT ); } // ----------------------------------------------------------------------------- @@ -93,8 +82,8 @@ // EXPORT_C CCalenLunarLocalizer::CCalenLunarLocalizer() : iEikEnv( CEikonEnv::Static() ) { - TRACE_ENTRY_POINT; - TRACE_EXIT_POINT; + OstTraceFunctionEntry0( DUP1_CCALENLUNARLOCALIZER_CCALENLUNARLOCALIZER_ENTRY ); + OstTraceFunctionExit0( DUP1_CCALENLUNARLOCALIZER_CCALENLUNARLOCALIZER_EXIT ); } // ----------------------------------------------------------------------------- @@ -102,129 +91,147 @@ // ----------------------------------------------------------------------------- // EXPORT_C void CCalenLunarLocalizer::ConstructL() - { - TRACE_ENTRY_POINT; - iRowFormatter = CCalenExtraRowFormatter::NewL(); - - TFileName dllName; - // Get the complate path of the DLL from where it is currently loaded - Dll::FileName( dllName ); - - TFileName resourceFilename; - resourceFilename.Append(dllName.Mid(0,2)); - resourceFilename.Append(KResourcePath); - resourceFilename.Append(KResourceChinesePluginFile); - BaflUtils::NearestLanguageFile( CEikonEnv::Static()->FsSession(), resourceFilename ); - // Add the resource file. - iResourceFileOffset = CEikonEnv::Static()->AddResourceFileL( resourceFilename ); - +{ + OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_CONSTRUCTL_ENTRY ); + iRowFormatter = CCalenExtraRowFormatter::NewL(); + + iFestivalNames.append(hbTrId("txt_calendar_preview_title_spring_fest")); + iFestivalNames.append(hbTrId("txt_calendar_preview_title_lantern_fest")); + iFestivalNames.append(hbTrId("txt_calendar_preview_title_dragon_fest")); + iFestivalNames.append(hbTrId("txt_calendar_preview_title_seventh_night_fest")); + iFestivalNames.append(hbTrId("txt_calendar_preview_title_ghost_fest")); + iFestivalNames.append(hbTrId("txt_calendar_preview_title_mid_autumn_fest")); + iFestivalNames.append(hbTrId("txt_calendar_preview_title_double_fest")); + iFestivalNames.append(hbTrId("txt_calendar_preview_title_eigth_day_fest")); + iFestivalNames.append(hbTrId("txt_calendar_preview_title_new_year_fest")); + + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_li_chun")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_yu_shui")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_jing_zhe")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_chun_fen")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_qing_ming")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_gu_yu")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_li_xia")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_xiao_man")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_mang_zhong")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_xia_zhi")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_xiao_shu")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_da_shu")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_li_qiu")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_chu_shu")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_bai_lu")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_qiu_fen")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_han_lu")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_shaung_jiang")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_li_dong")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_xiao_xue")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_da_xue")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_dong_zhi")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_xiao_han")); + iSolarTermNames.append(hbTrId("txt_calendar_preview_title_da_han")); - iFestivalNames = iEikEnv->ReadDesCArrayResourceL(R_CALEN_CHI_FESTIVALS); - iSolarTermNames = iEikEnv->ReadDesCArrayResourceL(R_CALEN_CHI_SOLAR_ITEMS); - iHeavenlyStemNames = iEikEnv->ReadDesCArrayResourceL(R_CALEN_CHI_HEAV_STEMS); - iTerrestialBranchNames = iEikEnv->ReadDesCArrayResourceL(R_CALEN_CHI_TERR_BRANCHES); - iAnimalYearNames = iEikEnv->ReadDesCArrayResourceL(R_CALEN_CHI_ANIMAL_YEARS); - - iGregorianDateFormat = StringLoader::LoadL(R_QTN_DATE_USUAL_WITH_ZERO); - + iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_jia")); + iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_yi")); + iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_bing")); + iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_ding")); + iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_wu")); + iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_ji")); + iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_geng")); + iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_xing")); + iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_reng")); + iHeavenlyStemNames.append(hbTrId("txt_calendar_preview_title_gui")); -#ifdef _DEBUG - // Validate assumptions - TInt maxStem = -1; - for (TInt i = 0; i < iHeavenlyStemNames->Count(); i++) - { - maxStem = Max( maxStem, iHeavenlyStemNames->MdcaPoint(i).Length() ); - } - - TInt maxBranch = -1; - for (TInt i = 0; i < iTerrestialBranchNames->MdcaPoint(i).Length() ; i++) - { - maxBranch = Max( maxBranch, iTerrestialBranchNames->MdcaPoint(i).Length() ); - } - ASSERT( maxStem + maxBranch <= 100); -#endif - - TRACE_EXIT_POINT; - } + iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_zi")); + iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_chou")); + iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_yin")); + iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_mao")); + iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_chen")); + iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_si")); + iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_wu")); + iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_wei")); + iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_shen")); + iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_you")); + iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_xu")); + iTerrestialBranchNames.append(hbTrId("txt_calendar_preview_title_tbranch_hai")); + + iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_rat")); + iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_ox")); + iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_tiger")); + iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_rabbit")); + iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_dragon")); + iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_snake")); + iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_horse")); + iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_sheep")); + iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_monkey")); + iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_rooster")); + iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_dog")); + iAnimalYearNames.append(hbTrId("txt_calendar_preview_title_year_of_the_pig")); + + OstTraceFunctionExit0( CCALENLUNARLOCALIZER_CONSTRUCTL_EXIT ); +} // ----------------------------------------------------------------------------- // CCalenLunarLocalizer::LocalizeL // ----------------------------------------------------------------------------- // EXPORT_C CCalenLunarLocalizedInfo* CCalenLunarLocalizer::LocalizeL( TCalenLunarInfo& aInfo ) - { - TRACE_ENTRY_POINT; - - - CCalenLunarLocalizedInfo* localized = CCalenLunarLocalizedInfo::NewL(); - CleanupStack::PushL( localized ); +{ + OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_LOCALIZEL_ENTRY ); + CCalenLunarLocalizedInfo* localized = CCalenLunarLocalizedInfo::NewL(); + CleanupStack::PushL( localized ); + - if ( aInfo.HasFestival() ) - { - localized->iFestival.Set( iFestivalNames->MdcaPoint( aInfo.iFestival ) ); - } - - if ( aInfo.HasSolarTerm() ) - { - localized->iSolarTerm.Set( iSolarTermNames->MdcaPoint( aInfo.iSolarTerm ) ); - } + if ( aInfo.HasFestival() ) + { + QString festival = iFestivalNames.at(aInfo.iFestival); + localized->iFestival.Set( static_cast(festival.utf16()),festival.length()); + } - // Animal year - localized->iAnimalYear.Set( iAnimalYearNames->MdcaPoint( aInfo.AnimalYear() ) ); - + if ( aInfo.HasSolarTerm() ) + { + QString solarTerm = iSolarTermNames.at(aInfo.iSolarTerm); + localized->iSolarTerm.Set( static_cast(solarTerm.utf16()),solarTerm.length()); + } - // Lunar year - CPtrCArray* yearSubs = new (ELeave) CPtrCArray(2); - CleanupStack::PushL( yearSubs ); - yearSubs->AppendL( iHeavenlyStemNames->MdcaPoint( aInfo.iHeavenlyStem ) ); - yearSubs->AppendL( iTerrestialBranchNames->MdcaPoint( aInfo.iTerrestialBranch ) ); + // Animal year + QString animalYear = iAnimalYearNames.at(aInfo.AnimalYear()); + localized->iAnimalYear.Set( static_cast(animalYear.utf16()),animalYear.length()); - HBufC* tmp = StringLoader::LoadLC( R_CALE_LUNAR_YEAR, *yearSubs, iEikEnv ); -#ifdef _DEBUG - RDebug::Print( *tmp ); -#endif - localized->iLunarYear = *tmp; - CleanupStack::PopAndDestroy( tmp ); - CleanupStack::PopAndDestroy( yearSubs ); + // Lunar year + QString heavenlyStemNames = iHeavenlyStemNames.at(aInfo.iHeavenlyStem); + QString terrestialBranchNames = iTerrestialBranchNames.at(aInfo.iTerrestialBranch); + QString lunarYear = hbTrId("txt_calendar_info_lunar_year").arg(heavenlyStemNames).arg(terrestialBranchNames); + localized->iLunarYear = static_cast (lunarYear.utf16()), lunarYear.length(); + + LocalizeMonthAndDayL(localized, aInfo); -#ifdef _DEBUG - RDebug::Print( localized->iLunarYear ); -#endif - - LocalizeMonthAndDayL(localized, aInfo); - - // Full lunar date - CPtrCArray* subs = new (ELeave) CPtrCArray(2); - CleanupStack::PushL( subs ); - subs->AppendL( localized->LunarMonthAndDay() ); - subs->AppendL( localized->LunarYear() ); - - tmp = StringLoader::LoadLC( R_CALE_LUNAR_FULL_DATE, *subs ); - localized->iFullLunarDate = *tmp; - CleanupStack::PopAndDestroy( tmp ); - CleanupStack::PopAndDestroy( subs ); - - - aInfo.iGregorianDate.FormatL( localized->iGregorianDate, - *iGregorianDateFormat ); - CleanupStack::Pop( localized ); - - - - TRACE_EXIT_POINT; - return localized; - } + QString monthAndDay = QString::fromUtf16(localized->LunarMonthAndDay().Ptr(),localized->LunarMonthAndDay().Length()); + QString yearString = QString::fromUtf16(localized->LunarYear().Ptr(),localized->LunarYear().Length()); + QString fullLunarDate = hbTrId("txt_calendar_info_lunar_full_date").arg(monthAndDay).arg(yearString); + + localized->iFullLunarDate = static_cast (fullLunarDate.utf16()), fullLunarDate.length(); + + QString format(r_qtn_date_usual_with_zero); + TBuf<100> gregFormatBuf; + gregFormatBuf = static_cast (format.utf16()), format.length(); + + aInfo.iGregorianDate.FormatL( localized->iGregorianDate, gregFormatBuf ); + + CleanupStack::Pop( localized ); + + OstTraceFunctionExit0( CCALENLUNARLOCALIZER_LOCALIZEL_EXIT ); + return localized; +} // ----------------------------------------------------------------------------- // CCalenLunarLocalizer::GetExtraRowTextL // ----------------------------------------------------------------------------- // -EXPORT_C TPtrC CCalenLunarLocalizer::GetExtraRowTextL( CCalenLunarLocalizedInfo& aLocInfo, TInt aMaxWidth, - const CFont& aFont, TBool aTwoLines ) +EXPORT_C TPtrC CCalenLunarLocalizer::GetExtraRowTextL( + CCalenLunarLocalizedInfo& aLocInfo ) { - TRACE_ENTRY_POINT; - + OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_GETEXTRAROWTEXTL_ENTRY ); RArray fields; CleanupClosePushL( fields ); fields.AppendL( CCalenLunarLocalizedInfo::EFestival ); @@ -233,15 +240,10 @@ fields.AppendL( CCalenLunarLocalizedInfo::EAnimalYear ); fields.AppendL( CCalenLunarLocalizedInfo::ELunarYear ); - TPtrC text = iRowFormatter->FormatExtraRowInformationL( aLocInfo, fields, aMaxWidth, aFont - - , aTwoLines + TPtrC text = iRowFormatter->FormatExtraRowInformationL( aLocInfo, fields ); + CleanupStack::PopAndDestroy( &fields ); - ); - CleanupStack::PopAndDestroy( &fields ); - - - TRACE_EXIT_POINT; + OstTraceFunctionExit0( CCALENLUNARLOCALIZER_GETEXTRAROWTEXTL_EXIT ); return text; } @@ -251,24 +253,29 @@ // void CCalenLunarLocalizer::LocalizeMonthAndDayL(CCalenLunarLocalizedInfo* aLocInfo, TCalenLunarInfo& aInfo) - { - // Lunar Month and Day - TInt dateResource = aInfo.iLunarDate.iLeapMonth ? R_CALE_LUNAR_LEAP_DATE : R_CALE_LUNAR_DATE; - TBuf<10> month; - TBuf<10> day; - GetChineseMonth(aInfo.iLunarDate, month); - GetChineseDay(aInfo.iLunarDate, day); +{ + OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_LOCALIZEMONTHANDDAYL_ENTRY ); + TBuf<10> month; + TBuf<10> day; + GetChineseMonth(aInfo.iLunarDate, month); + GetChineseDay(aInfo.iLunarDate, day); - CPtrCArray* monthAndDaySubs = new (ELeave) CPtrCArray(2); - CleanupStack::PushL( monthAndDaySubs ); - monthAndDaySubs->AppendL(month); - monthAndDaySubs->AppendL(day); - - HBufC* tmp = StringLoader::LoadLC( dateResource, *monthAndDaySubs ); - aLocInfo->iLunarMonthAndDay = *tmp; - CleanupStack::PopAndDestroy( tmp ); - CleanupStack::PopAndDestroy( monthAndDaySubs ); - } + QString formattedString; + if(aInfo.iLunarDate.iLeapMonth) { + formattedString = hbTrId( + "txt_calendar_info_lunar_leap_date").arg( + QString((QChar*)month.Ptr(),month.Length())).arg( + QString((QChar*)day.Ptr(),day.Length())); + }else { + formattedString = hbTrId( + "txt_calendar_info_lunar_date").arg( + QString((QChar*)month.Ptr(),month.Length())).arg( + QString((QChar*)day.Ptr(),day.Length())); + } + aLocInfo->iLunarMonthAndDay = static_cast ( + formattedString.utf16()), formattedString.length(); + OstTraceFunctionExit0( CCALENLUNARLOCALIZER_LOCALIZEMONTHANDDAYL_EXIT ); +} // ----------------------------------------------------------------------------- // CCalenLunarLocalizer::GetChineseMonth @@ -277,8 +284,7 @@ void CCalenLunarLocalizer::GetChineseMonth(const TChineseDate& aChineseDate, TDes& aDes) { - TRACE_ENTRY_POINT; - + OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_GETCHINESEMONTH_ENTRY ); if (aChineseDate.iMonth == 1) { aDes.Append(KCharFirstMonth); // Special character for first month @@ -289,8 +295,7 @@ } aDes.Append(KCharMonth); - - TRACE_EXIT_POINT; + OstTraceFunctionExit0( CCALENLUNARLOCALIZER_GETCHINESEMONTH_EXIT ); } // ----------------------------------------------------------------------------- @@ -300,16 +305,14 @@ void CCalenLunarLocalizer::GetChineseDay(const TChineseDate& aChineseDate, TDes& aDes) { - TRACE_ENTRY_POINT; - + OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_GETCHINESEDAY_ENTRY ); if (aChineseDate.iDay <= 10) // day { aDes.Append(KCharChu); } GetChineseDigits(aChineseDate.iDay, aDes); - - TRACE_EXIT_POINT; + OstTraceFunctionExit0( CCALENLUNARLOCALIZER_GETCHINESEDAY_EXIT ); } // ----------------------------------------------------------------------------- @@ -318,8 +321,7 @@ // void CCalenLunarLocalizer::GetChineseDigits(TInt aNum, TDes& aDes) { - TRACE_ENTRY_POINT; - + OstTraceFunctionEntry0( CCALENLUNARLOCALIZER_GETCHINESEDIGITS_ENTRY ); ASSERT( 0 < aNum && aNum <= 30 ); TInt tens = aNum / 10; TInt ones = aNum % 10; @@ -355,8 +357,7 @@ { __ASSERT_DEBUG(EFalse, User::Invariant()); } - - TRACE_EXIT_POINT; + OstTraceFunctionExit0( CCALENLUNARLOCALIZER_GETCHINESEDIGITS_EXIT ); } //EOF