CWDbaseContent.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 /*
00035  * The main database content used by Claris Works parser to store spreedsheet/Databese
00036  *
00037  */
00038 #ifndef CW_DBASE_CONTENT
00039 #  define CW_DBASE_CONTENT
00040 
00041 #include <iostream>
00042 #include <map>
00043 #include <vector>
00044 
00045 #include "libmwaw_internal.hxx"
00046 
00047 #include "MWAWEntry.hxx"
00048 #include "MWAWFont.hxx"
00049 
00050 // remove me
00051 #include "CWStyleManager.hxx"
00052 
00053 class CWStyleManager;
00054 
00056 class CWDbaseContent
00057 {
00058 public:
00060   CWDbaseContent(MWAWParserStatePtr parserState, shared_ptr<CWStyleManager> styleManager, bool spreadsheet);
00062   ~CWDbaseContent();
00064   bool readContent();
00065 
00067   bool getExtrema(Vec2i &min, Vec2i &max) const;
00069   bool getRecordList(std::vector<int> &list) const;
00070 
00072   bool send(Vec2i const &pos);
00074   void setDatabaseFormats(std::vector<CWStyleManager::CellFormat> const &format);
00075 protected:
00077   struct Record {
00079     enum Type { R_Unknown, R_Long, R_Double, R_String };
00081     Record() : m_style(-1), m_resType(R_Unknown), m_resLong(0), m_resDouble(0), m_resString(), m_format(0), m_font(3,9), m_justify(0), m_borders(0) {
00082     }
00083 
00085     int m_style;
00087     Type m_resType;
00089     long m_resLong;
00091     double m_resDouble;
00093     MWAWEntry m_resString;
00095     int m_format;
00097     MWAWFont m_font;
00099     int m_justify;
00101     int m_borders;
00102   };
00104   struct Column {
00106     Column() : m_idRecordMap() {
00107     }
00109     std::map<int,Record> m_idRecordMap;
00110   };
00111 
00113   bool readColumnList();
00115   bool readColumn(int c);
00117   bool readRecordList(Vec2i const &where, Column &col);
00119   bool readRecordSS(Vec2i const &where, long pos, Record &record);
00121   bool readRecordSSV1(Vec2i const &where, long pos, Record &record);
00123   bool readRecordDB(Vec2i const &where, long pos, Record &record);
00124 
00126   void send(double val, CWStyleManager::CellFormat const &format);
00127 
00129   int m_version;
00131   bool m_isSpreadsheet;
00132 
00134   MWAWParserStatePtr m_parserState;
00136   shared_ptr<CWStyleManager> m_styleManager;
00137 
00139   std::map<int, Column> m_idColumnMap;
00141   std::vector<CWStyleManager::CellFormat> m_dbFormatList;
00142 };
00143 #endif
00144 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
00145 
00146