Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
6.9 KiB

  1. // TestITN.h : Declaration of the CTestITN
  2. #ifndef __TESTITN_H_
  3. #define __TESTITN_H_
  4. #include "resource.h" // main symbols
  5. #include <wchar.h> // for swprintf()
  6. #define MAX_LOCALE_DATA 5
  7. #define MAX_DATE_FORMAT 30
  8. #define MAX_SIG_FIGS 12
  9. #define MAX_STATEZIP 12
  10. #define CANADIAN_ZIPSIZE 8
  11. #define MAX_PHONE_NUMBER 17 // 1-(425)-882-8080\0
  12. // Flags for number display
  13. typedef enum DISPLAYFLAGS
  14. {
  15. DF_UNFORMATTED = (1L << 0),// No formatting
  16. DF_ORDINAL = (1L << 1),// Ordinal number
  17. DF_WHOLENUMBER = (1L << 2),// Should be displayed without decimal
  18. DF_FIXEDWIDTH = (1L << 3),// Requiring a certain width
  19. DF_LEADINGZERO = (1L << 4),// Presence of leading 0 of the number is between 0 and 1
  20. DF_NOTHOUSANDSGROUP = (1L << 5),// Do not do any thousands grouping (commas)
  21. DF_MILLIONBILLION = (1L << 6) // If the number is a flat "millions" or "billions"
  22. // then display as "3 million"
  23. } DISPLAYFLAGS;
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CTestITN
  26. class ATL_NO_VTABLE CTestITN :
  27. public CComObjectRootEx<CComMultiThreadModel>,
  28. public CComCoClass<CTestITN, &CLSID_TestITN>,
  29. public ISpCFGInterpreter
  30. {
  31. public:
  32. CTestITN() : m_pSite( NULL ),
  33. m_pwszNeg( NULL )
  34. {
  35. }
  36. ~CTestITN()
  37. {
  38. delete m_pwszNeg;
  39. }
  40. DECLARE_REGISTRY_RESOURCEID(IDR_TESTITN)
  41. DECLARE_PROTECT_FINAL_CONSTRUCT()
  42. BEGIN_COM_MAP(CTestITN)
  43. COM_INTERFACE_ENTRY(ISpCFGInterpreter)
  44. END_COM_MAP()
  45. private:
  46. HRESULT InterpretNumber( const SPPHRASEPROPERTY *pProperties,
  47. const bool fCardinal,
  48. DOUBLE *pdblVal,
  49. WCHAR *pszVal,
  50. UINT cSize,
  51. const bool fFinalDisplayFmt = false );
  52. HRESULT InterpretDigitNumber( const SPPHRASEPROPERTY *pProperties,
  53. DOUBLE *pdblVal,
  54. WCHAR *pszVal,
  55. UINT cSize);
  56. HRESULT InterpretFPNumber( const SPPHRASEPROPERTY *pProperties,
  57. DOUBLE *pdblVal,
  58. WCHAR *pszVal,
  59. UINT cSize);
  60. HRESULT InterpretMillBill( const SPPHRASEPROPERTY *pProperties,
  61. DOUBLE *pdblVal,
  62. WCHAR *pszVal,
  63. UINT cSize );
  64. HRESULT InterpretFraction( const SPPHRASEPROPERTY *pProperties,
  65. DOUBLE *pdblVal,
  66. WCHAR *pszVal,
  67. UINT cSize);
  68. HRESULT InterpretDate( const SPPHRASEPROPERTY *pProperties,
  69. DOUBLE *pdblVal,
  70. WCHAR *pszVal,
  71. UINT cSize);
  72. HRESULT InterpretTime( const SPPHRASEPROPERTY *pProperties,
  73. DOUBLE *pdblVal,
  74. WCHAR *pszVal,
  75. UINT cSize );
  76. HRESULT InterpretStateZip( const SPPHRASEPROPERTY *pProperties,
  77. WCHAR *pszVal,
  78. UINT cSize,
  79. BYTE *pbAttribs );
  80. HRESULT InterpretCanadaZip( const SPPHRASEPROPERTY *pProperties,
  81. WCHAR *pszVal,
  82. UINT cSize );
  83. HRESULT InterpretPhoneNumber( const SPPHRASEPROPERTY *pProperties,
  84. WCHAR *pszVal,
  85. UINT cSize );
  86. HRESULT InterpretDegrees( const SPPHRASEPROPERTY *pProperties,
  87. DOUBLE *pdblVal,
  88. WCHAR *pszVal,
  89. UINT cSize );
  90. HRESULT InterpretMeasurement( const SPPHRASEPROPERTY *pProperties,
  91. DOUBLE *pdblVal,
  92. WCHAR *pszVal,
  93. UINT cSize );
  94. HRESULT InterpretCurrency( const SPPHRASEPROPERTY *pProperties,
  95. DOUBLE *pdblVal,
  96. WCHAR *pszVal,
  97. UINT cSize);
  98. HRESULT AddPropertyAndReplacement( const WCHAR *szBuff,
  99. const DOUBLE dblValue,
  100. const ULONG ulMinPos,
  101. const ULONG ulMaxPos,
  102. const ULONG ulFirstElement,
  103. const ULONG ulCountOfElements,
  104. const BYTE bDisplayAttrib = SPAF_ONE_TRAILING_SPACE);
  105. HRESULT MakeDisplayNumber( DOUBLE dblNum,
  106. DWORD dwDisplayFlags,
  107. UINT uiFixedWidth,
  108. UINT uiDecimalPlaces,
  109. WCHAR *pwszNum,
  110. UINT cSize );
  111. int MakeDigitString( const SPPHRASEPROPERTY *pProperties,
  112. WCHAR *pwszDigitString,
  113. UINT cSize );
  114. HRESULT GetNumberFormatDefaults();
  115. HRESULT GetCurrencyFormatDefaults();
  116. ULONG ComputeNum999(const SPPHRASEPROPERTY *pProperties );
  117. void HandleDigitsAfterDecimal( WCHAR *pwszFormattedNum,
  118. UINT cSizeOfFormattedNum,
  119. const WCHAR *pwszRightOfDecimal );
  120. void GetMinAndMaxPos( const SPPHRASEPROPERTY *pProperties, ULONG *pulMinPos, ULONG *pulMaxPos );
  121. int GetMonthName( int iMonth, WCHAR *pwszMonth, int cSize, bool fAbbrev );
  122. int GetDayOfWeekName( int iDayOfWeek, WCHAR *pwszDayOfWeek, int cSize, bool fAbbrev );
  123. int FormatDate( const SYSTEMTIME &stDate, WCHAR *pwszFormat, WCHAR *pwszDate, int cSize );
  124. HRESULT MakeNumberNegative( WCHAR *pwszNumber );
  125. HRESULT MakePositiveCurrency( WCHAR *pwszCurr, const WCHAR * const pwszCurrSym );
  126. HRESULT MakeNegativeCurrency( WCHAR *pwszCurr, const WCHAR * const pwszCurrSym );
  127. private:
  128. // Data members
  129. CSpUnicodeSupport m_Unicode;
  130. NUMBERFMTW m_nmfmtDefault;
  131. CURRENCYFMTW m_cyfmtDefault;
  132. WCHAR m_pwszDecimalSep[ MAX_LOCALE_DATA];
  133. WCHAR m_pwszThousandSep[MAX_LOCALE_DATA];
  134. WCHAR m_pwszCurrencySym[MAX_LOCALE_DATA];
  135. WCHAR *m_pwszNeg;
  136. ISpCFGInterpreterSite *m_pSite;
  137. // ISpCFGInterptreter
  138. public:
  139. STDMETHODIMP InitGrammar(const WCHAR * pszGrammarName, const void ** pvGrammarData);
  140. STDMETHODIMP Interpret(ISpPhraseBuilder * pInterpretRule, const ULONG ulFirstElement, const ULONG ulCountOfElements, ISpCFGInterpreterSite * pSite);
  141. public:
  142. CComPtr<ISpPhraseBuilder> m_cpPhrase; // Decalred as a member to prevent repeated construct/destroy
  143. };
  144. #endif //__TESTITN_H_