apengine/apsettingshandlerui/src/TextOverrides.cpp
changeset 0 5a93021fdf25
child 66 ed07dcc72692
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *     Declares the CTextOverrides class.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "TextOverrides.h"
       
    22 #include <ApSettingsHandlerCommons.h>
       
    23 #include "ApSettingsHandlerLogger.h"
       
    24 
       
    25 // CLASS DECLARATION
       
    26 
       
    27 // ================= MEMBER FUNCTIONS =======================
       
    28 
       
    29 // ---------------------------------------------------------
       
    30 // CTextOverrides::NewL
       
    31 // ---------------------------------------------------------
       
    32 //
       
    33 CTextOverrides* CTextOverrides::NewL( )
       
    34     {
       
    35     APSETUILOGGER_ENTERFN( EOther,"TxtOverride::NewL")
       
    36     
       
    37     CTextOverrides* db = new( ELeave ) CTextOverrides();
       
    38     CleanupStack::PushL( db );
       
    39     db->ConstructL( );
       
    40     CleanupStack::Pop(); // db
       
    41     
       
    42     APSETUILOGGER_LEAVEFN( EOther,"TxtOverride::NewL")
       
    43     return db;
       
    44     }
       
    45 
       
    46 
       
    47 
       
    48 // Destructor
       
    49 CTextOverrides::~CTextOverrides()
       
    50     {
       
    51     APSETUILOGGER_ENTERFN( EOther,"TxtOverride::~CTextOverrides")
       
    52     
       
    53     if ( iTxtArray )
       
    54         {
       
    55         iTxtArray->ResetAndDestroy();
       
    56         }
       
    57     delete iTxtArray;
       
    58     
       
    59     APSETUILOGGER_LEAVEFN( EOther,"TxtOverride::~CTextOverrides")
       
    60     }
       
    61 
       
    62 
       
    63 // Constructor
       
    64 CTextOverrides::CTextOverrides()
       
    65     {
       
    66     }
       
    67 
       
    68 
       
    69 // ---------------------------------------------------------
       
    70 // CTextOverrides::ConstructL
       
    71 // ---------------------------------------------------------
       
    72 //
       
    73 void CTextOverrides::ConstructL( )
       
    74     {
       
    75     APSETUILOGGER_ENTERFN( EOther,"TxtOverride::ConstructL")
       
    76     
       
    77     iTxtArray = new( ELeave ) CArrayPtrFlat<HBufC>( KTxtOverrideGran );
       
    78     for (TInt i=0; i<=KTTextIdMax; i++ )
       
    79         {
       
    80         iTxtArray->AppendL( NULL);
       
    81         }
       
    82     
       
    83     APSETUILOGGER_LEAVEFN( EOther,"TxtOverride::ConstructL")
       
    84     }
       
    85 
       
    86 
       
    87 // ---------------------------------------------------------
       
    88 // CTextOverrides::SetTextOverridesL
       
    89 // ---------------------------------------------------------
       
    90 //
       
    91 void CTextOverrides::SetTextOverrideL( TTextID aText2Change,
       
    92                                                 const TDesC& aNewText )
       
    93     {
       
    94     APSETUILOGGER_ENTERFN( EOther,"TxtOverride::SetTextOverrideL")
       
    95     
       
    96     ValidateIdL( aText2Change );
       
    97 
       
    98     HBufC* a = aNewText.AllocL();
       
    99     iTxtArray->Delete( aText2Change );
       
   100     iTxtArray->InsertL( aText2Change, a );
       
   101 
       
   102     APSETUILOGGER_LEAVEFN( EOther,"TxtOverride::SetTextOverrideL")
       
   103     }
       
   104 
       
   105 
       
   106 // ---------------------------------------------------------
       
   107 // CTextOverrides::TextOverridesL
       
   108 // ---------------------------------------------------------
       
   109 //
       
   110 const TDesC& CTextOverrides::TextOverrideL( TTextID aTextId )
       
   111     {
       
   112     APSETUILOGGER_ENTERFN( EOther,"TxtOverride::TextOverrideL")
       
   113     
       
   114     ValidateIdL( aTextId );
       
   115     if ( !IsTextOverridenL( aTextId ) )
       
   116         {
       
   117         User::Leave( KTxtNotOverriden );
       
   118         }
       
   119     
       
   120     APSETUILOGGER_LEAVEFN( EOther,"TxtOverride::TextOverrideL")
       
   121     return *iTxtArray->At( aTextId );
       
   122     }
       
   123 
       
   124 
       
   125 // ---------------------------------------------------------
       
   126 // CTextOverrides::IsTextOverridenL
       
   127 // ---------------------------------------------------------
       
   128 //
       
   129 TBool CTextOverrides::IsTextOverridenL( TTextID aTextId )
       
   130     {
       
   131     APSETUILOGGER_ENTERFN( EOther,"TxtOverride::IsTextOverridenL")
       
   132     
       
   133     TBool retval( EFalse );
       
   134     ValidateIdL( aTextId );
       
   135     if ( iTxtArray->At( aTextId ) )
       
   136         {
       
   137         retval = ETrue;
       
   138         }
       
   139     else
       
   140         {
       
   141         retval = EFalse;
       
   142         }
       
   143     
       
   144     APSETUILOGGER_LEAVEFN( EOther,"TxtOverride::IsTextOverridenL")
       
   145     return retval;
       
   146     }
       
   147 
       
   148 
       
   149 // ---------------------------------------------------------
       
   150 // CTextOverrides::ValidateIdL
       
   151 // ---------------------------------------------------------
       
   152 //
       
   153 void CTextOverrides::ValidateIdL( TTextID aTextId )
       
   154     {
       
   155     APSETUILOGGER_ENTERFN( EOther,"TxtOverride::ValidateIdL")
       
   156     
       
   157     if ( ( aTextId < KTTextIdMin ) || ( aTextId > KTTextIdMax ) )
       
   158         {
       
   159         User::Leave( KErrInvalidTextId );
       
   160         }
       
   161     
       
   162     APSETUILOGGER_LEAVEFN( EOther,"TxtOverride::ValidateIdL")
       
   163     }
       
   164 
       
   165 
       
   166 // End of File