MWAWParser.hxx
Go to the documentation of this file.
00001 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
00002 
00003 /* libmwaw
00004 * Version: MPL 2.0 / LGPLv2+
00005 *
00006 * The contents of this file are subject to the Mozilla Public License Version
00007 * 2.0 (the "License"); you may not use this file except in compliance with
00008 * the License or as specified alternatively below. You may obtain a copy of
00009 * the License at http://www.mozilla.org/MPL/
00010 *
00011 * Software distributed under the License is distributed on an "AS IS" basis,
00012 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013 * for the specific language governing rights and limitations under the
00014 * License.
00015 *
00016 * Major Contributor(s):
00017 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
00018 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
00019 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00020 * Copyright (C) 2006, 2007 Andrew Ziem
00021 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
00022 *
00023 *
00024 * All Rights Reserved.
00025 *
00026 * For minor contributions see the git repository.
00027 *
00028 * Alternatively, the contents of this file may be used under the terms of
00029 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
00030 * in which case the provisions of the LGPLv2+ are applicable
00031 * instead of those above.
00032 */
00033 
00034 #ifndef MWAW_PARSER_H
00035 #define MWAW_PARSER_H
00036 
00037 #include <ostream>
00038 #include <string>
00039 #include <vector>
00040 
00041 #include "MWAWDebug.hxx"
00042 #include "MWAWInputStream.hxx"
00043 
00044 #include "MWAWEntry.hxx"
00045 #include "MWAWHeader.hxx"
00046 #include "MWAWPageSpan.hxx"
00047 
00048 class WPXDocumentInterface;
00049 
00051 class MWAWParserState
00052 {
00053 public:
00054   // Constructor
00055   MWAWParserState(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
00057   ~MWAWParserState();
00058 
00060   int m_version;
00062   MWAWInputStreamPtr m_input;
00064   MWAWHeader *m_header;
00066   MWAWRSRCParserPtr m_rsrcParser;
00067 
00069   MWAWFontConverterPtr m_fontConverter;
00071   MWAWGraphicListenerPtr m_graphicListener;
00073   MWAWListManagerPtr m_listManager;
00075   MWAWContentListenerPtr m_listener;
00076 
00078   libmwaw::DebugFile m_asciiFile;
00079 
00080 private:
00081   MWAWParserState(MWAWParserState const &orig);
00082   MWAWParserState &operator=(MWAWParserState const &orig);
00083 };
00084 
00089 class MWAWParser
00090 {
00091 public:
00093   virtual ~MWAWParser();
00095   virtual void parse(WPXDocumentInterface *documentInterface) = 0;
00097   virtual bool checkHeader(MWAWHeader *header, bool strict=false) = 0;
00098 
00100   int version() const {
00101     return m_parserState->m_version;
00102   }
00104   void setVersion(int vers) {
00105     m_parserState->m_version = vers;
00106   }
00107 
00108 protected:
00110   MWAWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
00112   MWAWParser(MWAWParserStatePtr state) : m_parserState(state), m_pageSpan(), m_asciiName("") { }
00113 
00115   MWAWParserStatePtr getParserState() {
00116     return m_parserState;
00117   }
00119   MWAWHeader *getHeader() {
00120     return m_parserState->m_header;
00121   }
00123   MWAWInputStreamPtr &getInput() {
00124     return m_parserState->m_input;
00125   }
00127   MWAWGraphicListenerPtr &getGraphicListener() {
00128     return m_parserState->m_graphicListener;
00129   }
00131   MWAWContentListenerPtr &getListener() {
00132     return m_parserState->m_listener;
00133   }
00135   MWAWPageSpan const &getPageSpan() const {
00136     return m_pageSpan;
00137   }
00139   MWAWPageSpan &getPageSpan() {
00140     return m_pageSpan;
00141   }
00143   double getFormLength() const {
00144     return m_pageSpan.getFormLength();
00145   }
00147   double getFormWidth() const {
00148     return m_pageSpan.getFormWidth();
00149   }
00151   double getPageLength() const {
00152     return m_pageSpan.getPageLength();
00153   }
00155   double getPageWidth() const {
00156     return m_pageSpan.getPageWidth();
00157   }
00159   MWAWRSRCParserPtr &getRSRCParser() {
00160     return m_parserState->m_rsrcParser;
00161   }
00163   void setListener(MWAWContentListenerPtr &listener);
00165   void resetListener();
00167   MWAWFontConverterPtr &getFontConverter() {
00168     return m_parserState->m_fontConverter;
00169   }
00171   void setFontConverter(MWAWFontConverterPtr fontConverter);
00173   libmwaw::DebugFile &ascii() {
00174     return m_parserState->m_asciiFile;
00175   }
00177   void setAsciiName(char const *name) {
00178     m_asciiName = name;
00179   }
00181   std::string const &asciiName() const {
00182     return m_asciiName;
00183   }
00184 
00185 private:
00187   MWAWParser(const MWAWParser &);
00189   MWAWParser &operator=(const MWAWParser &);
00190 
00192   MWAWParserStatePtr m_parserState;
00194   MWAWPageSpan m_pageSpan;
00196   std::string m_asciiName;
00197 };
00198 
00199 #endif /* MWAWPARSER_H */
00200 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: