Skip to content

Commit

Permalink
Fixes #305
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardomozart committed Jun 21, 2023
1 parent 2e3f6a7 commit 618a1cb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ODT/ODTImport.php
Expand Up @@ -835,7 +835,7 @@ static protected function import_styles_from_css_internal(ODTInternalParams $par

$toImport = array_merge (self::$internalRegs, $registrations);
foreach ($toImport as $style => $element) {
if ($element ['compare']) {
if (isset($element ['compare']) && $element ['compare']) {
self::importStyle($params, $htmlStack,
$style,
$element ['element'],
Expand Down
8 changes: 3 additions & 5 deletions ODT/ODTUtility.php
Expand Up @@ -458,11 +458,9 @@ public static function adjustValueForODT ($property, $value, ODTUnits $units) {
$values = preg_split ('/\s+/', $value);
$value = '';
foreach ($values as $part) {
$length = strlen ($part);

// If it is a short color value (#xxx) then convert it to long value (#xxxxxx)
// (ODT does not support the short form)
if (isset($part[0]) && $part[0] == '#' && $length == 4 ) {
if (isset($part[0]) && $part[0] == '#' && strlen($part) == 4 ) {
$part = '#'.$part [1].$part [1].$part [2].$part [2].$part [3].$part [3];
} else {
// If it is a CSS color name, get it's real color value
Expand All @@ -472,11 +470,11 @@ public static function adjustValueForODT ($property, $value, ODTUnits $units) {
}
}

if ( $length > 2 && $part [$length-2] == 'e' && $part [$length-1] == 'm' ) {
if ( strlen($part) > 2 && substr($part, -2, -1) == 'e' && substr($part, -1) == 'm' ) {
$part = $units->toPoints($part, 'y');
}

if ( $length > 2 && ($part [$length-2] != 'p' || $part [$length-1] != 't') &&
if ( strlen($part) > 2 && (substr($part, -2, -1) != 'p' || substr($part, -1) != 't') &&
strpos($property, 'border')!==false ) {
$part = $units->toPoints($part, 'y');
}
Expand Down
6 changes: 3 additions & 3 deletions ODT/styles/ODTParagraphStyle.php
Expand Up @@ -473,15 +473,15 @@ public static function copyLayoutProperties(ODTParagraphStyle $source, ODTParagr
// Copy $tab_stop_fields
foreach (self::$tab_stop_fields as $property => $fields) {
$value = $source->getProperty($property);
if (isset($value) && $disabled [$property] == 0) {
if (isset($value) && (!isset($disabled [$property]) || $disabled [$property] == 0)) {
$dest -> setProperty($property, $value);
}
}

// Copy $paragraph_fields
foreach (self::$paragraph_fields as $property => $fields) {
$value = $source->getProperty($property);
if (isset($value) && $disabled [$property] == 0) {
if (isset($value) && (!isset($disabled [$property]) || $disabled [$property] == 0)) {
$dest -> setProperty($property, $value);
}
}
Expand All @@ -490,7 +490,7 @@ public static function copyLayoutProperties(ODTParagraphStyle $source, ODTParagr
$text_fields = ODTTextStyle::getTextProperties ();
foreach ($text_fields as $property => $fields) {
$value = $source->getProperty($property);
if (isset($value) && $disabled [$property] == 0) {
if (isset($value) && (!isset($disabled [$property]) || $disabled [$property] == 0)) {
$dest -> setProperty($property, $value);
}
}
Expand Down

0 comments on commit 618a1cb

Please sign in to comment.