menufw/hierarchynavigator/hnmetadatamodel/inc/hnmdlocalization.h
changeset 0 f72a12da539e
child 26 1b758917cafc
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_HNMDLOCALIZATION_H
       
    21 #define C_HNMDLOCALIZATION_H
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <xmlengelement.h> 
       
    26 
       
    27 class CHnMdLocalizationElement;
       
    28 class CCoeEnv;
       
    29 
       
    30 /**
       
    31  * Localization.
       
    32  * 
       
    33  * This class is designed to support localization.
       
    34  *
       
    35  * @since S60 5.0
       
    36  * @ingroup group_hnmetadatamodel
       
    37  */
       
    38 NONSHARABLE_CLASS(CHnMdLocalization) : public CBase
       
    39     {
       
    40 public:
       
    41 
       
    42     /**
       
    43      * Two-phase constructor.
       
    44      *
       
    45      * @since S60 5.0
       
    46      * @return Fully constructed object.
       
    47      */
       
    48     static CHnMdLocalization* NewL();
       
    49 
       
    50     /**
       
    51      * Two-phase constructor.
       
    52      *
       
    53      * @since S60 5.0
       
    54      * @return Fully constructed object.
       
    55      */
       
    56     static CHnMdLocalization* NewLC();
       
    57 
       
    58     /**
       
    59      * Standard C++ virtual destructor.
       
    60      *
       
    61      * @since S60 5.0
       
    62      */
       
    63     virtual ~CHnMdLocalization();
       
    64     
       
    65     /**
       
    66      * Appends localizations.
       
    67      *
       
    68      * @since S60 5.0
       
    69      * @param aElement Xml element.
       
    70      */
       
    71     void AppendLocalizationsL( TXmlEngElement aElement );
       
    72 
       
    73     /**
       
    74      * Gets element by name.
       
    75      *
       
    76      * @since S60 5.0
       
    77      * @param aNamespace Namespace.
       
    78      * @return Localization element.
       
    79      */
       
    80     const CHnMdLocalizationElement* ElementByNamespace(
       
    81             const TDesC& aNamespace ) const;
       
    82             
       
    83     /**
       
    84      * Loads resource.
       
    85      * Resources can be defined in formats 
       
    86      * @code <namespace>:<id> @endcode
       
    87      * Namespaces can be defined by localization elements,
       
    88      * but can also point to rsg file.
       
    89      * Id can be rsg constants, but it can be also numbers.
       
    90      *
       
    91      * @since S60 5.0
       
    92      * @param aResourceName Resource name.
       
    93      * @param aDesParams descriptor parameters to format %U, %0U.
       
    94      * @param aIntParams integer parameters to format %N, %0N.* 
       
    95      * @return Descriptor.
       
    96      */
       
    97      HBufC* LoadL( const TDesC& aResourceName, 
       
    98                    const CDesC16Array* aDesParams, 
       
    99                    const CArrayFix<TInt>* aIntParams );
       
   100      
       
   101      /**
       
   102       * Realeses loaded resources.
       
   103       *
       
   104       * @since S60 5.0
       
   105       */
       
   106      void ReleaseResourceFiles();
       
   107      /**
       
   108       * Reloads realesed resources.
       
   109       *
       
   110       * @since S60 5.0
       
   111       */
       
   112      void ReloadResourceFilesL();
       
   113 
       
   114 private:
       
   115 
       
   116     /**
       
   117      * Standard C++ constructor.
       
   118      *
       
   119      * @since S60 5.0
       
   120      */
       
   121     CHnMdLocalization();
       
   122 
       
   123     /**
       
   124      * Standard symbian 2nd pahse constructor.
       
   125      *
       
   126      * @since S60 5.0
       
   127      */
       
   128     void ConstructL();
       
   129     
       
   130     /**
       
   131      * Appends element the list of localization elements, it also checks for duplicates
       
   132      * if it is RSC file it load the file in CoeEnv
       
   133      * 
       
   134      * @param aElement element to add, ownership is taken
       
   135      *      if element with the same namespace exists element is ignored
       
   136      *
       
   137      * @since S60 5.0
       
   138      */
       
   139     void AppendElementL( CHnMdLocalizationElement*  aElement );
       
   140 
       
   141     /**
       
   142      * Check extension of file and decide it is a resource file
       
   143      * 
       
   144      * @param aFilename file name to check 
       
   145      * @return ETrue if it is rsc file, else EFalse
       
   146      */
       
   147     TBool IsResourceFile( const TDesC&  aFilename );
       
   148         
       
   149     /**
       
   150      * Formats text.
       
   151      * 
       
   152      * @since S60 5.0
       
   153      * @param aTextToFormat A text to format.
       
   154      * @param aDesParams Parameters of the text to be formated.
       
   155      * @param aIntParams Integer parameters of the text to be formated.
       
   156      */
       
   157     HBufC* FormatTextL( const TDesC& aTextToFormat,
       
   158                         const CDesC16Array* aDesParams, 
       
   159                         const CArrayFix<TInt>* aIntParams );
       
   160     
       
   161     /**
       
   162      * Checks whether the localization element identified by a namespace is
       
   163      * duplicated.
       
   164      *
       
   165      * @param aNamespace Namespace.
       
   166      */
       
   167     TBool IsDuplicateL( TDesC8& aNamespace );
       
   168     
       
   169     /**
       
   170      * Checks whether the localization element identified by a namespace is
       
   171      * duplicated.
       
   172      *
       
   173      * @param aNamespace Namespace.
       
   174      */
       
   175     TBool IsDuplicateL( TDesC& aNamespace );
       
   176     
       
   177     /**
       
   178      * Checks whether the localization element identified by a namespace is
       
   179      * internal.
       
   180      *
       
   181      * @param aName Name.
       
   182      */
       
   183     TBool IsInternalL( const TDesC& aName );
       
   184     
       
   185 private: // data
       
   186 
       
   187     /**
       
   188      * CoeEnv.
       
   189      * Not own.
       
   190      */
       
   191     CCoeEnv* iCoeEnv;
       
   192     
       
   193     /**
       
   194      * Own - Dynamic offset.
       
   195      */
       
   196     RArray< TInt > iDynamicOffset;
       
   197     
       
   198     /**
       
   199      * Own - Dynamic localization.
       
   200      */
       
   201     RPointerArray<CHnMdLocalizationElement> iDynamicLocalization;
       
   202     
       
   203     /**
       
   204      * Own - Internal offset.
       
   205      */
       
   206     RArray< TInt > iInternalOffset;
       
   207     
       
   208     /**
       
   209      * Own - Internal localization.
       
   210      */
       
   211     RPointerArray<CHnMdLocalizationElement> iInternalLocalization;
       
   212 
       
   213     };
       
   214 
       
   215 #endif // C_HNMMLOCALIZATION_H