diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2015-12-20 18:51:31 +0100 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2015-12-20 18:51:31 +0100 |
commit | 303ad7bc004636c9008d3ca4314b731c6a4f9dde (patch) | |
tree | 5c249e453e98104a522e17ab00142ee2db8b861e | |
parent | a41a69b78aa8a5407f6cdec419c5e7433388388b (diff) |
0x0a is a paragraph break and not line break in visio
Change-Id: Ib9f63146b408f7aec63fc7bc5bae82a8f8aec912
-rw-r--r-- | src/lib/VSDContentCollector.cpp | 36 | ||||
-rw-r--r-- | src/lib/VSDOutputElementList.cpp | 97 | ||||
-rw-r--r-- | src/lib/VSDOutputElementList.h | 2 |
3 files changed, 91 insertions, 44 deletions
diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp index 5b2ecb4..8854ddf 100644 --- a/src/lib/VSDContentCollector.cpp +++ b/src/lib/VSDContentCollector.cpp @@ -704,7 +704,41 @@ void libvisio::VSDContentCollector::_flushText() VSD_DEBUG_MSG(("Text: %s\n", text.cstr())); m_shapeOutputText->addOpenSpan(textProps); - m_shapeOutputText->addInsertText(text); + + librevenge::RVNGString::Iter i(text); + i.rewind(); + librevenge::RVNGString sOutputText; + for (i.rewind(); i.next();) + { + if (*(i()) == '\n') + { + m_shapeOutputText->addInsertText(sOutputText); + m_shapeOutputText->addCloseSpan(); + if (!currentBullet) + { + m_shapeOutputText->addCloseParagraph(); + m_shapeOutputText->addOpenParagraph(paraProps); + } + else + { + m_shapeOutputText->addCloseListElement(); + m_shapeOutputText->addOpenListElement(paraProps); + } + m_shapeOutputText->addOpenSpan(textProps); + sOutputText.clear(); + } + else if (*(i()) == '\t') + { + if (!sOutputText.empty()) + m_shapeOutputText->addInsertText(sOutputText); + m_shapeOutputText->addInsertTab(); + sOutputText.clear(); + } + else + sOutputText.append(i()); + } + + m_shapeOutputText->addInsertText(sOutputText); m_shapeOutputText->addCloseSpan(); charIndex++; diff --git a/src/lib/VSDOutputElementList.cpp b/src/lib/VSDOutputElementList.cpp index 73ddef4..5b06fb8 100644 --- a/src/lib/VSDOutputElementList.cpp +++ b/src/lib/VSDOutputElementList.cpp @@ -15,47 +15,6 @@ namespace libvisio namespace { -static void separateTabsAndInsertText(librevenge::RVNGDrawingInterface *iface, const librevenge::RVNGString &text) -{ - if (!iface || text.empty()) - return; - librevenge::RVNGString tmpText; - librevenge::RVNGString::Iter i(text); - for (i.rewind(); i.next();) - { - if (*(i()) == '\t') - { - if (!tmpText.empty()) - { - if (iface) - iface->insertText(tmpText); - tmpText.clear(); - } - - if (iface) - iface->insertTab(); - } - else if (*(i()) == '\n') - { - if (!tmpText.empty()) - { - if (iface) - iface->insertText(tmpText); - tmpText.clear(); - } - - if (iface) - iface->insertLineBreak(); - } - else - { - tmpText.append(i()); - } - } - if (iface && !tmpText.empty()) - iface->insertText(tmpText); -} - static void separateSpacesAndInsertText(librevenge::RVNGDrawingInterface *iface, const librevenge::RVNGString &text) { if (!iface) @@ -79,7 +38,7 @@ static void separateSpacesAndInsertText(librevenge::RVNGDrawingInterface *iface, { if (!tmpText.empty()) { - separateTabsAndInsertText(iface, tmpText); + iface->insertText(tmpText); tmpText.clear(); } @@ -91,7 +50,7 @@ static void separateSpacesAndInsertText(librevenge::RVNGDrawingInterface *iface, tmpText.append(i()); } } - separateTabsAndInsertText(iface, tmpText); + iface->insertText(tmpText); } } // anonymous namespace @@ -239,6 +198,32 @@ private: }; +class VSDInsertLineBreakOutputElement : public VSDOutputElement +{ +public: + VSDInsertLineBreakOutputElement(); + virtual ~VSDInsertLineBreakOutputElement() {} + virtual void draw(librevenge::RVNGDrawingInterface *painter); + virtual VSDOutputElement *clone() + { + return new VSDInsertLineBreakOutputElement(); + } +}; + + +class VSDInsertTabOutputElement : public VSDOutputElement +{ +public: + VSDInsertTabOutputElement(); + virtual ~VSDInsertTabOutputElement() {} + virtual void draw(librevenge::RVNGDrawingInterface *painter); + virtual VSDOutputElement *clone() + { + return new VSDInsertTabOutputElement(); + } +}; + + class VSDCloseSpanOutputElement : public VSDOutputElement { public: @@ -422,6 +407,22 @@ void libvisio::VSDInsertTextOutputElement::draw(librevenge::RVNGDrawingInterface separateSpacesAndInsertText(painter, m_text); } +libvisio::VSDInsertLineBreakOutputElement::VSDInsertLineBreakOutputElement() {} + +void libvisio::VSDInsertLineBreakOutputElement::draw(librevenge::RVNGDrawingInterface *painter) +{ + if (painter) + painter->insertLineBreak(); +} + +libvisio::VSDInsertTabOutputElement::VSDInsertTabOutputElement() {} + +void libvisio::VSDInsertTabOutputElement::draw(librevenge::RVNGDrawingInterface *painter) +{ + if (painter) + painter->insertTab(); +} + libvisio::VSDCloseSpanOutputElement::VSDCloseSpanOutputElement() {} void libvisio::VSDCloseSpanOutputElement::draw(librevenge::RVNGDrawingInterface *painter) @@ -567,6 +568,16 @@ void libvisio::VSDOutputElementList::addInsertText(const librevenge::RVNGString m_elements.push_back(new VSDInsertTextOutputElement(text)); } +void libvisio::VSDOutputElementList::addInsertLineBreak() +{ + m_elements.push_back(new VSDInsertLineBreakOutputElement()); +} + +void libvisio::VSDOutputElementList::addInsertTab() +{ + m_elements.push_back(new VSDInsertTabOutputElement()); +} + void libvisio::VSDOutputElementList::addCloseSpan() { m_elements.push_back(new VSDCloseSpanOutputElement()); diff --git a/src/lib/VSDOutputElementList.h b/src/lib/VSDOutputElementList.h index c77bada..0a500e2 100644 --- a/src/lib/VSDOutputElementList.h +++ b/src/lib/VSDOutputElementList.h @@ -43,6 +43,8 @@ public: void addOpenSpan(const librevenge::RVNGPropertyList &propList); void addCloseSpan(); void addInsertText(const librevenge::RVNGString &text); + void addInsertLineBreak(); + void addInsertTab(); void addStartLayer(const librevenge::RVNGPropertyList &propList); void addEndLayer(); bool empty() const |