calendarui/regionalplugins/calenregionalutil/src/calenextrarowformatter.cpp
changeset 55 2c54b51f39c4
parent 45 b6db4fd4947b
child 75 7ac58b2aae6f
equal deleted inserted replaced
51:0b38fc5b94c6 55:2c54b51f39c4
    21 #include <badesca.h> 
    21 #include <badesca.h> 
    22 #include <eikenv.h>
    22 #include <eikenv.h>
    23 
    23 
    24 #include "calendarui_debug.h"
    24 #include "calendarui_debug.h"
    25 #include "CalenExtraRowFormatter.h"
    25 #include "CalenExtraRowFormatter.h"
       
    26 #include "OstTraceDefinitions.h"
       
    27 #ifdef OST_TRACE_COMPILER_IN_USE
       
    28 #include "calenextrarowformatterTraces.h"
       
    29 #endif
    26 
    30 
    27 // Constants
    31 // Constants
    28 const TInt KZero( 0 );
    32 const TInt KZero( 0 );
    29 
    33 
    30 // -----------------------------------------------------------------------------
    34 // -----------------------------------------------------------------------------
    31 // CollapseDuplicatesL
    35 // CollapseDuplicatesL
    32 // -----------------------------------------------------------------------------
    36 // -----------------------------------------------------------------------------
    33 //
    37 //
    34 void CollapseDuplicatesL( TDes& aStr, TInt aPos, const TDesC& aSub )
    38 void CollapseDuplicatesL( TDes& aStr, TInt aPos, const TDesC& aSub )
    35     {
    39     {
    36     TRACE_ENTRY_POINT;
    40     OstTraceFunctionEntry0( _COLLAPSEDUPLICATESL_ENTRY );
    37     
       
    38     const TInt sublen = aSub.Length();
    41     const TInt sublen = aSub.Length();
    39     if (aStr.Length() == KZero || sublen == KZero || aPos < KZero || (aPos >aStr.Length()))
    42     if (aStr.Length() == KZero || sublen == KZero || aPos < KZero || (aPos >aStr.Length()))
    40         {
    43         {
       
    44         OstTraceFunctionExit0( _COLLAPSEDUPLICATESL_EXIT );
    41         return;
    45         return;
    42         }
    46         }
    43 
    47 
    44     TPtrC remaining = aStr.Mid( aPos );
    48     TPtrC remaining = aStr.Mid( aPos );
    45     TInt fstInRemaining = remaining.Find( aSub );
    49     TInt fstInRemaining = remaining.Find( aSub );
    68             CollapseDuplicatesL( aStr, snd, aSub );
    72             CollapseDuplicatesL( aStr, snd, aSub );
    69             }
    73             }
    70         // 3) No second substring found -> nothing to collapse
    74         // 3) No second substring found -> nothing to collapse
    71         else             
    75         else             
    72             {
    76             {
    73             TRACE_EXIT_POINT; 
    77             OstTraceFunctionExit0( DUP1__COLLAPSEDUPLICATESL_EXIT );
    74             return;
    78             return;
    75             }
    79             }
    76         }
    80         }
    77     // No substring found 
    81     // No substring found 
    78     else
    82     else
    79         {
    83         {
    80         TRACE_EXIT_POINT;
    84         OstTraceFunctionExit0( DUP2__COLLAPSEDUPLICATESL_EXIT );
    81         return;
    85         return;
    82         }
    86         }
       
    87     OstTraceFunctionExit0( DUP3__COLLAPSEDUPLICATESL_EXIT );
    83     }
    88     }
    84 
    89 
    85 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
    86 // RemoveLeadingAndTrailingL
    91 // RemoveLeadingAndTrailingL
    87 // -----------------------------------------------------------------------------
    92 // -----------------------------------------------------------------------------
    88 //
    93 //
    89 void RemoveLeadingAndTrailingL( TDes& aStr, const TDesC& aSub )
    94 void RemoveLeadingAndTrailingL( TDes& aStr, const TDesC& aSub )
    90     {
    95     {
    91     TRACE_ENTRY_POINT;
    96     OstTraceFunctionEntry0( _REMOVELEADINGANDTRAILINGL_ENTRY );
    92     
       
    93     // Trailing
    97     // Trailing
    94     const TInt sublen = aSub.Length();
    98     const TInt sublen = aSub.Length();
    95     if ( aStr.Right( sublen ).Find( aSub ) == KZero )
    99     if ( aStr.Right( sublen ).Find( aSub ) == KZero )
    96         {
   100         {
    97         aStr.Replace( aStr.Length() - sublen, sublen, KNullDesC );
   101         aStr.Replace( aStr.Length() - sublen, sublen, KNullDesC );
   101     if ( aStr.Left( sublen ).Find( aSub ) == KZero )
   105     if ( aStr.Left( sublen ).Find( aSub ) == KZero )
   102         {
   106         {
   103         aStr.Replace( KZero, sublen, KNullDesC );
   107         aStr.Replace( KZero, sublen, KNullDesC );
   104         }
   108         }
   105         
   109         
   106     TRACE_EXIT_POINT;
   110     OstTraceFunctionExit0( _REMOVELEADINGANDTRAILINGL_EXIT );
   107     }
   111     }
   108 
   112 
   109 // -----------------------------------------------------------------------------
   113 // -----------------------------------------------------------------------------
   110 // CCalenExtraRowFormatter::NewL
   114 // CCalenExtraRowFormatter::NewL
   111 // -----------------------------------------------------------------------------
   115 // -----------------------------------------------------------------------------
   112 //
   116 //
   113 EXPORT_C CCalenExtraRowFormatter* CCalenExtraRowFormatter::NewL()
   117 EXPORT_C CCalenExtraRowFormatter* CCalenExtraRowFormatter::NewL()
   114     {
   118     {
   115     TRACE_ENTRY_POINT;
   119     OstTraceFunctionEntry0( CCALENEXTRAROWFORMATTER_NEWL_ENTRY );
   116     
       
   117     CCalenExtraRowFormatter* self = new (ELeave) CCalenExtraRowFormatter;
   120     CCalenExtraRowFormatter* self = new (ELeave) CCalenExtraRowFormatter;
   118     CleanupStack::PushL(self);
   121     CleanupStack::PushL(self);
   119     self->ConstructL();
   122     self->ConstructL();
   120     CleanupStack::Pop(self);
   123     CleanupStack::Pop(self);
   121     
   124     
   122     TRACE_EXIT_POINT;
   125     OstTraceFunctionExit0( CCALENEXTRAROWFORMATTER_NEWL_EXIT );
   123     return self;
   126     return self;
   124     }
   127     }
   125 
   128 
   126 // -----------------------------------------------------------------------------
   129 // -----------------------------------------------------------------------------
   127 // CCalenExtraRowFormatter::~CCalenExtraRowFormatter
   130 // CCalenExtraRowFormatter::~CCalenExtraRowFormatter
   128 // -----------------------------------------------------------------------------
   131 // -----------------------------------------------------------------------------
   129 //
   132 //
   130 EXPORT_C CCalenExtraRowFormatter::~CCalenExtraRowFormatter()
   133 EXPORT_C CCalenExtraRowFormatter::~CCalenExtraRowFormatter()
   131     {
   134     {
   132     TRACE_ENTRY_POINT;
   135     OstTraceFunctionEntry0( CCALENEXTRAROWFORMATTER_CCALENEXTRAROWFORMATTER_ENTRY );
   133     TRACE_EXIT_POINT;
   136     OstTraceFunctionExit0( CCALENEXTRAROWFORMATTER_CCALENEXTRAROWFORMATTER_EXIT );
   134     }
   137     }
   135 
   138 
   136 // -----------------------------------------------------------------------------
   139 // -----------------------------------------------------------------------------
   137 // CCalenExtraRowFormatter::CCalenExtraRowFormatter
   140 // CCalenExtraRowFormatter::CCalenExtraRowFormatter
   138 // -----------------------------------------------------------------------------
   141 // -----------------------------------------------------------------------------
   139 //
   142 //
   140 CCalenExtraRowFormatter::CCalenExtraRowFormatter()
   143 CCalenExtraRowFormatter::CCalenExtraRowFormatter()
   141     {
   144     {
   142     TRACE_ENTRY_POINT;
   145     OstTraceFunctionEntry0( DUP1_CCALENEXTRAROWFORMATTER_CCALENEXTRAROWFORMATTER_ENTRY );
   143     TRACE_EXIT_POINT;
   146     OstTraceFunctionExit0( DUP1_CCALENEXTRAROWFORMATTER_CCALENEXTRAROWFORMATTER_EXIT );
   144     }
   147     }
   145 
   148 
   146 // -----------------------------------------------------------------------------
   149 // -----------------------------------------------------------------------------
   147 // CCalenExtraRowFormatter::ConstructL
   150 // CCalenExtraRowFormatter::ConstructL
   148 // -----------------------------------------------------------------------------
   151 // -----------------------------------------------------------------------------
   149 //
   152 //
   150 void CCalenExtraRowFormatter::ConstructL()
   153 void CCalenExtraRowFormatter::ConstructL()
   151     {
   154     {
   152     TRACE_ENTRY_POINT;
   155     OstTraceFunctionEntry0( CCALENEXTRAROWFORMATTER_CONSTRUCTL_ENTRY );
   153     TRACE_EXIT_POINT;
   156     OstTraceFunctionExit0( CCALENEXTRAROWFORMATTER_CONSTRUCTL_EXIT );
   154     }
   157     }
   155 
   158 
   156 
   159 
   157 // -----------------------------------------------------------------------------
   160 // -----------------------------------------------------------------------------
   158 // CCalenExtraRowFormatter::FormatExtraRowInformationL
   161 // CCalenExtraRowFormatter::FormatExtraRowInformationL
   160 //
   163 //
   161 EXPORT_C TPtrC CCalenExtraRowFormatter::FormatExtraRowInformationL( 
   164 EXPORT_C TPtrC CCalenExtraRowFormatter::FormatExtraRowInformationL( 
   162     CCalenLunarLocalizedInfo& aLocInfo, 
   165     CCalenLunarLocalizedInfo& aLocInfo, 
   163     RArray<CCalenLunarLocalizedInfo::TField>& aPrioritizedFields )
   166     RArray<CCalenLunarLocalizedInfo::TField>& aPrioritizedFields )
   164 {
   167 {
   165 	TRACE_ENTRY_POINT;
   168 	OstTraceFunctionEntry0( CCALENEXTRAROWFORMATTER_FORMATEXTRAROWINFORMATIONL_ENTRY );
   166 
       
   167 
       
   168 	if ( aPrioritizedFields.Count() == KZero)
   169 	if ( aPrioritizedFields.Count() == KZero)
   169 	{
   170 	{
   170 		iText = KNullDesC;
   171 		iText = KNullDesC;
   171 
   172 
   172 		TRACE_EXIT_POINT;
   173 		OstTraceFunctionExit0( CCALENEXTRAROWFORMATTER_FORMATEXTRAROWINFORMATIONL_EXIT );
   173 		return iText;
   174 		return iText;
   174 	}
   175 	}
   175 
   176 
   176 	// Initialize substring labels
   177 	// Initialize substring labels
   177 	RArray<CCalenLunarLocalizedInfo::TField> subLabels;
   178 	RArray<CCalenLunarLocalizedInfo::TField> subLabels;
   245 	RemoveLeadingAndTrailingL( iText, textBuf );
   246 	RemoveLeadingAndTrailingL( iText, textBuf );
   246 	
   247 	
   247 	// CleanUp
   248 	// CleanUp
   248 	CleanupStack::PopAndDestroy( subs );
   249 	CleanupStack::PopAndDestroy( subs );
   249 	CleanupStack::PopAndDestroy( &subLabels );
   250 	CleanupStack::PopAndDestroy( &subLabels );
   250 	TRACE_EXIT_POINT;
   251 	
   251 	
   252 	OstTraceFunctionExit0( DUP1_CCALENEXTRAROWFORMATTER_FORMATEXTRAROWINFORMATIONL_EXIT );
   252 	return iText;
   253 	return iText;
   253 }
   254 }
   254 
   255 
   255 //EOF
   256 //EOF
   256 
   257