ClarisWksDbaseContent.hxx Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

ClarisWksDbaseContent.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33
34 /*
35 * The main database content used by Claris Works parser to store spreedsheet/Databese
36 *
37 */
38 #ifndef CLARIS_WKS_DBASE_CONTENT
39 # define CLARIS_WKS_DBASE_CONTENT
40
41 #include <iostream>
42 #include <map>
43 #include <vector>
44
45 #include "libmwaw_internal.hxx"
46
47 #include "MWAWCell.hxx"
48 #include "MWAWEntry.hxx"
49 #include "MWAWFont.hxx"
50
51 #include "ClarisWksStyleManager.hxx"
52
53 class ClarisWksDocument;
54
56 class ClarisWksDbaseContent
57 {
58 public:
59 struct Record;
60
62 ClarisWksDbaseContent(ClarisWksDocument &document, bool spreadsheet);
64 ~ClarisWksDbaseContent();
66 bool readContent();
67
69 bool getExtrema(Vec2i &min, Vec2i &max) const;
71 bool getRecordList(std::vector<int> &list) const;
72
74 bool get(Vec2i const &pos, Record &data) const;
76 bool send(Vec2i const &pos);
78 void setDatabaseFormats(std::vector<ClarisWksStyleManager::CellFormat> const &format);
80 struct Record {
82 Record() : m_style(-1), m_format(), m_hAlign(MWAWCell::HALIGN_DEFAULT), m_fileFormat(0),
83 m_content(), m_valueType(MWAWCellContent::C_UNKNOWN), m_hasNaNValue(false), m_backgroundColor(MWAWColor::white()), m_font(3,9), m_borders(0)
84 {
85 }
86
88 int m_style;
90 MWAWCell::Format m_format;
92 MWAWCell::HorizontalAlignment m_hAlign;
94 int m_fileFormat;
96 MWAWCellContent m_content;
98 MWAWCellContent::Type m_valueType;
100 bool m_hasNaNValue;
102 MWAWColor m_backgroundColor;
104 MWAWFont m_font;
106 int m_borders;
107 };
108 protected:
110 struct Column {
112 Column() : m_idRecordMap()
113 {
114 }
116 std::map<int,Record> m_idRecordMap;
117 };
118
120 bool readColumnList();
122 bool readColumn(int c);
124 bool readRecordList(Vec2i const &where, Column &col);
126 bool readRecordSS(Vec2i const &where, long pos, Record &record);
128 bool readRecordSSV1(Vec2i const &where, long pos, Record &record);
130 bool readRecordDB(Vec2i const &where, long pos, Record &record);
131
133 void send(double val, bool isNotaNumber, ClarisWksStyleManager::CellFormat const &format);
134
135 //
136 // low level
137 //
138
140 bool readCellInFormula(Vec2i const &pos, MWAWCellContent::FormulaInstruction &instr);
142 bool readString(long endPos, std::string &res);
144 bool readNumber(long endPos, double &res, bool &isNan);
146 bool readFormula(Vec2i const &cPos, long endPos,
147 std::vector<MWAWCellContent::FormulaInstruction> &formula, std::string &error);
148
150 int m_version;
152 bool m_isSpreadsheet;
153
155 ClarisWksDocument &m_document;
157 MWAWParserStatePtr m_parserState;
158
160 std::map<int, Column> m_idColumnMap;
162 std::vector<ClarisWksStyleManager::CellFormat> m_dbFormatList;
163 };
164 #endif
165 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
166
167
MWAWCellContent::FormulaInstruction
small class use to define a formula instruction
Definition: MWAWCell.hxx:360
MWAWCellContent::Type
Type
the different types of cell's field
Definition: MWAWCell.hxx:391
ClarisWksDbaseContent::readCellInFormula
bool readCellInFormula(Vec2i const &pos, MWAWCellContent::FormulaInstruction &instr)
reads a cell
Definition: ClarisWksDbaseContent.cxx:1136
ClarisWksDbaseContent::Column
struct which stores a column in ClarisWksDbaseContent
Definition: ClarisWksDbaseContent.hxx:110
ClarisWksDbaseContent::readContent
bool readContent()
try to read the record structure
Definition: ClarisWksDbaseContent.cxx:134
ClarisWksDbaseContent::Record::m_fileFormat
int m_fileFormat
the format ( in a v1-3 spreadsheet)
Definition: ClarisWksDbaseContent.hxx:94
ClarisWksDbaseContent::Column::Column
Column()
constructor
Definition: ClarisWksDbaseContent.hxx:112
ClarisWksDbaseContent::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition: ClarisWksDbaseContent.hxx:157
ClarisWksDbaseContent::getExtrema
bool getExtrema(Vec2i &min, Vec2i &max) const
returns the dimension of the read data
Definition: ClarisWksDbaseContent.cxx:82
ClarisWksDbaseContent::Record::m_format
MWAWCell::Format m_format
the format
Definition: ClarisWksDbaseContent.hxx:90
ClarisWksDbaseContent::m_dbFormatList
std::vector< ClarisWksStyleManager::CellFormat > m_dbFormatList
the databse format
Definition: ClarisWksDbaseContent.hxx:162
MWAWEntry.hxx
libmwaw_internal.hxx
ClarisWksDbaseContent::getRecordList
bool getRecordList(std::vector< int > &list) const
returns the list of filled record (for database)
Definition: ClarisWksDbaseContent.cxx:111
MWAWCell::Format
a structure uses to define the format of a cell content
Definition: MWAWCell.hxx:60
ClarisWksDbaseContent::readRecordSSV1
bool readRecordSSV1(Vec2i const &where, long pos, Record &record)
try to read a spreadsheet record(v1-v3)
Definition: ClarisWksDbaseContent.cxx:397
ClarisWksDbaseContent::Column::m_idRecordMap
std::map< int, Record > m_idRecordMap
a map line (or record id) to record
Definition: ClarisWksDbaseContent.hxx:116
ClarisWksDbaseContent::Record::m_backgroundColor
MWAWColor m_backgroundColor
the background color
Definition: ClarisWksDbaseContent.hxx:102
ClarisWksDbaseContent::readColumnList
bool readColumnList()
try to read the columns list structure(CTAB)
Definition: ClarisWksDbaseContent.cxx:199
ClarisWksDbaseContent::readRecordSS
bool readRecordSS(Vec2i const &where, long pos, Record &record)
try to read a spreadsheet record
Definition: ClarisWksDbaseContent.cxx:687
ClarisWksDbaseContent::readNumber
bool readNumber(long endPos, double &res, bool &isNan)
try to read a number
Definition: ClarisWksDbaseContent.cxx:1189
ClarisWksDbaseContent::ClarisWksDbaseContent
ClarisWksDbaseContent(ClarisWksDocument &document, bool spreadsheet)
constructor
Definition: ClarisWksDbaseContent.cxx:59
ClarisWksDbaseContent::readFormula
bool readFormula(Vec2i const &cPos, long endPos, std::vector< MWAWCellContent::FormulaInstruction > &formula, std::string &error)
read to read a formula
Definition: ClarisWksDbaseContent.cxx:1216
ClarisWksDbaseContent::m_idColumnMap
std::map< int, Column > m_idColumnMap
a map col id to column
Definition: ClarisWksDbaseContent.hxx:160
MWAWCell::HorizontalAlignment
HorizontalAlignment
the default horizontal alignment.
Definition: MWAWCell.hxx:118
MWAWCell
a structure used to define a cell and its format
Definition: MWAWCell.hxx:52
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:167
MWAWCellContent
small class use to define a sheet cell content
Definition: MWAWCell.hxx:356
ClarisWksStyleManager.hxx
ClarisWksDbaseContent::m_isSpreadsheet
bool m_isSpreadsheet
a bool to know if this is a spreadsheet or a database
Definition: ClarisWksDbaseContent.hxx:152
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:44
ClarisWksDbaseContent::Record::m_hasNaNValue
bool m_hasNaNValue
a flag to know if a double result is nan or not
Definition: ClarisWksDbaseContent.hxx:100
ClarisWksDocument
main document information used to create a ClarisWorks file
Definition: ClarisWksDocument.hxx:72
ClarisWksDbaseContent::Record::m_content
MWAWCellContent m_content
the content
Definition: ClarisWksDbaseContent.hxx:96
ClarisWksDbaseContent
small structure used to parse main content of a spreadsheet/database zone
Definition: ClarisWksDbaseContent.hxx:56
MWAWFont.hxx
ClarisWksDbaseContent::Record::m_font
MWAWFont m_font
the font ( in v1-3 spreadsheet)
Definition: ClarisWksDbaseContent.hxx:104
ClarisWksDbaseContent::Record::m_hAlign
MWAWCell::HorizontalAlignment m_hAlign
the cell alignment : by default nothing
Definition: ClarisWksDbaseContent.hxx:92
ClarisWksDbaseContent::Record
struct which stores a record in ClarisWksDbaseContent
Definition: ClarisWksDbaseContent.hxx:80
ClarisWksDbaseContent::readString
bool readString(long endPos, std::string &res)
try to read a string
Definition: ClarisWksDbaseContent.cxx:1174
ClarisWksDbaseContent::readRecordList
bool readRecordList(Vec2i const &where, Column &col)
try to read a list of records(CHNK)
Definition: ClarisWksDbaseContent.cxx:318
ClarisWksDbaseContent::readColumn
bool readColumn(int c)
try to read the column structure(COLM): a list of chnk
Definition: ClarisWksDbaseContent.cxx:265
ClarisWksStyleManager::CellFormat
the CELL structure a structure related to number/date format
Definition: ClarisWksStyleManager.hxx:149
ClarisWksDbaseContent::Record::m_borders
int m_borders
the border in v1-3 spreadsheet
Definition: ClarisWksDbaseContent.hxx:106
ClarisWksDbaseContent::m_version
int m_version
the file version
Definition: ClarisWksDbaseContent.hxx:150
ClarisWksDbaseContent::readRecordDB
bool readRecordDB(Vec2i const &where, long pos, Record &record)
try to read a database record
Definition: ClarisWksDbaseContent.cxx:934
ClarisWksDbaseContent::m_document
ClarisWksDocument & m_document
the document
Definition: ClarisWksDbaseContent.hxx:155
MWAWCell.hxx
Defines MWAWCell (cell content and format)
MWAWParserStatePtr
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:435
Vec2< int >
ClarisWksDbaseContent::~ClarisWksDbaseContent
~ClarisWksDbaseContent()
destructor
Definition: ClarisWksDbaseContent.cxx:69
ClarisWksDbaseContent::setDatabaseFormats
void setDatabaseFormats(std::vector< ClarisWksStyleManager::CellFormat > const &format)
set the field format ( for database )
Definition: ClarisWksDbaseContent.cxx:73
ClarisWksDbaseContent::send
bool send(Vec2i const &pos)
try to send a cell content to the listener
Definition: ClarisWksDbaseContent.cxx:1056
ClarisWksDbaseContent::Record::m_valueType
MWAWCellContent::Type m_valueType
the type of the content value ( original or result of a formula )
Definition: ClarisWksDbaseContent.hxx:98
ClarisWksDbaseContent::Record::m_style
int m_style
the style if known
Definition: ClarisWksDbaseContent.hxx:88
ClarisWksDbaseContent::Record::Record
Record()
contructor
Definition: ClarisWksDbaseContent.hxx:82