PrinterContext.st
changeset 2274 c0c247557f01
parent 2273 14e357a2c73f
child 2275 6c2f8ba6b301
--- a/PrinterContext.st	Tue Nov 28 11:54:21 2006 +0100
+++ b/PrinterContext.st	Thu Nov 30 14:26:37 2006 +0100
@@ -704,6 +704,68 @@
     "Modified: / 12-10-2006 / 11:50:37 / User"
 !
 
+print: aString
+    pageHeader: aString2
+    font: aFont
+    title: aTitle
+    collate: collateBoolean
+    copies: copiesInteger
+    wordWrap: wordWrapBoolean
+    marginsRect: aMarginsRect
+
+        "Private - Answer the receiver.  Output the receiver string to
+        the printer using aFont.  A Print abort dialog box will be opened
+        with aTitle.  If collateBoolean is true, collate output, otherwise
+        do not.  Print copiesInteger copies of the specified string.  If
+        wordWrapBoolean is true, word wrap the lines, otherwise do not.
+        Left, top, right & bottom margins are specified in inches in
+        aMarginsRect.
+        Mg: Erweitert um pageHeader"
+       "Changed by K3/EES5-Mg, 08.01.96"
+
+    | lines linesPerPage totalPage marginsRect firstPage charHeight  printerFont headerLines|
+
+    printerFont := self setPrinterFont: aFont.
+    charHeight := self "pen" getCharHeight.
+    marginsRect := self marginsRectangleFor: aMarginsRect.
+    lines := self "pen" asArrayOfStringLines: aString in: marginsRect wordWrap: wordWrapBoolean.
+    headerLines := self "pen" asArrayOfStringLines: aString2 in: marginsRect wordWrap: wordWrapBoolean.
+    linesPerPage := marginsRect bottom - marginsRect top // charHeight.
+
+    linesPerPage > headerLines size
+        ifFalse:
+          [Dialog information: 'Der Dokumentenkopf ist zu groß; wird ignoriert!!'.
+           headerLines := #().
+          ]
+        ifTrue: [linesPerPage := linesPerPage - headerLines size].
+    totalPage := lines size + linesPerPage - 1 // linesPerPage.
+    firstPage := true.
+
+"/    collateBoolean
+"/        ifTrue: [
+"/            copiesInteger timesRepeat: [
+
+                1 to: totalPage do: [ :page |
+                    abort ifTrue: [ ^self endPrintJob ].
+                    firstPage ifFalse: [ self formFeed ].
+                    self "pen" font: aFont "printerFont".
+                    self printPage: page in: marginsRect lines: lines headerLines: headerLines linesPerPage: linesPerPage.
+                    firstPage := false ] 
+
+"/              ] 
+"/          ]
+"/        ifFalse: [
+"/            1 to: totalPage do: [ :page |
+"/                copiesInteger timesRepeat: [
+"/                    abort ifTrue: [ ^self endPrintJob ].
+"/                    firstPage ifFalse: [ self formFeed ].
+"/                    self "pen" font: printerFont.
+"/                    self printPage: page in: marginsRect lines: lines headerLines: headerLines linesPerPage: linesPerPage.
+"/                    firstPage := false ] ] ].
+
+    "Created: / 30-11-2006 / 13:19:06 / User"
+!
+
 print:aString pageHeader:aString2 font:aFont title:aTitle wordWrap:wordWrapBoolean marginsRect:aMarginsRect 
     "Private - Answer the receiver.  Output the receiver string to
      the printer using aFont.  A Print abort dialog box will be opened
@@ -1120,7 +1182,8 @@
     hLines := headerLines deepCopy.
     headerLines size > 0 ifTrue:[
         l := hLines first.
-        (p := l indexOfString:'#P') = 0 ifFalse:[
+        p := l indexOfSubCollection: "indexOfString:"'#P'.
+        p = 0 ifFalse:[
             indexString := pageIndex printString , ' '.
             l := (l copyFrom:1 to:p - 1) , indexString , (l copyFrom:p + 2 to:l size).
             hLines at:1 put:l.
@@ -1138,6 +1201,7 @@
     "Created: / 27-07-2006 / 18:28:00 / fm"
     "Modified: / 03-08-2006 / 16:03:15 / fm"
     "Modified: / 10-10-2006 / 18:18:15 / cg"
+    "Modified: / 30-11-2006 / 13:34:44 / User"
 !
 
 printPage:pageIndex in:aRectangle lines:lines linesPerPage:linesPerPage 
@@ -1225,5 +1289,5 @@
 !PrinterContext class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/PrinterContext.st,v 1.10 2006-11-28 10:54:21 fm Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/PrinterContext.st,v 1.11 2006-11-30 13:26:37 fm Exp $'
 ! !