1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sprain\SwissQrBill\PaymentPart\Output\PhpWordOutput; |
4
|
|
|
|
5
|
|
|
use PhpOffice\PhpWord\PhpWord; |
6
|
|
|
use PhpOffice\PhpWord\Shared\Converter; |
7
|
|
|
use PhpOffice\PhpWord\SimpleType\Jc; |
8
|
|
|
use PhpOffice\PhpWord\SimpleType\LineSpacingRule; |
9
|
|
|
|
10
|
|
|
abstract class FontStyle |
11
|
|
|
{ |
12
|
|
|
const FONT_FAMILY = 'Helvetica'; |
13
|
|
|
const FONT_STYLE_TITLE = 'SwissBill Title'; |
14
|
|
|
const FONT_STYLE_HEADING_RECEIPT = 'SwissBill Receipt Heading'; |
15
|
|
|
const FONT_STYLE_VALUE_RECEIPT = 'SwissBill Receipt Value'; |
16
|
|
|
const FONT_STYLE_AMOUNT_RECEIPT = 'SwissBill Receipt Amount'; |
17
|
|
|
const FONT_STYLE_ACCEPTANCE_POINT = 'SwissBill Acceptance point'; |
18
|
|
|
const FONT_STYLE_HEADING_PAYMENT_PART = 'SwissBill Payment part Heading'; |
19
|
|
|
const FONT_STYLE_VALUE_PAYMENT_PART = 'SwissBill Payment part Value'; |
20
|
|
|
const FONT_STYLE_AMOUNT_PAYMENT_PART = 'SwissBill Payment part Amount'; |
21
|
|
|
const FONT_STYLE_FURTHER_INFORMATION_PAYMENT_PART = 'SwissBill Payment part Further information'; |
22
|
|
|
const FONT_STYLE_SEPARATOR = 'SwissBill Separator'; |
23
|
|
|
|
24
|
|
|
private static string $currentText = self::FONT_STYLE_VALUE_RECEIPT; |
25
|
|
|
|
26
|
|
|
public static function getCurrentText() : string |
27
|
|
|
{ |
28
|
|
|
return self::$currentText; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public static function setCurrentText(string $fStyle) |
32
|
|
|
{ |
33
|
|
|
self::$currentText = $fStyle; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public static function defineFontStyles(PhpWord $phpWord) : void |
37
|
|
|
{ |
38
|
|
|
$phpWord->addFontStyle( |
39
|
|
|
self::FONT_STYLE_TITLE, |
40
|
|
|
[ |
41
|
|
|
'name' => self::FONT_FAMILY, |
42
|
|
|
'size' => 11, |
43
|
|
|
'bold' => true, |
44
|
|
|
] |
45
|
|
|
); |
46
|
|
|
$phpWord->addFontStyle( |
47
|
|
|
self::FONT_STYLE_HEADING_RECEIPT, |
48
|
|
|
[ |
49
|
|
|
'name' => self::FONT_FAMILY, |
50
|
|
|
'size' => 6, |
51
|
|
|
'bold' => true, |
52
|
|
|
], |
53
|
|
|
[ |
54
|
|
|
'spacing' => Converter::pointToTwip(9), |
55
|
|
|
'spacingLineRule' => LineSpacingRule::EXACT, |
56
|
|
|
'spaceAfter' => 0, |
57
|
|
|
] |
58
|
|
|
); |
59
|
|
|
$phpWord->addFontStyle( |
60
|
|
|
self::FONT_STYLE_VALUE_RECEIPT, |
61
|
|
|
[ |
62
|
|
|
'name' => self::FONT_FAMILY, |
63
|
|
|
'size' => 8, |
64
|
|
|
], |
65
|
|
|
[ |
66
|
|
|
'spacing' => Converter::pointToTwip(9), |
67
|
|
|
'spacingLineRule' => LineSpacingRule::EXACT, |
68
|
|
|
'spaceAfter' => 0, |
69
|
|
|
] |
70
|
|
|
); |
71
|
|
|
$phpWord->addFontStyle( |
72
|
|
|
self::FONT_STYLE_AMOUNT_RECEIPT, |
73
|
|
|
[ |
74
|
|
|
'name' => self::FONT_FAMILY, |
75
|
|
|
'size' => 8, |
76
|
|
|
], |
77
|
|
|
[ |
78
|
|
|
'spacing' => Converter::pointToTwip(11), |
79
|
|
|
'spacingLineRule' => LineSpacingRule::EXACT, |
80
|
|
|
'spaceAfter' => 0, |
81
|
|
|
] |
82
|
|
|
); |
83
|
|
|
$phpWord->addFontStyle( |
84
|
|
|
self::FONT_STYLE_ACCEPTANCE_POINT, |
85
|
|
|
[ |
86
|
|
|
'name' => self::FONT_FAMILY, |
87
|
|
|
'size' => 6, |
88
|
|
|
'bold' => true, |
89
|
|
|
], |
90
|
|
|
[ |
91
|
|
|
'spacing' => Converter::pointToTwip(8), |
92
|
|
|
'spacingLineRule' => LineSpacingRule::EXACT, |
93
|
|
|
'spaceAfter' => 0, |
94
|
|
|
'alignment' => Jc::END, |
95
|
|
|
] |
96
|
|
|
); |
97
|
|
|
$phpWord->addFontStyle( |
98
|
|
|
self::FONT_STYLE_HEADING_PAYMENT_PART, |
99
|
|
|
[ |
100
|
|
|
'name' => self::FONT_FAMILY, |
101
|
|
|
'size' => 8, |
102
|
|
|
'bold' => true, |
103
|
|
|
], |
104
|
|
|
[ |
105
|
|
|
'spacing' => Converter::pointToTwip(11), |
106
|
|
|
'spacingLineRule' => LineSpacingRule::EXACT, |
107
|
|
|
'spaceAfter' => 0, |
108
|
|
|
] |
109
|
|
|
); |
110
|
|
|
$phpWord->addFontStyle( |
111
|
|
|
self::FONT_STYLE_VALUE_PAYMENT_PART, |
112
|
|
|
[ |
113
|
|
|
'name' => self::FONT_FAMILY, |
114
|
|
|
'size' => 10, |
115
|
|
|
], |
116
|
|
|
[ |
117
|
|
|
'spacing' => Converter::pointToTwip(11), |
118
|
|
|
'spacingLineRule' => LineSpacingRule::EXACT, |
119
|
|
|
'spaceAfter' => 0, |
120
|
|
|
] |
121
|
|
|
); |
122
|
|
|
$phpWord->addFontStyle( |
123
|
|
|
self::FONT_STYLE_AMOUNT_PAYMENT_PART, |
124
|
|
|
[ |
125
|
|
|
'name' => self::FONT_FAMILY, |
126
|
|
|
'size' => 10, |
127
|
|
|
], |
128
|
|
|
[ |
129
|
|
|
'spacing' => Converter::pointToTwip(13), |
130
|
|
|
'spacingLineRule' => LineSpacingRule::EXACT, |
131
|
|
|
'spaceAfter' => 0, |
132
|
|
|
] |
133
|
|
|
); |
134
|
|
|
|
135
|
|
|
$fontStyle = [ |
136
|
|
|
'name' => self::FONT_FAMILY, |
137
|
|
|
'size' => 7, |
138
|
|
|
]; |
139
|
|
|
$paragraphStyle = [ |
140
|
|
|
'spacing' => Converter::pointToTwip(8), |
141
|
|
|
'spacingLineRule' => LineSpacingRule::EXACT, |
142
|
|
|
'spaceAfter' => 0, |
143
|
|
|
]; |
144
|
|
|
$phpWord->addFontStyle( |
145
|
|
|
self::FONT_STYLE_FURTHER_INFORMATION_PAYMENT_PART, |
146
|
|
|
$fontStyle, |
147
|
|
|
$paragraphStyle |
148
|
|
|
); |
149
|
|
|
$phpWord->addFontStyle( |
150
|
|
|
self::FONT_STYLE_SEPARATOR, |
151
|
|
|
$fontStyle, |
152
|
|
|
array_merge($paragraphStyle, ['alignment' => Jc::CENTER]), |
153
|
|
|
); |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
|