diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/VSDXCollector.h | 7 | ||||
-rw-r--r-- | src/lib/VSDXContentCollector.cpp | 14 | ||||
-rw-r--r-- | src/lib/VSDXContentCollector.h | 7 | ||||
-rw-r--r-- | src/lib/VSDXFieldList.cpp | 80 | ||||
-rw-r--r-- | src/lib/VSDXFieldList.h | 15 | ||||
-rw-r--r-- | src/lib/VSDXParser.cpp | 23 | ||||
-rw-r--r-- | src/lib/VSDXStylesCollector.cpp | 11 | ||||
-rw-r--r-- | src/lib/VSDXStylesCollector.h | 7 |
8 files changed, 65 insertions, 99 deletions
diff --git a/src/lib/VSDXCollector.h b/src/lib/VSDXCollector.h index 5a8d077..3b8a5e2 100644 --- a/src/lib/VSDXCollector.h +++ b/src/lib/VSDXCollector.h @@ -111,10 +111,9 @@ public: // Field list virtual void collectFieldList(unsigned id, unsigned level, const std::vector<unsigned> &fieldsOrder) = 0; - virtual void collectTextField(unsigned id, unsigned level, unsigned nameId) = 0; - virtual void collectNumericField(unsigned id, unsigned level, unsigned format, double number) = 0; - virtual void collectDatetimeField(unsigned id, unsigned level, unsigned format, unsigned long timeValue) = 0; - virtual void collectEmptyField(unsigned id, unsigned level) = 0; + virtual void collectTextField(unsigned id, unsigned level, int format, int nameId) = 0; + virtual void collectNumericField(unsigned id, unsigned level, int format, double number) = 0; + virtual void collectDatetimeField(unsigned id, unsigned level, int format, double timeValue) = 0; // Temporary hack virtual void startPage() = 0; diff --git a/src/lib/VSDXContentCollector.cpp b/src/lib/VSDXContentCollector.cpp index 7745231..25a9d86 100644 --- a/src/lib/VSDXContentCollector.cpp +++ b/src/lib/VSDXContentCollector.cpp @@ -1862,30 +1862,24 @@ void libvisio::VSDXContentCollector::collectFieldList(unsigned /* id */, unsigne m_fields.setElementsOrder(fieldsOrder); } -void libvisio::VSDXContentCollector::collectTextField(unsigned id, unsigned level, unsigned nameId) +void libvisio::VSDXContentCollector::collectTextField(unsigned id, unsigned level, int format, int nameId) { _handleLevelChange(level); - m_fields.addTextField(id, level, nameId); + m_fields.addTextField(id, level, format, nameId); } -void libvisio::VSDXContentCollector::collectNumericField(unsigned id, unsigned level, unsigned format, double number) +void libvisio::VSDXContentCollector::collectNumericField(unsigned id, unsigned level, int format, double number) { _handleLevelChange(level); m_fields.addNumericField(id, level, format, number); } -void libvisio::VSDXContentCollector::collectDatetimeField(unsigned id, unsigned level, unsigned format, unsigned long timeValue) +void libvisio::VSDXContentCollector::collectDatetimeField(unsigned id, unsigned level, int format, double timeValue) { _handleLevelChange(level); m_fields.addDatetimeField(id, level, format, timeValue); } -void libvisio::VSDXContentCollector::collectEmptyField(unsigned id, unsigned level) -{ - _handleLevelChange(level); - m_fields.addClonedField(id); -} - void libvisio::VSDXContentCollector::_handleLevelChange(unsigned level) { diff --git a/src/lib/VSDXContentCollector.h b/src/lib/VSDXContentCollector.h index 03c192f..b3fda32 100644 --- a/src/lib/VSDXContentCollector.h +++ b/src/lib/VSDXContentCollector.h @@ -132,10 +132,9 @@ public: // Field list void collectFieldList(unsigned id, unsigned level, const std::vector<unsigned> &fieldsOrder); - void collectTextField(unsigned id, unsigned level, unsigned nameId); - void collectNumericField(unsigned id, unsigned level, unsigned format, double number); - void collectDatetimeField(unsigned id, unsigned level, unsigned format, unsigned long timeValue); - void collectEmptyField(unsigned id, unsigned level); + void collectTextField(unsigned id, unsigned level, int format, int nameId); + void collectNumericField(unsigned id, unsigned level, int format, double number); + void collectDatetimeField(unsigned id, unsigned level, int format, double timeValue); void startPage(); void endPage(); diff --git a/src/lib/VSDXFieldList.cpp b/src/lib/VSDXFieldList.cpp index ec7f196..4721a51 100644 --- a/src/lib/VSDXFieldList.cpp +++ b/src/lib/VSDXFieldList.cpp @@ -39,28 +39,30 @@ namespace libvisio class VSDXTextField : public VSDXFieldListElement { public: - VSDXTextField(unsigned id, unsigned level, unsigned nameId) + VSDXTextField(unsigned id, unsigned level, int format, int nameId) : m_id(id), m_level(level), + m_format(format), m_nameId(nameId) {} ~VSDXTextField() {} void handle(VSDXCollector *collector); VSDXFieldListElement *clone(); WPXString getString(const std::vector<WPXString> &strVec) { - if (m_nameId >= strVec.size()) + if (m_nameId < 0 || (unsigned)m_nameId >= strVec.size()) return WPXString(); else return strVec[m_nameId]; } private: - unsigned m_id, m_level, m_nameId; + unsigned m_id, m_level; + int m_format, m_nameId; }; class VSDXNumericField : public VSDXFieldListElement { public: - VSDXNumericField(unsigned id, unsigned level, unsigned format, double number) + VSDXNumericField(unsigned id, unsigned level, int format, double number) : m_id(id), m_level(level), m_format(format), @@ -80,7 +82,8 @@ public: return result; } private: - unsigned m_id, m_level, m_format; + unsigned m_id, m_level; + int m_format; double m_number; }; @@ -89,7 +92,7 @@ private: class VSDXDatetimeField : public VSDXFieldListElement { public: - VSDXDatetimeField(unsigned id, unsigned level, unsigned format, unsigned long timeValue) + VSDXDatetimeField(unsigned id, unsigned level, unsigned format, double timeValue) : m_id(id), m_level(level), m_format(format), @@ -111,21 +114,9 @@ public: return datetimeToString("%x %X", m_timeValue); } private: - unsigned m_id, m_level, m_format; - unsigned long m_timeValue; -}; - -class VSDXEmptyField : public VSDXFieldListElement -{ -public: - VSDXEmptyField(unsigned id, unsigned level) - : m_id(id), - m_level(level) {} - ~VSDXEmptyField() {} - void handle(VSDXCollector *collector); - VSDXFieldListElement *clone(); -private: unsigned m_id, m_level; + int m_format; + double m_timeValue; }; } // namespace libvisio @@ -134,12 +125,12 @@ private: void libvisio::VSDXTextField::handle(VSDXCollector *collector) { - collector->collectTextField(m_id, m_level, m_nameId); + collector->collectTextField(m_id, m_level, m_format, m_nameId); } libvisio::VSDXFieldListElement *libvisio::VSDXTextField::clone() { - return new VSDXTextField(m_id, m_level, m_nameId); + return new VSDXTextField(m_id, m_level, m_format, m_nameId); } @@ -165,22 +156,12 @@ libvisio::VSDXFieldListElement *libvisio::VSDXDatetimeField::clone() } -void libvisio::VSDXEmptyField::handle(VSDXCollector *collector) -{ - collector->collectEmptyField(m_id, m_level); -} - -libvisio::VSDXFieldListElement *libvisio::VSDXEmptyField::clone() -{ - return new VSDXEmptyField(m_id, m_level); -} - - libvisio::VSDXFieldList::VSDXFieldList() : m_elements(), m_elementsOrder(), m_id(0), - m_level(0) + m_level(0), + m_initialized(false) { } @@ -188,7 +169,8 @@ libvisio::VSDXFieldList::VSDXFieldList(const libvisio::VSDXFieldList &fieldList) m_elements(), m_elementsOrder(fieldList.m_elementsOrder), m_id(fieldList.m_id), - m_level(fieldList.m_level) + m_level(fieldList.m_level), + m_initialized(fieldList.m_initialized) { std::map<unsigned, VSDXFieldListElement *>::const_iterator iter = fieldList.m_elements.begin(); for (; iter != fieldList.m_elements.end(); iter++) @@ -204,6 +186,7 @@ libvisio::VSDXFieldList &libvisio::VSDXFieldList::operator=(const libvisio::VSDX m_elementsOrder = fieldList.m_elementsOrder; m_id = fieldList.m_id; m_level = fieldList.m_level; + m_initialized = fieldList.m_initialized; return *this; } @@ -219,43 +202,28 @@ void libvisio::VSDXFieldList::setElementsOrder(const std::vector<unsigned> &elem m_elementsOrder.push_back(elementsOrder[i]); } -void libvisio::VSDXFieldList::setId(unsigned id) +void libvisio::VSDXFieldList::addFieldList(unsigned id, unsigned level) { m_id = id; -} - -void libvisio::VSDXFieldList::setLevel(unsigned level) -{ m_level = level; + m_initialized = true; } -void libvisio::VSDXFieldList::addTextField(unsigned id, unsigned level, unsigned nameId) +void libvisio::VSDXFieldList::addTextField(unsigned id, unsigned level, int format, int nameId) { - m_elements[id] = new VSDXTextField(id, level, nameId); + m_elements[id] = new VSDXTextField(id, level, format, nameId); } -void libvisio::VSDXFieldList::addNumericField(unsigned id, unsigned level, unsigned format, double number) +void libvisio::VSDXFieldList::addNumericField(unsigned id, unsigned level, int format, double number) { m_elements[id] = new VSDXNumericField(id, level, format, number); } -void libvisio::VSDXFieldList::addDatetimeField(unsigned id, unsigned level, unsigned format, unsigned long timeValue) +void libvisio::VSDXFieldList::addDatetimeField(unsigned id, unsigned level, int format, double timeValue) { m_elements[id] = new VSDXDatetimeField(id, level, format, timeValue); } -void libvisio::VSDXFieldList::addEmptyField(unsigned id, unsigned level) -{ - m_elements[id] = new VSDXEmptyField(id, level); -} - -void libvisio::VSDXFieldList::addClonedField(unsigned id) -{ - VSDXFieldListElement *element = getElement(id); - if (element) - m_elements[id] = element->clone(); -} - void libvisio::VSDXFieldList::handle(VSDXCollector *collector) { if (empty()) diff --git a/src/lib/VSDXFieldList.h b/src/lib/VSDXFieldList.h index 737c147..c166ae8 100644 --- a/src/lib/VSDXFieldList.h +++ b/src/lib/VSDXFieldList.h @@ -62,12 +62,10 @@ public: ~VSDXFieldList(); VSDXFieldList &operator=(const VSDXFieldList &fieldList); void setElementsOrder(const std::vector<unsigned> &m_elementsOrder); - void setId(unsigned id); - void setLevel(unsigned level); - void addTextField(unsigned id, unsigned level, unsigned nameId); - void addNumericField(unsigned id, unsigned level, unsigned format, double number); - void addDatetimeField(unsigned id, unsigned level, unsigned format, unsigned long timeValue); - void addEmptyField(unsigned id, unsigned level); + void addFieldList(unsigned id, unsigned level); + void addTextField(unsigned id, unsigned level, int format, int nameId); + void addNumericField(unsigned id, unsigned level, int format, double number); + void addDatetimeField(unsigned id, unsigned level, int format, double timeValue); void addClonedField(unsigned id); void handle(VSDXCollector *collector); void clear(); @@ -79,11 +77,16 @@ public: { return (!m_elements.size()); } + bool initialized() const + { + return m_initialized; + } VSDXFieldListElement *getElement(unsigned index); private: std::map<unsigned, VSDXFieldListElement *> m_elements; std::vector<unsigned> m_elementsOrder; unsigned m_id, m_level; + bool m_initialized; }; } // namespace libvisio diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp index a2331b3..202ad2f 100644 --- a/src/lib/VSDXParser.cpp +++ b/src/lib/VSDXParser.cpp @@ -594,7 +594,13 @@ void libvisio::VSDXParser::_handleLevelChange(unsigned level) delete *iter3; } m_paraListVector.clear(); - if (!m_fieldList.empty()) + if (m_fieldList.empty() && m_fieldList.initialized()) + { + m_fieldList.handle(m_collector); + m_fieldList.clear(); + m_nameList.clear(); + } + else if (!m_fieldList.empty()) { if (!m_nameList.empty()) m_nameList.handle(m_collector); @@ -602,6 +608,7 @@ void libvisio::VSDXParser::_handleLevelChange(unsigned level) m_fieldList.clear(); } m_nameList.clear(); + } m_currentLevel = level; } @@ -1566,8 +1573,7 @@ void libvisio::VSDXParser::readFieldList(WPXInputStream *input) else { m_fieldList.setElementsOrder(fieldOrder); - m_fieldList.setId(m_header.id); - m_fieldList.setLevel(m_header.level); + m_fieldList.addFieldList(m_header.id, m_header.level); // We want the collectors to still get the level information m_collector->collectUnhandledChunk(m_header.id, m_header.level); } @@ -1579,20 +1585,23 @@ void libvisio::VSDXParser::readTextField(WPXInputStream *input) unsigned char tmpCode = readU8(input); if (tmpCode == 0xe8) { - int nameId = readU32(input); + int nameId = (int)readU32(input); if (nameId >= 0) { + input->seek(6, WPX_SEEK_CUR); + int formatId = (int)readU32(input); if (m_isStencilStarted) - m_stencilShape.m_fields.addTextField(m_header.id, m_header.level, (unsigned)nameId); + m_stencilShape.m_fields.addTextField(m_header.id, m_header.level, formatId, nameId); else - m_fieldList.addTextField(m_header.id, m_header.level, (unsigned)nameId); + m_fieldList.addTextField(m_header.id, m_header.level, formatId, nameId); } } else { double numericValue = readDouble(input); input->seek(2, WPX_SEEK_CUR); - unsigned formatId = readU32(input); + int formatId = (int)readU32(input); + printf("Fridrich is a good guy 2 %i\n", formatId); if (tmpCode == 0x28) { if (m_isStencilStarted) diff --git a/src/lib/VSDXStylesCollector.cpp b/src/lib/VSDXStylesCollector.cpp index 9720ebd..70fdec2 100644 --- a/src/lib/VSDXStylesCollector.cpp +++ b/src/lib/VSDXStylesCollector.cpp @@ -349,22 +349,17 @@ void libvisio::VSDXStylesCollector::collectFieldList(unsigned /* id */, unsigned _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectTextField(unsigned /* id */, unsigned level, unsigned /* nameId */) +void libvisio::VSDXStylesCollector::collectTextField(unsigned /* id */, unsigned level, int /* format */, int /* nameId */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectNumericField(unsigned /* id */, unsigned level, unsigned /* format */, double /* number */) +void libvisio::VSDXStylesCollector::collectNumericField(unsigned /* id */, unsigned level, int /* format */, double /* number */) { _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectDatetimeField(unsigned /* id */, unsigned level, unsigned /* format */, unsigned long /* timeValue */) -{ - _handleLevelChange(level); -} - -void libvisio::VSDXStylesCollector::collectEmptyField(unsigned /* id */, unsigned level) +void libvisio::VSDXStylesCollector::collectDatetimeField(unsigned /* id */, unsigned level, int /* format */, double /* timeValue */) { _handleLevelChange(level); } diff --git a/src/lib/VSDXStylesCollector.h b/src/lib/VSDXStylesCollector.h index 54c1427..6a11404 100644 --- a/src/lib/VSDXStylesCollector.h +++ b/src/lib/VSDXStylesCollector.h @@ -122,10 +122,9 @@ public: // Field list void collectFieldList(unsigned id, unsigned level, const std::vector<unsigned> &fieldsOrder); - void collectTextField(unsigned id, unsigned level, unsigned nameId); - void collectNumericField(unsigned id, unsigned level, unsigned format, double number); - void collectDatetimeField(unsigned id, unsigned level, unsigned format, unsigned long timeValue); - void collectEmptyField(unsigned id, unsigned level); + void collectTextField(unsigned id, unsigned level, int format, int nameId); + void collectNumericField(unsigned id, unsigned level, int format, double number); + void collectDatetimeField(unsigned id, unsigned level, int format, double timeValue); // Temporary hack void startPage(); |