00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 00002 /* libvisio 00003 * Version: MPL 1.1 / GPLv2+ / LGPLv2+ 00004 * 00005 * The contents of this file are subject to the Mozilla Public License Version 00006 * 1.1 (the "License"); you may not use this file except in compliance with 00007 * the License or as specified alternatively below. You may obtain a copy of 00008 * the License at http://www.mozilla.org/MPL/ 00009 * 00010 * Software distributed under the License is distributed on an "AS IS" basis, 00011 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 00012 * for the specific language governing rights and limitations under the 00013 * License. 00014 * 00015 * Major Contributor(s): 00016 * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch> 00017 * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com> 00018 * 00019 * 00020 * All Rights Reserved. 00021 * 00022 * For minor contributions see the git repository. 00023 * 00024 * Alternatively, the contents of this file may be used under the terms of 00025 * either the GNU General Public License Version 2 or later (the "GPLv2+"), or 00026 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), 00027 * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable 00028 * instead of those above. 00029 */ 00030 00031 #ifndef __VSDXPARSER_H__ 00032 #define __VSDXPARSER_H__ 00033 00034 #include <stdio.h> 00035 #include <iostream> 00036 #include <vector> 00037 #include <map> 00038 #include <libwpd/libwpd.h> 00039 #include <libwpd-stream/libwpd-stream.h> 00040 #include <libwpg/libwpg.h> 00041 #include "VSDXTypes.h" 00042 #include "VSDXGeometryList.h" 00043 #include "VSDXFieldList.h" 00044 #include "VSDXCharacterList.h" 00045 #include "VSDXParagraphList.h" 00046 #include "VSDXShapeList.h" 00047 #include "VSDXStencils.h" 00048 00049 namespace libvisio 00050 { 00051 00052 class VSDXCollector; 00053 00054 class VSDXParser 00055 { 00056 public: 00057 explicit VSDXParser(WPXInputStream *input, libwpg::WPGPaintInterface *painter); 00058 virtual ~VSDXParser(); 00059 bool parseMain(); 00060 00061 protected: 00062 // reader functions 00063 void readEllipticalArcTo(WPXInputStream *input); 00064 void readForeignData(WPXInputStream *input); 00065 void readEllipse(WPXInputStream *input); 00066 void readLine(WPXInputStream *input); 00067 virtual void readFillAndShadow(WPXInputStream *input) = 0; 00068 void readGeomList(WPXInputStream *input); 00069 void readGeometry(WPXInputStream *input); 00070 void readMoveTo(WPXInputStream *input); 00071 void readLineTo(WPXInputStream *input); 00072 void readArcTo(WPXInputStream *input); 00073 void readNURBSTo(WPXInputStream *input); 00074 void readPolylineTo(WPXInputStream *input); 00075 void readInfiniteLine(WPXInputStream *input); 00076 void readShapeData(WPXInputStream *input); 00077 void readXFormData(WPXInputStream *input); 00078 void readTxtXForm(WPXInputStream *input); 00079 void readShapeId(WPXInputStream *input); 00080 void readShapeList(WPXInputStream *input); 00081 void readForeignDataType(WPXInputStream *input); 00082 void readPageProps(WPXInputStream *input); 00083 void readShape(WPXInputStream *input); 00084 void readColours(WPXInputStream *input); 00085 void readFont(WPXInputStream *input, unsigned id); 00086 void readFontIX(WPXInputStream *input); 00087 void readCharList(WPXInputStream *input); 00088 void readParaList(WPXInputStream *input); 00089 void readPage(WPXInputStream *input); 00090 virtual void readText(WPXInputStream *input) = 0; 00091 virtual void readCharIX(WPXInputStream *input) = 0; 00092 virtual void readParaIX(WPXInputStream *input) = 0; 00093 void readTextBlock(WPXInputStream *input); 00094 00095 void readNameList(WPXInputStream *input); 00096 virtual void readName(WPXInputStream *input) = 0; 00097 00098 void readFieldList(WPXInputStream *input); 00099 virtual void readTextField(WPXInputStream *input) = 0; 00100 00101 void readStyleSheet(WPXInputStream *input); 00102 00103 void readSplineStart(WPXInputStream *input); 00104 void readSplineKnot(WPXInputStream *input); 00105 00106 void readStencilShape(WPXInputStream *input); 00107 00108 void readOLEList(WPXInputStream *input); 00109 void readOLEData(WPXInputStream *input); 00110 00111 // parser of one pass 00112 bool parseDocument(WPXInputStream *input); 00113 00114 // Stream handlers 00115 void handlePages(WPXInputStream *input, unsigned shift); 00116 void handlePage(WPXInputStream *input); 00117 void handleStyles(WPXInputStream *input); 00118 void handleStencils(WPXInputStream *input, unsigned shift); 00119 void handleStencilPage(WPXInputStream *input, unsigned shift); 00120 void handleStencilForeign(WPXInputStream *input, unsigned shift); 00121 void handleStencilShape(WPXInputStream *input); 00122 00123 virtual bool getChunkHeader(WPXInputStream *input) = 0; 00124 void _handleLevelChange(unsigned level); 00125 00126 WPXInputStream *m_input; 00127 libwpg::WPGPaintInterface *m_painter; 00128 ChunkHeader m_header; 00129 VSDXCollector *m_collector; 00130 VSDXGeometryList *m_geomList; 00131 std::vector<VSDXGeometryList *> m_geomListVector; 00132 VSDXFieldList m_fieldList; 00133 VSDXCharacterList *m_charList; 00134 VSDXParagraphList *m_paraList; 00135 std::vector<VSDXCharacterList *> m_charListVector; 00136 std::vector<VSDXParagraphList *> m_paraListVector; 00137 VSDXShapeList m_shapeList; 00138 unsigned m_currentLevel; 00139 00140 VSDXStencils m_stencils; 00141 VSDXStencil *m_currentStencil; 00142 VSDXStencilShape m_stencilShape; 00143 bool m_isStencilStarted; 00144 bool m_isInStyles; 00145 unsigned m_currentPageID; 00146 00147 private: 00148 VSDXParser(); 00149 VSDXParser(const VSDXParser &); 00150 VSDXParser &operator=(const VSDXParser &); 00151 00152 }; 00153 00154 struct Pointer 00155 { 00156 unsigned Type; 00157 unsigned Offset; 00158 unsigned Length; 00159 unsigned short Format; 00160 }; 00161 00162 } // namespace libvisio 00163 00164 #endif // __VSDXPARSER_H__ 00165 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */