summaryrefslogtreecommitdiff
path: root/app/Report/ReportPdfCell.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-11-18 15:04:58 +0000
committerGreg Roach <fisharebest@webtrees.net>2019-11-21 19:36:35 +0000
commitb6f35a76f16ee5da672b7d3d886becc6b838498e (patch)
tree519ee5559a2d2c88348f0eabc4e0b02e192afa26 /app/Report/ReportPdfCell.php
parentd12d7677a80e02e389524f0147daae9eea677d09 (diff)
downloadwebtrees-b6f35a76f16ee5da672b7d3d886becc6b838498e.tar.gz
webtrees-b6f35a76f16ee5da672b7d3d886becc6b838498e.tar.bz2
webtrees-b6f35a76f16ee5da672b7d3d886becc6b838498e.zip
Refactor report classes
Diffstat (limited to 'app/Report/ReportPdfCell.php')
-rw-r--r--app/Report/ReportPdfCell.php58
1 files changed, 31 insertions, 27 deletions
diff --git a/app/Report/ReportPdfCell.php b/app/Report/ReportPdfCell.php
index 1ae10a8b15..68d547a724 100644
--- a/app/Report/ReportPdfCell.php
+++ b/app/Report/ReportPdfCell.php
@@ -21,6 +21,11 @@ namespace Fisharebest\Webtrees\Report;
use Fisharebest\Webtrees\Functions\FunctionsRtl;
+use function hexdec;
+use function is_array;
+use function preg_match;
+use function str_replace;
+
/**
* Class ReportPdfCell
*/
@@ -29,13 +34,13 @@ class ReportPdfCell extends ReportBaseCell
/**
* PDF Cell renderer
*
- * @param ReportTcpdf $renderer
+ * @param PdfRenderer $renderer
*
* @return void
*/
public function render($renderer)
{
- $temptext = str_replace('#PAGENUM#', (string) $renderer->PageNo(), $this->text);
+ $temptext = str_replace('#PAGENUM#', (string) $renderer->tcpdf->PageNo(), $this->text);
// underline «title» part of Source item
$temptext = str_replace([
'«',
@@ -53,14 +58,14 @@ class ReportPdfCell extends ReportBaseCell
// Background color
$match = [];
// Indicates if the cell background must be painted (1) or transparent (0)
- if ($this->fill == 1) {
+ if ($this->fill === 1) {
if (!empty($this->bgcolor)) {
// HTML color to RGB
if (preg_match('/#?(..)(..)(..)/', $this->bgcolor, $match)) {
$r = hexdec($match[1]);
$g = hexdec($match[2]);
$b = hexdec($match[3]);
- $renderer->SetFillColor($r, $g, $b);
+ $renderer->tcpdf->SetFillColor($r, $g, $b);
}
} else {
// If no color set then don't fill
@@ -69,28 +74,27 @@ class ReportPdfCell extends ReportBaseCell
}
// Borders
- if (!empty($this->bocolor)) {
- // HTML color to RGB
- if (preg_match('/#?(..)(..)(..)/', $this->bocolor, $match)) {
- $r = hexdec($match[1]);
- $g = hexdec($match[2]);
- $b = hexdec($match[3]);
- $renderer->SetDrawColor($r, $g, $b);
- }
+ // HTML color to RGB
+ if (preg_match('/#?(..)(..)(..)/', $this->bocolor, $match)) {
+ $r = hexdec($match[1]);
+ $g = hexdec($match[2]);
+ $b = hexdec($match[3]);
+ $renderer->tcpdf->SetDrawColor($r, $g, $b);
}
+
// Paint the text color or they might use inherited colors by the previous function
if (preg_match('/#?(..)(..)(..)/', $this->tcolor, $match)) {
$r = hexdec($match[1]);
$g = hexdec($match[2]);
$b = hexdec($match[3]);
- $renderer->SetTextColor($r, $g, $b);
+ $renderer->tcpdf->SetTextColor($r, $g, $b);
} else {
- $renderer->SetTextColor(0, 0, 0);
+ $renderer->tcpdf->SetTextColor(0, 0, 0);
}
// If current position (left)
if ($this->left === ReportBaseElement::CURRENT_POSITION) {
- $cX = $renderer->GetX();
+ $cX = $renderer->tcpdf->GetX();
} else {
// For static position add margin (also updates X)
$cX = $renderer->addMarginX($this->left);
@@ -102,9 +106,9 @@ class ReportPdfCell extends ReportBaseCell
}
// For current position
if ($this->top === ReportBaseElement::CURRENT_POSITION) {
- $this->top = $renderer->GetY();
+ $this->top = $renderer->tcpdf->GetY();
} else {
- $renderer->SetY($this->top);
+ $renderer->tcpdf->SetY($this->top);
}
// Check the last cell height and adjust the current cell height if needed
@@ -113,9 +117,9 @@ class ReportPdfCell extends ReportBaseCell
}
// Check for pagebreak
if (!empty($temptext)) {
- $cHT = $renderer->getNumLines($temptext, $this->width);
- $cHT = $cHT * $renderer->getCellHeightRatio() * $renderer->getCurrentStyleHeight();
- $cM = $renderer->getMargins();
+ $cHT = $renderer->tcpdf->getNumLines($temptext, $this->width);
+ $cHT = $cHT * $renderer->tcpdf->getCellHeightRatio() * $renderer->getCurrentStyleHeight();
+ $cM = $renderer->tcpdf->getMargins();
// Add padding
if (is_array($cM['cell'])) {
$cHT += ($cM['padding_bottom'] + $cM['padding_top']);
@@ -124,12 +128,12 @@ class ReportPdfCell extends ReportBaseCell
}
// Add a new page if needed
if ($renderer->checkPageBreakPDF($cHT)) {
- $this->top = $renderer->GetY();
+ $this->top = $renderer->tcpdf->GetY();
}
$temptext = FunctionsRtl::spanLtrRtl($temptext);
}
// HTML ready - last value is true
- $renderer->MultiCell(
+ $renderer->tcpdf->MultiCell(
$this->width,
$this->height,
$temptext,
@@ -146,17 +150,17 @@ class ReportPdfCell extends ReportBaseCell
// Reset the last cell height for the next line
if ($this->newline >= 1) {
$renderer->lastCellHeight = 0;
- } elseif ($renderer->lastCellHeight < $renderer->getLastH()) {
+ } elseif ($renderer->lastCellHeight < $renderer->tcpdf->getLastH()) {
// OR save the last height if heigher then before
- $renderer->lastCellHeight = $renderer->getLastH();
+ $renderer->lastCellHeight = $renderer->tcpdf->getLastH();
}
// Set up the url link if exists ontop of the cell
if (!empty($this->url)) {
- $renderer->Link($cX, $this->top, $this->width, $this->height, $this->url);
+ $renderer->tcpdf->Link($cX, $this->top, $this->width, $this->height, $this->url);
}
// Reset the border and the text color to black or they will be inherited
- $renderer->SetDrawColor(0, 0, 0);
- $renderer->SetTextColor(0, 0, 0);
+ $renderer->tcpdf->SetDrawColor(0, 0, 0);
+ $renderer->tcpdf->SetTextColor(0, 0, 0);
}
}