140 lines
2.9 KiB
C++
140 lines
2.9 KiB
C++
#ifndef _WORKSHT_WORKSHEET_HPP_
|
|
#define _WORKSHT_WORKSHEET_HPP_
|
|
#ifndef _COMMON_ARRAY_HPP_
|
|
#include <common/array.hpp>
|
|
#endif
|
|
#ifndef _COMMON_SMARTPOINTER_HPP_
|
|
#include <common/pointer.hpp>
|
|
#endif
|
|
#ifndef _COMMON_ASSERT_HPP_
|
|
#include <common/assert.hpp>
|
|
#endif
|
|
#ifndef _WORKSHT_RECORD_HPP_
|
|
#include <worksht/record.hpp>
|
|
#endif
|
|
#ifndef _WORKSHT_LABEL_HPP_
|
|
#include <worksht/label.hpp>
|
|
#endif
|
|
#ifndef _WORKSHT_NUMBER_HPP_
|
|
#include <worksht/number.hpp>
|
|
#endif
|
|
#ifndef _WORKSHT_INTEGER_HPP_
|
|
#include <worksht/integer.hpp>
|
|
#endif
|
|
#ifndef _FILEIO_FILEIO_HPP_
|
|
#include <fileio/fileio.hpp>
|
|
#endif
|
|
|
|
class Worksheet
|
|
{
|
|
public:
|
|
typedef Array<SmartPointer<Record> > ColumnData;
|
|
Worksheet(void);
|
|
virtual ~Worksheet();
|
|
ColumnData &operator[](UINT index);
|
|
UINT rows(void)const;
|
|
UINT cols(void)const;
|
|
void setDimensions(UINT rows,UINT cols);
|
|
bool setAt(int row,int col,SmartPointer<Record> &record);
|
|
bool setAt(int row,int col,const String &strLabel);
|
|
bool setAt(int row,int col,WORD value);
|
|
BOOL open(const String &strPathFileName);
|
|
BOOL save(const String &strPathFileName);
|
|
BOOL saveText(const String &strPathFileName);
|
|
BOOL isOkay(void)const;
|
|
protected:
|
|
virtual void processEvents(void);
|
|
private:
|
|
enum{MaxColumn=16384};
|
|
Worksheet(const Worksheet &someWorksheet);
|
|
Worksheet &operator=(const Worksheet &someWorksheet);
|
|
BOOL operator==(const Worksheet &someWorksheet);
|
|
Array<ColumnData> mMatrix;
|
|
Record mLotusRecord;
|
|
UINT mRows;
|
|
UINT mCols;
|
|
};
|
|
|
|
inline
|
|
Worksheet::Worksheet(void)
|
|
: mRows(0), mCols(0)
|
|
{
|
|
}
|
|
|
|
inline
|
|
Worksheet::Worksheet(const Worksheet &someWorksheet)
|
|
{ // private implmentation
|
|
*this=someWorksheet;
|
|
}
|
|
|
|
inline
|
|
Worksheet::~Worksheet()
|
|
{
|
|
}
|
|
|
|
inline
|
|
Worksheet &Worksheet::operator=(const Worksheet &/*someWorksheet*/)
|
|
{ // private implementation
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
BOOL Worksheet::operator==(const Worksheet &/*someWorksheet*/)
|
|
{ // private implementation
|
|
return FALSE;
|
|
}
|
|
|
|
inline
|
|
Worksheet::ColumnData &Worksheet::operator[](UINT index)
|
|
{
|
|
assert(index<mMatrix.size());
|
|
return mMatrix[index];
|
|
}
|
|
|
|
inline
|
|
UINT Worksheet::rows(void)const
|
|
{
|
|
return mRows;
|
|
}
|
|
|
|
inline
|
|
UINT Worksheet::cols(void)const
|
|
{
|
|
return mCols;
|
|
}
|
|
|
|
inline
|
|
bool Worksheet::setAt(int row,int col,SmartPointer<Record> &record)
|
|
{
|
|
if(row>=rows()||col>=cols())return false;
|
|
record.disposition(PointerDisposition::Assume);
|
|
(mMatrix[row])[col]=record;
|
|
(mMatrix[row])[col].disposition(PointerDisposition::Delete);
|
|
return true;
|
|
}
|
|
|
|
inline
|
|
bool Worksheet::setAt(int row,int col,const String &strLabel)
|
|
{
|
|
SmartPointer<Record> label=new Label(row,col,strLabel);
|
|
setAt(row,col,label);
|
|
return true;
|
|
}
|
|
|
|
inline
|
|
bool Worksheet::setAt(int row,int col,WORD value)
|
|
{
|
|
if(row>=rows()||col>=cols())return false;
|
|
SmartPointer<Record> integer=new Integer(row,col,value);
|
|
integer.disposition(PointerDisposition::Assume);
|
|
(mMatrix[row])[col]=integer;
|
|
(mMatrix[row])[col].disposition(PointerDisposition::Delete);
|
|
return true;
|
|
}
|
|
|
|
inline
|
|
BOOL Worksheet::isOkay(void)const
|
|
{
|
|
return (rows()&&cols());
|
|
}
|
|
#endif |