diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2013-11-05 12:46:55 +0100 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2013-11-05 12:46:55 +0100 |
commit | 143fecc00b53b751a11bb0b9301a95c7cd114441 (patch) | |
tree | b0c91640c05cd1d233d72f0cf4ffcc9fb519cd29 | |
parent | 2553cd43803e6af436a6c9e1aa40b4c1d2c3e3d2 (diff) |
port to librevenge-generators
Change-Id: Ie15bcf35d65fdd1b4a9ccd0b59fea05136400625
-rw-r--r-- | configure.ac | 23 | ||||
-rw-r--r-- | inc/libvisio/VisioDocument.h | 4 | ||||
-rw-r--r-- | src/conv/raw/Makefile.am | 23 | ||||
-rw-r--r-- | src/conv/raw/vsd2raw.cpp | 8 | ||||
-rw-r--r-- | src/conv/raw/vss2raw.cpp | 331 | ||||
-rw-r--r-- | src/conv/svg/Makefile.am | 23 | ||||
-rw-r--r-- | src/conv/svg/vsd2xhtml.cpp | 5 | ||||
-rw-r--r-- | src/conv/svg/vss2xhtml.cpp | 5 | ||||
-rw-r--r-- | src/conv/text/Makefile.am | 20 | ||||
-rw-r--r-- | src/lib/Makefile.am | 2 | ||||
-rw-r--r-- | src/lib/VSDSVGGenerator.cpp | 843 | ||||
-rw-r--r-- | src/lib/VSDSVGGenerator.h | 101 | ||||
-rw-r--r-- | src/lib/VisioDocument.cpp | 31 |
13 files changed, 92 insertions, 1327 deletions
diff --git a/configure.ac b/configure.ac index 3cd9418..5b3f67b 100644 --- a/configure.ac +++ b/configure.ac @@ -59,7 +59,6 @@ AC_SUBST(GPERF) # ==================== PKG_CHECK_MODULES([REVENGE],[ librevenge-0.0 - librevenge-stream-0.0 ]) PKG_CHECK_MODULES([LIBXML],[ @@ -116,6 +115,28 @@ AC_CHECK_HEADERS( [] ) +# ===== +# Tools +# ===== +AC_ARG_ENABLE([tools], + [AS_HELP_STRING([--disable-tools], [Build conversion tools])], + [enable_tools="$enableval"], + [enable_tools=yes] +) +AS_IF([test "x$enable_tools" = "xyes"], [ + PKG_CHECK_MODULES([REVENGE_GENERATORS],[ + librevenge-generators-0.0 + ]) + PKG_CHECK_MODULES([REVENGE_STREAM],[ + librevenge-stream-0.0 + ]) +]) +AC_SUBST([REVENGE_GENERATORS_CFLAGS]) +AC_SUBST([REVENGE_GENERATORS_LIBS]) +AC_SUBST([REVENGE_STREAM_CFLAGS]) +AC_SUBST([REVENGE_STREAM_LIBS]) +AM_CONDITIONAL(BUILD_TOOLS, [test "x$enable_tools" = "xyes"]) + # ================================= # Libtool/Version Makefile settings # ================================= diff --git a/inc/libvisio/VisioDocument.h b/inc/libvisio/VisioDocument.h index 94b7252..dab307f 100644 --- a/inc/libvisio/VisioDocument.h +++ b/inc/libvisio/VisioDocument.h @@ -45,10 +45,6 @@ public: static bool parse(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *painter); static bool parseStencils(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *painter); - - static bool generateSVG(librevenge::RVNGInputStream *input, librevenge::RVNGStringVector &output); - - static bool generateSVGStencils(librevenge::RVNGInputStream *input, librevenge::RVNGStringVector &output); }; } // namespace libvisio diff --git a/src/conv/raw/Makefile.am b/src/conv/raw/Makefile.am index 742d4fb..3c7c474 100644 --- a/src/conv/raw/Makefile.am +++ b/src/conv/raw/Makefile.am @@ -1,14 +1,29 @@ bin_PROGRAMS = vsd2raw vss2raw -AM_CXXFLAGS = -I$(top_srcdir)/inc $(LIBVISIO_CXXFLAGS) $(DEBUG_CXXFLAGS) +AM_CXXFLAGS = \ + -I$(top_srcdir)/inc \ + $(LIBVISIO_CXXFLAGS) \ + $(REVENGE_STREAM_CFLAGS) \ + $(REVENGE_GENERATORS_CFLAGS) \ + $(DEBUG_CXXFLAGS) vsd2raw_DEPENDENCIES = @VSD2RAW_WIN32_RESOURCE@ vss2raw_DEPENDENCIES = @VSS2RAW_WIN32_RESOURCE@ -vsd2raw_LDADD = ../../lib/libvisio-@VSD_MAJOR_VERSION@.@VSD_MINOR_VERSION@.la $(LIBVISIO_LIBS) @VSD2RAW_WIN32_RESOURCE@ - -vss2raw_LDADD = ../../lib/libvisio-@VSD_MAJOR_VERSION@.@VSD_MINOR_VERSION@.la $(LIBVISIO_LIBS) @VSS2RAW_WIN32_RESOURCE@ +vsd2raw_LDADD = \ + ../../lib/libvisio-@VSD_MAJOR_VERSION@.@VSD_MINOR_VERSION@.la \ + $(REVENGE_GENERATORS_LIBS) \ + $(LIBVISIO_LIBS) \ + $(REVENGE_STREAM_LIBS) \ + @VSD2RAW_WIN32_RESOURCE@ + +vss2raw_LDADD = \ + ../../lib/libvisio-@VSD_MAJOR_VERSION@.@VSD_MINOR_VERSION@.la \ + $(REVENGE_GENERATORS_LIBS) \ + $(LIBVISIO_LIBS) \ + $(REVENGE_STREAM_LIBS) \ + @VSS2RAW_WIN32_RESOURCE@ vsd2raw_SOURCES = \ vsd2raw.cpp diff --git a/src/conv/raw/vsd2raw.cpp b/src/conv/raw/vsd2raw.cpp index c32710b..1226923 100644 --- a/src/conv/raw/vsd2raw.cpp +++ b/src/conv/raw/vsd2raw.cpp @@ -34,9 +34,13 @@ #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, @@ -363,6 +367,7 @@ void RawPainter::insertText(const librevenge::RVNGString &str) __iprintf("RawPainter::insertText (%s)\n", str.cstr()); } +#endif namespace { @@ -408,7 +413,8 @@ int main(int argc, char *argv[]) return 1; } - RawPainter painter(printIndentLevel); + (void)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 46d1e23..4f2ad3b 100644 --- a/src/conv/raw/vss2raw.cpp +++ b/src/conv/raw/vss2raw.cpp @@ -34,336 +34,10 @@ #include <stack> #include <librevenge-stream/librevenge-stream.h> +#include <librevenge-generators/librevenge-generators.h> #include <librevenge/librevenge.h> #include <libvisio/libvisio.h> -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()); -} - - namespace { @@ -408,7 +82,8 @@ int main(int argc, char *argv[]) return 1; } - RawPainter painter(printIndentLevel); + (void)printIndentLevel; + librevenge::RVNGRawDrawingGenerator painter /* (printIndentLevel) */; if (!libvisio::VisioDocument::parseStencils(&input, &painter)) { fprintf(stderr, "ERROR: Parsing of document failed!\n"); diff --git a/src/conv/svg/Makefile.am b/src/conv/svg/Makefile.am index b958b0c..d366cd0 100644 --- a/src/conv/svg/Makefile.am +++ b/src/conv/svg/Makefile.am @@ -1,14 +1,29 @@ bin_PROGRAMS = vsd2xhtml vss2xhtml -AM_CXXFLAGS = -I$(top_srcdir)/inc $(LIBVISIO_CXXFLAGS) $(DEBUG_CXXFLAGS) +AM_CXXFLAGS = \ + -I$(top_srcdir)/inc \ + $(LIBVISIO_CXXFLAGS) \ + $(REVENGE_STREAM_CFLAGS) \ + $(REVENGE_GENERATORS_CFLAGS) \ + $(DEBUG_CXXFLAGS) vsd2xhtml_DEPENDENCIES = @VSD2XHTML_WIN32_RESOURCE@ vss2xhtml_DEPENDENCIES = @VSS2XHTML_WIN32_RESOURCE@ -vsd2xhtml_LDADD = ../../lib/libvisio-@VSD_MAJOR_VERSION@.@VSD_MINOR_VERSION@.la $(LIBVISIO_LIBS) @VSD2XHTML_WIN32_RESOURCE@ - -vss2xhtml_LDADD = ../../lib/libvisio-@VSD_MAJOR_VERSION@.@VSD_MINOR_VERSION@.la $(LIBVISIO_LIBS) @VSS2XHTML_WIN32_RESOURCE@ +vsd2xhtml_LDADD = \ + ../../lib/libvisio-@VSD_MAJOR_VERSION@.@VSD_MINOR_VERSION@.la \ + $(REVENGE_GENERATORS_LIBS) \ + $(LIBVISIO_LIBS) \ + $(REVENGE_STREAM_LIBS) \ + @VSD2XHTML_WIN32_RESOURCE@ + +vss2xhtml_LDADD = \ + ../../lib/libvisio-@VSD_MAJOR_VERSION@.@VSD_MINOR_VERSION@.la \ + $(REVENGE_GENERATORS_LIBS) \ + $(LIBVISIO_LIBS) \ + $(REVENGE_STREAM_LIBS) \ + @VSS2XHTML_WIN32_RESOURCE@ vsd2xhtml_SOURCES = \ vsd2xhtml.cpp diff --git a/src/conv/svg/vsd2xhtml.cpp b/src/conv/svg/vsd2xhtml.cpp index 3ce76fe..e21a477 100644 --- a/src/conv/svg/vsd2xhtml.cpp +++ b/src/conv/svg/vsd2xhtml.cpp @@ -33,6 +33,7 @@ #include <stdio.h> #include <string.h> #include <librevenge-stream/librevenge-stream.h> +#include <librevenge-generators/librevenge-generators.h> #include <librevenge/librevenge.h> #include <libvisio/libvisio.h> @@ -77,12 +78,12 @@ int main(int argc, char *argv[]) } librevenge::RVNGStringVector output; - if (!libvisio::VisioDocument::generateSVG(&input, output)) + librevenge::RVNGSVGDrawingGenerator generator(output, ""); + if (!libvisio::VisioDocument::parse(&input, &generator)) { std::cerr << "ERROR: SVG Generation failed!" << std::endl; return 1; } - if (output.empty()) { std::cerr << "ERROR: No SVG document generated!" << std::endl; diff --git a/src/conv/svg/vss2xhtml.cpp b/src/conv/svg/vss2xhtml.cpp index 4ce3709..b96b639 100644 --- a/src/conv/svg/vss2xhtml.cpp +++ b/src/conv/svg/vss2xhtml.cpp @@ -33,6 +33,7 @@ #include <stdio.h> #include <string.h> #include <librevenge-stream/librevenge-stream.h> +#include <librevenge-generators/librevenge-generators.h> #include <librevenge/librevenge.h> #include <libvisio/libvisio.h> @@ -77,12 +78,12 @@ int main(int argc, char *argv[]) } librevenge::RVNGStringVector output; - if (!libvisio::VisioDocument::generateSVGStencils(&input, output)) + librevenge::RVNGSVGDrawingGenerator generator(output, ""); + if (!libvisio::VisioDocument::parseStencils(&input, &generator)) { std::cerr << "ERROR: SVG Generation failed!" << std::endl; return 1; } - if (output.empty()) { std::cerr << "ERROR: No SVG document generated!" << std::endl; diff --git a/src/conv/text/Makefile.am b/src/conv/text/Makefile.am index 89602f8..5e3a1d9 100644 --- a/src/conv/text/Makefile.am +++ b/src/conv/text/Makefile.am @@ -1,14 +1,26 @@ bin_PROGRAMS = vsd2text vss2text -AM_CXXFLAGS = -I$(top_srcdir)/inc $(LIBVISIO_CXXFLAGS) $(DEBUG_CXXFLAGS) +AM_CXXFLAGS = \ + -I$(top_srcdir)/inc \ + $(LIBVISIO_CXXFLAGS) \ + $(REVENGE_STREAM_CFLAGS) \ + $(DEBUG_CXXFLAGS) vsd2text_DEPENDENCIES = @VSD2TEXT_WIN32_RESOURCE@ vss2text_DEPENDENCIES = @VSS2TEXT_WIN32_RESOURCE@ -vsd2text_LDADD = ../../lib/libvisio-@VSD_MAJOR_VERSION@.@VSD_MINOR_VERSION@.la $(LIBVISIO_LIBS) @VSD2TEXT_WIN32_RESOURCE@ - -vss2text_LDADD = ../../lib/libvisio-@VSD_MAJOR_VERSION@.@VSD_MINOR_VERSION@.la $(LIBVISIO_LIBS) @VSS2TEXT_WIN32_RESOURCE@ +vsd2text_LDADD = \ + ../../lib/libvisio-@VSD_MAJOR_VERSION@.@VSD_MINOR_VERSION@.la \ + $(LIBVISIO_LIBS) \ + $(REVENGE_STREAM_LIBS) \ + @VSD2TEXT_WIN32_RESOURCE@ + +vss2text_LDADD = \ + ../../lib/libvisio-@VSD_MAJOR_VERSION@.@VSD_MINOR_VERSION@.la \ + $(LIBVISIO_LIBS) \ + $(REVENGE_STREAM_LIBS) \ + @VSS2TEXT_WIN32_RESOURCE@ vsd2text_SOURCES = \ vsd2text.cpp diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 8eeafc4..41b74a2 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -26,7 +26,6 @@ libvisio_@VSD_MAJOR_VERSION@_@VSD_MINOR_VERSION@_la_SOURCES = \ VSD5Parser.cpp \ VSD6Parser.cpp \ VSDInternalStream.cpp \ - VSDSVGGenerator.cpp \ VSDCharacterList.cpp \ VSDContentCollector.cpp \ VSDFieldList.cpp \ @@ -44,7 +43,6 @@ libvisio_@VSD_MAJOR_VERSION@_@VSD_MINOR_VERSION@_la_SOURCES = \ VSD5Parser.h \ VSD6Parser.h \ VSDInternalStream.h \ - VSDSVGGenerator.h \ VSDCharacterList.h \ VSDCollector.h \ VSDContentCollector.h \ diff --git a/src/lib/VSDSVGGenerator.cpp b/src/lib/VSDSVGGenerator.cpp deleted file mode 100644 index b8df0c2..0000000 --- a/src/lib/VSDSVGGenerator.cpp +++ /dev/null @@ -1,843 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libvisio - * Version: MPL 1.1 / GPLv2+ / LGPLv2+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch> - * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com> - * - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPLv2+"), or - * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), - * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable - * instead of those above. - */ - -#include "VSDSVGGenerator.h" -#include <sstream> -#include <string> - -namespace -{ - -static std::string doubleToString(const double value) -{ - librevenge::RVNGProperty *prop = librevenge::RVNGPropertyFactory::newDoubleProp(value); - std::string retVal = prop->getStr().cstr(); - delete prop; - return retVal; -} - -static unsigned stringToColour(const librevenge::RVNGString &s) -{ - std::string str(s.cstr()); - if (str[0] == '#') - { - if (str.length() != 7) - return 0; - else - str.erase(str.begin()); - } - else - return 0; - - std::istringstream istr(str); - unsigned val = 0; - istr >> std::hex >> val; - return val; -} - -} // anomymous namespace - -namespace libvisio -{ - -struct VSDSVGGeneratorPrivate -{ - VSDSVGGeneratorPrivate(librevenge::RVNGStringVector &vec, const librevenge::RVNGString &nmSpace); - - void setStyle(const librevenge::RVNGPropertyList &propList, const librevenge::RVNGPropertyListVector &gradient); - void writeStyle(bool isClosed=true); - void drawPolySomething(const librevenge::RVNGPropertyListVector &vertices, bool isClosed); - - //! return the namespace and the delimiter - std::string const &getNamespaceAndDelim() const - { - return m_nmSpaceAndDelim; - } - librevenge::RVNGPropertyListVector m_gradient; - librevenge::RVNGPropertyList m_style; - int m_gradientIndex, m_shadowIndex; - //! index uses when fill=bitmap - int m_patternIndex; - int m_arrowStartIndex /** start arrow index*/, m_arrowEndIndex /** end arrow index */; - //! layerId used if svg:id is not defined when calling startLayer - int m_layerId; - //! a prefix used to define the svg namespace - std::string m_nmSpace; - //! a prefix used to define the svg namespace with delimiter - std::string m_nmSpaceAndDelim; - std::ostringstream m_outputSink; - librevenge::RVNGStringVector &m_vec; -}; - -VSDSVGGeneratorPrivate::VSDSVGGeneratorPrivate(librevenge::RVNGStringVector &vec, const librevenge::RVNGString &nmSpace) : - m_gradient(), - m_style(), - m_gradientIndex(1), - m_shadowIndex(1), - m_patternIndex(1), - m_arrowStartIndex(1), - m_arrowEndIndex(1), - m_layerId(1000), - m_nmSpace(nmSpace.cstr()), - m_nmSpaceAndDelim(""), - m_outputSink(), - m_vec(vec) -{ - if (!m_nmSpace.empty()) - m_nmSpaceAndDelim = m_nmSpace+":"; -} - -void VSDSVGGeneratorPrivate::drawPolySomething(const librevenge::RVNGPropertyListVector &vertices, bool isClosed) -{ - if(vertices.count() < 2) - return; - - if(vertices.count() == 2) - { - if (!vertices[0]["svg:x"]||!vertices[0]["svg:y"]||!vertices[1]["svg:x"]||!vertices[1]["svg:y"]) - return; - m_outputSink << "<" << getNamespaceAndDelim() << "line "; - m_outputSink << "x1=\"" << doubleToString(72*(vertices[0]["svg:x"]->getDouble())) << "\" y1=\"" << doubleToString(72*(vertices[0]["svg:y"]->getDouble())) << "\" "; - m_outputSink << "x2=\"" << doubleToString(72*(vertices[1]["svg:x"]->getDouble())) << "\" y2=\"" << doubleToString(72*(vertices[1]["svg:y"]->getDouble())) << "\"\n"; - writeStyle(); - m_outputSink << "/>\n"; - } - else - { - if (isClosed) - m_outputSink << "<" << getNamespaceAndDelim() << "polygon "; - else - m_outputSink << "<" << getNamespaceAndDelim() << "polyline "; - - m_outputSink << "points=\""; - for(unsigned i = 0; i < vertices.count(); i++) - { - if (!vertices[i]["svg:x"]||!vertices[i]["svg:y"]) - continue; - m_outputSink << doubleToString(72*(vertices[i]["svg:x"]->getDouble())) << " " << doubleToString(72*(vertices[i]["svg:y"]->getDouble())); - if (i < vertices.count()-1) - m_outputSink << ", "; - } - m_outputSink << "\"\n"; - writeStyle(isClosed); - m_outputSink << "/>\n"; - } -} - -void VSDSVGGeneratorPrivate::setStyle(const librevenge::RVNGPropertyList &propList, const librevenge::RVNGPropertyListVector &gradient) -{ - m_style.clear(); - m_style = propList; - - m_gradient = gradient; - if(m_style["draw:shadow"] && m_style["draw:shadow"]->getStr() == "visible" && m_style["draw:shadow-opacity"]) - { - double shadowRed = 0.0; - double shadowGreen = 0.0; - double shadowBlue = 0.0; - if (m_style["draw:shadow-color"]) - { - unsigned shadowColour = stringToColour(m_style["draw:shadow-color"]->getStr()); - shadowRed = (double)((shadowColour & 0x00ff0000) >> 16)/255.0; - shadowGreen = (double)((shadowColour & 0x0000ff00) >> 8)/255.0; - shadowBlue = (double)(shadowColour & 0x000000ff)/255.0; - } - m_outputSink << "<" << getNamespaceAndDelim() << "defs>\n"; - m_outputSink << "<" << getNamespaceAndDelim() << "filter filterUnits=\"userSpaceOnUse\" id=\"shadow" << m_shadowIndex++ << "\">"; - m_outputSink << "<" << getNamespaceAndDelim() << "feOffset in=\"SourceGraphic\" result=\"offset\" "; - if (m_style["draw:shadow-offset-x"]) - m_outputSink << "dx=\"" << doubleToString(72*m_style["draw:shadow-offset-x"]->getDouble()) << "\" "; - if (m_style["draw:shadow-offset-y"]) - m_outputSink << "dy=\"" << doubleToString(72*m_style["draw:shadow-offset-y"]->getDouble()) << "\" "; - m_outputSink << "/>"; - m_outputSink << "<" << getNamespaceAndDelim() << "feColorMatrix in=\"offset\" result=\"offset-color\" type=\"matrix\" values=\""; - m_outputSink << "0 0 0 0 " << doubleToString(shadowRed) ; - m_outputSink << " 0 0 0 0 " << doubleToString(shadowGreen); - m_outputSink << " 0 0 0 0 " << doubleToString(shadowBlue); - if(m_style["draw:opacity"] && m_style["draw:opacity"]->getDouble() < 1) - m_outputSink << " 0 0 0 " << doubleToString(m_style["draw:shadow-opacity"]->getDouble()/m_style["draw:opacity"]->getDouble()) << " 0\"/>"; - else - m_outputSink << " 0 0 0 " << doubleToString(m_style["draw:shadow-opacity"]->getDouble()) << " 0\"/>"; - - m_outputSink << "<" << getNamespaceAndDelim() << "feMerge>"; - m_outputSink << "<" << getNamespaceAndDelim() << "feMergeNode in=\"offset-color\" />"; - m_outputSink << "<" << getNamespaceAndDelim() << "feMergeNode in=\"SourceGraphic\" />"; - m_outputSink << "</" << getNamespaceAndDelim() << "feMerge>"; - m_outputSink << "</" << getNamespaceAndDelim() << "filter>"; - m_outputSink << "</" << getNamespaceAndDelim() << "defs>"; - } - - if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "gradient" && m_style["draw:style"]) - { - double angle = (m_style["draw:angle"] ? m_style["draw:angle"]->getDouble() : 0.0); - angle *= -1.0; - while(angle < 0) - angle += 360; - while(angle > 360) - angle -= 360; - - if (m_style["draw:style"]->getStr() == "radial" || m_style["draw:style"]->getStr() == "rectangular" || - m_style["draw:style"]->getStr() == "square" || m_style["draw:style"]->getStr() == "ellipsoid") - { - m_outputSink << "<" << getNamespaceAndDelim() << "defs>\n"; - m_outputSink << " <" << getNamespaceAndDelim() << "radialGradient id=\"grad" << m_gradientIndex++ << "\""; - - if (m_style["svg:cx"]) - m_outputSink << " cx=\"" << m_style["svg:cx"]->getStr().cstr() << "\""; - else if (m_style["draw:cx"]) - m_outputSink << " cx=\"" << m_style["draw:cx"]->getStr().cstr() << "\""; - - if (m_style["svg:cy"]) - m_outputSink << " cy=\"" << m_style["svg:cy"]->getStr().cstr() << "\""; - else if (m_style["draw:cy"]) - m_outputSink << " cy=\"" << m_style["draw:cy"]->getStr().cstr() << "\""; - if (m_style["svg:r"]) - m_outputSink << " r=\"" << m_style["svg:r"]->getStr().cstr() << "\""; - else if (m_style["draw:border"]) - m_outputSink << " r=\"" << doubleToString((1 - m_style["draw:border"]->getDouble())*100.0) << "%\""; - else - m_outputSink << " r=\"100%\""; - m_outputSink << " >\n"; - if (m_gradient.count()) - { - for(unsigned c = 0; c < m_gradient.count(); c++) - { - librevenge::RVNGPropertyList const &grad=m_gradient[c]; - m_outputSink << " <" << getNamespaceAndDelim() << "stop"; - if (grad["svg:offset"]) - m_outputSink << " offset=\"" << grad["svg:offset"]->getStr().cstr() << "\""; - if (grad["svg:stop-color"]) - m_outputSink << " stop-color=\"" << grad["svg:stop-color"]->getStr().cstr() << "\""; - if (grad["svg:stop-opacity"]) - m_outputSink << " stop-opacity=\"" << doubleToString(grad["svg:stop-opacity"]->getDouble()) << "\""; - m_outputSink << "/>" << std::endl; - } - } - else if (m_style["draw:start-color"] && m_style["draw:end-color"]) - { - m_outputSink << " <" << getNamespaceAndDelim() << "stop offset=\"0%\""; - m_outputSink << " stop-color=\"" << m_style["draw:end-color"]->getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << doubleToString(m_style["librevenge:end-opacity"] ? m_style["librevenge:end-opacity"]->getDouble() : 1) << "\" />" << std::endl; - - m_outputSink << " <" << getNamespaceAndDelim() << "stop offset=\"100%\""; - m_outputSink << " stop-color=\"" << m_style["draw:start-color"]->getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << doubleToString(m_style["librevenge:start-opacity"] ? m_style["librevenge:start-opacity"]->getDouble() : 1) << "\" />" << std::endl; - } - m_outputSink << " </" << getNamespaceAndDelim() << "radialGradient>\n"; - m_outputSink << "</" << getNamespaceAndDelim() << "defs>\n"; - } - else if (m_style["draw:style"]->getStr() == "linear" || m_style["draw:style"]->getStr() == "axial") - { - m_outputSink << "<" << getNamespaceAndDelim() << "defs>\n"; - m_outputSink << " <" << getNamespaceAndDelim() << "linearGradient id=\"grad" << m_gradientIndex++ << "\" >\n"; - - if (m_gradient.count()) - { - bool canBuildAxial = false; - if (m_style["draw:style"]->getStr() == "axial") - { - // check if we can reconstruct the linear offset, ie. if each offset is a valid percent% - canBuildAxial = true; - for(unsigned c = 0; c < m_gradient.count(); ++c) - { - librevenge::RVNGPropertyList const &grad=m_gradient[c]; - if (!grad["svg:offset"] || grad["svg:offset"]->getDouble()<0 || grad["svg:offset"]->getDouble() > 1) - { - canBuildAxial=false; - break; - } - librevenge::RVNGString str=grad["svg:offset"]->getStr(); - int len=str.len(); - if (len<1 || str.cstr()[len-1]!='%') - { - canBuildAxial=false; - break; - } - } - } - if (canBuildAxial) - { - for(unsigned c = m_gradient.count(); c>0 ; ) - { - librevenge::RVNGPropertyList const &grad=m_gradient[--c]; - m_outputSink << " <" << getNamespaceAndDelim() << "stop "; - if (grad["svg:offset"]) - m_outputSink << "offset=\"" << doubleToString(50.-50.*grad["svg:offset"]->getDouble()) << "%\""; - if (grad["svg:stop-color"]) - m_outputSink << " stop-color=\"" << grad["svg:stop-color"]->getStr().cstr() << "\""; - if (grad["svg:stop-opacity"]) - m_outputSink << " stop-opacity=\"" << doubleToString(grad["svg:stop-opacity"]->getDouble()) << "\""; - m_outputSink << "/>" << std::endl; - } - for(unsigned c = 0; c < m_gradient.count(); ++c) - { - librevenge::RVNGPropertyList const &grad=m_gradient[c]; - if (c==0 && grad["svg:offset"] && grad["svg:offset"]->getDouble() <= 0) - continue; - m_outputSink << " <" << getNamespaceAndDelim() << "stop "; - if (grad["svg:offset"]) - m_outputSink << "offset=\"" << doubleToString(50.+50.*grad["svg:offset"]->getDouble()) << "%\""; - if (grad["svg:stop-color"]) - m_outputSink << " stop-color=\"" << grad["svg:stop-color"]->getStr().cstr() << "\""; - if (grad["svg:stop-opacity"]) - m_outputSink << " stop-opacity=\"" << doubleToString(grad["svg:stop-opacity"]->getDouble()) << "\""; - m_outputSink << "/>" << std::endl; - } - } - else - { - for(unsigned c = 0; c < m_gradient.count(); c++) - { - librevenge::RVNGPropertyList const &grad=m_gradient[c]; - m_outputSink << " <" << getNamespaceAndDelim() << "stop"; - if (grad["svg:offset"]) - m_outputSink << " offset=\"" << grad["svg:offset"]->getStr().cstr() << "\""; - if (grad["svg:stop-color"]) - m_outputSink << " stop-color=\"" << grad["svg:stop-color"]->getStr().cstr() << "\""; - if (grad["svg:stop-opacity"]) - m_outputSink << " stop-opacity=\"" << doubleToString(grad["svg:stop-opacity"]->getDouble()) << "\""; - m_outputSink << "/>" << std::endl; - } - } - } - else if (m_style["draw:start-color"] && m_style["draw:end-color"]) - { - if (m_style["draw:style"]->getStr() == "linear") - { - m_outputSink << " <" << getNamespaceAndDelim() << "stop offset=\"0%\""; - m_outputSink << " stop-color=\"" << m_style["draw:start-color"]->getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << doubleToString(m_style["librevenge:start-opacity"] ? m_style["librevenge:start-opacity"]->getDouble() : 1) << "\" />" << std::endl; - - m_outputSink << " <" << getNamespaceAndDelim() << "stop offset=\"100%\""; - m_outputSink << " stop-color=\"" << m_style["draw:end-color"]->getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << doubleToString(m_style["librevenge:end-opacity"] ? m_style["librevenge:end-opacity"]->getDouble() : 1) << "\" />" << std::endl; - } - else - { - m_outputSink << " <" << getNamespaceAndDelim() << "stop offset=\"0%\""; - m_outputSink << " stop-color=\"" << m_style["draw:end-color"]->getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << doubleToString(m_style["librevenge:end-opacity"] ? m_style["librevenge:end-opacity"]->getDouble() : 1) << "\" />" << std::endl; - - m_outputSink << " <" << getNamespaceAndDelim() << "stop offset=\"50%\""; - m_outputSink << " stop-color=\"" << m_style["draw:start-color"]->getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << doubleToString(m_style["librevenge:start-opacity"] ? m_style["librevenge:start-opacity"]->getDouble() : 1) << "\" />" << std::endl; - - m_outputSink << " <" << getNamespaceAndDelim() << "stop offset=\"100%\""; - m_outputSink << " stop-color=\"" << m_style["draw:end-color"]->getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << doubleToString(m_style["librevenge:end-opacity"] ? m_style["librevenge:end-opacity"]->getDouble() : 1) << "\" />" << std::endl; - } - } - m_outputSink << " </" << getNamespaceAndDelim() << "linearGradient>\n"; - - // not a simple horizontal gradient - if(angle != 270) - { - m_outputSink << " <" << getNamespaceAndDelim() << "linearGradient xlink:href=\"#grad" << m_gradientIndex-1 << "\""; - m_outputSink << " id=\"grad" << m_gradientIndex++ << "\" "; - m_outputSink << "x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\" "; - m_outputSink << "gradientTransform=\"rotate(" << angle << " .5 .5)\" "; - m_outputSink << "gradientUnits=\"objectBoundingBox\" >\n"; - m_outputSink << " </" << getNamespaceAndDelim() << "linearGradient>\n"; - } - - m_outputSink << "</" << getNamespaceAndDelim() << "defs>\n"; - } - } - else if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "bitmap" && m_style["draw:fill-image"] && m_style["librevenge:mime-type"]) - { - m_outputSink << "<" << getNamespaceAndDelim() << "defs>\n"; - m_outputSink << " <" << getNamespaceAndDelim() << "pattern id=\"img" << m_patternIndex++ << "\" patternUnits=\"userSpaceOnUse\" "; - if (m_style["svg:width"]) - m_outputSink << "width=\"" << doubleToString(72*(m_style["svg:width"]->getDouble())) << "\" "; - else - m_outputSink << "width=\"100\" "; - - if (m_style["svg:height"]) - m_outputSink << "height=\"" << doubleToString(72*(m_style["svg:height"]->getDouble())) << "\">" << std::endl; - else - m_outputSink << "height=\"100\">" << std::endl; - m_outputSink << "<" << getNamespaceAndDelim() << "image "; - - if (m_style["svg:x"]) - m_outputSink << "x=\"" << doubleToString(72*(m_style["svg:x"]->getDouble())) << "\" "; - else - m_outputSink << "x=\"0\" "; - - if (m_style["svg:y"]) - m_outputSink << "y=\"" << doubleToString(72*(m_style["svg:y"]->getDouble())) << "\" "; - else - m_outputSink << "y=\"0\" "; - - if (m_style["svg:width"]) - m_outputSink << "width=\"" << doubleToString(72*(m_style["svg:width"]->getDouble())) << "\" "; - else - m_outputSink << "width=\"100\" "; - - if (m_style["svg:height"]) - m_outputSink << "height=\"" << doubleToString(72*(m_style["svg:height"]->getDouble())) << "\" "; - else - m_outputSink << "height=\"100\" "; - - m_outputSink << "xlink:href=\"data:" << m_style["librevenge:mime-type"]->getStr().cstr() << ";base64,"; - m_outputSink << m_style["draw:fill-image"]->getStr().cstr(); - m_outputSink << "\" />\n"; - m_outputSink << " </" << getNamespaceAndDelim() << "pattern>\n"; - m_outputSink << "</" << getNamespaceAndDelim() << "defs>\n"; - } - - // check for arrow and if find some, define a basic arrow - if (m_style["draw:marker-start-path"]) - { - m_outputSink << "<" << getNamespaceAndDelim() << "defs>\n"; - m_outputSink << "<" << getNamespaceAndDelim() << "marker id=\"startMarker" << m_arrowStartIndex++ << "\" "; - m_outputSink << " markerUnits=\"strokeWidth\" orient=\"auto\" markerWidth=\"8\" markerHeight=\"6\"\n"; - m_outputSink << " viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\">\n"; - m_outputSink << "<" << getNamespaceAndDelim() << "polyline points=\"10,0 0,5 10,10 9,5\" fill=\"solid\" />\n"; - m_outputSink << "</" << getNamespaceAndDelim() << "marker>\n"; - m_outputSink << "</" << getNamespaceAndDelim() << "defs>\n"; - } - if (m_style["draw:marker-end-path"]) - { - m_outputSink << "<" << getNamespaceAndDelim() << "defs>\n"; - m_outputSink << "<" << getNamespaceAndDelim() << "marker id=\"endMarker" << m_arrowEndIndex++ << "\" "; - m_outputSink << " markerUnits=\"strokeWidth\" orient=\"auto\" markerWidth=\"8\" markerHeight=\"6\"\n"; - m_outputSink << " viewBox=\"0 0 10 10\" refX=\"1\" refY=\"5\">\n"; - m_outputSink << "<" << getNamespaceAndDelim() << "polyline points=\"0,0 10,5 0,10 1,5\" fill=\"solid\" />\n"; - m_outputSink << "</" << getNamespaceAndDelim() << "marker>\n"; - m_outputSink << "</" << getNamespaceAndDelim() << "defs>\n"; - } -} - -// create "style" attribute based on current pen and brush -void VSDSVGGeneratorPrivate::writeStyle(bool /* isClosed */) -{ - m_outputSink << "style=\""; - - double width = 1.0 / 72.0; - if (m_style["svg:stroke-width"]) - { - width = m_style["svg:stroke-width"]->getDouble(); -#if 0 - // add me in libmspub and libcdr - if (width <= 0.0 && m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() != "none") - width = 0.2 / 72.0; // reasonable hairline -#endif - m_outputSink << "stroke-width: " << doubleToString(72*width) << "; "; - } - - if (m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() != "none") - { - if (m_style["svg:stroke-color"]) - m_outputSink << "stroke: " << m_style["svg:stroke-color"]->getStr().cstr() << "; "; - if(m_style["svg:stroke-opacity"] && m_style["svg:stroke-opacity"]->getInt()!= 1) - m_outputSink << "stroke-opacity: " << doubleToString(m_style["svg:stroke-opacity"]->getDouble()) << "; "; - } - - if (m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() == "solid") - m_outputSink << "stroke-dasharray: none; "; - else if (m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() == "dash") - { - int dots1 = m_style["draw:dots1"] ? m_style["draw:dots1"]->getInt() : 0; - int dots2 = m_style["draw:dots2"] ? m_style["draw:dots2"]->getInt() : 0; - double dots1len = 72.*width, dots2len = 72.*width, gap = 72.*width; - if (m_style["draw:dots1-length"]) - { - dots1len = 72.*m_style["draw:dots1-length"]->getDouble(); - std::string str = m_style["draw:dots1-length"]->getStr().cstr(); - if (str.size() > 1 && str[str.size()-1]=='%') - dots1len *=width; - } - if (m_style["draw:dots2-length"]) - { - dots2len = 72.*m_style["draw:dots2-length"]->getDouble(); - std::string str = m_style["draw:dots2-length"]->getStr().cstr(); - if (str.size() > 1 && str[str.size()-1]=='%') - dots2len *=width; - } - if (m_style["draw:distance"]) - { - gap = 72.*m_style["draw:distance"]->getDouble(); - std::string str = m_style["draw:distance"]->getStr().cstr(); - if (str.size() > 1 && str[str.size()-1]=='%') - gap *=width; - } - m_outputSink << "stroke-dasharray: "; - for (int i = 0; i < dots1; i++) - { - if (i) - m_outputSink << ", "; - m_outputSink << doubleToString(dots1len); - m_outputSink << ", "; - m_outputSink << doubleToString(gap); - } - for (int j = 0; j < dots2; j++) - { - m_outputSink << ", "; - m_outputSink << doubleToString(dots2len); - m_outputSink << ", "; - m_outputSink << doubleToString(gap); - } - m_outputSink << "; "; - } - - if (m_style["svg:stroke-linecap"]) - m_outputSink << "stroke-linecap: " << m_style["svg:stroke-linecap"]->getStr().cstr() << "; "; - - if (m_style["svg:stroke-linejoin"]) - m_outputSink << "stroke-linejoin: " << m_style["svg:stroke-linejoin"]->getStr().cstr() << "; "; - - if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "none") - m_outputSink << "fill: none; "; - else if(m_style["svg:fill-rule"]) - m_outputSink << "fill-rule: " << m_style["svg:fill-rule"]->getStr().cstr() << "; "; - - if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "gradient") - m_outputSink << "fill: url(#grad" << m_gradientIndex-1 << "); "; - else if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "bitmap") - m_outputSink << "fill: url(#img" << m_patternIndex-1 << "); "; - - if(m_style["draw:shadow"] && m_style["draw:shadow"]->getStr() == "visible") - m_outputSink << "filter:url(#shadow" << m_shadowIndex-1 << "); "; - - if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "solid") - if (m_style["draw:fill-color"]) - m_outputSink << "fill: " << m_style["draw:fill-color"]->getStr().cstr() << "; "; - if(m_style["draw:opacity"] && m_style["draw:opacity"]->getDouble() < 1) - m_outputSink << "fill-opacity: " << doubleToString(m_style["draw:opacity"]->getDouble()) << "; "; - - if (m_style["draw:marker-start-path"]) - m_outputSink << "marker-start: url(#startMarker" << m_arrowStartIndex-1 << "); "; - if (m_style["draw:marker-end-path"]) - m_outputSink << "marker-end: url(#endMarker" << m_arrowEndIndex-1 << "); "; - - m_outputSink << "\""; // style -} - - -VSDSVGGenerator::VSDSVGGenerator(librevenge::RVNGStringVector &vec, const librevenge::RVNGString &nmSpace) : - m_pImpl(new VSDSVGGeneratorPrivate(vec, nmSpace)) -{ -} - -VSDSVGGenerator::~VSDSVGGenerator() -{ - delete m_pImpl; -} - -void VSDSVGGenerator::startPage(const librevenge::RVNGPropertyList &propList) -{ - if (m_pImpl->m_nmSpace.empty()) - { - m_pImpl->m_outputSink << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"; - m_pImpl->m_outputSink << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\""; - m_pImpl->m_outputSink << " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"; - } - m_pImpl->m_outputSink << "<" << m_pImpl->getNamespaceAndDelim() << "svg version=\"1.1\" xmlns"; - m_pImpl->m_outputSink << (m_pImpl->m_nmSpace.empty() ? "" : ":") << m_pImpl->m_nmSpace << "=\"http://www.w3.org/2000/svg\" "; - m_pImpl->m_outputSink << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" "; - if (propList["svg:width"]) - m_pImpl->m_outputSink << "width=\"" << doubleToString(72*(propList["svg:width"]->getDouble())) << "\" "; - if (propList["svg:height"]) - m_pImpl->m_outputSink << "height=\"" << doubleToString(72*(propList["svg:height"]->getDouble())) << "\""; - m_pImpl->m_outputSink << " >\n"; -} - -void VSDSVGGenerator::endPage() -{ - m_pImpl->m_outputSink << "</" << m_pImpl->getNamespaceAndDelim() << "svg>\n"; - m_pImpl->m_vec.append(m_pImpl->m_outputSink.str().c_str()); - m_pImpl->m_outputSink.str(""); -} - - -void VSDSVGGenerator::startLayer(const librevenge::RVNGPropertyList &propList) -{ - m_pImpl->m_outputSink << "<" << m_pImpl->getNamespaceAndDelim() << "g"; - if (propList["svg:id"]) - m_pImpl->m_outputSink << " id=\"Layer" << propList["svg:id"]->getStr().cstr() << "\""; - else - m_pImpl->m_outputSink << " id=\"Layer" << m_pImpl->m_layerId++ << "\""; - if (propList["svg:fill-rule"]) - m_pImpl->m_outputSink << " fill-rule=\"" << propList["svg:fill-rule"]->getStr().cstr() << "\""; - m_pImpl->m_outputSink << " >\n"; -} - -void VSDSVGGenerator::endLayer() -{ - m_pImpl->m_outputSink << "</" << m_pImpl->getNamespaceAndDelim() << "g>\n"; -} - -void VSDSVGGenerator::setStyle(const librevenge::RVNGPropertyList &propList, const librevenge::RVNGPropertyListVector &gradient) -{ - m_pImpl->setStyle(propList, gradient); -} - -void VSDSVGGenerator::drawRectangle(const librevenge::RVNGPropertyList &propList) -{ - if (!propList["svg:x"] || !propList["svg:y"] || !propList["svg:width"] || !propList["svg:height"]) - return; - m_pImpl->m_outputSink << "<" << m_pImpl->getNamespaceAndDelim() << "rect "; - m_pImpl->m_outputSink << "x=\"" << doubleToString(72*propList["svg:x"]->getDouble()) << "\" y=\"" << doubleToString(72*propList["svg:y"]->getDouble()) << "\" "; - m_pImpl->m_outputSink << "width=\"" << doubleToString(72*propList["svg:width"]->getDouble()) << "\" height=\"" << doubleToString(72*propList["svg:height"]->getDouble()) << "\" "; - if(propList["svg:rx"] && propList["svg:rx"]->getDouble() > 0 && propList["svg:ry"] && propList["svg:ry"]->getDouble()>0) - m_pImpl->m_outputSink << "rx=\"" << doubleToString(72*propList["svg:rx"]->getDouble()) << "\" ry=\"" << doubleToString(72*propList["svg:ry"]->getDouble()) << "\" "; - m_pImpl->writeStyle(); - m_pImpl->m_outputSink << "/>\n"; -} - -void VSDSVGGenerator::drawEllipse(const librevenge::RVNGPropertyList &propList) -{ - if (!propList["svg:cx"] || !propList["svg:cy"] || !propList["svg:rx"] || !propList["svg:ry"]) - return; - m_pImpl->m_outputSink << "<" << m_pImpl->getNamespaceAndDelim() << "ellipse "; - m_pImpl->m_outputSink << "cx=\"" << doubleToString(72*propList["svg:cx"]->getDouble()) << "\" cy=\"" << doubleToString(72*propList["svg:cy"]->getDouble()) << "\" "; - m_pImpl->m_outputSink << "rx=\"" << doubleToString(72*propList["svg:rx"]->getDouble()) << "\" ry=\"" << doubleToString(72*propList["svg:ry"]->getDouble()) << "\" "; - m_pImpl->writeStyle(); - if (propList["librevenge:rotate"] && propList["librevenge:rotate"]->getDouble() != 0.0) - m_pImpl->m_outputSink << " transform=\" rotate(" << doubleToString(-propList["librevenge:rotate"]->getDouble()) - << ", " << doubleToString(72*propList["svg:cy"]->getDouble()) - << ", " << doubleToString(72*propList["svg:cy"]->getDouble()) - << ")\" "; - m_pImpl->m_outputSink << "/>\n"; -} - -void VSDSVGGenerator::drawPolyline(const librevenge::RVNGPropertyListVector &vertices) -{ - m_pImpl->drawPolySomething(vertices, false); -} - -void VSDSVGGenerator::drawPolygon(const librevenge::RVNGPropertyListVector &vertices) -{ - m_pImpl->drawPolySomething(vertices, true); -} - -void VSDSVGGenerator::drawPath(const librevenge::RVNGPropertyListVector &path) -{ - m_pImpl->m_outputSink << "<" << m_pImpl->getNamespaceAndDelim() << "path d=\" "; - bool isClosed = false; - unsigned i=0; - for(i=0; i < path.count(); i++) - { - librevenge::RVNGPropertyList propList = path[i]; - if (!propList["librevenge:path-action"]) continue; - std::string action=propList["librevenge:path-action"]->getStr().cstr(); - if (action.length()!=1) continue; - bool coordOk=propList["svg:x"]&&propList["svg:y"]; - bool coord1Ok=coordOk && propList["svg:x1"]&&propList["svg:y1"]; - bool coord2Ok=coord1Ok && propList["svg:x2"]&&propList["svg:y2"]; - if (propList["svg:x"] && action[0] == 'H') - m_pImpl->m_outputSink << "\nH" << doubleToString(72*(propList["svg:x"]->getDouble())); - else if (propList["svg:y"] && action[0] == 'V') - m_pImpl->m_outputSink << "\nV" << doubleToString(72*(propList["svg:y"]->getDouble())); - else if (coordOk && (action[0] == 'M' || action[0] == 'L' || action[0] == 'T')) - { - m_pImpl->m_outputSink << "\n" << action; - m_pImpl->m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); - } - else if (coord1Ok && (action[0] == 'Q' || action[0] == 'S')) - { - m_pImpl->m_outputSink << "\n" << action; - m_pImpl->m_outputSink << doubleToString(72*(propList["svg:x1"]->getDouble())) << "," << doubleToString(72*(propList["svg:y1"]->getDouble())) << " "; - m_pImpl->m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); - } - else if (coord2Ok && action[0] == 'C') - { - m_pImpl->m_outputSink << "\nC"; - m_pImpl->m_outputSink << doubleToString(72*(propList["svg:x1"]->getDouble())) << "," << doubleToString(72*(propList["svg:y1"]->getDouble())) << " "; - m_pImpl->m_outputSink << doubleToString(72*(propList["svg:x2"]->getDouble())) << "," << doubleToString(72*(propList["svg:y2"]->getDouble())) << " "; - m_pImpl->m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); - } - else if (coordOk && propList["svg:rx"] && propList["svg:ry"] && action[0] == 'A') - { - m_pImpl->m_outputSink << "\nA"; - m_pImpl->m_outputSink << doubleToString(72*(propList["svg:rx"]->getDouble())) << "," << doubleToString(72*(propList["svg:ry"]->getDouble())) << " "; - m_pImpl->m_outputSink << doubleToString(propList["librevenge:rotate"] ? propList["librevenge:rotate"]->getDouble() : 0) << " "; - m_pImpl->m_outputSink << (propList["librevenge:large-arc"] ? propList["librevenge:large-arc"]->getInt() : 1) << ","; - m_pImpl->m_outputSink << (propList["librevenge:sweep"] ? propList["librevenge:sweep"]->getInt() : 1) << " "; - m_pImpl->m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); - } - else if (action[0] == 'Z' ) - { - isClosed = true; - m_pImpl->m_outputSink << "\nZ"; - } - } - - m_pImpl->m_outputSink << "\" \n"; - m_pImpl->writeStyle(isClosed); - m_pImpl->m_outputSink << "/>\n"; -} - -void VSDSVGGenerator::drawGraphicObject(const librevenge::RVNGPropertyList &propList, const librevenge::RVNGBinaryData &binaryData) -{ - if (!propList["librevenge:mime-type"] || propList["librevenge:mime-type"]->getStr().len() <= 0) - return; - librevenge::RVNGString base64 = binaryData.getBase64Data(); - m_pImpl->m_outputSink << "<" << m_pImpl->getNamespaceAndDelim() << "image "; - if (propList["svg:x"] && propList["svg:y"] && propList["svg:width"] && propList["svg:height"]) - { - double x(propList["svg:x"]->getDouble()); - double y(propList["svg:y"]->getDouble()); - double width(propList["svg:width"]->getDouble()); - double height(propList["svg:height"]->getDouble()); - bool flipX(propList["draw:mirror-horizontal"] && propList["draw:mirror-horizontal"]->getInt()); - bool flipY(propList["draw:mirror-vertical"] && propList["draw:mirror-vertical"]->getInt()); - - m_pImpl->m_outputSink << "x=\"" << doubleToString(72*x) << "\" y=\"" << doubleToString(72*y) << "\" "; - m_pImpl->m_outputSink << "width=\"" << doubleToString(72*width) << "\" height=\"" << doubleToString(72*height) << "\" "; - if (flipX || flipY || propList["librevenge:rotate"]) - { - double xmiddle = x + width / 2.0; - double ymiddle = y + height / 2.0; - m_pImpl->m_outputSink << "transform=\""; - m_pImpl->m_outputSink << " translate(" << doubleToString(72*xmiddle) << ", " << doubleToString (72*ymiddle) << ") "; - m_pImpl->m_outputSink << " scale(" << (flipX ? "-1" : "1") << ", " << (flipY ? "-1" : "1") << ") "; - // rotation is around the center of the object's bounding box - if (propList["librevenge:rotate"]) - { - double angle(propList["librevenge:rotate"]->getDouble()); - while (angle > 180.0) - angle -= 360.0; - while (angle < -180.0) - angle += 360.0; - m_pImpl->m_outputSink << " rotate(" << doubleToString(angle) << ") "; - } - m_pImpl->m_outputSink << " translate(" << doubleToString(-72*xmiddle) << ", " << doubleToString (-72*ymiddle) << ") "; - m_pImpl->m_outputSink << "\" "; - } - } - m_pImpl->m_outputSink << "xlink:href=\"data:" << propList["librevenge:mime-type"]->getStr().cstr() << ";base64,"; - m_pImpl->m_outputSink << base64.cstr(); - m_pImpl->m_outputSink << "\" />\n"; -} - -void VSDSVGGenerator::startTextObject(const librevenge::RVNGPropertyList &propList, const librevenge::RVNGPropertyListVector & /* path */) -{ - double x = 0.0; - double y = 0.0; - double height = 0.0; - m_pImpl->m_outputSink << "<" << m_pImpl->getNamespaceAndDelim() << "text "; - if (propList["svg:x"] && propList["svg:y"]) - { - x = propList["svg:x"]->getDouble(); - y = propList["svg:y"]->getDouble(); - } - - double xmiddle = x; - double ymiddle = y; - - if (propList["svg:width"]) - { - double width = propList["svg:width"]->getDouble(); - xmiddle += width / 2.0; - } - - if (propList["svg:height"]) - { - height = propList["svg:height"]->getDouble(); - ymiddle += height / 2.0; - } - - if (propList["draw:textarea-vertical-align"]) - { - if (propList["draw:textarea-vertical-align"]->getStr() == "middle") - y = ymiddle; - if (propList["draw:textarea-vertical-align"]->getStr() == "bottom") - { - y += height; - if (propList["fo:padding-bottom"]) - y -= propList["fo:padding-bottom"]->getDouble(); - } - } - else - y += height; - - if (propList["fo:padding-left"]) - x += propList["fo:padding-left"]->getDouble(); - - m_pImpl->m_outputSink << "x=\"" << doubleToString(72*x) << "\" y=\"" << doubleToString(72*y) << "\""; - - // rotation is around the center of the object's bounding box - if (propList["librevenge:rotate"] && propList["librevenge:rotate"]->getDouble() != 0.0) - { - double angle(propList["librevenge:rotate"]->getDouble()); - while (angle > 180.0) - angle -= 360.0; - while (angle < -180.0) - angle += 360.0; - m_pImpl->m_outputSink << " transform=\"rotate(" << doubleToString(angle) << ", " << doubleToString(72*xmiddle) << ", " << doubleToString(72*ymiddle) << ")\" "; - } - m_pImpl->m_outputSink << ">\n"; - -} - -void VSDSVGGenerator::endTextObject() -{ - m_pImpl->m_outputSink << "</" << m_pImpl->getNamespaceAndDelim() << "text>\n"; -} - -void VSDSVGGenerator::openSpan(const librevenge::RVNGPropertyList &propList) -{ - m_pImpl->m_outputSink << "<" << m_pImpl->getNamespaceAndDelim() << "tspan "; - if (propList["style:font-name"]) - m_pImpl->m_outputSink << "font-family=\"" << propList["style:font-name"]->getStr().cstr() << "\" "; - if (propList["fo:font-style"]) - m_pImpl->m_outputSink << "font-style=\"" << propList["fo:font-style"]->getStr().cstr() << "\" "; - if (propList["fo:font-weight"]) - m_pImpl->m_outputSink << "font-weight=\"" << propList["fo:font-weight"]->getStr().cstr() << "\" "; - if (propList["fo:font-variant"]) - m_pImpl->m_outputSink << "font-variant=\"" << propList["fo:font-variant"]->getStr().cstr() << "\" "; - if (propList["fo:font-size"]) - m_pImpl->m_outputSink << "font-size=\"" << doubleToString(propList["fo:font-size"]->getDouble()) << "\" "; - if (propList["fo:color"]) - m_pImpl->m_outputSink << "fill=\"" << propList["fo:color"]->getStr().cstr() << "\" "; - if (propList["fo:text-transform"]) - m_pImpl->m_outputSink << "text-transform=\"" << propList["fo:text-transform"]->getStr().cstr() << "\" "; - if (propList["svg:fill-opacity"]) - m_pImpl->m_outputSink << "fill-opacity=\"" << doubleToString(propList["svg:fill-opacity"]->getDouble()) << "\" "; - if (propList["svg:stroke-opacity"]) - m_pImpl->m_outputSink << "stroke-opacity=\"" << doubleToString(propList["svg:stroke-opacity"]->getDouble()) << "\" "; - m_pImpl->m_outputSink << ">\n"; -} - -void VSDSVGGenerator::closeSpan() -{ - m_pImpl->m_outputSink << "</" << m_pImpl->getNamespaceAndDelim() << "tspan>\n"; -} - -void VSDSVGGenerator::insertText(const librevenge::RVNGString &str) -{ - librevenge::RVNGString tempUTF8(str, true); - m_pImpl->m_outputSink << tempUTF8.cstr() << "\n"; -} - -} // namespace libvisio - -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDSVGGenerator.h b/src/lib/VSDSVGGenerator.h deleted file mode 100644 index 8440da0..0000000 --- a/src/lib/VSDSVGGenerator.h +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libvisio - * Version: MPL 1.1 / GPLv2+ / LGPLv2+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch> - * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com> - * - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPLv2+"), or - * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), - * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable - * instead of those above. - */ - -#ifndef __VISIOSVGGENERATOR_H__ -#define __VISIOSVGGENERATOR_H__ - -#include <stdio.h> -#include <iostream> -#include <sstream> -#include <librevenge/librevenge.h> -#include <libvisio/libvisio.h> - -namespace libvisio -{ -struct VSDSVGGeneratorPrivate; - -class VSDSVGGenerator : public librevenge::RVNGDrawingInterface -{ -public: - VSDSVGGenerator(librevenge::RVNGStringVector &vec, const librevenge::RVNGString &nmspace="svg"); - ~VSDSVGGenerator(); - - 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: - VSDSVGGenerator(const VSDSVGGenerator &); - VSDSVGGenerator &operator=(const VSDSVGGenerator &); - VSDSVGGeneratorPrivate *m_pImpl; -}; - -} // namespace libvisio - -#endif // __VISIOSVGGENERATOR_H__ -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VisioDocument.cpp b/src/lib/VisioDocument.cpp index f0db592..e11a9e2 100644 --- a/src/lib/VisioDocument.cpp +++ b/src/lib/VisioDocument.cpp @@ -33,7 +33,6 @@ #include <libvisio/libvisio.h> #include "libvisio_utils.h" #include "VDXParser.h" -#include "VSDSVGGenerator.h" #include "VSDParser.h" #include "VSDXParser.h" #include "VSD5Parser.h" @@ -414,34 +413,4 @@ bool libvisio::VisioDocument::parseStencils(librevenge::RVNGInputStream *input, } return false; } - - -/** -Parses the input stream content and generates a valid Scalable Vector Graphics -Provided as a convenience function for applications that support SVG internally. -\param input The input stream -\param output The output string whose content is the resulting SVG -\return A value that indicates whether the SVG generation was successful. -*/ -bool libvisio::VisioDocument::generateSVG(librevenge::RVNGInputStream *input, librevenge::RVNGStringVector &output) -{ - libvisio::VSDSVGGenerator generator(output); - bool result = libvisio::VisioDocument::parse(input, &generator); - return result; -} - -/** -Parses the input stream content and extracts stencil pages. It generates a valid -Scalable Vector Graphics document per stencil. -Provided as a convenience function for applications that support SVG internally. -\param input The input stream -\param output The output string whose content is the resulting SVG -\return A value that indicates whether the SVG generation was successful. -*/ -bool libvisio::VisioDocument::generateSVGStencils(librevenge::RVNGInputStream *input, librevenge::RVNGStringVector &output) -{ - libvisio::VSDSVGGenerator generator(output); - bool result = libvisio::VisioDocument::parseStencils(input, &generator); - return result; -} /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ |