QuattroSpreadsheet.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* libwps
00003  * Version: MPL 2.0 / LGPLv2.1+
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Major Contributor(s):
00010  * Copyright (C) 2006, 2007 Andrew Ziem
00011  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
00012  * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
00013  *
00014  * For minor contributions see the git repository.
00015  *
00016  * Alternatively, the contents of this file may be used under the terms
00017  * of the GNU Lesser General Public License Version 2.1 or later
00018  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00019  * applicable instead of those above.
00020  */
00021 
00022 #ifndef QUATTRO_SPREADSHEET_H
00023 #define QUATTRO_SPREADSHEET_H
00024 
00025 #include <ostream>
00026 #include <vector>
00027 
00028 #include <librevenge-stream/librevenge-stream.h>
00029 
00030 #include "libwps_internal.h"
00031 
00032 #include "WPSDebug.h"
00033 #include "WKSContentListener.h"
00034 
00035 namespace QuattroSpreadsheetInternal
00036 {
00037 class Cell;
00038 class SpreadSheet;
00039 struct State;
00040 }
00041 
00042 class QuattroParser;
00043 
00048 class QuattroSpreadsheet
00049 {
00050 public:
00051         friend class QuattroParser;
00052 
00054         QuattroSpreadsheet(QuattroParser &parser);
00056         ~QuattroSpreadsheet();
00058         void setListener(WKSContentListenerPtr &listen)
00059         {
00060                 m_listener = listen;
00061         }
00062 
00063 protected:
00065         bool checkFilePosition(long pos);
00067         int version() const;
00069         bool hasLICSCharacters() const;
00070 
00072         int getNumSpreadsheets() const;
00074         void sendSpreadsheet(int sId);
00075 
00077         void sendCellContent(QuattroSpreadsheetInternal::Cell const &cell);
00078 
00080 
00082         bool readSpreadsheetOpen();
00084         bool readSpreadsheetClose();
00085 
00086         //
00087         // low level
00088         //
00090 
00092         bool readCell();
00094         bool readCellFormulaResult();
00096         bool readSheetSize();
00098         bool readSpreadsheetName();
00100         bool readColumnSize();
00102         bool readRowSize();
00104         bool readHiddenColumns();
00105 
00107         bool readCellProperty();
00109         bool readCellStyle();
00111         bool readUserStyle();
00112 
00113         /* reads a cell */
00114         bool readCell(Vec2i actPos, WKSContentListener::FormulaInstruction &instr, bool hasSheetId=false, int sheetId=0);
00115         /* reads a formula */
00116         bool readFormula(long endPos, Vec2i const &pos, int sheetId,
00117                          std::vector<WKSContentListener::FormulaInstruction> &formula, std::string &error);
00118 
00119 private:
00120         QuattroSpreadsheet(QuattroSpreadsheet const &orig);
00121         QuattroSpreadsheet &operator=(QuattroSpreadsheet const &orig);
00123         libwps::DebugFile &ascii()
00124         {
00125                 return m_asciiFile;
00126         }
00128         RVNGInputStreamPtr m_input;
00129         shared_ptr<WKSContentListener> m_listener; 
00130 
00131         QuattroParser &m_mainParser;
00133         shared_ptr<QuattroSpreadsheetInternal::State> m_state;
00135         libwps::DebugFile &m_asciiFile;
00136 };
00137 
00138 #endif /* WPS4_H */
00139 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */