Skip to content

Commit 6297738

Browse files
committed
Rasamassen PR 2838
I made RTF usable some time ago. @rasamassen has recently done a lot of useful work to cover many missing areas. Since who knows when those changes will be merged, I intend to incorporate much of that work. I will do this with several pushes, each based on one or more of those changes. This one is based on PR #2838.
1 parent e592785 commit 6297738

File tree

11 files changed

+592
-95
lines changed

11 files changed

+592
-95
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -480,11 +480,6 @@ parameters:
480480
count: 1
481481
path: src/PhpWord/Style/AbstractStyle.php
482482

483-
-
484-
message: "#^Method PhpOffice\\\\PhpWord\\\\Style\\\\Border\\:\\:getBorderSize\\(\\) should return array\\<int\\> but returns array\\<int, float\\|int\\>\\.$#"
485-
count: 1
486-
path: src/PhpWord/Style/Border.php
487-
488483
-
489484
message: "#^Method PhpOffice\\\\PhpWord\\\\Style\\\\Cell\\:\\:getBgColor\\(\\) should return string but returns null\\.$#"
490485
count: 1

phpstan-baseline.php73.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,6 @@ parameters:
470470
count: 1
471471
path: src/PhpWord/Style/AbstractStyle.php
472472

473-
-
474-
message: "#^Method PhpOffice\\\\PhpWord\\\\Style\\\\Border\\:\\:getBorderSize\\(\\) should return array\\<int\\> but returns array\\<int, float\\|int\\>\\.$#"
475-
count: 1
476-
path: src/PhpWord/Style/Border.php
477-
478473
-
479474
message: "#^Method PhpOffice\\\\PhpWord\\\\Style\\\\Cell\\:\\:getBgColor\\(\\) should return string but returns null\\.$#"
480475
count: 1

src/PhpWord/SimpleType/Border.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ final class Border extends AbstractEnum
4848
const THIN_THICK_LARGE_GAP = 'thinThickLargeGap'; //A thin line contained within a thick line with a large-sized intermediate gap
4949
const THIN_THICK_MEDIUM_GAP = 'thinThickMediumGap'; //A thick line contained within a thin line with a medium-sized intermediate gap
5050
const THIN_THICK_SMALL_GAP = 'thinThickSmallGap'; //A thick line contained within a thin line with a small intermediate gap
51+
/** @deprecated 2.0 use THIN_THICK_THIN_LARGE_GAP */
5152
const THIN_THICK_THINLARGE_GAP = 'thinThickThinLargeGap'; //A thin-thick-thin line with a large gap
53+
const THIN_THICK_THIN_LARGE_GAP = 'thinThickThinLargeGap'; //A thin-thick-thin line with a large gap
5254
const THIN_THICK_THIN_MEDIUM_GAP = 'thinThickThinMediumGap'; //A thin-thick-thin line with a medium gap
5355
const THIN_THICK_THIN_SMALL_GAP = 'thinThickThinSmallGap'; //A thin-thick-thin line with a small gap
5456
const THREE_D_EMBOSS = 'threeDEmboss'; //A three-staged gradient line, getting darker towards the paragraph

src/PhpWord/Style/Border.php

Lines changed: 159 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ class Border extends AbstractStyle
4646
*/
4747
protected $borderTopStyle;
4848

49+
/**
50+
* Border Top Space. For section and paragraph borders only.
51+
*
52+
* @var float|int
53+
*/
54+
protected $borderTopSpace;
55+
4956
/**
5057
* Border Left Size.
5158
*
@@ -67,6 +74,13 @@ class Border extends AbstractStyle
6774
*/
6875
protected $borderLeftStyle;
6976

77+
/**
78+
* Border Left Space. For section and paragraph borders only.
79+
*
80+
* @var float|int
81+
*/
82+
protected $borderLeftSpace;
83+
7084
/**
7185
* Border Right Size.
7286
*
@@ -88,6 +102,13 @@ class Border extends AbstractStyle
88102
*/
89103
protected $borderRightStyle;
90104

105+
/**
106+
* Border Right Space. For section and paragraph borders only.
107+
*
108+
* @var float|int
109+
*/
110+
protected $borderRightSpace;
111+
91112
/**
92113
* Border Bottom Size.
93114
*
@@ -109,6 +130,13 @@ class Border extends AbstractStyle
109130
*/
110131
protected $borderBottomStyle;
111132

133+
/**
134+
* Border Bottom Space. For section and paragraph borders only.
135+
*
136+
* @var float|int
137+
*/
138+
protected $borderBottomSpace;
139+
112140
/**
113141
* Top margin spacing.
114142
*
@@ -140,7 +168,7 @@ class Border extends AbstractStyle
140168
/**
141169
* Get border size.
142170
*
143-
* @return int[]
171+
* @return array<float|int>
144172
*/
145173
public function getBorderSize()
146174
{
@@ -233,6 +261,38 @@ public function setBorderStyle($value = null)
233261
return $this;
234262
}
235263

