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
24 class VSDFieldListElement
25 {
26 public:
27 VSDFieldListElement() {}
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
37 class VSDTextField : public VSDFieldListElement
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) {}
45 ~VSDTextField() override {}
46 void handle(VSDCollector *collector) const override;
47 VSDFieldListElement *clone() override;
48 librevenge::RVNGString getString(const std::map<unsigned, librevenge::RVNGString> &strVec) override;
49 void setNameId(int nameId) override;
50 void setFormat(unsigned short) override {}
51 void setValue(double) override {}
52 private:
53 unsigned m_id, m_level;
54 int m_nameId, m_formatStringId;
55 };
56
57 class VSDNumericField : public VSDFieldListElement
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) {}
66 ~VSDNumericField() override {}
67 void handle(VSDCollector *collector) const override;
68 VSDFieldListElement *clone() override;
69 librevenge::RVNGString getString(const std::map<unsigned, librevenge::RVNGString> &) override;
70 void setNameId(int) override {}
71 void setFormat(unsigned short format) override;
72 void setValue(double number) override;
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;
78 int m_formatStringId;
79 };
80
81 class VSDFieldList
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: */
libvisio::VSDFieldList::addFieldList
void addFieldList(unsigned id, unsigned level)
Definition: VSDFieldList.cpp:211
libvisio::VSDNumericField::setNameId
void setNameId(int) override
Definition: VSDFieldList.h:70
libvisio::VSDNumericField::getString
librevenge::RVNGString getString(const std::map< unsigned, librevenge::RVNGString > &) override
Definition: VSDFieldList.cpp:65
libvisio::VSDTextField::m_level
unsigned m_level
Definition: VSDFieldList.h:53
libvisio::VSDNumericField::setValue
void setValue(double number) override
Definition: VSDFieldList.cpp:159
libvisio::VSDFieldList::addTextField
void addTextField(unsigned id, unsigned level, int nameId, int formatStringId)
Definition: VSDFieldList.cpp:217
libvisio::VSDNumericField::~VSDNumericField
~VSDNumericField() override
Definition: VSDFieldList.h:66
libvisio::VSDFieldListElement::setValue
virtual void setValue(double)=0
VSDDocumentStructure.h
libvisio::VSDFieldList::m_id
unsigned m_id
Definition: VSDFieldList.h:107
libvisio::VSDFieldListElement::setFormat
virtual void setFormat(unsigned short)=0
libvisio::VSDFieldListElement::VSDFieldListElement
VSDFieldListElement()
Definition: VSDFieldList.h:27
libvisio::VSDFieldList::addNumericField
void addNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId)
Definition: VSDFieldList.cpp:223
libvisio::VSDFieldList::~VSDFieldList
~VSDFieldList()
Definition: VSDFieldList.cpp:199
libvisio::VSDFieldListElement
Definition: VSDFieldList.h:24
libvisio::VSDTextField::setFormat
void setFormat(unsigned short) override
Definition: VSDFieldList.h:50
libvisio::VSDFieldList::empty
bool empty() const
Definition: VSDFieldList.h:99
libvisio::VSDFieldList::getElement
VSDFieldListElement * getElement(unsigned index)
Definition: VSDFieldList.cpp:260
libvisio::VSDNumericField::setFormat
void setFormat(unsigned short format) override
Definition: VSDFieldList.cpp:155
libvisio::VSDTextField::VSDTextField
VSDTextField(unsigned id, unsigned level, int nameId, int formatStringId)
Definition: VSDFieldList.h:40
libvisio::VSDNumericField::datetimeToString
librevenge::RVNGString datetimeToString(const char *format, double datetime)
Definition: VSDFieldList.cpp:51
libvisio::VSDFieldListElement::getString
virtual librevenge::RVNGString getString(const std::map< unsigned, librevenge::RVNGString > &)=0
libvisio::VSDNumericField::handle
void handle(VSDCollector *collector) const override
Definition: VSDFieldList.cpp:39
libvisio::VSDFieldList::operator=
VSDFieldList & operator=(const VSDFieldList &fieldList)
Definition: VSDFieldList.cpp:184
libvisio::VSDNumericField::m_format
unsigned short m_format
Definition: VSDFieldList.h:76
libvisio::VSDFieldList::addClonedField
void addClonedField(unsigned id)
libvisio::VSDNumericField::m_formatStringId
int m_formatStringId
Definition: VSDFieldList.h:78
libvisio::VSDCollector
Definition: VSDCollector.h:20
libvisio::VSDFieldList
Definition: VSDFieldList.h:81
libvisio::VSDFieldListElement::setNameId
virtual void setNameId(int)=0
libvisio::VSDFieldListElement::handle
virtual void handle(VSDCollector *collector) const =0
libvisio::VSDTextField::m_nameId
int m_nameId
Definition: VSDFieldList.h:54
libvisio::VSDNumericField::clone
VSDFieldListElement * clone() override
Definition: VSDFieldList.cpp:44
libvisio::VSDTextField::getString
librevenge::RVNGString getString(const std::map< unsigned, librevenge::RVNGString > &strVec) override
Definition: VSDFieldList.cpp:24
libvisio::VSDNumericField::VSDNumericField
VSDNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId)
Definition: VSDFieldList.h:60
VSDTypes.h
libvisio::VSDTextField
Definition: VSDFieldList.h:37
libvisio::VSDNumericField::m_number
double m_number
Definition: VSDFieldList.h:77
libvisio::VSDFieldList::clear
void clear()
Definition: VSDFieldList.cpp:252
libvisio::VSDFieldListElement::clone
virtual VSDFieldListElement * clone()=0
libvisio::VSDTextField::handle
void handle(VSDCollector *collector) const override
Definition: VSDFieldList.cpp:14
libvisio::VSDNumericField::m_level
unsigned m_level
Definition: VSDFieldList.h:75
libvisio::VSDFieldList::handle
void handle(VSDCollector *collector) const
Definition: VSDFieldList.cpp:229
libvisio
Definition: libvisio_utils.h:48
libvisio::VSDTextField::clone
VSDFieldListElement * clone() override
Definition: VSDFieldList.cpp:19
libvisio::VSDTextField::m_formatStringId
int m_formatStringId
Definition: VSDFieldList.h:54
libvisio::VSDFieldList::VSDFieldList
VSDFieldList()
Definition: VSDFieldList.cpp:165
libvisio::VSDTextField::~VSDTextField
~VSDTextField() override
Definition: VSDFieldList.h:45
libvisio::VSDNumericField
Definition: VSDFieldList.h:57
libvisio::VSDNumericField::m_id
unsigned m_id
Definition: VSDFieldList.h:75
libvisio::VSDFieldList::size
unsigned long size() const
Definition: VSDFieldList.h:95
libvisio::VSDFieldList::setElementsOrder
void setElementsOrder(const std::vector< unsigned > &m_elementsOrder)
Definition: VSDFieldList.cpp:204
libvisio::VSDTextField::setNameId
void setNameId(int nameId) override
Definition: VSDFieldList.cpp:33
libvisio::VSDTextField::m_id
unsigned m_id
Definition: VSDFieldList.h:53
libvisio::VSDTextField::setValue
void setValue(double) override
Definition: VSDFieldList.h:51
libvisio::VSDFieldListElement::~VSDFieldListElement
virtual ~VSDFieldListElement()
Definition: VSDFieldList.h:28
libvisio::VSDFieldList::m_elements
std::map< unsigned, VSDFieldListElement * > m_elements
Definition: VSDFieldList.h:105
libvisio::VSDFieldList::m_level
unsigned m_level
Definition: VSDFieldList.h:107
libvisio::VSDFieldList::m_elementsOrder
std::vector< unsigned > m_elementsOrder
Definition: VSDFieldList.h:106