CDRParser.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* libcdr
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  *
00018  *
00019  * All Rights Reserved.
00020  *
00021  * For minor contributions see the git repository.
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
00025  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
00026  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
00027  * instead of those above.
00028  */
00029 
00030 #ifndef __CDRPARSER_H__
00031 #define __CDRPARSER_H__
00032 
00033 #include <stdio.h>
00034 #include <iostream>
00035 #include <vector>
00036 #include <map>
00037 #include <stack>
00038 #include <libwpd-stream/libwpd-stream.h>
00039 #include "CDRTypes.h"
00040 #include "CommonParser.h"
00041 
00042 namespace libcdr
00043 {
00044 
00045 class CDRCollector;
00046 
00047 class CDRParser : protected CommonParser
00048 {
00049 public:
00050   explicit CDRParser(const std::vector<WPXInputStream *> &externalStreams, CDRCollector *collector);
00051   virtual ~CDRParser();
00052   bool parseRecords(WPXInputStream *input, unsigned *blockLengths = 0, unsigned level = 0);
00053   bool parseWaldo(WPXInputStream *input);
00054 
00055 private:
00056   CDRParser();
00057   CDRParser(const CDRParser &);
00058   CDRParser &operator=(const CDRParser &);
00059   bool parseWaldoStructure(WPXInputStream *input, std::stack<WaldoRecordType1> &waldoStack,
00060                            const std::map<unsigned, WaldoRecordType1> &records1,
00061                            std::map<unsigned, WaldoRecordInfo> &records2);
00062   bool gatherWaldoInformation(WPXInputStream *input, std::vector<WaldoRecordInfo> &records, std::map<unsigned, WaldoRecordInfo> &records2,
00063                               std::map<unsigned, WaldoRecordInfo> &records3, std::map<unsigned, WaldoRecordInfo> &records4,
00064                               std::map<unsigned, WaldoRecordInfo> &records6, std::map<unsigned, WaldoRecordInfo> &records7,
00065                               std::map<unsigned, WaldoRecordInfo> &records8, std::map<unsigned, WaldoRecordInfo> recordsOther);
00066   void readWaldoRecord(WPXInputStream *input, const WaldoRecordInfo &info);
00067   bool parseRecord(WPXInputStream *input, unsigned *blockLengths = 0, unsigned level = 0);
00068   void readRecord(unsigned fourCC, unsigned length, WPXInputStream *input);
00069   double readRectCoord(WPXInputStream *input);
00070   CDRColor readColor(WPXInputStream *input);
00071 
00072   void readRectangle(WPXInputStream *input);
00073   void readEllipse(WPXInputStream *input);
00074   void readLineAndCurve(WPXInputStream *input);
00075   void readBitmap(WPXInputStream *input);
00076   void readPageSize(WPXInputStream *input);
00077   void readWaldoBmp(WPXInputStream *input, unsigned length, unsigned id);
00078   void readWaldoBmpf(WPXInputStream *input, unsigned id);
00079   void readWaldoTrfd(WPXInputStream *input);
00080   void readWaldoOutl(WPXInputStream *input);
00081   void readWaldoFill(WPXInputStream *input);
00082   void readWaldoLoda(WPXInputStream *input, unsigned length);
00083   void readOpacity(WPXInputStream *input, unsigned length);
00084   void readTrfd(WPXInputStream *input, unsigned length);
00085   void readFild(WPXInputStream *input, unsigned length);
00086   void readOutl(WPXInputStream *input, unsigned length);
00087   void readLoda(WPXInputStream *input, unsigned length);
00088   void readFlags(WPXInputStream *input, unsigned length);
00089   void readMcfg(WPXInputStream *input, unsigned length);
00090   void readPath(WPXInputStream *input);
00091   void readPolygonCoords(WPXInputStream *input);
00092   void readPolygonTransform(WPXInputStream *input);
00093   void readBmp(WPXInputStream *input, unsigned length);
00094   void readBmpf(WPXInputStream *input, unsigned length);
00095   void readPpdt(WPXInputStream *input, unsigned length);
00096   void readFtil(WPXInputStream *input, unsigned length);
00097   void readDisp(WPXInputStream *input, unsigned length);
00098   void readVersion(WPXInputStream *input, unsigned length);
00099   void readIccd(WPXInputStream *input, unsigned length);
00100   void readBBox(WPXInputStream *input, unsigned length);
00101   void readSpnd(WPXInputStream *input, unsigned length);
00102   void readVpat(WPXInputStream *input, unsigned length);
00103   void readUidr(WPXInputStream *input, unsigned length);
00104   void readFont(WPXInputStream *input, unsigned length);
00105   void readStlt(WPXInputStream *input, unsigned length);
00106   void readStyd(WPXInputStream *input);
00107   void readTxsm(WPXInputStream *input, unsigned length);
00108   void readTxsm16(WPXInputStream *input);
00109   void readTxsm6(WPXInputStream *input);
00110   void readTxsm5(WPXInputStream *input);
00111   void readArtisticText(WPXInputStream *input);
00112   void readParagraphText(WPXInputStream *input);
00113 
00114   bool _redirectX6Chunk(WPXInputStream **input, unsigned &length);
00115 
00116   std::vector<WPXInputStream *> m_externalStreams;
00117 
00118   std::map<unsigned, CDRFont> m_fonts;
00119   std::map<unsigned, CDRFillStyle> m_fillStyles;
00120   std::map<unsigned, CDRLineStyle> m_lineStyles;
00121 
00122   unsigned m_version;
00123 
00124 };
00125 
00126 } // namespace libcdr
00127 
00128 #endif // __CDRPARSER_H__
00129 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */