From 46377333551996128b0b1b4a4d25eedbc35eee31 Mon Sep 17 00:00:00 2001 From: Fridrich Štrba Date: Sun, 27 Dec 2015 09:25:05 +0100 Subject: Use U+FFFC as field placeholder and output field only in one place Change-Id: I617ffd23b8577ae6ca71cfde07822a67cd683204 --- src/lib/VSDContentCollector.cpp | 31 ++++++++++++++++--------------- src/lib/VSDContentCollector.h | 1 + 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp index 97be554..e0cff20 100644 --- a/src/lib/VSDContentCollector.cpp +++ b/src/lib/VSDContentCollector.cpp @@ -53,7 +53,7 @@ libvisio::VSDContentCollector::VSDContentCollector( m_currentPageNumber(0), m_shapeOutputDrawing(0), m_shapeOutputText(0), m_pageOutputDrawing(), m_pageOutputText(), m_documentPageShapeOrders(documentPageShapeOrders), m_pageShapeOrder(m_documentPageShapeOrders.begin()), m_isFirstGeometry(true), m_NURBSData(), m_polylineData(), - m_textStream(), m_names(), m_stencilNames(), m_fields(), m_stencilFields(), m_fieldIndex(0), + m_textStream(), m_currentText(), m_names(), m_stencilNames(), m_fields(), m_stencilFields(), m_fieldIndex(0), m_textFormat(VSD_TEXT_ANSI), m_charFormats(), m_paraFormats(), m_lineStyle(), m_fillStyle(), m_textBlockStyle(), m_themeReference(), m_defaultCharStyle(), m_defaultParaStyle(), m_currentStyleSheet(0), m_styles(styles), m_stencils(stencils), m_stencilShape(0), m_isStencilStarted(false), m_currentGeometryCount(0), @@ -647,6 +647,11 @@ void libvisio::VSDContentCollector::_flushText() m_shapeOutputText->addInsertTab(); sOutputText.clear(); } + else if (strlen(i()) == 3 && + i()[0] == (char)0xef && + i()[1] == (char)0xbf && + i()[2] == (char)0xbc) + _appendField(sOutputText); else sOutputText.append(i()); } @@ -2113,9 +2118,6 @@ void libvisio::VSDContentCollector::collectShape(unsigned id, unsigned level, un _handleForeignData(m_stencilShape->m_foreign->data); } - // m_textStream = m_stencilShape->m_text; - // m_textFormat = m_stencilShape->m_textFormat; - for (std::map< unsigned, VSDName>::const_iterator iterData = m_stencilShape->m_names.begin(); iterData != m_stencilShape->m_names.end(); ++iterData) { librevenge::RVNGString nameString; @@ -2222,6 +2224,13 @@ void libvisio::VSDContentCollector::collectText(unsigned level, const librevenge m_textStream = textStream; m_textFormat = format; + m_currentText.clear(); + if (!m_textStream.empty()) + { + std::vector tmpBuffer(textStream.size()); + memcpy(&tmpBuffer[0], textStream.getDataBuffer(), textStream.size()); + appendCharacters(m_currentText, tmpBuffer, format); + } } void libvisio::VSDContentCollector::collectParaIX(unsigned /* id */ , unsigned level, unsigned charCount, const boost::optional &indFirst, @@ -3174,10 +3183,7 @@ void libvisio::VSDContentCollector::appendCharacters(librevenge::RVNGString &tex iter != characters.end(); ++iter) { if (0x1e == ucs4Character) - { - _appendField(text); - continue; - } + ucs4Character = 0xfffc; else if (*iter < 0x20) ucs4Character = 0x20; else @@ -3244,7 +3250,7 @@ void libvisio::VSDContentCollector::appendCharacters(librevenge::RVNGString &tex if (U_SUCCESS(status) && U_IS_UNICODE_CHAR(ucs4Character)) { if (0x1e == ucs4Character) - _appendField(text); + appendUCS4(text, 0xfffc); else appendUCS4(text, ucs4Character); } @@ -3268,12 +3274,7 @@ void libvisio::VSDContentCollector::appendCharacters(librevenge::RVNGString &tex { UChar32 ucs4Character = ucnv_getNextUChar(conv, &src, srcLimit, &status); if (U_SUCCESS(status) && U_IS_UNICODE_CHAR(ucs4Character)) - { - if (0xfffc == ucs4Character) - _appendField(text); - else - appendUCS4(text, ucs4Character); - } + appendUCS4(text, ucs4Character); } } if (conv) diff --git a/src/lib/VSDContentCollector.h b/src/lib/VSDContentCollector.h index 9a956db..c3aaff2 100644 --- a/src/lib/VSDContentCollector.h +++ b/src/lib/VSDContentCollector.h @@ -276,6 +276,7 @@ private: std::map m_NURBSData; std::map m_polylineData; librevenge::RVNGBinaryData m_textStream; + librevenge::RVNGString m_currentText; std::map m_names, m_stencilNames; std::vector m_fields; VSDFieldList m_stencilFields; -- cgit v1.2.3