
COMMENT @-----------------------------------------------------------------------

	Copyright (c) Geoworks 1992 -- All Rights Reserved

PROJECT:	PC GEOS
MODULE:		
FILE:		ssmeta.def

AUTHOR:		Cheng, 8/92

ROUTINES:
	Name			Description
	----			-----------
	
REVISION HISTORY:
	Name	Date		Description
	----	----		-----------
	Cheng	8/92		Initial revision

DESCRIPTION:
	Definitions for the Spreadsheet Meta library. This library manages
	the meta file for the spreadsheet.

	$Id: ssmeta.def,v 1.1 97/04/04 14:24:03 newdeal Exp $

-------------------------------------------------------------------------------@

StartLibrary	ssmeta

SSMETA_PROTO_MAJOR	equ	0
SSMETA_PROTO_MINOR	equ	0

SSMETA_LIB_DISK_HANDLE	equ	SP_SYSTEM
if DBCS_PCGEOS
SSMETA_LIB_DIR		equ	<'\\',0>
else
SSMETA_LIB_DIR		equ	<'\\\\', 0>
endif

if DBCS_PCGEOS
if ERROR_CHECK
SSMETA_LIB_PATH	equ	<'EC SSMeta Lib', 0>
else
SSMETA_LIB_PATH	equ	<'SSMeta Lib', 0>
endif
else
if ERROR_CHECK
SSMETA_LIB_PATH	equ	<'EC SSheet Meta Library', 0>
else
SSMETA_LIB_PATH	equ	<'SSheet Meta Library', 0>
endif
endif


COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    SSMETA DATA ARRAY STRUCTURES

    Use by the spreadsheet's cut/copy/paste code as well as for the spreadsheet
    translation library.

    NAMES OF THINGS:

	The clipboard transfer item header will have a handle to a SSMETA
	HEADER BLOCK.

	The ssmeta header block is a VM blk containing the size of the scrap
	(number of rows and columns) and five SSMETA DATA ARRAY RECORDS.
	
	Each ssmeta data array record describes a DATA ARRAY.

	One data array is used to store the cell data, one for the styles, one
	for the formats, and another for the names. The fifth data array is
	for use by the database. Any data array can be empty.

	A data array is an array of SSMETA ENTRIES.

	Each ssmeta entry will have an ENTRY HEADER which is followed by the
	ENTRY DATA. The entry header will contain a field for a token, and
	fields for the coordinate (row, column) that the cell data processing
	code needs. Entry tokens are optional. You may use them if you intend
	to use them to search for entries.

    NOTES:
	The VM file handle is stored in the SSMetaHeader and each of the
	SSMetaDataArrayRecords. This duplication is for convenience - it
	lessens the amount of separate data that needs to be passed around.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@

DataArraySpecifier	etype	byte
DAS_CELL			enum DataArraySpecifier
DAS_STYLE			enum DataArraySpecifier
DAS_FORMAT			enum DataArraySpecifier
DAS_NAME			enum DataArraySpecifier
DAS_FIELD			enum DataArraySpecifier	; for use by dbase

SSMETA_NUM_SPECIFIERS		equ	5

SSMetaAddEntryFlags	etype	byte
SSMAEF_ADD_IN_TOKEN_ORDER	enum	SSMetaAddEntryFlags
SSMAEF_ADD_IN_ROW_ORDER		enum	SSMetaAddEntryFlags
SSMETA_ADD_TO_END		enum	SSMetaAddEntryFlags
SSMAEF_ENTRY_POS_PASSED		enum	SSMetaAddEntryFlags

;
; SSMetaDataArrayRecord:
;
; used to track a data array
;
SSMetaDataArrayRecord	struct
	SSMDAR_signature	word
	SSMDAR_numEntries	word	; number of entries in the data array
	SSMDAR_dataArrayLinkOffset word	; offset to chain link in VMChainTree
					; structure
SSMetaDataArrayRecord	end

;
; SSMetaHeaderBlock
;
SSMetaHeaderBlock	struct
	;
	; VM chain tree structures
	;
	SSMHB_vmChainTree	VMChainTree
	SSMHB_links		label	word
	SSMHB_cellLink		dword
	SSMHB_styleLink		dword
	SSMHB_formatLink	dword
	SSMHB_nameLink		dword
	SSMHB_fieldLink		dword
	;
	; SSMetaDataArrayRecords
	;
	SSMHB_startArrayRecords	label	word
	SSMHB_cellData		SSMetaDataArrayRecord
	SSMHB_styleData		SSMetaDataArrayRecord
	SSMHB_formatData	SSMetaDataArrayRecord
	SSMHB_nameData		SSMetaDataArrayRecord
	SSMHB_fieldData		SSMetaDataArrayRecord
	;
	; scrap size
	;
	SSMHB_scrapRows		word
	SSMHB_scrapCols		word
SSMetaHeaderBlock	ends

