menufw/hierarchynavigator/hnmetadatamodel/inc/hnmdlocalization.h
branchRCL_3
changeset 34 5456b4e8b3a8
equal deleted inserted replaced
33:5f0182e07bfb 34:5456b4e8b3a8
       
     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 private:
       
   101 
       
   102     /**
       
   103      * Standard C++ constructor.
       
   104      *
       
   105      * @since S60 5.0
       
   106      */
       
   107     CHnMdLocalization();
       
   108 
       
   109     /**
       
   110      * Standard symbian 2nd pahse constructor.
       
   111      *
       
   112      * @since S60 5.0
       
   113      */
       
   114     void ConstructL();
       
   115     
       
   116     /**
       
   117      * Appends element the list of localization elements, it also checks for duplicates
       
   118      * if it is RSC file it load the file in CoeEnv
       
   119      * 
       
   120      * @param aElement element to add, ownership is taken
       
   121      *      if element with the same namespace exists element is ignored
       
   122      *
       
   123      * @since S60 5.0
       
   124      */
       
   125     void AppendElementL( CHnMdLocalizationElement*  aElement );
       
   126 
       
   127     /**
       
   128      * Check extension of file and decide it is a resource file
       
   129      * 
       
   130      * @param aFilename file name to check 
       
   131      * @return ETrue if it is rsc file, else EFalse
       
   132      */
       
   133     TBool IsResourceFile( const TDesC&  aFilename );
       
   134         
       
   135     /**
       
   136      * Formats text.
       
   137      * 
       
   138      * @since S60 5.0
       
   139      * @param aTextToFormat A text to format.
       
   140      * @param aDesParams Parameters of the text to be formated.
       
   141      * @param aIntParams Integer parameters of the text to be formated.
       
   142      */
       
   143     HBufC* FormatTextL( const TDesC& aTextToFormat,
       
   144                         const CDesC16Array* aDesParams, 
       
   145                         const CArrayFix<TInt>* aIntParams );
       
   146     
       
   147     /**
       
   148      * Checks whether the localization element identified by a namespace is
       
   149      * duplicated.
       
   150      *
       
   151      * @param aNamespace Namespace.
       
   152      */
       
   153     TBool IsDuplicateL( TDesC8& aNamespace );
       
   154     
       
   155     /**
       
   156      * Checks whether the localization element identified by a namespace is
       
   157      * duplicated.
       
   158      *
       
   159      * @param aNamespace Namespace.
       
   160      */
       
   161     TBool IsDuplicateL( TDesC& aNamespace );
       
   162     
       
   163     /**
       
   164      * Checks whether the localization element identified by a namespace is
       
   165      * internal.
       
   166      *
       
   167      * @param aName Name.
       
   168      */
       
   169     TBool IsInternalL( const TDesC& aName );
       
   170     
       
   171 private: // data
       
   172 
       
   173     /**
       
   174      * CoeEnv.
       
   175      * Not own.
       
   176      */
       
   177     CCoeEnv* iCoeEnv;
       
   178 
       
   179     /**
       
   180      * Own - Internal offset.
       
   181      */
       
   182     RArray< TInt > iInternalOffset;
       
   183     
       
   184     /**
       
   185      * Own - Internal localization.
       
   186      */
       
   187     RPointerArray<CHnMdLocalizationElement> iInternalLocalization;
       
   188 
       
   189     };
       
   190 
       
   191 #endif // C_HNMMLOCALIZATION_H