summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 35c8410)
raw | patch | inline | side by side (parent: 35c8410)
author | gouldtj <gouldtj@users.sourceforge.net> | |
Wed, 31 Oct 2007 13:29:03 +0000 (13:29 +0000) | ||
committer | gouldtj <gouldtj@users.sourceforge.net> | |
Wed, 31 Oct 2007 13:29:03 +0000 (13:29 +0000) |
Switching everything over to a linked in libwpg
43 files changed:
diff --git a/src/Makefile.am b/src/Makefile.am
index 95ab6ce56e600e250836280a6938b94544430dd0..9eb9e1693b6a04de69a1f6f9ad88422e70985c5d 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
include extension/Makefile_insert
include extension/implementation/Makefile_insert
include extension/internal/Makefile_insert
-include extension/internal/libwpg/Makefile_insert
include extension/script/Makefile_insert
include helper/Makefile_insert
include inkjar/Makefile_insert
dom/libdom.a \
extension/implementation/libimplementation.a \
extension/internal/libinternal.a \
- extension/internal/libwpg/libwpg.a \
extension/libextension.a \
extension/script/libscript.a \
helper/libspchelp.a \
diff --git a/src/Makefile_insert b/src/Makefile_insert
index 886ad6dc9262cae52e960a33d4ebc5f0b321c3ba..3e62c730cf846df405d909f721b5d1d5f0a9517f 100644 (file)
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
extension/libextension.a \
extension/implementation/libimplementation.a \
extension/internal/libinternal.a \
- extension/internal/libwpg/libwpg.a \
extension/script/libscript.a \
- dom/libdom.a \
+ dom/libdom.a \
xml/libspxml.a \
2geom/lib2geom.a \
util/libinkutil.a \
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index 3a9f1e9aadcee8b822d8b9deeda7f3f6e8bc3205..852b7ce7031a756670b81cd39e528d70a59e7e6e 100644 (file)
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
#include "internal/bluredge.h"
#include "internal/gimpgrad.h"
#include "internal/grid.h"
+#ifdef WITH_LIBWPG
#include "internal/wpg-input.h"
+#endif
#include "prefs-utils.h"
#include "io/sys.h"
Internal::OdfOutput::init();
Internal::PrintLatex::init();
Internal::LatexOutput::init();
+#ifdef WITH_LIBWPG
Internal::WpgInput::init();
+#endif
/* Effects */
Internal::BlurEdge::init();
diff --git a/src/extension/internal/libwpg/.cvsignore b/src/extension/internal/libwpg/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.deps
-.libs
-libwpg.h
-Makefile
-Makefile.in
-*.lo
-*.rc
-*.la
diff --git a/src/extension/internal/libwpg/Makefile_insert b/src/extension/internal/libwpg/Makefile_insert
+++ /dev/null
@@ -1,45 +0,0 @@
-## Makefile.am fragment sourced by src/Makefile.am.
-
-extension/internal/libwpg/all: extension/internal/libwpg/libwpg.a
-
-extension/internal/libwpg/clean:
- rm -f extension/internal/libwpg/libwpg.a $(extension_internal_libwpg_libwpg_OBJECTS)
-
-extension_internal_libwpg_libwpg_a_SOURCES = \
- extension/internal/libwpg/libwpg.h \
- extension/internal/libwpg/libwpg_utils.h \
- extension/internal/libwpg/Makefile_insert \
- extension/internal/libwpg/WPG1Parser.cpp \
- extension/internal/libwpg/WPG1Parser.h \
- extension/internal/libwpg/WPG2Parser.cpp \
- extension/internal/libwpg/WPG2Parser.h \
- extension/internal/libwpg/WPGBrush.cpp \
- extension/internal/libwpg/WPGBrush.h \
- extension/internal/libwpg/WPGColor.cpp \
- extension/internal/libwpg/WPGColor.h \
- extension/internal/libwpg/WPGGradient.cpp \
- extension/internal/libwpg/WPGGradient.h \
- extension/internal/libwpg/WPGHeader.cpp \
- extension/internal/libwpg/WPGHeader.h \
- extension/internal/libwpg/WPGOLEStream.cpp \
- extension/internal/libwpg/WPGOLEStream.h \
- extension/internal/libwpg/WPGPaintInterface.h \
- extension/internal/libwpg/WPGPath.cpp \
- extension/internal/libwpg/WPGPath.h \
- extension/internal/libwpg/WPGPen.cpp \
- extension/internal/libwpg/WPGPen.h \
- extension/internal/libwpg/WPGPoint.cpp \
- extension/internal/libwpg/WPGPoint.h \
- extension/internal/libwpg/WPGraphics.cpp \
- extension/internal/libwpg/WPGraphics.h \
- extension/internal/libwpg/WPGRect.cpp \
- extension/internal/libwpg/WPGRect.h \
- extension/internal/libwpg/WPGStream.h \
- extension/internal/libwpg/WPGStreamImplementation.cpp \
- extension/internal/libwpg/WPGStreamImplementation.h \
- extension/internal/libwpg/WPGString.cpp \
- extension/internal/libwpg/WPGString.h \
- extension/internal/libwpg/WPGSVGGenerator.cpp \
- extension/internal/libwpg/WPGSVGGenerator.h \
- extension/internal/libwpg/WPGXParser.cpp \
- extension/internal/libwpg/WPGXParser.h
diff --git a/src/extension/internal/libwpg/WPG1Parser.cpp b/src/extension/internal/libwpg/WPG1Parser.cpp
+++ /dev/null
@@ -1,432 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
- * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "WPG1Parser.h"
-#include "WPGPaintInterface.h"
-#include "libwpg_utils.h"
-
-static const unsigned char defaultWPG1PaletteRed[] = {
- 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x7F,
- 0xC0, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x00, 0x14, 0x20, 0x2C, 0x38, 0x45, 0x51, 0x61,
- 0x71, 0x82, 0x92, 0xA2, 0xB6, 0xCB, 0xE3, 0xFF,
- 0x00, 0x41, 0x7D, 0xBE, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBE, 0x7D, 0x41,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x7D, 0x9E, 0xBE, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xBE, 0x9E,
- 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D,
- 0xB6, 0xC7, 0xDB, 0xEB, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEB, 0xDB, 0xC7,
- 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6,
- 0x00, 0x1C, 0x38, 0x55, 0x71, 0x71, 0x71, 0x71,
- 0x71, 0x71, 0x71, 0x71, 0x71, 0x55, 0x38, 0x1C,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x38, 0x45, 0x55, 0x61, 0x71, 0x71, 0x71, 0x71,
- 0x71, 0x71, 0x71, 0x71, 0x71, 0x61, 0x55, 0x45,
- 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38,
- 0x51, 0x59, 0x61, 0x69, 0x71, 0x71, 0x71, 0x71,
- 0x71, 0x71, 0x71, 0x71, 0x71, 0x69, 0x61, 0x59,
- 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51,
- 0x00, 0x10, 0x20, 0x30, 0x41, 0x41, 0x41, 0x41,
- 0x41, 0x41, 0x41, 0x41, 0x41, 0x30, 0x20, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x20, 0x28, 0x30, 0x38, 0x41, 0x41, 0x41, 0x41,
- 0x41, 0x41, 0x41, 0x41, 0x41, 0x38, 0x30, 0x28,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x3C, 0x30, 0x34, 0x3C, 0x41, 0x41, 0x41, 0x41,
- 0x41, 0x41, 0x41, 0x41, 0x41, 0x3C, 0x34, 0x30,
- 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-
-static const unsigned char defaultWPG1PaletteGreen[] = {
- 0x00, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x3F, 0x7F,
- 0xC0, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF,
- 0x00, 0x14, 0x20, 0x2C, 0x38, 0x45, 0x51, 0x61,
- 0x71, 0x82, 0x92, 0xA2, 0xB6, 0xCB, 0xE3, 0xFF,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x41, 0x7D, 0xBE, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBE, 0x7D, 0x41,
- 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D,
- 0x7D, 0x9E, 0xBE, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xBE, 0x9E,
- 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6,
- 0xB6, 0xC7, 0xDB, 0xEB, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEB, 0xDB, 0xC7,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x1C, 0x38, 0x55, 0x71, 0x71, 0x71, 0x71,
- 0x71, 0x71, 0x71, 0x71, 0x71, 0x55, 0x38, 0x1C,
- 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38,
- 0x38, 0x45, 0x55, 0x61, 0x71, 0x71, 0x71, 0x71,
- 0x71, 0x71, 0x71, 0x71, 0x71, 0x61, 0x55, 0x45,
- 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51,
- 0x51, 0x59, 0x61, 0x69, 0x71, 0x71, 0x71, 0x71,
- 0x71, 0x71, 0x71, 0x71, 0x71, 0x69, 0x61, 0x59,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x20, 0x30, 0x41, 0x41, 0x41, 0x41,
- 0x41, 0x41, 0x41, 0x41, 0x41, 0x30, 0x20, 0x10,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x28, 0x30, 0x38, 0x41, 0x41, 0x41, 0x41,
- 0x41, 0x41, 0x41, 0x41, 0x41, 0x38, 0x30, 0x28,
- 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C,
- 0x3C, 0x30, 0x34, 0x3C, 0x41, 0x41, 0x41, 0x41,
- 0x41, 0x41, 0x41, 0x41, 0x41, 0x3C, 0x34, 0x30,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-
-static const unsigned char defaultWPG1PaletteBlue[] = {
- 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F,
- 0xC0, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
- 0x00, 0x14, 0x20, 0x2C, 0x38, 0x45, 0x51, 0x61,
- 0x71, 0x82, 0x92, 0xA2, 0xB6, 0xCB, 0xE3, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBE, 0x7D, 0x41,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x41, 0x7D, 0xBE, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xBE, 0x9E,
- 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D,
- 0x7D, 0x9E, 0xBE, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEB, 0xDB, 0xC7,
- 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6,
- 0xB6, 0xC7, 0xDB, 0xEB, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x71, 0x71, 0x71, 0x71, 0x71, 0x55, 0x38, 0x1C,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x1C, 0x38, 0x55, 0x71, 0x71, 0x71, 0x71,
- 0x71, 0x71, 0x71, 0x71, 0x71, 0x61, 0x55, 0x45,
- 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38,
- 0x38, 0x45, 0x55, 0x61, 0x71, 0x71, 0x71, 0x71,
- 0x71, 0x71, 0x71, 0x71, 0x71, 0x69, 0x61, 0x59,
- 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51,
- 0x51, 0x59, 0x61, 0x69, 0x71, 0x71, 0x71, 0x71,
- 0x41, 0x41, 0x41, 0x41, 0x41, 0x30, 0x20, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x20, 0x30, 0x41, 0x41, 0x41, 0x41,
- 0x41, 0x41, 0x41, 0x41, 0x41, 0x38, 0x30, 0x28,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x28, 0x30, 0x38, 0x41, 0x41, 0x41, 0x41,
- 0x41, 0x41, 0x41, 0x41, 0x41, 0x3C, 0x34, 0x30,
- 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C,
- 0x2C, 0x30, 0x34, 0x3C, 0x41, 0x41, 0x41, 0x41,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-
-
-WPG1Parser::WPG1Parser(libwpg::WPGInputStream *input, libwpg::WPGPaintInterface* painter):
- WPGXParser(input, painter),
- m_success(true), m_exit(false),
- m_width(0), m_height(0)
-{
-}
-
-bool WPG1Parser::parse()
-{
- typedef void (WPG1Parser::*Method)();
-
- struct RecordHandler
- {
- int type;
- const char *name;
- Method handler;
- };
-
- static const struct RecordHandler handlers[] =
- {
- { 0x01, "Fill Attributes", &WPG1Parser::handleFillAttributes },
- { 0x02, "Line Attributes", &WPG1Parser::handleLineAttributes },
- { 0x03, "Marker Atttibutes", 0 },
- { 0x04, "Polymarker", 0 },
- { 0x05, "Line", &WPG1Parser::handleLine },
- { 0x06, "Polyline", &WPG1Parser::handlePolyline },
- { 0x07, "Rectangle", &WPG1Parser::handleRectangle },
- { 0x08, "Polygon", &WPG1Parser::handlePolygon },
- { 0x09, "Ellipse", &WPG1Parser::handleEllipse },
- { 0x0e, "Colormap", &WPG1Parser::handleColormap },
- { 0x0f, "Start WPG", &WPG1Parser::handleStartWPG },
- { 0x10, "End WPG", &WPG1Parser::handleEndWPG },
- { 0x00, 0, 0 } // end marker
- };
-
- // initialization
- m_success = true;
- m_exit = false;
-
- // default style
- m_pen.foreColor = libwpg::WPGColor(0,0,0);
- m_pen.backColor = libwpg::WPGColor(0,0,0);
- m_pen.width = 0.001;
- m_pen.height = 0.001;
- m_pen.solid = true;
- m_pen.dashArray = libwpg::WPGDashArray();
- m_brush.foreColor = libwpg::WPGColor(0,0,0);
- m_brush.backColor = libwpg::WPGColor(0,0,0);
- resetPalette();
-
- while(!m_input->atEnd())
- {
-#ifdef DEBUG
- long recordPos = m_input->tell();
-#endif
- int recordType = readU8();
- int length = readVariableLengthInteger();
- long nextPos = m_input->tell() + length;
-#if !defined(DEBUG)
- //(void)recordPos;
-#endif // !defined(DEBUG)
-
- // search function to handler this record
- int index = -1;
- for(int i = 0; (index < 0) && handlers[i].name; i++)
- if(handlers[i].type == recordType)
- index = i;
-
- WPG_DEBUG_MSG(("\n"));
- if(index < 0)
- WPG_DEBUG_MSG(("Unknown record type 0x%02x at %d size %d\n",
- recordType, recordPos, length));
- else
- {
- Method recordHandler = handlers[index].handler;
- if(!recordHandler)
- WPG_DEBUG_MSG(("Record '%s' (ignored) type 0x%02x at %d size %d\n",
- handlers[index].name, recordType, recordPos, length));
- else
- {
- WPG_DEBUG_MSG(("Record '%s' type 0x%02x at %d size %d\n",
- handlers[index].name, recordType, recordPos, length));
-
- // invoke the handler for this record
- (this->*recordHandler)();
- }
- }
-
- //if(m_input->tell() > nextPos)
- {
- //WPG_DEBUG_MSG(("Record 0x%x consumes more bytes than necessary!\n", recordType));
- WPG_DEBUG_MSG(("Current stream position: %d\n", m_input->tell()));
- }
-
- if(m_exit) break;
-
- m_input->seek(nextPos);
- }
-
- return m_success;
-}
-
-void WPG1Parser::handleStartWPG()
-{
- // unsigned char version = readU8();
- // unsigned char bitFlags = readU8();
- m_input->seek(m_input->tell() + 2);
- //(void)version;
- //(void)bitFlags;
- m_width = readU16();
- m_height = readU16();
-
- double width = (double)m_width / 1200.0;
- double height = (double)m_height / 1200.0;
- m_painter->startDocument(width, height);
-
- WPG_DEBUG_MSG(("StartWPG\n"));
-}
-
-void WPG1Parser::handleEndWPG()
-{
- m_painter->endDocument();
- m_exit = true;
-
- WPG_DEBUG_MSG(("EndWPG\n"));
-}
-
-void WPG1Parser::handleColormap()
-{
- unsigned startIndex = readU16();
- unsigned numEntries = readU16();
-
- WPG_DEBUG_MSG(("Colormap\n"));
- for(unsigned int i = 0; i < numEntries; i++)
- {
- libwpg::WPGColor color;
- color.red = readU8();
- color.green = readU8();
- color.blue = readU8();
- m_colorPalette[startIndex+i] = color;
- WPG_DEBUG_MSG(("Index#%d: RGB %d %d %d\n", startIndex+i, color.red, color.green, color.blue));
- }
-}
-
-void WPG1Parser::handleFillAttributes()
-{
- unsigned char style = readU8();
- unsigned char color = readU8();
-
- if(style == 0)
- m_brush.style = libwpg::WPGBrush::NoBrush;
- if(style == 1)
- m_brush.style = libwpg::WPGBrush::Solid;
-
- m_brush.foreColor = m_colorPalette[color];
-
- WPG_DEBUG_MSG(("Fill Attributes\n"));
- WPG_DEBUG_MSG((" Fill style: %d\n", style));
- WPG_DEBUG_MSG((" Fill color index: %d\n", color));
-}
-
-void WPG1Parser::handleLineAttributes()
-{
- unsigned char style = readU8();
- unsigned char color = readU8();
- unsigned int width = readU16();
-
- m_pen.solid = style != 0;
- m_pen.foreColor = m_colorPalette[color];
- m_pen.width = (double)width / 1200.0;
-
- WPG_DEBUG_MSG(("Line Attributes\n"));
- WPG_DEBUG_MSG((" Line style: %d\n", style));
- WPG_DEBUG_MSG((" Line color index: %d\n", color));
- WPG_DEBUG_MSG((" Line width: %d\n", width));
-}
-
-void WPG1Parser::handleLine()
-{
- int sx = readS16();
- int sy = readS16();
- int ex = readS16();
- int ey = readS16();
-
- libwpg::WPGPointArray points;
- points.add(libwpg::WPGPoint((double)sx/1200.0, (double)(m_height-sy)/1200.0));
- points.add(libwpg::WPGPoint((double)ex/1200.0, (double)(m_height-ey)/1200.0));
-
- m_painter->setBrush(m_brush);
- m_painter->setPen(m_pen);
- m_painter->drawPolygon(points);
-
- WPG_DEBUG_MSG(("Line\n"));
- WPG_DEBUG_MSG((" Starting point: %d,%d\n", sx, sy));
- WPG_DEBUG_MSG((" End point: %d,%d\n", ex, ey));
-}
-
-void WPG1Parser::handlePolyline()
-{
- unsigned int count = readU16();
-
- libwpg::WPGPointArray points;
- for(unsigned int i = 0; i < count; i++ )
- {
- long x = readS16();
- long y = readS16();
- points.add(libwpg::WPGPoint((double)x/1200.0, (double)(m_height-y)/1200.0));
- }
-
- m_painter->setBrush(libwpg::WPGBrush()); // not filled
- m_painter->setPen(m_pen);
- m_painter->drawPolygon(points);
-
- WPG_DEBUG_MSG(("Polyline\n"));
-}
-
-void WPG1Parser::handleRectangle()
-{
- int x = readS16();
- int y = readS16();
- int w = readS16();
- int h = readS16();
-
- libwpg::WPGRect rect;
- rect.x1 = (double)x/1200.0;
- rect.y1 = (double)(m_height-y)/1200.0;
- rect.x2 = rect.x1 + (double)w/1200.0;
- rect.y2 = rect.y1 + (double)h/1200.0;
-
- m_painter->setBrush(m_brush);
- m_painter->setPen(m_pen);
- m_painter->drawRectangle(rect, 0, 0);
-
- WPG_DEBUG_MSG(("Line\n"));
- WPG_DEBUG_MSG((" Corner point: %d,%d\n", x, y));
- WPG_DEBUG_MSG((" Width: %d\n", w));
- WPG_DEBUG_MSG((" Height: %d\n", h));
-}
-
-void WPG1Parser::handlePolygon()
-{
- unsigned int count = readU16();
-
- libwpg::WPGPointArray points;
- for(unsigned int i = 0; i < count; i++ )
- {
- long x = readS16();
- long y = readS16();
- points.add(libwpg::WPGPoint((double)x/1200.0, (double)(m_height-y)/1200.0));
- }
-
- m_painter->setBrush(m_brush);
- m_painter->setPen(m_pen);
- m_painter->drawPolygon(points);
-
- WPG_DEBUG_MSG(("Polygon\n"));
-}
-
-void WPG1Parser::handleEllipse()
-{
- int cx = readS16();
- int cy = readS16();
- int rx = readS16();
- int ry = readS16();
-
- libwpg::WPGPoint center;
- center.x = (double)cx/1200.0;
- center.y = (double)(m_height-cy)/1200.0;
-
- double radx = (double)rx/1200.0;
- double rady = (double)ry/1200.0;
-
- m_painter->setBrush(m_brush);
- m_painter->setPen(m_pen);
- m_painter->drawEllipse(center, radx, rady);
-
- WPG_DEBUG_MSG(("Ellipse\n"));
- WPG_DEBUG_MSG((" Center point: %d,%d\n", cx, cy));
- WPG_DEBUG_MSG((" Radius x: %d\n", rx));
- WPG_DEBUG_MSG((" Radius y: %d\n", ry));
-}
-
-void WPG1Parser::resetPalette()
-{
- m_colorPalette.clear();
- for (int i=0; i<256; i++)
- {
- libwpg::WPGColor color;
- color.red = defaultWPG1PaletteRed[i];
- color.green = defaultWPG1PaletteGreen[i];
- color.blue = defaultWPG1PaletteBlue[i];
- m_colorPalette[i] = color;
- }
-}
-
diff --git a/src/extension/internal/libwpg/WPG1Parser.h b/src/extension/internal/libwpg/WPG1Parser.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
- * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPG1PARSER_H__
-#define __WPG1PARSER_H__
-
-#include "WPGXParser.h"
-#include "WPGBrush.h"
-#include "WPGPen.h"
-
-class WPG1Parser : public WPGXParser
-{
-public:
- WPG1Parser(libwpg::WPGInputStream *input, libwpg::WPGPaintInterface* painter);
- bool parse();
-
-private:
- void handleStartWPG();
- void handleEndWPG();
-
- void handleFillAttributes();
- void handleLineAttributes();
- void handleColormap();
-
- void handleLine();
- void handlePolyline();
- void handleRectangle();
- void handlePolygon();
- void handleEllipse();
-
- void resetPalette();
-
- // parsing context
- bool m_success;
- bool m_exit;
- int m_width;
- int m_height;
- libwpg::WPGPen m_pen;
- libwpg::WPGBrush m_brush;
-};
-
-#endif // __WPG1PARSER_H__
diff --git a/src/extension/internal/libwpg/WPG2Parser.cpp b/src/extension/internal/libwpg/WPG2Parser.cpp
+++ /dev/null
@@ -1,1282 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
- * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "WPG2Parser.h"
-#include "WPGPaintInterface.h"
-#include "libwpg_utils.h"
-
-#include <math.h>
-#include <vector>
-
-// MSVC++ 6.0 does not have the macro defined, so we define it
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-static const unsigned char defaultWPG2PaletteRed[] = {
- 0x00, 0xFF, 0x7F, 0xBF, 0x00, 0x00, 0x00, 0x7F,
- 0x7F, 0x7F, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
- 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
- 0x7B, 0x91, 0xA7, 0xBD, 0xD3, 0xE9, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x7B, 0x91, 0xA7, 0xBD, 0xD3, 0xE9, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x7B, 0x91, 0xA7, 0xBD, 0xD3, 0xE9, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x3D, 0x48, 0x53, 0x5E, 0x69, 0x74, 0x7F, 0x8A,
- 0x95, 0xA0, 0xAB, 0xB6, 0xC1, 0xCC, 0xD7, 0xE2,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x3D, 0x48, 0x53, 0x5E, 0x69, 0x74, 0x7F, 0x8A,
- 0x95, 0xA0, 0xAB, 0xB6, 0xC1, 0xCC, 0xD7, 0xE2,
- 0x7B, 0x91, 0xA7, 0xBD, 0xD3, 0xE4, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x7B, 0x91, 0xA7, 0xBD, 0xD3, 0xE4, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x33, 0x47, 0x61, 0x73, 0x87, 0x9C, 0xB0, 0xC7,
- 0xCC, 0xD4, 0xDB, 0xE3, 0xE8, 0xF0, 0xF7, 0xFF,
-};
-
-static const unsigned char defaultWPG2PaletteGreen[] = {
- 0x00, 0xFF, 0x7F, 0xBF, 0x00, 0x7F, 0x7F, 0x00,
- 0x00, 0x7F, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF,
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
- 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x3D, 0x48, 0x53, 0x5E, 0x69, 0x74, 0x7F, 0x8A,
- 0x95, 0xA0, 0xAB, 0xB6, 0xC1, 0xCC, 0xD7, 0xE2,
- 0x7B, 0x91, 0xA7, 0xBD, 0xD3, 0xE9, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x7B, 0x91, 0xA7, 0xBD, 0xD3, 0xE9, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x7B, 0x91, 0xA7, 0xBD, 0xD3, 0xE9, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x7B, 0x91, 0xA7, 0xBD, 0xD3, 0xE9, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x7B, 0x91, 0xA7, 0xBD, 0xD3, 0xE9, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x56, 0x64, 0x72, 0x80, 0x8E, 0x9C, 0xAA, 0xB1,
- 0xB8, 0xBF, 0xC6, 0xCD, 0xD4, 0xDB, 0xE2, 0xE9,
- 0x2B, 0x32, 0x39, 0x40, 0x47, 0x4E, 0x55, 0x63,
- 0x71, 0x7F, 0x8D, 0x9B, 0xA9, 0xB7, 0xC5, 0xD3,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x29, 0x38, 0x45, 0x4F, 0x5C, 0x63, 0x69, 0xD4,
- 0x87, 0x8F, 0x9C, 0xA8, 0xB3, 0xC4, 0xCF, 0xE0,
-};
-
-static const unsigned char defaultWPG2PaletteBlue[] = {
- 0x00, 0xFF, 0x7F, 0xBF, 0x7F, 0x00, 0x7F, 0x00,
- 0x7F, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
- 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
- 0x2C, 0x42, 0x58, 0x6E, 0x84, 0x9A, 0xB0, 0xC6,
- 0x3D, 0x48, 0x53, 0x5E, 0x69, 0x74, 0x7F, 0x8A,
- 0x95, 0xA0, 0xAB, 0xB6, 0xC1, 0xCC, 0xD7, 0xE2,
- 0x7B, 0x91, 0xA7, 0xBD, 0xD3, 0xE9, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x7B, 0x91, 0xA7, 0xB0, 0xD3, 0xE4, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x7B, 0x91, 0xA7, 0xBD, 0xD3, 0xE4, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x7B, 0x91, 0xA7, 0xBD, 0xD3, 0xE4, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x7B, 0x91, 0xA7, 0xBD, 0xD3, 0xE4, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x7B, 0x91, 0xA7, 0xBD, 0xD3, 0xE4, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x3D, 0x48, 0x53, 0x5E, 0x69, 0x74, 0x7F, 0x8A,
- 0x95, 0xA0, 0xAB, 0xB6, 0xC1, 0xCC, 0xD7, 0xE2,
- 0x11, 0x17, 0x1C, 0x24, 0x29, 0x2B, 0x2B, 0x30,
- 0x47, 0x57, 0x69, 0x78, 0x8C, 0x9C, 0xB0, 0xC7,
-};
-
-class WPG2Parser::ObjectCharacterization
-{
-public:
- bool taper;
- bool translate;
- bool skew;
- bool scale;
- bool rotate;
- bool hasObjectId;
- bool editLock;
- bool windingRule;
- bool filled;
- bool closed;
- bool framed;
-
- unsigned long objectId;
- unsigned long lockFlags;
- long rotationAngle;
- long sxcos;
- long sycos;
- long kxsin;
- long kysin;
- long txinteger;
- short txfraction;
- long tyinteger;
- short tyfraction;
- long px;
- long py;
-
- WPG2TransformMatrix matrix;
-
- ObjectCharacterization():
- taper(false),
- translate(false),
- skew(false),
- scale(false),
- rotate(false),
- hasObjectId(false),
- editLock(false),
- windingRule(false),
- filled(false),
- closed(false),
- framed(true),
- objectId(0),
- lockFlags(0),
- rotationAngle(0),
- sxcos(0),
- sycos(0),
- kxsin(0),
- kysin(0),
- txinteger(0),
- txfraction(0),
- tyinteger(0),
- tyfraction(0),
- px(0),
- py(0)
- {}
-};
-
-WPG2Parser::WPG2Parser(libwpg::WPGInputStream *input, libwpg::WPGPaintInterface* painter):
- WPGXParser(input, painter),
- m_success(true), m_exit(false),
- m_xres(1200), m_yres(1200),
- m_xofs(0), m_yofs(0),
- m_width(0), m_height(0),
- m_doublePrecision(false),
- m_layerOpened(false), m_layerId(0)
-{
-}
-
-bool WPG2Parser::parse()
-{
- typedef void (WPG2Parser::*Method)();
-
- struct RecordHandler
- {
- int type;
- const char *name;
- Method handler;
- };
-
- static const struct RecordHandler handlers[] =
- {
- { 0x01, "Start WPG", &WPG2Parser::handleStartWPG },
- { 0x02, "End WPG", &WPG2Parser::handleEndWPG },
- { 0x03, "Form Settings", 0 }, // ignored
- { 0x04, "Ruler Settings", 0 }, // ignored
- { 0x05, "Grid Settings", 0 }, // ignored
- { 0x06, "Layer", &WPG2Parser::handleLayer },
- { 0x08, "Pen Style Definition", &WPG2Parser::handlePenStyleDefinition },
- { 0x09, "Pattern Definition", 0 },
- { 0x0a, "Comment", 0 }, // ignored
- { 0x0b, "Color Transfer", 0 },
- { 0x0c, "Color Palette", &WPG2Parser::handleColorPalette },
- { 0x0d, "DP Color Palette", &WPG2Parser::handleDPColorPalette },
- { 0x0e, "Bitmap Data", 0 },
- { 0x0f, "Text Data", 0 },
- { 0x10, "Chart Style", 0 }, // ignored
- { 0x11, "Chart Data", 0 }, // ignored
- { 0x12, "Object Image", 0 },
- { 0x15, "Polyline", &WPG2Parser::handlePolyline },
- { 0x16, "Polyspline", 0 },
- { 0x17, "Polycurve", &WPG2Parser::handlePolycurve },
- { 0x18, "Rectangle", &WPG2Parser::handleRectangle },
- { 0x19, "Arc", &WPG2Parser::handleArc },
- { 0x1a, "Compound Polygon", &WPG2Parser::handleCompoundPolygon },
- { 0x1b, "Bitmap", 0 },
- { 0x1c, "Text Line", 0 },
- { 0x1d, "Text Block", 0 },
- { 0x1e, "Text Path", 0 },
- { 0x1f, "Chart", 0 },
- { 0x20, "Group", 0 },
- { 0x21, "Object Capsule", 0 },
- { 0x22, "Font Settings", 0 },
- { 0x25, "Pen Fore Color", &WPG2Parser::handlePenForeColor },
- { 0x26, "DP Pen Fore Color", &WPG2Parser::handleDPPenForeColor },
- { 0x27, "Pen Back Color", &WPG2Parser::handlePenBackColor },
- { 0x28, "DP Pen Back Color", &WPG2Parser::handleDPPenBackColor },
- { 0x29, "Pen Style", &WPG2Parser::handlePenStyle },
- { 0x2a, "Pen Pattern", 0 },
- { 0x2b, "Pen Size", &WPG2Parser::handlePenSize },
- { 0x2c, "DP Pen Size", &WPG2Parser::handleDPPenSize },
- { 0x2d, "Line Cap", 0 },
- { 0x2e, "Line Join", 0 },
- { 0x2f, "Brush Gradient", &WPG2Parser::handleBrushGradient },
- { 0x30, "DP Brush Gradient", &WPG2Parser::handleDPBrushGradient },
- { 0x31, "Brush Fore Color", &WPG2Parser::handleBrushForeColor },
- { 0x32, "DP Brush Fore Color", &WPG2Parser::handleDPBrushForeColor },
- { 0x33, "Brush Back Color", &WPG2Parser::handleBrushBackColor },
- { 0x34, "DP Brush Back Color", &WPG2Parser::handleDPBrushBackColor },
- { 0x35, "Brush Pattern", &WPG2Parser::handleBrushPattern },
- { 0x36, "Horizontal Line", 0 },
- { 0x37, "Vertical Line", 0 },
- { 0x38, "Poster Settings", 0 },
- { 0x39, "Image State", 0 },
- { 0x3a, "Envelope Definition", 0 },
- { 0x3b, "Envelope", 0 },
- { 0x3c, "Texture Definition", 0 },
- { 0x3d, "Brush Texture", 0 },
- { 0x3e, "Texture Alignment", 0 },
- { 0x3f, "Pen Texture ", 0 },
- { 0x00, 0, 0 } // end marker
- };
-
- // initialization
- m_success = true;
- m_exit = false;
- m_xres = m_yres = 1200;
- m_doublePrecision = false;
- m_layerOpened = false;
- m_matrix = WPG2TransformMatrix();
- m_groupStack = std::stack<WPGGroupContext>();
- m_compoundMatrix = WPG2TransformMatrix();
- m_compoundWindingRule = false;
- m_compoundFilled = false;
- m_compoundFramed = true;
- m_compoundClosed = false;
-
- // default style
- m_pen.foreColor = libwpg::WPGColor(0,0,0);
- m_pen.backColor = libwpg::WPGColor(0,0,0);
- m_pen.width = 0.001;
- m_pen.height = 0.001;
- m_pen.solid = true;
- m_pen.dashArray = libwpg::WPGDashArray();
- m_brush.foreColor = libwpg::WPGColor(0,0,0);
- m_brush.backColor = libwpg::WPGColor(0,0,0);
- resetPalette();
-
- while(!m_input->atEnd())
- {
-#ifdef DEBUG
- long recordPos = m_input->tell();
- int recordClass = readU8();
-#else
- readU8();
-#endif
- int recordType = readU8();
- int extension = readVariableLengthInteger();
- int length = readVariableLengthInteger();
- long nextPos = m_input->tell() + length;
-#if !defined(DEBUG)
- //(void)recordPos;
- //(void)recordClass;
-#endif // !defined(DEBUG)
-
- // inside a subgroup, one less sub record
- if(!m_groupStack.empty())
- m_groupStack.top().subIndex--;
-
- // search function to handler this record
- int index = -1;
- for(int i = 0; (index < 0) && handlers[i].name; i++)
- if(handlers[i].type == recordType)
- index = i;
-
- WPG_DEBUG_MSG(("\n"));
- if(index < 0)
- {
- WPG_DEBUG_MSG(("Unknown record type 0x%02x at %d size %d extension %d\n",
- recordType, recordPos, length, extension));
- }
- else
- {
- Method recordHandler = handlers[index].handler;
-
- if(!recordHandler)
- WPG_DEBUG_MSG(("Record '%s' (ignored) type 0x%02x at %d size %d extension %d\n",
- handlers[index].name, recordType, recordPos, length, extension));
- else
- {
- WPG_DEBUG_MSG(("Record '%s' type 0x%02x at %d size %d extension %d\n",
- handlers[index].name, recordType, recordPos, length, extension));
-
- // invoke the handler for this record
- (this->*recordHandler)();
- }
- }
-
- // the last subgroup
- if(!m_groupStack.empty())
- {
- WPGGroupContext& context = m_groupStack.top();
- if(context.subIndex == 0)
- {
- if(context.isCompoundPolygon())
- flushCompoundPolygon();
- m_groupStack.pop();
- }
- }
-
- // we enter another subgroup, save the context to stack
- if(extension > 0)
- {
- WPGGroupContext context;
- context.parentType = recordType;
- context.subIndex = extension;
- if(context.isCompoundPolygon())
- {
- context.compoundMatrix = m_compoundMatrix;
- context.compoundFilled = m_compoundFilled;
- context.compoundFramed = m_compoundFramed;
- context.compoundClosed = m_compoundClosed;
- }
- m_groupStack.push(context);
- }
-
- //if(m_input->tell() > nextPos)
- {
- //WPG_DEBUG_MSG(("Record 0x%x consumes more bytes than necessary!\n", recordType));
- WPG_DEBUG_MSG(("Current stream position: %d\n", m_input->tell()));
- }
-
- if(m_exit) break;
-
- m_input->seek(nextPos);
- }
-
- return m_success;
-}
-
-#ifdef DEBUG
-static const char* describePrecision(unsigned char precision)
-{
- const char* result = "Unknown";
- switch(precision)
- {
- case 0: result = "single"; break;
- case 1: result = "double"; break;
- default: break;
- }
- return result;
-}
-
-static const char* describeGradient(unsigned char gradientType)
-{
- const char* result = "Unknown";
- switch(gradientType)
- {
- case 0: result = "None"; break;
- case 1: result = "Linear"; break;
- case 2: result = "Polygonal"; break;
- case 3: result = "Concentric Circles"; break;
- case 4: result = "Convergent Circles"; break;
- case 5: result = "Concentric Ellipses"; break;
- case 6: result = "Convergent Ellipses"; break;
- case 7: result = "Concentric Squares"; break;
- case 8: result = "Convergent Squares"; break;
- case 9: result = "Concentric Rectangles"; break;
- case 10: result = "Convergent Rectangles"; break;
- default: break;
- }
- return result;
-}
-#endif
-
-#define TO_DOUBLE(x) ( (m_doublePrecision) ? ((double)(x)/65536.0) : (double)(x) )
-#define TRANSFORM_XY(x,y) { m_matrix.transform((x),(y)); (x)-= m_xofs; (y)-= m_yofs; (y)=m_height-(y); }
-
-void WPG2Parser::handleStartWPG()
-{
- unsigned int horizontalUnit = readU16();
- unsigned int verticalUnit = readU16();
- unsigned char precision = readU8();
-
- // sanity check
- m_xres = horizontalUnit;
- m_yres = verticalUnit;
- if((horizontalUnit==0) || (verticalUnit==0))
- {
- m_xres = m_yres = 1200;
- WPG_DEBUG_MSG(("Warning ! Insane unit of measure"));
- }
-
- // danger if we do not recognize the precision code
- if(precision != 0)
- if(precision != 1)
- {
- m_success = false;
- m_exit = true;
- return;
- }
- m_doublePrecision = (precision == 1);
-
-#ifdef DEBUG
- long viewportX1 = (m_doublePrecision) ? readS32() : readS16();
- long viewportY1 = (m_doublePrecision) ? readS32() : readS16();
- long viewportX2 = (m_doublePrecision) ? readS32() : readS16();
- long viewportY2 = (m_doublePrecision) ? readS32() : readS16();
-#else
- m_input->seek(m_input->tell() + ((m_doublePrecision) ? 16 : 8));
-#endif
- long imageX1 = (m_doublePrecision) ? readS32() : readS16();
- long imageY1 = (m_doublePrecision) ? readS32() : readS16();
- long imageX2 = (m_doublePrecision) ? readS32() : readS16();
- long imageY2 = (m_doublePrecision) ? readS32() : readS16();
-
- // used to adjust coordinates
- m_xofs = (imageX1 < imageX2) ? imageX1 : imageX2;
- m_yofs = (imageY1 < imageY2) ? imageY1 : imageX2;
- m_width = (imageX2 > imageX1 ) ? imageX2-imageX1 : imageX1-imageX2;
- m_height = (imageY2 > imageY1) ? imageY2-imageY1 : imageY1-imageY2;
-
- WPG_DEBUG_MSG(("StartWPG\n"));
- WPG_DEBUG_MSG((" Horizontal unit of measure : %d pixels/inch\n", horizontalUnit));
- WPG_DEBUG_MSG((" Vertical unit of measure : %d pixels/inch\n", verticalUnit));
- WPG_DEBUG_MSG((" Data precision : %d (%s)\n", precision, describePrecision(precision)));
- WPG_DEBUG_MSG((" Viewport X1 : %d\n", viewportX1));
- WPG_DEBUG_MSG((" Viewport Y1 : %d\n", viewportY1));
- WPG_DEBUG_MSG((" Viewport X2 : %d\n", viewportX2));
- WPG_DEBUG_MSG((" Viewport Y2 : %d\n", viewportY2));
- WPG_DEBUG_MSG((" Image X1 : %d\n", imageX1));
- WPG_DEBUG_MSG((" Image Y1 : %d\n", imageY1));
- WPG_DEBUG_MSG((" Image X2 : %d\n", imageX2));
- WPG_DEBUG_MSG((" Image Y2 : %d\n", imageY2));
- WPG_DEBUG_MSG((" X offset : %d\n", m_xofs));
- WPG_DEBUG_MSG((" Y offset : %d\n", m_yofs));
- WPG_DEBUG_MSG((" width : %d\n", m_width));
- WPG_DEBUG_MSG((" height : %d\n", m_height));
-
- double width = (TO_DOUBLE(m_width)) / m_xres;
- double height = (TO_DOUBLE(m_height)) / m_yres;
-
- m_painter->startDocument(width, height);
-
- static const int WPG2_defaultPenDashes[] = {
- 1, 291, 0, // style #0 (actually solid)
- 1, 218, 73, // style #1
- 1, 145, 73, // style #2
- 1, 73, 73, // style #3
- 1, 36, 36, // style #4
- 1, 18, 18, // style #5
- 1, 18, 55, // style #6
- 3, 18, 55, 18, 55, 18, 127, // style #7
- 2, 164, 55, 18, 55, // style #8
- 3, 145, 36, 138, 36, 18, 36, // style #9
- 3, 91, 55, 91, 55, 18, 55, // style #10
- 4, 91, 36, 91, 36, 18, 36, 18, 36, // style #11
- 2, 182, 73, 73, 73, // style #12
- 3, 182, 36, 55, 36, 55, 36, // style #13
- 3, 255, 73, 255, 73, 73, 73, // style #14
- 4, 273, 36, 273, 36, 55, 36, 55, 36, // style #15
- 0 // end marker
- };
-
- // create default pen styles
- int styleNo = 0;
- for(int i = 0; (long)i < (long)(sizeof(WPG2_defaultPenDashes)/sizeof(WPG2_defaultPenDashes[0]));)
- {
- int segments = 2 * WPG2_defaultPenDashes[i++];
- if(segments == 0) break;
- libwpg::WPGDashArray dashArray;
- for(int j = 0; j < segments; j++, i++)
- dashArray.add(WPG2_defaultPenDashes[i]*3.6/218.0);
- m_penStyles[styleNo] = dashArray;
- styleNo++;
- }
-}
-
-void WPG2Parser::handleEndWPG()
-{
- // sentinel
- if(m_layerOpened)
- m_painter->endLayer(m_layerId);
-
- m_painter->endDocument();
- m_exit = true;
-}
-
-void WPG2Parser::handleLayer()
-{
- m_layerId = readU16();
-
- // close previous one
- if(m_layerOpened)
- m_painter->endLayer(m_layerId);
-
- m_painter->startLayer(m_layerId);
- m_layerOpened = true;
-
- WPG_DEBUG_MSG((" Layer Id: %d\n", m_layerId));
-}
-
-void WPG2Parser::handleCompoundPolygon()
-{
- ObjectCharacterization objCh;
- parseCharacterization(&objCh);
-
- m_compoundWindingRule = objCh.windingRule;
- m_compoundMatrix = objCh.matrix;
- m_compoundFilled = objCh.filled;
- m_compoundFramed = objCh.framed;
- m_compoundClosed = objCh.closed;
-}
-void WPG2Parser::flushCompoundPolygon()
-{
- WPGGroupContext& context = m_groupStack.top();
-
- m_painter->setBrush( context.compoundFilled ? m_brush : libwpg::WPGBrush() );
- m_painter->setPen( context.compoundFramed ? m_pen : libwpg::WPGPen() );
- if(context.compoundWindingRule)
- m_painter->setFillRule(libwpg::WPGPaintInterface::WindingFill);
- else
- m_painter->setFillRule(libwpg::WPGPaintInterface::AlternatingFill);
- context.compoundPath.closed = context.compoundClosed;
- m_painter->drawPath(context.compoundPath);
-}
-
-void WPG2Parser::handlePenStyleDefinition()
-{
- unsigned int style = readU16();
- unsigned int segments = readU16();
-
- libwpg::WPGDashArray dashArray;
- for(unsigned i = 0; i < segments; i++)
- {
- unsigned int p = (m_doublePrecision) ? readU32() : readU16();
- unsigned int q = (m_doublePrecision) ? readU32() : readU16();
- dashArray.add(TO_DOUBLE(p)*3.6/218.0);
- dashArray.add(TO_DOUBLE(q)*3.6/218.0);
- }
- m_penStyles[style] = dashArray;
-
- WPG_DEBUG_MSG((" Style : %d\n", style));
- WPG_DEBUG_MSG((" Segment pairs : %d\n", segments));
-}
-
-// TODO
-void WPG2Parser::handlePatternDefinition()
-{
- WPG_DEBUG_MSG(("PatternDefinition\n"));
-}
-
-void WPG2Parser::handleColorPalette()
-{
- unsigned startIndex = readU16();
- unsigned numEntries = readU16();
-
- for(unsigned i = 0; i < numEntries; i++)
- {
- libwpg::WPGColor color;
- color.red = readU8();
- color.green = readU8();
- color.blue = readU8();
- color.alpha = readU8();
- m_colorPalette[startIndex+i] = color;
- WPG_DEBUG_MSG(("Index#%d: RGB %d %d %d\n", startIndex+i, color.red, color.green, color.blue));
- }
-}
-
-void WPG2Parser::handleDPColorPalette()
-{
- unsigned startIndex = readU16();
- unsigned numEntries = readU16();
-
- for(unsigned int i = 0; i < numEntries; i++)
- {
- libwpg::WPGColor color;
- color.red = readU16() >> 8 ;
- color.green = readU16() >> 8 ;
- color.blue = readU16() >> 8 ;
- color.alpha = readU16() >> 8 ;
- m_colorPalette[startIndex+i] = color;
- WPG_DEBUG_MSG(("Index#%d: RGB %d %d %d\n", startIndex+i, color.red, color.green, color.blue));
- }
-}
-
-void WPG2Parser::handlePenForeColor()
-{
- if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
- return;
- unsigned char red = readU8();
- unsigned char green = readU8();
- unsigned char blue = readU8();
- unsigned char alpha = readU8();
-
- m_pen.foreColor = libwpg::WPGColor(red, green, blue, alpha);
-
- WPG_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
-}
-
-void WPG2Parser::handleDPPenForeColor()
-{
- if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
- return;
- // we just ignore the least significant 8 bits
- unsigned int red = (m_doublePrecision) ? readU16()>>8 : readU8();
- unsigned int green = (m_doublePrecision) ? readU16()>>8 : readU8();
- unsigned int blue = (m_doublePrecision) ? readU16()>>8 : readU8();
- unsigned int alpha = (m_doublePrecision) ? readU16()>>8 : readU8();
-
- m_pen.foreColor = libwpg::WPGColor(red, green, blue, alpha);
-
- WPG_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
-}
-
-void WPG2Parser::handlePenBackColor()
-{
- if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
- return;
- unsigned char red = readU8();
- unsigned char green = readU8();
- unsigned char blue = readU8();
- unsigned char alpha = readU8();
-
- m_pen.backColor = libwpg::WPGColor(red, green, blue, alpha);
-
- WPG_DEBUG_MSG((" Background color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
-}
-
-void WPG2Parser::handleDPPenBackColor()
-{
- if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
- return;
- // we just ignore the least significant 8 bits
- unsigned int red = (m_doublePrecision) ? readU16()>>8 : readU8();
- unsigned int green = (m_doublePrecision) ? readU16()>>8 : readU8();
- unsigned int blue = (m_doublePrecision) ? readU16()>>8 : readU8();
- unsigned int alpha = (m_doublePrecision) ? readU16()>>8 : readU8();
-
- m_pen.backColor = libwpg::WPGColor(red, green, blue, alpha);
-
- WPG_DEBUG_MSG((" Background color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
-}
-
-void WPG2Parser::handlePenStyle()
-{
- if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
- return;
- unsigned int style = readU16();
-
- m_pen.dashArray = m_penStyles[style];
- m_pen.solid = (style == 0);
-
- WPG_DEBUG_MSG((" Pen style : %d\n", style));
- WPG_DEBUG_MSG((" Segments : %d\n", m_pen.dashArray.count()));
-}
-
-void WPG2Parser::handlePenSize()
-{
- if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
- return;
- unsigned int width = readU16();
- unsigned int height = readU16();
-
- m_pen.width = TO_DOUBLE(width) / m_xres;
- m_pen.height = TO_DOUBLE(height) / m_yres;
-
- WPG_DEBUG_MSG((" Width: %d\n", width));
- WPG_DEBUG_MSG((" Height: %d\n", height));
-}
-
-void WPG2Parser::handleDPPenSize()
-{
- if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
- return;
- unsigned long width = readU32();
- unsigned long height = readU32();
-
- m_pen.width = TO_DOUBLE(width) / m_xres / 256;
- m_pen.height = TO_DOUBLE(height) / m_yres / 256;
-
- WPG_DEBUG_MSG((" Width: %d\n", width));
- WPG_DEBUG_MSG((" Height: %d\n", height));
-}
-
-void WPG2Parser::handleBrushGradient()
-{
- if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
- return;
- unsigned angleFraction = readU16();
- unsigned angleInteger = readU16();
- unsigned xref = readU16();
- unsigned yref = readU16();
-#ifdef DEBUG
- unsigned flag = readU16();
- bool granular = ((flag & (1<<6))>>6) == 1;
- bool anchor = ((flag & (1<<7))>>7) == 1;
-#else
- readU16();
-#endif
-#if !defined(DEBUG)
- //(void)granular;
- //(void)anchor;
-#endif // !defined(DEBUG)
-
- // TODO: get gradient extent
-
- m_gradientAngle = angleInteger + (double)angleFraction/65536.0;
- m_gradientRef.x = xref;
- m_gradientRef.y = yref;
-
- WPG_DEBUG_MSG((" Gradient angle : %d.%d\n", angleInteger, angleFraction));
- WPG_DEBUG_MSG((" Gradient reference : %d.%d\n", xref, yref));
- WPG_DEBUG_MSG((" Granular : %s\n", (granular ? "yes" : "no")));
- WPG_DEBUG_MSG((" Anchored : %s\n", (anchor ? "yes" : "no")));
-}
-
-void WPG2Parser::handleDPBrushGradient()
-{
- if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
- return;
- unsigned angleFraction = readU16();
- unsigned angleInteger = readU16();
- unsigned xref = readU16();
- unsigned yref = readU16();
-#ifdef DEBUG
- unsigned flag = readU16();
- bool granular = (flag & (1<<6)) == 1;
- bool anchor = (flag & (1<<7)) == 1;
-#else
- readU16();
-#endif
-
- // TODO: get gradient extent (in double precision)
-
- m_gradientAngle = angleFraction + (double)angleInteger/65536.0;
- m_gradientRef.x = xref;
- m_gradientRef.y = yref;
-
- WPG_DEBUG_MSG((" Gradient angle : %d.%d\n", angleInteger, angleFraction));
- WPG_DEBUG_MSG((" Gradient reference : %d.%d\n", xref, yref));
- WPG_DEBUG_MSG((" Granular : %s\n", (granular ? "yes" : "no")));
- WPG_DEBUG_MSG((" Anchored : %s\n", (anchor ? "yes" : "no")));
-}
-
-void WPG2Parser::handleBrushForeColor()
-{
- if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
- return;
- unsigned char gradientType = readU8();
- WPG_DEBUG_MSG((" Gradient type : %d (%s)\n", gradientType, describeGradient(gradientType)));
-
- if(gradientType == 0)
- {
- unsigned char red = readU8();
- unsigned char green = readU8();
- unsigned char blue = readU8();
- unsigned char alpha = readU8();
- WPG_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
-
- m_brush.foreColor = libwpg::WPGColor(red, green, blue, alpha);
- if(m_brush.style != libwpg::WPGBrush::Gradient)
- m_brush.style = libwpg::WPGBrush::Solid;
- }
- else
- {
- unsigned count = readU16();
- std::vector<libwpg::WPGColor> colors;
- std::vector<double> positions;
- WPG_DEBUG_MSG((" Gradient colors : %d\n", count));
-
- for(unsigned i = 0; i < count; i++)
- {
- unsigned char red = readU8();
- unsigned char green = readU8();
- unsigned char blue = readU8();
- unsigned char alpha = readU8();
- libwpg::WPGColor color(red, green, blue, alpha);
- colors.push_back(color);
- WPG_DEBUG_MSG((" Color #%d (RGBA): %d %d %d %d\n", i+1, red, green, blue, alpha));
- }
-
- for(unsigned j = 0; j < count-1; j++)
- {
- unsigned pos = readU16();
- positions.push_back(TO_DOUBLE(pos));
- WPG_DEBUG_MSG((" Position #%d : %d\n", j+1, pos));
- }
-
- // looks like Corel Presentations only create 2 colors gradient
- // and they are actually in reverse order
- if(count == 2)
- {
- double xref = (double)m_gradientRef.x/65536.0;
- double yref = (double)m_gradientRef.y/65536.0;
- double angle = m_gradientAngle*M_PI/180.0;
- double tanangle = tan(angle);
- double ref = (tanangle < 1e2 && tanangle > -1e2) ? (yref+xref*tanangle)/(1+tanangle) : xref;
- libwpg::WPGGradient gradient;
- gradient.setAngle(-m_gradientAngle); // upside down
- gradient.addStop(0, colors[1]);
- gradient.addStop(ref, colors[0]);
- if((m_gradientRef.x != 65535) && (m_gradientRef.y != 65535))
- gradient.addStop(1, colors[1]);
- m_brush.gradient = gradient;
- m_brush.style = libwpg::WPGBrush::Gradient;
- }
- }
-}
-
-void WPG2Parser::handleDPBrushForeColor()
-{
- if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
- return;
- unsigned char gradientType = readU8();
- WPG_DEBUG_MSG((" Gradient type : %d (%s)\n", gradientType, describeGradient(gradientType)));
-
- if(gradientType == 0)
- {
- unsigned char red = (m_doublePrecision) ? readU16()>>8 : readU8();
- unsigned char green = (m_doublePrecision) ? readU16()>>8 : readU8();
- unsigned char blue = (m_doublePrecision) ? readU16()>>8 : readU8();
- unsigned char alpha = (m_doublePrecision) ? readU16()>>8 : readU8();
- WPG_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
-
- m_brush.foreColor = libwpg::WPGColor(red, green, blue, alpha);
- if(m_brush.style != libwpg::WPGBrush::NoBrush)
- m_brush.style = libwpg::WPGBrush::Solid;
- }
- else
- {
- unsigned count = readU16();
- std::vector<libwpg::WPGColor> colors;
- std::vector<double> positions;
- WPG_DEBUG_MSG((" Gradient colors : %d\n", count));
-
- for(unsigned i = 0; i < count; i++)
- {
- unsigned char red = (m_doublePrecision) ? readU16()>>8 : readU8();
- unsigned char green = (m_doublePrecision) ? readU16()>>8 : readU8();
- unsigned char blue = (m_doublePrecision) ? readU16()>>8 : readU8();
- unsigned char alpha = (m_doublePrecision) ? readU16()>>8 : readU8();
- libwpg::WPGColor color(red, green, blue, alpha);
- colors.push_back(color);
- WPG_DEBUG_MSG((" Color #%d (RGBA): %d %d %d %d\n", i+1, red, green, blue, alpha));
- }
-
- for(unsigned j = 0; j < count-1; j++)
- {
- unsigned pos = readU16();
- positions.push_back(TO_DOUBLE(pos));
- WPG_DEBUG_MSG((" Position #%d : %d\n", j+1, pos));
- }
-
- // looks like Corel Presentations only create 2 colors gradient
- // and they are actually in reverse order
- if(count == 2)
- {
- double xref = (double)m_gradientRef.x/65536.0;
- double yref = (double)m_gradientRef.y/65536.0;
- double angle = m_gradientAngle*M_PI/180.0;
- double tanangle = tan(angle);
- double ref = (tanangle<1e2) ? (yref+xref*tanangle)/(1+tanangle) : xref;
- libwpg::WPGGradient gradient;
- gradient.setAngle(-m_gradientAngle); // upside down
- gradient.addStop(0, colors[1]);
- gradient.addStop(ref, colors[0]);
- if((m_gradientRef.x != 65535) && (m_gradientRef.y != 65536))
- gradient.addStop(1, colors[1]);
- m_brush.gradient = gradient;
- m_brush.style = libwpg::WPGBrush::Gradient;
- }
- }
-}
-
-void WPG2Parser::handleBrushBackColor()
-{
- if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
- return;
- unsigned char red = readU8();
- unsigned char green = readU8();
- unsigned char blue = readU8();
- unsigned char alpha = readU8();
-
- m_brush.backColor = libwpg::WPGColor(red, green, blue, alpha);
- if(m_brush.style == libwpg::WPGBrush::NoBrush)
- m_brush.style = libwpg::WPGBrush::Solid;
-
- WPG_DEBUG_MSG((" Backround color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
-}
-
-void WPG2Parser::handleDPBrushBackColor()
-{
- if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
- return;
- // we just ignore the least significant 8 bits
- unsigned int red = (m_doublePrecision) ? readU16()>>8 : readU8();
- unsigned int green = (m_doublePrecision) ? readU16()>>8 : readU8();
- unsigned int blue = (m_doublePrecision) ? readU16()>>8 : readU8();
- unsigned int alpha = (m_doublePrecision) ? readU16()>>8 : readU8();
-
- m_brush.backColor = libwpg::WPGColor(red, green, blue, alpha);
- if(m_brush.style == libwpg::WPGBrush::NoBrush)
- m_brush.style = libwpg::WPGBrush::Solid;
-
- WPG_DEBUG_MSG((" Background color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
-}
-
-void WPG2Parser::handleBrushPattern()
-{
- if (!m_groupStack.empty() && m_groupStack.top().isCompoundPolygon())
- return;
-#ifdef DEBUG
- unsigned int pattern = readU16();
-#endif
-
- // TODO
-
- WPG_DEBUG_MSG((" Pattern : %d\n", pattern));
-}
-
-void WPG2Parser::parseCharacterization(ObjectCharacterization* ch)
-{
- // sanity check
- if(!ch) return;
-
- // identity
- ch->matrix = WPG2TransformMatrix();
-
- unsigned int flags = readU16();
- ch->taper = (flags & 0x01) != 0;
- ch->translate = (flags & 0x02) != 0;
- ch->skew = (flags & 0x04) != 0;
- ch->scale = (flags & 0x08) != 0;
- ch->rotate = (flags & 0x10) != 0;
- ch->hasObjectId = (flags & 0x20) != 0;
- ch->editLock = (flags & 0x80) != 0;
- ch->windingRule = (flags & (1<<12)) != 0;
- ch->filled = (flags & (1<<13)) != 0;
- ch->closed = (flags & (1<<14)) != 0;
- ch->framed = (flags & (1<<15)) != 0;
-
- if(ch->editLock) ch->lockFlags = readU32();
-
- // object ID can be 2 or 4 bytes
- if(ch->hasObjectId) ch->objectId = readU16();
- if(ch->objectId >> 15) ch->objectId = ((ch->objectId & 0x7fff) << 16) | readU16();
-
- if(ch->rotate) ch->rotationAngle = readS32();
-
- if(ch->rotate || ch->scale)
- {
- ch->sxcos = readS32();
- ch->sycos = readS32();
- ch->matrix.element[0][0] = (double)(ch->sxcos)/65536;
- ch->matrix.element[1][1] = (double)(ch->sxcos)/65536;
- }
-
- if(ch->rotate || ch->skew)
- {
- ch->kxsin = readS32();
- ch->kysin = readS32();
- ch->matrix.element[1][0] = (double)(ch->kxsin)/65536;
- ch->matrix.element[0][1] = (double)(ch->kysin)/65536;
- }
-
- if(ch->translate)
- {
- ch->txfraction = readU16();
- ch->txinteger = readS32();
- ch->tyfraction = readU16();
- ch->tyinteger = readS32();
- ch->matrix.element[2][0] = (double)(ch->txinteger);
- ch->matrix.element[2][1] = (double)(ch->tyinteger);
- }
-
- if(ch->taper)
- {
- ch->px = readS32();
- ch->py = readS32();
- ch->matrix.element[0][2] = (double)(ch->px);
- ch->matrix.element[1][2] = (double)(ch->py);
- }
-
- WPG_DEBUG_MSG(("ObjectCharacterization\n"));
- WPG_DEBUG_MSG((" taper : %s\n", (ch->taper ? "yes" : "no")));
- WPG_DEBUG_MSG((" translate : %s\n", (ch->translate ? "yes" : "no")));
- WPG_DEBUG_MSG((" skew : %s\n", (ch->skew ? "yes" : "no")));
- WPG_DEBUG_MSG((" scale : %s\n", (ch->scale ? "yes" : "no")));
- WPG_DEBUG_MSG((" rotate : %s\n", (ch->rotate ? "yes" : "no")));
- WPG_DEBUG_MSG((" hasObjectId : %s\n", (ch->hasObjectId ? "yes" : "no")));
- WPG_DEBUG_MSG((" editLock : %s\n", (ch->editLock ? "yes" : "no")));
- if(ch->editLock) WPG_DEBUG_MSG((" lock flags : 0x%x\n", ch->lockFlags));
- if(ch->hasObjectId) WPG_DEBUG_MSG((" object ID : 0x%x\n", ch->objectId));
- if(ch->translate) WPG_DEBUG_MSG((" tx : %d %d\n", ch->txinteger, ch->txfraction));
- if(ch->translate) WPG_DEBUG_MSG((" ty : %d %d\n", ch->tyinteger, ch->tyfraction));
- WPG_DEBUG_MSG(("transform matrix:\n"));
- WPG_DEBUG_MSG(("%f %f %f\n", ch->matrix.element[0][0], ch->matrix.element[0][1],ch->matrix.element[0][2]));
- WPG_DEBUG_MSG(("%f %f %f\n", ch->matrix.element[1][0], ch->matrix.element[1][1],ch->matrix.element[1][2]));
- WPG_DEBUG_MSG(("%f %f %f\n", ch->matrix.element[2][0], ch->matrix.element[2][1],ch->matrix.element[2][2]));
-}
-
-void WPG2Parser::handlePolyline()
-{
- ObjectCharacterization objCh;
- parseCharacterization(&objCh);
- m_matrix = objCh.matrix;
-
- bool insideCompound = m_groupStack.empty() ? false :
- m_groupStack.top().isCompoundPolygon();
-
- // inside a compound, so take the parent transformation into account
- if(insideCompound)
- m_matrix.transformBy(m_groupStack.top().compoundMatrix);
-
- unsigned long count = readU16();
-
- libwpg::WPGPointArray points;
- for(unsigned long i = 0; i < count; i++ )
- {
- long x = (m_doublePrecision) ? readS32() : readS16();
- long y = (m_doublePrecision) ? readS32() : readS16();
- TRANSFORM_XY(x,y);
- libwpg::WPGPoint p(TO_DOUBLE(x)/m_xres, TO_DOUBLE(y)/m_yres);
- points.add(p);
- }
-
- if(insideCompound)
- {
- if(count > 0)
- {
- // inside a compound ? convert it into path because for compound
- // we will only use paths
- libwpg::WPGPath& path = m_groupStack.top().compoundPath;
- path.moveTo(points[0]);
- for(unsigned long ii = 1; ii < count; ii++)
- path.lineTo(points[ii]);
- }
- }
- else
- {
- // otherwise draw directly
- m_painter->setBrush( objCh.filled ? m_brush : libwpg::WPGBrush() );
- m_painter->setPen( objCh.framed ? m_pen : libwpg::WPGPen() );
- if(objCh.windingRule)
- m_painter->setFillRule(libwpg::WPGPaintInterface::WindingFill);
- else
- m_painter->setFillRule(libwpg::WPGPaintInterface::AlternatingFill);
- m_painter->drawPolygon(points);
- }
-
- WPG_DEBUG_MSG((" Vertices count : %d\n", count));
- for(unsigned int j = 0; j < count; j++ )
- WPG_DEBUG_MSG((" Point #%d : %g,%g\n", j+1, points[j].x, points[j].y));
-}
-
-void WPG2Parser::handlePolycurve()
-{
- ObjectCharacterization objCh;
- parseCharacterization(&objCh);
- m_matrix = objCh.matrix;
-
- bool insideCompound = m_groupStack.empty() ? false :
- m_groupStack.top().isCompoundPolygon();
-
- // inside a compound, so take the parent transformation into account
- if(insideCompound)
- m_matrix.transformBy(m_groupStack.top().compoundMatrix);
-
- unsigned int count = readU16();
-
- libwpg::WPGPointArray vertices;
- libwpg::WPGPointArray controlPoints;
- for(unsigned int i = 0; i < count; i++ )
- {
- long ix = (m_doublePrecision) ? readS32() : readS16();
- long iy = (m_doublePrecision) ? readS32() : readS16();
- TRANSFORM_XY(ix,iy);
- libwpg::WPGPoint initialPoint( TO_DOUBLE(ix)/m_xres, TO_DOUBLE(iy)/m_yres );
-
- long ax = (m_doublePrecision) ? readS32() : readS16();
- long ay = (m_doublePrecision) ? readS32() : readS16();
- TRANSFORM_XY(ax,ay);
- libwpg::WPGPoint anchorPoint( TO_DOUBLE(ax)/m_xres, TO_DOUBLE(ay)/m_yres );
-
- long tx = (m_doublePrecision) ? readS32() : readS16();
- long ty = (m_doublePrecision) ? readS32() : readS16();
- TRANSFORM_XY(tx,ty);
- libwpg::WPGPoint terminalPoint( TO_DOUBLE(tx)/m_xres, TO_DOUBLE(ty)/m_yres );
-
- vertices.add(anchorPoint);
- if(i > 0)
- controlPoints.add(initialPoint);
- controlPoints.add(terminalPoint);
- }
-
- libwpg::WPGPath path;
- path.closed = objCh.closed;
- path.moveTo(vertices[0]);
- for(unsigned j = 1; j < vertices.count(); j++)
- path.curveTo(controlPoints[j*2-2], controlPoints[j*2-1], vertices[j]);
-
- if(insideCompound)
- // inside a compound ? just collect the path together
- m_groupStack.top().compoundPath.append(path);
- else
- {
- // otherwise draw directly
- m_painter->setBrush( objCh.filled ? m_brush : libwpg::WPGBrush() );
- m_painter->setPen( objCh.framed ? m_pen : libwpg::WPGPen() );
- if(objCh.windingRule)
- m_painter->setFillRule(libwpg::WPGPaintInterface::WindingFill);
- else
- m_painter->setFillRule(libwpg::WPGPaintInterface::AlternatingFill);
- m_painter->drawPath(path);
- }
-}
-
-void WPG2Parser::handleRectangle()
-{
- ObjectCharacterization objCh;
- parseCharacterization(&objCh);
- m_matrix = objCh.matrix;
-
- long x1 = (m_doublePrecision) ? readS32() : readS16();
- long y1 = (m_doublePrecision) ? readS32() : readS16();
- TRANSFORM_XY(x1,y1);
-
- long x2 = (m_doublePrecision) ? readS32() : readS16();
- long y2 = (m_doublePrecision) ? readS32() : readS16();
- TRANSFORM_XY(x2,y2);
-
- long xs1 = (x1 <= x2) ? x1 : x2;
- long xs2 = (x1 <= x2) ? x2 : x1;
- long ys1 = (y1 <= y2) ? y1 : y2;
- long ys2 = (y1 <= y2) ? y2 : y1;
-
- long rx = (m_doublePrecision) ? readS32() : readS16();
- long ry = (m_doublePrecision) ? readS32() : readS16();
-
- libwpg::WPGRect rect;
- rect.x1 = TO_DOUBLE(xs1) / m_xres;
- rect.x2 = TO_DOUBLE(xs2) / m_xres;
- rect.y1 = TO_DOUBLE(ys1) / m_yres;
- rect.y2 = TO_DOUBLE(ys2) / m_yres;
- double roundx = TO_DOUBLE(rx)/m_xres;
- double roundy = TO_DOUBLE(ry)/m_yres;
-
- m_painter->setBrush( objCh.filled ? m_brush : libwpg::WPGBrush() );
- m_painter->setPen( objCh.framed ? m_pen : libwpg::WPGPen() );
- m_painter->drawRectangle(rect, roundx, roundy);
-
- WPG_DEBUG_MSG((" X1 : %d\n", x1));
- WPG_DEBUG_MSG((" Y1 : %d\n", y1));
- WPG_DEBUG_MSG((" X2 : %d\n", x2));
- WPG_DEBUG_MSG((" Y2 : %d\n", y2));
- WPG_DEBUG_MSG((" Round X : %d\n", rx));
- WPG_DEBUG_MSG((" Round Y : %d\n", ry));
-}
-
-void WPG2Parser::handleArc()
-{
- ObjectCharacterization objCh;
- parseCharacterization(&objCh);
- m_matrix = objCh.matrix;
-
- long cx = (m_doublePrecision) ? readS32() : readS16();
- long cy = (m_doublePrecision) ? readS32() : readS16();
- TRANSFORM_XY(cx,cy);
-
- long radx = (m_doublePrecision) ? readS32() : readS16();
- long rady = (m_doublePrecision) ? readS32() : readS16();
-
- long ix = (m_doublePrecision) ? readS32() : readS16();
- long iy = (m_doublePrecision) ? readS32() : readS16();
- TRANSFORM_XY(ix,iy);
-
- long ex = (m_doublePrecision) ? readS32() : readS16();
- long ey = (m_doublePrecision) ? readS32() : readS16();
- TRANSFORM_XY(ex,ey);
-
- if((ix==ex) && (iy==ey))
- {
- libwpg::WPGPoint center;
- center.x = TO_DOUBLE(cx) / m_xres;
- center.y = TO_DOUBLE(cy) / m_xres;
- double rx = TO_DOUBLE(radx) / m_xres;
- double ry = TO_DOUBLE(rady) / m_xres;
-
- m_painter->setBrush( objCh.filled ? m_brush : libwpg::WPGBrush() );
- m_painter->setPen( objCh.framed ? m_pen : libwpg::WPGPen() );
- m_painter->drawEllipse(center, rx, ry);
- }
-
- WPG_DEBUG_MSG((" Center point x : %d\n", cx));
- WPG_DEBUG_MSG((" Center point y : %d\n", cy));
- WPG_DEBUG_MSG((" Radius x : %d\n", radx));
- WPG_DEBUG_MSG((" Radius y : %d\n", rady));
- WPG_DEBUG_MSG((" Initial point x : %d\n", ix));
- WPG_DEBUG_MSG((" Initial point y : %d\n", iy));
- WPG_DEBUG_MSG((" End point x : %d\n", ex));
- WPG_DEBUG_MSG((" End point y : %d\n", ey));
-}
-
-
-void WPG2Parser::resetPalette()
-{
- m_colorPalette.clear();
- for (int i=0; i<256; i++)
- {
- libwpg::WPGColor color;
- color.red = defaultWPG2PaletteRed[i];
- color.green = defaultWPG2PaletteGreen[i];
- color.blue = defaultWPG2PaletteBlue[i];
- m_colorPalette[i] = color;
- }
-}
diff --git a/src/extension/internal/libwpg/WPG2Parser.h b/src/extension/internal/libwpg/WPG2Parser.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
- * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPG2PARSER_H__
-#define __WPG2PARSER_H__
-
-#include "WPGXParser.h"
-#include "WPGBrush.h"
-#include "WPGPen.h"
-
-#include <map>
-#include <stack>
-
-class WPG2TransformMatrix
-{
-public:
- double element[3][3];
-
- WPG2TransformMatrix()
- {
- // identity transformation
- element[0][0] = element[1][1] = 1; element[2][2] = 1;
- element[0][1] = element[0][2] = 0;
- element[1][0] = element[1][2] = 0;
- element[2][0] = element[2][1] = 0;
- }
-
- void transform(long& x, long& y) const
- {
- long rx = (long)(element[0][0]*x + element[1][0]*y + element[2][0]);
- long ry = (long)(element[0][1]*x + element[1][1]*y + element[2][1]);
- x = rx;
- y = ry;
- }
-
- libwpg::WPGPoint transform(const libwpg::WPGPoint& p) const
- {
- libwpg::WPGPoint point;
- point.x = element[0][0]*p.x + element[1][0]*p.y + element[2][0];
- point.y = element[0][1]*p.x + element[1][1]*p.y + element[2][1];
- return point;
- }
-
- libwpg::WPGRect transform(const libwpg::WPGRect& r) const
- {
- libwpg::WPGRect rect;
- rect.x1 = element[0][0]*r.x1 + element[1][0]*r.y1 + element[2][0];
- rect.y1 = element[0][1]*r.x1 + element[1][1]*r.y1 + element[2][1];
- rect.x2 = element[0][0]*r.x2 + element[1][0]*r.y2 + element[2][0];
- rect.y2 = element[0][1]*r.x2 + element[1][1]*r.y2 + element[2][1];
- return rect;
- }
-
- WPG2TransformMatrix& transformBy(const WPG2TransformMatrix& m)
- {
- double result[3][3];
-
- for(int i = 0; i < 3; i++)
- for(int j = 0; j < 3; j++)
- {
- result[i][j] = 0;
- for(int k = 0; k < 3; k++)
- result[i][j] += m.element[i][k]*element[k][j];
- }
-
- for(int x = 0; x < 3; x++)
- for(int y = 0; y < 3; y++)
- element[x][y] = result[x][y];
-
- return *this;
- }
-};
-
-class WPGCompoundPolygon
-{
-public:
- WPG2TransformMatrix matrix;
- bool isFilled;
- bool isFramed;
- bool isClosed;
-
- WPGCompoundPolygon(): matrix(), isFilled(true), isFramed(true), isClosed(true) {}
-};
-
-class WPGGroupContext
-{
-public:
- unsigned subIndex;
- int parentType;
- libwpg::WPGPath compoundPath;
- WPG2TransformMatrix compoundMatrix;
- bool compoundWindingRule;
- bool compoundFilled;
- bool compoundFramed;
- bool compoundClosed;
-
- WPGGroupContext(): subIndex(0), parentType(0),
- compoundPath(), compoundMatrix(), compoundWindingRule(false),
- compoundFilled(false), compoundFramed(true), compoundClosed(false) {}
-
- bool isCompoundPolygon() const { return parentType == 0x1a; }
-};
-
-class WPG2Parser : public WPGXParser
-{
-public:
- WPG2Parser(libwpg::WPGInputStream *input, libwpg::WPGPaintInterface* painter);
- bool parse();
-
-private:
- void handleStartWPG();
- void handleEndWPG();
- void handleLayer();
- void handleCompoundPolygon();
-
- void handlePenStyleDefinition();
- void handlePatternDefinition();
- void handleColorPalette();
- void handleDPColorPalette();
- void handlePenForeColor();
- void handleDPPenForeColor();
- void handlePenBackColor();
- void handleDPPenBackColor();
- void handlePenStyle();
- void handlePenSize();
- void handleDPPenSize();
- void handleBrushGradient();
- void handleDPBrushGradient();
- void handleBrushForeColor();
- void handleDPBrushForeColor();
- void handleBrushBackColor();
- void handleDPBrushBackColor();
- void handleBrushPattern();
-
- void handlePolyline();
- void handlePolycurve();
- void handleRectangle();
- void handleArc();
-
- void resetPalette();
- void flushCompoundPolygon();
-
- // parsing context
- bool m_success;
- bool m_exit;
- unsigned int m_xres;
- unsigned int m_yres;
- long m_xofs;
- long m_yofs;
- long m_width;
- long m_height;
- bool m_doublePrecision;
- libwpg::WPGPen m_pen;
- libwpg::WPGBrush m_brush;
- std::map<unsigned int,libwpg::WPGDashArray> m_penStyles;
- bool m_layerOpened;
- unsigned int m_layerId;
- WPG2TransformMatrix m_matrix;
- double m_gradientAngle;
- libwpg::WPGPoint m_gradientRef;
- std::stack<WPGGroupContext> m_groupStack;
- WPG2TransformMatrix m_compoundMatrix;
- bool m_compoundWindingRule;
- bool m_compoundFilled;
- bool m_compoundFramed;
- bool m_compoundClosed;
-
- class ObjectCharacterization;
- void parseCharacterization(ObjectCharacterization*);
-};
-
-#endif // __WPG2PARSER_H__
diff --git a/src/extension/internal/libwpg/WPGBrush.cpp b/src/extension/internal/libwpg/WPGBrush.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "WPGBrush.h"
-
-libwpg::WPGBrush::WPGBrush():
- style(Solid),
- foreColor(0,0,0),
- backColor(0xFF,0xFF,0xFF),
- gradient()
-{}
-
-libwpg::WPGBrush::WPGBrush(const WPGColor& fore):
- style(Solid),
- foreColor(fore),
- backColor(0xFF,0xFF,0xFF),
- gradient()
-{}
-
-libwpg::WPGBrush::WPGBrush(const WPGColor& fore, const WPGColor& back):
- style(Solid),
- foreColor(fore),
- backColor(back),
- gradient()
-{}
-
-libwpg::WPGBrush::WPGBrush(const WPGBrush& brush):
- style(brush.style),
- foreColor(brush.foreColor),
- backColor(brush.backColor),
- gradient(brush.gradient)
-{}
-
-libwpg::WPGBrush& libwpg::WPGBrush::operator=(const libwpg::WPGBrush& brush)
-{
- style = brush.style;
- foreColor = brush.foreColor;
- backColor = brush.backColor;
- gradient = brush.gradient;
- return *this;
-}
diff --git a/src/extension/internal/libwpg/WPGBrush.h b/src/extension/internal/libwpg/WPGBrush.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPGBRUSH_H__
-#define __WPGBRUSH_H__
-
-#include "WPGColor.h"
-#include "WPGGradient.h"
-
-namespace libwpg
-{
-
-class WPGBrush
-{
-public:
-
- typedef enum
- {
- NoBrush,
- Solid,
- Pattern,
- Gradient
- } WPGBrushStyle;
-
- WPGBrushStyle style;
- WPGColor foreColor;
- WPGColor backColor;
-
- WPGGradient gradient;
-
- WPGBrush();
-
- explicit WPGBrush(const WPGColor& fore);
-
- WPGBrush(const WPGColor& fore, const WPGColor& back);
-
- WPGBrush(const WPGBrush& brush);
-
- WPGBrush& operator=(const WPGBrush& brush);
-};
-
-} // namespace libwpg
-
-#endif // __WPGBRUSH_H__
diff --git a/src/extension/internal/libwpg/WPGColor.cpp b/src/extension/internal/libwpg/WPGColor.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "WPGColor.h"
-
-libwpg::WPGColor::WPGColor():
- red(0),
- green(0),
- blue(0),
- alpha(0)
-{}
-
-libwpg::WPGColor::WPGColor(int r, int g, int b):
- red(r),
- green(g),
- blue(b),
- alpha(0)
-{}
-
-libwpg::WPGColor::WPGColor(int r, int g, int b, int a):
- red(r),
- green(g),
- blue(b),
- alpha(a)
-{}
-
-libwpg::WPGColor::WPGColor(const WPGColor& color):
- red(color.red),
- green(color.green),
- blue(color.blue),
- alpha(color.alpha)
-{}
-
-libwpg::WPGColor& libwpg::WPGColor::operator=(const libwpg::WPGColor& color)
-{
- red = color.red;
- green = color.green;
- blue = color.blue;
- alpha = color.alpha;
- return *this;
-}
diff --git a/src/extension/internal/libwpg/WPGColor.h b/src/extension/internal/libwpg/WPGColor.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPGCOLOR_H__
-#define __WPGCOLOR_H__
-
-namespace libwpg
-{
-
-class WPGColor
-{
-public:
- int red, green, blue, alpha;
-
- WPGColor();
-
- WPGColor(int r, int g, int b);
-
- WPGColor(int r, int g, int b, int a);
-
- WPGColor(const WPGColor& color);
-
- WPGColor& operator=(const WPGColor& color);
-};
-
-} // namespace libwpg
-
-#endif // __WPGCOLOR_H__
diff --git a/src/extension/internal/libwpg/WPGGradient.cpp b/src/extension/internal/libwpg/WPGGradient.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "WPGGradient.h"
-#include "WPGColor.h"
-
-#include <vector>
-
-namespace libwpg
-{
-
-class WPGGradientStop
-{
-public:
- double offset;
- WPGColor color;
-
- WPGGradientStop(): offset(0) {}
-
- WPGGradientStop(double ofs, const WPGColor& c): offset(ofs), color(c) {}
-};
-
-class WPGGradientPrivate
-{
-public:
- double angle;
- std::vector<WPGGradientStop> gradientStops;
-};
-
-} // namespace libwpg
-
-libwpg::WPGGradient::WPGGradient()
-{
- d = new WPGGradientPrivate;
- d->angle = 0.0;
-}
-
-libwpg::WPGGradient::~WPGGradient()
-{
- delete d;
-}
-
-libwpg::WPGGradient::WPGGradient(const libwpg::WPGGradient& g)
-{
- d = new libwpg::WPGGradientPrivate;
- d->angle = g.d->angle;
- d->gradientStops = g.d->gradientStops;
-}
-
-libwpg::WPGGradient& libwpg::WPGGradient::operator=(const libwpg::WPGGradient& g)
-{
- d->angle = g.d->angle;
- d->gradientStops = g.d->gradientStops;
- return *this;
-}
-
-double libwpg::WPGGradient::angle() const
-{
- return d->angle;
-}
-
-void libwpg::WPGGradient::setAngle(double a)
-{
- d->angle = a;
-}
-
-unsigned libwpg::WPGGradient::count() const
-{
- return d->gradientStops.size();
-}
-
-double libwpg::WPGGradient::stopOffset(unsigned index) const
-{
- return d->gradientStops[index].offset;
-}
-
-libwpg::WPGColor libwpg::WPGGradient::stopColor(unsigned index) const
-{
- return d->gradientStops[index].color;
-}
-
-void libwpg::WPGGradient::clear()
-{
- d->gradientStops.clear();
-}
-
-void libwpg::WPGGradient::addStop(double offset, const libwpg::WPGColor& color)
-{
- libwpg::WPGGradientStop stop(offset, color);
- d->gradientStops.push_back(stop);
-}
diff --git a/src/extension/internal/libwpg/WPGGradient.h b/src/extension/internal/libwpg/WPGGradient.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPGGRADIENT_H__
-#define __WPGGRADIENT_H__
-
-#include "WPGColor.h"
-
-namespace libwpg
-{
-
-class WPGGradientPrivate;
-
-class WPGGradient
-{
-public:
-
- WPGGradient();
-
- ~WPGGradient();
-
- WPGGradient(const WPGGradient&);
-
- WPGGradient& operator=(const WPGGradient&);
-
- double angle() const; // in radiant
-
- void setAngle(double angle);
-
- unsigned count() const;
-
- double stopOffset(unsigned index) const;
-
- WPGColor stopColor(unsigned index) const;
-
- void clear();
-
- void addStop(double offset, const WPGColor& color);
-
-private:
- WPGGradientPrivate *d;
-};
-
-} // namespace libwpg
-
-#endif // __WPGGRADIENT_H__
diff --git a/src/extension/internal/libwpg/WPGHeader.cpp b/src/extension/internal/libwpg/WPGHeader.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "WPGHeader.h"
-#include "libwpg_utils.h"
-
-namespace
-{
-static inline unsigned short readU16( const void* p )
-{
- const unsigned char* ptr = (const unsigned char*) p;
- return ptr[0]+(ptr[1]<<8);
-}
-
-static inline unsigned long readU32( const void* p )
-{
- const unsigned char* ptr = (const unsigned char*) p;
- return ptr[0]+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
-}
-}
-
-WPGHeader::WPGHeader()
-{
- // create a sensible default header
- m_identifier[0] = 0xff;
- m_identifier[1] = 'W';
- m_identifier[2] = 'P';
- m_identifier[3] = 'C';
- m_productType = 0x01;
- m_fileType = 0x16;
- m_encryptionKey = 0x00;
- m_majorVersion = 0x02;
- m_minorVersion = 0x00;
- m_encryptionKey = 0;
- m_startOfPacketData = 0;
- m_entryCount = 0;
- m_resourceComplete = 0;
- m_encryptionBlockOffset = 0;
- m_fileSize = 0;
- m_encryptVersion = 0;
-}
-
-bool WPGHeader::load(libwpg::WPGInputStream *input)
-{
- input->seek(0);
-
- unsigned char prefix[26];
- long n = input->read(26, (char*)prefix);
- if(n < 26)
- return false;
-
- m_identifier[0] = prefix[0];
- m_identifier[1] = prefix[1];
- m_identifier[2] = prefix[2];
- m_identifier[3] = prefix[3];
- m_startOfDocument = readU32(prefix+4);
- m_productType = prefix[8];
- m_fileType = prefix[9];
- m_majorVersion = prefix[10];
- m_minorVersion = prefix[11];
- m_encryptionKey = readU16(prefix+12);
- m_startOfPacketData = readU16(prefix+14);
-
- WPG_DEBUG_MSG(("Header Identifier = %c%c%c\n", m_identifier[1],
- m_identifier[2], m_identifier[3]));
- WPG_DEBUG_MSG(("Product type = 0x%x\n", m_productType));
- WPG_DEBUG_MSG(("File type = 0x%x\n", m_fileType));
- WPG_DEBUG_MSG(("Major version = 0x%x\n", m_majorVersion));
- WPG_DEBUG_MSG(("Minor version = 0x%x\n", m_minorVersion));
- WPG_DEBUG_MSG(("Encryption key = 0x%x\n", m_encryptionKey));
-
- return true;
-}
-
-bool WPGHeader::isSupported() const
-{
- return (
- (m_identifier[0] == 0xFF) &&
- (m_identifier[1] == 'W') &&
- (m_identifier[2] == 'P') &&
- (m_identifier[3] == 'C') &&
- (m_productType == 0x01) &&
- (m_fileType == 0x16) &&
- (m_encryptionKey == 0x00) && // we don't support encryption
- ((m_majorVersion == 0x02) || (m_majorVersion == 0x01)) &&
- (m_minorVersion == 0x00)
-);
-}
-
-unsigned long WPGHeader::startOfDocument() const
-{
- return m_startOfDocument;
-}
-
-int WPGHeader::majorVersion() const
-{
- return m_majorVersion;
-}
diff --git a/src/extension/internal/libwpg/WPGHeader.h b/src/extension/internal/libwpg/WPGHeader.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPGHEADER_H__
-#define __WPGHEADER_H__
-
-#include "WPGStream.h"
-
-class WPGHeader
-{
-public:
- WPGHeader();
-
- bool load(libwpg::WPGInputStream *input);
-
- bool isSupported() const;
-
- unsigned long startOfDocument() const;
-
- int majorVersion() const;
-
-private:
- unsigned char m_identifier[4]; // should always be 0xFF followed by "WPC"
- unsigned long m_startOfDocument; // index into file
- unsigned char m_productType; // should always be 1 for WPG files
- unsigned char m_fileType; // should always be 22 for WPG files
- unsigned char m_majorVersion; // 2 for WPG 8.0 files
- unsigned char m_minorVersion; // 0 for WPG 8.0 files
- unsigned int m_encryptionKey; // 0 when not encrypted
- unsigned int m_startOfPacketData; // unused, since according to the docs no packets are defined
- unsigned char m_entryCount; // number of entries in extension
- unsigned char m_resourceComplete; // resource completeness indicator
- unsigned int m_encryptionBlockOffset; // encryption block offset
- unsigned long m_fileSize; // size of the entire wpg file
- unsigned int m_encryptVersion; // encryption version information
-};
-
-#endif // WPGHEADER
diff --git a/src/extension/internal/libwpg/WPGOLEStream.cpp b/src/extension/internal/libwpg/WPGOLEStream.cpp
+++ /dev/null
@@ -1,989 +0,0 @@
-/* POLE - Portable C++ library to access OLE Storage
- Copyright (C) 2002-2005 Ariya Hidayat <ariya@kde.org>
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of the authors nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <sstream>
-#include <iostream>
-#include <list>
-#include <string>
-#include <vector>
-
-#include "WPGOLEStream.h"
-#include "libwpg_utils.h"
-
-namespace libwpg
-{
-
-class Header
-{
- public:
- unsigned char id[8]; // signature, or magic identifier
- unsigned b_shift; // bbat->blockSize = 1 << b_shift
- unsigned s_shift; // sbat->blockSize = 1 << s_shift
- unsigned num_bat; // blocks allocated for big bat
- unsigned dirent_start; // starting block for directory info
- unsigned threshold; // switch from small to big file (usually 4K)
- unsigned sbat_start; // starting block index to store small bat
- unsigned num_sbat; // blocks allocated for small bat
- unsigned mbat_start; // starting block to store meta bat
- unsigned num_mbat; // blocks allocated for meta bat
- unsigned long bb_blocks[109];
-
- Header();
- bool valid();
- void load( const unsigned char* buffer );
- void save( unsigned char* buffer );
- void debug();
-};
-
-class AllocTable
-{
- public:
- static const unsigned Eof;
- static const unsigned Avail;
- static const unsigned Bat;
- static const unsigned MetaBat;
- unsigned blockSize;
- AllocTable();
- void clear();
- unsigned long count();
- void resize( unsigned long newsize );
- void preserve( unsigned long n );
- void set( unsigned long index, unsigned long val );
- unsigned unused();
- void setChain( std::vector<unsigned long> );
- std::vector<unsigned long> follow( unsigned long start );
- unsigned long operator[](unsigned long index );
- void load( const unsigned char* buffer, unsigned len );
- void save( unsigned char* buffer );
- private:
- std::vector<unsigned long> data;
- AllocTable( const AllocTable& );
- AllocTable& operator=( const AllocTable& );
-};
-
-class DirEntry
-{
- public:
- bool valid; // false if invalid (should be skipped)
- std::string name; // the name, not in unicode anymore
- bool dir; // true if directory
- unsigned long size; // size (not valid if directory)
- unsigned long start; // starting block
- unsigned prev; // previous sibling
- unsigned next; // next sibling
- unsigned child; // first child
-};
-
-class DirTree
-{
- public:
- static const unsigned End;
- DirTree();
- void clear();
- unsigned entryCount();
- DirEntry* entry( unsigned index );
- DirEntry* entry( const std::string& name );
- int parent( unsigned index );
- std::string fullName( unsigned index );
- std::vector<unsigned> children( unsigned index );
- void load( unsigned char* buffer, unsigned len );
- void save( unsigned char* buffer );
- private:
- std::vector<DirEntry> entries;
- DirTree( const DirTree& );
- DirTree& operator=( const DirTree& );
-};
-
-class StorageIO
-{
- public:
- Storage* storage; // owner
- std::stringstream buf;
- int result; // result of operation
- unsigned long bufsize; // size of the buffer
-
- Header* header; // storage header
- DirTree* dirtree; // directory tree
- AllocTable* bbat; // allocation table for big blocks
- AllocTable* sbat; // allocation table for small blocks
-
- std::vector<unsigned long> sb_blocks; // blocks for "small" files
-
- std::list<Stream*> streams;
-
- StorageIO( Storage* storage, const std::stringstream &memorystream );
- ~StorageIO();
-
- bool isOle();
- void load();
-
- unsigned long loadBigBlocks( std::vector<unsigned long> blocks, unsigned char* buffer, unsigned long maxlen );
-
- unsigned long loadBigBlock( unsigned long block, unsigned char* buffer, unsigned long maxlen );
-
- unsigned long loadSmallBlocks( std::vector<unsigned long> blocks, unsigned char* buffer, unsigned long maxlen );
-
- unsigned long loadSmallBlock( unsigned long block, unsigned char* buffer, unsigned long maxlen );
-
- StreamIO* streamIO( const std::string& name );
-
- private:
- // no copy or assign
- StorageIO( const StorageIO& );
- StorageIO& operator=( const StorageIO& );
-
-};
-
-class StreamIO
-{
- public:
- StorageIO* io;
- DirEntry* entry;
- std::string fullName;
- bool eof;
- bool fail;
-
- StreamIO( StorageIO* io, DirEntry* entry );
- ~StreamIO();
- unsigned long size();
- unsigned long tell();
- int getch();
- unsigned long read( unsigned char* data, unsigned long maxlen );
- unsigned long read( unsigned long pos, unsigned char* data, unsigned long maxlen );
-
-
- private:
- std::vector<unsigned long> blocks;
-
- // no copy or assign
- StreamIO( const StreamIO& );
- StreamIO& operator=( const StreamIO& );
-
- // pointer for read
- unsigned long m_pos;
-
- // simple cache system to speed-up getch()
- unsigned char* cache_data;
- unsigned long cache_size;
- unsigned long cache_pos;
- void updateCache();
-};
-
-} // namespace libwpg
-
-static inline unsigned long readU16( const unsigned char* ptr )
-{
- return ptr[0]+(ptr[1]<<8);
-}
-
-static inline unsigned long readU32( const unsigned char* ptr )
-{
- return ptr[0]+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
-}
-
-static const unsigned char wpgole_magic[] =
- { 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1 };
-
-// =========== Header ==========
-
-libwpg::Header::Header()
-{
- b_shift = 9;
- s_shift = 6;
- num_bat = 0;
- dirent_start = 0;
- threshold = 4096;
- sbat_start = 0;
- num_sbat = 0;
- mbat_start = 0;
- num_mbat = 0;
-
- for( unsigned i = 0; i < 8; i++ )
- id[i] = wpgole_magic[i];
- for( unsigned j=0; j<109; j++ )
- bb_blocks[j] = libwpg::AllocTable::Avail;
-}
-
-bool libwpg::Header::valid()
-{
- if( threshold != 4096 ) return false;
- if( num_bat == 0 ) return false;
- if( (num_bat > 109) && (num_bat > (num_mbat * 127) + 109)) return false;
- if( (num_bat < 109) && (num_mbat != 0) ) return false;
- if( s_shift > b_shift ) return false;
- if( b_shift <= 6 ) return false;
- if( b_shift >=31 ) return false;
-
- return true;
-}
-
-void libwpg::Header::load( const unsigned char* buffer )
-{
- b_shift = readU16( buffer + 0x1e );
- s_shift = readU16( buffer + 0x20 );
- num_bat = readU32( buffer + 0x2c );
- dirent_start = readU32( buffer + 0x30 );
- threshold = readU32( buffer + 0x38 );
- sbat_start = readU32( buffer + 0x3c );
- num_sbat = readU32( buffer + 0x40 );
- mbat_start = readU32( buffer + 0x44 );
- num_mbat = readU32( buffer + 0x48 );
-
- for( unsigned i = 0; i < 8; i++ )
- id[i] = buffer[i];
- for( unsigned j=0; j<109; j++ )
- bb_blocks[j] = readU32( buffer + 0x4C+j*4 );
-}
-
-// =========== AllocTable ==========
-
-const unsigned libwpg::AllocTable::Avail = 0xffffffff;
-const unsigned libwpg::AllocTable::Eof = 0xfffffffe;
-const unsigned libwpg::AllocTable::Bat = 0xfffffffd;
-const unsigned libwpg::AllocTable::MetaBat = 0xfffffffc;
-
-libwpg::AllocTable::AllocTable()
-{
- blockSize = 4096;
- // initial size
- resize( 128 );
-}
-
-unsigned long libwpg::AllocTable::count()
-{
- return data.size();
-}
-
-void libwpg::AllocTable::resize( unsigned long newsize )
-{
- unsigned oldsize = data.size();
- data.resize( newsize );
- if( newsize > oldsize )
- for( unsigned i = oldsize; i<newsize; i++ )
- data[i] = Avail;
-}
-
-// make sure there're still free blocks
-void libwpg::AllocTable::preserve( unsigned long n )
-{
- std::vector<unsigned long> pre;
- for( unsigned i=0; i < n; i++ )
- pre.push_back( unused() );
-}
-
-unsigned long libwpg::AllocTable::operator[]( unsigned long index )
-{
- unsigned long result;
- result = data[index];
- return result;
-}
-
-void libwpg::AllocTable::set( unsigned long index, unsigned long value )
-{
- if( index >= count() ) resize( index + 1);
- data[ index ] = value;
-}
-
-void libwpg::AllocTable::setChain( std::vector<unsigned long> chain )
-{
- if( chain.size() )
- {
- for( unsigned i=0; i<chain.size()-1; i++ )
- set( chain[i], chain[i+1] );
- set( chain[ chain.size()-1 ], AllocTable::Eof );
- }
-}
-
-// follow
-std::vector<unsigned long> libwpg::AllocTable::follow( unsigned long start )
-{
- std::vector<unsigned long> chain;
-
- if( start >= count() ) return chain;
-
- unsigned long p = start;
- while( p < count() )
- {
- if( p == (unsigned long)Eof ) break;
- if( p == (unsigned long)Bat ) break;
- if( p == (unsigned long)MetaBat ) break;
- if( p >= count() ) break;
- chain.push_back( p );
- if( data[p] >= count() ) break;
- p = data[ p ];
- }
-
- return chain;
-}
-
-unsigned libwpg::AllocTable::unused()
-{
- // find first available block
- for( unsigned i = 0; i < data.size(); i++ )
- if( data[i] == Avail )
- return i;
-
- // completely full, so enlarge the table
- unsigned block = data.size();
- resize( data.size()+10 );
- return block;
-}
-
-void libwpg::AllocTable::load( const unsigned char* buffer, unsigned len )
-{
- resize( len / 4 );
- for( unsigned i = 0; i < count(); i++ )
- set( i, readU32( buffer + i*4 ) );
-}
-
-// =========== DirTree ==========
-
-const unsigned libwpg::DirTree::End = 0xffffffff;
-
-libwpg::DirTree::DirTree()
-{
- clear();
-}
-
-void libwpg::DirTree::clear()
-{
- // leave only root entry
- entries.resize( 1 );
- entries[0].valid = true;
- entries[0].name = "Root Entry";
- entries[0].dir = true;
- entries[0].size = 0;
- entries[0].start = End;
- entries[0].prev = End;
- entries[0].next = End;
- entries[0].child = End;
-}
-
-unsigned libwpg::DirTree::entryCount()
-{
- return entries.size();
-}
-
-libwpg::DirEntry* libwpg::DirTree::entry( unsigned index )
-{
- if( index >= entryCount() ) return (libwpg::DirEntry*) 0;
- return &entries[ index ];
-}
-
-int libwpg::DirTree::parent( unsigned index )
-{
- // brute-force, basically we iterate for each entries, find its children
- // and check if one of the children is 'index'
- for( unsigned j=0; j<entryCount(); j++ )
- {
- std::vector<unsigned> chi = children( j );
- for( unsigned i=0; i<chi.size();i++ )
- if( chi[i] == index )
- return j;
- }
-
- return -1;
-}
-
-std::string libwpg::DirTree::fullName( unsigned index )
-{
- // don't use root name ("Root Entry"), just give "/"
- if( index == 0 ) return "/";
-
- std::string result = entry( index )->name;
- result.insert( 0, "/" );
- int p = parent( index );
- DirEntry * _entry = 0;
- while( p > 0 )
- {
- _entry = entry( p );
- if (_entry->dir && _entry->valid)
- {
- result.insert( 0, _entry->name);
- result.insert( 0, "/" );
- }
- --p;
- index = p;
- if( index <= 0 ) break;
- }
- return result;
-}
-
-// given a fullname (e.g "/ObjectPool/_1020961869"), find the entry
-libwpg::DirEntry* libwpg::DirTree::entry( const std::string& name )
-{
-
- if( !name.length() ) return (libwpg::DirEntry*)0;
-
- // quick check for "/" (that's root)
- if( name == "/" ) return entry( 0 );
-
- // split the names, e.g "/ObjectPool/_1020961869" will become:
- // "ObjectPool" and "_1020961869"
- std::list<std::string> names;
- std::string::size_type start = 0, end = 0;
- if( name[0] == '/' ) start++;
- while( start < name.length() )
- {
- end = name.find_first_of( '/', start );
- if( end == std::string::npos ) end = name.length();
- names.push_back( name.substr( start, end-start ) );
- start = end+1;
- }
-
- // start from root
- int index = 0 ;
-
- // trace one by one
- std::list<std::string>::iterator it;
-
- for( it = names.begin(); it != names.end(); ++it )
- {
- // find among the children of index
- std::vector<unsigned> chi = children( index );
- unsigned child = 0;
- for( unsigned i = 0; i < chi.size(); i++ )
- {
- libwpg::DirEntry* ce = entry( chi[i] );
- if( ce )
- if( ce->valid && ( ce->name.length()>1 ) )
- if( ce->name == *it )
- child = chi[i];
- }
-
- // traverse to the child
- if( child > 0 ) index = child;
- else return (libwpg::DirEntry*)0;
- }
-
- return entry( index );
-}
-
-// helper function: recursively find siblings of index
-void dirtree_find_siblings( libwpg::DirTree* dirtree, std::vector<unsigned>& result,
- unsigned index )
-{
- libwpg::DirEntry* e = dirtree->entry( index );
- if( !e ) return;
- if( !e->valid ) return;
-
- // prevent infinite loop
- for( unsigned i = 0; i < result.size(); i++ )
- if( result[i] == index ) return;
-
- // add myself
- result.push_back( index );
-
- // visit previous sibling, don't go infinitely
- unsigned prev = e->prev;
- if( ( prev > 0 ) && ( prev < dirtree->entryCount() ) )
- {
- for( unsigned i = 0; i < result.size(); i++ )
- if( result[i] == prev ) prev = 0;
- if( prev ) dirtree_find_siblings( dirtree, result, prev );
- }
-
- // visit next sibling, don't go infinitely
- unsigned next = e->next;
- if( ( next > 0 ) && ( next < dirtree->entryCount() ) )
- {
- for( unsigned i = 0; i < result.size(); i++ )
- if( result[i] == next ) next = 0;
- if( next ) dirtree_find_siblings( dirtree, result, next );
- }
-}
-
-std::vector<unsigned> libwpg::DirTree::children( unsigned index )
-{
- std::vector<unsigned> result;
-
- DirEntry* e = entry( index );
- if( e ) if( e->valid && e->child < entryCount() )
- dirtree_find_siblings( this, result, e->child );
-
- return result;
-}
-
-void libwpg::DirTree::load( unsigned char* buffer, unsigned size )
-{
- entries.clear();
-
- for( unsigned i = 0; i < size/128; i++ )
- {
- unsigned p = i * 128;
-
- // would be < 32 if first char in the name isn't printable
- unsigned prefix = 32;
-
- // parse name of this entry, which stored as Unicode 16-bit
- std::string name;
- int name_len = readU16( buffer + 0x40+p );
- if( name_len > 64 ) name_len = 64;
- for( int j=0; ( buffer[j+p]) && (j<name_len); j+= 2 )
- name.append( 1, buffer[j+p] );
-
- // first char isn't printable ? remove it...
- if( buffer[p] < 32 )
- {
- prefix = buffer[0];
- name.erase( 0,1 );
- }
-
- // 2 = file (aka stream), 1 = directory (aka storage), 5 = root
- unsigned type = buffer[ 0x42 + p];
-
- libwpg::DirEntry e;
- e.valid = true;
- e.name = name;
- e.start = readU32( buffer + 0x74+p );
- e.size = readU32( buffer + 0x78+p );
- e.prev = readU32( buffer + 0x44+p );
- e.next = readU32( buffer + 0x48+p );
- e.child = readU32( buffer + 0x4C+p );
- e.dir = ( type!=2 );
-
- // sanity checks
- if( (type != 2) && (type != 1 ) && (type != 5 ) ) e.valid = false;
- if( name_len < 1 ) e.valid = false;
-
- entries.push_back( e );
- }
-}
-
-// =========== StorageIO ==========
-
-libwpg::StorageIO::StorageIO( libwpg::Storage* st, const std::stringstream &memorystream ) :
- buf( memorystream.str(), std::ios::binary | std::ios::in )
-{
- storage = st;
- result = libwpg::Storage::Ok;
-
- header = new libwpg::Header();
- dirtree = new libwpg::DirTree();
- bbat = new libwpg::AllocTable();
- sbat = new libwpg::AllocTable();
-
- bufsize = 0;
- bbat->blockSize = 1 << header->b_shift;
- sbat->blockSize = 1 << header->s_shift;
-}
-
-libwpg::StorageIO::~StorageIO()
-{
- delete sbat;
- delete bbat;
- delete dirtree;
- delete header;
-
- std::list<libwpg::Stream*>::iterator it;
- for( it = streams.begin(); it != streams.end(); ++it )
- delete *it;
-}
-
-bool libwpg::StorageIO::isOle()
-{
- load();
- return (result == libwpg::Storage::Ok);
-}
-
-void libwpg::StorageIO::load()
-{
- unsigned char* buffer = 0;
- unsigned long buflen = 0;
- std::vector<unsigned long> blocks;
-
- // find size of input file
- buf.seekg( 0, std::ios::end );
- bufsize = buf.tellg();
-
- // load header
- buffer = new unsigned char[512];
- buf.seekg( 0 );
- buf.read( (char*)buffer, 512 );
- header->load( buffer );
- delete[] buffer;
-
- // check OLE magic id
- result = libwpg::Storage::NotOLE;
- for( unsigned i=0; i<8; i++ )
- if( header->id[i] != wpgole_magic[i] )
- return;
-
- // sanity checks
- result = libwpg::Storage::BadOLE;
- if( !header->valid() ) return;
- if( header->threshold != 4096 ) return;
-
- // important block size
- bbat->blockSize = 1 << header->b_shift;
- sbat->blockSize = 1 << header->s_shift;
-
- // find blocks allocated to store big bat
- // the first 109 blocks are in header, the rest in meta bat
- blocks.clear();
- blocks.resize( header->num_bat );
- for( unsigned j = 0; j < 109; j++ )
- if( j >= header->num_bat ) break;
- else blocks[j] = header->bb_blocks[j];
- if( (header->num_bat > 109) && (header->num_mbat > 0) )
- {
- unsigned char* buffer2 = new unsigned char[ bbat->blockSize ];
- unsigned k = 109;
- for( unsigned r = 0; r < header->num_mbat; r++ )
- {
- loadBigBlock( header->mbat_start+r, buffer2, bbat->blockSize );
- for( unsigned s=0; s < bbat->blockSize; s+=4 )
- {
- if( k >= header->num_bat ) break;
- else blocks[k++] = readU32( buffer2 + s );
- }
- }
- delete[] buffer2;
- }
-
- // load big bat
- buflen = blocks.size()*bbat->blockSize;
- if( buflen > 0 )
- {
- buffer = new unsigned char[ buflen ];
- loadBigBlocks( blocks, buffer, buflen );
- bbat->load( buffer, buflen );
- delete[] buffer;
- }
-
- // load small bat
- blocks.clear();
- blocks = bbat->follow( header->sbat_start );
- buflen = blocks.size()*bbat->blockSize;
- if( buflen > 0 )
- {
- buffer = new unsigned char[ buflen ];
- loadBigBlocks( blocks, buffer, buflen );
- sbat->load( buffer, buflen );
- delete[] buffer;
- }
-
- // load directory tree
- blocks.clear();
- blocks = bbat->follow( header->dirent_start );
- buflen = blocks.size()*bbat->blockSize;
- buffer = new unsigned char[ buflen ];
- loadBigBlocks( blocks, buffer, buflen );
- dirtree->load( buffer, buflen );
- unsigned sb_start = readU32( buffer + 0x74 );
- delete[] buffer;
-
- // fetch block chain as data for small-files
- sb_blocks = bbat->follow( sb_start ); // small files
-
- // so far so good
- result = libwpg::Storage::Ok;
-}
-
-libwpg::StreamIO* libwpg::StorageIO::streamIO( const std::string& name )
-{
- load();
-
- // sanity check
- if( !name.length() ) return (libwpg::StreamIO*)0;
-
- // search in the entries
- libwpg::DirEntry* entry = dirtree->entry( name );
- if( !entry ) return (libwpg::StreamIO*)0;
- if( entry->dir ) return (libwpg::StreamIO*)0;
-
- libwpg::StreamIO* result = new libwpg::StreamIO( this, entry );
- result->fullName = name;
-
- return result;
-}
-
-unsigned long libwpg::StorageIO::loadBigBlocks( std::vector<unsigned long> blocks,
- unsigned char* data, unsigned long maxlen )
-{
- // sentinel
- if( !data ) return 0;
- if( blocks.size() < 1 ) return 0;
- if( maxlen == 0 ) return 0;
-
- // read block one by one, seems fast enough
- unsigned long bytes = 0;
- for( unsigned long i=0; (i < blocks.size() ) & ( bytes<maxlen ); i++ )
- {
- unsigned long block = blocks[i];
- unsigned long pos = bbat->blockSize * ( block+1 );
- unsigned long p = (bbat->blockSize < maxlen-bytes) ? bbat->blockSize : maxlen-bytes;
- if( pos + p > bufsize ) p = bufsize - pos;
- buf.seekg( pos );
- buf.read( (char*)data + bytes, p );
- bytes += p;
- }
-
- return bytes;
-}
-
-unsigned long libwpg::StorageIO::loadBigBlock( unsigned long block,
- unsigned char* data, unsigned long maxlen )
-{
- // sentinel
- if( !data ) return 0;
-
- // wraps call for loadBigBlocks
- std::vector<unsigned long> blocks;
- blocks.resize( 1 );
- blocks[ 0 ] = block;
-
- return loadBigBlocks( blocks, data, maxlen );
-}
-
-// return number of bytes which has been read
-unsigned long libwpg::StorageIO::loadSmallBlocks( std::vector<unsigned long> blocks,
- unsigned char* data, unsigned long maxlen )
-{
- // sentinel
- if( !data ) return 0;
- if( blocks.size() < 1 ) return 0;
- if( maxlen == 0 ) return 0;
-
- // our own local buffer
- unsigned char* buf = new unsigned char[ bbat->blockSize ];
-
- // read small block one by one
- unsigned long bytes = 0;
- for( unsigned long i=0; ( i<blocks.size() ) & ( bytes<maxlen ); i++ )
- {
- unsigned long block = blocks[i];
-
- // find where the small-block exactly is
- unsigned long pos = block * sbat->blockSize;
- unsigned long bbindex = pos / bbat->blockSize;
- if( bbindex >= sb_blocks.size() ) break;
-
- loadBigBlock( sb_blocks[ bbindex ], buf, bbat->blockSize );
-
- // copy the data
- unsigned offset = pos % bbat->blockSize;
- unsigned long p = (maxlen-bytes < bbat->blockSize-offset ) ? maxlen-bytes : bbat->blockSize-offset;
- p = (sbat->blockSize<p ) ? sbat->blockSize : p;
- memcpy( data + bytes, buf + offset, p );
- bytes += p;
- }
-
- delete[] buf;
-
- return bytes;
-}
-
-unsigned long libwpg::StorageIO::loadSmallBlock( unsigned long block,
- unsigned char* data, unsigned long maxlen )
-{
- // sentinel
- if( !data ) return 0;
-
- // wraps call for loadSmallBlocks
- std::vector<unsigned long> blocks;
- blocks.resize( 1 );
- blocks.assign( 1, block );
-
- return loadSmallBlocks( blocks, data, maxlen );
-}
-
-// =========== StreamIO ==========
-
-libwpg::StreamIO::StreamIO( libwpg::StorageIO* s, libwpg::DirEntry* e)
-{
- io = s;
- entry = e;
- eof = false;
- fail = false;
-
- m_pos = 0;
-
- if( entry->size >= io->header->threshold )
- blocks = io->bbat->follow( entry->start );
- else
- blocks = io->sbat->follow( entry->start );
-
- // prepare cache
- cache_pos = 0;
- cache_size = 4096; // optimal ?
- cache_data = new unsigned char[cache_size];
- updateCache();
-}
-
-// FIXME tell parent we're gone
-libwpg::StreamIO::~StreamIO()
-{
- delete[] cache_data;
-}
-
-unsigned long libwpg::StreamIO::tell()
-{
- return m_pos;
-}
-
-int libwpg::StreamIO::getch()
-{
- // past end-of-file ?
- if( m_pos > entry->size ) return -1;
-
- // need to update cache ?
- if( !cache_size || ( m_pos < cache_pos ) ||
- ( m_pos >= cache_pos + cache_size ) )
- updateCache();
-
- // something bad if we don't get good cache
- if( !cache_size ) return -1;
-
- int data = cache_data[m_pos - cache_pos];
- m_pos++;
-
- return data;
-}
-
-unsigned long libwpg::StreamIO::read( unsigned long pos, unsigned char* data, unsigned long maxlen )
-{
- // sanity checks
- if( !data ) return 0;
- if( maxlen == 0 ) return 0;
-
- unsigned long totalbytes = 0;
-
- if ( entry->size < io->header->threshold )
- {
- // small file
- unsigned long index = pos / io->sbat->blockSize;
-
- if( index >= blocks.size() ) return 0;
-
- unsigned char* buf = new unsigned char[ io->sbat->blockSize ];
- unsigned long offset = pos % io->sbat->blockSize;
- while( totalbytes < maxlen )
- {
- if( index >= blocks.size() ) break;
- io->loadSmallBlock( blocks[index], buf, io->bbat->blockSize );
- unsigned long count = io->sbat->blockSize - offset;
- if( count > maxlen-totalbytes ) count = maxlen-totalbytes;
- memcpy( data+totalbytes, buf + offset, count );
- totalbytes += count;
- offset = 0;
- index++;
- }
- delete[] buf;
-
- }
- else
- {
- // big file
- unsigned long index = pos / io->bbat->blockSize;
-
- if( index >= blocks.size() ) return 0;
-
- unsigned char* buf = new unsigned char[ io->bbat->blockSize ];
- unsigned long offset = pos % io->bbat->blockSize;
- while( totalbytes < maxlen )
- {
- if( index >= blocks.size() ) break;
- io->loadBigBlock( blocks[index], buf, io->bbat->blockSize );
- unsigned long count = io->bbat->blockSize - offset;
- if( count > maxlen-totalbytes ) count = maxlen-totalbytes;
- memcpy( data+totalbytes, buf + offset, count );
- totalbytes += count;
- index++;
- offset = 0;
- }
- delete [] buf;
-
- }
-
- return totalbytes;
-}
-
-unsigned long libwpg::StreamIO::read( unsigned char* data, unsigned long maxlen )
-{
- unsigned long bytes = read( tell(), data, maxlen );
- m_pos += bytes;
- return bytes;
-}
-
-void libwpg::StreamIO::updateCache()
-{
- // sanity check
- if( !cache_data ) return;
-
- cache_pos = m_pos - ( m_pos % cache_size );
- unsigned long bytes = cache_size;
- if( cache_pos + bytes > entry->size ) bytes = entry->size - cache_pos;
- cache_size = read( cache_pos, cache_data, bytes );
-}
-
-
-// =========== Storage ==========
-
-libwpg::Storage::Storage( const std::stringstream &memorystream )
-{
- io = new StorageIO( this, memorystream );
-}
-
-libwpg::Storage::~Storage()
-{
- delete io;
-}
-
-int libwpg::Storage::result()
-{
- return io->result;
-}
-
-bool libwpg::Storage::isOle()
-{
- return io->isOle();
-}
-
-// =========== Stream ==========
-
-libwpg::Stream::Stream( libwpg::Storage* storage, const std::string& name )
-{
- io = storage->io->streamIO( name );
-}
-
-// FIXME tell parent we're gone
-libwpg::Stream::~Stream()
-{
- delete io;
-}
-
-unsigned long libwpg::Stream::size()
-{
- return io ? io->entry->size : 0;
-}
-
-unsigned long libwpg::Stream::read( unsigned char* data, unsigned long maxlen )
-{
- return io ? io->read( data, maxlen ) : 0;
-}
diff --git a/src/extension/internal/libwpg/WPGOLEStream.h b/src/extension/internal/libwpg/WPGOLEStream.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/* POLE - Portable C++ library to access OLE Storage
- Copyright (C) 2002-2005 Ariya Hidayat <ariya@kde.org>
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of the authors nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef WPGOLESTREAM_H
-#define WPGOLESTREAM_H
-
-#include <string>
-#include <fstream>
-#include <sstream>
-#include <list>
-
-namespace libwpg
-{
-
-class StorageIO;
-class Stream;
-class StreamIO;
-
-class Storage
-{
- friend class Stream;
-
-public:
-
- // for Storage::result()
- enum { Ok, OpenFailed, NotOLE, BadOLE, UnknownError };
-
- /**
- * Constructs a storage with data.
- **/
- explicit Storage( const std::stringstream &memorystream );
-
- /**
- * Destroys the storage.
- **/
- ~Storage();
-
- /**
- * Checks whether the storage is OLE2 storage.
- **/
- bool isOle();
-
- /**
- * Returns the error code of last operation.
- **/
- int result();
-
-private:
- StorageIO* io;
-
- // no copy or assign
- Storage( const Storage& );
- Storage& operator=( const Storage& );
-
-};
-
-class Stream
-{
- friend class Storage;
- friend class StorageIO;
-
-public:
-
- /**
- * Creates a new stream.
- */
- // name must be absolute, e.g "/PerfectOffice_MAIN"
- Stream( Storage* storage, const std::string& name );
-
- /**
- * Destroys the stream.
- */
- ~Stream();
-
- /**
- * Returns the stream size.
- **/
- unsigned long size();
-
- /**
- * Reads a block of data.
- **/
- unsigned long read( unsigned char* data, unsigned long maxlen );
-
-private:
- StreamIO* io;
-
- // no copy or assign
- Stream( const Stream& );
- Stream& operator=( const Stream& );
-};
-
-} // namespace libwpg
-
-#endif // WPGOLESTREAM_H
diff --git a/src/extension/internal/libwpg/WPGPaintInterface.h b/src/extension/internal/libwpg/WPGPaintInterface.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPGPAINTINTERFACE_H__
-#define __WPGPAINTINTERFACE_H__
-
-#include "WPGBrush.h"
-#include "WPGPath.h"
-#include "WPGPen.h"
-#include "WPGPoint.h"
-#include "WPGRect.h"
-
-namespace libwpg
-{
-
-class WPGPaintInterface {
-public:
- virtual ~WPGPaintInterface() {}
-
- // none of the other callback functions will be called before this function is called
- virtual void startDocument(double width, double height) = 0;
-
- virtual void setPen(const WPGPen& pen) = 0;
-
- virtual void setBrush(const WPGBrush& brush) = 0;
-
- typedef enum { AlternatingFill, WindingFill } FillRule;
- virtual void setFillRule(FillRule rule ) = 0;
-
- virtual void startLayer(unsigned int id) = 0;
-
- virtual void endLayer(unsigned int id) = 0;
-
- virtual void drawRectangle(const WPGRect& rect, double rx, double ry) = 0;
-
- virtual void drawEllipse(const WPGPoint& center, double rx, double ry) = 0;
-
- virtual void drawPolygon(const WPGPointArray& vertices) = 0;
-
- virtual void drawPath(const WPGPath& path) = 0;
-
- // none of the other callback functions will be called after this function is called
- virtual void endDocument() = 0;
-};
-
-} // namespace libwpg
-
-#endif // __WPGPAINTINTERFACE_H__
-
diff --git a/src/extension/internal/libwpg/WPGPath.cpp b/src/extension/internal/libwpg/WPGPath.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "WPGPath.h"
-#include "WPGPoint.h"
-
-#include <vector>
-
-namespace libwpg
-{
-
-class WPGPathPrivate
-{
-public:
- std::vector<WPGPathElement> elements;
-};
-
-} // namespace libwpg
-
-libwpg::WPGPathElement::WPGPathElement():
- type(NullElement),
- point(WPGPoint()),
- extra1(WPGPoint()),
- extra2(WPGPoint())
-{}
-
-libwpg::WPGPath::WPGPath(): closed(true), d(new libwpg::WPGPathPrivate())
-{}
-
-libwpg::WPGPath::~WPGPath()
-{
- delete d;
-}
-
-libwpg::WPGPath::WPGPath(const libwpg::WPGPath& path): closed(path.closed), d(new libwpg::WPGPathPrivate())
-{
- d->elements = path.d->elements;
-}
-
-libwpg::WPGPath& libwpg::WPGPath::operator=(const libwpg::WPGPath& path)
-{
- d->elements = path.d->elements;
- return *this;
-}
-
-unsigned libwpg::WPGPath::count() const
-{
- return d->elements.size();
-}
-
-libwpg::WPGPathElement libwpg::WPGPath::element(unsigned index) const
-{
- return d->elements[index];
-}
-
-void libwpg::WPGPath::moveTo(const libwpg::WPGPoint& point)
-{
- libwpg::WPGPathElement element;
- element.type = libwpg::WPGPathElement::MoveToElement;
- element.point = point;
- addElement(element);
-}
-
-void libwpg::WPGPath::lineTo(const libwpg::WPGPoint& point)
-{
- libwpg::WPGPathElement element;
- element.type = libwpg::WPGPathElement::LineToElement;
- element.point = point;
- addElement(element);
-}
-
-void libwpg::WPGPath::curveTo(const libwpg::WPGPoint& c1, const libwpg::WPGPoint& c2, const libwpg::WPGPoint& endPoint)
-{
- libwpg::WPGPathElement element;
- element.type = libwpg::WPGPathElement::CurveToElement;
- element.point = endPoint;
- element.extra1 = c1;
- element.extra2 = c2;
- addElement(element);
-}
-
-void libwpg::WPGPath::addElement(const libwpg::WPGPathElement& element)
-{
- d->elements.push_back(element);
-}
-
-void libwpg::WPGPath::append(const libwpg::WPGPath& path)
-{
- for(unsigned i = 0; i < path.count(); i++)
- addElement(path.element(i));
-}
diff --git a/src/extension/internal/libwpg/WPGPath.h b/src/extension/internal/libwpg/WPGPath.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPGPATH_H__
-#define __WPGPATH_H__
-
-#include "WPGPoint.h"
-
-namespace libwpg
-{
-
-class WPGPathElement
-{
-public:
- typedef enum
- {
- NullElement,
- MoveToElement,
- LineToElement,
- CurveToElement
- } Type;
-
- Type type;
- WPGPoint point;
- WPGPoint extra1;
- WPGPoint extra2;
-
- WPGPathElement();
-};
-
-class WPGPathPrivate;
-
-class WPGPath
-{
-public:
-
- bool closed;
-
- WPGPath();
-
- ~WPGPath();
-
- WPGPath(const WPGPath&);
-
- WPGPath& operator=(const WPGPath&);
-
- unsigned count() const;
-
- WPGPathElement element(unsigned index) const;
-
- void moveTo(const WPGPoint& point);
-
- void lineTo(const WPGPoint& point);
-
- void curveTo(const WPGPoint& c1, const WPGPoint& c2, const WPGPoint& endPoint);
-
- void addElement(const WPGPathElement& element);
-
- void append(const WPGPath& path);
-
-private:
- WPGPathPrivate *d;
-};
-
-} // namespace libwpg
-
-#endif // __WPGPATH_H__
diff --git a/src/extension/internal/libwpg/WPGPen.cpp b/src/extension/internal/libwpg/WPGPen.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "WPGPen.h"
-
-#include <vector>
-
-namespace libwpg
-{
-class WPGDashArrayPrivate
-{
-public:
- std::vector<double> dashes;
-};
-}
-
-libwpg::WPGDashArray::WPGDashArray() : d(new libwpg::WPGDashArrayPrivate())
-{
-}
-
-libwpg::WPGDashArray::~WPGDashArray()
-{
- delete d;
-}
-
-libwpg::WPGDashArray::WPGDashArray(const libwpg::WPGDashArray& dash):
- d(new libwpg::WPGDashArrayPrivate())
-{
- d->dashes = dash.d->dashes;
-}
-
-libwpg::WPGDashArray& libwpg::WPGDashArray::operator=(const libwpg::WPGDashArray& dash)
-{
- d->dashes = dash.d->dashes;
- return *this;
-}
-
-unsigned libwpg::WPGDashArray::count() const
-{
- return d->dashes.size();
-}
-
-double libwpg::WPGDashArray::at(unsigned i) const
-{
- return d->dashes[i];
-}
-
-void libwpg::WPGDashArray::add(double p)
-{
- d->dashes.push_back(p);
-}
-
-libwpg::WPGPen::WPGPen():
- foreColor(0,0,0),
- backColor(0xFF,0xFF,0xFF),
- width(0),
- height(0),
- solid(true) ,
- dashArray(WPGDashArray())
-{
-}
-
-libwpg::WPGPen::WPGPen(const WPGColor& fore):
- foreColor(fore),
- backColor(0xFF,0xFF,0xFF),
- width(0),
- height(0),
- solid(true),
- dashArray(WPGDashArray())
-{
-}
-
-libwpg::WPGPen::WPGPen(const WPGColor& fore, const WPGColor& back):
- foreColor(fore),
- backColor(back),
- width(0),
- height(0),
- solid(true) ,
- dashArray(WPGDashArray())
-{
-}
-
-libwpg::WPGPen::WPGPen(const WPGPen& pen):
- foreColor(pen.foreColor),
- backColor(pen.backColor),
- width(pen.width),
- height(pen.height),
- solid(pen.solid),
- dashArray(pen.dashArray)
-{
-}
-
-libwpg::WPGPen& libwpg::WPGPen::operator=(const libwpg::WPGPen& pen)
-{
- foreColor = pen.foreColor;
- backColor = pen.backColor;
- width = pen.width;
- height = pen.height;
- solid = pen.solid;
- dashArray = pen.dashArray;
- return *this;
-}
-
diff --git a/src/extension/internal/libwpg/WPGPen.h b/src/extension/internal/libwpg/WPGPen.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPGPEN_H__
-#define __WPGPEN_H__
-
-#include "WPGColor.h"
-
-namespace libwpg
-{
-
-class WPGDashArrayPrivate;
-
-class WPGDashArray
-{
-public:
- WPGDashArray();
- ~WPGDashArray();
- WPGDashArray(const WPGDashArray&);
- WPGDashArray& operator=(const WPGDashArray&);
- unsigned count() const;
- double at(unsigned i) const;
- void add(double p);
-
-private:
- WPGDashArrayPrivate *d;
-};
-
-class WPGPen
-{
-public:
- WPGColor foreColor;
- WPGColor backColor;
- double width;
- double height;
- bool solid;
- WPGDashArray dashArray;
-
- WPGPen();
- WPGPen(const WPGColor& fore);
- WPGPen(const WPGColor& fore, const WPGColor& back);
- WPGPen(const WPGPen& pen);
-
- WPGPen& operator=(const WPGPen& pen);
-
- static WPGPen NoPen;
-};
-
-} // namespace libwpg
-
-
-#endif // __WPGPEN_H__
diff --git a/src/extension/internal/libwpg/WPGPoint.cpp b/src/extension/internal/libwpg/WPGPoint.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "WPGPoint.h"
-
-#include <vector>
-
-namespace libwpg
-{
-
-class WPGPointArrayPrivate
-{
-public:
- std::vector<WPGPoint> points;
-};
-
-}
-
-libwpg::WPGPoint::WPGPoint():
- x(0.0),
- y(0.0)
-{}
-
-libwpg::WPGPoint::WPGPoint(double xx, double yy):
- x(xx),
- y(yy)
-{}
-
-libwpg::WPGPoint::WPGPoint(const WPGPoint& point):
- x(point.x),
- y(point.y)
-{}
-
-libwpg::WPGPoint& libwpg::WPGPoint::operator=(const libwpg::WPGPoint& point)
-{
- x = point.x;
- y = point.y;
- return *this;
-}
-
-libwpg::WPGPointArray::WPGPointArray(): d(new libwpg::WPGPointArrayPrivate())
-{}
-
-libwpg::WPGPointArray::~WPGPointArray()
-{
- delete d;
-}
-
-libwpg::WPGPointArray::WPGPointArray(const libwpg::WPGPointArray& pa):
- d(new libwpg::WPGPointArrayPrivate())
-{
- d->points = pa.d->points;
-}
-
-libwpg::WPGPointArray& libwpg::WPGPointArray::operator=(const libwpg::WPGPointArray& pa)
-{
- d->points = pa.d->points;
- return *this;
-}
-
-unsigned libwpg::WPGPointArray::count() const
-{
- return d->points.size();
-}
-
-libwpg::WPGPoint& libwpg::WPGPointArray::at(unsigned i)
-{
- return d->points[i];
-}
-
-const libwpg::WPGPoint& libwpg::WPGPointArray::at(unsigned i) const
-{
- return d->points[i];
-}
-
-const libwpg::WPGPoint& libwpg::WPGPointArray::operator[](unsigned i) const
-{
- return d->points[i];
-}
-
-void libwpg::WPGPointArray::add(const libwpg::WPGPoint& p)
-{
- d->points.push_back(p);
-}
diff --git a/src/extension/internal/libwpg/WPGPoint.h b/src/extension/internal/libwpg/WPGPoint.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPGPOINT_H__
-#define __WPGPOINT_H__
-
-#include "WPGColor.h"
-
-namespace libwpg
-{
-
-class WPGPoint
-{
-public:
- double x;
- double y;
-
- WPGPoint();
-
- WPGPoint(double xx, double yy);
-
- WPGPoint(const WPGPoint& point);
-
- WPGPoint& operator=(const WPGPoint& point);
-};
-
-class WPGPointArrayPrivate;
-
-class WPGPointArray
-{
-public:
- WPGPointArray();
- ~WPGPointArray();
- WPGPointArray(const WPGPointArray&);
- WPGPointArray& operator=(const WPGPointArray&);
- unsigned count() const;
- WPGPoint& at(unsigned i);
- const WPGPoint& at(unsigned i) const;
- const WPGPoint& operator[](unsigned i) const;
- void add(const WPGPoint& p);
-
-private:
- WPGPointArrayPrivate *d;
-};
-
-} // namespace libwpg
-
-#endif // __WPGPOINT_H__
diff --git a/src/extension/internal/libwpg/WPGRect.cpp b/src/extension/internal/libwpg/WPGRect.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "WPGRect.h"
-
-libwpg::WPGRect::WPGRect():
- x1(0.0),
- y1(0.0),
- x2(0.0),
- y2(0.0)
-{}
-
-libwpg::WPGRect::WPGRect(double xx1, double yy1, double xx2, double yy2):
- x1(xx1),
- y1(yy1),
- x2(xx2),
- y2(yy2)
-{}
-
-libwpg::WPGRect::WPGRect(const WPGRect& rect):
- x1(rect.x1),
- y1(rect.y1),
- x2(rect.x2),
- y2(rect.y2)
-{}
-
-libwpg::WPGRect& libwpg::WPGRect::operator=(const WPGRect& rect)
-{
- x1 = rect.x1;
- y1 = rect.y1;
- x2 = rect.x2;
- y2 = rect.y2;
- return *this;
-}
-
-const double libwpg::WPGRect::width() const
-{
- return x2-x1;
-}
-
-const double libwpg::WPGRect::height() const
-{
- return y2-y1;
-}
diff --git a/src/extension/internal/libwpg/WPGRect.h b/src/extension/internal/libwpg/WPGRect.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPGRECT_H__
-#define __WPGRECT_H__
-
-#include "WPGColor.h"
-
-namespace libwpg
-{
-
-class WPGRect
-{
-public:
- double x1;
- double y1;
- double x2;
- double y2;
-
- WPGRect();
-
- WPGRect(double xx1, double yy1, double xx2, double yy2);
-
- WPGRect(const WPGRect& rect);
-
- WPGRect& operator=(const WPGRect& rect);
-
- const double width() const;
- const double height() const;
-};
-
-} // namespace libwpg
-
-#endif // __WPGRECT_H__
diff --git a/src/extension/internal/libwpg/WPGSVGGenerator.cpp b/src/extension/internal/libwpg/WPGSVGGenerator.cpp
+++ /dev/null
@@ -1,256 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "WPGSVGGenerator.h"
-
-libwpg::WPGSVGGenerator::WPGSVGGenerator(std::ostream & output_sink): m_pen(libwpg::WPGPen()), m_brush(libwpg::WPGBrush()), m_fillRule(AlternatingFill), m_gradientIndex(1), m_outputSink(output_sink), m_oldLocale(output_sink.getloc())
-{
- // set the stream's locale to "C" when printing floats
- std::locale c_locale("C");
- m_outputSink.imbue(c_locale);
-}
-
-libwpg::WPGSVGGenerator::~WPGSVGGenerator()
-{
- m_outputSink.imbue(m_oldLocale);
-}
-
-void libwpg::WPGSVGGenerator::startDocument(double width, double height)
-{
- m_outputSink << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
- m_outputSink << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"";
- m_outputSink << " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
-
- // m_outputSink << "<!-- Created with wpg2svg/libwpg " << LIBWPG_VERSION_STRING << " -->\n";
-
- m_outputSink << "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" ";
- m_outputSink << "xmlns:xlink=\"http://www.w3.org/1999/xlink\" ";
- m_outputSink << "width=\"" << 72*width << "\" height=\"" << 72*height << "\" >\n";
-
- m_gradientIndex = 1;
-}
-
-void libwpg::WPGSVGGenerator::endDocument()
-{
- m_outputSink << "</svg>\n";
-}
-
-void libwpg::WPGSVGGenerator::setPen(const libwpg::WPGPen& pen)
-{
- m_pen = pen;
-}
-
-void libwpg::WPGSVGGenerator::setBrush(const libwpg::WPGBrush& brush)
-{
- m_brush = brush;
-
- if(m_brush.style == libwpg::WPGBrush::Gradient)
- {
- double angle = m_brush.gradient.angle();
-
- m_outputSink << "<defs>\n";
- m_outputSink << " <linearGradient id=\"grad" << m_gradientIndex++ << "\" >\n";
- for(unsigned c = 0; c < m_brush.gradient.count(); c++)
- {
- // round to nearest percentage
- int ofs = (int)((100.0*m_brush.gradient.stopOffset(c))+0.5);
-
- libwpg::WPGColor color = m_brush.gradient.stopColor(c);
-
- m_outputSink << " <stop offset=\"" << ofs << "%\"";
- // set stream to %02x formatting
- size_t old_stream_size = m_outputSink.width(2);
- m_outputSink << std::hex;
-
- m_outputSink << " stop-color=\"#" << (color.red <= 0xF ? "0" : "") << color.red;
- m_outputSink << "" << (color.green <= 0xF ? "0" : "") << color.green;
- m_outputSink << "" << (color.blue <= 0xF ? "0" : "") << color.blue << "\" />\n";
-
- // reset stream formatting
- m_outputSink << std::dec;
- m_outputSink.width(old_stream_size);
- }
- m_outputSink << " </linearGradient>\n";
-
- // not a simple horizontal gradient
- if(angle != -90.0)
- {
- m_outputSink << " <linearGradient xlink:href=\"#grad" << m_gradientIndex-1 << "\"";
- m_outputSink << " id=\"grad" << m_gradientIndex++ << "\" ";
- m_outputSink << "x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\" ";
- m_outputSink << "gradientTransform=\"rotate(" << angle << ")\" ";
- m_outputSink << "gradientUnits=\"objectBoundingBox\" >\n";
- m_outputSink << " </linearGradient>\n";
- }
-
- m_outputSink << "</defs>\n";
- }
-}
-
-void libwpg::WPGSVGGenerator::setFillRule(FillRule rule)
-{
- m_fillRule = rule;
-}
-
-void libwpg::WPGSVGGenerator::startLayer(unsigned int id)
-{
- m_outputSink << "<g id=\"Layer" << id << "\" >\n";
-}
-
-void libwpg::WPGSVGGenerator::endLayer(unsigned int)
-{
- m_outputSink << "</g>\n";
-}
-
-void libwpg::WPGSVGGenerator::drawRectangle(const libwpg::WPGRect& rect, double rx, double ry)
-{
- m_outputSink << "<rect ";
- m_outputSink << "x=\"" << 72*rect.x1 << "\" y=\"" << 72*rect.y1 << "\" ";
- m_outputSink << "width=\"" << 72*rect.width() << "\" height=\"" << 72*rect.height() << "\" ";
- if((rx !=0) || (ry !=0))
- m_outputSink << "rx=\"" << 72*rx << "\" ry=\"" << 72*ry << "\" ";
- writeStyle();
- m_outputSink << "/>\n";
-}
-
-void libwpg::WPGSVGGenerator::drawEllipse(const libwpg::WPGPoint& center, double rx, double ry)
-{
- m_outputSink << "<ellipse ";
- m_outputSink << "cx=\"" << 72*center.x << "\" cy=\"" << 72*center.y << "\" ";
- m_outputSink << "rx=\"" << 72*rx << "\" ry=\"" << 72*ry << "\" ";
- writeStyle();
- m_outputSink << "/>\n";
-}
-
-void libwpg::WPGSVGGenerator::drawPolygon(const libwpg::WPGPointArray& vertices)
-{
- if(vertices.count() < 2)
- return;
-
- if(vertices.count() == 2)
- {
- const libwpg::WPGPoint& p1 = vertices[0];
- const libwpg::WPGPoint& p2 = vertices[1];
- m_outputSink << "<line ";
- m_outputSink << "x1=\"" << 72*p1.x << "\" y1=\"" << 72*p1.y << "\" ";
- m_outputSink << "x2=\"" << 72*p2.x << "\" y2=\"" << 72*p2.y << "\"\n";
- writeStyle();
- m_outputSink << "/>\n";
- }
- else
- {
- m_outputSink << "<polyline ";
- m_outputSink << "points=\"";
- for(unsigned i = 0; i < vertices.count(); i++)
- {
- m_outputSink << 72*vertices[i].x << " " << 72*vertices[i].y;
- if(i < vertices.count()-1) m_outputSink << ", ";
- }
- m_outputSink << "\"\n";
- writeStyle();
- m_outputSink << "/>\n";
- }
-}
-
-void libwpg::WPGSVGGenerator::drawPath(const libwpg::WPGPath& path)
-{
- m_outputSink << "<path d=\"";
- for(unsigned i = 0; i < path.count(); i++)
- {
- libwpg::WPGPathElement element = path.element(i);
- libwpg::WPGPoint point = element.point;
- switch(element.type)
- {
- case libwpg::WPGPathElement::MoveToElement:
- m_outputSink << "\n M" << 72*point.x << "," << 72*point.y << " ";
- break;
-
- case libwpg::WPGPathElement::LineToElement:
- m_outputSink << "\n L" << 72*point.x << "," << 72*point.y << " ";
- break;
-
- case libwpg::WPGPathElement::CurveToElement:
- m_outputSink << "C";
- m_outputSink << 72*element.extra1.x << "," << 72*element.extra1.y << " ";
- m_outputSink << 72*element.extra2.x << "," << 72*element.extra2.y << " ";
- m_outputSink << 72*point.x << "," << 72*point.y;
- break;
-
- default:
- break;
- }
- }
-
- if(path.closed)
- m_outputSink << "Z";
-
- m_outputSink << "\" \n";
- writeStyle();
- m_outputSink << "/>\n";
-}
-
-// create "style" attribute based on current pen and brush
-void libwpg::WPGSVGGenerator::writeStyle()
-{
- m_outputSink << "style=\"";
-
- const libwpg::WPGColor& color = m_pen.foreColor;
- m_outputSink << "stroke-width: " << 72*m_pen.width << "; ";
- if(m_pen.width > 0.0)
- {
- m_outputSink << "stroke: rgb(" << color.red << "," << color.green << "," << color.blue << "); ";
- if(color.alpha != 0)
- // alpha = 0 means opacity = 1.0, alpha = 256 means opacity = 0
- m_outputSink << "stroke-opacity: " << 1.0-(color.alpha/256.0) << "; ";
- }
-
- if(!m_pen.solid)
- {
- m_outputSink << "stroke-dasharray: ";
- for(unsigned i = 0; i < m_pen.dashArray.count(); i++)
- {
- m_outputSink << 72*m_pen.dashArray.at(i)*m_pen.width;
- if(i < m_pen.dashArray.count()-1)
- m_outputSink << ", ";
- }
- m_outputSink << "; ";
- }
-
- if(m_brush.style == libwpg::WPGBrush::NoBrush)
- m_outputSink << "fill: none; ";
-
- if(m_fillRule == WPGSVGGenerator::WindingFill)
- m_outputSink << "fill-rule: nonzero; ";
- else if(m_fillRule == WPGSVGGenerator::AlternatingFill)
- m_outputSink << "fill-rule: evenodd; ";
-
- if(m_brush.style == libwpg::WPGBrush::Gradient)
- m_outputSink << "fill: url(#grad" << m_gradientIndex-1 << "); ";
-
- if(m_brush.style == libwpg::WPGBrush::Solid)
- m_outputSink << "fill: rgb(" << m_brush.foreColor.red << "," << m_brush.foreColor.green << "," << m_brush.foreColor.blue << "); ";
-
- m_outputSink << "\""; // style
-}
diff --git a/src/extension/internal/libwpg/WPGSVGGenerator.h b/src/extension/internal/libwpg/WPGSVGGenerator.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPGSVGGENERATOR_H__
-#define __WPGSVGGENERATOR_H__
-
-#include <stdio.h>
-#include <iostream>
-#include <locale>
-#include "libwpg.h"
-#include "WPGStreamImplementation.h"
-
-namespace libwpg
-{
-
-class WPGSVGGenerator : public WPGPaintInterface {
-public:
- WPGSVGGenerator(std::ostream & output_sink);
- ~WPGSVGGenerator();
-
- void startDocument(double imageWidth, double imageHeight);
- void endDocument();
- void startLayer(unsigned int id);
- void endLayer(unsigned int id);
-
- void setPen(const libwpg::WPGPen& pen);
- void setBrush(const libwpg::WPGBrush& brush);
- void setFillRule(FillRule rule);
-
- void drawRectangle(const libwpg::WPGRect& rect, double rx, double ry);
- void drawEllipse(const libwpg::WPGPoint& center, double rx, double ry);
- void drawPolygon(const libwpg::WPGPointArray& vertices);
- void drawPath(const libwpg::WPGPath& path);
-
-private:
- libwpg::WPGPen m_pen;
- libwpg::WPGBrush m_brush;
- FillRule m_fillRule;
- int m_gradientIndex;
- void writeStyle();
-
- std::ostream & m_outputSink;
- std::locale m_oldLocale;
-};
-
-} // namespace libwpg
-
-#endif // __WPGSVGGENERATOR_H__
diff --git a/src/extension/internal/libwpg/WPGStream.h b/src/extension/internal/libwpg/WPGStream.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPGSTREAM_H__
-#define __WPGSTREAM_H__
-
-namespace libwpg
-{
-
-class WPGInputStream
-{
-public:
- virtual ~WPGInputStream() {}
- virtual unsigned char getc() = 0;
- virtual long read(long n, char* buffer) = 0;
- virtual long tell() = 0;
- virtual void seek(long offset) = 0;
- virtual bool atEnd() = 0;
-
- virtual bool isOle() = 0;
- virtual WPGInputStream *getWPGOleStream() = 0;
-};
-
-} // namespace wpg
-
-#endif // __WPGSTREAM_H__
diff --git a/src/extension/internal/libwpg/WPGStreamImplementation.cpp b/src/extension/internal/libwpg/WPGStreamImplementation.cpp
+++ /dev/null
@@ -1,238 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "WPGStreamImplementation.h"
-#include "WPGOLEStream.h"
-#include "libwpg.h"
-
-#include <fstream>
-#include <sstream>
-#include <string>
-
-// MSVC++ 6.0 defines getc as macro, so undefine it
-#undef getc
-
-namespace libwpg
-{
-
-class WPGFileStreamPrivate
-{
-public:
- WPGFileStreamPrivate();
- std::fstream file;
- std::stringstream buffer;
-};
-
-class WPGMemoryStreamPrivate
-{
-public:
- WPGMemoryStreamPrivate(const std::string str);
- std::stringstream buffer;
-};
-
-} // namespace libwpg
-
-libwpg::WPGFileStreamPrivate::WPGFileStreamPrivate() :
- file(),
- buffer(std::ios::binary | std::ios::in | std::ios::out)
-{
-}
-
-libwpg::WPGMemoryStreamPrivate::WPGMemoryStreamPrivate(const std::string str) :
- buffer(str, std::ios::binary | std::ios::in)
-{
-}
-
-
-libwpg::WPGFileStream::WPGFileStream(const char* filename)
-{
- d = new libwpg::WPGFileStreamPrivate;
-
- d->file.open( filename, std::ios::binary | std::ios::in );
-}
-
-libwpg::WPGFileStream::~WPGFileStream()
-{
- delete d;
-}
-
-unsigned char libwpg::WPGFileStream::getc()
-{
- return d->file.get();
-}
-
-long libwpg::WPGFileStream::read(long nbytes, char* buffer)
-{
- long nread = 0;
-
- if(d->file.good())
- {
- long curpos = d->file.tellg();
- d->file.read(buffer, nbytes);
- nread = (long)d->file.tellg() - curpos;
- }
-
- return nread;
-}
-
-long libwpg::WPGFileStream::tell()
-{
- return d->file.good() ? (long)d->file.tellg() : -1L;
-}
-
-void libwpg::WPGFileStream::seek(long offset)
-{
- if(d->file.good())
- d->file.seekg(offset);
-}
-
-bool libwpg::WPGFileStream::atEnd()
-{
- return d->file.eof();
-}
-
-bool libwpg::WPGFileStream::isOle()
-{
- if (d->buffer.str().empty())
- d->buffer << d->file.rdbuf();
- Storage tmpStorage( d->buffer );
- if (tmpStorage.isOle())
- return true;
- return false;
-}
-
-libwpg::WPGInputStream* libwpg::WPGFileStream::getWPGOleStream()
-{
- if (d->buffer.str().empty())
- d->buffer << d->file.rdbuf();
- libwpg::Storage *tmpStorage = new libwpg::Storage( d->buffer );
- libwpg::Stream tmpStream( tmpStorage, "PerfectOffice_MAIN" );
- if (!tmpStorage || (tmpStorage->result() != Storage::Ok) || !tmpStream.size())
- {
- if (tmpStorage)
- delete tmpStorage;
- return (libwpg::WPGInputStream*)0;
- }
-
- unsigned char *tmpBuffer = new unsigned char[tmpStream.size()];
- unsigned long tmpLength;
- tmpLength = tmpStream.read(tmpBuffer, tmpStream.size());
-
- // sanity check
- if (tmpLength > tmpStream.size() || tmpLength < tmpStream.size())
- /* something went wrong here and we do not trust the
- resulting buffer */
- {
- if (tmpStorage)
- delete tmpStorage;
- return (libwpg::WPGInputStream*)0;
- }
-
- delete tmpStorage;
- return new libwpg::WPGMemoryStream((const char *)tmpBuffer, tmpLength);
-}
-
-
-libwpg::WPGMemoryStream::WPGMemoryStream(const char *data, const unsigned int dataSize)
-{
- d = new libwpg::WPGMemoryStreamPrivate(std::string(data, dataSize));
-}
-
-libwpg::WPGMemoryStream::~WPGMemoryStream()
-{
- delete d;
-}
-
-unsigned char libwpg::WPGMemoryStream::getc()
-{
- return d->buffer.get();
-}
-
-long libwpg::WPGMemoryStream::read(long nbytes, char* buffer)
-{
- long nread = 0;
-
- if(d->buffer.good())
- {
- long curpos = d->buffer.tellg();
- d->buffer.read(buffer, nbytes);
- nread = (long)d->buffer.tellg() - curpos;
- }
-
- return nread;
-}
-
-long libwpg::WPGMemoryStream::tell()
-{
- return d->buffer.good() ? (long)d->buffer.tellg() : -1L;
-}
-
-void libwpg::WPGMemoryStream::seek(long offset)
-{
- if(d->buffer.good())
- d->buffer.seekg(offset);
-}
-
-bool libwpg::WPGMemoryStream::atEnd()
-{
- return d->buffer.eof();
-}
-
-bool libwpg::WPGMemoryStream::isOle()
-{
- libwpg::Storage tmpStorage( d->buffer );
- if (tmpStorage.isOle())
- return true;
- return false;
-}
-
-libwpg::WPGInputStream* libwpg::WPGMemoryStream::getWPGOleStream()
-{
- libwpg::Storage *tmpStorage = new libwpg::Storage( d->buffer );
- libwpg::Stream tmpStream( tmpStorage, "PerfectOffice_MAIN" );
- if (!tmpStorage || (tmpStorage->result() != libwpg::Storage::Ok) || !tmpStream.size())
- {
- if (tmpStorage)
- delete tmpStorage;
- return (libwpg::WPGInputStream*)0;
- }
-
- unsigned char *tmpBuffer = new unsigned char[tmpStream.size()];
- unsigned long tmpLength;
- tmpLength = tmpStream.read(tmpBuffer, tmpStream.size());
-
- // sanity check
- if (tmpLength > tmpStream.size() || tmpLength < tmpStream.size())
- /* something went wrong here and we do not trust the
- resulting buffer */
- {
- if (tmpStorage)
- delete tmpStorage;
- return (libwpg::WPGInputStream*)0;
- }
-
- delete tmpStorage;
- return new libwpg::WPGMemoryStream((const char *)tmpBuffer, tmpLength);
-}
diff --git a/src/extension/internal/libwpg/WPGStreamImplementation.h b/src/extension/internal/libwpg/WPGStreamImplementation.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPGSTREAMIMPLEMENTATION_H__
-#define __WPGSTREAMIMPLEMENTATION_H__
-
-#include "WPGStream.h"
-
-namespace libwpg
-{
-
-class WPGFileStreamPrivate;
-
-class WPGFileStream: public WPGInputStream
-{
-public:
- explicit WPGFileStream(const char* filename);
- ~WPGFileStream();
-
- unsigned char getc();
- long read(long n, char* buffer);
- long tell();
- void seek(long offset);
- bool atEnd();
-
- bool isOle();
- WPGInputStream *getWPGOleStream();
-
-private:
- WPGFileStreamPrivate* d;
- WPGFileStream(const WPGFileStream&); // copy is not allowed
- WPGFileStream& operator=(const WPGFileStream&); // assignment is not allowed
-};
-
-class WPGMemoryStreamPrivate;
-
-class WPGMemoryStream: public WPGInputStream
-{
-public:
- WPGMemoryStream(const char *data, const unsigned int dataSize);
- ~WPGMemoryStream();
-
- unsigned char getc();
- long read(long n, char* buffer);
- long tell();
- void seek(long offset);
- bool atEnd();
-
- bool isOle();
- WPGInputStream *getWPGOleStream();
-
-private:
- WPGMemoryStreamPrivate* d;
- WPGMemoryStream(const WPGMemoryStream&); // copy is not allowed
- WPGMemoryStream& operator=(const WPGMemoryStream&); // assignment is not allowed
-};
-
-} // namespace libwpg
-
-#endif // __WPGSTREAMIMPLEMENTATION_H__
diff --git a/src/extension/internal/libwpg/WPGString.cpp b/src/extension/internal/libwpg/WPGString.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "WPGString.h"
-#include <string>
-
-namespace libwpg
-{
-class WPGStringPrivate
-{
-public:
- std::string str;
-};
-
-} // namespace libwpg
-
-libwpg::WPGString::WPGString() :
- d(new WPGStringPrivate())
-{
-}
-
-
-libwpg::WPGString::WPGString(const char * str):
- d(new WPGStringPrivate())
-{
- d->str = str;
-}
-
-libwpg::WPGString::~WPGString()
-{
- delete d;
-}
-
-const bool libwpg::WPGString::empty() const
-{
- return d->str.empty();
-}
-
-const char * libwpg::WPGString::cstr() const
-{
- return d->str.c_str();
-}
-
-const long libwpg::WPGString::length() const
-{
- return d->str.length();
-}
-
-libwpg::WPGString& libwpg::WPGString::operator=(const libwpg::WPGString& str)
-{
- d->str = str.d->str;
- return *this;
-}
-
-libwpg::WPGString& libwpg::WPGString::operator=(const char * str)
-{
- d->str = str;
- return *this;
-}
diff --git a/src/extension/internal/libwpg/WPGString.h b/src/extension/internal/libwpg/WPGString.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPGSTRING_H__
-#define __WPGSTRING_H__
-
-namespace libwpg
-{
-class WPGStringPrivate;
-class WPGString
-{
-public:
- WPGString();
- WPGString(const char * str);
-
- ~WPGString();
-
- const bool empty() const;
-
- const char * cstr() const;
-
- const long length() const;
-
- WPGString& operator=(const WPGString& str);
- WPGString& operator=(const char * str);
-private:
- WPGStringPrivate * d;
-};
-
-} // namespace libwpg
-
-#endif // __WPGSTRING_H__
diff --git a/src/extension/internal/libwpg/WPGXParser.cpp b/src/extension/internal/libwpg/WPGXParser.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
- * Copyright (C) 2005 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "WPGXParser.h"
-
-WPGXParser::WPGXParser(libwpg::WPGInputStream *input, libwpg::WPGPaintInterface* painter):
- m_input(input), m_painter(painter)
-{
-}
-
-unsigned char WPGXParser::readU8()
-{
- return m_input->getc();
-}
-
-unsigned short WPGXParser::readU16()
-{
- unsigned short p0 = (unsigned short)readU8();
- unsigned short p1 = (unsigned short)readU8();
- return p0|(p1<<8);
-}
-
-unsigned long WPGXParser::readU32()
-{
- unsigned long p0 = (unsigned short)readU8();
- unsigned long p1 = (unsigned short)readU8();
- unsigned long p2 = (unsigned short)readU8();
- unsigned long p3 = (unsigned short)readU8();
- return p0|(p1<<8)|(p2<<16)|(p3<<24);
-}
-
-char WPGXParser::readS8()
-{
- return (char)m_input->getc();
-}
-
-short WPGXParser::readS16()
-{
- short p0 = readU8();
- short p1 = readS8();
- return p0|(p1<<8);
-}
-
-long WPGXParser::readS32()
-{
- long p0 = readU8();
- long p1 = readU8();
- long p2 = readU8();
- long p3 = readS8();
- return p0|(p1<<8)|(p2<<16)|(p3<<24);
-}
-
-unsigned int WPGXParser::readVariableLengthInteger()
-{
- // read a byte
- unsigned char value8 = readU8();
- // if it's in the range 0-0xFE, then we have a 8-bit value
- if (value8<=0xFE) {
- return (unsigned int)value8;
- } else {
- // now read a 16 bit value
- unsigned short value16 = readU16();
- // if the MSB is 1, we have a 32 bit value
- if (value16>>15) {
- // read the next 16 bit value (LSB part, in value16 resides the MSB part)
- unsigned long lvalue16 = readU16();
- unsigned long value32 = value16 & 0x7fff; // mask out the MSB
- return (value32<<16)+lvalue16;
- } else {
- // we have a 16 bit value, return it
- return (unsigned int)value16;
- }
- }
-
- // unreachable
- return 0;
-}
diff --git a/src/extension/internal/libwpg/WPGXParser.h b/src/extension/internal/libwpg/WPGXParser.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
- * Copyright (C) 2005 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPGXPARSER_H__
-#define __WPGXPARSER_H__
-
-#include "WPGPaintInterface.h"
-#include "WPGStream.h"
-#include "WPGColor.h"
-
-#include <map>
-
-class WPGXParser
-{
-public:
- WPGXParser(libwpg::WPGInputStream *input, libwpg::WPGPaintInterface* painter);
- virtual ~WPGXParser() {};
- virtual bool parse() = 0;
-
- unsigned char readU8();
- unsigned short readU16();
- unsigned long readU32();
- char readS8();
- short readS16();
- long readS32();
- unsigned int readVariableLengthInteger();
-
-protected:
- libwpg::WPGInputStream* m_input;
- libwpg::WPGPaintInterface* m_painter;
- std::map<int,libwpg::WPGColor> m_colorPalette;
-};
-
-#endif // __WPGXPARSER_H__
diff --git a/src/extension/internal/libwpg/WPGraphics.cpp b/src/extension/internal/libwpg/WPGraphics.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "WPGraphics.h"
-#include "WPGHeader.h"
-#include "WPGStream.h"
-#include "WPGXParser.h"
-#include "WPG1Parser.h"
-#include "WPG2Parser.h"
-#include "libwpg_utils.h"
-#include "WPGSVGGenerator.h"
-#include <sstream>
-
-/**
-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 WordPerfect Graphics that libwpg is able to parse
-*/
-bool libwpg::WPGraphics::isSupported(libwpg::WPGInputStream* input)
-{
- WPGHeader header;
- if(!header.load(input))
- return false;
-
- return header.isSupported();
-}
-
-/**
-Parses the input stream content. It will make callbacks to the functions provided by a
-WPGPaintInterface class implementation when needed. This is often commonly called the
-'main parsing routine'.
-\param input The input stream
-\param painter A WPGPainterInterface implementation
-\return A value that indicates whether the parsing was successful
-*/
-bool libwpg::WPGraphics::parse(libwpg::WPGInputStream* input, libwpg::WPGPaintInterface* painter)
-{
- WPGXParser *parser = 0;
-
- WPG_DEBUG_MSG(("Loading header...\n"));
- WPGHeader header;
- if(!header.load(input))
- return false;
-
- if(!header.isSupported())
- {
- WPG_DEBUG_MSG(("Unsupported file format!\n"));
- return false;
- }
-
- // seek to the start of document
- input->seek(header.startOfDocument());
-
- bool retval;
- switch (header.majorVersion()) {
- case 0x01: // WPG1
- WPG_DEBUG_MSG(("Parsing WPG1\n"));
- parser = new WPG1Parser(input, painter);
- retval = parser->parse();
- break;
- case 0x02: // WPG2
- WPG_DEBUG_MSG(("Parsing WPG2\n"));
- parser = new WPG2Parser(input, painter);
- retval = parser->parse();
- break;
- default: // other :-)
- WPG_DEBUG_MSG(("Unknown format\n"));
- return false;
- }
-
- if (parser)
- delete parser;
-
- return retval;
-}
-
-/**
-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 libwpg::WPGraphics::generateSVG(libwpg::WPGInputStream* input, libwpg::WPGString& output)
-{
- std::ostringstream tmpOutputStream;
- libwpg::WPGSVGGenerator generator(tmpOutputStream);
- bool result;
- if (result = libwpg::WPGraphics::parse(input, &generator))
- output = WPGString(tmpOutputStream.str().c_str());
- else
- output = WPGString("");
- return result;
-}
diff --git a/src/extension/internal/libwpg/WPGraphics.h b/src/extension/internal/libwpg/WPGraphics.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __WPGRAPHICS_H__
-#define __WPGRAPHICS_H__
-
-#include "WPGString.h"
-
-namespace libwpg
-{
-
-class WPGInputStream;
-class WPGPaintInterface;
-
-class WPGraphics
-{
-public:
-
- static bool isSupported(WPGInputStream* input);
-
- static bool parse(WPGInputStream* input, WPGPaintInterface* painter);
-
- static bool generateSVG(WPGInputStream* input, WPGString& output);
-};
-
-} // namespace libwpg
-
-#endif // __WPGRAPHICS_H__
diff --git a/src/extension/internal/libwpg/libwpg.h b/src/extension/internal/libwpg/libwpg.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* libwpg
- * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
- * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __LIBWPG_H__
-#define __LIBWPG_H__
-
-#include "WPGraphics.h"
-#include "WPGPaintInterface.h"
-#include "WPGStream.h"
-
-#include "WPGColor.h"
-#include "WPGPen.h"
-#include "WPGBrush.h"
-#include "WPGGradient.h"
-#include "WPGPath.h"
-#include "WPGPoint.h"
-#include "WPGRect.h"
-
-#endif
diff --git a/src/extension/internal/libwpg/libwpg_utils.h b/src/extension/internal/libwpg/libwpg_utils.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* libwpg
- * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
- *
- * 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
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef __LIBWPG_UTILS_H__
-#define __LIBWPG_UTILS_H__
-
-#include <stdio.h>
-
-//#define DEBUG // FIXME !
-
-// 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 WPG_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
- #define WPG_DEBUG(M) M
- #else
- #define WPG_DEBUG_MSG(M) printf M
- #define WPG_DEBUG(M) M
- #endif
-#else
- #define WPG_DEBUG_MSG(M)
- #define WPG_DEBUG(M)
-#endif
-
-#endif // __LIBWPG_UTILS_H__
diff --git a/src/extension/internal/libwpg/makefile.mk b/src/extension/internal/libwpg/makefile.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-PRJ=..$/..$/..$/..$/..$/..
-
-PRJNAME=libwpg
-TARGET=wpglib
-ENABLE_EXCEPTIONS=TRUE
-LIBTARGET=NO
-
-.INCLUDE : svpre.mk
-.INCLUDE : settings.mk
-.INCLUDE : sv.mk
-
-SLOFILES= \
- $(SLO)$/WPGraphics.obj \
- $(SLO)$/WPGPen.obj \
- $(SLO)$/WPGGradient.obj \
- $(SLO)$/WPGPoint.obj \
- $(SLO)$/WPGPath.obj \
- $(SLO)$/WPGHeader.obj \
- $(SLO)$/WPGXParser.obj \
- $(SLO)$/WPG1Parser.obj \
- $(SLO)$/WPG2Parser.obj \
- $(SLO)$/WPGOLEStream.obj \
- $(SLO)$/WPGStreamImplementation.obj
-
-LIB1ARCHIV=$(LB)$/libwpglib.a
-LIB1TARGET=$(SLB)$/$(TARGET).lib
-LIB1OBJFILES= $(SLOFILES)
-
-.INCLUDE : target.mk
index fd0cdff3947094e98c3ea74c4f21a00f2c812452..c385a9f14070f28eeb5a5cbcff659b294a703c81 100644 (file)
#include "document.h"
#include "libwpg/libwpg.h"
-#include "libwpg/WPGSVGGenerator.h"
+#include "libwpg/WPGStreamImplementation.h"
using namespace libwpg;
SPDocument *
WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) {
- WPGInputStream* input = new WPGFileStream(uri);
- if (input->isOle()) {
- WPGInputStream* olestream = input->getWPGOleStream();
+ WPXInputStream* input = new libwpg::WPGFileStream(uri);
+ if (input->isOLEStream()) {
+ WPXInputStream* olestream = input->getDocumentOLEStream();
if (olestream) {
delete input;
input = olestream;