1 // Copyright 2014 PDFium Authors. All rights reserved.
\r
2 // Use of this source code is governed by a BSD-style license that can be
\r
3 // found in the LICENSE file.
\r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
\r
7 #ifndef _FXFA_WIDGETVALUE_H
\r
8 #define _FXFA_WIDGETVALUE_H
\r
11 class CXFA_LocaleMgr;
\r
12 #define XFA_VT_NULL 0
\r
13 #define XFA_VT_BOOLEAN 1
\r
14 #define XFA_VT_INTEGER 2
\r
15 #define XFA_VT_DECIMAL 4
\r
16 #define XFA_VT_FLOAT 8
\r
17 #define XFA_VT_TEXT 16
\r
18 #define XFA_VT_DATE 32
\r
19 #define XFA_VT_TIME 64
\r
20 #define XFA_VT_DATETIME 128
\r
21 class CXFA_LocaleValue : public CFX_Object
\r
25 CXFA_LocaleValue(const CXFA_LocaleValue& value);
\r
26 CXFA_LocaleValue(FX_DWORD dwType, CXFA_LocaleMgr* pLocaleMgr);
\r
27 CXFA_LocaleValue(FX_DWORD dwType, const CFX_WideString& wsValue, CXFA_LocaleMgr* pLocaleMgr);
\r
28 CXFA_LocaleValue(FX_DWORD dwType, const CFX_WideString& wsValue,
\r
29 const CFX_WideString& wsFormat, IFX_Locale* pLocale, CXFA_LocaleMgr* pLocaleMgr);
\r
30 ~CXFA_LocaleValue();
\r
31 CXFA_LocaleValue& operator = (const CXFA_LocaleValue& value);
\r
33 FX_BOOL ValidateValue(const CFX_WideString& wsValue, const CFX_WideString& wsPattern, IFX_Locale* pLocale, CFX_WideString* pMatchFormat = NULL);
\r
34 FX_BOOL FormatPatterns(CFX_WideString& wsResult, const CFX_WideString& wsFormat, IFX_Locale* pLocale, XFA_VALUEPICTURE eValueType) const;
\r
35 FX_BOOL FormatSinglePattern(CFX_WideString& wsResult, const CFX_WideString& wsFormat, IFX_Locale* pLocale, XFA_VALUEPICTURE eValueType) const;
\r
36 FX_BOOL ValidateCanonicalValue(const CFX_WideString& wsValue, FX_DWORD dwVType);
\r
37 FX_BOOL ValidateCanonicalDate(const CFX_WideString& wsDate, CFX_Unitime& unDate);
\r
38 FX_BOOL ValidateCanonicalTime(const CFX_WideString& wsTime);
\r
39 FX_BOOL ValidateCanonicalDateTime(const CFX_WideString& wsDateTime);
\r
40 void GetNumbericFormat(CFX_WideString &wsFormat, FX_INT32 nIntLen, FX_INT32 nDecLen, FX_BOOL bSign = TRUE);
\r
41 FX_BOOL ValidateNumericTemp(CFX_WideString& wsNumeric, CFX_WideString& wsFormat, IFX_Locale* pLocale = NULL, FX_INT32* pos = NULL);
\r
43 CFX_WideString GetValue() const;
\r
44 FX_DWORD GetType() const;
\r
45 void SetValue(const CFX_WideString& wsValue, FX_DWORD dwType);
\r
46 CFX_WideString GetText() const;
\r
47 FX_FLOAT GetNum() const;
\r
48 FX_DOUBLE GetDoubleNum() const;
\r
49 CFX_Unitime GetDate() const;
\r
50 CFX_Unitime GetTime() const;
\r
51 CFX_Unitime GetDateTime() const;
\r
52 FX_BOOL SetText(const CFX_WideString& wsText);
\r
53 FX_BOOL SetText(const CFX_WideString& wsText, const CFX_WideString& wsFormat, IFX_Locale* pLocale);
\r
54 FX_BOOL SetNum(FX_FLOAT fNum);
\r
55 FX_BOOL SetNum(const CFX_WideString& wsNum, const CFX_WideString& wsFormat, IFX_Locale* pLocale);
\r
56 FX_BOOL SetDate(const CFX_Unitime& d);
\r
57 FX_BOOL SetDate(const CFX_WideString& wsDate, const CFX_WideString& wsFormat, IFX_Locale* pLocale);
\r
58 FX_BOOL SetTime(const CFX_Unitime& t);
\r
59 FX_BOOL SetTime(const CFX_WideString& wsTime, const CFX_WideString& wsFormat, IFX_Locale* pLocale);
\r
60 FX_BOOL SetDateTime(const CFX_Unitime& dt);
\r
61 FX_BOOL SetDateTime(const CFX_WideString& wsDateTime, const CFX_WideString& wsFormat, IFX_Locale* pLocale);
\r
62 inline FX_BOOL IsNull() const
\r
64 return m_dwType == XFA_VT_NULL;
\r
66 inline FX_BOOL IsEmpty() const
\r
68 return m_wsValue.IsEmpty();
\r
70 inline FX_BOOL IsValid() const
\r
75 FX_BOOL ParsePatternValue(const CFX_WideString& wsValue, const CFX_WideString& wsPattern, IFX_Locale* pLocale);
\r
76 CXFA_LocaleMgr* m_pLocaleMgr;
\r
77 CFX_WideString m_wsValue;
\r