-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathReport4PDF.35.gs
10773 lines (9655 loc) · 818 KB
/
Report4PDF.35.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Created 3. April 2022 um 18:57:25 by Gemstone Transform(1.4.0.7,chaider)
FileFormat UTF8
IfErr 1 list dictionaries
IfErr 2 stk
IfErr 3 display oops
IfErr 4 omit classoops
IfErr 5 stack
IfErr 6 Exit
DoIt
| package |
UserGlobals at: #FileInStartingTimestamp put: DateAndTime now.
(UserGlobals includesKey: #FileInSymbolDictionary) ifTrue: [
nil error: 'Previous file-in did not complete'].
(GsSession currentSession resolveSymbol: #Report4PDFLibrary) ifNil: [
package := GsPackageLibrary createPackageNamed: #Report4PDFLibrary.
package initialize.
package addPrereq: PDFtalkLibrary.
GsPackageLibrary installPackage: package].
%
DoIt
UserGlobals at: #FileInSymbolDictionary put: Report4PDFLibrary.
%
DoIt
FileInSymbolDictionary at: #codeComponents put: Dictionary new. "Add root of pundle structure"
FileInSymbolDictionary at: #namespacePathsAtClasses put: Dictionary new. "Add registry for namespace paths of classes"
%
DoIt
| dict components |
dict := SymbolDictionary new.
dict name: #Report4PDF.
dict at: #comment put: 'PDF4Smalltalk is an implementation of the PDF specification (ISO standard PDF 32000-1:2008) in VisualWorks Smalltalk. Report4PDF generates output for PDF4Smalltalk using layout and content information, coding in a style influenced by Seaside. This is intended to be a programmer''s tool for building PDF content; it is not an end user report tool.
See R4PReport class>>buildUserGuide for user guide.
SUnit tests and examples are found in Report4PDF-test
Developer mailing list: http://www.freelists.org/archive/pdf4st
'.
dict at: #developmentPrerequisites put: #(#(#any 'PDFtalk' '') #(#any 'ImageReaders' '')).
dict at: #disregardedPrerequisites put: #().
dict at: #notice put: 'The MIT License
Copyright © 2012-2018 Bob Nemec
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.'.
dict at: #packageName put: 'Report4PDF'.
dict at: #parcelName put: 'Report4PDF'.
dict at: #prerequisiteDescriptions put: #(#(#name 'PDFtalk' #componentType #bundle) #(#name 'ImageReaders' #componentType #package)).
dict at: #prerequisiteParcels put: #(#('PDFtalk' '') #('ImageReaders' '')).
dict at: #storeVersion put: '2.5.0.0'.
components := (GsPackageLibrary packageNamed: #Report4PDFLibrary) symbolDict at: #codeComponents.
components at: dict name put: dict.
%
# Define namespace Report4PDF
DoIt
| newDictionary |
newDictionary := SymbolDictionary new.
newDictionary at: #Report4PDF put: newDictionary.
Report4PDFLibrary at: #Report4PDF put: newDictionary
%
DoIt
System myUserProfile insertDictionary: Report4PDF at: 1.
%
# Define class R4PObject
DoIt
Object
subclass: 'R4PObject'
instVarNames: #(properties)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PObject category: 'Report4PDF'.
R4PObject namespacePath: #(#Report4PDF).
%
# Define class R4POutput
DoIt
R4PObject
subclass: 'R4POutput'
instVarNames: #(color colorName)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4POutput category: 'Report4PDF'.
R4POutput namespacePath: #(#Report4PDF).
%
# Define class R4PLayout
DoIt
R4PObject
subclass: 'R4PLayout'
instVarNames: #(parent widthPercent font fontSize align verticalAlign margin padding spacing border sections include exclude fixedBox layoutTop boxBottomLimit noWrapSet truncated built boxHeightUsed background foreground newPageBlock fitOnPage)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PLayout category: 'Report4PDF'.
R4PLayout namespacePath: #(#Report4PDF).
%
# Define class R4PTable
DoIt
R4PLayout
subclass: 'R4PTable'
instVarNames: #(headerRow columns cellPadding cellSpacing cellBorder repeatHeadingSet)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PTable category: 'Report4PDF'.
R4PTable namespacePath: #(#Report4PDF).
%
# Define class R4PText
DoIt
R4PLayout
subclass: 'R4PText'
instVarNames: #(flip leading maxFontHeight containsTruncatedText)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PText category: 'Report4PDF'.
R4PText namespacePath: #(#Report4PDF).
%
# Define class R4POutputPage
DoIt
R4POutput
subclass: 'R4POutputPage'
instVarNames: #(renderer output reportPage nextPage previousPage currentY minimumY maximumY pageWidth pageHeight outputPageIndex nextPageNumber)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4POutputPage category: 'Report4PDF'.
R4POutputPage namespacePath: #(#Report4PDF).
%
# Define class R4POutputBackground
DoIt
R4POutput
subclass: 'R4POutputBackground'
instVarNames: #(top left bottom right width height)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4POutputBackground category: 'Report4PDF'.
R4POutputBackground namespacePath: #(#Report4PDF).
%
# Define class R4PImage
DoIt
R4PLayout
subclass: 'R4PImage'
instVarNames: #(image filename scale)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PImage category: 'Report4PDF'.
R4PImage namespacePath: #(#Report4PDF).
%
# Define class R4POutputImage
DoIt
R4POutput
subclass: 'R4POutputImage'
instVarNames: #(matrix xImage)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4POutputImage category: 'Report4PDF'.
R4POutputImage namespacePath: #(#Report4PDF).
%
# Define class R4PBullet
DoIt
R4PLayout
subclass: 'R4PBullet'
instVarNames: #(bulletText)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PBullet category: 'Report4PDF'.
R4PBullet namespacePath: #(#Report4PDF).
%
# Define class R4POutputString
DoIt
R4POutput
subclass: 'R4POutputString'
instVarNames: #(matrix string font fontSize align originalWidth)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4POutputString category: 'Report4PDF'.
R4POutputString namespacePath: #(#Report4PDF).
%
# Define class R4PCell
DoIt
R4PLayout
subclass: 'R4PCell'
instVarNames: #(column columnSpan rowSpan cellHeight)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PCell category: 'Report4PDF'.
R4PCell namespacePath: #(#Report4PDF).
%
# Define class R4PLine
DoIt
R4PLayout
subclass: 'R4PLine'
instVarNames: #(lineWidth)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PLine category: 'Report4PDF'.
R4PLine namespacePath: #(#Report4PDF).
%
# Define class R4PSection
DoIt
R4PLayout
subclass: 'R4PSection'
instVarNames: #()
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PSection category: 'Report4PDF'.
R4PSection namespacePath: #(#Report4PDF).
%
# Define class R4PReport
DoIt
R4PObject
subclass: 'R4PReport'
instVarNames: #(pageHeight pageWidth pages font fontSize margin pageNumberPattern pageTotalPattern reportTotalPattern builder traceOption traceFileStream)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PReport category: 'Report4PDF'.
R4PReport namespacePath: #(#Report4PDF).
%
# Define class R4PError
DoIt
Exception
subclass: 'R4PError'
instVarNames: #()
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PError category: 'Report4PDF'.
R4PError namespacePath: #(#Report4PDF).
%
# Define class R4PColumn
DoIt
R4PLayout
subclass: 'R4PColumn'
instVarNames: #(cells columnWidth)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PColumn category: 'Report4PDF'.
R4PColumn namespacePath: #(#Report4PDF).
%
# Define class R4PBuilder
DoIt
R4PObject
subclass: 'R4PBuilder'
instVarNames: #(report reportPage outputPages currentPage currentFont)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PBuilder category: 'Report4PDF'.
R4PBuilder namespacePath: #(#Report4PDF).
%
# Define class R4POutputLine
DoIt
R4POutput
subclass: 'R4POutputLine'
instVarNames: #(startPoint endPoint width)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4POutputLine category: 'Report4PDF'.
R4POutputLine namespacePath: #(#Report4PDF).
%
# Define class R4PPage
DoIt
R4PLayout
subclass: 'R4PPage'
instVarNames: #(pageWidth pageHeight header footer nextPageNumber watermark outputPages)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PPage category: 'Report4PDF'.
R4PPage namespacePath: #(#Report4PDF).
%
# Define class R4PString
DoIt
R4PLayout
subclass: 'R4PString'
instVarNames: #(lineBreak endWithLineBreak string positionX)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PString category: 'Report4PDF'.
R4PString namespacePath: #(#Report4PDF).
%
# Define class R4PRow
DoIt
R4PLayout
subclass: 'R4PRow'
instVarNames: #(cellPadding cellSpacing cellBorder maxOutputPage)
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Report4PDF
%
DoIt
R4PRow category: 'Report4PDF'.
R4PRow namespacePath: #(#Report4PDF).
%
DoIt
System myUserProfile removeDictionaryAt: 1.
%
DoIt
| package policy |
package := GsPackageLibrary createPackageNamed: #SessionMethods.
GsPackageLibrary installPackage: package.
policy := GsPackagePolicy current.
policy homeSymbolDict: FileInSymbolDictionary.
policy externalSymbolList: (GsSession currentSession symbolList asArray copyWithout: FileInSymbolDictionary).
policy enable.
%
category: '*Report4PDF-converting'
method: CharacterCollection
asReportString
"replaces #greaseString"
^self asString
%
category: '*Report4PDF-Report4PDF'
method: Array
asLayoutArray
^self
%
category: '*Report4PDF-Report4PDF'
method: Character
asReportString
^String with: self
%
category: '*Report4PDF-Report4PDF'
method: Number
asLayoutArray
"top right bottom left"
^Array
with: self
with: self
with: self
with: self
%
category: '*Report4PDF-Report4PDF'
method: Object
asReportString
^self printString
%
DoIt
| dict policy |
dict := SymbolDictionary new.
dict at: #UNWRITABLE put: dict.
dict immediateInvariant.
policy := GsPackagePolicy current.
policy homeSymbolDict: dict.
policy externalSymbolList: Array new.
policy enable.
%
DoIt
System myUserProfile insertDictionary: Report4PDF at: 1.
%
category: 'accessing'
method: R4PBuilder
currentFont
^currentFont
%
method: R4PBuilder
currentFont: anObject
currentFont := anObject
%
method: R4PBuilder
layoutBounds
^self reportPage layoutBounds
%
method: R4PBuilder
outputPages
^outputPages
%
method: R4PBuilder
outputPages: anObject
outputPages := anObject
%
method: R4PBuilder
report
^report
%
method: R4PBuilder
report: anObject
report := anObject
%
method: R4PBuilder
reportPage
^reportPage
%
method: R4PBuilder
reportPage: aPage
reportPage := aPage
%
category: 'accessing - output'
method: R4PBuilder
clearCurrentPage
"use the last outputPage"
self currentPage: nil
%
method: R4PBuilder
currentPage
"currentPage can be set to a previous page for table output; normally it is nil"
^currentPage ifNil: [self outputPages last]
%
method: R4PBuilder
currentPage: aPage
currentPage := aPage
%
method: R4PBuilder
currentPageNumber
^self outputPages indexOf: self currentPage
%
method: R4PBuilder
currentY
^self currentPage currentY
%
method: R4PBuilder
currentY: aNumber
"'currentY:' echo: aNumber."
self currentPage currentY: aNumber
%
method: R4PBuilder
maximumY
"page height - footer height"
^self currentPage maximumY
%
method: R4PBuilder
maximumY: aNumber
self currentPage maximumY: aNumber
%
method: R4PBuilder
remainingY
^self maximumY - self currentY
%
category: 'actions'
method: R4PBuilder
addOutput: anOutput
self currentPage outputAdd: anOutput
%
method: R4PBuilder
addOutputAll: aCollection
aCollection do: [:each |
self currentPage outputAdd: each]
%
method: R4PBuilder
checkFitImage: aLayoutImage
aLayoutImage outputOnNewPage ifFalse: [
(aLayoutImage canBuildAt: self currentY limit: self maximumY) ifTrue: [^self]].
(aLayoutImage layoutHeight > aLayoutImage pageHeight) ifTrue: [
^self reportError: 'Image cannot fit on page'].
self pageBreak.
self incrementY: aLayoutImage spacingTop.
aLayoutImage layoutTop: self currentY.
aLayoutImage parent buildNewPageParent: self.
aLayoutImage parent buildNextPageParent: self.
%
method: R4PBuilder
checkFitLine: aLayoutLine
aLayoutLine outputOnNewPage ifFalse: [
(aLayoutLine canBuildAt: self currentY limit: self maximumY) ifTrue: [^self]].
self pageBreak.
self incrementY: aLayoutLine spacingTop.
aLayoutLine layoutTop: self currentY.
aLayoutLine parent buildNewPageParent: self.
aLayoutLine parent buildNextPageParent: self.
%
method: R4PBuilder
checkFitRowBottom: aLayoutRow
"a row's cells will create new output pages as required; row's bottom spacing may trigger a page break.
cell's leave current Y unchanged, so the row has to do the final increment"
(self findPageToFitRowBottom: aLayoutRow) ifTrue: [
^self incrementY: aLayoutRow layoutHeight].
self pageBreak.
self incrementY: aLayoutRow spacingTop.
%
method: R4PBuilder
checkFitRowTop: aLayoutRow
"we have cases where = failed on floats that should be equal"
aLayoutRow outputOnNewPage ifFalse: [
(self findPageToFitRowTop: aLayoutRow) ifTrue: [^self]].
self pageBreak.
aLayoutRow layoutTop: self currentY.
aLayoutRow parent buildNewPageParent: self.
aLayoutRow parent buildNextPageParent: self.
%
method: R4PBuilder
checkFitSpacingBottom: aLayoutText
aLayoutText isFixedLayout ifTrue: [^self].
(aLayoutText
canEndAtY: self currentY
limit: self maximumY)
ifTrue: [self incrementY: aLayoutText spacingBottom]
ifFalse: [self pageBreak]
%
method: R4PBuilder
checkFitSpacingTop: aLayout
"make sure there is room from top spacing; each line of text will check to see if it fits and may trigger a page break"
aLayout outputOnNewPage ifFalse: [
(self findPageToFitLayout: aLayout) ifTrue: [^true]].
self pageBreak.
self incrementY: aLayout spacingTop.
aLayout layoutTop: self currentY.
aLayout parent buildNewPageParent: self.
aLayout parent buildNextPageParent: self.
^false
%
method: R4PBuilder
checkFitString: aLayoutString
"check fit again in case next page also does not fit.
parent border may need to be done again if this is a row cell"
aLayoutString outputOnNewPage ifFalse: [
(self findPageToFitString: aLayoutString) ifTrue: [^self]].
self pageBreak.
self setLayout: aLayoutString.
aLayoutString parent buildNewPageParent: self.
aLayoutString parent buildNextPageParent: self.
%
method: R4PBuilder
findPageToFitLayout: aLayout
(aLayout canBuildAt: self currentY limit: self maximumY) ifTrue: [^true].
[self currentPage nextPage notNil] whileTrue: [
self currentPage: self currentPage nextPage.
(aLayout canBuildAt: self currentY limit: self maximumY) ifTrue: [^true]].
^false
%
method: R4PBuilder
findPageToFitRowBottom: aLayoutRow
"need to increment Y after all the cells are done"
(aLayoutRow canEndAtY: self currentY limit: self maximumY) ifTrue: [^true].
[self currentPage nextPage notNil] whileTrue: [
self currentPage: self currentPage nextPage.
(aLayoutRow canEndAtY: self currentY limit: self maximumY) ifTrue: [^true]].
^false
%
method: R4PBuilder
findPageToFitRowTop: aLayoutRow
(aLayoutRow canBuildAt: self currentY limit: self maximumY) ifTrue: [^true].
[self currentPage nextPage notNil] whileTrue: [
self currentPage: self currentPage nextPage.
(aLayoutRow canBuildAt: self currentY limit: self maximumY) ifTrue: [^true]].
^false
%
method: R4PBuilder
findPageToFitString: aLayoutString
(aLayoutString canBuildAt: self currentY limit: self maximumY) ifTrue: [^true].
[self currentPage nextPage notNil] whileTrue: [
self currentPage resetCurrentY.
self currentPage: self currentPage nextPage.
(aLayoutString canBuildAt: self currentY limit: self maximumY) ifTrue: [
aLayoutString parent buildNextPageParent: self.
^true]].
^false
%
method: R4PBuilder
incrementY: aNumber
| newY |
newY := self currentY + aNumber.
(newY roundTo: 0.01) > (self maximumY roundTo: 0.01) ifTrue: [
^self reportError: 'PRwBuilder>>incrementY: ', aNumber printString, ' exceeded maximumY: ', self maximumY printString].
self currentY: newY
%
method: R4PBuilder
newOutputPage
self outputPagesAdd: R4POutputPage new.
%
method: R4PBuilder
outputPagesAdd: aPage
self outputPages add: aPage.
aPage outputPageIndex: (self outputPages indexOf: aPage).
self reportPage outputPagesAdd: aPage.
%
method: R4PBuilder
pageBreak
"A 2nd page break can be triggered from a table cell if it's neighbour already triggered one.
aBlock is only intended for 'new' pages, not when revisiting 'next' pages"
| nextPage |
nextPage := self currentPage createNextPageOutput.
self currentPage resetCurrentY.
self clearCurrentPage.
self outputPagesAdd: nextPage.
self buildPageSetup.
%
method: R4PBuilder
resetCurrentYAfter: aBlock
| previousY previousPage |
previousY := self currentY.
previousPage := self currentPage.
aBlock value.
self currentPage resetCurrentY.
self currentPage: previousPage.
self currentY: previousY.
%
method: R4PBuilder
setCurrentPage: anOutputPage
"a nested table may need to set the currentPage to a page that is not the 'largest'
if outputPages is emtpy at this point, we have an error"
self outputPages last == anOutputPage ifTrue: [
self clearCurrentPage].
self currentPage: anOutputPage.
%
method: R4PBuilder
setLayout: aLayout
aLayout layoutTop: self currentY.
aLayout setBoxBottomLimit: self maximumY.
self incrementY: aLayout spacingTop.
%
method: R4PBuilder
updateOutputPages
"replace strings if total pages pattern is used"
"need to fix root cause of extra output pages with tables that have page breaks.
See exampleTextColumnsPageBreaks2"
| count |
self outputPages: (self outputPages reject: [:each | each output isEmpty]).
count := 0.
self outputPages do: [:eachPage |
count := count + 1.
eachPage nextPageNumber notNil ifTrue: [
count := eachPage nextPageNumber].
eachPage
replaceString: self report pageNumberPattern
with: count printString.
eachPage
replaceString: self report pageTotalPattern
with: eachPage outputPagesSize printString.
eachPage
replaceString: self report reportTotalPattern
with: self outputPages size printString].
%
category: 'build'
method: R4PBuilder
buildPage
self clearCurrentPage.
self newOutputPage.
self buildPageSetup.
self buildPageSections.
%
method: R4PBuilder
buildPages
"for debugging, send #buildPagesX"
[self buildPagesX]
on: R4PError
do: [:ex | self currentPage outputErrorMessage: '*** ERROR building PDF document: ', ex displayString].
%
method: R4PBuilder
buildPageSections
self reportPage layoutSections do: [:each | each buildOutput: self].
%
method: R4PBuilder
buildPageSetup
self currentPage
pageWidth: self report pageWidth;
pageHeight: self report pageHeight.
self currentY: self reportPage layoutTop.
self maximumY: self reportPage layoutBottom.
self currentPage previousPage isNil ifTrue: [ "only done by first output page"
self currentPage nextPageNumber: self reportPage nextPageNumber].
self reportPage buildWatermark: self.
self buildFooter.
self buildHeader.
%
method: R4PBuilder
buildPagesX
self report pages do: [:eachPage |
self reportPage: eachPage.
self buildPage]
%
method: R4PBuilder
buildReport: aReport
| document |
[
aReport start.
self report: aReport.
aReport builder: self.
self buildPages.
self updateOutputPages.
aReport traceOutput: aReport printOutput.
aReport traceOutput: 'output pages: ', self outputPages size printString
] ensure: [
aReport end].
document := (PDFtalk at: #Document) new.
self outputPages do: [:each |
document root addPage: each renderPage].
^document
%
category: 'build - layout'
method: R4PBuilder
buildBackground: aLayout
aLayout hasBackground ifFalse: [^self].
self addOutput: (aLayout outputBackgroundAt: self currentPageNumber)
%
method: R4PBuilder
buildBorder: aLayout
aLayout hasBorder ifFalse: [^self].
self currentPage outputBorder: aLayout at: self currentPageNumber.
%
method: R4PBuilder
buildBullet: aBulletLayout
self checkFitSpacingTop: aBulletLayout.
self resetCurrentYAfter: [
self setLayout: aBulletLayout.
self buildBackground: aBulletLayout bulletText.
self buildBorder: aBulletLayout bulletText.
self incrementY: aBulletLayout bulletTextYAdjustment.
self buildText: aBulletLayout bulletText].
self buildSection: aBulletLayout.
%
method: R4PBuilder
buildCell: aLayoutCell
"reset currentY because the cell contents may be multi-line ... contains truncated text if rowSpan > 1 and height > total row height"
self resetCurrentYAfter: [
self checkFitSpacingTop: aLayoutCell.
self setLayout: aLayoutCell.
self buildBackground: aLayoutCell.
self buildBorder: aLayoutCell.
self buildSections: aLayoutCell.
self addOutputAll: aLayoutCell outputTruncated.
aLayoutCell outputPage: self currentPage; built: true].
%
method: R4PBuilder
buildFixedImage: aLayoutImage
self resetCurrentYAfter: [
self currentY: aLayoutImage fixedTop.
self incrementY: aLayoutImage spacingTop.
self addOutput: aLayoutImage outputImage.
self buildBorder: aLayoutImage.
self buildSections: aLayoutImage]
%
method: R4PBuilder
buildFixedSection: aSection
self resetCurrentYAfter: [
self currentY: aSection fixedTop.
self incrementY: aSection spacingTop.
self buildBackground: aSection.
self buildBorder: aSection.
self buildSections: aSection].
%
method: R4PBuilder
buildFooter
| previousY newMaximumY |
self reportPage footer layoutSections isEmpty ifTrue: [^self].
newMaximumY := (self maximumY) - (self reportPage footer layoutHeight).
previousY := self currentY.
self currentY: newMaximumY.
self buildSection: self reportPage footer.
self maximumY: newMaximumY.
self currentY: previousY.
%
method: R4PBuilder
buildHeader
(self reportPage header layoutHeight) > (self report pageHeight) ifTrue: [
self error: 'header height is greate than page height: ',
((self reportPage header layoutHeight) -> (self report pageHeight)) printString].
self buildSection: self reportPage header.
self currentPage setMinimumY.
%
method: R4PBuilder
buildImage: aLayoutImage
"border is done after image in case padding is not set; border will overlay the image edge, othewise it would be invisible"
aLayoutImage isFixedLayout ifTrue: [
^self buildFixedImage: aLayoutImage].
self checkFitImage: aLayoutImage.
self setLayout: aLayoutImage.
self addOutput: aLayoutImage outputImage.
self buildBorder: aLayoutImage.
self incrementY: aLayoutImage layoutHeight.
self buildSections: aLayoutImage.
aLayoutImage built: true.
%
method: R4PBuilder
buildLine: aLayoutLine
aLayoutLine isFixedLayout ifTrue: [
^self addOutput: aLayoutLine fixedOutputLine].
self checkFitLine: aLayoutLine.
self setLayout: aLayoutLine.
self addOutput: aLayoutLine outputLine.
aLayoutLine built: true.
self incrementY: aLayoutLine nestedLayoutHeight + aLayoutLine spacingBottom.
%
method: R4PBuilder
buildRow: aLayoutRow
self checkFitRowTop: aLayoutRow.
self setLayout: aLayoutRow.
self buildBackground: aLayoutRow.
self buildBorder: aLayoutRow.
aLayoutRow setCellHeight.
self buildSections: aLayoutRow.
self setCurrentPage: aLayoutRow maxOutputPage.
self checkFitRowBottom: aLayoutRow.
aLayoutRow built: true.
%
method: R4PBuilder
buildSection: aSection
aSection isFixedLayout ifTrue: [
^self buildFixedSection: aSection].
self checkFitSpacingTop: aSection.
self setLayout: aSection.
self buildBackground: aSection.
self buildBorder: aSection.
self buildSections: aSection.
aSection built: true.
%
method: R4PBuilder
buildSections: aLayout
aLayout layoutSections do: [:each | each buildOutput: self].
%
method: R4PBuilder
buildString: aLayoutString
"fit is checked for a string prior to adding it, so there should not be a page break after it is added.
Sender increments Y ... different for footer vs. regular text"
self checkFitString: aLayoutString.
aLayoutString layoutTop: self currentY.
self addOutputAll: aLayoutString outputContent.