From 6e272e78c148590660e3443caefce378800260c3 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 19 Feb 2007 20:48:09 +0000 Subject: Cleaned up DOS line ends that had snuck in. (bzr r2399) --- src/extension/internal/libwpg/WPGOLEStream.h | 82 +++++------ src/extension/internal/libwpg/WPGXParser.cpp | 206 +++++++++++++-------------- src/extension/internal/libwpg/WPGXParser.h | 120 ++++++++-------- src/extension/internal/libwpg/WPGraphics.cpp | 166 ++++++++++----------- src/extension/internal/libwpg/WPGraphics.h | 92 ++++++------ 5 files changed, 333 insertions(+), 333 deletions(-) (limited to 'src/extension/internal/libwpg') diff --git a/src/extension/internal/libwpg/WPGOLEStream.h b/src/extension/internal/libwpg/WPGOLEStream.h index 49562bfd6..af4a3d02f 100644 --- a/src/extension/internal/libwpg/WPGOLEStream.h +++ b/src/extension/internal/libwpg/WPGOLEStream.h @@ -1,28 +1,28 @@ /* POLE - Portable C++ library to access OLE Storage Copyright (C) 2002-2005 Ariya Hidayat - - 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 + + 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. */ @@ -46,10 +46,10 @@ class Storage friend class Stream; public: - + // for Storage::result() - enum { Ok, OpenFailed, NotOLE, BadOLE, UnknownError }; - + enum { Ok, OpenFailed, NotOLE, BadOLE, UnknownError }; + /** * Constructs a storage with data. **/ @@ -84,19 +84,19 @@ 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. - */ +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. **/ @@ -105,11 +105,11 @@ public: /** * Reads a block of data. **/ - unsigned long read( unsigned char* data, unsigned long maxlen ); - + unsigned long read( unsigned char* data, unsigned long maxlen ); + private: StreamIO* io; - + // no copy or assign Stream( const Stream& ); Stream& operator=( const Stream& ); diff --git a/src/extension/internal/libwpg/WPGXParser.cpp b/src/extension/internal/libwpg/WPGXParser.cpp index dcdc44c50..e25b53aab 100644 --- a/src/extension/internal/libwpg/WPGXParser.cpp +++ b/src/extension/internal/libwpg/WPGXParser.cpp @@ -1,103 +1,103 @@ -/* 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" - -using namespace libwpg; - -WPGXParser::WPGXParser(WPGInputStream *input, 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; -} +/* 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" + +using namespace libwpg; + +WPGXParser::WPGXParser(WPGInputStream *input, 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 index 71c78d2c0..d7fd4cb5a 100644 --- a/src/extension/internal/libwpg/WPGXParser.h +++ b/src/extension/internal/libwpg/WPGXParser.h @@ -1,60 +1,60 @@ -/* 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 - -using namespace libwpg; - -class WPGXParser -{ -public: - WPGXParser(WPGInputStream *input, 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: - WPGInputStream* m_input; - WPGPaintInterface* m_painter; - std::map m_colorPalette; -}; - -#endif // __WPGXPARSER_H__ +/* 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 + +using namespace libwpg; + +class WPGXParser +{ +public: + WPGXParser(WPGInputStream *input, 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: + WPGInputStream* m_input; + WPGPaintInterface* m_painter; + std::map m_colorPalette; +}; + +#endif // __WPGXPARSER_H__ diff --git a/src/extension/internal/libwpg/WPGraphics.cpp b/src/extension/internal/libwpg/WPGraphics.cpp index a7454d2a1..e120b802e 100644 --- a/src/extension/internal/libwpg/WPGraphics.cpp +++ b/src/extension/internal/libwpg/WPGraphics.cpp @@ -1,83 +1,83 @@ -/* 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" - -using namespace libwpg; - -bool WPGraphics::isSupported(WPGInputStream* input) -{ - WPGHeader header; - if(!header.load(input)) - return false; - - return header.isSupported(); -} - -bool WPGraphics::parse(WPGInputStream* input, 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()); - - switch (header.majorVersion()) { - case 0x01: // WPG1 - WPG_DEBUG_MSG(("Parsing WPG1\n")); - parser = new WPG1Parser(input, painter); - parser->parse(); - break; - case 0x02: // WPG2 - WPG_DEBUG_MSG(("Parsing WPG2\n")); - parser = new WPG2Parser(input, painter); - parser->parse(); - break; - default: // other :-) - WPG_DEBUG_MSG(("Unknown format\n")); - break; - } - - delete parser; - - return false; -} - +/* 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" + +using namespace libwpg; + +bool WPGraphics::isSupported(WPGInputStream* input) +{ + WPGHeader header; + if(!header.load(input)) + return false; + + return header.isSupported(); +} + +bool WPGraphics::parse(WPGInputStream* input, 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()); + + switch (header.majorVersion()) { + case 0x01: // WPG1 + WPG_DEBUG_MSG(("Parsing WPG1\n")); + parser = new WPG1Parser(input, painter); + parser->parse(); + break; + case 0x02: // WPG2 + WPG_DEBUG_MSG(("Parsing WPG2\n")); + parser = new WPG2Parser(input, painter); + parser->parse(); + break; + default: // other :-) + WPG_DEBUG_MSG(("Unknown format\n")); + break; + } + + delete parser; + + return false; +} + diff --git a/src/extension/internal/libwpg/WPGraphics.h b/src/extension/internal/libwpg/WPGraphics.h index 3226835ca..21abddd1b 100644 --- a/src/extension/internal/libwpg/WPGraphics.h +++ b/src/extension/internal/libwpg/WPGraphics.h @@ -1,46 +1,46 @@ -/* 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__ - -namespace libwpg -{ - -class WPGInputStream; -class WPGPaintInterface; - -class WPGraphics -{ -public: - - static bool isSupported(WPGInputStream* input); - - static bool parse(WPGInputStream* input, WPGPaintInterface* painter); -}; - -} // namespace libwpg - -#endif // __WPGRAPHICS_H__ +/* 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__ + +namespace libwpg +{ + +class WPGInputStream; +class WPGPaintInterface; + +class WPGraphics +{ +public: + + static bool isSupported(WPGInputStream* input); + + static bool parse(WPGInputStream* input, WPGPaintInterface* painter); +}; + +} // namespace libwpg + +#endif // __WPGRAPHICS_H__ -- cgit v1.2.3