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