From 77251b4d7a15c16afca15a64dbe74e1d7aee98e7 Mon Sep 17 00:00:00 2001 From: Fridrich Štrba Date: Thu, 14 Jun 2012 15:48:14 +0200 Subject: Cleanup of the skeleton --- configure.ac | 16 +- libmspub.spec.in | 97 ------- libpgplus-0.0.pc.in | 4 +- libpgplus.spec.in | 97 +++++++ src/conv/raw/.gitignore | 4 +- src/conv/raw/Makefile.am | 10 +- src/conv/raw/ppp2raw.cpp | 2 +- src/conv/svg/.gitignore | 8 +- src/conv/svg/Makefile.am | 10 +- src/conv/svg/ppp2xhtml.cpp | 2 +- src/lib/.gitignore | 1 - src/lib/MSPUBCollector.cpp | 41 --- src/lib/MSPUBCollector.h | 62 ----- src/lib/MSPUBDocument.cpp | 87 ------ src/lib/MSPUBDocument.h | 54 ---- src/lib/MSPUBParser.cpp | 95 ------- src/lib/MSPUBParser.h | 62 ----- src/lib/MSPUBSVGGenerator.cpp | 616 ----------------------------------------- src/lib/MSPUBSVGGenerator.h | 88 ------ src/lib/MSPUBStringVector.cpp | 93 ------- src/lib/MSPUBStringVector.h | 60 ---- src/lib/PGPLUSCollector.cpp | 41 +++ src/lib/PGPLUSCollector.h | 62 +++++ src/lib/PGPLUSDocument.cpp | 67 +++++ src/lib/PGPLUSDocument.h | 54 ++++ src/lib/PGPLUSParser.cpp | 66 +++++ src/lib/PGPLUSParser.h | 62 +++++ src/lib/PGPLUSSVGGenerator.cpp | 616 +++++++++++++++++++++++++++++++++++++++++ src/lib/PGPLUSSVGGenerator.h | 88 ++++++ src/lib/PGPLUSStringVector.cpp | 93 +++++++ src/lib/PGPLUSStringVector.h | 60 ++++ src/lib/libmspub.h | 37 --- src/lib/libmspub.rc.in | 31 --- src/lib/libmspub_utils.cpp | 81 ------ src/lib/libmspub_utils.h | 98 ------- src/lib/libpgplus.h | 37 +++ src/lib/libpgplus.rc.in | 31 +++ src/lib/libpgplus_utils.cpp | 81 ++++++ src/lib/libpgplus_utils.h | 98 +++++++ src/lib/makefile.mk | 5 +- 40 files changed, 1585 insertions(+), 1632 deletions(-) delete mode 100644 libmspub.spec.in create mode 100644 libpgplus.spec.in delete mode 100644 src/lib/MSPUBCollector.cpp delete mode 100644 src/lib/MSPUBCollector.h delete mode 100644 src/lib/MSPUBDocument.cpp delete mode 100644 src/lib/MSPUBDocument.h delete mode 100644 src/lib/MSPUBParser.cpp delete mode 100644 src/lib/MSPUBParser.h delete mode 100644 src/lib/MSPUBSVGGenerator.cpp delete mode 100644 src/lib/MSPUBSVGGenerator.h delete mode 100644 src/lib/MSPUBStringVector.cpp delete mode 100644 src/lib/MSPUBStringVector.h create mode 100644 src/lib/PGPLUSCollector.cpp create mode 100644 src/lib/PGPLUSCollector.h create mode 100644 src/lib/PGPLUSDocument.cpp create mode 100644 src/lib/PGPLUSDocument.h create mode 100644 src/lib/PGPLUSParser.cpp create mode 100644 src/lib/PGPLUSParser.h create mode 100644 src/lib/PGPLUSSVGGenerator.cpp create mode 100644 src/lib/PGPLUSSVGGenerator.h create mode 100644 src/lib/PGPLUSStringVector.cpp create mode 100644 src/lib/PGPLUSStringVector.h delete mode 100644 src/lib/libmspub.h delete mode 100644 src/lib/libmspub.rc.in delete mode 100644 src/lib/libmspub_utils.cpp delete mode 100644 src/lib/libmspub_utils.h create mode 100644 src/lib/libpgplus.h create mode 100644 src/lib/libpgplus.rc.in create mode 100644 src/lib/libpgplus_utils.cpp create mode 100644 src/lib/libpgplus_utils.h diff --git a/configure.ac b/configure.ac index fb5f2f3..9a79dd1 100644 --- a/configure.ac +++ b/configure.ac @@ -66,20 +66,20 @@ AS_CASE([$host], [*-*-mingw*], [ native_win32=yes LIBPGPLUS_WIN32_RESOURCE=libpgplus-win32res.lo - PUB2RAW_WIN32_RESOURCE=pub2raw-win32res.lo - PUB2XHTML_WIN32_RESOURCE=pub2xhtml-win32res.lo + PPP2RAW_WIN32_RESOURCE=ppp2raw-win32res.lo + PPP2XHTML_WIN32_RESOURCE=ppp2xhtml-win32res.lo ], [ native_win32=no LIBPGPLUS_WIN32_RESOURCE= - PUB2RAW_WIN32_RESOURCE= - PUB2XHTML_WIN32_RESOURCE= + PPP2RAW_WIN32_RESOURCE= + PPP2XHTML_WIN32_RESOURCE= ] ) AC_MSG_RESULT([$native_win32]) AM_CONDITIONAL(OS_WIN32, [test "x$native_win32" = "xyes"]) AC_SUBST(LIBPGPLUS_WIN32_RESOURCE) -AC_SUBST(PUB2RAW_WIN32_RESOURCE) -AC_SUBST(PUB2XHTML_WIN32_RESOURCE) +AC_SUBST(PPP2RAW_WIN32_RESOURCE) +AC_SUBST(PPP2XHTML_WIN32_RESOURCE) AC_MSG_CHECKING([for Win32 platform in general]) AS_CASE([$host], @@ -191,9 +191,9 @@ Makefile src/Makefile src/conv/Makefile src/conv/raw/Makefile -src/conv/raw/pub2raw.rc +src/conv/raw/ppp2raw.rc src/conv/svg/Makefile -src/conv/svg/pub2xhtml.rc +src/conv/svg/ppp2xhtml.rc src/lib/Makefile src/lib/libpgplus.rc build/Makefile diff --git a/libmspub.spec.in b/libmspub.spec.in deleted file mode 100644 index e384758..0000000 --- a/libmspub.spec.in +++ /dev/null @@ -1,97 +0,0 @@ -%define name libpgplus -%define version @VERSION@ -%define RELEASE 1 -%define release %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE} - -Name: %{name} -Summary: Library for importing and converting Microsoft Publisher Documents -Version: %{version} -Release: %{release} -Source: %{name}-%{version}.tar.gz -Group: System Environment/Libraries -URL: http://libpgplus.sf.net/ -BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot -BuildRequires: libwpd-devel >= 0.9.0, gcc-c++, libstdc++-devel, pkgconfig >= 0.9.0 -License: LGPL -Prefix: %{prefix} - -%description -libpgplus is a library for reading and converting PGPLUS images - -%package tools -Requires: libpgplus -Summary: Tools to convert PGPLUS images into other formats -Group: Applications/Publishing - -%description tools -Tools to convert PGPLUS images into other formats. -Currently supported: raw svg - -%package devel -Requires: %{name} >= %{version} -Requires: libwpd-devel >= 0.9.0 -Summary: Files for developing with libpgplus. -Group: Development/Libraries - -%description devel -Includes and definitions for developing with libpgplus. - -%if %{!?_without_docs:1}%{?_without_docs:0} -%package docs -Requires: %{name} >= %{version} -BuildRequires: doxygen -Summary: Documentation of libpgplus API -Group: Development/Documentation - -%description docs -Documentation of libpgplus API for developing with libpgplus -%endif - -%prep -%__rm -rf $RPM_BUILD_ROOT - -%setup -q -n %{name}-%{version} - -%build -%configure --prefix=%{_prefix} --libdir=%{_libdir} \ - %{?_with_debug:--enable-debug} \ - -%__make - -%install -umask 022 - -%__make DESTDIR=$RPM_BUILD_ROOT install -%__rm -rf $RPM_BUILD_ROOT/%{_libdir}/libpgplus*.la - -%clean -%__rm -rf $RPM_BUILD_ROOT $RPM_BUILD_DIR/file.list.%{name} - -%files -%defattr(644,root,root,755) -%{_libdir}/libpgplus*.so.* -%doc ChangeLog README COPYING AUTHORS - -%files tools -%defattr(755,root,root,755) -%{_bindir}/pub2* - -%files devel -%defattr(644,root,root,755) -%{_libdir}/libpgplus*.so -%{_libdir}/pkgconfig/libpgplus*.pc -%{_includedir}/libpgplus-@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@/libpgplus - -%if %{!?_without_docs:1}%{?_without_docs:0} -%files docs -%{_datadir}/* -%endif - -%changelog -* Fri Apr 20 2007 Fridrich Strba -- Add documentation packaging -- Make doc and stream optional - -* Tue Jan 27 2004 Fridrich Strba -- Create rpm spec according to the rpm spec of libwpD -- of Rui M. Seabra diff --git a/libpgplus-0.0.pc.in b/libpgplus-0.0.pc.in index bbc11c9..7c602d5 100644 --- a/libpgplus-0.0.pc.in +++ b/libpgplus-0.0.pc.in @@ -4,8 +4,8 @@ libdir=@libdir@ includedir=@includedir@ Name: libpgplus-@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@ -Description: Library for parsing the Microsoft Publisher file format structure +Description: Library for parsing the PagePlus file format structure Version: @VERSION@ Requires: libwpd-0.9 libwpd-stream-0.9 libwpg-0.2 -Libs: -L${libdir} -lmspub-@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@ +Libs: -L${libdir} -lpgplus-@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@ Cflags: -I${includedir}/libpgplus-@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@ diff --git a/libpgplus.spec.in b/libpgplus.spec.in new file mode 100644 index 0000000..9d2d83c --- /dev/null +++ b/libpgplus.spec.in @@ -0,0 +1,97 @@ +%define name libpgplus +%define version @VERSION@ +%define RELEASE 1 +%define release %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE} + +Name: %{name} +Summary: Library for importing and converting PagePlus Documents +Version: %{version} +Release: %{release} +Source: %{name}-%{version}.tar.gz +Group: System Environment/Libraries +URL: http://libpgplus.sf.net/ +BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot +BuildRequires: libwpd-devel >= 0.9.0, gcc-c++, libstdc++-devel, pkgconfig >= 0.9.0 +License: LGPL +Prefix: %{prefix} + +%description +libpgplus is a library for reading and converting PGPLUS images + +%package tools +Requires: libpgplus +Summary: Tools to convert PGPLUS images into other formats +Group: Applications/Publishing + +%description tools +Tools to convert PGPLUS images into other formats. +Currently supported: raw svg + +%package devel +Requires: %{name} >= %{version} +Requires: libwpd-devel >= 0.9.0 +Summary: Files for developing with libpgplus. +Group: Development/Libraries + +%description devel +Includes and definitions for developing with libpgplus. + +%if %{!?_without_docs:1}%{?_without_docs:0} +%package docs +Requires: %{name} >= %{version} +BuildRequires: doxygen +Summary: Documentation of libpgplus API +Group: Development/Documentation + +%description docs +Documentation of libpgplus API for developing with libpgplus +%endif + +%prep +%__rm -rf $RPM_BUILD_ROOT + +%setup -q -n %{name}-%{version} + +%build +%configure --prefix=%{_prefix} --libdir=%{_libdir} \ + %{?_with_debug:--enable-debug} \ + +%__make + +%install +umask 022 + +%__make DESTDIR=$RPM_BUILD_ROOT install +%__rm -rf $RPM_BUILD_ROOT/%{_libdir}/libpgplus*.la + +%clean +%__rm -rf $RPM_BUILD_ROOT $RPM_BUILD_DIR/file.list.%{name} + +%files +%defattr(644,root,root,755) +%{_libdir}/libpgplus*.so.* +%doc ChangeLog README COPYING AUTHORS + +%files tools +%defattr(755,root,root,755) +%{_bindir}/pub2* + +%files devel +%defattr(644,root,root,755) +%{_libdir}/libpgplus*.so +%{_libdir}/pkgconfig/libpgplus*.pc +%{_includedir}/libpgplus-@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@/libpgplus + +%if %{!?_without_docs:1}%{?_without_docs:0} +%files docs +%{_datadir}/* +%endif + +%changelog +* Fri Apr 20 2007 Fridrich Strba +- Add documentation packaging +- Make doc and stream optional + +* Tue Jan 27 2004 Fridrich Strba +- Create rpm spec according to the rpm spec of libwpD +- of Rui M. Seabra diff --git a/src/conv/raw/.gitignore b/src/conv/raw/.gitignore index 3e93fbe..816c109 100644 --- a/src/conv/raw/.gitignore +++ b/src/conv/raw/.gitignore @@ -4,6 +4,6 @@ *.la Makefile Makefile.in -pub2raw -pub2raw.exe +ppp2raw +ppp2raw.exe *.rc diff --git a/src/conv/raw/Makefile.am b/src/conv/raw/Makefile.am index 2be9f6b..12a8cbf 100644 --- a/src/conv/raw/Makefile.am +++ b/src/conv/raw/Makefile.am @@ -2,13 +2,13 @@ bin_PROGRAMS = ppp2raw AM_CXXFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib $(LIBPGPLUS_CXXFLAGS) $(DEBUG_CXXFLAGS) -ppp2raw_DEPENDENCIES = @PUB2RAW_WIN32_RESOURCE@ +ppp2raw_DEPENDENCIES = @PPP2RAW_WIN32_RESOURCE@ if STATIC_TOOLS -ppp2raw_LDADD = ../../lib/@PGPLUS_OBJDIR@/libpgplus-@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@.a $(LIBPGPLUS_LIBS) @PUB2RAW_WIN32_RESOURCE@ +ppp2raw_LDADD = ../../lib/@PGPLUS_OBJDIR@/libpgplus-@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@.a $(LIBPGPLUS_LIBS) @PPP2RAW_WIN32_RESOURCE@ ppp2raw_LDFLAGS = -all-static else -ppp2raw_LDADD = ../../lib/libpgplus-@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@.la $(LIBPGPLUS_LIBS) @PUB2RAW_WIN32_RESOURCE@ +ppp2raw_LDADD = ../../lib/libpgplus-@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@.la $(LIBPGPLUS_LIBS) @PPP2RAW_WIN32_RESOURCE@ endif ppp2raw_SOURCES = \ @@ -16,9 +16,9 @@ ppp2raw_SOURCES = \ if OS_WIN32 -@PUB2RAW_WIN32_RESOURCE@ : ppp2raw.rc $(ppp2raw_OBJECTS) +@PPP2RAW_WIN32_RESOURCE@ : ppp2raw.rc $(ppp2raw_OBJECTS) chmod +x $(top_srcdir)/build/win32/*compile-resource - WINDRES=@WINDRES@ $(top_srcdir)/build/win32/lt-compile-resource ppp2raw.rc @PUB2RAW_WIN32_RESOURCE@ + WINDRES=@WINDRES@ $(top_srcdir)/build/win32/lt-compile-resource ppp2raw.rc @PPP2RAW_WIN32_RESOURCE@ endif EXTRA_DIST = \ diff --git a/src/conv/raw/ppp2raw.cpp b/src/conv/raw/ppp2raw.cpp index e4638b7..eb91ed9 100644 --- a/src/conv/raw/ppp2raw.cpp +++ b/src/conv/raw/ppp2raw.cpp @@ -214,7 +214,7 @@ namespace int printUsage() { - printf("Usage: ppp2raw [OPTION] \n"); + printf("Usage: ppp2raw [OPTION] \n"); printf("\n"); printf("Options:\n"); printf("--help Shows this help message\n"); diff --git a/src/conv/svg/.gitignore b/src/conv/svg/.gitignore index 3ef58b3..f8be790 100644 --- a/src/conv/svg/.gitignore +++ b/src/conv/svg/.gitignore @@ -4,8 +4,8 @@ *.la Makefile Makefile.in -pub2svg -pub2svg.exe -pub2xhtml -pub2xhtml.exe +ppp2svg +ppp2svg.exe +ppp2xhtml +ppp2xhtml.exe *.rc diff --git a/src/conv/svg/Makefile.am b/src/conv/svg/Makefile.am index cdcb53f..b4568cd 100644 --- a/src/conv/svg/Makefile.am +++ b/src/conv/svg/Makefile.am @@ -2,13 +2,13 @@ bin_PROGRAMS = ppp2xhtml AM_CXXFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib $(LIBPGPLUS_CXXFLAGS) $(DEBUG_CXXFLAGS) -ppp2xhtml_DEPENDENCIES = @PUB2XHTML_WIN32_RESOURCE@ +ppp2xhtml_DEPENDENCIES = @PPP2XHTML_WIN32_RESOURCE@ if STATIC_TOOLS -ppp2xhtml_LDADD = ../../lib/@PGPLUS_OBJDIR@/libpgplus-@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@.a $(LIBPGPLUS_LIBS) @PUB2XHTML_WIN32_RESOURCE@ +ppp2xhtml_LDADD = ../../lib/@PGPLUS_OBJDIR@/libpgplus-@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@.a $(LIBPGPLUS_LIBS) @PPP2XHTML_WIN32_RESOURCE@ ppp2xhtml_LDFLAGS = -all-static else -ppp2xhtml_LDADD = ../../lib/libpgplus-@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@.la $(LIBPGPLUS_LIBS) @PUB2XHTML_WIN32_RESOURCE@ +ppp2xhtml_LDADD = ../../lib/libpgplus-@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@.la $(LIBPGPLUS_LIBS) @PPP2XHTML_WIN32_RESOURCE@ endif ppp2xhtml_SOURCES = \ @@ -16,9 +16,9 @@ ppp2xhtml_SOURCES = \ if OS_WIN32 -@PUB2XHTML_WIN32_RESOURCE@ : ppp2xhtml.rc $(ppp2xhtml_OBJECTS) +@PPP2XHTML_WIN32_RESOURCE@ : ppp2xhtml.rc $(ppp2xhtml_OBJECTS) chmod +x $(top_srcdir)/build/win32/*compile-resource - WINDRES=@WINDRES@ $(top_srcdir)/build/win32/lt-compile-resource ppp2xhtml.rc @PUB2XHTML_WIN32_RESOURCE@ + WINDRES=@WINDRES@ $(top_srcdir)/build/win32/lt-compile-resource ppp2xhtml.rc @PPP2XHTML_WIN32_RESOURCE@ endif EXTRA_DIST = \ diff --git a/src/conv/svg/ppp2xhtml.cpp b/src/conv/svg/ppp2xhtml.cpp index d439292..6d4f303 100644 --- a/src/conv/svg/ppp2xhtml.cpp +++ b/src/conv/svg/ppp2xhtml.cpp @@ -41,7 +41,7 @@ namespace int printUsage() { - printf("Usage: vsd2xhtml [OPTION] \n"); + printf("Usage: vsd2xhtml [OPTION] \n"); printf("\n"); printf("Options:\n"); printf("--help Shows this help message\n"); diff --git a/src/lib/.gitignore b/src/lib/.gitignore index c086f3e..3273b70 100644 --- a/src/lib/.gitignore +++ b/src/lib/.gitignore @@ -6,4 +6,3 @@ *.rc Makefile Makefile.in -libwpg.h diff --git a/src/lib/MSPUBCollector.cpp b/src/lib/MSPUBCollector.cpp deleted file mode 100644 index 31f99ac..0000000 --- a/src/lib/MSPUBCollector.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libpgplus - * 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) 2012 Fridrich Strba - * - * - * 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 "PGPLUSCollector.h" - -libpgplus::PGPLUSCollector::PGPLUSCollector(libwpg::WPGPaintInterface *painter) : - m_painter(painter) -{ -} - -libpgplus::PGPLUSCollector::~PGPLUSCollector() -{ -} - -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/MSPUBCollector.h b/src/lib/MSPUBCollector.h deleted file mode 100644 index a692d63..0000000 --- a/src/lib/MSPUBCollector.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libpgplus - * 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) 2012 Fridrich Strba - * - * 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 __PGPLUSCOLLECTOR_H__ -#define __PGPLUSCOLLECTOR_H__ - -namespace libwpg -{ - -class WPGPaintInterface; - -} // namespace libwpg - -namespace libpgplus -{ - -class PGPLUSCollector -{ -public: - PGPLUSCollector(::libwpg::WPGPaintInterface *painter); - virtual ~PGPLUSCollector(); - - // collector functions - -private: - PGPLUSCollector(const PGPLUSCollector &); - PGPLUSCollector &operator=(const PGPLUSCollector &); - - // helper functions - - libwpg::WPGPaintInterface *m_painter; -}; - -} // namespace libpgplus - -#endif /* __PGPLUSCOLLECTOR_H__ */ -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/MSPUBDocument.cpp b/src/lib/MSPUBDocument.cpp deleted file mode 100644 index fb7d848..0000000 --- a/src/lib/MSPUBDocument.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libpgplus - * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org) - * Copyright (C) 2007 Fridrich Strba (fridrich.strba@bluewin.ch) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02111-1301 USA - */ - -#include -#include -#include -#include "PGPLUSDocument.h" -#include "PGPLUSSVGGenerator.h" -#include "libpgplus_utils.h" - -/** -Analyzes the content of an input stream to see if it can be parsed -\param input The input stream -\return A value that indicates whether the content from the input -stream is a Microsoft Publisher Document that libpgplus is able to parse -*/ -bool libpgplus::PGPLUSDocument::isSupported(WPXInputStream *input) -{ - if (!input->isOLEStream()) - return false; - WPXInputStream *tmpStream = input->getDocumentOLEStream("Quill/QuillSub/CONTENTS"); - if (tmpStream == 0) - return false; - delete tmpStream; - tmpStream = input->getDocumentOLEStream("Escher/EscherStm"); - if (tmpStream == 0) - return false; - delete tmpStream; - tmpStream = input->getDocumentOLEStream("Contents"); - if (tmpStream == 0) - return false; - // Check the magic signature at the beginning of the Contents stream - if (0xe8 == readU8(tmpStream) && 0xac == readU8(tmpStream) && 0x2c == readU8(tmpStream) && 0x00 == readU8(tmpStream)) - { - delete tmpStream; - return true; - } - delete tmpStream; - return false; -} - -/** -Parses the input stream content. It will make callbacks to the functions provided by a -PGPLUSPaintInterface class implementation when needed. This is often commonly called the -'main parsing routine'. -\param input The input stream -\param painter A PGPLUSPainterInterface implementation -\return A value that indicates whether the parsing was successful -*/ -bool libpgplus::PGPLUSDocument::parse(::WPXInputStream *input, libwpg::WPGPaintInterface *painter) -{ - 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 libpgplus::PGPLUSDocument::generateSVG(::WPXInputStream *input, libpgplus::PGPLUSStringVector &output) -{ - libpgplus::PGPLUSSVGGenerator generator(output); - bool result = libpgplus::PGPLUSDocument::parse(input, &generator); - return result; -} - -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/MSPUBDocument.h b/src/lib/MSPUBDocument.h deleted file mode 100644 index 7ca2be1..0000000 --- a/src/lib/MSPUBDocument.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libpgplus - * 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) 2012 Fridrich Strba - * - * 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 __PGPLUSDOCUMENT_H__ -#define __PGPLUSDOCUMENT_H__ - -#include -#include -#include "PGPLUSStringVector.h" - -class WPXInputStream; - -namespace libpgplus -{ -class PGPLUSDocument -{ -public: - - static bool isSupported(WPXInputStream *input); - - static bool parse(WPXInputStream *input, libwpg::WPGPaintInterface *painter); - - static bool generateSVG(::WPXInputStream *input, PGPLUSStringVector &output); -}; - -} // namespace libpgplus - -#endif // __PGPLUSRAPHICS_H__ -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/MSPUBParser.cpp b/src/lib/MSPUBParser.cpp deleted file mode 100644 index edf783e..0000000 --- a/src/lib/MSPUBParser.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libpgplus - * 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) 2012 Fridrich Strba - * - * 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 -#include -#include -#include -#include "PGPLUSParser.h" -#include "PGPLUSCollector.h" - -libpgplus::PGPLUSParser::PGPLUSParser(WPXInputStream *input, PGPLUSCollector *collector) - : m_input(input), m_collector(collector) -{ -} - -libpgplus::PGPLUSParser::~PGPLUSParser() -{ -} - -bool libpgplus::PGPLUSParser::parse() -{ - if (!m_input->isOLEStream()) - return false; - WPXInputStream *quill = m_input->getDocumentOLEStream("Quill/QuillSub/CONTENTS"); - if (!quill) - return false; - if (!parseQuill(quill, m_collector)) - { - delete quill; - return false; - } - delete quill; - WPXInputStream *escher = m_input->getDocumentOLEStream("Escher/EscherStm"); - if (!escher) - return false; - if (!parseEscher(escher, m_collector)) - { - delete escher; - return false; - } - delete escher; - WPXInputStream *contents = m_input->getDocumentOLEStream("CONTENTS"); - if (!contents) - return false; - if (!parseContents(contents, m_collector)) - { - delete contents; - return false; - } - delete contents; - return true; -} - -bool libpgplus::PGPLUSParser::parseContents(WPXInputStream *input, libpgplus::PGPLUSCollector *collector) -{ - return true; -} - -bool libpgplus::PGPLUSParser::parseQuill(WPXInputStream *input, libpgplus::PGPLUSCollector *collector) -{ - return true; -} - -bool libpgplus::PGPLUSParser::parseEscher(WPXInputStream *input, libpgplus::PGPLUSCollector *collector) -{ - return true; -} - - -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/MSPUBParser.h b/src/lib/MSPUBParser.h deleted file mode 100644 index 32eac84..0000000 --- a/src/lib/MSPUBParser.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libpgplus - * 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) 2012 Fridrich Strba - * - * 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 __PGPLUSPARSER_H__ -#define __PGPLUSPARSER_H__ - -#include -#include - -class WPXInputStream; - -namespace libpgplus -{ -class PGPLUSCollector; - -class PGPLUSParser -{ -public: - explicit PGPLUSParser(WPXInputStream *input, PGPLUSCollector *collector); - virtual ~PGPLUSParser(); - bool parse(); -private: - PGPLUSParser(); - PGPLUSParser(const PGPLUSParser &); - PGPLUSParser &operator=(const PGPLUSParser &); - bool parseContents(WPXInputStream *input, PGPLUSCollector *collector); - bool parseQuill(WPXInputStream *input, PGPLUSCollector *collector); - bool parseEscher(WPXInputStream *input, PGPLUSCollector *collector); - - WPXInputStream *m_input; - PGPLUSCollector *m_collector; -}; - -} // namespace libpgplus - -#endif // __PGPLUSRAPHICS_H__ -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/MSPUBSVGGenerator.cpp b/src/lib/MSPUBSVGGenerator.cpp deleted file mode 100644 index e60afec..0000000 --- a/src/lib/MSPUBSVGGenerator.cpp +++ /dev/null @@ -1,616 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libpgplus - * 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) 2012 Fridrich Strba - * Copyright (C) 2011 Eilidh McAdam - * - * 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 "PGPLUSSVGGenerator.h" -#include "libpgplus.h" -#include -#include -#include - -static std::string doubleToString(const double value) -{ - std::ostringstream tempStream; - tempStream << value; -#ifndef __ANDROID__ - std::string decimalPoint(localeconv()->decimal_point); -#else - std::string decimalPoint("."); -#endif - if ((decimalPoint.size() == 0) || (decimalPoint == ".")) - return tempStream.str(); - std::string stringValue(tempStream.str()); - if (!stringValue.empty()) - { - std::string::size_type pos; - while ((pos = stringValue.find(decimalPoint)) != std::string::npos) - stringValue.replace(pos,decimalPoint.size(),"."); - } - return stringValue; -} - -static unsigned stringToColour(const ::WPXString &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; -} - -libpgplus::PGPLUSSVGGenerator::PGPLUSSVGGenerator(libpgplus::PGPLUSStringVector &vec): m_gradient(), m_style(), m_gradientIndex(1), m_patternIndex(1), m_shadowIndex(1), m_outputSink(), m_vec(vec) -{ -} - -libpgplus::PGPLUSSVGGenerator::~PGPLUSSVGGenerator() -{ -} - -void libpgplus::PGPLUSSVGGenerator::startGraphics(const WPXPropertyList &propList) -{ - m_outputSink << "getDouble())) << "\" "; - if (propList["svg:height"]) - m_outputSink << "height=\"" << doubleToString(72*(propList["svg:height"]->getDouble())) << "\""; - m_outputSink << " >\n"; -} - -void libpgplus::PGPLUSSVGGenerator::endGraphics() -{ - m_outputSink << "\n"; - m_vec.append(m_outputSink.str().c_str()); - m_outputSink.str(""); -} - -void libpgplus::PGPLUSSVGGenerator::setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient) -{ - m_style.clear(); - m_style = propList; - - m_gradient = gradient; - if(m_style["draw:shadow"] && m_style["draw:shadow"]->getStr() == "visible") - { - unsigned shadowColour = 0; - double shadowRed = 0.0; - double shadowGreen = 0.0; - double shadowBlue = 0.0; - if (m_style["draw:shadow-color"]) - { - 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 << "\n"; - m_outputSink << ""; - m_outputSink << "getDouble()) << "\" "; - m_outputSink << "dy=\"" << doubleToString(72*m_style["draw:shadow-offset-y"]->getDouble()) << "\"/>"; - m_outputSink << "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 << ""; - } - - if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "gradient") - { - 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_gradient.count()) - { - if (m_style["draw:style"] && - (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 << "\n"; - m_outputSink << " 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() << "\""; - m_outputSink << " r=\"" << (1 - (m_style["draw:border"] ? m_style["draw:border"]->getDouble() : 0))*100.0 << "%\" >\n"; - m_outputSink << " >\n"; - - if (m_style["draw:start-color"] && m_style["draw:end-color"]) - { - m_outputSink << " getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << (m_style["libwpg:end-opacity"] ? m_style["libwpg:end-opacity"]->getDouble() : 1) << "\" />" << std::endl; - - m_outputSink << " getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << (m_style["libwpg:start-opacity"] ? m_style["libwpg:start-opacity"]->getDouble() : 1) << "\" />" << std::endl; - } - m_outputSink << " \n"; - m_outputSink << "\n"; - } - else if (m_style["draw:style"] && m_style["draw:style"]->getStr() == "linear") - { - m_outputSink << "\n"; - m_outputSink << " \n"; - - if (m_style["draw:start-color"] && m_style["draw:end-color"]) - { - m_outputSink << " getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << (m_style["libwpg:start-opacity"] ? m_style["libwpg:start-opacity"]->getDouble() : 1) << "\" />" << std::endl; - - m_outputSink << " getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << (m_style["libwpg:end-opacity"] ? m_style["libwpg:end-opacity"]->getDouble() : 1) << "\" />" << std::endl; - } - m_outputSink << " \n"; - - // not a simple horizontal gradient - if(angle != 270) - { - m_outputSink << " \n"; - m_outputSink << " \n"; - } - - m_outputSink << "\n"; - } - else if (m_style["draw:style"] && m_style["draw:style"]->getStr() == "axial") - { - m_outputSink << "\n"; - m_outputSink << " \n"; - - if (m_style["draw:start-color"] && m_style["draw:end-color"]) - { - m_outputSink << " getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << (m_style["libwpg:end-opacity"] ? m_style["libwpg:end-opacity"]->getDouble() : 1) << "\" />" << std::endl; - - m_outputSink << " getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << (m_style["libwpg:start-opacity"] ? m_style["libwpg:start-opacity"]->getDouble() : 1) << "\" />" << std::endl; - - m_outputSink << " getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << (m_style["libwpg:end-opacity"] ? m_style["libwpg:end-opacity"]->getDouble() : 1) << "\" />" << std::endl; - } - m_outputSink << " \n"; - - // not a simple horizontal gradient - if(angle != 270) - { - m_outputSink << " \n"; - m_outputSink << " \n"; - } - - m_outputSink << "\n"; - } - } - else - { - if (m_style["draw:style"] && m_style["draw:style"]->getStr() == "radial") - { - m_outputSink << "\n"; - m_outputSink << " getStr().cstr() << "\" cy=\"" << m_style["svg:cy"]->getStr().cstr() << "\" r=\"" << m_style["svg:r"]->getStr().cstr() << "\" >\n"; - for(unsigned c = 0; c < m_gradient.count(); c++) - { - m_outputSink << " getStr().cstr() << "\""; - - m_outputSink << " stop-color=\"" << m_gradient[c]["svg:stop-color"]->getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << m_gradient[c]["svg:stop-opacity"]->getDouble() << "\" />" << std::endl; - - } - m_outputSink << " \n"; - m_outputSink << "\n"; - } - else - { - m_outputSink << "\n"; - m_outputSink << " \n"; - for(unsigned c = 0; c < m_gradient.count(); c++) - { - m_outputSink << " getStr().cstr() << "\""; - - m_outputSink << " stop-color=\"" << m_gradient[c]["svg:stop-color"]->getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << m_gradient[c]["svg:stop-opacity"]->getDouble() << "\" />" << std::endl; - - } - m_outputSink << " \n"; - - // not a simple horizontal gradient - if(angle != 270) - { - m_outputSink << " \n"; - m_outputSink << " \n"; - } - - m_outputSink << "\n"; - } - } - } - else if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "bitmap") - { - if (m_style["draw:fill-image"] && m_style["libwpg:mime-type"]) - { - m_outputSink << "\n"; - m_outputSink << " 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 << "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["libwpg:mime-type"]->getStr().cstr() << ";base64,"; - m_outputSink << m_style["draw:fill-image"]->getStr().cstr(); - m_outputSink << "\" />\n"; - m_outputSink << " \n"; - m_outputSink << "\n"; - } - } -} - -void libpgplus::PGPLUSSVGGenerator::startLayer(const ::WPXPropertyList &propList) -{ - m_outputSink << "getInt() << "\""; - if (propList["svg:fill-rule"]) - m_outputSink << " fill-rule=\"" << propList["svg:fill-rule"]->getStr().cstr() << "\""; - m_outputSink << " >\n"; -} - -void libpgplus::PGPLUSSVGGenerator::endLayer() -{ - m_outputSink << "\n"; -} - -void libpgplus::PGPLUSSVGGenerator::drawRectangle(const ::WPXPropertyList &propList) -{ - m_outputSink << "getDouble()) << "\" y=\"" << doubleToString(72*propList["svg:y"]->getDouble()) << "\" "; - m_outputSink << "width=\"" << doubleToString(72*propList["svg:width"]->getDouble()) << "\" height=\"" << doubleToString(72*propList["svg:height"]->getDouble()) << "\" "; - if((propList["svg:rx"] && propList["svg:rx"]->getInt() !=0) || (propList["svg:ry"] && propList["svg:ry"]->getInt() !=0)) - m_outputSink << "rx=\"" << doubleToString(72*propList["svg:rx"]->getDouble()) << "\" ry=\"" << doubleToString(72*propList["svg:ry"]->getDouble()) << "\" "; - writeStyle(); - m_outputSink << "/>\n"; -} - -void libpgplus::PGPLUSSVGGenerator::drawEllipse(const WPXPropertyList &propList) -{ - m_outputSink << "getDouble()) << "\" cy=\"" << doubleToString(72*propList["svg:cy"]->getDouble()) << "\" "; - m_outputSink << "rx=\"" << doubleToString(72*propList["svg:rx"]->getDouble()) << "\" ry=\"" << doubleToString(72*propList["svg:ry"]->getDouble()) << "\" "; - writeStyle(); - if (propList["libwpg:rotate"] && propList["libwpg:rotate"]->getDouble() != 0.0) - m_outputSink << " transform=\" translate(" << doubleToString(72*propList["svg:cx"]->getDouble()) << ", " << doubleToString(72*propList["svg:cy"]->getDouble()) - << ") rotate(" << doubleToString(-propList["libwpg:rotate"]->getDouble()) - << ") translate(" << doubleToString(-72*propList["svg:cx"]->getDouble()) - << ", " << doubleToString(-72*propList["svg:cy"]->getDouble()) - << ")\" "; - m_outputSink << "/>\n"; -} - -void libpgplus::PGPLUSSVGGenerator::drawPolyline(const ::WPXPropertyListVector &vertices) -{ - drawPolySomething(vertices, false); -} - -void libpgplus::PGPLUSSVGGenerator::drawPolygon(const ::WPXPropertyListVector &vertices) -{ - drawPolySomething(vertices, true); -} - -void libpgplus::PGPLUSSVGGenerator::drawPolySomething(const ::WPXPropertyListVector &vertices, bool isClosed) -{ - if(vertices.count() < 2) - return; - - if(vertices.count() == 2) - { - m_outputSink << "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 << "getDouble())) << " " << doubleToString(72*(vertices[i]["svg:y"]->getDouble())); - if (i < vertices.count()-1) - m_outputSink << ", "; - } - m_outputSink << "\"\n"; - writeStyle(isClosed); - m_outputSink << "/>\n"; - } -} - -void libpgplus::PGPLUSSVGGenerator::drawPath(const ::WPXPropertyListVector &path) -{ - m_outputSink << "getStr() == "M") - { - m_outputSink << "\nM"; - m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); - } - else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "L") - { - m_outputSink << "\nL"; - m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); - } - else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "C") - { - m_outputSink << "\nC"; - m_outputSink << doubleToString(72*(propList["svg:x1"]->getDouble())) << "," << doubleToString(72*(propList["svg:y1"]->getDouble())) << " "; - m_outputSink << doubleToString(72*(propList["svg:x2"]->getDouble())) << "," << doubleToString(72*(propList["svg:y2"]->getDouble())) << " "; - m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); - } - else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "Q") - { - m_outputSink << "\nQ"; - m_outputSink << doubleToString(72*(propList["svg:x1"]->getDouble())) << "," << doubleToString(72*(propList["svg:y1"]->getDouble())) << " "; - m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); - } - else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "A") - { - m_outputSink << "\nA"; - m_outputSink << doubleToString(72*(propList["svg:rx"]->getDouble())) << "," << doubleToString(72*(propList["svg:ry"]->getDouble())) << " "; - m_outputSink << doubleToString(propList["libwpg:rotate"] ? propList["libwpg:rotate"]->getDouble() : 0) << " "; - m_outputSink << (propList["libwpg:large-arc"] ? propList["libwpg:large-arc"]->getInt() : 1) << ","; - m_outputSink << (propList["libwpg:sweep"] ? propList["libwpg:sweep"]->getInt() : 1) << " "; - m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); - } - else if ((i >= path.count()-1 && i > 2) && propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "Z" ) - { - isClosed = true; - m_outputSink << "\nZ"; - } - } - - m_outputSink << "\" \n"; - writeStyle(isClosed); - m_outputSink << "/>\n"; -} - -void libpgplus::PGPLUSSVGGenerator::drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData) -{ - if (!propList["libwpg:mime-type"] || propList["libwpg:mime-type"]->getStr().len() <= 0) - return; - WPXString base64 = binaryData.getBase64Data(); - m_outputSink << "getDouble())) << "\" y=\"" << doubleToString(72*(propList["svg:y"]->getDouble())) << "\" "; - m_outputSink << "width=\"" << doubleToString(72*(propList["svg:width"]->getDouble())) << "\" height=\"" << doubleToString(72*(propList["svg:height"]->getDouble())) << "\" "; - m_outputSink << "xlink:href=\"data:" << propList["libwpg:mime-type"]->getStr().cstr() << ";base64,"; - m_outputSink << base64.cstr(); - m_outputSink << "\" />\n"; -} - -void libpgplus::PGPLUSSVGGenerator::startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector & /* path */) -{ - m_outputSink << "getDouble())) << "\" y=\"" << doubleToString(72*(propList["svg:y"]->getDouble())) << "\""; - if (propList["libwpg:rotate"] && propList["libwpg:rotate"]->getDouble() != 0.0) - m_outputSink << " transform=\"translate(" << doubleToString(72*propList["svg:x"]->getDouble()) << ", " << doubleToString(72*propList["svg:y"]->getDouble()) - << ") rotate(" << doubleToString(-propList["libwpg:rotate"]->getDouble()) - << ") translate(" << doubleToString(-72*propList["svg:x"]->getDouble()) - << ", " << doubleToString(-72*propList["svg:y"]->getDouble()) - << ")\""; - m_outputSink << ">\n"; - -} - -void libpgplus::PGPLUSSVGGenerator::endTextObject() -{ - m_outputSink << "\n"; -} - -void libpgplus::PGPLUSSVGGenerator::startTextSpan(const ::WPXPropertyList &propList) -{ - m_outputSink << "getStr().cstr() << "\" "; - if (propList["fo:font-style"]) - m_outputSink << "font-style=\"" << propList["fo:font-style"]->getStr().cstr() << "\" "; - if (propList["fo:font-weight"]) - m_outputSink << "font-weight=\"" << propList["fo:font-weight"]->getStr().cstr() << "\" "; - if (propList["fo:font-variant"]) - m_outputSink << "font-variant=\"" << propList["fo:font-variant"]->getStr().cstr() << "\" "; - if (propList["fo:font-size"]) - m_outputSink << "font-size=\"" << doubleToString(propList["fo:font-size"]->getDouble()) << "\" "; - if (propList["fo:color"]) - m_outputSink << "fill=\"" << propList["fo:color"]->getStr().cstr() << "\" "; - if (propList["fo:text-transform"]) - m_outputSink << "text-transform=\"" << propList["fo:text-transform"]->getStr().cstr() << "\" "; - if (propList["svg:fill-opacity"]) - m_outputSink << "fill-opacity=\"" << doubleToString(propList["svg:fill-opacity"]->getDouble()) << "\" "; - if (propList["svg:stroke-opacity"]) - m_outputSink << "stroke-opacity=\"" << doubleToString(propList["svg:stroke-opacity"]->getDouble()) << "\" "; - m_outputSink << ">\n"; -} - -void libpgplus::PGPLUSSVGGenerator::endTextSpan() -{ - m_outputSink << "\n"; -} - -void libpgplus::PGPLUSSVGGenerator::insertText(const ::WPXString &str) -{ - WPXString tempUTF8(str, true); - m_outputSink << tempUTF8.cstr() << "\n"; -} - -// create "style" attribute based on current pen and brush -void libpgplus::PGPLUSSVGGenerator::writeStyle(bool /* isClosed */) -{ - m_outputSink << "style=\""; - - if (m_style["svg:stroke-width"]) - { - double width = m_style["svg:stroke-width"]->getDouble(); - if (width == 0.0 && m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() != "none") - width = 0.2 / 72.0; // reasonable hairline - 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: solid; "; - else if (m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() == "dash") - { - int dots1 = m_style["draw:dots1"]->getInt(); - int dots2 = m_style["draw:dots2"]->getInt(); - double dots1len = m_style["draw:dots1-length"]->getDouble(); - double dots2len = m_style["draw:dots2-length"]->getDouble(); - double gap = m_style["draw:distance"]->getDouble(); - m_outputSink << "stroke-dasharray: "; - for (int i = 0; i < dots1; i++) - { - if (i) - m_outputSink << ", "; - m_outputSink << (int)dots1len; - m_outputSink << ", "; - m_outputSink << (int)gap; - } - for (int j = 0; j < dots2; j++) - { - m_outputSink << ", "; - m_outputSink << (int)dots2len; - m_outputSink << ", "; - m_outputSink << (int)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 << "); "; - - 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()) << "; "; - m_outputSink << "\""; // style -} -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/MSPUBSVGGenerator.h b/src/lib/MSPUBSVGGenerator.h deleted file mode 100644 index 42b87cb..0000000 --- a/src/lib/MSPUBSVGGenerator.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libpgplus - * 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 - * Copyright (C) 2011 Eilidh McAdam - * - * 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 __PGPLUSSVGGENERATOR_H__ -#define __PGPLUSSVGGENERATOR_H__ - -#include -#include -#include -#include -#include -#include "PGPLUSStringVector.h" - -namespace libpgplus -{ - -class PGPLUSSVGGenerator : public libwpg::WPGPaintInterface -{ -public: - PGPLUSSVGGenerator(PGPLUSStringVector &vec); - ~PGPLUSSVGGenerator(); - - void startGraphics(const ::WPXPropertyList &propList); - void endGraphics(); - void startLayer(const ::WPXPropertyList &propList); - void endLayer(); - void startEmbeddedGraphics(const ::WPXPropertyList & /*propList*/) {} - void endEmbeddedGraphics() {} - - void setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient); - - void drawRectangle(const ::WPXPropertyList &propList); - void drawEllipse(const ::WPXPropertyList &propList); - void drawPolyline(const ::WPXPropertyListVector &vertices); - void drawPolygon(const ::WPXPropertyListVector &vertices); - void drawPath(const ::WPXPropertyListVector &path); - void drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData); - void startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path); - void endTextObject(); - void startTextLine(const ::WPXPropertyList & /* propList */) {} - void endTextLine() {} - void startTextSpan(const ::WPXPropertyList &propList); - void endTextSpan(); - void insertText(const ::WPXString &str); - -private: - ::WPXPropertyListVector m_gradient; - ::WPXPropertyList m_style; - int m_gradientIndex; - int m_patternIndex; - int m_shadowIndex; - void writeStyle(bool isClosed=true); - void drawPolySomething(const ::WPXPropertyListVector &vertices, bool isClosed); - - std::ostringstream m_outputSink; - PGPLUSStringVector &m_vec; -}; - -} // namespace libpgplus - -#endif // __PGPLUSSVGGENERATOR_H__ -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/MSPUBStringVector.cpp b/src/lib/MSPUBStringVector.cpp deleted file mode 100644 index a950185..0000000 --- a/src/lib/MSPUBStringVector.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libpgplus - * 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) 2012 Fridrich Strba - * - * - * 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 -#include "PGPLUSStringVector.h" - -namespace libpgplus -{ -class PGPLUSStringVectorImpl -{ -public: - PGPLUSStringVectorImpl() : m_strings() {} - PGPLUSStringVectorImpl(const PGPLUSStringVectorImpl &impl) : m_strings(impl.m_strings) {} - ~PGPLUSStringVectorImpl() {} - std::vector m_strings; -}; - -} // namespace libpgplus - -libpgplus::PGPLUSStringVector::PGPLUSStringVector() - : m_pImpl(new PGPLUSStringVectorImpl()) -{ -} - -libpgplus::PGPLUSStringVector::PGPLUSStringVector(const PGPLUSStringVector &vec) - : m_pImpl(new PGPLUSStringVectorImpl(*(vec.m_pImpl))) -{ -} - -libpgplus::PGPLUSStringVector::~PGPLUSStringVector() -{ -} - -libpgplus::PGPLUSStringVector &libpgplus::PGPLUSStringVector::operator=(const PGPLUSStringVector &vec) -{ - if (m_pImpl) - delete m_pImpl; - m_pImpl = new PGPLUSStringVectorImpl(*(vec.m_pImpl)); - return *this; -} - -unsigned libpgplus::PGPLUSStringVector::size() const -{ - return (unsigned)(m_pImpl->m_strings.size()); -} - -bool libpgplus::PGPLUSStringVector::empty() const -{ - return m_pImpl->m_strings.empty(); -} - -const WPXString &libpgplus::PGPLUSStringVector::operator[](unsigned idx) const -{ - return m_pImpl->m_strings[idx]; -} - -void libpgplus::PGPLUSStringVector::append(const WPXString &str) -{ - m_pImpl->m_strings.push_back(str); -} - -void libpgplus::PGPLUSStringVector::clear() -{ - m_pImpl->m_strings.clear(); -} - -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/MSPUBStringVector.h b/src/lib/MSPUBStringVector.h deleted file mode 100644 index b18ec59..0000000 --- a/src/lib/MSPUBStringVector.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libpgplus - * 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) 2012 Fridrich Strba - * - * 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 __PGPLUSSTRINGVECTOR_H__ -#define __PGPLUSSTRINGVECTOR_H__ - -#include - -namespace libpgplus -{ -class PGPLUSStringVectorImpl; - -class PGPLUSStringVector -{ -public: - PGPLUSStringVector(); - PGPLUSStringVector(const PGPLUSStringVector &vec); - ~PGPLUSStringVector(); - - PGPLUSStringVector &operator=(const PGPLUSStringVector &vec); - - unsigned size() const; - bool empty() const; - const WPXString &operator[](unsigned idx) const; - void append(const WPXString &str); - void clear(); - -private: - PGPLUSStringVectorImpl *m_pImpl; -}; - -} // namespace libpgplus - -#endif /* __PGPLUSSTRINGVECTOR_H__ */ -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/PGPLUSCollector.cpp b/src/lib/PGPLUSCollector.cpp new file mode 100644 index 0000000..31f99ac --- /dev/null +++ b/src/lib/PGPLUSCollector.cpp @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libpgplus + * 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) 2012 Fridrich Strba + * + * + * 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 "PGPLUSCollector.h" + +libpgplus::PGPLUSCollector::PGPLUSCollector(libwpg::WPGPaintInterface *painter) : + m_painter(painter) +{ +} + +libpgplus::PGPLUSCollector::~PGPLUSCollector() +{ +} + +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/PGPLUSCollector.h b/src/lib/PGPLUSCollector.h new file mode 100644 index 0000000..a692d63 --- /dev/null +++ b/src/lib/PGPLUSCollector.h @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libpgplus + * 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) 2012 Fridrich Strba + * + * 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 __PGPLUSCOLLECTOR_H__ +#define __PGPLUSCOLLECTOR_H__ + +namespace libwpg +{ + +class WPGPaintInterface; + +} // namespace libwpg + +namespace libpgplus +{ + +class PGPLUSCollector +{ +public: + PGPLUSCollector(::libwpg::WPGPaintInterface *painter); + virtual ~PGPLUSCollector(); + + // collector functions + +private: + PGPLUSCollector(const PGPLUSCollector &); + PGPLUSCollector &operator=(const PGPLUSCollector &); + + // helper functions + + libwpg::WPGPaintInterface *m_painter; +}; + +} // namespace libpgplus + +#endif /* __PGPLUSCOLLECTOR_H__ */ +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/PGPLUSDocument.cpp b/src/lib/PGPLUSDocument.cpp new file mode 100644 index 0000000..ef4f77f --- /dev/null +++ b/src/lib/PGPLUSDocument.cpp @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libpgplus + * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org) + * Copyright (C) 2007 Fridrich Strba (fridrich.strba@bluewin.ch) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02111-1301 USA + */ + +#include +#include +#include +#include "PGPLUSDocument.h" +#include "PGPLUSSVGGenerator.h" +#include "libpgplus_utils.h" + +/** +Analyzes the content of an input stream to see if it can be parsed +\param input The input stream +\return A value that indicates whether the content from the input +stream is a PagePlus Document that libpgplus is able to parse +*/ +bool libpgplus::PGPLUSDocument::isSupported(WPXInputStream *input) +{ + return false; +} + +/** +Parses the input stream content. It will make callbacks to the functions provided by a +PGPLUSPaintInterface class implementation when needed. This is often commonly called the +'main parsing routine'. +\param input The input stream +\param painter A PGPLUSPainterInterface implementation +\return A value that indicates whether the parsing was successful +*/ +bool libpgplus::PGPLUSDocument::parse(::WPXInputStream *input, libwpg::WPGPaintInterface *painter) +{ + 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 libpgplus::PGPLUSDocument::generateSVG(::WPXInputStream *input, libpgplus::PGPLUSStringVector &output) +{ + libpgplus::PGPLUSSVGGenerator generator(output); + bool result = libpgplus::PGPLUSDocument::parse(input, &generator); + return result; +} + +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/PGPLUSDocument.h b/src/lib/PGPLUSDocument.h new file mode 100644 index 0000000..7ca2be1 --- /dev/null +++ b/src/lib/PGPLUSDocument.h @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libpgplus + * 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) 2012 Fridrich Strba + * + * 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 __PGPLUSDOCUMENT_H__ +#define __PGPLUSDOCUMENT_H__ + +#include +#include +#include "PGPLUSStringVector.h" + +class WPXInputStream; + +namespace libpgplus +{ +class PGPLUSDocument +{ +public: + + static bool isSupported(WPXInputStream *input); + + static bool parse(WPXInputStream *input, libwpg::WPGPaintInterface *painter); + + static bool generateSVG(::WPXInputStream *input, PGPLUSStringVector &output); +}; + +} // namespace libpgplus + +#endif // __PGPLUSRAPHICS_H__ +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/PGPLUSParser.cpp b/src/lib/PGPLUSParser.cpp new file mode 100644 index 0000000..860681e --- /dev/null +++ b/src/lib/PGPLUSParser.cpp @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libpgplus + * 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) 2012 Fridrich Strba + * + * 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 +#include +#include +#include +#include "PGPLUSParser.h" +#include "PGPLUSCollector.h" + +libpgplus::PGPLUSParser::PGPLUSParser(WPXInputStream *input, PGPLUSCollector *collector) + : m_input(input), m_collector(collector) +{ +} + +libpgplus::PGPLUSParser::~PGPLUSParser() +{ +} + +bool libpgplus::PGPLUSParser::parse() +{ + return false; +} + +bool libpgplus::PGPLUSParser::parseContents(WPXInputStream *input, libpgplus::PGPLUSCollector *collector) +{ + return false; +} + +bool libpgplus::PGPLUSParser::parseQuill(WPXInputStream *input, libpgplus::PGPLUSCollector *collector) +{ + return false; +} + +bool libpgplus::PGPLUSParser::parseEscher(WPXInputStream *input, libpgplus::PGPLUSCollector *collector) +{ + return false; +} + + +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/PGPLUSParser.h b/src/lib/PGPLUSParser.h new file mode 100644 index 0000000..32eac84 --- /dev/null +++ b/src/lib/PGPLUSParser.h @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libpgplus + * 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) 2012 Fridrich Strba + * + * 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 __PGPLUSPARSER_H__ +#define __PGPLUSPARSER_H__ + +#include +#include + +class WPXInputStream; + +namespace libpgplus +{ +class PGPLUSCollector; + +class PGPLUSParser +{ +public: + explicit PGPLUSParser(WPXInputStream *input, PGPLUSCollector *collector); + virtual ~PGPLUSParser(); + bool parse(); +private: + PGPLUSParser(); + PGPLUSParser(const PGPLUSParser &); + PGPLUSParser &operator=(const PGPLUSParser &); + bool parseContents(WPXInputStream *input, PGPLUSCollector *collector); + bool parseQuill(WPXInputStream *input, PGPLUSCollector *collector); + bool parseEscher(WPXInputStream *input, PGPLUSCollector *collector); + + WPXInputStream *m_input; + PGPLUSCollector *m_collector; +}; + +} // namespace libpgplus + +#endif // __PGPLUSRAPHICS_H__ +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/PGPLUSSVGGenerator.cpp b/src/lib/PGPLUSSVGGenerator.cpp new file mode 100644 index 0000000..e60afec --- /dev/null +++ b/src/lib/PGPLUSSVGGenerator.cpp @@ -0,0 +1,616 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libpgplus + * 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) 2012 Fridrich Strba + * Copyright (C) 2011 Eilidh McAdam + * + * 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 "PGPLUSSVGGenerator.h" +#include "libpgplus.h" +#include +#include +#include + +static std::string doubleToString(const double value) +{ + std::ostringstream tempStream; + tempStream << value; +#ifndef __ANDROID__ + std::string decimalPoint(localeconv()->decimal_point); +#else + std::string decimalPoint("."); +#endif + if ((decimalPoint.size() == 0) || (decimalPoint == ".")) + return tempStream.str(); + std::string stringValue(tempStream.str()); + if (!stringValue.empty()) + { + std::string::size_type pos; + while ((pos = stringValue.find(decimalPoint)) != std::string::npos) + stringValue.replace(pos,decimalPoint.size(),"."); + } + return stringValue; +} + +static unsigned stringToColour(const ::WPXString &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; +} + +libpgplus::PGPLUSSVGGenerator::PGPLUSSVGGenerator(libpgplus::PGPLUSStringVector &vec): m_gradient(), m_style(), m_gradientIndex(1), m_patternIndex(1), m_shadowIndex(1), m_outputSink(), m_vec(vec) +{ +} + +libpgplus::PGPLUSSVGGenerator::~PGPLUSSVGGenerator() +{ +} + +void libpgplus::PGPLUSSVGGenerator::startGraphics(const WPXPropertyList &propList) +{ + m_outputSink << "getDouble())) << "\" "; + if (propList["svg:height"]) + m_outputSink << "height=\"" << doubleToString(72*(propList["svg:height"]->getDouble())) << "\""; + m_outputSink << " >\n"; +} + +void libpgplus::PGPLUSSVGGenerator::endGraphics() +{ + m_outputSink << "\n"; + m_vec.append(m_outputSink.str().c_str()); + m_outputSink.str(""); +} + +void libpgplus::PGPLUSSVGGenerator::setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient) +{ + m_style.clear(); + m_style = propList; + + m_gradient = gradient; + if(m_style["draw:shadow"] && m_style["draw:shadow"]->getStr() == "visible") + { + unsigned shadowColour = 0; + double shadowRed = 0.0; + double shadowGreen = 0.0; + double shadowBlue = 0.0; + if (m_style["draw:shadow-color"]) + { + 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 << "\n"; + m_outputSink << ""; + m_outputSink << "getDouble()) << "\" "; + m_outputSink << "dy=\"" << doubleToString(72*m_style["draw:shadow-offset-y"]->getDouble()) << "\"/>"; + m_outputSink << "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 << ""; + } + + if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "gradient") + { + 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_gradient.count()) + { + if (m_style["draw:style"] && + (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 << "\n"; + m_outputSink << " 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() << "\""; + m_outputSink << " r=\"" << (1 - (m_style["draw:border"] ? m_style["draw:border"]->getDouble() : 0))*100.0 << "%\" >\n"; + m_outputSink << " >\n"; + + if (m_style["draw:start-color"] && m_style["draw:end-color"]) + { + m_outputSink << " getStr().cstr() << "\""; + m_outputSink << " stop-opacity=\"" << (m_style["libwpg:end-opacity"] ? m_style["libwpg:end-opacity"]->getDouble() : 1) << "\" />" << std::endl; + + m_outputSink << " getStr().cstr() << "\""; + m_outputSink << " stop-opacity=\"" << (m_style["libwpg:start-opacity"] ? m_style["libwpg:start-opacity"]->getDouble() : 1) << "\" />" << std::endl; + } + m_outputSink << " \n"; + m_outputSink << "\n"; + } + else if (m_style["draw:style"] && m_style["draw:style"]->getStr() == "linear") + { + m_outputSink << "\n"; + m_outputSink << " \n"; + + if (m_style["draw:start-color"] && m_style["draw:end-color"]) + { + m_outputSink << " getStr().cstr() << "\""; + m_outputSink << " stop-opacity=\"" << (m_style["libwpg:start-opacity"] ? m_style["libwpg:start-opacity"]->getDouble() : 1) << "\" />" << std::endl; + + m_outputSink << " getStr().cstr() << "\""; + m_outputSink << " stop-opacity=\"" << (m_style["libwpg:end-opacity"] ? m_style["libwpg:end-opacity"]->getDouble() : 1) << "\" />" << std::endl; + } + m_outputSink << " \n"; + + // not a simple horizontal gradient + if(angle != 270) + { + m_outputSink << " \n"; + m_outputSink << " \n"; + } + + m_outputSink << "\n"; + } + else if (m_style["draw:style"] && m_style["draw:style"]->getStr() == "axial") + { + m_outputSink << "\n"; + m_outputSink << " \n"; + + if (m_style["draw:start-color"] && m_style["draw:end-color"]) + { + m_outputSink << " getStr().cstr() << "\""; + m_outputSink << " stop-opacity=\"" << (m_style["libwpg:end-opacity"] ? m_style["libwpg:end-opacity"]->getDouble() : 1) << "\" />" << std::endl; + + m_outputSink << " getStr().cstr() << "\""; + m_outputSink << " stop-opacity=\"" << (m_style["libwpg:start-opacity"] ? m_style["libwpg:start-opacity"]->getDouble() : 1) << "\" />" << std::endl; + + m_outputSink << " getStr().cstr() << "\""; + m_outputSink << " stop-opacity=\"" << (m_style["libwpg:end-opacity"] ? m_style["libwpg:end-opacity"]->getDouble() : 1) << "\" />" << std::endl; + } + m_outputSink << " \n"; + + // not a simple horizontal gradient + if(angle != 270) + { + m_outputSink << " \n"; + m_outputSink << " \n"; + } + + m_outputSink << "\n"; + } + } + else + { + if (m_style["draw:style"] && m_style["draw:style"]->getStr() == "radial") + { + m_outputSink << "\n"; + m_outputSink << " getStr().cstr() << "\" cy=\"" << m_style["svg:cy"]->getStr().cstr() << "\" r=\"" << m_style["svg:r"]->getStr().cstr() << "\" >\n"; + for(unsigned c = 0; c < m_gradient.count(); c++) + { + m_outputSink << " getStr().cstr() << "\""; + + m_outputSink << " stop-color=\"" << m_gradient[c]["svg:stop-color"]->getStr().cstr() << "\""; + m_outputSink << " stop-opacity=\"" << m_gradient[c]["svg:stop-opacity"]->getDouble() << "\" />" << std::endl; + + } + m_outputSink << " \n"; + m_outputSink << "\n"; + } + else + { + m_outputSink << "\n"; + m_outputSink << " \n"; + for(unsigned c = 0; c < m_gradient.count(); c++) + { + m_outputSink << " getStr().cstr() << "\""; + + m_outputSink << " stop-color=\"" << m_gradient[c]["svg:stop-color"]->getStr().cstr() << "\""; + m_outputSink << " stop-opacity=\"" << m_gradient[c]["svg:stop-opacity"]->getDouble() << "\" />" << std::endl; + + } + m_outputSink << " \n"; + + // not a simple horizontal gradient + if(angle != 270) + { + m_outputSink << " \n"; + m_outputSink << " \n"; + } + + m_outputSink << "\n"; + } + } + } + else if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "bitmap") + { + if (m_style["draw:fill-image"] && m_style["libwpg:mime-type"]) + { + m_outputSink << "\n"; + m_outputSink << " 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 << "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["libwpg:mime-type"]->getStr().cstr() << ";base64,"; + m_outputSink << m_style["draw:fill-image"]->getStr().cstr(); + m_outputSink << "\" />\n"; + m_outputSink << " \n"; + m_outputSink << "\n"; + } + } +} + +void libpgplus::PGPLUSSVGGenerator::startLayer(const ::WPXPropertyList &propList) +{ + m_outputSink << "getInt() << "\""; + if (propList["svg:fill-rule"]) + m_outputSink << " fill-rule=\"" << propList["svg:fill-rule"]->getStr().cstr() << "\""; + m_outputSink << " >\n"; +} + +void libpgplus::PGPLUSSVGGenerator::endLayer() +{ + m_outputSink << "\n"; +} + +void libpgplus::PGPLUSSVGGenerator::drawRectangle(const ::WPXPropertyList &propList) +{ + m_outputSink << "getDouble()) << "\" y=\"" << doubleToString(72*propList["svg:y"]->getDouble()) << "\" "; + m_outputSink << "width=\"" << doubleToString(72*propList["svg:width"]->getDouble()) << "\" height=\"" << doubleToString(72*propList["svg:height"]->getDouble()) << "\" "; + if((propList["svg:rx"] && propList["svg:rx"]->getInt() !=0) || (propList["svg:ry"] && propList["svg:ry"]->getInt() !=0)) + m_outputSink << "rx=\"" << doubleToString(72*propList["svg:rx"]->getDouble()) << "\" ry=\"" << doubleToString(72*propList["svg:ry"]->getDouble()) << "\" "; + writeStyle(); + m_outputSink << "/>\n"; +} + +void libpgplus::PGPLUSSVGGenerator::drawEllipse(const WPXPropertyList &propList) +{ + m_outputSink << "getDouble()) << "\" cy=\"" << doubleToString(72*propList["svg:cy"]->getDouble()) << "\" "; + m_outputSink << "rx=\"" << doubleToString(72*propList["svg:rx"]->getDouble()) << "\" ry=\"" << doubleToString(72*propList["svg:ry"]->getDouble()) << "\" "; + writeStyle(); + if (propList["libwpg:rotate"] && propList["libwpg:rotate"]->getDouble() != 0.0) + m_outputSink << " transform=\" translate(" << doubleToString(72*propList["svg:cx"]->getDouble()) << ", " << doubleToString(72*propList["svg:cy"]->getDouble()) + << ") rotate(" << doubleToString(-propList["libwpg:rotate"]->getDouble()) + << ") translate(" << doubleToString(-72*propList["svg:cx"]->getDouble()) + << ", " << doubleToString(-72*propList["svg:cy"]->getDouble()) + << ")\" "; + m_outputSink << "/>\n"; +} + +void libpgplus::PGPLUSSVGGenerator::drawPolyline(const ::WPXPropertyListVector &vertices) +{ + drawPolySomething(vertices, false); +} + +void libpgplus::PGPLUSSVGGenerator::drawPolygon(const ::WPXPropertyListVector &vertices) +{ + drawPolySomething(vertices, true); +} + +void libpgplus::PGPLUSSVGGenerator::drawPolySomething(const ::WPXPropertyListVector &vertices, bool isClosed) +{ + if(vertices.count() < 2) + return; + + if(vertices.count() == 2) + { + m_outputSink << "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 << "getDouble())) << " " << doubleToString(72*(vertices[i]["svg:y"]->getDouble())); + if (i < vertices.count()-1) + m_outputSink << ", "; + } + m_outputSink << "\"\n"; + writeStyle(isClosed); + m_outputSink << "/>\n"; + } +} + +void libpgplus::PGPLUSSVGGenerator::drawPath(const ::WPXPropertyListVector &path) +{ + m_outputSink << "getStr() == "M") + { + m_outputSink << "\nM"; + m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); + } + else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "L") + { + m_outputSink << "\nL"; + m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); + } + else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "C") + { + m_outputSink << "\nC"; + m_outputSink << doubleToString(72*(propList["svg:x1"]->getDouble())) << "," << doubleToString(72*(propList["svg:y1"]->getDouble())) << " "; + m_outputSink << doubleToString(72*(propList["svg:x2"]->getDouble())) << "," << doubleToString(72*(propList["svg:y2"]->getDouble())) << " "; + m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); + } + else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "Q") + { + m_outputSink << "\nQ"; + m_outputSink << doubleToString(72*(propList["svg:x1"]->getDouble())) << "," << doubleToString(72*(propList["svg:y1"]->getDouble())) << " "; + m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); + } + else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "A") + { + m_outputSink << "\nA"; + m_outputSink << doubleToString(72*(propList["svg:rx"]->getDouble())) << "," << doubleToString(72*(propList["svg:ry"]->getDouble())) << " "; + m_outputSink << doubleToString(propList["libwpg:rotate"] ? propList["libwpg:rotate"]->getDouble() : 0) << " "; + m_outputSink << (propList["libwpg:large-arc"] ? propList["libwpg:large-arc"]->getInt() : 1) << ","; + m_outputSink << (propList["libwpg:sweep"] ? propList["libwpg:sweep"]->getInt() : 1) << " "; + m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); + } + else if ((i >= path.count()-1 && i > 2) && propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "Z" ) + { + isClosed = true; + m_outputSink << "\nZ"; + } + } + + m_outputSink << "\" \n"; + writeStyle(isClosed); + m_outputSink << "/>\n"; +} + +void libpgplus::PGPLUSSVGGenerator::drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData) +{ + if (!propList["libwpg:mime-type"] || propList["libwpg:mime-type"]->getStr().len() <= 0) + return; + WPXString base64 = binaryData.getBase64Data(); + m_outputSink << "getDouble())) << "\" y=\"" << doubleToString(72*(propList["svg:y"]->getDouble())) << "\" "; + m_outputSink << "width=\"" << doubleToString(72*(propList["svg:width"]->getDouble())) << "\" height=\"" << doubleToString(72*(propList["svg:height"]->getDouble())) << "\" "; + m_outputSink << "xlink:href=\"data:" << propList["libwpg:mime-type"]->getStr().cstr() << ";base64,"; + m_outputSink << base64.cstr(); + m_outputSink << "\" />\n"; +} + +void libpgplus::PGPLUSSVGGenerator::startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector & /* path */) +{ + m_outputSink << "getDouble())) << "\" y=\"" << doubleToString(72*(propList["svg:y"]->getDouble())) << "\""; + if (propList["libwpg:rotate"] && propList["libwpg:rotate"]->getDouble() != 0.0) + m_outputSink << " transform=\"translate(" << doubleToString(72*propList["svg:x"]->getDouble()) << ", " << doubleToString(72*propList["svg:y"]->getDouble()) + << ") rotate(" << doubleToString(-propList["libwpg:rotate"]->getDouble()) + << ") translate(" << doubleToString(-72*propList["svg:x"]->getDouble()) + << ", " << doubleToString(-72*propList["svg:y"]->getDouble()) + << ")\""; + m_outputSink << ">\n"; + +} + +void libpgplus::PGPLUSSVGGenerator::endTextObject() +{ + m_outputSink << "\n"; +} + +void libpgplus::PGPLUSSVGGenerator::startTextSpan(const ::WPXPropertyList &propList) +{ + m_outputSink << "getStr().cstr() << "\" "; + if (propList["fo:font-style"]) + m_outputSink << "font-style=\"" << propList["fo:font-style"]->getStr().cstr() << "\" "; + if (propList["fo:font-weight"]) + m_outputSink << "font-weight=\"" << propList["fo:font-weight"]->getStr().cstr() << "\" "; + if (propList["fo:font-variant"]) + m_outputSink << "font-variant=\"" << propList["fo:font-variant"]->getStr().cstr() << "\" "; + if (propList["fo:font-size"]) + m_outputSink << "font-size=\"" << doubleToString(propList["fo:font-size"]->getDouble()) << "\" "; + if (propList["fo:color"]) + m_outputSink << "fill=\"" << propList["fo:color"]->getStr().cstr() << "\" "; + if (propList["fo:text-transform"]) + m_outputSink << "text-transform=\"" << propList["fo:text-transform"]->getStr().cstr() << "\" "; + if (propList["svg:fill-opacity"]) + m_outputSink << "fill-opacity=\"" << doubleToString(propList["svg:fill-opacity"]->getDouble()) << "\" "; + if (propList["svg:stroke-opacity"]) + m_outputSink << "stroke-opacity=\"" << doubleToString(propList["svg:stroke-opacity"]->getDouble()) << "\" "; + m_outputSink << ">\n"; +} + +void libpgplus::PGPLUSSVGGenerator::endTextSpan() +{ + m_outputSink << "\n"; +} + +void libpgplus::PGPLUSSVGGenerator::insertText(const ::WPXString &str) +{ + WPXString tempUTF8(str, true); + m_outputSink << tempUTF8.cstr() << "\n"; +} + +// create "style" attribute based on current pen and brush +void libpgplus::PGPLUSSVGGenerator::writeStyle(bool /* isClosed */) +{ + m_outputSink << "style=\""; + + if (m_style["svg:stroke-width"]) + { + double width = m_style["svg:stroke-width"]->getDouble(); + if (width == 0.0 && m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() != "none") + width = 0.2 / 72.0; // reasonable hairline + 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: solid; "; + else if (m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() == "dash") + { + int dots1 = m_style["draw:dots1"]->getInt(); + int dots2 = m_style["draw:dots2"]->getInt(); + double dots1len = m_style["draw:dots1-length"]->getDouble(); + double dots2len = m_style["draw:dots2-length"]->getDouble(); + double gap = m_style["draw:distance"]->getDouble(); + m_outputSink << "stroke-dasharray: "; + for (int i = 0; i < dots1; i++) + { + if (i) + m_outputSink << ", "; + m_outputSink << (int)dots1len; + m_outputSink << ", "; + m_outputSink << (int)gap; + } + for (int j = 0; j < dots2; j++) + { + m_outputSink << ", "; + m_outputSink << (int)dots2len; + m_outputSink << ", "; + m_outputSink << (int)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 << "); "; + + 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()) << "; "; + m_outputSink << "\""; // style +} +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/PGPLUSSVGGenerator.h b/src/lib/PGPLUSSVGGenerator.h new file mode 100644 index 0000000..42b87cb --- /dev/null +++ b/src/lib/PGPLUSSVGGenerator.h @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libpgplus + * 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 + * Copyright (C) 2011 Eilidh McAdam + * + * 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 __PGPLUSSVGGENERATOR_H__ +#define __PGPLUSSVGGENERATOR_H__ + +#include +#include +#include +#include +#include +#include "PGPLUSStringVector.h" + +namespace libpgplus +{ + +class PGPLUSSVGGenerator : public libwpg::WPGPaintInterface +{ +public: + PGPLUSSVGGenerator(PGPLUSStringVector &vec); + ~PGPLUSSVGGenerator(); + + void startGraphics(const ::WPXPropertyList &propList); + void endGraphics(); + void startLayer(const ::WPXPropertyList &propList); + void endLayer(); + void startEmbeddedGraphics(const ::WPXPropertyList & /*propList*/) {} + void endEmbeddedGraphics() {} + + void setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient); + + void drawRectangle(const ::WPXPropertyList &propList); + void drawEllipse(const ::WPXPropertyList &propList); + void drawPolyline(const ::WPXPropertyListVector &vertices); + void drawPolygon(const ::WPXPropertyListVector &vertices); + void drawPath(const ::WPXPropertyListVector &path); + void drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData); + void startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path); + void endTextObject(); + void startTextLine(const ::WPXPropertyList & /* propList */) {} + void endTextLine() {} + void startTextSpan(const ::WPXPropertyList &propList); + void endTextSpan(); + void insertText(const ::WPXString &str); + +private: + ::WPXPropertyListVector m_gradient; + ::WPXPropertyList m_style; + int m_gradientIndex; + int m_patternIndex; + int m_shadowIndex; + void writeStyle(bool isClosed=true); + void drawPolySomething(const ::WPXPropertyListVector &vertices, bool isClosed); + + std::ostringstream m_outputSink; + PGPLUSStringVector &m_vec; +}; + +} // namespace libpgplus + +#endif // __PGPLUSSVGGENERATOR_H__ +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/PGPLUSStringVector.cpp b/src/lib/PGPLUSStringVector.cpp new file mode 100644 index 0000000..a950185 --- /dev/null +++ b/src/lib/PGPLUSStringVector.cpp @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libpgplus + * 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) 2012 Fridrich Strba + * + * + * 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 +#include "PGPLUSStringVector.h" + +namespace libpgplus +{ +class PGPLUSStringVectorImpl +{ +public: + PGPLUSStringVectorImpl() : m_strings() {} + PGPLUSStringVectorImpl(const PGPLUSStringVectorImpl &impl) : m_strings(impl.m_strings) {} + ~PGPLUSStringVectorImpl() {} + std::vector m_strings; +}; + +} // namespace libpgplus + +libpgplus::PGPLUSStringVector::PGPLUSStringVector() + : m_pImpl(new PGPLUSStringVectorImpl()) +{ +} + +libpgplus::PGPLUSStringVector::PGPLUSStringVector(const PGPLUSStringVector &vec) + : m_pImpl(new PGPLUSStringVectorImpl(*(vec.m_pImpl))) +{ +} + +libpgplus::PGPLUSStringVector::~PGPLUSStringVector() +{ +} + +libpgplus::PGPLUSStringVector &libpgplus::PGPLUSStringVector::operator=(const PGPLUSStringVector &vec) +{ + if (m_pImpl) + delete m_pImpl; + m_pImpl = new PGPLUSStringVectorImpl(*(vec.m_pImpl)); + return *this; +} + +unsigned libpgplus::PGPLUSStringVector::size() const +{ + return (unsigned)(m_pImpl->m_strings.size()); +} + +bool libpgplus::PGPLUSStringVector::empty() const +{ + return m_pImpl->m_strings.empty(); +} + +const WPXString &libpgplus::PGPLUSStringVector::operator[](unsigned idx) const +{ + return m_pImpl->m_strings[idx]; +} + +void libpgplus::PGPLUSStringVector::append(const WPXString &str) +{ + m_pImpl->m_strings.push_back(str); +} + +void libpgplus::PGPLUSStringVector::clear() +{ + m_pImpl->m_strings.clear(); +} + +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/PGPLUSStringVector.h b/src/lib/PGPLUSStringVector.h new file mode 100644 index 0000000..b18ec59 --- /dev/null +++ b/src/lib/PGPLUSStringVector.h @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libpgplus + * 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) 2012 Fridrich Strba + * + * 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 __PGPLUSSTRINGVECTOR_H__ +#define __PGPLUSSTRINGVECTOR_H__ + +#include + +namespace libpgplus +{ +class PGPLUSStringVectorImpl; + +class PGPLUSStringVector +{ +public: + PGPLUSStringVector(); + PGPLUSStringVector(const PGPLUSStringVector &vec); + ~PGPLUSStringVector(); + + PGPLUSStringVector &operator=(const PGPLUSStringVector &vec); + + unsigned size() const; + bool empty() const; + const WPXString &operator[](unsigned idx) const; + void append(const WPXString &str); + void clear(); + +private: + PGPLUSStringVectorImpl *m_pImpl; +}; + +} // namespace libpgplus + +#endif /* __PGPLUSSTRINGVECTOR_H__ */ +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/libmspub.h b/src/lib/libmspub.h deleted file mode 100644 index 17453e2..0000000 --- a/src/lib/libmspub.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libpgplus - * 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) 2012 Fridrich Strba - * - * 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 __LIBPGPLUS_H__ -#define __LIBPGPLUS_H__ - -#include "PGPLUSDocument.h" -#include -#include - -#endif -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/libmspub.rc.in b/src/lib/libmspub.rc.in deleted file mode 100644 index 432eb25..0000000 --- a/src/lib/libmspub.rc.in +++ /dev/null @@ -1,31 +0,0 @@ -#include - -VS_VERSION_INFO VERSIONINFO - FILEVERSION @PGPLUS_MAJOR_VERSION@,@PGPLUS_MINOR_VERSION@,@PGPLUS_MICRO_VERSION@,BUILDNUMBER - PRODUCTVERSION @PGPLUS_MAJOR_VERSION@,@PGPLUS_MINOR_VERSION@,@PGPLUS_MICRO_VERSION@,0 - FILEFLAGSMASK 0 - FILEFLAGS 0 - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE VFT2_UNKNOWN - BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "The libpgplus developer community" - VALUE "FileDescription", "libpgplus" - VALUE "FileVersion", "@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@.@PGPLUS_MICRO_VERSION@.BUILDNUMBER" - VALUE "InternalName", "libpgplus-0.1" - VALUE "LegalCopyright", "Copyright (C) 2004 Marc Oude Kotte, other contributers" - VALUE "OriginalFilename", "libpgplus-0.1.dll" - VALUE "ProductName", "libpgplus" - VALUE "ProductVersion", "@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@.@PGPLUS_MICRO_VERSION@" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END - END - diff --git a/src/lib/libmspub_utils.cpp b/src/lib/libmspub_utils.cpp deleted file mode 100644 index c84e107..0000000 --- a/src/lib/libmspub_utils.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libpgplus - * 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 - * Copyright (C) 2011 Eilidh McAdam - * - * - * 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 "libpgplus_utils.h" - -#define PGPLUS_NUM_ELEMENTS(array) sizeof(array)/sizeof(array[0]) - -uint8_t libpgplus::readU8(WPXInputStream *input) -{ - if (!input || input->atEOS()) - throw EndOfStreamException(); - unsigned long numBytesRead; - uint8_t const *p = input->read(sizeof(uint8_t), numBytesRead); - - if (p && numBytesRead == sizeof(uint8_t)) - return *(uint8_t const *)(p); - throw EndOfStreamException(); -} - -uint16_t libpgplus::readU16(WPXInputStream *input) -{ - uint16_t p0 = (uint16_t)readU8(input); - uint16_t p1 = (uint16_t)readU8(input); - return (uint16_t)(p0|(p1<<8)); -} - -uint32_t libpgplus::readU32(WPXInputStream *input) -{ - uint32_t p0 = (uint32_t)readU8(input); - uint32_t p1 = (uint32_t)readU8(input); - uint32_t p2 = (uint32_t)readU8(input); - uint32_t p3 = (uint32_t)readU8(input); - return (uint32_t)(p0|(p1<<8)|(p2<<16)|(p3<<24)); -} - -int32_t libpgplus::readS32(WPXInputStream *input) -{ - return (int32_t)readU32(input); -} - -uint64_t libpgplus::readU64(WPXInputStream *input) -{ - uint64_t p0 = (uint64_t)readU8(input); - uint64_t p1 = (uint64_t)readU8(input); - uint64_t p2 = (uint64_t)readU8(input); - uint64_t p3 = (uint64_t)readU8(input); - uint64_t p4 = (uint64_t)readU8(input); - uint64_t p5 = (uint64_t)readU8(input); - uint64_t p6 = (uint64_t)readU8(input); - uint64_t p7 = (uint64_t)readU8(input); - return (uint64_t)(p0|(p1<<8)|(p2<<16)|(p3<<24)|(p4<<32)|(p5<<40)|(p6<<48)|(p7<<56)); -} - -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/libmspub_utils.h b/src/lib/libmspub_utils.h deleted file mode 100644 index f0d79c2..0000000 --- a/src/lib/libmspub_utils.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* libpgplus - * 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) 2012 Fridrich Strba - * - * 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 __LIBPGPLUS_UTILS_H__ -#define __LIBPGPLUS_UTILS_H__ - -#include -#include -#include -#include - -#ifdef _MSC_VER - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned uint32_t; -typedef int int32_t; -typedef unsigned __int64 uint64_t; - -#else - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef HAVE_STDINT_H -#include -#endif - -#ifdef HAVE_INTTYPES_H -#include -#endif - -#endif - -// debug message includes source file and line number -//#define VERBOSE_DEBUG 1 - -// do nothing with debug messages in a release compile -#ifdef DEBUG -#ifdef VERBOSE_DEBUG -#define PGPLUS_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M -#define PGPLUS_DEBUG(M) M -#else -#define PGPLUS_DEBUG_MSG(M) printf M -#define PGPLUS_DEBUG(M) M -#endif -#else -#define PGPLUS_DEBUG_MSG(M) -#define PGPLUS_DEBUG(M) -#endif - -namespace libpgplus -{ - -uint8_t readU8(WPXInputStream *input); -uint16_t readU16(WPXInputStream *input); -uint32_t readU32(WPXInputStream *input); -uint64_t readU64(WPXInputStream *input); -int32_t readS32(WPXInputStream *input); - -class EndOfStreamException -{ -}; - -class GenericException -{ -}; - -} // namespace libpgplus - -#endif // __LIBPGPLUS_UTILS_H__ -/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/libpgplus.h b/src/lib/libpgplus.h new file mode 100644 index 0000000..17453e2 --- /dev/null +++ b/src/lib/libpgplus.h @@ -0,0 +1,37 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libpgplus + * 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) 2012 Fridrich Strba + * + * 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 __LIBPGPLUS_H__ +#define __LIBPGPLUS_H__ + +#include "PGPLUSDocument.h" +#include +#include + +#endif +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/libpgplus.rc.in b/src/lib/libpgplus.rc.in new file mode 100644 index 0000000..432eb25 --- /dev/null +++ b/src/lib/libpgplus.rc.in @@ -0,0 +1,31 @@ +#include + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @PGPLUS_MAJOR_VERSION@,@PGPLUS_MINOR_VERSION@,@PGPLUS_MICRO_VERSION@,BUILDNUMBER + PRODUCTVERSION @PGPLUS_MAJOR_VERSION@,@PGPLUS_MINOR_VERSION@,@PGPLUS_MICRO_VERSION@,0 + FILEFLAGSMASK 0 + FILEFLAGS 0 + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_UNKNOWN + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "The libpgplus developer community" + VALUE "FileDescription", "libpgplus" + VALUE "FileVersion", "@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@.@PGPLUS_MICRO_VERSION@.BUILDNUMBER" + VALUE "InternalName", "libpgplus-0.1" + VALUE "LegalCopyright", "Copyright (C) 2004 Marc Oude Kotte, other contributers" + VALUE "OriginalFilename", "libpgplus-0.1.dll" + VALUE "ProductName", "libpgplus" + VALUE "ProductVersion", "@PGPLUS_MAJOR_VERSION@.@PGPLUS_MINOR_VERSION@.@PGPLUS_MICRO_VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END + diff --git a/src/lib/libpgplus_utils.cpp b/src/lib/libpgplus_utils.cpp new file mode 100644 index 0000000..c84e107 --- /dev/null +++ b/src/lib/libpgplus_utils.cpp @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libpgplus + * 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 + * Copyright (C) 2011 Eilidh McAdam + * + * + * 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 "libpgplus_utils.h" + +#define PGPLUS_NUM_ELEMENTS(array) sizeof(array)/sizeof(array[0]) + +uint8_t libpgplus::readU8(WPXInputStream *input) +{ + if (!input || input->atEOS()) + throw EndOfStreamException(); + unsigned long numBytesRead; + uint8_t const *p = input->read(sizeof(uint8_t), numBytesRead); + + if (p && numBytesRead == sizeof(uint8_t)) + return *(uint8_t const *)(p); + throw EndOfStreamException(); +} + +uint16_t libpgplus::readU16(WPXInputStream *input) +{ + uint16_t p0 = (uint16_t)readU8(input); + uint16_t p1 = (uint16_t)readU8(input); + return (uint16_t)(p0|(p1<<8)); +} + +uint32_t libpgplus::readU32(WPXInputStream *input) +{ + uint32_t p0 = (uint32_t)readU8(input); + uint32_t p1 = (uint32_t)readU8(input); + uint32_t p2 = (uint32_t)readU8(input); + uint32_t p3 = (uint32_t)readU8(input); + return (uint32_t)(p0|(p1<<8)|(p2<<16)|(p3<<24)); +} + +int32_t libpgplus::readS32(WPXInputStream *input) +{ + return (int32_t)readU32(input); +} + +uint64_t libpgplus::readU64(WPXInputStream *input) +{ + uint64_t p0 = (uint64_t)readU8(input); + uint64_t p1 = (uint64_t)readU8(input); + uint64_t p2 = (uint64_t)readU8(input); + uint64_t p3 = (uint64_t)readU8(input); + uint64_t p4 = (uint64_t)readU8(input); + uint64_t p5 = (uint64_t)readU8(input); + uint64_t p6 = (uint64_t)readU8(input); + uint64_t p7 = (uint64_t)readU8(input); + return (uint64_t)(p0|(p1<<8)|(p2<<16)|(p3<<24)|(p4<<32)|(p5<<40)|(p6<<48)|(p7<<56)); +} + +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/libpgplus_utils.h b/src/lib/libpgplus_utils.h new file mode 100644 index 0000000..f0d79c2 --- /dev/null +++ b/src/lib/libpgplus_utils.h @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* libpgplus + * 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) 2012 Fridrich Strba + * + * 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 __LIBPGPLUS_UTILS_H__ +#define __LIBPGPLUS_UTILS_H__ + +#include +#include +#include +#include + +#ifdef _MSC_VER + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned uint32_t; +typedef int int32_t; +typedef unsigned __int64 uint64_t; + +#else + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_STDINT_H +#include +#endif + +#ifdef HAVE_INTTYPES_H +#include +#endif + +#endif + +// debug message includes source file and line number +//#define VERBOSE_DEBUG 1 + +// do nothing with debug messages in a release compile +#ifdef DEBUG +#ifdef VERBOSE_DEBUG +#define PGPLUS_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M +#define PGPLUS_DEBUG(M) M +#else +#define PGPLUS_DEBUG_MSG(M) printf M +#define PGPLUS_DEBUG(M) M +#endif +#else +#define PGPLUS_DEBUG_MSG(M) +#define PGPLUS_DEBUG(M) +#endif + +namespace libpgplus +{ + +uint8_t readU8(WPXInputStream *input); +uint16_t readU16(WPXInputStream *input); +uint32_t readU32(WPXInputStream *input); +uint64_t readU64(WPXInputStream *input); +int32_t readS32(WPXInputStream *input); + +class EndOfStreamException +{ +}; + +class GenericException +{ +}; + +} // namespace libpgplus + +#endif // __LIBPGPLUS_UTILS_H__ +/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/makefile.mk b/src/lib/makefile.mk index 58b83d2..2676554 100644 --- a/src/lib/makefile.mk +++ b/src/lib/makefile.mk @@ -3,7 +3,7 @@ EXTERNAL_WARNINGS_NOT_ERRORS := TRUE PRJ=..$/..$/..$/..$/..$/.. PRJNAME=libpgplus -TARGET=mspublib +TARGET=pgpluslib ENABLE_EXCEPTIONS=TRUE LIBTARGET=NO @@ -29,7 +29,10 @@ INCPRE+=$(SOLARVER)$/$(INPATH)$/inc$/libwpg .ENDIF SLOFILES= \ + $(SLO)$/PGPLUSCollector.obj \ $(SLO)$/PGPLUSDocument.obj \ + $(SLO)$/PGPLUSParser.obj \ + $(SLO)$/PGPLUSStringVector.obj \ $(SLO)$/PGPLUSSVGGenerator.obj \ $(SLO)$/libpgplus_utils.obj -- cgit v1.2.3