ClarisWksDbaseContent.hxx
Go to the documentation of this file.
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
/* libmwaw
* Version: MPL 2.0 / LGPLv2+
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
*
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
* in which case the provisions of the LGPLv2+ are applicable
* instead of those above.
*/
/*
* The main database content used by Claris Works parser to store spreedsheet/Databese
*
*/
#ifndef CLARIS_WKS_DBASE_CONTENT
# define CLARIS_WKS_DBASE_CONTENT
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include "libmwaw_internal.hxx"
#include "MWAWCell.hxx"
#include "MWAWEntry.hxx"
#include "MWAWFont.hxx"
#include "ClarisWksStyleManager.hxx"
class ClarisWksDocument;
class ClarisWksDbaseContent
{
public:
struct Record;
ClarisWksDbaseContent(ClarisWksDocument &document, bool spreadsheet);
~ClarisWksDbaseContent();
bool readContent();
bool readFormula(MWAWVec2i const &cPos, long endPos,
std::vector<MWAWCellContent::FormulaInstruction> &formula, std::string &error);
bool getExtrema(MWAWVec2i &min, MWAWVec2i &max) const;
bool getRecordList(std::vector<int> &list) const;
bool getColumnList(int row, std::vector<int> &list) const;
bool get(MWAWVec2i const &pos, Record &data) const;
bool send(MWAWVec2i const &pos);
void setDatabaseFormats(std::vector<ClarisWksStyleManager::CellFormat> const &format);
struct Record {
Record()
: m_style(-1)
, m_format()
, m_hAlign(MWAWCell::HALIGN_DEFAULT)
, m_fileFormat(0)
, m_content()
, m_valueType(MWAWCellContent::C_UNKNOWN)
, m_hasNaNValue(false)
, m_backgroundColor(MWAWColor::white())
, m_font(3,9)
, m_borders(0)
, m_posToFontMap()
{
}
void updateFormulaCells(MWAWVec2i const &removeDelta);
int m_style;
MWAWCell::Format m_format;
MWAWCell::HorizontalAlignment m_hAlign;
int m_fileFormat;
MWAWCellContent m_content;
MWAWCellContent::Type m_valueType;
bool m_hasNaNValue;
MWAWColor m_backgroundColor;
MWAWFont m_font;
int m_borders;
std::map<int, MWAWFont> m_posToFontMap;
};
protected:
struct Column {
Column()
: m_idRecordMap()
{
}
std::map<int,Record> m_idRecordMap;
};
bool readColumnList();
bool readColumn(int c);
bool readRecordList(MWAWVec2i const &where, Column &col);
bool readRecordSS(MWAWVec2i const &where, long pos, Record &record);
bool readRecordSSV1(MWAWVec2i const &where, long pos, Record &record);
bool readRecordDB(MWAWVec2i const &where, long pos, Record &record);
void send(double val, bool isNotaNumber, ClarisWksStyleManager::CellFormat const &format);
//
// low level
//
bool readCellInFormula(MWAWVec2i const &pos, MWAWCellContent::FormulaInstruction &instr);
bool readString(long endPos, std::string &res);
bool readNumber(long endPos, double &res, bool &isNan);
void updateCellPositionsSet() const;
int m_version;
bool m_isSpreadsheet;
ClarisWksDocument &m_document;
MWAWParserStatePtr m_parserState;
std::map<int, Column> m_idColumnMap;
mutable std::set<MWAWVec2i> m_positionSet;
std::vector<ClarisWksStyleManager::CellFormat> m_dbFormatList;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
ClarisWksStyleManager.hxx
MWAWCell.hxx
Defines MWAWCell (cell content and format).
MWAWEntry.hxx
MWAWFont.hxx
ClarisWksDbaseContent::readRecordSSV1
bool readRecordSSV1(MWAWVec2i const &where, long pos, Record &record)
try to read a spreadsheet record(v1-v3)
Definition ClarisWksDbaseContent.cxx:428
ClarisWksDbaseContent::readColumnList
bool readColumnList()
try to read the columns list structure(CTAB)
Definition ClarisWksDbaseContent.cxx:230
ClarisWksDbaseContent::m_idColumnMap
std::map< int, Column > m_idColumnMap
a map col id to column
Definition ClarisWksDbaseContent.hxx:179
ClarisWksDbaseContent::m_positionSet
std::set< MWAWVec2i > m_positionSet
a set of cell position (sorted by row)
Definition ClarisWksDbaseContent.hxx:181
ClarisWksDbaseContent::getRecordList
bool getRecordList(std::vector< int > &list) const
returns the list of filled record/row
Definition ClarisWksDbaseContent.cxx:129
ClarisWksDbaseContent::m_version
int m_version
the file version
Definition ClarisWksDbaseContent.hxx:169
ClarisWksDbaseContent::readString
bool readString(long endPos, std::string &res)
try to read a string
Definition ClarisWksDbaseContent.cxx:1261
ClarisWksDbaseContent::getColumnList
bool getColumnList(int row, std::vector< int > &list) const
returns the list of filled columns
Definition ClarisWksDbaseContent.cxx:147
ClarisWksDbaseContent::readColumn
bool readColumn(int c)
try to read the column structure(COLM): a list of chnk
Definition ClarisWksDbaseContent.cxx:296
ClarisWksDbaseContent::readFormula
bool readFormula(MWAWVec2i const &cPos, long endPos, std::vector< MWAWCellContent::FormulaInstruction > &formula, std::string &error)
read to read a formula
Definition ClarisWksDbaseContent.cxx:1303
ClarisWksDbaseContent::getExtrema
bool getExtrema(MWAWVec2i &min, MWAWVec2i &max) const
returns the dimension of the read data
Definition ClarisWksDbaseContent.cxx:88
ClarisWksDbaseContent::m_isSpreadsheet
bool m_isSpreadsheet
a bool to know if this is a spreadsheet or a database
Definition ClarisWksDbaseContent.hxx:171
ClarisWksDbaseContent::m_document
ClarisWksDocument & m_document
the document
Definition ClarisWksDbaseContent.hxx:174
ClarisWksDbaseContent::m_dbFormatList
std::vector< ClarisWksStyleManager::CellFormat > m_dbFormatList
the databse format
Definition ClarisWksDbaseContent.hxx:183
ClarisWksDbaseContent::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition ClarisWksDbaseContent.hxx:176
ClarisWksDbaseContent::setDatabaseFormats
void setDatabaseFormats(std::vector< ClarisWksStyleManager::CellFormat > const &format)
set the field format ( for database )
Definition ClarisWksDbaseContent.cxx:79
ClarisWksDbaseContent::ClarisWksDbaseContent
ClarisWksDbaseContent(ClarisWksDocument &document, bool spreadsheet)
constructor
Definition ClarisWksDbaseContent.cxx:59
ClarisWksDbaseContent::readNumber
bool readNumber(long endPos, double &res, bool &isNan)
try to read a number
Definition ClarisWksDbaseContent.cxx:1276
ClarisWksDbaseContent::readCellInFormula
bool readCellInFormula(MWAWVec2i const &pos, MWAWCellContent::FormulaInstruction &instr)
reads a cell
Definition ClarisWksDbaseContent.cxx:1223
ClarisWksDbaseContent::readRecordSS
bool readRecordSS(MWAWVec2i const &where, long pos, Record &record)
try to read a spreadsheet record
Definition ClarisWksDbaseContent.cxx:718
ClarisWksDbaseContent::readRecordList
bool readRecordList(MWAWVec2i const &where, Column &col)
try to read a list of records(CHNK)
Definition ClarisWksDbaseContent.cxx:349
ClarisWksDbaseContent::~ClarisWksDbaseContent
~ClarisWksDbaseContent()
destructor
Definition ClarisWksDbaseContent.cxx:75
ClarisWksDbaseContent::get
bool get(MWAWVec2i const &pos, Record &data) const
retrieves the cell data
Definition ClarisWksDbaseContent.cxx:1113
ClarisWksDbaseContent::readContent
bool readContent()
try to read the record structure
Definition ClarisWksDbaseContent.cxx:165
ClarisWksDbaseContent::send
bool send(MWAWVec2i const &pos)
try to send a cell content to the listener
Definition ClarisWksDbaseContent.cxx:1137
ClarisWksDbaseContent::updateCellPositionsSet
void updateCellPositionsSet() const
update the position set
Definition ClarisWksDbaseContent.cxx:115
ClarisWksDbaseContent::readRecordDB
bool readRecordDB(MWAWVec2i const &where, long pos, Record &record)
try to read a database record
Definition ClarisWksDbaseContent.cxx:982
ClarisWksDocument
main document information used to create a ClarisWorks file
Definition ClarisWksDocument.hxx:74
MWAWCellContent
small class use to define a sheet cell content
Definition MWAWCell.hxx:394
MWAWCellContent::Type
Type
the different types of cell's field
Definition MWAWCell.hxx:433
MWAWCell
a structure used to define a cell and its format
Definition MWAWCell.hxx:53
MWAWCell::HorizontalAlignment
HorizontalAlignment
the default horizontal alignment.
Definition MWAWCell.hxx:128
MWAWFont
Class to store font.
Definition MWAWFont.hxx:44
libmwaw_internal.hxx
MWAWVec2i
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition libmwaw_internal.hxx:838
MWAWParserStatePtr
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition libmwaw_internal.hxx:557
ClarisWksDbaseContent::Column
struct which stores a column in ClarisWksDbaseContent
Definition ClarisWksDbaseContent.hxx:129
ClarisWksDbaseContent::Column::Column
Column()
constructor
Definition ClarisWksDbaseContent.hxx:131
ClarisWksDbaseContent::Column::m_idRecordMap
std::map< int, Record > m_idRecordMap
a map line (or record id) to record
Definition ClarisWksDbaseContent.hxx:136
ClarisWksDbaseContent::Record
struct which stores a record in ClarisWksDbaseContent
Definition ClarisWksDbaseContent.hxx:86
ClarisWksDbaseContent::Record::m_hAlign
MWAWCell::HorizontalAlignment m_hAlign
the cell alignment : by default nothing
Definition ClarisWksDbaseContent.hxx:109
ClarisWksDbaseContent::Record::m_font
MWAWFont m_font
the font ( in v1-3 spreadsheet)
Definition ClarisWksDbaseContent.hxx:121
ClarisWksDbaseContent::Record::m_fileFormat
int m_fileFormat
the format ( in a v1-3 spreadsheet)
Definition ClarisWksDbaseContent.hxx:111
ClarisWksDbaseContent::Record::m_borders
int m_borders
the border in v1-3 spreadsheet
Definition ClarisWksDbaseContent.hxx:123
ClarisWksDbaseContent::Record::m_valueType
MWAWCellContent::Type m_valueType
the type of the content value ( original or result of a formula )
Definition ClarisWksDbaseContent.hxx:115
ClarisWksDbaseContent::Record::m_backgroundColor
MWAWColor m_backgroundColor
the background color
Definition ClarisWksDbaseContent.hxx:119
ClarisWksDbaseContent::Record::m_hasNaNValue
bool m_hasNaNValue
a flag to know if a double result is nan or not
Definition ClarisWksDbaseContent.hxx:117
ClarisWksDbaseContent::Record::m_style
int m_style
the style if known
Definition ClarisWksDbaseContent.hxx:105
ClarisWksDbaseContent::Record::Record
Record()
contructor
Definition ClarisWksDbaseContent.hxx:88
ClarisWksDbaseContent::Record::updateFormulaCells
void updateFormulaCells(MWAWVec2i const &removeDelta)
update the formula cell (removing delta to each position)
Definition ClarisWksDbaseContent.cxx:1502
ClarisWksDbaseContent::Record::m_posToFontMap
std::map< int, MWAWFont > m_posToFontMap
map id to font ( in database)
Definition ClarisWksDbaseContent.hxx:125
ClarisWksDbaseContent::Record::m_format
MWAWCell::Format m_format
the format
Definition ClarisWksDbaseContent.hxx:107
ClarisWksDbaseContent::Record::m_content
MWAWCellContent m_content
the content
Definition ClarisWksDbaseContent.hxx:113
ClarisWksStyleManager::CellFormat
the CELL structure a structure related to number/date format
Definition ClarisWksStyleManager.hxx:151
MWAWCellContent::FormulaInstruction
small class use to define a formula instruction
Definition MWAWCell.hxx:397
MWAWCell::Format
a structure uses to define the format of a cell content
Definition MWAWCell.hxx:60
MWAWColor
the class to store a color
Definition libmwaw_internal.hxx:192