Minor refactoring
This commit is contained in:
parent
586b36b440
commit
6cbb622a9e
|
@ -64,9 +64,7 @@ class PageSettings
|
||||||
$pageSetupAttributes = $pageSetupValue->attributes($namespaces['x']);
|
$pageSetupAttributes = $pageSetupValue->attributes($namespaces['x']);
|
||||||
switch ($pageSetupKey) {
|
switch ($pageSetupKey) {
|
||||||
case 'Layout':
|
case 'Layout':
|
||||||
$printDefaults->orientation = (string) strtolower($pageSetupAttributes->Orientation) ?: PageSetup::ORIENTATION_PORTRAIT;
|
$this->setLayout($printDefaults, $pageSetupAttributes);
|
||||||
$printDefaults->horizontalCentered = (bool) $pageSetupAttributes->CenterHorizontal ?: false;
|
|
||||||
$printDefaults->verticalCentered = (bool) $pageSetupAttributes->CenterVertical ?: false;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'Header':
|
case 'Header':
|
||||||
|
@ -78,10 +76,7 @@ class PageSettings
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'PageMargins':
|
case 'PageMargins':
|
||||||
$printDefaults->leftMargin = (float) $pageSetupAttributes->Left ?: 1.0;
|
$this->setMargins($printDefaults, $pageSetupAttributes);
|
||||||
$printDefaults->rightMargin = (float) $pageSetupAttributes->Right ?: 1.0;
|
|
||||||
$printDefaults->topMargin = (float) $pageSetupAttributes->Top ?: 1.0;
|
|
||||||
$printDefaults->bottomMargin = (float) $pageSetupAttributes->Bottom ?: 1.0;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -117,4 +112,19 @@ class PageSettings
|
||||||
|
|
||||||
return $printDefaults;
|
return $printDefaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function setLayout(stdClass $printDefaults, SimpleXMLElement $pageSetupAttributes): void
|
||||||
|
{
|
||||||
|
$printDefaults->orientation = (string)strtolower($pageSetupAttributes->Orientation) ?: PageSetup::ORIENTATION_PORTRAIT;
|
||||||
|
$printDefaults->horizontalCentered = (bool)$pageSetupAttributes->CenterHorizontal ?: false;
|
||||||
|
$printDefaults->verticalCentered = (bool)$pageSetupAttributes->CenterVertical ?: false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setMargins(stdClass $printDefaults, SimpleXMLElement $pageSetupAttributes): void
|
||||||
|
{
|
||||||
|
$printDefaults->leftMargin = (float)$pageSetupAttributes->Left ?: 1.0;
|
||||||
|
$printDefaults->rightMargin = (float)$pageSetupAttributes->Right ?: 1.0;
|
||||||
|
$printDefaults->topMargin = (float)$pageSetupAttributes->Top ?: 1.0;
|
||||||
|
$printDefaults->bottomMargin = (float)$pageSetupAttributes->Bottom ?: 1.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue