File tree 2 files changed +41
-1
lines changed 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,14 @@ class PHPWord_Style_Paragraph {
64
64
private $ _spacing ;
65
65
66
66
67
+ /**
68
+ * Indent by how much
69
+ *
70
+ * @var int
71
+ */
72
+ private $ _indent ;
73
+
74
+
67
75
/**
68
76
* New Paragraph Style
69
77
*/
@@ -72,6 +80,7 @@ public function __construct() {
72
80
$ this ->_spaceBefore = null ;
73
81
$ this ->_spaceAfter = null ;
74
82
$ this ->_spacing = null ;
83
+ $ this ->_indent = null ;
75
84
}
76
85
77
86
/**
@@ -84,6 +93,9 @@ public function setStyleValue($key, $value) {
84
93
if ($ key == '_spacing ' ) {
85
94
$ value += 240 ; // because line height of 1 matches 240 twips
86
95
}
96
+ if ($ key == '_indent ' ) {
97
+ $ value = (int )$ value * 720 ; // 720 twips per indent
98
+ }
87
99
$ this ->$ key = $ value ;
88
100
}
89
101
@@ -170,5 +182,25 @@ public function setSpacing($pValue = null) {
170
182
$ this ->_spacing = $ pValue ;
171
183
return $ this ;
172
184
}
185
+
186
+ /**
187
+ * Get indentation
188
+ *
189
+ * @return int
190
+ */
191
+ public function getIndent () {
192
+ return $ this ->_indent ;
193
+ }
194
+
195
+ /**
196
+ * Set indentation
197
+ *
198
+ * @param int $pValue
199
+ * @return PHPWord_Style_Paragraph
200
+ */
201
+ public function setIndent ($ pValue = null ) {
202
+ $ this ->_indent = $ pValue ;
203
+ return $ this ;
204
+ }
173
205
}
174
206
?>
Original file line number Diff line number Diff line change @@ -113,9 +113,10 @@ protected function _writeParagraphStyle(PHPWord_Shared_XMLWriter $objWriter = nu
113
113
$ spaceBefore = $ style ->getSpaceBefore ();
114
114
$ spaceAfter = $ style ->getSpaceAfter ();
115
115
$ spacing = $ style ->getSpacing ();
116
+ $ indent = $ style ->getIndent ();
116
117
117
118
118
- if (!is_null ($ align ) || !is_null ($ spacing ) || !is_null ($ spaceBefore ) || !is_null ($ spaceAfter )) {
119
+ if (!is_null ($ align ) || !is_null ($ spacing ) || !is_null ($ spaceBefore ) || !is_null ($ spaceAfter ) || ! is_null ( $ indent ) ) {
119
120
120
121
if (!$ withoutPPR ) {
121
122
$ objWriter ->startElement ('w:pPr ' );
@@ -127,6 +128,13 @@ protected function _writeParagraphStyle(PHPWord_Shared_XMLWriter $objWriter = nu
127
128
$ objWriter ->endElement ();
128
129
}
129
130
131
+ if (!is_null ($ indent )) {
132
+ $ objWriter ->startElement ('w:ind ' );
133
+ $ objWriter ->writeAttribute ('w:firstLine ' , 0 );
134
+ $ objWriter ->writeAttribute ('w:left ' , $ indent );
135
+ $ objWriter ->endElement ();
136
+ }
137
+
130
138
if (!is_null ($ spaceBefore ) || !is_null ($ spaceAfter ) || !is_null ($ spacing )) {
131
139
132
140
$ objWriter ->startElement ('w:spacing ' );
You can’t perform that action at this time.
0 commit comments