VSDFieldList.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * This file is part of the libvisio project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef __VSDFIELDLIST_H__
11 #define __VSDFIELDLIST_H__
12 
13 #include <vector>
14 #include <map>
15 #include <librevenge/librevenge.h>
16 #include "VSDDocumentStructure.h"
17 #include "VSDTypes.h"
18 
19 namespace libvisio
20 {
21 
22 class VSDCollector;
23 
25 {
26 public:
28  virtual ~VSDFieldListElement() {}
29  virtual void handle(VSDCollector *collector) const = 0;
30  virtual VSDFieldListElement *clone() = 0;
31  virtual librevenge::RVNGString getString(const std::map<unsigned, librevenge::RVNGString> &) = 0;
32  virtual void setNameId(int) = 0;
33  virtual void setFormat(unsigned short) = 0;
34  virtual void setValue(double) = 0;
35 };
36 
38 {
39 public:
40  VSDTextField(unsigned id, unsigned level, int nameId, int formatStringId)
41  : m_id(id),
42  m_level(level),
43  m_nameId(nameId),
44  m_formatStringId(formatStringId) {}
46  void handle(VSDCollector *collector) const;
48  librevenge::RVNGString getString(const std::map<unsigned, librevenge::RVNGString> &strVec);
49  void setNameId(int nameId);
50  void setFormat(unsigned short) {}
51  void setValue(double) {}
52 private:
53  unsigned m_id, m_level;
55 };
56 
58 {
59 public:
60  VSDNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId)
61  : m_id(id),
62  m_level(level),
63  m_format(format),
64  m_number(number),
65  m_formatStringId(formatStringId) {}
67  void handle(VSDCollector *collector) const;
69  librevenge::RVNGString getString(const std::map<unsigned, librevenge::RVNGString> &);
70  void setNameId(int) {}
71  void setFormat(unsigned short format);
72  void setValue(double number);
73 private:
74  librevenge::RVNGString datetimeToString(const char *format, double datetime);
75  unsigned m_id, m_level;
76  unsigned short m_format;
77  double m_number;
79 };
80 
82 {
83 public:
84  VSDFieldList();
85  VSDFieldList(const VSDFieldList &fieldList);
86  ~VSDFieldList();
87  VSDFieldList &operator=(const VSDFieldList &fieldList);
88  void setElementsOrder(const std::vector<unsigned> &m_elementsOrder);
89  void addFieldList(unsigned id, unsigned level);
90  void addTextField(unsigned id, unsigned level, int nameId, int formatStringId);
91  void addNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId);
92  void addClonedField(unsigned id);
93  void handle(VSDCollector *collector) const;
94  void clear();
95  unsigned long size() const
96  {
97  return (unsigned long)m_elements.size();
98  }
99  bool empty() const
100  {
101  return (m_elements.empty());
102  }
103  VSDFieldListElement *getElement(unsigned index);
104 private:
105  std::map<unsigned, VSDFieldListElement *> m_elements;
106  std::vector<unsigned> m_elementsOrder;
107  unsigned m_id, m_level;
108 };
109 
110 } // namespace libvisio
111 
112 #endif // __VSDFIELDLIST_H__
113 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
void addFieldList(unsigned id, unsigned level)
Definition: VSDFieldList.cpp:211
unsigned m_level
Definition: VSDFieldList.h:53
~VSDNumericField()
Definition: VSDFieldList.h:66
librevenge::RVNGString getString(const std::map< unsigned, librevenge::RVNGString > &)
Definition: VSDFieldList.cpp:65
void addTextField(unsigned id, unsigned level, int nameId, int formatStringId)
Definition: VSDFieldList.cpp:217
void handle(VSDCollector *collector) const
Definition: VSDFieldList.cpp:227
virtual void setValue(double)=0
unsigned m_id
Definition: VSDFieldList.h:107
virtual void setFormat(unsigned short)=0
VSDFieldListElement()
Definition: VSDFieldList.h:27
void addNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId)
Definition: VSDFieldList.cpp:222
~VSDFieldList()
Definition: VSDFieldList.cpp:199
Definition: VSDFieldList.h:24
VSDFieldListElement * clone()
Definition: VSDFieldList.cpp:44
VSDFieldListElement * getElement(unsigned index)
Definition: VSDFieldList.cpp:258
void setNameId(int nameId)
Definition: VSDFieldList.cpp:33
VSDFieldListElement * clone()
Definition: VSDFieldList.cpp:19
VSDTextField(unsigned id, unsigned level, int nameId, int formatStringId)
Definition: VSDFieldList.h:40
librevenge::RVNGString datetimeToString(const char *format, double datetime)
Definition: VSDFieldList.cpp:51
virtual librevenge::RVNGString getString(const std::map< unsigned, librevenge::RVNGString > &)=0
void handle(VSDCollector *collector) const
Definition: VSDFieldList.cpp:14
VSDFieldList & operator=(const VSDFieldList &fieldList)
Definition: VSDFieldList.cpp:184
unsigned short m_format
Definition: VSDFieldList.h:76
void addClonedField(unsigned id)
void setFormat(unsigned short format)
Definition: VSDFieldList.cpp:155
int m_formatStringId
Definition: VSDFieldList.h:78
Definition: VSDCollector.h:20
librevenge::RVNGString getString(const std::map< unsigned, librevenge::RVNGString > &strVec)
Definition: VSDFieldList.cpp:24
Definition: VSDFieldList.h:81
virtual void setNameId(int)=0
virtual void handle(VSDCollector *collector) const =0
void setFormat(unsigned short)
Definition: VSDFieldList.h:50
int m_nameId
Definition: VSDFieldList.h:54
VSDNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId)
Definition: VSDFieldList.h:60
Definition: VSDFieldList.h:37
double m_number
Definition: VSDFieldList.h:77
void clear()
Definition: VSDFieldList.cpp:250
virtual VSDFieldListElement * clone()=0
void setNameId(int)
Definition: VSDFieldList.h:70
unsigned m_level
Definition: VSDFieldList.h:75
bool empty() const
Definition: VSDFieldList.h:99
Definition: libvisio_utils.h:68
unsigned long size() const
Definition: VSDFieldList.h:95
int m_formatStringId
Definition: VSDFieldList.h:54
void setValue(double number)
Definition: VSDFieldList.cpp:159
void handle(VSDCollector *collector) const
Definition: VSDFieldList.cpp:39
VSDFieldList()
Definition: VSDFieldList.cpp:165
Definition: VSDFieldList.h:57
unsigned m_id
Definition: VSDFieldList.h:75
void setElementsOrder(const std::vector< unsigned > &m_elementsOrder)
Definition: VSDFieldList.cpp:204
void setValue(double)
Definition: VSDFieldList.h:51
unsigned m_id
Definition: VSDFieldList.h:53
virtual ~VSDFieldListElement()
Definition: VSDFieldList.h:28
~VSDTextField()
Definition: VSDFieldList.h:45
std::map< unsigned, VSDFieldListElement * > m_elements
Definition: VSDFieldList.h:105
unsigned m_level
Definition: VSDFieldList.h:107
std::vector< unsigned > m_elementsOrder
Definition: VSDFieldList.h:106

Generated for libvisio by doxygen 1.8.9.1