summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/VSD11Parser.cpp32
-rw-r--r--src/lib/VSD11Parser.h1
-rw-r--r--src/lib/VSD6Parser.cpp15
-rw-r--r--src/lib/VSD6Parser.h1
-rw-r--r--src/lib/VSDXCharacterList.cpp25
-rw-r--r--src/lib/VSDXCharacterList.h2
-rw-r--r--src/lib/VSDXCollector.h4
-rw-r--r--src/lib/VSDXContentCollector.cpp168
-rw-r--r--src/lib/VSDXContentCollector.h7
-rw-r--r--src/lib/VSDXDocumentStructure.h2
-rw-r--r--src/lib/VSDXOutputElementList.cpp47
-rw-r--r--src/lib/VSDXOutputElementList.h2
-rw-r--r--src/lib/VSDXParser.cpp99
-rw-r--r--src/lib/VSDXParser.h2
-rw-r--r--src/lib/VSDXStylesCollector.cpp7
-rw-r--r--src/lib/VSDXStylesCollector.h4
-rw-r--r--src/lib/VSDXTypes.h12
17 files changed, 298 insertions, 132 deletions
diff --git a/src/lib/VSD11Parser.cpp b/src/lib/VSD11Parser.cpp
index 4f2cb51..d3b5bf9 100644
--- a/src/lib/VSD11Parser.cpp
+++ b/src/lib/VSD11Parser.cpp
@@ -94,14 +94,36 @@ bool libvisio::VSD11Parser::getChunkHeader(WPXInputStream *input)
void libvisio::VSD11Parser::readText(WPXInputStream *input)
{
input->seek(8, WPX_SEEK_CUR);
- WPXString text;
- text.clear();
+ std::vector<uint8_t> textStream;
// Read up to end of chunk in byte pairs (except from last 2 bytes)
- for (unsigned bytesRead = 8; bytesRead < m_header.dataLength-2; bytesRead+=2)
- _appendUTF16LE(text, readU16(input));
+ for (unsigned bytesRead = 8; bytesRead < m_header.dataLength-2; bytesRead++)
+ textStream.push_back(readU8(input));
+
+ m_collector->collectText(m_header.id, m_header.level, textStream, libvisio::VSD_TEXT_UTF16);
+}
+
+void libvisio::VSD11Parser::readCharIX(WPXInputStream *input)
+{
+ WPXString fontFace = "Arial";
+ unsigned charCount = readU32(input);
+
+ input->seek(7, WPX_SEEK_CUR);
+
+ unsigned short fontMod = readU8(input);
+ bool bold = false; bool italic = false; bool underline = false;
+ if (fontMod & 1) bold = true;
+ if (fontMod & 2) italic = true;
+ if (fontMod & 4) underline = true;
+
+ input->seek(6, WPX_SEEK_CUR);
+ double fontSize = readDouble(input);
+
+ input->seek(43, WPX_SEEK_CUR);
+ unsigned langId = readU32(input);
+
+ m_charList->addCharIX(m_header.id, m_header.level, charCount, langId, fontSize, bold, italic, underline, fontFace);
- m_charList->addText(m_header.id, m_header.level, text);
}
void libvisio::VSD11Parser::readFillAndShadow(WPXInputStream *input)
diff --git a/src/lib/VSD11Parser.h b/src/lib/VSD11Parser.h
index 6e52354..8d24a01 100644
--- a/src/lib/VSD11Parser.h
+++ b/src/lib/VSD11Parser.h
@@ -39,6 +39,7 @@ public:
private:
bool getChunkHeader(WPXInputStream *input);
void readText(WPXInputStream *input);
+ void readCharIX(WPXInputStream *input);
void readFillAndShadow(WPXInputStream *input);
VSD11Parser();
diff --git a/src/lib/VSD6Parser.cpp b/src/lib/VSD6Parser.cpp
index c5ee01b..521a897 100644
--- a/src/lib/VSD6Parser.cpp
+++ b/src/lib/VSD6Parser.cpp
@@ -73,12 +73,21 @@ bool libvisio::VSD6Parser::getChunkHeader(WPXInputStream *input)
void libvisio::VSD6Parser::readText(WPXInputStream *input)
{
input->seek(8, WPX_SEEK_CUR);
- WPXString text;
+ std::vector<uint8_t> textStream;
for (unsigned bytesRead = 8; bytesRead < m_header.dataLength-1; bytesRead++)
- text.append(readU8(input));
+ textStream.push_back(readU8(input));
+
+ m_collector->collectText(m_header.id, m_header.level, textStream, VSD_TEXT_ANSI);
+}
+
+void libvisio::VSD6Parser::readCharIX(WPXInputStream *input)
+{
+ WPXString fontFace = "Arial";
+ unsigned charCount = readU32(input);
+
+ m_charList->addCharIX(m_header.id, m_header.level, charCount, 0, 0.1667, false, false, false, fontFace);
- m_charList->addText(m_header.id, m_header.level, text);
}
void libvisio::VSD6Parser::readFillAndShadow(WPXInputStream *input)
diff --git a/src/lib/VSD6Parser.h b/src/lib/VSD6Parser.h
index 4c9335d..8e020ed 100644
--- a/src/lib/VSD6Parser.h
+++ b/src/lib/VSD6Parser.h
@@ -39,6 +39,7 @@ public:
private:
bool getChunkHeader(WPXInputStream *input);
void readText(WPXInputStream *input);
+ void readCharIX(WPXInputStream *input);
void readFillAndShadow(WPXInputStream *input);
VSD6Parser();
diff --git a/src/lib/VSDXCharacterList.cpp b/src/lib/VSDXCharacterList.cpp
index 25227a5..e2d4096 100644
--- a/src/lib/VSDXCharacterList.cpp
+++ b/src/lib/VSDXCharacterList.cpp
@@ -30,23 +30,30 @@ public:
virtual void handle(VSDXCollector *collector) = 0;
};
-class VSDXText : public VSDXCharacterListElement
+class VSDXCharIX : public VSDXCharacterListElement
{
public:
- VSDXText(unsigned id , unsigned level, const WPXString &text) :
- m_id(id), m_level(level), m_text(text) {}
- ~VSDXText() {}
+ VSDXCharIX(unsigned id , unsigned level, unsigned charCount, unsigned langId,
+ double fontSize, bool bold, bool italic, bool underline,
+ WPXString fontFace) :
+ m_id(id), m_level(level), m_charCount(charCount), m_langId(langId),
+ m_fontSize(fontSize), m_bold(bold), m_italic(italic),
+ m_underline(underline), m_fontFace(fontFace) {}
+ ~VSDXCharIX() {}
void handle(VSDXCollector *collector);
private:
unsigned m_id, m_level;
- const WPXString m_text;
+ unsigned m_charCount, m_langId;
+ double m_fontSize;
+ bool m_bold, m_italic, m_underline;
+ WPXString m_fontFace;
};
} // namespace libvisio
-void libvisio::VSDXText::handle(VSDXCollector *collector)
+void libvisio::VSDXCharIX::handle(VSDXCollector *collector)
{
- collector->collectText(m_id, m_level, m_text);
+ collector->collectCharFormat(m_id, m_level, m_charCount, m_langId, m_fontSize, m_bold, m_italic, m_underline, m_fontFace);
}
libvisio::VSDXCharacterList::VSDXCharacterList()
@@ -58,9 +65,9 @@ libvisio::VSDXCharacterList::~VSDXCharacterList()
clear();
}
-void libvisio::VSDXCharacterList::addText(unsigned id, unsigned level, const WPXString &text)
+void libvisio::VSDXCharacterList::addCharIX(unsigned id, unsigned level, unsigned charCount, unsigned langId, double fontSize, bool bold, bool italic, bool underline, WPXString fontFace)
{
- m_elements[id] = new VSDXText(id, level, text);
+ m_elements[id] = new VSDXCharIX(id, level, charCount, langId, fontSize, bold, italic, underline, fontFace);
}
void libvisio::VSDXCharacterList::setElementsOrder(const std::vector<unsigned> &elementsOrder)
diff --git a/src/lib/VSDXCharacterList.h b/src/lib/VSDXCharacterList.h
index d1e4593..4929048 100644
--- a/src/lib/VSDXCharacterList.h
+++ b/src/lib/VSDXCharacterList.h
@@ -34,7 +34,7 @@ class VSDXCharacterList
public:
VSDXCharacterList();
~VSDXCharacterList();
- void addText(unsigned id, unsigned level, const WPXString &text);
+ void addCharIX(unsigned id, unsigned level, unsigned charCount, unsigned langId, double fontSize, bool bold, bool italic, bool underline, WPXString fontFace);
void setElementsOrder(const std::vector<unsigned> &m_elementsOrder);
void handle(VSDXCollector *collector);
void clear();
diff --git a/src/lib/VSDXCollector.h b/src/lib/VSDXCollector.h
index 6e5b98f..ba751d5 100644
--- a/src/lib/VSDXCollector.h
+++ b/src/lib/VSDXCollector.h
@@ -22,6 +22,7 @@
#define VSDXCOLLECTOR_H
#include <vector>
+#include <stdint.h>
#include "VSDXParser.h"
namespace libvisio {
@@ -62,7 +63,8 @@ public:
virtual void collectColours(const std::vector<Colour> &colours) = 0;
virtual void collectCharList(unsigned id, unsigned level) = 0;
- virtual void collectText(unsigned id, unsigned level, const WPXString &text) = 0;
+ virtual void collectText(unsigned id, unsigned level, const std::vector<uint8_t> &textStream, TextFormat format) = 0;
+ virtual void collectCharFormat(unsigned id , unsigned level, unsigned charCount, unsigned langId, double fontSize, bool bold, bool italic, bool underline, WPXString fontFace) = 0;
// Temporary hack
virtual void startPage() = 0;
diff --git a/src/lib/VSDXContentCollector.cpp b/src/lib/VSDXContentCollector.cpp
index feb2789..c0cedef 100644
--- a/src/lib/VSDXContentCollector.cpp
+++ b/src/lib/VSDXContentCollector.cpp
@@ -51,7 +51,7 @@ libvisio::VSDXContentCollector::VSDXContentCollector(
m_groupXFormsSequence(groupXFormsSequence),
m_groupMembershipsSequence(groupMembershipsSequence), m_currentPageNumber(0),
m_shapeList(), m_shapeOutput(0), m_documentPageShapeOrders(documentPageShapeOrders),
- m_pageShapeOrder(documentPageShapeOrders[0]), m_isFirstGeometry(true)
+ m_pageShapeOrder(documentPageShapeOrders[0]), m_isFirstGeometry(true), m_textFormat(VSD_TEXT_ANSI), m_outputTextStart(false)
{
}
@@ -987,23 +987,75 @@ void libvisio::VSDXContentCollector::collectColours(const std::vector<Colour> &c
m_colours.push_back(colours[i]);
}
-void libvisio::VSDXContentCollector::collectText(unsigned /*id*/, unsigned level, const WPXString &text)
+void libvisio::VSDXContentCollector::collectText(unsigned /*id*/, unsigned level, const std::vector<uint8_t> &textStream, TextFormat format)
{
_handleLevelChange(level);
- VSD_DEBUG_MSG(("Text: %s\n", text.c_str()));
- double angle = 0.0;
- transformAngle(angle);
- WPXPropertyList textCoords;
- textCoords.insert("svg:x", m_scale * m_x);
- textCoords.insert("svg:y", m_scale * m_y);
- textCoords.insert("svg:cx", m_scale * m_x);
- textCoords.insert("svg:cy", m_scale * m_y);
- textCoords.insert("libwpg:rotate", -angle*180/M_PI);
+ m_textStream = textStream;
+ m_textFormat = format;
+ m_outputTextStart = true;
+}
+
+void libvisio::VSDXContentCollector::collectCharFormat(unsigned /*id*/ , unsigned level, unsigned charCount, unsigned /*langId*/, double fontSize, bool bold, bool italic, bool /*underline*/, WPXString fontFace)
+{
+ _handleLevelChange(level);
+
+ if (m_textStream.size() == 0) return;
+ WPXString text;
+ text.clear();
+ if (m_outputTextStart)
+ {
+ double angle = 0.0;
+ transformAngle(angle);
+
+ WPXPropertyList textCoords;
+ textCoords.insert("svg:x", m_scale * m_x);
+ textCoords.insert("svg:y", m_scale * m_y);
+ textCoords.insert("svg:cx", m_scale * m_x);
+ textCoords.insert("svg:cy", m_scale * m_y);
+ textCoords.insert("libwpg:rotate", -angle*180/M_PI);
+
+ m_shapeOutput->addStartTextObject(textCoords, WPXPropertyListVector());
+ m_outputTextStart = false;
+ }
- m_shapeOutput->addStartTextObject(textCoords, WPXPropertyListVector());
+ if (m_textFormat == VSD_TEXT_ANSI)
+ {
+ unsigned max = charCount <= m_textStream.size() ? charCount : m_textStream.size();
+ max = (charCount == 0 && m_textStream.size()) ? m_textStream.size() : max;
+ for (unsigned i = 0; i < max; i++)
+ text.append((char) m_textStream[i]);
+
+ if (charCount > 0)
+ m_textStream.erase(m_textStream.begin(), m_textStream.begin() + max);
+ }
+ else if (m_textFormat == VSD_TEXT_UTF16)
+ {
+ unsigned max = charCount <= (m_textStream.size()/2) ? charCount : (m_textStream.size()/2);
+ VSD_DEBUG_MSG(("Charcount: %d, max: %d, stream size: %d\n", charCount, max, m_textStream.size()));
+ max = (charCount == 0 && m_textStream.size()) ? m_textStream.size()/2 : max;
+ VSD_DEBUG_MSG(("Charcount: %d, max: %d, stream size: %d\n", charCount, max, m_textStream.size()));
+ for (unsigned i = 0; i < (max * 2)-1; i+=2)
+ {
+ unsigned short c = m_textStream[i] | (m_textStream[i+1] << 8);
+ _appendUTF16LE(text, c);
+ }
+ if (charCount > 0)
+ m_textStream.erase(m_textStream.begin(), m_textStream.begin() + (max*2));
+ }
+ WPXPropertyList textProps;
+ textProps.insert("style:font-name", fontFace);
+ if (bold) textProps.insert("fo:font-weight", "bold");
+ if (italic) textProps.insert("fo:font-style", "italic");
+ textProps.insert("fo:font-size", fontSize);
+
+ VSD_DEBUG_MSG(("Text: %s\n", text.cstr()));
+ m_shapeOutput->addStartTextSpan(textProps);
m_shapeOutput->addInsertText(text);
- m_shapeOutput->addEndTextObject();
+ m_shapeOutput->addEndTextSpan();
+
+ if (m_textStream.size() == 0)
+ m_shapeOutput->addEndTextObject();
}
void libvisio::VSDXContentCollector::_handleLevelChange(unsigned level)
@@ -1059,3 +1111,93 @@ void libvisio::VSDXContentCollector::endPage()
m_isPageStarted = false;
}
}
+
+#define SURROGATE_VALUE(h,l) (((h) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000)
+
+void libvisio::VSDXContentCollector::_appendUTF16LE(WPXString &text, const unsigned short character)
+{
+ uint16_t high_surrogate = 0;
+ bool fail = false;
+ uint32_t ucs4Character = 0;
+ while (true)
+ {
+ if (character >= 0xdc00 && character < 0xe000) /* low surrogate */
+ {
+ if (high_surrogate)
+ {
+ ucs4Character = SURROGATE_VALUE(high_surrogate, character);
+ high_surrogate = 0;
+ break;
+ }
+ else
+ {
+ fail = true;
+ break;
+ }
+ }
+ else
+ {
+ if (high_surrogate)
+ {
+ fail = true;
+ break;
+ }
+ if (character >= 0xd800 && character < 0xdc00) /* high surrogate */
+ {
+ high_surrogate = character;
+ }
+ else
+ {
+ ucs4Character = character;
+ break;
+ }
+ }
+ }
+ if (fail)
+ throw GenericException();
+
+ uint8_t first;
+ int len;
+ if (ucs4Character < 0x80)
+ {
+ first = 0;
+ len = 1;
+ }
+ else if (ucs4Character < 0x800)
+ {
+ first = 0xc0;
+ len = 2;
+ }
+ else if (ucs4Character < 0x10000)
+ {
+ first = 0xe0;
+ len = 3;
+ }
+ else if (ucs4Character < 0x200000)
+ {
+ first = 0xf0;
+ len = 4;
+ }
+ else if (ucs4Character < 0x4000000)
+ {
+ first = 0xf8;
+ len = 5;
+ }
+ else
+ {
+ first = 0xfc;
+ len = 6;
+ }
+
+ uint8_t outbuf[6] = { 0, 0, 0, 0, 0, 0};
+ int i;
+ for (i = len - 1; i > 0; --i)
+ {
+ outbuf[i] = (ucs4Character & 0x3f) | 0x80;
+ ucs4Character >>= 6;
+ }
+ outbuf[0] = ucs4Character | first;
+
+ for (i = 0; i < len; i++)
+ text.append(outbuf[i]);
+}
diff --git a/src/lib/VSDXContentCollector.h b/src/lib/VSDXContentCollector.h
index 1701fbb..f40cfeb 100644
--- a/src/lib/VSDXContentCollector.h
+++ b/src/lib/VSDXContentCollector.h
@@ -77,7 +77,8 @@ public:
void collectColours(const std::vector<Colour> &colours);
void collectCharList(unsigned id, unsigned level);
- void collectText(unsigned id, unsigned level, const WPXString &text);
+ void collectText(unsigned id, unsigned level, const std::vector<uint8_t> &textStream, TextFormat format);
+ void collectCharFormat(unsigned id , unsigned level, unsigned charCount, unsigned langId, double fontSize, bool bold, bool italic, bool underline, WPXString fontFace);
void startPage();
void endPage();
@@ -100,6 +101,7 @@ private:
const ::WPXString getColourString(const Colour& c) const;
void _handleLevelChange(unsigned level);
+ void _appendUTF16LE(WPXString &text, unsigned short character);
bool m_isPageStarted;
double m_pageWidth;
@@ -146,6 +148,9 @@ private:
std::map<unsigned, NURBSData> m_NURBSData;
std::map<unsigned, PolylineData> m_polylineData;
+ std::vector<uint8_t> m_textStream;
+ TextFormat m_textFormat;
+ bool m_outputTextStart;
};
} // namespace libvisio
diff --git a/src/lib/VSDXDocumentStructure.h b/src/lib/VSDXDocumentStructure.h
index d4331d6..d657dd1 100644
--- a/src/lib/VSDXDocumentStructure.h
+++ b/src/lib/VSDXDocumentStructure.h
@@ -111,6 +111,4 @@
#define VSD_SHAPE_DATA 0xd1
-
-
#endif /* VSDXDOCUMENTSTRUCTURE_H */
diff --git a/src/lib/VSDXOutputElementList.cpp b/src/lib/VSDXOutputElementList.cpp
index f9b370e..8e6d33b 100644
--- a/src/lib/VSDXOutputElementList.cpp
+++ b/src/lib/VSDXOutputElementList.cpp
@@ -108,6 +108,17 @@ private:
};
+class VSDXStartTextSpanOutputElement : public VSDXOutputElement
+{
+public:
+ VSDXStartTextSpanOutputElement(const WPXPropertyList &propList);
+ virtual ~VSDXStartTextSpanOutputElement() {}
+ virtual void draw(libwpg::WPGPaintInterface *painter);
+private:
+ WPXPropertyList m_propList;
+};
+
+
class VSDXInsertTextOutputElement : public VSDXOutputElement
{
public:
@@ -119,6 +130,15 @@ private:
};
+class VSDXEndTextSpanOutputElement : public VSDXOutputElement
+{
+public:
+ VSDXEndTextSpanOutputElement();
+ virtual ~VSDXEndTextSpanOutputElement() {}
+ virtual void draw(libwpg::WPGPaintInterface *painter);
+};
+
+
class VSDXEndTextObjectOutputElement : public VSDXOutputElement
{
public:
@@ -197,6 +217,15 @@ void libvisio::VSDXStartTextObjectOutputElement::draw(libwpg::WPGPaintInterface
painter->startTextObject(m_propList, m_propListVec);
}
+libvisio::VSDXStartTextSpanOutputElement::VSDXStartTextSpanOutputElement(const WPXPropertyList &propList) :
+ m_propList(propList) {}
+
+void libvisio::VSDXStartTextSpanOutputElement::draw(libwpg::WPGPaintInterface *painter)
+{
+ if (painter)
+ painter->startTextSpan(m_propList);
+}
+
libvisio::VSDXInsertTextOutputElement::VSDXInsertTextOutputElement(const WPXString &text) :
m_text(text) {}
@@ -207,6 +236,14 @@ void libvisio::VSDXInsertTextOutputElement::draw(libwpg::WPGPaintInterface *pain
painter->insertText(m_text);
}
+libvisio::VSDXEndTextSpanOutputElement::VSDXEndTextSpanOutputElement() {}
+
+void libvisio::VSDXEndTextSpanOutputElement::draw(libwpg::WPGPaintInterface *painter)
+{
+ if (painter)
+ painter->endTextSpan();
+}
+
libvisio::VSDXEndTextObjectOutputElement::VSDXEndTextObjectOutputElement() {}
@@ -265,11 +302,21 @@ void libvisio::VSDXOutputElementList::addStartTextObject(const WPXPropertyList &
m_elements.push_back(new VSDXStartTextObjectOutputElement(propList, propListVec));
}
+void libvisio::VSDXOutputElementList::addStartTextSpan(const WPXPropertyList &propList)
+{
+ m_elements.push_back(new VSDXStartTextSpanOutputElement(propList));
+}
+
void libvisio::VSDXOutputElementList::addInsertText(const WPXString &text)
{
m_elements.push_back(new VSDXInsertTextOutputElement(text));
}
+void libvisio::VSDXOutputElementList::addEndTextSpan()
+{
+ m_elements.push_back(new VSDXEndTextSpanOutputElement());
+}
+
void libvisio::VSDXOutputElementList::addEndTextObject()
{
m_elements.push_back(new VSDXEndTextObjectOutputElement());
diff --git a/src/lib/VSDXOutputElementList.h b/src/lib/VSDXOutputElementList.h
index eae0010..5cc1897 100644
--- a/src/lib/VSDXOutputElementList.h
+++ b/src/lib/VSDXOutputElementList.h
@@ -44,7 +44,9 @@ public:
void addStartLayer(const WPXPropertyList &propList);
void addEndLayer();
void addStartTextObject(const WPXPropertyList &propList, const WPXPropertyListVector &propListVec);
+ void addStartTextSpan(const WPXPropertyList &propList);
void addInsertText(const WPXString &text);
+ void addEndTextSpan();
void addEndTextObject();
bool empty() const { return !m_elements.size(); }
void clear();
diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp
index 1ce7ee1..4b0c92c 100644
--- a/src/lib/VSDXParser.cpp
+++ b/src/lib/VSDXParser.cpp
@@ -219,96 +219,6 @@ void libvisio::VSDXParser::_handleLevelChange(unsigned level)
m_currentLevel = level;
}
-#define SURROGATE_VALUE(h,l) (((h) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000)
-
-void libvisio::VSDXParser::_appendUTF16LE(WPXString &text, const unsigned short character)
-{
- uint16_t high_surrogate = 0;
- bool fail = false;
- uint32_t ucs4Character = 0;
- while (true)
- {
- if (character >= 0xdc00 && character < 0xe000) /* low surrogate */
- {
- if (high_surrogate)
- {
- ucs4Character = SURROGATE_VALUE(high_surrogate, character);
- high_surrogate = 0;
- break;
- }
- else
- {
- fail = true;
- break;
- }
- }
- else
- {
- if (high_surrogate)
- {
- fail = true;
- break;
- }
- if (character >= 0xd800 && character < 0xdc00) /* high surrogate */
- {
- high_surrogate = character;
- }
- else
- {
- ucs4Character = character;
- break;
- }
- }
- }
- if (fail)
- throw GenericException();
-
- uint8_t first;
- int len;
- if (ucs4Character < 0x80)
- {
- first = 0;
- len = 1;
- }
- else if (ucs4Character < 0x800)
- {
- first = 0xc0;
- len = 2;
- }
- else if (ucs4Character < 0x10000)
- {
- first = 0xe0;
- len = 3;
- }
- else if (ucs4Character < 0x200000)
- {
- first = 0xf0;
- len = 4;
- }
- else if (ucs4Character < 0x4000000)
- {
- first = 0xf8;
- len = 5;
- }
- else
- {
- first = 0xfc;
- len = 6;
- }
-
- uint8_t outbuf[6] = { 0, 0, 0, 0, 0, 0};
- int i;
- for (i = len - 1; i > 0; --i)
- {
- outbuf[i] = (ucs4Character & 0x3f) | 0x80;
- ucs4Character >>= 6;
- }
- outbuf[0] = ucs4Character | first;
-
- for (i = 0; i < len; i++)
- text.append(outbuf[i]);
-}
-
void libvisio::VSDXParser::handlePage(WPXInputStream *input)
{
try
@@ -389,12 +299,15 @@ void libvisio::VSDXParser::handlePage(WPXInputStream *input)
case VSD_PAGE_PROPS:
readPageProps(input);
break;
-// case VSD_CHAR_LIST:
-// readCharList(input);
-// break;
+ case VSD_CHAR_LIST:
+ readCharList(input);
+ break;
case VSD_TEXT:
readText(input);
break;
+ case VSD_CHAR_IX:
+ readCharIX(input);
+ break;
default:
m_collector->collectUnhandledChunk(m_header.id, m_header.level);
}
diff --git a/src/lib/VSDXParser.h b/src/lib/VSDXParser.h
index cb2de97..5d45329 100644
--- a/src/lib/VSDXParser.h
+++ b/src/lib/VSDXParser.h
@@ -70,6 +70,7 @@ protected:
void readColours(WPXInputStream *input);
void readCharList(WPXInputStream *input);
virtual void readText(WPXInputStream *input) = 0;
+ virtual void readCharIX(WPXInputStream *input) = 0;
// parser of one pass
bool parseDocument(WPXInputStream *input);
@@ -80,7 +81,6 @@ protected:
virtual bool getChunkHeader(WPXInputStream *input) = 0;
void _handleLevelChange(unsigned level);
- void _appendUTF16LE(WPXString &text, unsigned short character);
WPXInputStream *m_input;
libwpg::WPGPaintInterface *m_painter;
diff --git a/src/lib/VSDXStylesCollector.cpp b/src/lib/VSDXStylesCollector.cpp
index 8d87f35..b3b8245 100644
--- a/src/lib/VSDXStylesCollector.cpp
+++ b/src/lib/VSDXStylesCollector.cpp
@@ -180,7 +180,12 @@ void libvisio::VSDXStylesCollector::collectColours(const std::vector<Colour> & /
{
}
-void libvisio::VSDXStylesCollector::collectText(unsigned /*id*/, unsigned level, const WPXString & /*text*/)
+void libvisio::VSDXStylesCollector::collectText(unsigned /*id*/, unsigned level, const std::vector<uint8_t> & /*textStream*/, TextFormat /*format*/)
+{
+ _handleLevelChange(level);
+}
+
+void libvisio::VSDXStylesCollector::collectCharFormat(unsigned /*id*/ , unsigned level, unsigned /*charCount*/, unsigned /*langId*/, double /*fontSize*/, bool /*bold*/, bool /*italic*/, bool /*underline*/, WPXString /*fontFace*/)
{
_handleLevelChange(level);
}
diff --git a/src/lib/VSDXStylesCollector.h b/src/lib/VSDXStylesCollector.h
index 8d731dc..dc242a7 100644
--- a/src/lib/VSDXStylesCollector.h
+++ b/src/lib/VSDXStylesCollector.h
@@ -68,8 +68,8 @@ public:
void collectColours(const std::vector<Colour> &colours);
void collectCharList(unsigned id, unsigned level);
- void collectText(unsigned id, unsigned level, const WPXString &text);
-
+ void collectText(unsigned id, unsigned level, const std::vector<uint8_t> &textStream, TextFormat format);
+ void collectCharFormat(unsigned id , unsigned level, unsigned charCount, unsigned langId, double fontSize, bool bold, bool italic, bool underline, WPXString fontFace);
// Temporary hack
void startPage();
void endPage();
diff --git a/src/lib/VSDXTypes.h b/src/lib/VSDXTypes.h
index 4608b7f..586f5a8 100644
--- a/src/lib/VSDXTypes.h
+++ b/src/lib/VSDXTypes.h
@@ -78,6 +78,18 @@ struct PolylineData
std::vector<std::pair<double, double> > points;
};
+struct CharFormat
+{
+ unsigned charCount;
+ double fontSize;
+ bool bold;
+ bool italic;
+ bool underline;
+ WPXString fontFace;
+};
+
+enum TextFormat { VSD_TEXT_ANSI, VSD_TEXT_UTF16 };
+
} // namespace libvisio
#endif /* VSDXTYPES_H */