VSDFieldList.h
Go to the documentation of this file.
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* This file is part of the libvisio project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef __VSDFIELDLIST_H__
#define __VSDFIELDLIST_H__
#include <memory>
#include <vector>
#include <map>
#include <librevenge/librevenge.h>
#include "VSDDocumentStructure.h"
#include "VSDTypes.h"
namespace libvisio
{
class VSDCollector;
class VSDFieldListElement
{
public:
VSDFieldListElement() {}
virtual ~VSDFieldListElement() {}
virtual void handle(VSDCollector *collector) const = 0;
virtual VSDFieldListElement *clone() = 0;
virtual librevenge::RVNGString getString(const std::map<unsigned, librevenge::RVNGString> &, unsigned defaultUnit) = 0;
virtual void setNameId(int) = 0;
virtual void setFormat(unsigned short) = 0;
virtual void setCellType(unsigned short) = 0;
virtual void setValue(double) = 0;
};
class VSDTextField : public VSDFieldListElement
{
public:
VSDTextField(unsigned id, unsigned level, int nameId, int formatStringId)
: m_id(id),
m_level(level),
m_nameId(nameId),
m_formatStringId(formatStringId) {}
~VSDTextField() override {}
void handle(VSDCollector *collector) const override;
VSDFieldListElement *clone() override;
librevenge::RVNGString getString(const std::map<unsigned, librevenge::RVNGString> &strVec, unsigned defaultUnit) override;
void setNameId(int nameId) override;
void setFormat(unsigned short) override {}
void setCellType(unsigned short) override {}
void setValue(double) override {}
private:
unsigned m_id, m_level;
int m_nameId, m_formatStringId;
};
class VSDNumericField : public VSDFieldListElement
{
public:
VSDNumericField(unsigned id, unsigned level, unsigned short format, unsigned short cellType, double number, int formatStringId)
: m_id(id),
m_level(level),
m_format(format),
m_cell_type(cellType),
m_number(number),
m_formatStringId(formatStringId) {}
~VSDNumericField() override {}
void handle(VSDCollector *collector) const override;
VSDFieldListElement *clone() override;
librevenge::RVNGString getString(const std::map<unsigned, librevenge::RVNGString> &, unsigned defaultUnit) override;
void setNameId(int) override {}
void setFormat(unsigned short format) override;
void setCellType(unsigned short cellType) override;
void setValue(double number) override;
private:
librevenge::RVNGString datetimeToString(const char *format, double datetime);
unsigned m_id, m_level;
unsigned short m_format;
unsigned short m_cell_type;
double m_number;
int m_formatStringId;
};
class VSDFieldList
{
public:
VSDFieldList();
VSDFieldList(const VSDFieldList &fieldList);
~VSDFieldList();
VSDFieldList &operator=(const VSDFieldList &fieldList);
void setElementsOrder(const std::vector<unsigned> &m_elementsOrder);
void addFieldList(unsigned id, unsigned level);
void addTextField(unsigned id, unsigned level, int nameId, int formatStringId);
void addNumericField(unsigned id, unsigned level, unsigned short format, unsigned short cellType, double number, int formatStringId);
void addClonedField(unsigned id);
void handle(VSDCollector *collector) const;
void clear();
unsigned long size() const
{
return (unsigned long)m_elements.size();
}
bool empty() const
{
return (m_elements.empty());
}
VSDFieldListElement *getElement(unsigned index);
private:
std::map<unsigned, std::unique_ptr<VSDFieldListElement>> m_elements;
std::vector<unsigned> m_elementsOrder;
unsigned m_id, m_level;
};
} // namespace libvisio
#endif // __VSDFIELDLIST_H__
/* 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:591
libvisio::VSDFieldList::setElementsOrder
void setElementsOrder(const std::vector< unsigned > &m_elementsOrder)
Definition VSDFieldList.cpp:538
libvisio::VSDFieldList::addFieldList
void addFieldList(unsigned id, unsigned level)
Definition VSDFieldList.cpp:545
libvisio::VSDFieldList::~VSDFieldList
~VSDFieldList()
Definition VSDFieldList.cpp:534
libvisio::VSDFieldList::operator=
VSDFieldList & operator=(const VSDFieldList &fieldList)
Definition VSDFieldList.cpp:520
libvisio::VSDFieldList::VSDFieldList
VSDFieldList()
Definition VSDFieldList.cpp:502
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:557
libvisio::VSDFieldList::empty
bool empty() const
Definition VSDFieldList.h:105
libvisio::VSDFieldList::clear
void clear()
Definition VSDFieldList.cpp:585
libvisio::VSDFieldList::addTextField
void addTextField(unsigned id, unsigned level, int nameId, int formatStringId)
Definition VSDFieldList.cpp:551
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:563
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:229
libvisio::VSDNumericField::m_number
double m_number
Definition VSDFieldList.h:83
libvisio::VSDNumericField::setFormat
void setFormat(unsigned short format) override
Definition VSDFieldList.cpp:486
libvisio::VSDNumericField::setCellType
void setCellType(unsigned short cellType) override
Definition VSDFieldList.cpp:491
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:496
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:47