calendarui/regionalplugins/calenregionalutil/src/calenextrarowformatter.cpp
branchRCL_3
changeset 5 42814f902fe6
parent 0 f979ecb2b13e
child 65 12af337248b1
equal deleted inserted replaced
0:f979ecb2b13e 5:42814f902fe6
   208             {
   208             {
   209             CCalenLunarLocalizedInfo::TField field = aPrioritizedFields[i];        
   209             CCalenLunarLocalizedInfo::TField field = aPrioritizedFields[i];        
   210             TInt subIx = subLabels.Find( field );
   210             TInt subIx = subLabels.Find( field );
   211             // Replace 
   211             // Replace 
   212             subs->Delete(subIx);
   212             subs->Delete(subIx);
   213             RDebug::Print( _L("A sub count  %d"), subs->Count() );                       
   213 #ifdef _DEBUG
       
   214             RDebug::Print( _L("A sub count  %d"), subs->Count() );         
       
   215 #endif
   214             subs->InsertL(subIx, TPtrC( aLocInfo.GetField( field ) ) );
   216             subs->InsertL(subIx, TPtrC( aLocInfo.GetField( field ) ) );
       
   217 #ifdef _DEBUG
   215             RDebug::Print( _L("B sub count %d"), subs->Count() );                       
   218             RDebug::Print( _L("B sub count %d"), subs->Count() );                       
   216             RDebug::Print( _L("B field %S"), &(subs->At(subIx)) );                       
   219             RDebug::Print( _L("B field %S"), &(subs->At(subIx)) );
       
   220 #endif
   217             
   221             
   218             }
   222             }
   219         
   223         
   220         // Format all fields to extra row     
   224         // Format all fields to extra row     
   221         HBufC* extraRowFmt = StringLoader::LoadLC( R_CALE_EXTRA_ROW_LUNAR );
   225         HBufC* extraRowFmt = StringLoader::LoadLC( R_CALE_EXTRA_ROW_LUNAR );
   222         
   226         
       
   227 #ifdef _DEBUG
   223         RDebug::RawPrint( *extraRowFmt );
   228         RDebug::RawPrint( *extraRowFmt );
       
   229 #endif
   224         
   230         
   225         TBuf<1000> fmt = *extraRowFmt;
   231         TBuf<1000> fmt = *extraRowFmt;
   226         for (TInt i=0; i < subLabels.Count(); i++)
   232         for (TInt i=0; i < subLabels.Count(); i++)
   227             {
   233             {
       
   234 #ifdef _DEBUG
   228             RDebug::Print( _L("Before Format") );
   235             RDebug::Print( _L("Before Format") );
   229             RDebug::RawPrint( fmt );
   236             RDebug::RawPrint( fmt );
       
   237 #endif
   230             StringLoader::Format( iText, 
   238             StringLoader::Format( iText, 
   231                                   fmt,
   239                                   fmt,
   232                                   i + 1, // %0U is a separator 
   240                                   i + 1, // %0U is a separator 
   233                                   subs->At( i ) );
   241                                   subs->At( i ) );
   234             fmt = iText;
   242             fmt = iText;
       
   243 #ifdef _DEBUG
   235             RDebug::Print( _L("After Format") );
   244             RDebug::Print( _L("After Format") );
   236             RDebug::RawPrint( fmt );
   245             RDebug::RawPrint( fmt );
       
   246 #endif
   237             }
   247             }
   238         
   248         
   239         // Now we have something like "Year of Dog%0U%0U6/11%0U%0U" 
   249         // Now we have something like "Year of Dog%0U%0U6/11%0U%0U" 
   240         // First We need to remove multiple occurences of %0U
   250         // First We need to remove multiple occurences of %0U
   241         _LIT(KSeparatorFmt, "%0U");
   251         _LIT(KSeparatorFmt, "%0U");
   242         
   252         
   243         CollapseDuplicatesL( iText, 0, KSeparatorFmt );
   253         CollapseDuplicatesL( iText, 0, KSeparatorFmt );
       
   254 #ifdef _DEBUG
   244         RDebug::Print( _L("After collapse") );
   255         RDebug::Print( _L("After collapse") );
   245         RDebug::RawPrint( iText );
   256         RDebug::RawPrint( iText );
       
   257 #endif
   246 
   258 
   247         // Remove leading and trailing %0U
   259         // Remove leading and trailing %0U
   248         // By now, we are sure that there is max 1 %0U in the beginning
   260         // By now, we are sure that there is max 1 %0U in the beginning
   249         // and in the end of string.
   261         // and in the end of string.
   250         RemoveLeadingAndTrailingL( iText, KSeparatorFmt );
   262         RemoveLeadingAndTrailingL( iText, KSeparatorFmt );
       
   263 #ifdef _DEBUG
   251         RDebug::Print( _L("After leading and trailing removal") );
   264         RDebug::Print( _L("After leading and trailing removal") );
   252         RDebug::RawPrint( iText );
   265         RDebug::RawPrint( iText );
       
   266 #endif
   253         
   267         
   254 
   268 
   255         // If there are now separators anymore, then do not fill them
   269         // If there are now separators anymore, then do not fill them
   256         TBool hasSeparators = iText.Find( KSeparatorFmt ) >= 0;
   270         TBool hasSeparators = iText.Find( KSeparatorFmt ) >= 0;
   257         
   271         
   264             StringLoader::Format( iText, 
   278             StringLoader::Format( iText, 
   265                                   fmt,
   279                                   fmt,
   266                                   0, // %0U is a separator 
   280                                   0, // %0U is a separator 
   267                                   *separator );
   281                                   *separator );
   268         
   282         
       
   283 #ifdef _DEBUG
   269             RDebug::Print( _L("After separator insert") );
   284             RDebug::Print( _L("After separator insert") );
   270             RDebug::RawPrint( iText );
   285             RDebug::RawPrint( iText );
       
   286 #endif
   271             CleanupStack::PopAndDestroy( separator );
   287             CleanupStack::PopAndDestroy( separator );
   272             }
   288             }
   273 
   289 
   274 
   290 
   275         CleanupStack::PopAndDestroy( extraRowFmt );
   291         CleanupStack::PopAndDestroy( extraRowFmt );