diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2011-11-04 14:32:14 +0100 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2011-11-04 14:32:14 +0100 |
commit | 1e836a75900a51f6230d201214a310892834a76a (patch) | |
tree | a4e2e07a3f87d776a71b924e4a4179a3151137fd | |
parent | 7b2e2107d1eb14c85e40b234b21cfdc0d86d31a3 (diff) |
Laying foundation for the support of Text Fields
-rw-r--r-- | src/lib/Makefile.am | 2 | ||||
-rw-r--r-- | src/lib/VSDXFieldList.cpp | 164 | ||||
-rw-r--r-- | src/lib/VSDXFieldList.h | 65 | ||||
-rw-r--r-- | src/lib/makefile.mk | 1 |
4 files changed, 232 insertions, 0 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index c74cb95..4c4017d 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -27,6 +27,7 @@ libvisio_@VSD_MAJOR_VERSION@_@VSD_MINOR_VERSION@_la_SOURCES = \ VSDXCharacterList.cpp \ VSDXCollector.cpp \ VSDXContentCollector.cpp \ + VSDXFieldList.cpp \ VSDXGeometryList.cpp \ VSDXOutputElementList.cpp \ VSDXPages.cpp \ @@ -45,6 +46,7 @@ libvisio_@VSD_MAJOR_VERSION@_@VSD_MINOR_VERSION@_la_SOURCES = \ VSDXCollector.h \ VSDXContentCollector.h \ VSDXDocumentStructure.h \ + VSDXFieldList.h \ VSDXGeometryList.h \ VSDXOutputElementList.h \ VSDXPages.h \ diff --git a/src/lib/VSDXFieldList.cpp b/src/lib/VSDXFieldList.cpp new file mode 100644 index 0000000..7b6ea04 --- /dev/null +++ b/src/lib/VSDXFieldList.cpp @@ -0,0 +1,164 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libvisio + * Version: MPL 1.1 / GPLv2+ / LGPLv2+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch> + * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com> + * + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPLv2+"), or + * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), + * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable + * instead of those above. + */ + +#include "VSDXCollector.h" +#include "VSDXFieldList.h" + +namespace libvisio +{ + +class VSDXFieldListElement +{ +public: + VSDXFieldListElement() {} + virtual ~VSDXFieldListElement() {} + virtual VSDXFieldListElement *clone() = 0; +}; + +class VSDXTextField : public VSDXFieldListElement +{ +public: + VSDXTextField(unsigned id, unsigned level) : m_id(id), m_level(level) {} + ~VSDXTextField() {} + void handle(VSDXCollector *collector); + VSDXFieldListElement *clone(); +private: + unsigned m_id, m_level; +}; + +class VSDXNumericField : public VSDXFieldListElement +{ +public: + VSDXNumericField(unsigned id, unsigned level) : m_id(id), m_level(level) {} + ~VSDXNumericField() {} + void handle(VSDXCollector *collector); + VSDXFieldListElement *clone(); +private: + unsigned m_id, m_level; +}; + +class VSDXGenericField : public VSDXFieldListElement +{ +public: + VSDXGenericField(unsigned id, unsigned level) : m_id(id), m_level(level) {} + ~VSDXGenericField() {} + void handle(VSDXCollector *collector); + VSDXFieldListElement *clone(); +private: + unsigned m_id, m_level; +}; +} // namespace libvisio + + + +void libvisio::VSDXTextField::handle(VSDXCollector *collector) +{ +} + +libvisio::VSDXFieldListElement *libvisio::VSDXTextField::clone() +{ + return new VSDXTextField(m_id, m_level); +} + + +void libvisio::VSDXNumericField::handle(VSDXCollector *collector) +{ +} + +libvisio::VSDXFieldListElement *libvisio::VSDXNumericField::clone() +{ + return new VSDXTextField(m_id, m_level); +} + + +void libvisio::VSDXGenericField::handle(VSDXCollector *collector) +{ +} + +libvisio::VSDXFieldListElement *libvisio::VSDXGenericField::clone() +{ + return new VSDXGenericField(m_id, m_level); +} + + +libvisio::VSDXFieldList::VSDXFieldList() : + m_elements(), + m_elementsOrder() +{ +} + +libvisio::VSDXFieldList::VSDXFieldList(const libvisio::VSDXFieldList &fieldList) : + m_elements(), + m_elementsOrder(fieldList.m_elementsOrder) +{ + std::map<unsigned, VSDXFieldListElement *>::const_iterator iter = fieldList.m_elements.begin(); + for (; iter != fieldList.m_elements.end(); iter++) + m_elements[iter->first] = iter->second->clone(); +} + +libvisio::VSDXFieldList &libvisio::VSDXFieldList::operator=(const libvisio::VSDXFieldList &fieldList) +{ + clear(); + std::map<unsigned, VSDXFieldListElement *>::const_iterator iter = fieldList.m_elements.begin(); + for (; iter != fieldList.m_elements.end(); iter++) + m_elements[iter->first] = iter->second->clone(); + m_elementsOrder = fieldList.m_elementsOrder; + return *this; +} + +libvisio::VSDXFieldList::~VSDXFieldList() +{ + clear(); +} + +void libvisio::VSDXFieldList::setElementsOrder(const std::vector<unsigned> &elementsOrder) +{ + m_elementsOrder.clear(); + for (unsigned i = 0; i<elementsOrder.size(); i++) + m_elementsOrder.push_back(elementsOrder[i]); +} + +void libvisio::VSDXFieldList::clear() +{ + for (std::map<unsigned, VSDXFieldListElement *>::iterator iter = m_elements.begin(); iter != m_elements.end(); iter++) + delete iter->second; + m_elements.clear(); + m_elementsOrder.clear(); +} + +libvisio::VSDXFieldListElement *libvisio::VSDXFieldList::getElement(unsigned index) +{ + std::map<unsigned, VSDXFieldListElement *>::iterator iter = m_elements.find(index); + if (iter != m_elements.end()) + return iter->second; + else + return 0; +} +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXFieldList.h b/src/lib/VSDXFieldList.h new file mode 100644 index 0000000..a5957d0 --- /dev/null +++ b/src/lib/VSDXFieldList.h @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libvisio + * Version: MPL 1.1 / GPLv2+ / LGPLv2+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch> + * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com> + * + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPLv2+"), or + * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), + * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable + * instead of those above. + */ + +#ifndef __VSDXFIELDLIST_H__ +#define __VSDXFIELDLIST_H__ + +#include <vector> +#include <map> + +namespace libvisio +{ + +class VSDXFieldListElement; +class VSDXCollector; + +class VSDXFieldList +{ +public: + VSDXFieldList(); + VSDXFieldList(const VSDXFieldList ¶List); + ~VSDXFieldList(); + VSDXFieldList &operator=(const VSDXFieldList ¶List); + void setElementsOrder(const std::vector<unsigned> &m_elementsOrder); + void clear(); + bool empty() const + { + return (!m_elements.size()); + } + VSDXFieldListElement *getElement(unsigned index); +private: + std::map<unsigned, VSDXFieldListElement *> m_elements; + std::vector<unsigned> m_elementsOrder; +}; + +} // namespace libvisio + +#endif // __VSDXFIELDLIST_H__ +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/makefile.mk b/src/lib/makefile.mk index f155982..16c325c 100644 --- a/src/lib/makefile.mk +++ b/src/lib/makefile.mk @@ -39,6 +39,7 @@ SLOFILES= \ $(SLO)$/VSDXCollector.obj \ $(SLO)$/VSDXContentCollector.obj \ $(SLO)$/VSDXGeometryList.obj \ + $(SLO)$/VSDXFieldList.obj \ $(SLO)$/VSDXOutputElementList.obj \ $(SLO)$/VSDXPages.obj \ $(SLO)$/VSDXParagraphList.obj \ |