PressReader:
DEFINITIONS =
BEGIN
ROPE: TYPE = Rope.ROPE;
Handle: TYPE = REF PressReaderRec;
PressReaderRec: TYPE;
DocumentDirectory: PUBLIC TYPE = REF DocumentDirectoryRec;
DocumentDirectoryRec:
PUBLIC
TYPE =
RECORD [
passwd: INT,
nRecs: INT,
nParts: INT,
pdStart: INT,
pdRecs: INT,
backP: INT,
date: LONG CARDINAL,
fCopy: INT,
lCopy: INT,
fPage: INT,
lPage: INT,
fileName: ROPE,
creator: ROPE,
dateText: ROPE ];
PartDirectoryEntry:
PUBLIC
TYPE =
RECORD [
partType: PartType,
typeNumber: INT,
partStart: INT,
partRecs: INT,
padding: INT ];
PartType: PUBLIC TYPE = { private, printedPage, fontDirectory, other };
FontDirectoryEntry:
PUBLIC
TYPE =
RECORD [
length: INT,
fontSet: INT,
font: INT,
firstChar: INT,
lastChar: INT,
family: ROPE,
face: FontFace,
source: INT,
size: INT,
rotation: INT ];
FontFace:
PUBLIC
TYPE =
RECORD [
encoding: INT,
weight: {medium, bold, light},
slope: {regular, italic},
expansion: {regular, condensed, expanded}];
EntityTrailer:
PUBLIC
TYPE =
RECORD [
entityType: INT,
fontSet: INT,
dataStart: INT,
dataLength: INT,
Xe: INT,
Ye: INT,
xLeft: INT,
yBottom: INT,
width: INT,
height: INT,
length:INT ];
Dots:
TYPE =
RECORD [
file: IO.STREAM,
numberPages: NAT,
pageNumber: NAT,
byteOffset: INT,
length: INT ];
OpenPressFile:
PROCEDURE [name:
ROPE]
RETURNS [handle: Handle];
Open's file for reading, checks that it is a Press file
ERRORS: Error[FileNotAvailableForRead, FileNotAPressFile, AbortedBecauseGetFailed]
GetDocumentDirectory:
PROCEDURE [Handle]
RETURNS [DocumentDirectory];
Returns the file's Document Directory
ERRORS: Error[BadHandle, AbortedBecauseGetFailed]
GetParts:
PUBLIC
PROCEDURE [handle: Handle, partNumber:
INT, pageProc: PageProc ←
NIL, fontDirectoryProc: FontDirectoryProc ←
NIL];
calls pageProc or fontDirectoryProc (depending on part type) for the specified part,
if partNumber = 0 then pageProc is called for each Printed Page part and
fontDirectoryProc for the Font Directory in the order in which they occur in the Press file
ERRORS: Error[BadHandle, BadPartType, PartNotFound, AbortedBecauseGetFailed]
GetFonts:
PUBLIC
PROCEDURE [handle: Handle, fontEntryProc: FontEntryProc];
calls fontEntryProc for each Font Entry in the Font Directory
may call objectProcs for a graphically defined font
ERRORS: Error[BadHandle, NoFontDirectoryPart, AbortedBecauseGetFailed]
GetPage:
PUBLIC
PROCEDURE [handle: Handle, entityProc: EntityProc];
calls entityProc for each entity in the (current) printed page,
thus, GetPage should be called from within a GetParts pageProc
ERRORS: Error[BadHandle, CurrentPartNotAPage, AbortedBecauseGetFailed]
GetCommands:
PUBLIC
PROCEDURE [handle: Handle, commandProcs: CommandProcs];
calls members of commandProcs for each command in the (current) entity,
thus GetCommands should be called from within a GetPage entityProc, else NoEntity is raised
ERRORS: Error[BadHandle, NoEntity, AbortedBecauseGetFailed]
GetObject:
PROCEDURE [handle: Handle, objectProcs: ObjectProcs];
calls members of ObjectProcs for each object command,
thus GetObject should be called from within a GetCommands showObjectProc
ERRORS: Error[BadHandle, NotAtObject, AbortedBecauseGetFailed];
GetDots:
PROCEDURE [handle: Handle, dotProcs: DotProcs];
calls members of DotProcs for each dots command,
thus GetDots should be called from within a GetCommands showDotsProc
passUpDots allows the dots in the file to be skipped
ERRORS: Error[BadHandle, NotAtDots, AbortedBecauseGetFailed];
ClosePressFile:
PROCEDURE [Handle];
called when Press file reading is complete
PageProc:
TYPE =
PROCEDURE [handle: Handle, partDirectoryEntry: PartDirectoryEntry];
called (from GetParts) for each printedPage part
FontDirectoryProc:
TYPE =
PROCEDURE [handle: Handle, partDirectoryEntry: PartDirectoryEntry];
called (from GetParts) for the fontDirectory part
FontEntryProc:
TYPE =
PROCEDURE [fontDirectoryEntry: FontDirectoryEntry];
called (from GetFonts) for each font directory entry
EntityProc:
TYPE =
PROCEDURE [handle: Handle, entityTrailer: EntityTrailer];
called (from GetPage) for each entity on a page
the following procedure types make up a CommandProcs record,
they are called (from GetCommands) for the entity commands
ShowCharactersProc:
TYPE =
PROCEDURE [
opCode: {showCharactersShort, showCharactersAndSkip, showCharacters, showCharacterImmediate},
length: INT,
text: ROPE];
SkipProc:
TYPE =
PROCEDURE [
opCode: {skipCharacters, skipControlBytes, skipControlBytesImmediate, skipCharactersShort},
length: INT];
SpacingProc:
TYPE =
PROCEDURE [
opCode: {setSpaceX, setSpaceY, setSpaceXShort, setSpaceYShort, resetSpace},
value: INT];
SpaceProc: TYPE = PROCEDURE;
PositionProc: TYPE = PROCEDURE [opCode: {setX, setY}, value: INT];
ColorProc: TYPE = PROCEDURE [opCode: {setHue, setSaturation, setBrightness}, value: INT];
FontProc: TYPE = PROCEDURE [font: INT];
NoOpProc: TYPE = PROCEDURE;
ShowRectangleProc: TYPE = PROCEDURE [width, height: INT];
CopyProc: TYPE = PROCEDURE [value: INT];
AlternativeProc: TYPE = PROCEDURE [types: CARDINAL, elBytes, dlBytes: INT];
ShowObjectProc: TYPE = PROCEDURE [handle: Handle, length: INT];
ShowDotsProc: TYPE = PROCEDURE [handle: Handle, opCode: {showDots, showDotsOpaque}, length: INT];
BadProc: TYPE = PROCEDURE [opCode, command, data: INT];
MoveToProc: TYPE = PROCEDURE [x,y: INT];
DrawToProc: TYPE = PROCEDURE [x,y: INT];
DrawCurveProc: TYPE = PROCEDURE [cX, cY, bX, bY, aX, aY: REAL];
SetCodingProc: TYPE = PROCEDURE [code, dots, lines: INT];
SetModeProc: TYPE = PROCEDURE [mode: INT];
SetWindowProc: TYPE = PROCEDURE [pd,dd,pl,dl: INT];
SetSizeProc: TYPE = PROCEDURE [width, height: INT];
DotsFollowProc: TYPE = PROCEDURE [dots: Dots];
ObjectProcs:
TYPE =
RECORD[
moveToProc: MoveToProc ← NIL,
drawToProc: DrawToProc ← NIL,
drawCurveProc: DrawCurveProc ← NIL ];
DotProcs:
TYPE =
RECORD[
setCoding: SetCodingProc ← NIL,
setMode: SetModeProc ← NIL,
setWindow: SetWindowProc ← NIL,
setSize: SetSizeProc ← NIL,
dotsFollow: DotsFollowProc ← NIL ];
CommandProcs:
TYPE =
RECORD[
showCharactersProc: ShowCharactersProc← NIL,
skipProc: SkipProc ← NIL,
spacingProc: SpacingProc ← NIL,
spaceProc: SpaceProc ← NIL,
positionProc: PositionProc ← NIL,
colorProc: ColorProc ← NIL,
fontProc: FontProc ← NIL,
noOpProc: NoOpProc ← NIL,
showRectangleProc: ShowRectangleProc ← NIL,
showObjectProc: ShowObjectProc ← NIL,
showDotsProc: ShowDotsProc ← NIL,
copyProc: CopyProc ← NIL,
alternativeProc: AlternativeProc ← NIL,
badProc: BadProc ← NIL ];
PressReaderError: ERROR [errorCode: ErrorCode];
ErrorCode:
PUBLIC
TYPE = {
FileNotAvailableForRead,
FileNotAPressFile,
BadHandle,
BadPartType,
PartNotFound,
NoFontDirectoryPart,
CurrentPartNotAPage,
NoEntity,
NotAtObject,
NotAtDots,
AbortedBecauseGetFailed };
END.