phonebookui/Phonebook2/inc/Pbk2PresentationUtils.h
changeset 0 e686773b3f54
child 3 04ab22b956c2
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Phonebook 2 presentation utilities.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef PBK2PRESENTATIONUTILS_H
       
    20 #define PBK2PRESENTATIONUTILS_H
       
    21 
       
    22 #include <e32std.h>
       
    23 
       
    24 /**
       
    25  * Util class with static text formatting functions
       
    26  */
       
    27 class Pbk2PresentationUtils
       
    28     {
       
    29     public: // Interface
       
    30 
       
    31         /**
       
    32          * Appends given text to given descriptor. Ignores all leading
       
    33          * and trailing spaces in the given text and converts consencutive
       
    34          * space characters to a single space character.
       
    35          *
       
    36          * @precond aDest.MaxLength()-aDest.Length() >= TrimAllLength(aText)
       
    37          * @postcond aDest.Length()-old(aDest.Length()) == TrimAllLength(aText)
       
    38          * @param aText     Text to append as a trimmed version.
       
    39          * @param aDest     Buffer where thed trimmed text is appended.
       
    40          *                  Must have enough room for the copied text.
       
    41          * @return  Number of characters appended.
       
    42          */
       
    43         static TInt TrimAllAppend(
       
    44                 const TDesC& aText,
       
    45                 TDes& aDest );
       
    46 
       
    47         /**
       
    48          * Appends given text to given descriptor. Ignores all trailing
       
    49          * spaces in the given text and converts consencutive space
       
    50          * characters to a single space character. Leading spaces remain
       
    51          * unaffected.
       
    52          *
       
    53          * @precond aDest.MaxLength()-aDest.Length() >= TrimRightLength(aText)
       
    54          * @postcond aDest.Length()-old(aDest.Length())==TrimRightLength(aText)
       
    55          * @param aText     Text to append as a trimmed version.
       
    56          * @param aDest     Buffer where the trimmed text is appended.
       
    57          *                  Must have enough room for the copied text.
       
    58          * @return  Number of characters appended.
       
    59          */
       
    60         IMPORT_C static TInt TrimRightAppend(
       
    61                 const TDesC& aText,
       
    62                 TDes& aDest );
       
    63 
       
    64         /**
       
    65          * Appends a descriptor to another and replaces characters while
       
    66          * appending.
       
    67          *
       
    68          * @precond (aDest.MaxLength()-aDest.Length()) >= aSrc.Length()
       
    69          * @precond aCharsToReplace.Length() == aReplaceChars.Length()
       
    70          * @param aDest             Destination descriptor.
       
    71          * @param aSrc              Source descriptor.
       
    72          * @param aCharsToReplace   Characters to replace.
       
    73          * @param aReplaceChars     Replace characters. The replace position
       
    74          *                          maps to the position in aCharsToReplace.
       
    75          * @return  Number of characters replaced.
       
    76          */
       
    77         IMPORT_C static TInt AppendAndReplaceChars(
       
    78                 TDes& aDest,
       
    79                 const TDesC& aSrc,
       
    80                 const TDesC& aCharsToReplace,
       
    81                 const TDesC& aReplaceChars );
       
    82 
       
    83         /**
       
    84          * Replaces all non-graphic characters (!TChar::IsGraph()) in
       
    85          * a string with the specified character.
       
    86          *
       
    87          * @param aText     The string where to replace
       
    88          *                  non-graphics characters.
       
    89          * @param aChar     The character used to replace non-graphic
       
    90          *                  characters.
       
    91          */
       
    92         IMPORT_C static void ReplaceNonGraphicCharacters(
       
    93                 TDes& aText,
       
    94                 TText aChar );
       
    95                 
       
    96         /**
       
    97          * Replaces all CR, LF or CRLF characters with unicode Paragraph
       
    98          * Separator (0x2029) character that for example Avkon controls
       
    99          * understand. Copies all other text as-is. Copies only as many
       
   100          * characters from the beginning of aText as aBuffer has space for.
       
   101          *
       
   102          * @param aBuffer  Destination buffer where aText is appended with
       
   103          *                 newlines translated to Paragraph Separators.
       
   104          * @param aText    Source text to be translated.
       
   105          */
       
   106         IMPORT_C static void AppendWithNewlineTranslationL(
       
   107                 TDes& aBuffer,
       
   108                 const TDesC& aText );
       
   109                 
       
   110         /**
       
   111         * Solves the correct language specific resource filename.
       
   112         * With all resource files the same pbk2presentation.rsg can be used.
       
   113         *
       
   114         * @return A reference to resource file
       
   115         */    
       
   116         IMPORT_C static const TDesC& PresentationResourceFile();
       
   117     
       
   118     private: // Disabled functions
       
   119         Pbk2PresentationUtils();
       
   120     };
       
   121 
       
   122 #endif // PBK2PRESENTATIONUTILS_H
       
   123 
       
   124 // End of File