LotusSpreadsheet.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 LOTUS_SPREADSHEET_H
00023 #define LOTUS_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 LotusSpreadsheetInternal
00036 {
00037 class Cell;
00038 class SpreadSheet;
00039 struct Style;
00040 struct State;
00041 }
00042 
00043 class LotusParser;
00044 class LotusStyleManager;
00045 
00050 class LotusSpreadsheet
00051 {
00052 public:
00053         friend class LotusParser;
00054 
00056         LotusSpreadsheet(LotusParser &parser);
00058         ~LotusSpreadsheet();
00060         void cleanState();
00062         void updateState();
00064         void setListener(WKSContentListenerPtr &listen)
00065         {
00066                 m_listener = listen;
00067         }
00069         void setLastSpreadsheetId(int id);
00070 protected:
00072         bool checkFilePosition(long pos);
00074         int version() const;
00076         bool hasSomeSpreadsheetData() const;
00077 
00079         void sendSpreadsheet(int sheetId);
00080 
00082         void sendCellContent(LotusSpreadsheetInternal::Cell const &cell,
00083                              LotusSpreadsheetInternal::Style const &style);
00084 
00086 
00087         //
00088         // low level
00089         //
00091 
00093         bool readSheetName();
00094 
00096         bool readColumnDefinition();
00098         bool readColumnSizes();
00100         bool readRowFormats();
00102         bool readRowFormat(LotusSpreadsheetInternal::Style &style, int &numCell, long endPos);
00104         bool readRowSizes(long endPos);
00105 
00107         bool readCell();
00109         bool readCellName();
00110 
00111         // data in formula
00112 
00113         /* reads a cell */
00114         bool readCell(int sId, bool isList, WKSContentListener::FormulaInstruction &instr);
00115         /* reads a formula */
00116         bool readFormula(long endPos, int sId, bool newFormula,
00117                          std::vector<WKSContentListener::FormulaInstruction> &formula, std::string &error);
00118 private:
00119         LotusSpreadsheet(LotusSpreadsheet const &orig);
00120         LotusSpreadsheet &operator=(LotusSpreadsheet const &orig);
00122         libwps::DebugFile &ascii()
00123         {
00124                 return m_asciiFile;
00125         }
00127         RVNGInputStreamPtr m_input;
00128         shared_ptr<WKSContentListener> m_listener; 
00129 
00130         LotusParser &m_mainParser;
00132         shared_ptr<LotusStyleManager> m_styleManager;
00134         shared_ptr<LotusSpreadsheetInternal::State> m_state;
00136         libwps::DebugFile &m_asciiFile;
00137 };
00138 
00139 #endif /* LOTUS_SPREAD_SHEET_H */
00140 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */