ImagePrint/ImagePrintEngine/DeviceProtocols/xhtmlfilecomposer/inc/xhtmlfilecomposerconst.h
branchRCL_3
changeset 20 159fc2f68139
parent 17 26673e532f65
child 21 d59c248c9d36
equal deleted inserted replaced
17:26673e532f65 20:159fc2f68139
     1 /*
       
     2 * Copyright (c) 2002-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:  Contains the constant definitions used for composing XHTML file.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef XHTMLFILECOMPOSERCONST_H
       
    20 #define XHTMLFILECOMPOSERCONST_H
       
    21 
       
    22 /**
       
    23  * @name Constants
       
    24  */
       
    25 //@{
       
    26 /** Frame ratio defined for all image frames
       
    27  *
       
    28  * Paper is used maximally. That is, the image frames at certain layout
       
    29  * are calculated to fill the whole page what ever an aspect ratio of a frame will be.\n
       
    30  * It is wanted to use defined aspect ratio for all images at all layouts. It is more
       
    31  * effectual to perform an image at reasonable aspect ratio despiting of the unused space
       
    32  * left on page.
       
    33  */
       
    34 const TReal KFrameRatio = 1.3325;
       
    35 
       
    36 /** Relation between inches and millimieters.
       
    37  * @note 25.4 is the amount to multiply inch to get millimeters.
       
    38  */
       
    39 const TReal KInchDivider = 25.4;
       
    40 
       
    41 /** DPI (dots per inch) divider to convert the image size in pixels to the same unit as the paper is.*/
       
    42 const TInt KDpiDivider = 150;
       
    43 //@}
       
    44 
       
    45 /**
       
    46  * @ref Constants
       
    47  */
       
    48 //@{
       
    49 /** Maximum size of template file */
       
    50 const TInt KXFCMaxFileSize = 2048;
       
    51 
       
    52 /** Maximum length for XHTML value to be set in final XHTML file */
       
    53 const TInt KXFCMaxSettingLen = 110;
       
    54 
       
    55 /** Maximum length for template element for XHTML block before assigning */
       
    56 const TInt KXFCMaxBlockLen = 250;
       
    57 //@}
       
    58 
       
    59 
       
    60 /**
       
    61  * @ref Constants
       
    62  */
       
    63 //@{
       
    64 /** Degree value for image orientation*/
       
    65 const TInt  KXFC270Deg = 270;
       
    66 const TInt  KXFCZeroDeg = 0;
       
    67 const TInt  KXFC90Deg = 90;
       
    68 const TInt  KXFC180Deg = 180;
       
    69 //@}
       
    70 
       
    71 /**
       
    72  * @name Literal constants
       
    73  */
       
    74 //@{
       
    75 /// Default path for the XHTML-file
       
    76 _LIT( KXFCDefaultResultPath, "c:\\system\\data\\xhtml\\" );
       
    77 
       
    78 /// Mime type identifier for JPEG
       
    79 _LIT8( KMimeJpeg, "image/jpeg" );
       
    80 
       
    81 _LIT8(KMimeXhtml, "application/xhtml+xml");
       
    82 
       
    83 /// Characters
       
    84 _LIT8( KPros8, "%" );
       
    85 _LIT8( KUnderScore8, "_" );
       
    86 _LIT( KPros, "%" );
       
    87 _LIT( KUnderScore, "_" );
       
    88 _LIT8( KBackSlash, "\\" );
       
    89 _LIT8( KSlash, "/" );
       
    90 
       
    91 /// URL encode values
       
    92 _LIT8( KAmpUrlEncoded, "%26"   );
       
    93 _LIT8( KSemiColonUrlEncoded, "%3b" );
       
    94 _LIT8( KSlashUrlEncoded, "%2f" );
       
    95 _LIT8( KQuestionMarkUrlEncoded, "%3f" );
       
    96 _LIT8( KAtUrlEncoded, "%40" );
       
    97 _LIT8( KEqualsUrlEncoded, "%3d" );
       
    98 _LIT8( KPlusUrlEncoded, "%2b" );
       
    99 _LIT8( KDollarUrlEncoded, "%24" );
       
   100 _LIT8( KCommaUrlEncoded, "%2c" );
       
   101 _LIT8( KAposUrlEncoded, "%27" );
       
   102 _LIT8( KLeftBracketUrlEncoded, "%5b" );
       
   103 _LIT8( KRightBracketUrlEncoded, "%5d" );
       
   104 _LIT8( KHashUrlEncoded, "%23" );
       
   105 _LIT8( KBackSlashUrlEncoded, "%5c" );
       
   106 _LIT8( KColonUrlEncoded, "%3a" );
       
   107 
       
   108 //@}
       
   109 
       
   110 /** @typedef 	typedef TBuf8<KXFCMaxSettingLen> TXhtmlSetting
       
   111  *  @brief 		Type definition for XHTML setting value string */
       
   112 typedef TBuf8<KXFCMaxSettingLen> TXhtmlSetting;
       
   113 
       
   114 /** @typedef 	typedef TBuf8<KXFCMaxBlockLen> TBlock
       
   115  *  @brief 		Type definition for XHTML element block */
       
   116 typedef TBuf8<KXFCMaxBlockLen> TBlock;
       
   117 
       
   118 /** @typedef 	typedef TBuf8<KMaxFileName> TFileName8
       
   119  *  @brief 		Type definition for 8-bit filename buffer */
       
   120 typedef TBuf8<KMaxFileName> TFileName8;
       
   121 
       
   122 
       
   123 /**
       
   124 * @class 	TSizeReal
       
   125 * @brief	A type class to store a size (width, height) with floating values.
       
   126 *
       
   127 */
       
   128 class TSizeReal
       
   129 {
       
   130 	public:
       
   131 		//@{
       
   132 		/// Constructors
       
   133 		inline TSizeReal(){iWidth = 0; iHeight = 0;}
       
   134 		inline TSizeReal(const TSize &a){iWidth = a.iWidth; iHeight = a.iHeight;}
       
   135 		inline TSizeReal(const TReal aW, const TReal aH){iWidth = aW; iHeight = aH;}
       
   136 		inline TSizeReal(const TInt aW, const TInt aH){iWidth = aW; iHeight = aH;}
       
   137 		inline TSizeReal(const TReal aW, const TInt aH){iWidth = aW; iHeight = aH;}
       
   138 		inline TSizeReal(const TInt aW, const TReal aH){iWidth = aW; iHeight = aH;}
       
   139 		//@}
       
   140 
       
   141 		inline void SetSize(const TReal aW, const TReal aH){iWidth = aW; iHeight = aH;}
       
   142 		inline void SetSize(const TInt aW, const TInt aH){iWidth = aW; iHeight = aH;}
       
   143 		inline void SetSize(const TReal aW, const TInt aH){iWidth = aW; iHeight = aH;}
       
   144 		inline void SetSize(const TInt aW, const TReal aH){iWidth = aW; iHeight = aH;}
       
   145 
       
   146 		// Arithmetic operators
       
   147 		inline TSizeReal operator*(const TSizeReal& a) const
       
   148 		{TSizeReal x; x.iWidth = iWidth * a.iWidth; x.iHeight = iHeight * a.iHeight; return x;}
       
   149 
       
   150 		inline TSizeReal operator*(const TReal& a) const
       
   151 		{TSizeReal x; x.iWidth = iWidth * a; x.iHeight = iHeight * a; return x;}
       
   152 
       
   153 		inline TSizeReal operator/(const TReal& a) const
       
   154 		{TSizeReal x; x.iWidth = iWidth / a; x.iHeight = iHeight / a; return x;}
       
   155 
       
   156 		inline TSizeReal operator/(const TSizeReal& a) const
       
   157 		{TSizeReal x; x.iWidth = iWidth / a.iWidth; x.iHeight = iHeight / a.iHeight; return x;}
       
   158 
       
   159 		inline TSizeReal operator-(const TReal& a) const
       
   160 		{TSizeReal x; x.iWidth = iWidth - a; x.iHeight = iHeight - a; return x;}
       
   161 
       
   162 		inline TSizeReal operator-(const TSizeReal& a) const
       
   163 		{TSizeReal x; x.iWidth = iWidth - a.iWidth; x.iHeight = iHeight - a.iHeight; return x;}
       
   164 
       
   165 		inline TSizeReal operator+(const TReal& a) const
       
   166 		{TSizeReal x; x.iWidth = iWidth + a; x.iHeight = iHeight + a; return x;}
       
   167 
       
   168 		inline TSizeReal operator+(const TSizeReal& a) const
       
   169 		{TSizeReal x; x.iWidth = iWidth + a.iWidth; x.iHeight = iHeight + a.iHeight; return x;}
       
   170 
       
   171 		inline TSizeReal operator-=(const TReal& a)
       
   172 		{iWidth = iWidth - a; iHeight = iHeight - a; return *this;}
       
   173 
       
   174 		inline TSizeReal operator-=(const TSizeReal& a)
       
   175 		{iWidth = iWidth - a.iWidth; iHeight = iHeight - a.iHeight; return *this;}
       
   176 
       
   177 		inline TSizeReal operator+=(const TReal& a)
       
   178 		{iWidth = iWidth + a; iHeight = iHeight + a; return *this;}
       
   179 
       
   180 		inline TSizeReal operator+=(const TSizeReal& a)
       
   181 		{iWidth = iWidth + a.iWidth; iHeight = iHeight + a.iHeight; return *this;}
       
   182 
       
   183 		inline TSizeReal operator*=(const TReal& a)
       
   184 		{iWidth = iWidth * a; iHeight = iHeight * a; return *this;}
       
   185 
       
   186 		inline TSizeReal operator*=(const TSizeReal& a)
       
   187 		{iWidth = iWidth * a.iWidth; iHeight = iHeight * a.iHeight; return *this;}
       
   188 
       
   189 		inline TSizeReal operator/=(const TReal& a)
       
   190 		{iWidth = iWidth / a; iHeight = iHeight / a; return *this;}
       
   191 
       
   192 		inline TSizeReal operator/=(const TSizeReal& a)
       
   193 		{iWidth = iWidth / a.iWidth; iHeight = iHeight / a.iHeight; return *this;}
       
   194 
       
   195 		// Compare operators
       
   196 		inline TBool operator==(const TSizeReal& a) const
       
   197 		{if((iWidth == a.iWidth) && (iHeight == a.iHeight))return ETrue;
       
   198 		 else return EFalse;}
       
   199 
       
   200 		inline TBool operator!=(const TSizeReal& a) const
       
   201 		{if((iWidth != a.iWidth) && (iHeight != a.iHeight))return ETrue;
       
   202 		 else return EFalse;}
       
   203 
       
   204 		inline TBool operator<=(const TSizeReal& a) const
       
   205 		{if((iWidth <= a.iWidth) && (iHeight <= a.iHeight))return ETrue;
       
   206 		 else return EFalse;}
       
   207 
       
   208 		inline TBool operator>=(const TSizeReal& a) const
       
   209 		{if((iWidth >= a.iWidth) && (iHeight >= a.iHeight))return ETrue;
       
   210 		 else return EFalse;}
       
   211 
       
   212 		inline TBool operator<(const TSizeReal& a) const
       
   213 		{if((iWidth < a.iWidth) && (iHeight < a.iHeight))return ETrue;
       
   214 		 else return EFalse;}
       
   215 
       
   216 		inline TBool operator>(const TSizeReal& a) const
       
   217 		{if((iWidth > a.iWidth) && (iHeight > a.iHeight))return ETrue;
       
   218 		 else return EFalse;}
       
   219 
       
   220 		inline TBool operator==(const TReal& a) const
       
   221 		{if((iWidth == a) && (iHeight == a))return ETrue;
       
   222 		 else return EFalse;}
       
   223 
       
   224 		inline TBool operator!=(const TReal& a) const
       
   225 		{if((iWidth != a) && (iHeight != a))return ETrue;
       
   226 		 else return EFalse;}
       
   227 
       
   228 		inline TBool operator<=(const TReal& a) const
       
   229 		{if((iWidth <= a) && (iHeight <= a))return ETrue;
       
   230 		 else return EFalse;}
       
   231 
       
   232 		inline TBool operator>=(const TReal& a) const
       
   233 		{if((iWidth >= a) && (iHeight >= a))return ETrue;
       
   234 		 else return EFalse;}
       
   235 
       
   236 		inline TBool operator<(const TReal& a) const
       
   237 		{if((iWidth < a) && (iHeight < a))return ETrue;
       
   238 		 else return EFalse;}
       
   239 
       
   240 		inline TBool operator>(const TReal& a) const
       
   241 		{if((iWidth > a) && (iHeight > a))return ETrue;
       
   242 		 else return EFalse;}
       
   243 
       
   244 		// Change width to height and vice versa
       
   245 		inline void Reverse()
       
   246 		{TSizeReal x(iHeight, iWidth); iWidth = x.iWidth; iHeight = x.iHeight;}
       
   247 
       
   248 		// Get the ratio of of width vs. height
       
   249 		inline TReal Ratio()
       
   250 		{return iWidth/iHeight;}
       
   251 
       
   252 	public:
       
   253 		TReal iWidth;
       
   254 		TReal iHeight;
       
   255 };
       
   256 
       
   257 #endif // XHTMLFILECOMPOSERCONST_H
       
   258 
       
   259 //  End of File