WKS4Spreadsheet.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 WKS4_SPREADSHEET_H
00023 #define WKS4_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 WKS4SpreadsheetInternal
00036 {
00037 class Cell;
00038 class SpreadSheet;
00039 struct State;
00040 }
00041 
00042 class WKS4Parser;
00043 
00048 class WKS4Spreadsheet
00049 {
00050 public:
00051         friend class WKS4Parser;
00052 
00054         WKS4Spreadsheet(WKS4Parser &parser);
00056         ~WKS4Spreadsheet();
00058         void setListener(WKSContentListenerPtr &listen)
00059         {
00060                 m_listener = listen;
00061         }
00062 
00063 protected:
00065         bool checkFilePosition(long pos);
00067         int version() const;
00068 
00070         void sendSpreadsheet();
00071 
00073         void sendCellContent(WKS4SpreadsheetInternal::Cell const &cell);
00074 
00076 
00078         bool readReportOpen();
00080         bool readReportClose();
00081 
00083         bool readFilterOpen();
00085         bool readFilterClose();
00086 
00087         //
00088         // low level
00089         //
00091 
00093         bool readCell();
00095         bool readCellFormulaResult();
00096 
00098         bool readStyle();
00099 
00101         bool readDOSFieldProperty();
00102 
00104         bool readDOSCellProperty();
00105 
00107         bool readDOSCellExtraProperty();
00108 
00110         bool readDOSPageBreak();
00111 
00113         bool readSheetSize();
00114 
00116         bool readPageBreak();
00117 
00119         bool readColumnSize();
00120 
00122         bool readColumnSize2();
00123 
00125         bool readRowSize2();
00126 
00127         /* reads a cell */
00128         bool readCell(Vec2i actPos, WKSContentListener::FormulaInstruction &instr);
00129         /* reads a number */
00130         bool readNumber(long endPos, double &res);
00131         /* reads a float store with 4 bytes */
00132         bool readFloat4(long endPos, double &res);
00133         /* reads a formula */
00134         bool readFormula(long endPos, Vec2i const &pos, std::vector<WKSContentListener::FormulaInstruction> &formula, std::string &error);
00135 
00136 private:
00137         WKS4Spreadsheet(WKS4Spreadsheet const &orig);
00138         WKS4Spreadsheet &operator=(WKS4Spreadsheet const &orig);
00140         libwps::DebugFile &ascii()
00141         {
00142                 return m_asciiFile;
00143         }
00145         RVNGInputStreamPtr m_input;
00146         shared_ptr<WKSContentListener> m_listener; 
00147 
00148         WKS4Parser &m_mainParser;
00150         shared_ptr<WKS4SpreadsheetInternal::State> m_state;
00152         libwps::DebugFile &m_asciiFile;
00153 };
00154 
00155 #endif /* WPS4_H */
00156 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */