[Libreoffice-commits] libvisio.git: src/conv
Fridrich Å trba
fridrich.strba at bluewin.ch
Tue Nov 5 13:08:34 CET 2013
src/conv/raw/vsd2raw.cpp | 338 -----------------------------------------------
src/conv/raw/vss2raw.cpp | 7
2 files changed, 2 insertions(+), 343 deletions(-)
New commits:
commit bdfaab8e82224873c4e18a9c3ae058d734ff1b7d
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date: Tue Nov 5 13:08:08 2013 +0100
Add printing of indent levels in vs?2raw
Change-Id: I034d6e604b60ddbfc21e1ddee2935d59f9bd1292
diff --git a/src/conv/raw/vsd2raw.cpp b/src/conv/raw/vsd2raw.cpp
index 1226923..e20e2b7 100644
--- a/src/conv/raw/vsd2raw.cpp
+++ b/src/conv/raw/vsd2raw.cpp
@@ -28,347 +28,11 @@
* instead of those above.
*/
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <stack>
-
#include <librevenge-stream/librevenge-stream.h>
#include <librevenge-generators/librevenge-generators.h>
#include <librevenge/librevenge.h>
#include <libvisio/libvisio.h>
-
-#if 0
-
-enum PainterCallback
-{
- PC_START_GRAPHICS = 0,
- PC_START_LAYER,
- PC_START_EMBEDDED_GRAPHICS,
- PC_START_TEXT_OBJECT,
- PC_START_TEXT_LINE,
- PC_START_TEXT_SPAN
-};
-
-#ifdef _U
-#undef _U
-#endif
-
-#define _U(M, L) \
- if (!m_printCallgraphScore) \
- __iuprintf M; \
- else \
- m_callStack.push(L);
-
-#ifdef _D
-#undef _D
-#endif
-
-#define _D(M, L) \
- if (!m_printCallgraphScore) \
- __idprintf M; \
- else \
- { \
- PainterCallback lc = m_callStack.top(); \
- if (lc != L) \
- m_callbackMisses++; \
- m_callStack.pop(); \
- }
-
-class RawPainter : public librevenge::RVNGDrawingInterface
-{
-public:
- RawPainter(bool printCallgraphScore);
-
- ~RawPainter();
-
- void startDocument(const librevenge::RVNGPropertyList & /*propList*/) {}
- void endDocument() {}
- void setDocumentMetaData(const librevenge::RVNGPropertyList & /*propList*/) {}
- void startPage(const librevenge::RVNGPropertyList &propList);
- void endPage();
- void startLayer(const librevenge::RVNGPropertyList &propList);
- void endLayer();
- void startEmbeddedGraphics(const librevenge::RVNGPropertyList &propList);
- void endEmbeddedGraphics();
-
- void setStyle(const librevenge::RVNGPropertyList &propList, const librevenge::RVNGPropertyListVector &gradient);
-
- void drawRectangle(const librevenge::RVNGPropertyList &propList);
- void drawEllipse(const librevenge::RVNGPropertyList &propList);
- void drawPolyline(const librevenge::RVNGPropertyListVector &vertices);
- void drawPolygon(const librevenge::RVNGPropertyListVector &vertices);
- void drawPath(const librevenge::RVNGPropertyListVector &path);
- void drawGraphicObject(const librevenge::RVNGPropertyList &propList, const librevenge::RVNGBinaryData &binaryData);
- void startTextObject(const librevenge::RVNGPropertyList &propList, const librevenge::RVNGPropertyListVector &path);
- void endTextObject();
-
-
- void openOrderedListLevel(const librevenge::RVNGPropertyList & /*propList*/) {}
- void closeOrderedListLevel() {}
-
- void openUnorderedListLevel(const librevenge::RVNGPropertyList & /*propList*/) {}
- void closeUnorderedListLevel() {}
-
- void openListElement(const librevenge::RVNGPropertyList & /*propList*/, const librevenge::RVNGPropertyListVector & /* tabStops */) {}
- void closeListElement() {}
-
- void openParagraph(const librevenge::RVNGPropertyList &propList, const librevenge::RVNGPropertyListVector &tabStops);
- void closeParagraph();
-
- void openSpan(const librevenge::RVNGPropertyList &propList);
- void closeSpan();
-
- void insertTab() {}
- void insertSpace() {}
- void insertText(const librevenge::RVNGString &text);
- void insertLineBreak() {}
- void insertField(const librevenge::RVNGString & /* type */, const librevenge::RVNGPropertyList & /*propList*/) {}
-
-
-private:
- int m_indent;
- int m_callbackMisses;
- bool m_printCallgraphScore;
- std::stack<PainterCallback> m_callStack;
-
- void __indentUp()
- {
- m_indent++;
- }
- void __indentDown()
- {
- if (m_indent > 0) m_indent--;
- }
-
- void __iprintf(const char *format, ...);
- void __iuprintf(const char *format, ...);
- void __idprintf(const char *format, ...);
-};
-
-librevenge::RVNGString getPropString(const librevenge::RVNGPropertyList &propList)
-{
- librevenge::RVNGString propString;
- librevenge::RVNGPropertyList::Iter i(propList);
- if (!i.last())
- {
- propString.append(i.key());
- propString.append(": ");
- propString.append(i()->getStr().cstr());
- for (; i.next(); )
- {
- propString.append(", ");
- propString.append(i.key());
- propString.append(": ");
- propString.append(i()->getStr().cstr());
- }
- }
-
- return propString;
-}
-
-librevenge::RVNGString getPropString(const librevenge::RVNGPropertyListVector &itemList)
-{
- librevenge::RVNGString propString;
-
- propString.append("(");
- librevenge::RVNGPropertyListVector::Iter i(itemList);
-
- if (!i.last())
- {
- propString.append("(");
- propString.append(getPropString(i()));
- propString.append(")");
-
- for (; i.next();)
- {
- propString.append(", (");
- propString.append(getPropString(i()));
- propString.append(")");
- }
-
- }
- propString.append(")");
-
- return propString;
-}
-
-RawPainter::RawPainter(bool printCallgraphScore):
- librevenge::RVNGDrawingInterface(),
- m_indent(0),
- m_callbackMisses(0),
- m_printCallgraphScore(printCallgraphScore),
- m_callStack()
-{
-}
-
-RawPainter::~RawPainter()
-{
- if (m_printCallgraphScore)
- printf("%d\n", (int)(m_callStack.size() + m_callbackMisses));
-}
-
-void RawPainter::__iprintf(const char *format, ...)
-{
- if (m_printCallgraphScore) return;
-
- va_list args;
- va_start(args, format);
- for (int i=0; i<m_indent; i++)
- printf(" ");
- vprintf(format, args);
- va_end(args);
-}
-
-void RawPainter::__iuprintf(const char *format, ...)
-{
- va_list args;
- va_start(args, format);
- for (int i=0; i<m_indent; i++)
- printf(" ");
- vprintf(format, args);
- __indentUp();
- va_end(args);
-}
-
-void RawPainter::__idprintf(const char *format, ...)
-{
- va_list args;
- va_start(args, format);
- __indentDown();
- for (int i=0; i<m_indent; i++)
- printf(" ");
- vprintf(format, args);
- va_end(args);
-}
-
-void RawPainter::startPage(const librevenge::RVNGPropertyList &propList)
-{
- _U(("RawPainter::startPage(%s)\n", getPropString(propList).cstr()), PC_START_GRAPHICS);
-}
-
-void RawPainter::endPage()
-{
- _D(("RawPainter::endPage\n"), PC_START_GRAPHICS);
-}
-
-void RawPainter::startLayer(const librevenge::RVNGPropertyList &propList)
-{
- _U(("RawPainter::startLayer (%s)\n", getPropString(propList).cstr()), PC_START_LAYER);
-}
-
-void RawPainter::endLayer()
-{
- _D(("RawPainter::endLayer\n"), PC_START_LAYER);
-}
-
-void RawPainter::startEmbeddedGraphics(const librevenge::RVNGPropertyList &propList)
-{
- _U(("RawPainter::startEmbeddedGraphics (%s)\n", getPropString(propList).cstr()), PC_START_EMBEDDED_GRAPHICS);
-}
-
-void RawPainter::endEmbeddedGraphics()
-{
- _D(("RawPainter::endEmbeddedGraphics \n"), PC_START_EMBEDDED_GRAPHICS);
-}
-
-void RawPainter::setStyle(const librevenge::RVNGPropertyList &propList, const librevenge::RVNGPropertyListVector &gradient)
-{
- if (m_printCallgraphScore)
- return;
-
- __iprintf("RawPainter::setStyle(%s, gradient: (%s))\n", getPropString(propList).cstr(), getPropString(gradient).cstr());
-}
-
-void RawPainter::drawRectangle(const librevenge::RVNGPropertyList &propList)
-{
- if (m_printCallgraphScore)
- return;
-
- __iprintf("RawPainter::drawRectangle (%s)\n", getPropString(propList).cstr());
-}
-
-void RawPainter::drawEllipse(const librevenge::RVNGPropertyList &propList)
-{
- if (m_printCallgraphScore)
- return;
-
- __iprintf("RawPainter::drawEllipse (%s)\n", getPropString(propList).cstr());
-}
-
-void RawPainter::drawPolyline(const librevenge::RVNGPropertyListVector &vertices)
-{
- if (m_printCallgraphScore)
- return;
-
- __iprintf("RawPainter::drawPolyline (%s)\n", getPropString(vertices).cstr());
-}
-
-void RawPainter::drawPolygon(const librevenge::RVNGPropertyListVector &vertices)
-{
- if (m_printCallgraphScore)
- return;
-
- __iprintf("RawPainter::drawPolygon (%s)\n", getPropString(vertices).cstr());
-}
-
-void RawPainter::drawPath(const librevenge::RVNGPropertyListVector &path)
-{
- if (m_printCallgraphScore)
- return;
-
- __iprintf("RawPainter::drawPath (%s)\n", getPropString(path).cstr());
-}
-
-void RawPainter::drawGraphicObject(const librevenge::RVNGPropertyList &propList, const librevenge::RVNGBinaryData & /*binaryData*/)
-{
- if (m_printCallgraphScore)
- return;
-
- __iprintf("RawPainter::drawGraphicObject (%s)\n", getPropString(propList).cstr());
-}
-
-void RawPainter::startTextObject(const librevenge::RVNGPropertyList &propList, const librevenge::RVNGPropertyListVector &path)
-{
- _U(("RawPainter::startTextObject (%s, path: (%s))\n", getPropString(propList).cstr(), getPropString(path).cstr()), PC_START_TEXT_OBJECT);
-}
-
-void RawPainter::endTextObject()
-{
- _D(("RawPainter::endTextObject\n"), PC_START_TEXT_OBJECT);
-}
-
-void RawPainter::openParagraph(const librevenge::RVNGPropertyList &propList, const librevenge::RVNGPropertyListVector &tabStops)
-{
- _U(("RawPainter::openParagraph (%s, tabStops: (%s))\n", getPropString(propList).cstr(), getPropString(tabStops).cstr()), PC_START_TEXT_LINE);
-}
-
-void RawPainter::closeParagraph()
-{
- _D(("RawPainter::closeParagraph\n"), PC_START_TEXT_LINE);
-}
-
-void RawPainter::openSpan(const librevenge::RVNGPropertyList &propList)
-{
- _U(("RawPainter::openSpan (%s)\n", getPropString(propList).cstr()), PC_START_TEXT_SPAN);
-}
-
-void RawPainter::closeSpan()
-{
- _D(("RawPainter::closeSpan\n"), PC_START_TEXT_SPAN);
-}
-
-void RawPainter::insertText(const librevenge::RVNGString &str)
-{
- if (m_printCallgraphScore)
- return;
-
- __iprintf("RawPainter::insertText (%s)\n", str.cstr());
-}
-
-#endif
-
namespace
{
@@ -414,7 +78,7 @@ int main(int argc, char *argv[])
}
(void)printIndentLevel;
- librevenge::RVNGRawDrawingGenerator painter /* (printIndentLevel) */;
+ librevenge::RVNGRawDrawingGenerator painter(printIndentLevel);
if (!libvisio::VisioDocument::parse(&input, &painter))
{
fprintf(stderr, "ERROR: Parsing of document failed!\n");
diff --git a/src/conv/raw/vss2raw.cpp b/src/conv/raw/vss2raw.cpp
index 4f2ad3b..b496e28 100644
--- a/src/conv/raw/vss2raw.cpp
+++ b/src/conv/raw/vss2raw.cpp
@@ -28,11 +28,6 @@
* instead of those above.
*/
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <stack>
-
#include <librevenge-stream/librevenge-stream.h>
#include <librevenge-generators/librevenge-generators.h>
#include <librevenge/librevenge.h>
@@ -83,7 +78,7 @@ int main(int argc, char *argv[])
}
(void)printIndentLevel;
- librevenge::RVNGRawDrawingGenerator painter /* (printIndentLevel) */;
+ librevenge::RVNGRawDrawingGenerator painter(printIndentLevel);
if (!libvisio::VisioDocument::parseStencils(&input, &painter))
{
fprintf(stderr, "ERROR: Parsing of document failed!\n");
More information about the Libreoffice-commits
mailing list