Mobile API Reference  MicroStrategy 2019
NumberObject.h
Go to the documentation of this file.
1 //==============================================================================================
2 // FILENAME : NumberObject.h
3 // AUTHOR : Liang Liu
4 // CREATION : 2008-09-23
5 // Copyright (C) MicroStrategy Incorporated 2008
6 // All Rights Reserved
7 //==============================================================================================
8 
9 #ifndef MsiChart_NumberObject_h
10 #define MsiChart_NumberObject_h
11 
12 #include "TextObject.h"
13 #include "NumberObjectHelper.h"
14 
15 namespace MsiChart
16 {
18  typedef enum
19  {
20  Default = -2,
21  Fixed = 0,
33 
34  #define CURR_SYMB_SIZE 5
35  #define FORMAT_SIZE 256
36 
39  {
41  int iDigits;
42  int iGrouping;
44  int iPosCurr;
45  int NegFormat;
47 
49  iDigits(0),
50  iGrouping(3),
51  iPosCurr(0),
52  NegFormat(3)
53 
54  {
55  strlcpy(szCurrency, "$", CURR_SYMB_SIZE);
56  strlcpy(szCustomFormat, "General", FORMAT_SIZE);
57  }
58  };
59 
60  const static char sFixedStringTable[3][8] = {
61  {"[SF:-3]"},
62  {"[SF:-6]"},
63  {"[SF:-9]"}
64  };
66 
70  class NumberObject: public TextObject
71  {
72  public:
74 
89  NumberObject(const TripleId& irTripleId,
90  GraphObjectManager* ipManager,
91  double iNumber,
92  const ChartAdvFormat& irNumberFormat,
93  GraphCollectionObject* ipParentObject = NULL,
94  LCID iLocale = 0,
95  bool iClientDrag = false,
96  Dataset::Ptr iDatasetPtr = NULL,
97  bool iIsFinal = true,
98  Int32 iColumnOffset = 0,
100 
101  virtual ~NumberObject();
102 
103  // Pure virtual function from GraphObject
104  virtual void Draw() const;
105 
110  void AddTextBeforeNumber(const MBase::String& irString);
111 
116  double GetNumber() const;
117  void SetNumber(double iNumber);
118 
119  void SetThreshHold(bool iIsThreshHold, Int32 iColor = 0);
120 
125  bool IsAbbreviated() const;
126 
132  bool GetNumberFromText(double& orValue);
133 
138  bool IsReplacedText() const;
139 
141 
142 
143  Int32 GetColor() const;
144  void SetColor(Int32 iColor);
145  void SetPrefix(MBase::String iPrefix);
146  void SetSuffix(MBase::String iSuffix);
147  void GetPrefix(MBase::String& orPrefix);
148  void GetSuffix(MBase::String& orSuffix);
149  void SetHasBracket(bool iHasBracket);
150  Int32 GetColumnOffset() const;
151  //void SetTextValue(const MBase::String& irString);
156  //NumberObjectHelper need to call this method and there is a SetText in TextObject,so I didn't change the prefix --Jin ,dong
157  void hSetText(const MBase::String& irString);
158  void HandleNegNumberFormat(const char* ipFormattingString, Int32 iNegFormat, LCID iLocale);
159  void FilterQuotes(char* ipString, bool iDividPosAndNeg = true);
160  bool FilterQuotes(std::string& iorString, bool iDividPosAndNeg = true);
161  void MapFormattingString(std::string& iorStr);
162  bool IsFraction(const std::string& irNumberFormat) const;
163  double AdjustFormatStringWithDot(std::string& formatString, int iDotIndex);
164  bool HasBracket(std::string& iorFormatStr);
165  double AnalyzeSeperatorAtTail(std::string& iorNumberFormat);
166  bool GetPreAndSuffix(std::string& iorFormatStr, std::string& orPrefix, std::string& orSuffix);
167  private:
175  void SetNumberFormat(const ChartAdvFormat& irNumberFormat, LCID iLocale, Dataset::Ptr iDatasetPtr, EnumDssGraphNumberFormatAsAxis iNumberFormatAsAxis = DssGraphNumberFormatAsDefaultAxis);
176 
181  void SetNumberFormatForTimeSeries(const ChartAdvFormat& irNumberFormat);
182 
190  void hFormatTimeSeriesAxisLabels(const ChartAdvFormat& irNumberFormat, LCID iLocale, Dataset::Ptr iDatasetPtr, EnumDssGraphNumberFormatAsAxis iNumberFormatAsAxis);
191  void hFormatGraphMatrixAxisLabels(const ChartAdvFormat& irNumberFormat, LCID iLocale, Dataset::Ptr iDatasetPtr);
192 
198  TripleId hMapTripleId(EnumDssGraphNumberFormatAsAxis iNumberFormatAsAxis, ChartAdvFormat& iorNumberFormat);
199 
205  void hMapFormatType(const TripleId& irTripleId, ChartAdvFormat& iorNumberFormat);
206 
210  bool hGetPreAndSuffix(std::string& iorFormatStr, std::string& orPrefix, std::string& orSuffix, bool& orHasBrakcket, bool iDividPosAndNeg = true);
211 
212  void hParseColor(char** oppSource);
213 
214  std::string hConvertToFraction(double value, std::string& formatString);
215 
216  void hSetTextFromGrid(Dataset::Ptr iDatasetPtr, MFormat::NumberFormat* ipNumberFormat, LCID iLocale); //Handle the "From Grid" case
217  void hSetNumberFormat(Dataset::Ptr iDatasetPtr, const ChartAdvFormat& irNumberFormat, LCID iLocale);
218  void hRemoveMinusFromNegExpComponet(std::string& iorNumberFormat); //used in scientific mode.
219  bool replaceQuestionMarkWithHash(std::string& iorNumberFormat);
220  bool hIsCondenseAllowed(Dataset::Ptr iDatasetPtr);
221 
222  void hParseConditions(std::string& iorFormat);
223  void hReplaceCurencySymbol(std::string& iorFormat);
224  bool hHandleReplacedText(Dataset::Ptr iDatasetPtr);
225 
226  // data members
227  double mNumber;
228  Int32 mColor;
229  bool mIsFinal;
230  bool mIsThreshHold;
231  bool mIsAbbreviated; //< Abbreviated with time series style.
232  Int32 mColumnOffset;
233  bool mIsReplacedText; //< Replaced Text from Thresholds or other specified text.
234 
235  bool mHasBracket;
236  MBase::String mPrefix;
237  MBase::String mSuffix;
238 
239  NumberObjectHelper *mpNumberObjectHelper;
240  };
242  {
243  return mColumnOffset;
244  }
245  inline double NumberObject::GetNumber() const
246  {
247  return mNumber;
248  }
249  inline void NumberObject::SetThreshHold(bool iIsThreshHold, Int32 iColor)
250  {
251  mIsThreshHold = iIsThreshHold;
252  if (mIsThreshHold)
253  mColor = iColor;
254  }
255  inline void NumberObject::SetHasBracket(bool iHasBracket)
256  {
257  mHasBracket = iHasBracket;
258  }
259  inline bool NumberObject::IsAbbreviated() const
260  {
261  return mIsAbbreviated;
262  }
263  inline bool NumberObject::IsReplacedText() const
264  {
265  return mIsReplacedText;
266  }
268  {
269  return mColor;
270  }
271  inline void NumberObject::SetColor(Int32 iColor)
272  {
273  mColor = iColor;
274  }
276  {
277  mPrefix = iPrefix;
278  }
280  {
281  mSuffix = iSuffix;
282  }
283  inline void NumberObject::GetPrefix(MBase::String& orPrefix)
284  {
285  orPrefix = mPrefix;
286  }
287  inline void NumberObject::GetSuffix(MBase::String& orSuffix)
288  {
289  orSuffix = mSuffix;
290  }
291  inline void NumberObject::SetNumber(double iNumber)
292  {
293  mNumber = iNumber;
294  }
295 }
296 
297 #endif
bool HasBracket(std::string &iorFormatStr)
Definition: NumberObject.h:26
void SetPrefix(MBase::String iPrefix)
Definition: NumberObject.h:275
MSynch::SmartPtr< NumberObject > Ptr
Definition: NumberObject.h:73
void SetThreshHold(bool iIsThreshHold, Int32 iColor=0)
Definition: NumberObject.h:249
void SetCorrectDateFormatString(ChartAdvFormat &orFormat)
double AnalyzeSeperatorAtTail(std::string &iorNumberFormat)
Definition: Common.h:46
void SetColor(Int32 iColor)
Definition: NumberObject.h:271
Definition: NumberFormat.h:32
bool GetPreAndSuffix(std::string &iorFormatStr, std::string &orPrefix, std::string &orSuffix)
NumberObject(const TripleId &irTripleId, GraphObjectManager *ipManager, double iNumber, const ChartAdvFormat &irNumberFormat, GraphCollectionObject *ipParentObject=NULL, LCID iLocale=0, bool iClientDrag=false, Dataset::Ptr iDatasetPtr=NULL, bool iIsFinal=true, Int32 iColumnOffset=0, EnumDssGraphNumberFormatAsAxis iNumberFormatAsAxis=DssGraphNumberFormatAsDefaultAxis)
#define CURR_SYMB_SIZE
Definition: NumberObject.h:34
void SetSuffix(MBase::String iSuffix)
Definition: NumberObject.h:279
int formatType
Definition: NumberObject.h:40
Definition: NumberObject.h:31
char szCustomFormat[FORMAT_SIZE]
Definition: NumberObject.h:46
Definition: NumberObject.h:21
This struct is from ChartCtrl.h.
Definition: NumberObject.h:38
bool IsFraction(const std::string &irNumberFormat) const
bool IsReplacedText() const
Definition: NumberObject.h:263
Definition: NumberObject.h:23
double GetNumber() const
Definition: NumberObject.h:245
void AddTextBeforeNumber(const MBase::String &irString)
Definition: GraphCollectionObject.h:19
Definition: NumberObject.h:27
virtual void Draw() const
int iPosCurr
Definition: NumberObject.h:44
int iGrouping
Definition: NumberObject.h:42
void HandleNegNumberFormat(const char *ipFormattingString, Int32 iNegFormat, LCID iLocale)
bool IsAbbreviated() const
Definition: NumberObject.h:259
Definition: NumberObject.h:22
Definition: Dataset.h:198
DWORD LCID
Definition: PDCwtypes.h:294
Definition: NumberObject.h:30
void FilterQuotes(char *ipString, bool iDividPosAndNeg=true)
bool GetNumberFromText(double &orValue)
char szCurrency[CURR_SYMB_SIZE]
Definition: NumberObject.h:43
#define Int32
Definition: BasicTypes.h:20
int iDigits
Definition: NumberObject.h:41
Definition: TextObject.h:181
ChartAdvFormat()
Definition: NumberObject.h:48
Int32 GetColumnOffset() const
Definition: NumberObject.h:241
EnumDssGraphNumberFormatAsAxis
Definition: Common.h:44
Definition: SmartPtr.h:38
Definition: NumberObject.h:25
std::basic_string< WCHAR, std::char_traits< WCHAR >, Allocator< WCHAR > > String
Definition: BaseString.h:26
Definition: ABLPlot.h:21
#define FORMAT_SIZE
Definition: NumberObject.h:35
void SetHasBracket(bool iHasBracket)
Definition: NumberObject.h:255
double AdjustFormatStringWithDot(std::string &formatString, int iDotIndex)
void GetPrefix(MBase::String &orPrefix)
Definition: NumberObject.h:283
Definition: NumberObject.h:28
void GetSuffix(MBase::String &orSuffix)
Definition: NumberObject.h:287
Definition: NumberObject.h:70
void SetNumber(double iNumber)
Definition: NumberObject.h:291
int NegFormat
Definition: NumberObject.h:45
void hSetText(const MBase::String &irString)
void MapFormattingString(std::string &iorStr)
Definition: NumberObject.h:20
#define NULL
Definition: Null.h:10
Definition: GraphObjectManager.h:37
Int32 GetColor() const
Definition: NumberObject.h:267
Definition: NumberObjectHelper.h:9
Definition: NumberObject.h:29
Definition: Common.h:397
Definition: NumberObject.h:24
NumberCategory
This enumeration is from ChartCtrl.h.
Definition: NumberObject.h:18