Merge pull request #1536 from Samuel-BF/fix-RTF-numerals

For RTF writers, sizes should should never have decimals
This commit is contained in:
troosan 2018-12-26 23:16:22 +01:00 committed by GitHub
commit 0f963e40a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 15 deletions

View File

@ -22,6 +22,7 @@ v0.16.0 (xx dec 2018)
- Fix loading of Sharepoint document @Garrcomm #1498 - Fix loading of Sharepoint document @Garrcomm #1498
- RTF writer: Round getPageSizeW and getPageSizeH to avoid decimals @Patrick64 #1493 - RTF writer: Round getPageSizeW and getPageSizeH to avoid decimals @Patrick64 #1493
- Fix parsing of Office 365 documents @Timanx #1485 - Fix parsing of Office 365 documents @Timanx #1485
- For RTF writers, sizes should should never have decimals @Samuel-BF #1536
### Miscelaneous ### Miscelaneous
- Get rid of duplicated code in TemplateProcessor @abcdmitry #1161 - Get rid of duplicated code in TemplateProcessor @abcdmitry #1161

View File

@ -92,7 +92,7 @@ class Border extends AbstractStyle
$content .= '\pgbrdr' . substr($side, 0, 1); $content .= '\pgbrdr' . substr($side, 0, 1);
$content .= '\brdrs'; // Single-thickness border; @todo Get other type of border $content .= '\brdrs'; // Single-thickness border; @todo Get other type of border
$content .= '\brdrw' . $width; // Width $content .= '\brdrw' . round($width); // Width
$content .= '\brdrcf' . $colorIndex; // Color $content .= '\brdrcf' . $colorIndex; // Color
$content .= '\brsp480'; // Space in twips between borders and the paragraph (24pt, following OOXML) $content .= '\brsp480'; // Space in twips between borders and the paragraph (24pt, following OOXML)
$content .= ' '; $content .= ' ';

View File

@ -53,7 +53,7 @@ class Font extends AbstractStyle
$content .= '\f' . $this->nameIndex; $content .= '\f' . $this->nameIndex;
$size = $style->getSize(); $size = $style->getSize();
$content .= $this->getValueIf(is_numeric($size), '\fs' . ($size * 2)); $content .= $this->getValueIf(is_numeric($size), '\fs' . round($size * 2));
$content .= $this->getValueIf($style->isBold(), '\b'); $content .= $this->getValueIf($style->isBold(), '\b');
$content .= $this->getValueIf($style->isItalic(), '\i'); $content .= $this->getValueIf($style->isItalic(), '\i');

View File

@ -36,9 +36,9 @@ class Indentation extends AbstractStyle
return ''; return '';
} }
$content = '\fi' . $style->getFirstLine(); $content = '\fi' . round($style->getFirstLine());
$content .= '\li' . $style->getLeft(); $content .= '\li' . round($style->getLeft());
$content .= '\ri' . $style->getRight(); $content .= '\ri' . round($style->getRight());
return $content . ' '; return $content . ' ';
} }

View File

@ -65,8 +65,8 @@ class Paragraph extends AbstractStyle
$content .= $alignments[$style->getAlignment()]; $content .= $alignments[$style->getAlignment()];
} }
$content .= $this->writeIndentation($style->getIndentation()); $content .= $this->writeIndentation($style->getIndentation());
$content .= $this->getValueIf($spaceBefore !== null, '\sb' . $spaceBefore); $content .= $this->getValueIf($spaceBefore !== null, '\sb' . round($spaceBefore));
$content .= $this->getValueIf($spaceAfter !== null, '\sa' . $spaceAfter); $content .= $this->getValueIf($spaceAfter !== null, '\sa' . round($spaceAfter));
$styles = $style->getStyleValues(); $styles = $style->getStyleValues();
$content .= $this->writeTabs($styles['tabs']); $content .= $this->writeTabs($styles['tabs']);

View File

@ -46,13 +46,13 @@ class Section extends AbstractStyle
$content .= $this->getValueIf($style->getPageSizeW() !== null, '\pgwsxn' . round($style->getPageSizeW())); $content .= $this->getValueIf($style->getPageSizeW() !== null, '\pgwsxn' . round($style->getPageSizeW()));
$content .= $this->getValueIf($style->getPageSizeH() !== null, '\pghsxn' . round($style->getPageSizeH())); $content .= $this->getValueIf($style->getPageSizeH() !== null, '\pghsxn' . round($style->getPageSizeH()));
$content .= ' '; $content .= ' ';
$content .= $this->getValueIf($style->getMarginTop() !== null, '\margtsxn' . $style->getMarginTop()); $content .= $this->getValueIf($style->getMarginTop() !== null, '\margtsxn' . round($style->getMarginTop()));
$content .= $this->getValueIf($style->getMarginRight() !== null, '\margrsxn' . $style->getMarginRight()); $content .= $this->getValueIf($style->getMarginRight() !== null, '\margrsxn' . round($style->getMarginRight()));
$content .= $this->getValueIf($style->getMarginBottom() !== null, '\margbsxn' . $style->getMarginBottom()); $content .= $this->getValueIf($style->getMarginBottom() !== null, '\margbsxn' . round($style->getMarginBottom()));
$content .= $this->getValueIf($style->getMarginLeft() !== null, '\marglsxn' . $style->getMarginLeft()); $content .= $this->getValueIf($style->getMarginLeft() !== null, '\marglsxn' . round($style->getMarginLeft()));
$content .= $this->getValueIf($style->getHeaderHeight() !== null, '\headery' . $style->getHeaderHeight()); $content .= $this->getValueIf($style->getHeaderHeight() !== null, '\headery' . round($style->getHeaderHeight()));
$content .= $this->getValueIf($style->getFooterHeight() !== null, '\footery' . $style->getFooterHeight()); $content .= $this->getValueIf($style->getFooterHeight() !== null, '\footery' . round($style->getFooterHeight()));
$content .= $this->getValueIf($style->getGutter() !== null, '\guttersxn' . $style->getGutter()); $content .= $this->getValueIf($style->getGutter() !== null, '\guttersxn' . round($style->getGutter()));
$content .= ' '; $content .= ' ';
// Borders // Borders

View File

@ -42,7 +42,7 @@ class Tab extends AbstractStyle
if (isset($tabs[$style->getType()])) { if (isset($tabs[$style->getType()])) {
$content .= $tabs[$style->getType()]; $content .= $tabs[$style->getType()];
} }
$content .= '\tx' . $style->getPosition(); $content .= '\tx' . round($style->getPosition());
return $content; return $content;
} }