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 <memory>
14#include <vector>
15#include <map>
16#include <librevenge/librevenge.h>
17#include "VSDDocumentStructure.h"
18#include "VSDTypes.h"
19
20 namespace libvisio
21{
22
23 class VSDCollector;
24
25 class VSDFieldListElement
26{
27 public:
28 VSDFieldListElement() {}
29 virtual ~VSDFieldListElement() {}
30 virtual void handle(VSDCollector *collector) const = 0;
31 virtual VSDFieldListElement *clone() = 0;
32 virtual librevenge::RVNGString getString(const std::map<unsigned, librevenge::RVNGString> &, unsigned defaultUnit) = 0;
33 virtual void setNameId(int) = 0;
34 virtual void setFormat(unsigned short) = 0;
35 virtual void setCellType(unsigned short) = 0;
36 virtual void setValue(double) = 0;
37};
38
39 class VSDTextField : public VSDFieldListElement
40{
41 public:
42 VSDTextField(unsigned id, unsigned level, int nameId, int formatStringId)
43 : m_id(id),
44 m_level(level),
45 m_nameId(nameId),
46 m_formatStringId(formatStringId) {}
47 ~VSDTextField() override {}
48 void handle(VSDCollector *collector) const override;
49 VSDFieldListElement *clone() override;
50 librevenge::RVNGString getString(const std::map<unsigned, librevenge::RVNGString> &strVec, unsigned defaultUnit) override;
51 void setNameId(int nameId) override;
52 void setFormat(unsigned short) override {}
53 void setCellType(unsigned short) override {}
54 void setValue(double) override {}
55 private:
56 unsigned m_id, m_level;
57 int m_nameId, m_formatStringId;
58};
59
60 class VSDNumericField : public VSDFieldListElement
61{
62 public:
63 VSDNumericField(unsigned id, unsigned level, unsigned short format, unsigned short cellType, double number, int formatStringId)
64 : m_id(id),
65 m_level(level),
66 m_format(format),
67 m_cell_type(cellType),
68 m_number(number),
69 m_formatStringId(formatStringId) {}
70 ~VSDNumericField() override {}
71 void handle(VSDCollector *collector) const override;
72 VSDFieldListElement *clone() override;
73 librevenge::RVNGString getString(const std::map<unsigned, librevenge::RVNGString> &, unsigned defaultUnit) override;
74 void setNameId(int) override {}
75 void setFormat(unsigned short format) override;
76 void setCellType(unsigned short cellType) override;
77 void setValue(double number) override;
78 private:
79 librevenge::RVNGString datetimeToString(const char *format, double datetime);
80 unsigned m_id, m_level;
81 unsigned short m_format;
82 unsigned short m_cell_type;
83 double m_number;
84 int m_formatStringId;
85};
86
87 class VSDFieldList
88{
89 public:
90 VSDFieldList();
91 VSDFieldList(const VSDFieldList &fieldList);
92 ~VSDFieldList();
93 VSDFieldList &operator=(const VSDFieldList &fieldList);
94 void setElementsOrder(const std::vector<unsigned> &m_elementsOrder);
95 void addFieldList(unsigned id, unsigned level);
96 void addTextField(unsigned id, unsigned level, int nameId, int formatStringId);
97 void addNumericField(unsigned id, unsigned level, unsigned short format, unsigned short cellType, double number, int formatStringId);
98 void addClonedField(unsigned id);
99 void handle(VSDCollector *collector) const;
100 void clear();
101 unsigned long size() const
102 {
103 return (unsigned long)m_elements.size();
104 }
105 bool empty() const
106 {
107 return (m_elements.empty());
108 }
109 VSDFieldListElement *getElement(unsigned index);
110 private:
111 std::map<unsigned, std::unique_ptr<VSDFieldListElement>> m_elements;
112 std::vector<unsigned> m_elementsOrder;
113 unsigned m_id, m_level;
114};
115
116} // namespace libvisio
117
118#endif // __VSDFIELDLIST_H__
119/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
VSDDocumentStructure.h
VSDTypes.h
libvisio::VSDCollector
Definition VSDCollector.h:21
libvisio::VSDFieldListElement
Definition VSDFieldList.h:26
libvisio::VSDFieldListElement::clone
virtual VSDFieldListElement * clone()=0
libvisio::VSDFieldListElement::VSDFieldListElement
VSDFieldListElement()
Definition VSDFieldList.h:28
libvisio::VSDFieldListElement::getString
virtual librevenge::RVNGString getString(const std::map< unsigned, librevenge::RVNGString > &, unsigned defaultUnit)=0
libvisio::VSDFieldListElement::handle
virtual void handle(VSDCollector *collector) const =0
libvisio::VSDFieldListElement::setValue
virtual void setValue(double)=0
libvisio::VSDFieldListElement::setNameId
virtual void setNameId(int)=0
libvisio::VSDFieldListElement::~VSDFieldListElement
virtual ~VSDFieldListElement()
Definition VSDFieldList.h:29
libvisio::VSDFieldListElement::setCellType
virtual void setCellType(unsigned short)=0
libvisio::VSDFieldListElement::setFormat
virtual void setFormat(unsigned short)=0
libvisio::VSDFieldList::getElement
VSDFieldListElement * getElement(unsigned index)
Definition VSDFieldList.cpp:552
libvisio::VSDFieldList::setElementsOrder
void setElementsOrder(const std::vector< unsigned > &m_elementsOrder)
Definition VSDFieldList.cpp:499
libvisio::VSDFieldList::addFieldList
void addFieldList(unsigned id, unsigned level)
Definition VSDFieldList.cpp:506
libvisio::VSDFieldList::~VSDFieldList
~VSDFieldList()
Definition VSDFieldList.cpp:495
libvisio::VSDFieldList::operator=
VSDFieldList & operator=(const VSDFieldList &fieldList)
Definition VSDFieldList.cpp:481
libvisio::VSDFieldList::VSDFieldList
VSDFieldList()
Definition VSDFieldList.cpp:463
libvisio::VSDFieldList::m_id
unsigned m_id
Definition VSDFieldList.h:113
libvisio::VSDFieldList::size
unsigned long size() const
Definition VSDFieldList.h:101
libvisio::VSDFieldList::addNumericField
void addNumericField(unsigned id, unsigned level, unsigned short format, unsigned short cellType, double number, int formatStringId)
Definition VSDFieldList.cpp:518
libvisio::VSDFieldList::empty
bool empty() const
Definition VSDFieldList.h:105
libvisio::VSDFieldList::clear
void clear()
Definition VSDFieldList.cpp:546
libvisio::VSDFieldList::addTextField
void addTextField(unsigned id, unsigned level, int nameId, int formatStringId)
Definition VSDFieldList.cpp:512
libvisio::VSDFieldList::addClonedField
void addClonedField(unsigned id)
libvisio::VSDFieldList::m_level
unsigned m_level
Definition VSDFieldList.h:113
libvisio::VSDFieldList::m_elements
std::map< unsigned, std::unique_ptr< VSDFieldListElement > > m_elements
Definition VSDFieldList.h:111
libvisio::VSDFieldList::handle
void handle(VSDCollector *collector) const
Definition VSDFieldList.cpp:524
libvisio::VSDFieldList::m_elementsOrder
std::vector< unsigned > m_elementsOrder
Definition VSDFieldList.h:112
libvisio::VSDNumericField::datetimeToString
librevenge::RVNGString datetimeToString(const char *format, double datetime)
Definition VSDFieldList.cpp:57
libvisio::VSDNumericField::m_level
unsigned m_level
Definition VSDFieldList.h:80
libvisio::VSDNumericField::m_formatStringId
int m_formatStringId
Definition VSDFieldList.h:84
libvisio::VSDNumericField::~VSDNumericField
~VSDNumericField() override
Definition VSDFieldList.h:70
libvisio::VSDNumericField::m_id
unsigned m_id
Definition VSDFieldList.h:80
libvisio::VSDNumericField::getString
librevenge::RVNGString getString(const std::map< unsigned, librevenge::RVNGString > &, unsigned defaultUnit) override
Definition VSDFieldList.cpp:225
libvisio::VSDNumericField::m_number
double m_number
Definition VSDFieldList.h:83
libvisio::VSDNumericField::setFormat
void setFormat(unsigned short format) override
Definition VSDFieldList.cpp:447
libvisio::VSDNumericField::setCellType
void setCellType(unsigned short cellType) override
Definition VSDFieldList.cpp:452
libvisio::VSDNumericField::m_cell_type
unsigned short m_cell_type
Definition VSDFieldList.h:82
libvisio::VSDNumericField::handle
void handle(VSDCollector *collector) const override
Definition VSDFieldList.cpp:45
libvisio::VSDNumericField::VSDNumericField
VSDNumericField(unsigned id, unsigned level, unsigned short format, unsigned short cellType, double number, int formatStringId)
Definition VSDFieldList.h:63
libvisio::VSDNumericField::setValue
void setValue(double number) override
Definition VSDFieldList.cpp:457
libvisio::VSDNumericField::setNameId
void setNameId(int) override
Definition VSDFieldList.h:74
libvisio::VSDNumericField::clone
VSDFieldListElement * clone() override
Definition VSDFieldList.cpp:50
libvisio::VSDNumericField::m_format
unsigned short m_format
Definition VSDFieldList.h:81
libvisio::VSDTextField::m_id
unsigned m_id
Definition VSDFieldList.h:56
libvisio::VSDTextField::clone
VSDFieldListElement * clone() override
Definition VSDFieldList.cpp:22
libvisio::VSDTextField::~VSDTextField
~VSDTextField() override
Definition VSDFieldList.h:47
libvisio::VSDTextField::handle
void handle(VSDCollector *collector) const override
Definition VSDFieldList.cpp:17
libvisio::VSDTextField::setNameId
void setNameId(int nameId) override
Definition VSDFieldList.cpp:39
libvisio::VSDTextField::m_nameId
int m_nameId
Definition VSDFieldList.h:57
libvisio::VSDTextField::getString
librevenge::RVNGString getString(const std::map< unsigned, librevenge::RVNGString > &strVec, unsigned defaultUnit) override
Definition VSDFieldList.cpp:27
libvisio::VSDTextField::setFormat
void setFormat(unsigned short) override
Definition VSDFieldList.h:52
libvisio::VSDTextField::m_formatStringId
int m_formatStringId
Definition VSDFieldList.h:57
libvisio::VSDTextField::VSDTextField
VSDTextField(unsigned id, unsigned level, int nameId, int formatStringId)
Definition VSDFieldList.h:42
libvisio::VSDTextField::m_level
unsigned m_level
Definition VSDFieldList.h:56
libvisio::VSDTextField::setValue
void setValue(double) override
Definition VSDFieldList.h:54
libvisio::VSDTextField::setCellType
void setCellType(unsigned short) override
Definition VSDFieldList.h:53
libvisio
Definition libvisio_utils.h:49