Minor refactoring

This commit is contained in:
MarkBaker 2020-07-05 20:21:54 +02:00
parent f3fc321177
commit c6de56e4cf
1 changed files with 40 additions and 29 deletions

View File

@ -437,6 +437,13 @@ class Gnumeric extends BaseReader
'footer' => 0.3, 'footer' => 0.3,
]; ];
$marginSet = $this->buildMarginSet($sheet, $marginSet);
$this->adjustMargins($marginSet);
}
}
private function buildMarginSet(SimpleXMLElement $sheet, array $marginSet): array
{
foreach ($sheet->PrintInformation->Margins->children($this->gnm, true) as $key => $margin) { foreach ($sheet->PrintInformation->Margins->children($this->gnm, true) as $key => $margin) {
$marginAttributes = $margin->attributes(); $marginAttributes = $margin->attributes();
$marginSize = ($marginAttributes['Points']) ?? 72; // Default is 72pt $marginSize = ($marginAttributes['Points']) ?? 72; // Default is 72pt
@ -445,6 +452,11 @@ class Gnumeric extends BaseReader
$marginSet[$key] = $marginSize; $marginSet[$key] = $marginSize;
} }
return $marginSet;
}
private function adjustMargins(array $marginSet): void
{
foreach ($marginSet as $key => $marginSize) { foreach ($marginSet as $key => $marginSize) {
// Gnumeric is quirky in the way it displays the header/footer values: // Gnumeric is quirky in the way it displays the header/footer values:
// header is actually the sum of top and header; footer is actually the sum of bottom and footer // header is actually the sum of top and header; footer is actually the sum of bottom and footer
@ -474,7 +486,6 @@ class Gnumeric extends BaseReader
} }
} }
} }
}
private function sheetMargin(string $key, float $marginSize): void private function sheetMargin(string $key, float $marginSize): void
{ {