;
; SSMetaEntry
;
SSMetaEntry	struct
	SSME_signature		word	; sig for error checking
	SSME_entryDataSize	word	; size of entry data
	SSME_token		word	; token (if there is one)
	SSME_coordRow		word
	SSME_coordCol		word
	SSME_newToken		word	; for use when pasting
	SSME_dataPortion	label	byte	; the entry data
SSMetaEntry	ends

SSMetaEntryDescriptor	struct
	SSMED_ptr	fptr
	SSMED_size	word
SSMetaEntryDescriptor	ends

;
; SSMetaStruc:
;
SSMetaStruc	struct
	;
	; library user usually passes info in these fields:
	;
	SSMDAS_transferItemFlags	ClipboardItemFlags
	SSMDAS_dataArraySpecifier	DataArraySpecifier
	SSMDAS_row			word
	SSMDAS_col			word
	SSMDAS_token			word
	SSMDAS_handle			word	; for routines that need it,
						; handle to a mem block

	;
	; Library user gets info back in these fields:
	;
	SSMDAS_newEntrySeg		word
;	SSMDAS_entry			dword	; pointer to entry
;	SSMDAS_entrySize		word	; size excluding entry header
	SSMDAS_vmFileHan		word	; transfer VM file han
	SSMDAS_hdrBlkVMHan		word	; SSMetaHeaderBlock VM blk han

	;
	; Fields containing info about the scrap (initialized by
	; SSMetaInitForPaste)
	; Once initialized, library users should not change these.
	;
	SSMDAS_tferItemHdrVMHan		word	; ClipboardItemHeader VM blk han
	SSMDAS_tferItemMemHan		word	; ClipboardItemHeader mem han
	SSMDAS_hdrBlkMemHan		word	; SSMetaHeaderBlock mem han
						; (initialized by
						; SSMetaGetDataArrayRecord)
	SSMDAS_sourceID			dword	; sourceID of transfer item
	SSMDAS_scrapRows		word	; number of rows
	SSMDAS_scrapCols		word	; number of columns

	;
	; fields for library's own use - don't touch these
	;
	SSMDAS_signature		word	; for error checking
	SSMDAS_dataArrayRecordPtr	fptr	; used by GetDataArrayRecord
						; & SSMetaDataArrayGetNextEntry
	SSMDAS_dataArrayBlkHan		word	; huge array handle for data
						; array
	SSMDAS_numEntries		word	; num entries in specified chain

	;
	; SSMDAS_dataArrayEntryTable - tracks the position of the last accessed
	; entry in each of the data arrays.
	;
	SSMDAS_dataArrayEntryTable	label	dword
	SSMDAS_cellEntry		SSMetaEntryDescriptor
	SSMDAS_styleEntry		SSMetaEntryDescriptor
	SSMDAS_formatEntry		SSMetaEntryDescriptor
	SSMDAS_nameEntry		SSMetaEntryDescriptor
	SSMDAS_fieldEntry		SSMetaEntryDescriptor

	SSMDAS_entryDataAddr		dword	; user passes this to library
	SSMDAS_entryDataSize		word	; user passes this to library
	SSMDAS_entryMemHan		word
	SSMDAS_flag			byte	; user passes this to library
	SSMDAS_entryPos			dword	; tracks array traversal

	;
	; used for binary search in AddEntryBinarySearch, touch these not
	;
	SSMDAS_startIndex		word
	SSMDAS_endIndex			word
	SSMDAS_checkIndex		word
	SSMDAS_compFlag			byte	; SSMetaBinSearchConditionType
SSMetaStruc	ends

;
; initialization routines
;
global	SSMetaInitForStorage:far
global	SSMetaInitForRetrieval:far
global	SSMetaInitForCutCopy:far
global	SSMetaDoneWithCutCopy:far
global	SSMetaInitForPaste:far
global	SSMetaDoneWithPaste:far
global	SSMetaDoneWithCutCopyNoRegister:far

;
; storage routines
;
global	SSMetaSetScrapSize:far
global	SSMetaDataArrayLocateOrAddEntry:far
global	SSMetaDataArrayAddEntry:far
;
; retrieval routines
;
global	SSMetaSeeIfScrapPresent:far
global	SSMetaGetScrapSize:far
global	SSMetaDataArrayGetNumEntries:far
global	SSMetaDataArrayResetEntryPointer:far
global	SSMetaDataArrayGetFirstEntry:far
global	SSMetaDataArrayGetNextEntry:far
global	SSMetaDataArrayGetEntryByToken:far
global	SSMetaDataArrayGetEntryByCoord:far
global	SSMetaDataArrayGetNthEntry:far
global	SSMetaDataArrayUnlock:far

;
; Routines for accessing the data as named-field data records.
;
global	SSMetaGetNumberOfDataRecords:far
global	SSMetaResetForDataRecords:far
global	SSMetaFieldNameLock:far
global	SSMetaFieldNameUnlock:far
global	SSMetaDataRecordFieldLock:far
global	SSMetaDataRecordFieldUnlock:far
global	SSMetaFormatCellText:far

EndLibrary	ssmeta
