// CodeGear C++Builder
// Copyright (c) 1995, 2011 by Embarcadero Technologies, Inc.
// All rights reserved

// (DO NOT EDIT: machine generated header) 'SMCells.pas' rev: 23.00 (Win32)

#ifndef SmcellsHPP
#define SmcellsHPP

#pragma delphiheader begin
#pragma option push
#pragma option -w-      // All warnings off
#pragma option -Vx      // Zero-length empty class member functions
#pragma pack(push,8)
#include <System.hpp>	// Pascal unit
#include <SysInit.hpp>	// Pascal unit
#include <System.Classes.hpp>	// Pascal unit
#include <System.SysUtils.hpp>	// Pascal unit
#include <Winapi.Windows.hpp>	// Pascal unit
#include <System.Variants.hpp>	// Pascal unit

//-- user supplied -----------------------------------------------------------

namespace Smcells
{
//-- type declarations -------------------------------------------------------
#pragma option push -b-
enum TSMICellType : unsigned char { ictUnknown, ictEmpty, ictString, ictInteger, ictDecimal, ictDateTime, ictBoolean, ictMemo, ictDate, ictTime };
#pragma option pop

typedef void __fastcall (*TProgressPreviewCallback)(int Position, int TotalSize);

typedef void __fastcall (__closure *TOnColumnWidth)(System::TObject* Sender, int SheetNo, int ColumnNo, int Width);

typedef void __fastcall (__closure *TOnRowHeight)(System::TObject* Sender, int SheetNo, int RowNo, int Height);

typedef void __fastcall (__closure *TOnDimensions)(System::TObject* Sender, int SheetNo, int FirstRow, int LastRow, int FirstColumn, int LastColumn);

typedef void __fastcall (__closure *TOnCellValue)(System::TObject* Sender, int SheetNo, int Row, int Column, int FormatIndex, const System::Variant &Value, System::Classes::TAlignment Alignment, TSMICellType CellType);

typedef void __fastcall (__closure *TOnGetCellValue)(System::TObject* Sender, int SheetNo, int Row, int Column, System::Variant &Value);

typedef void __fastcall (__closure *TOnSheet)(System::TObject* Sender, System::WideString Caption, int Index, bool &Skip);

typedef void __fastcall (__closure *TSMIOnPasswordEvent)(System::TObject* Sender, System::UnicodeString &APassword, bool &Continue);

#pragma pack(push,1)
struct DECLSPEC_DRECORD TBIFFRecordHeader
{
	
public:
	System::Word ID;
	System::Word Len;
};
#pragma pack(pop)


#pragma pack(push,1)
struct DECLSPEC_DRECORD TBIFF12RecordHeader
{
	
public:
	unsigned ID;
	unsigned Len;
};
#pragma pack(pop)


typedef void __fastcall (__closure *TOnRecord)(System::TObject* Sender, TBIFFRecordHeader Header, System::Byte *Data);

class DELPHICLASS TSMICell;
class PASCALIMPLEMENTATION TSMICell : public System::Classes::TPersistent
{
	typedef System::Classes::TPersistent inherited;
	
private:
	System::Variant FValue;
	System::Classes::TAlignment FAlignment;
	int FFormatIndex;
	TSMICellType FCellType;
	
public:
	virtual void __fastcall Assign(System::Classes::TPersistent* Source);
	
__published:
	__property System::Variant Value = {read=FValue, write=FValue};
	__property System::Classes::TAlignment Alignment = {read=FAlignment, write=FAlignment, default=0};
	__property int FormatIndex = {read=FFormatIndex, write=FFormatIndex, nodefault};
	__property TSMICellType CellType = {read=FCellType, write=FCellType, default=0};
public:
	/* TPersistent.Destroy */ inline __fastcall virtual ~TSMICell(void) { }
	
public:
	/* TObject.Create */ inline __fastcall TSMICell(void) : System::Classes::TPersistent() { }
	
};


class DELPHICLASS TSpreadSheetCols;
#pragma pack(push,4)
class PASCALIMPLEMENTATION TSpreadSheetCols : public System::Classes::TList
{
	typedef System::Classes::TList inherited;
	
public:
	TSMICell* __fastcall GetCell(int Col);
	void __fastcall SetCell(int Col, TSMICell* Value);
public:
	/* TList.Destroy */ inline __fastcall virtual ~TSpreadSheetCols(void) { }
	
public:
	/* TObject.Create */ inline __fastcall TSpreadSheetCols(void) : System::Classes::TList() { }
	
};

#pragma pack(pop)

#pragma option push -b-
enum TSMIRowStatus : unsigned char { rsNormal, rsDeleted, rsError };
#pragma option pop

typedef System::Set<TSMIRowStatus, TSMIRowStatus::rsNormal, TSMIRowStatus::rsError>  TSMIRowStatuses;

class DELPHICLASS TSpreadSheetRow;
#pragma pack(push,4)
class PASCALIMPLEMENTATION TSpreadSheetRow : public System::Classes::TPersistent
{
	typedef System::Classes::TPersistent inherited;
	
private:
	int FOriginalRecNo;
	TSMIRowStatus FStatus;
	bool FVisible;
	
public:
	int Index;
	TSpreadSheetCols* Cols;
	__fastcall virtual TSpreadSheetRow(void);
	__fastcall virtual ~TSpreadSheetRow(void);
	void __fastcall ClearValues(void);
	__property int OriginalRecNo = {read=FOriginalRecNo, write=FOriginalRecNo, nodefault};
	__property TSMIRowStatus Status = {read=FStatus, write=FStatus, default=0};
	__property bool Visible = {read=FVisible, write=FVisible, default=1};
};

#pragma pack(pop)

class DELPHICLASS TSpreadSheetCells;
#pragma pack(push,4)
class PASCALIMPLEMENTATION TSpreadSheetCells : public System::Classes::TList
{
	typedef System::Classes::TList inherited;
	
private:
	int FColCount;
	int FRowCount;
	int FUsedColCount;
	int FUsedRowCount;
	
public:
	bool AutoUsedRangeDetect;
	__fastcall virtual TSpreadSheetCells(void);
	__fastcall virtual ~TSpreadSheetCells(void);
	int __fastcall AddRow(int i);
	void __fastcall RemoveRow(int i);
	virtual void __fastcall Clear(void);
	void __fastcall ClearSort(void);
	void __fastcall SortByColumn(int AColIndex, bool Ascending);
	System::Variant __fastcall GetValue(int Col, int Row);
	void __fastcall SetValue(int Col, int Row, const System::Variant &Value, System::Classes::TAlignment Alignment, int FormatIndex, TSMICellType CellType);
	System::Variant __fastcall ValueByCell(const System::UnicodeString ACellRange);
	System::Variant __fastcall ValueByRange(const System::UnicodeString ARange);
	__property int UsedColCount = {read=FUsedColCount, nodefault};
	__property int UsedRowCount = {read=FUsedRowCount, nodefault};
	__property int ColCount = {read=FColCount, write=FColCount, nodefault};
	__property int RowCount = {read=FRowCount, write=FRowCount, nodefault};
};

#pragma pack(pop)

class DELPHICLASS TSpreadSheet;
#pragma pack(push,4)
class PASCALIMPLEMENTATION TSpreadSheet : public System::Classes::TComponent
{
	typedef System::Classes::TComponent inherited;
	
public:
	TSpreadSheetCells* Cells;
	System::WideString Caption;
	System::Classes::TList* ColWidths;
	__fastcall virtual TSpreadSheet(System::Classes::TComponent* AOwner);
	__fastcall virtual ~TSpreadSheet(void);
	System::UnicodeString __fastcall PlainText(void);
};

#pragma pack(pop)

class DELPHICLASS TSpreadSheets;
#pragma pack(push,4)
class PASCALIMPLEMENTATION TSpreadSheets : public System::Classes::TList
{
	typedef System::Classes::TList inherited;
	
public:
	__fastcall virtual ~TSpreadSheets(void);
	HIDESBASE int __fastcall Add(void);
	HIDESBASE void __fastcall Remove(int Index);
	virtual void __fastcall Clear(void);
	TSpreadSheet* __fastcall Spreadsheet(int Index);
	TSpreadSheet* __fastcall SheetByName(const System::WideString Value);
	int __fastcall SheetIndexByName(const System::WideString Value);
public:
	/* TObject.Create */ inline __fastcall TSpreadSheets(void) : System::Classes::TList() { }
	
};

#pragma pack(pop)

class DELPHICLASS TSMRange;
#pragma pack(push,4)
class PASCALIMPLEMENTATION TSMRange : public System::Classes::TPersistent
{
	typedef System::Classes::TPersistent inherited;
	
private:
	int FFirstRow;
	int FLastRow;
	int FFirstCol;
	int FLastCol;
	
public:
	__fastcall virtual TSMRange(void);
	virtual void __fastcall Assign(System::Classes::TPersistent* Source);
	
__published:
	__property int FirstRow = {read=FFirstRow, write=FFirstRow, default=1};
	__property int LastRow = {read=FLastRow, write=FLastRow, default=2147483647};
	__property int FirstCol = {read=FFirstCol, write=FFirstCol, default=1};
	__property int LastCol = {read=FLastCol, write=FLastCol, default=2147483647};
public:
	/* TPersistent.Destroy */ inline __fastcall virtual ~TSMRange(void) { }
	
};

#pragma pack(pop)

typedef void __fastcall (__closure *TErrorParseRecord)(System::TObject* Sender, System::Sysutils::Exception* Error, bool &Abort);

typedef void __fastcall (__closure *TOnRecordStatusChanged)(System::TObject* Sender, int SheetNo, TSpreadSheetRow* ARow, TSMIRowStatus AStatus);

class DELPHICLASS TCustomSpreadSheetFile;
class PASCALIMPLEMENTATION TCustomSpreadSheetFile : public System::Classes::TComponent
{
	typedef System::Classes::TComponent inherited;
	
private:
	System::UnicodeString FFileName;
	TErrorParseRecord FOnErrorProcess;
	bool FLoadNULLs;
	int FSheetIndex;
	TSMRange* FLoadRange;
	TOnColumnWidth FOnColumnWidth;
	TOnRowHeight FOnRowHeight;
	TOnDimensions FOnDimensions;
	TOnCellValue FOnCellValue;
	TOnGetCellValue FOnGetCellValue;
	TOnSheet FOnSheet;
	TOnRecord FOnRecord;
	TOnRecordStatusChanged FOnRecordStatusChanged;
	void __fastcall SetLoadRange(TSMRange* Value);
	
public:
	bool IsIncrementalLoad;
	__fastcall virtual TCustomSpreadSheetFile(System::Classes::TComponent* AOwner);
	__fastcall virtual ~TCustomSpreadSheetFile(void);
	virtual bool __fastcall IsEncrypted(void);
	__property int SheetIndex = {read=FSheetIndex, write=FSheetIndex, default=-1};
	__property TSMRange* LoadRange = {read=FLoadRange, write=SetLoadRange};
	
__published:
	__property System::UnicodeString FileName = {read=FFileName, write=FFileName};
	__property bool LoadNULLs = {read=FLoadNULLs, write=FLoadNULLs, default=0};
	__property TOnColumnWidth OnColumnWidth = {read=FOnColumnWidth, write=FOnColumnWidth};
	__property TOnRowHeight OnRowHeight = {read=FOnRowHeight, write=FOnRowHeight};
	__property TOnDimensions OnDimensions = {read=FOnDimensions, write=FOnDimensions};
	__property TOnCellValue OnCellValue = {read=FOnCellValue, write=FOnCellValue};
	__property TOnGetCellValue OnGetCellValue = {read=FOnGetCellValue, write=FOnGetCellValue};
	__property TOnSheet OnSheet = {read=FOnSheet, write=FOnSheet};
	__property TOnRecord OnRecord = {read=FOnRecord, write=FOnRecord};
	__property TOnRecordStatusChanged OnRecordStatusChanged = {read=FOnRecordStatusChanged, write=FOnRecordStatusChanged};
	__property TErrorParseRecord OnErrorProcess = {read=FOnErrorProcess, write=FOnErrorProcess};
};


typedef void __fastcall (__closure *TOnLoadProgress)(System::TObject* Sender, int Position, int TotalSize);

#pragma option push -b-
enum TSMIColumnNameKind : unsigned char { nkAlphabet, nkFieldName };
#pragma option pop

class DELPHICLASS TSpreadSheetFile;
class PASCALIMPLEMENTATION TSpreadSheetFile : public TCustomSpreadSheetFile
{
	typedef TCustomSpreadSheetFile inherited;
	
private:
	bool FParseBLOB;
	TOnLoadProgress FOnLoadProgress;
	TSMIColumnNameKind FNameKind;
	TSMIRowStatuses FLoadRowStatutes;
	void __fastcall DimsEvent(System::TObject* Sender, int SheetNo, int FirstRow, int LastRow, int FirstColumn, int LastColumn);
	void __fastcall SetCellEvent(System::TObject* Sender, int SheetNo, int Row, int Column, int FormatIndex, const System::Variant &Value, System::Classes::TAlignment Alignment, TSMICellType CellType);
	void __fastcall GetCellEvent(System::TObject* Sender, int SheetNo, int Row, int Column, System::Variant &Value);
	void __fastcall SheetEvent(System::TObject* Sender, System::WideString Caption, int Index, bool &Skip);
	void __fastcall ColumnWidthEvent(System::TObject* Sender, int SheetNo, int ColumnNo, int Width);
	
protected:
	TBIFFRecordHeader BufferHeader;
	bool CheckFileExists;
	void __fastcall UpdateProgress(int Position, int TotalSize);
	virtual void __fastcall ApplyEvents(void);
	virtual void __fastcall ReadBLOBValue(unsigned BlockNo, unsigned ASize, System::UnicodeString &s);
	void __fastcall SetRowStatus(int ASheetNo, int ARow, TSMIRowStatus AStatus);
	virtual void __fastcall InternalLoadFromOLEStream(System::Classes::TStream* Stream);
	
public:
	TSpreadSheets* Sheets;
	TProgressPreviewCallback ReadProgressCallback;
	int LastLoadedRecNo;
	__fastcall virtual TSpreadSheetFile(System::Classes::TComponent* AOwner);
	__fastcall virtual ~TSpreadSheetFile(void);
	virtual void __fastcall LoadFromFile(const System::WideString FileName);
	virtual void __fastcall LoadFromStream(System::Classes::TStream* AStream);
	virtual void __fastcall LoadFromOLEStream(System::Classes::TStream* AStream);
	virtual void __fastcall BeforeLoad(void);
	virtual void __fastcall AfterLoad(void);
	virtual bool __fastcall LoadRecord(int RecNo);
	virtual int __fastcall FindColumn(const System::UnicodeString AFieldName);
	virtual void __fastcall FillColumnList(System::Classes::TStrings* lst, const System::UnicodeString strFieldList);
	
__published:
	__property TSMIColumnNameKind NameKind = {read=FNameKind, write=FNameKind, default=0};
	__property TSMIRowStatuses LoadRowStatutes = {read=FLoadRowStatutes, write=FLoadRowStatutes, default=1};
	__property TOnLoadProgress OnLoadProgress = {read=FOnLoadProgress, write=FOnLoadProgress};
	__property bool ParseBLOB = {read=FParseBLOB, write=FParseBLOB, default=1};
};


#pragma pack(push,1)
struct DECLSPEC_DRECORD TBCD
{
	
public:
	System::Byte Precision;
	System::Byte SignSpecialPlaces;
	System::StaticArray<System::Byte, 32> Fraction;
};
#pragma pack(pop)


struct DECLSPEC_DRECORD TSMIBCD
{
	
public:
	System::Byte Ctrl;
	System::StaticArray<System::Byte, 16> Data;
};


//-- var, const, procedure ---------------------------------------------------
static const System::Int8 ZARange = System::Int8(0x19);
extern PACKAGE bool __fastcall IsNan(const double AValue);
extern PACKAGE int __fastcall GetSpreadSheetColID(System::UnicodeString s, int MaxColCount);
extern PACKAGE System::UnicodeString __fastcall GetSpreadSheetColByID(int ID);
extern PACKAGE bool __fastcall BCDToCurr(const TBCD &BCD, System::Currency &Curr);
extern PACKAGE bool __fastcall SMBCDToCurr(const TSMIBCD &smibcd, int Len, double &dbl);
extern PACKAGE System::TDateTime __fastcall Julian2DMY(int j);
extern PACKAGE double __fastcall DMY2Julian(const System::TDateTime AValue);
extern PACKAGE void __fastcall BuildColList(int UsedColCount, const System::UnicodeString strFieldList, System::Classes::TStrings* lst);

}	/* namespace Smcells */
#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_SMCELLS)
using namespace Smcells;
#endif
#pragma pack(pop)
#pragma option pop

#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif	// SmcellsHPP
