DIRECTORY FS USING [OpenFile], IO USING [STREAM], Rope USING [ROPE]; PressReader: CEDAR 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, texDesignSize: REAL, weight: {medium, bold, light, none}, slope: {regular, italic, none}, expansion: {regular, condensed, expanded, none} ]; 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: PROC [name: ROPE] RETURNS [handle: Handle]; FromOpenFile: PROC [openFile: FS.OpenFile] RETURNS [handle: Handle]; GetDocumentDirectory: PROC [Handle] RETURNS [DocumentDirectory]; GetParts: PUBLIC PROC [handle: Handle, partNumber: INT, pageProc: PageProc _ NIL, fontDirectoryProc: FontDirectoryProc _ NIL]; GetFonts: PUBLIC PROC [handle: Handle, fontEntryProc: FontEntryProc]; GetPage: PUBLIC PROC [handle: Handle, entityProc: EntityProc]; GetCommands: PUBLIC PROC [ handle: Handle, 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 ]; GetObject: PROC [ handle: Handle, moveToProc: MoveToProc _ NIL, drawToProc: DrawToProc _ NIL, drawCurveProc: DrawCurveProc _ NIL ]; GetDots: PROC [ handle: Handle, setCoding: SetCodingProc _ NIL, setMode: SetModeProc _ NIL, setWindow: SetWindowProc _ NIL, setSize: SetSizeProc _ NIL, setSamplingProperties: SetSamplingPropertiesProc _ NIL, dotsFollow: DotsFollowProc _ NIL ]; ClosePressFile: PROC [Handle]; PageProc: TYPE = PROC [handle: Handle, partDirectoryEntry: PartDirectoryEntry]; FontDirectoryProc: TYPE = PROC [handle: Handle, partDirectoryEntry: PartDirectoryEntry]; FontEntryProc: TYPE = PROC [fontDirectoryEntry: FontDirectoryEntry]; EntityProc: TYPE = PROC [handle: Handle, entityTrailer: EntityTrailer]; ShowCharactersProc: TYPE = PROC [ opCode: {showCharactersShort, showCharactersAndSkip, showCharacters, showCharacterImmediate}, length: INT, text: ROPE ]; SkipProc: TYPE = PROC [ opCode: {skipCharacters, skipControlBytes, skipControlBytesImmediate, skipCharactersShort}, length: INT ]; SpacingProc: TYPE = PROC [ opCode: {setSpaceX, setSpaceY, setSpaceXShort, setSpaceYShort, resetSpace}, value: INT ]; SpaceProc: TYPE = PROC; PositionProc: TYPE = PROC [opCode: {setX, setY}, value: INT]; ColorProc: TYPE = PROC [opCode: {setHue, setSaturation, setBrightness}, value: INT]; FontProc: TYPE = PROC [font: INT]; NoOpProc: TYPE = PROC; ShowRectangleProc: TYPE = PROC [width, height: INT]; CopyProc: TYPE = PROC [value: INT]; AlternativeProc: TYPE = PROC [types: CARDINAL, elBytes, dlBytes: INT]; ShowObjectProc: TYPE = PROC [handle: Handle, length: INT]; ShowDotsProc: TYPE = PROC [handle: Handle, opCode: {showDots, showDotsOpaque}, length: INT]; BadProc: TYPE = PROC [opCode, command, data: INT]; MoveToProc: TYPE = PROC [x,y: INT]; DrawToProc: TYPE = PROC [x,y: INT]; DrawCurveProc: TYPE = PROC [cX, cY, bX, bY, aX, aY: REAL]; SetCodingProc: TYPE = PROC [code, dots, lines: INT]; SetModeProc: TYPE = PROC [mode: INT]; SetWindowProc: TYPE = PROC [pd,dd,pl,dl: INT]; SetSizeProc: TYPE = PROC [width, height: INT]; DotsFollowProc: TYPE = PROC [dots: Dots]; SetSamplingPropertiesProc: TYPE ~ PROC [samplingProperties: LIST OF SamplingProperty]; SamplingProperty: TYPE ~ REF; SSPInputIntensity: TYPE ~ REF SSPInputIntensityRep; SSPInputIntensityRep: TYPE ~ MACHINE DEPENDENT RECORD [ min: INTEGER, max: INTEGER ]; SSPOutputIntensity: TYPE ~ REF SSPOutputIntensityRep; SSPOutputIntensityRep: TYPE ~ MACHINE DEPENDENT RECORD [ minBrightness, minHue, minSaturation, maxBrightness, maxHue, maxSaturation: [0..255] ]; SSPScreen: TYPE ~ REF SSPScreenRep; SSPScreenRep: TYPE ~ MACHINE DEPENDENT RECORD [ angle, amplitude, frequency: INTEGER ]; SSPDot: TYPE ~ REF SSPDotRep; SSPDotRep: TYPE ~ MACHINE DEPENDENT RECORD [ nCells: CARDINAL, nLines: CARDINAL, nShifts: CARDINAL, thresholds: SEQUENCE COMPUTED CARDINAL OF CARDINAL ]; PressReaderError: ERROR [errorCode: ErrorCode]; ErrorCode: PUBLIC TYPE = { FileNotAPressFile, BadHandle, BadPartType, PartNotFound, NoFontDirectoryPart, CurrentPartNotAPage, NoEntity, NotAtObject, NotAtDots, AbortedBecauseGetFailed, UnexpectedOpCode, MalformedPressFile, Unimplemented, Bug }; END. °PressReader.mesa Last Modified by Shore; November 22, 1982 11:47 am Last Modified by Wyatt; December 1, 1983 4:53 pm Last Modified by Plass, March 14, 1985 8:18:05 am PST This is for applications that wish to read Press files For an explanation of Press files see "Press File Format" Filed on [Indigo]PressFormat.Press. The expected way of using it is as follows: open the press file using OpenPressFile read the document directory using GetDocumentDirectory (this can be done at any time once the file is open) read the parts using GetParts the PageProc may wish to call GetPage the EntityProc may wish to call GetCommands the appropriate command proc gets called for each command the ShowObjectProc may wish to call GetObject the appropriate object proc gets called for each object command the ShowDotsProc may wish to call GetDots the appropriate dot proc gets called for each dot command the FontDirectoryProc may wish to call GetFonts the FontEntryProc gets called for each font in the font directory the FontEntryProc may wish to call GetObject for a graphically defined font the appropriate object proc gets called for each object command close the press file with ClosePressFile note that GetFonts can actually be called at any time after the file is open Opens file for reading, checks that it is a Press file ERRORS: FS.Error, PressReaderError ]; FileNotAPressFile, AbortedBecauseGetFailed] ERRORS: PressReaderError ]; FileNotAPressFile, AbortedBecauseGetFailed] Returns the file's Document Directory ERRORS: PressReaderError ]; BadHandle, AbortedBecauseGetFailed] 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: PressReaderError ]; BadHandle, BadPartType, PartNotFound, AbortedBecauseGetFailed] calls fontEntryProc for each Font Entry in the Font Directory may call objectProcs for a graphically defined font ERRORS: PressReaderError ]; BadHandle, NoFontDirectoryPart, AbortedBecauseGetFailed] calls entityProc for each entity in the (current) printed page, thus, GetPage should be called from within a GetParts pageProc ERRORS: PressReaderError ]; BadHandle, CurrentPartNotAPage, AbortedBecauseGetFailed] 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: PressReaderError ]; BadHandle, NoEntity, AbortedBecauseGetFailed] calls supplied procs for each object command, thus GetObject should be called from within a GetCommands showObjectProc ERRORS: PressReaderError[BadHandle, NotAtObject, AbortedBecauseGetFailed]; calls supplied procs 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: PressReaderError[BadHandle, NotAtDots, AbortedBecauseGetFailed]; called when Press file reading is complete called (from GetParts) for each printedPage part called (from GetParts) for the fontDirectory part called (from GetFonts) for each font directory entry called (from GetPage) for each entity on a page the following procedure types are for parameters of GetCommands, and are called for the entity commands One of the following: -- not used in any known press files Change Log Created by Shore; June 1982 Changed by Shore; August 22, 1982 3:28 pm converted to formatted Tioga file revisions for Cedar 3.3 Changed by Shore; August 26, 1982 12:29 am made Dots and Objects one level deeper to permit exit actions by the Commands Changed by Shore; September 2, 1982 9:08 am made Parts individually gettable (partNumber parameter to GetParts) Changed by Shore; September 3, 1982 5:08 pm now pass up Dots Changed by Shore; November 14, 1982 2:58 pm changed to Cedar.Style and added formats Changed by Plass, March 12, 1985 2:43:57 pm PST Added SetSamplingProperties Changed by Michael Plass, March 14, 1985 7:54:30 am PST Changed GetCommands, GetObject, and GetDots to take the callback procedures directly as parameters, rather than records of procedures (which the compiler thinks are not safe). Κ P– "Cedar" style˜codešΟc™Kš2™2Kš0™0Kšœ$™5K™—Kš6™6š9™9Kš œ'™1—š+™+KšΠcn ™'š"ž™6Kš4™4—šž™šž™%š ž ™+Kš9™9š$ž ™-Kš?™?—š"ž™)Kš9™9———š'ž™/šA™Aš#ž ™KKš?™?————Kšž™(K˜Kš ž:™LK˜—šΟk ˜ KšŸœŸœ ˜KšŸœŸœŸœ˜KšœŸœŸœ˜K˜—šΟn œŸœŸ œŸ˜&KšŸœŸœŸœ˜K˜KšœŸœŸœ˜"KšœŸœ˜K˜KšœŸœŸœŸœ˜:šœŸœŸœŸœ˜,KšœŸœ˜ KšœŸœ˜ KšœŸœ˜ Kšœ Ÿœ˜ KšœŸœ˜ KšœŸœ˜ KšœŸœŸœ˜KšœŸœ˜ KšœŸœ˜ KšœŸœ˜ KšœŸœ˜ Kšœ Ÿœ˜Kšœ Ÿœ˜Kšœ Ÿ˜K˜K˜—šœŸœŸœŸœ˜*Kšœ˜Kšœ Ÿœ˜Kšœ Ÿœ˜Kšœ Ÿœ˜Kšœ Ÿ˜ K˜K˜—Kšœ ŸœŸœ2˜GšœŸœŸœŸœ˜*KšœŸœ˜ Kšœ Ÿœ˜ KšœŸœ˜ Kšœ Ÿœ˜Kšœ Ÿœ˜KšœŸœ˜ Kšœ˜KšœŸœ˜ KšœŸœ˜ Kšœ Ÿ˜ K˜K˜—šœ ŸœŸœŸœ˜ Kšœ Ÿœ˜KšœŸœ˜Kšœ$˜$Kšœ˜Kšœ/˜/Kšœ˜K˜—šœŸœŸœŸœ˜%Kšœ Ÿœ˜Kšœ Ÿœ˜ Kšœ Ÿœ˜Kšœ Ÿœ˜KšœŸœ˜KšœŸœ˜KšœŸœ˜ Kšœ Ÿœ˜ KšœŸœ˜ KšœŸœ˜ KšœŸ˜ K˜K˜—šœŸœŸœ˜KšœŸœŸœ˜Kšœ Ÿœ˜Kšœ Ÿœ˜Kšœ Ÿœ˜KšœŸ˜ K˜K˜—š  œŸœŸœŸœ˜:Kš6™6Kš"™"Kšœ™Kš+™+K™—š  œŸœ Ÿœ Ÿœ˜DKš™Kšœ™Kš+™+K™—š œŸœ Ÿœ˜@Kš%™%Kš™Kšœ™Kš#™#K™—š  œŸœŸœŸœŸœ)Ÿœ˜~KšT™TKšH™HKš[™[Kš™Kšœ™Kš>™>K™—š œŸœŸœ0˜EKš=™=Kš3™3Kš™Kšœ™Kš8™8K™—š œŸœŸœ*˜>Kš?™?Kš>™>Kš™Kšœ™Kš8™8K™—š  œŸœŸœ˜Kšœ˜Kšœ)Ÿœ˜-KšœŸœ˜KšœŸœ˜KšœŸœ˜KšœŸœ˜!KšœŸœ˜KšœŸœ˜KšœŸœ˜Kšœ'Ÿœ˜+Kšœ!Ÿœ˜%KšœŸœ˜!KšœŸœ˜Kšœ#Ÿœ˜'KšœŸ˜Kšœ˜KšG™GKš[™[Kš™Kšœ™Kš-™-K™—š  œŸœ˜Kšœ˜KšœŸœ˜KšœŸœ˜KšœŸ˜"Kšœ˜Kš-™-KšH™HKšœ1™JK™—š œŸœ˜Kšœ˜KšœŸœ˜KšœŸœ˜KšœŸœ˜KšœŸœ˜Kšœ3Ÿœ˜7KšœŸ˜ Kšœ˜Kš+™+KšD™DKš4™4Kšœ/™HK™—š œŸœ ˜Kš*™*—K˜š œŸœŸœ:˜OKš0™0K™—š œŸœŸœ:˜XKš1™1K™—š  œŸœŸœ*˜DKš4™4K™—š  œŸœŸœ0˜GKš/™/—K˜šg™gš œŸœŸœ˜!Kšœ^˜^KšœŸœ˜ KšœŸ˜ Kšœ˜K˜—š œŸœŸœ˜Kšœ\˜\KšœŸ˜ K˜K˜—š  œŸœŸœ˜KšœK˜KKšœŸ˜ K˜K˜—Kš  œŸœŸœ˜Kš  œŸœŸœŸœ˜=Kš  œŸœŸœ9Ÿœ˜TKš œŸœŸœŸœ˜"Kš œŸœŸœ˜Kš œŸœŸœŸœ˜4Kš œŸœŸœ Ÿœ˜#Kš  œŸœŸœ ŸœŸœ˜FKš œŸœŸœŸœ˜:Kš  œŸœŸœ>Ÿœ˜\Kš œŸœŸœŸœ˜2Kš  œŸœŸœŸœ˜#Kš  œŸœŸœŸœ˜#Kš  œŸœŸœŸœ˜;Kš  œŸœŸœŸœ˜4Kš  œŸœŸœŸœ˜%Kš  œŸœŸœŸœ˜.Kš  œŸœŸœŸœ˜.Kš œŸœŸœ˜)K˜—š œŸœŸœŸœŸœ˜VK˜—šœŸœŸœ˜K™K˜KšœŸœŸœ˜3š œŸœŸœŸ œŸœ˜7KšœŸœ˜ KšœŸ˜ Kšœ˜K˜—KšœŸœŸœ˜5š œŸœŸœŸ œŸœ˜8KšœT˜TKšœ˜K™$K˜—Kšœ ŸœŸœ˜#š œŸœŸœŸ œŸœ˜/KšœŸ˜$Kšœ˜K˜—KšœŸœŸœ ˜š œ ŸœŸœŸ œŸœ˜,KšœŸœ˜KšœŸœ˜Kšœ Ÿœ˜Kš œ ŸœŸœŸœŸœŸ˜2Kšœ˜K˜——KšœŸœ˜/šœ ŸœŸœ˜Kšœ˜Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜Kšœ ˜ K˜ K˜ Kšœ˜K˜K˜Kšœ˜Kšœ˜Kšœ˜—K˜KšŸœ˜K™—š ™ Kšœ™K™™)K™!K™—K™™*K™M—K™™+K™C—K™™+K™—K™™+K™(—K™™/Kšœ™—K™™7Kšœž œž œžœ„™―——K™—…—T2T