264+
/**
265+
* Get border space.
266+
*
267+
* @return array<float|int>
268+
*/
269+
public function getBorderSpace()
270+
{
271+
return [
272+
$this->getBorderTopSpace(),
273+
$this->getBorderLeftSpace(),
274+
$this->getBorderRightSpace(),
275+
$this->getBorderBottomSpace(),
276+
];
277+
}
278+
279+
/**
280+
* Set border space.
281+
*
282+
* @param float|int $value
283+
*
284+
* @return self
285+
*/
286+
public function setBorderSpace($value = null)
287+
{
288+
$this->setBorderTopSpace($value);
289+
$this->setBorderLeftSpace($value);
290+
$this->setBorderRightSpace($value);
291+
$this->setBorderBottomSpace($value);
292+
293+
return $this;
294+
}
295+
236296
/**
237297
* Get border top size.
238298
*
@@ -292,7 +352,7 @@ public function getBorderTopStyle()
292352
}
293353

294354
/**
295-
* Set border top Style.
355+
* Set border top style.
296356
*
297357
* @param string $value
298358
*
@@ -305,6 +365,30 @@ public function setBorderTopStyle($value = null)
305365
return $this;
306366
}
307367

368+
/**
369+
* Get border top space.
370+
*
371+
* @return float|int
372+
*/
373+
public function getBorderTopSpace()
374+
{
375+
return $this->borderTopSpace;
376+
}
377+
378+
/**
379+
* Set border top space.
380+
*
381+
* @param float|int $value
382+
*
383+
* @return self
384+
*/
385+
public function setBorderTopSpace($value = null)
386+
{
387+
$this->borderTopSpace = $value;
388+
389+
return $this;
390+
}
391+
308392
/**
309393
* Get border left size.
310394
*
@@ -377,6 +461,30 @@ public function setBorderLeftStyle($value = null)
377461
return $this;
378462
}
379463

464+
/**
465+
* Get border left space.
466+
*
467+
* @return float|int
468+
*/
469+
public function getBorderLeftSpace()
470+
{
471+
return $this->borderLeftSpace;
472+
}
473+
474+
/**
475+
* Set border left space.
476+
*
477+
* @param float|int $value
478+
*
479+
* @return self
480+
*/
481+
public function setBorderLeftSpace($value = null)
482+
{
483+
$this->borderLeftSpace = $value;
484+
485+
return $this;
486+
}
487+
380488
/**
381489
* Get border right size.
382490
*
@@ -449,6 +557,30 @@ public function setBorderRightStyle($value = null)
449557
return $this;
450558
}
451559

560+
/**
561+
* Get border right space.
562+
*
563+
* @return float|int
564+
*/
565+
public function getBorderRightSpace()
566+
{
567+
return $this->borderRightSpace;
568+
}
569+
570+
/**
571+
* Set border right space.
572+
*
573+
* @param float|int $value
574+
*
575+
* @return self
576+
*/
577+
public function setBorderRightSpace($value = null)
578+
{
579+
$this->borderRightSpace = $value;
580+
581+
return $this;
582+
}
583+
452584
/**
453585
* Get border bottom size.
454586
*
@@ -521,22 +653,38 @@ public function setBorderBottomStyle($value = null)
521653
return $this;
522654
}
523655

656+
/**
657+
* Get border bottom space.
658+
*
659+
* @return float|int
660+
*/
661+
public function getBorderBottomSpace()
662+
{
663+
return $this->borderBottomSpace;
664+
}
665+
666+
/**
667+
* Set border bottom space.
668+
*
669+
* @param float|int $value
670+
*
671+
* @return self
672+
*/
673+
public function setBorderBottomSpace($value = null)
674+
{
675+
$this->borderBottomSpace = $value;
676+
677+
return $this;
678+
}
679+
524680
/**
525681
* Check if any of the border is not null.
526682
*
527683
* @return bool
528684
*/
529685
public function hasBorder()
530686
{
531-
$borders = $this->getBorderSize();
532-
if ($borders !== array_filter($borders, 'is_null')) {
533-
return true;
534-
}
535-
$borders = $this->getBorderColor();
536-
if ($borders !== array_filter($borders, 'is_null')) {
537-
return true;
538-
}
539-
$borders = $this->getBorderStyle();
687+
$borders = array_merge($this->getBorderSize(), $this->getBorderColor(), $this->getBorderStyle(), $this->getBorderSpace());
540688

541689
return $borders !== array_filter($borders, 'is_null');
542690
}

0 commit comments

Comments
 (0)