Skip to content

Commit

Permalink
Fixed some errors. See #263.
Browse files Browse the repository at this point in the history
  • Loading branch information
lpaulsen93 committed Feb 14, 2021
1 parent 0fca0a6 commit 40d14f4
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 35 deletions.
2 changes: 1 addition & 1 deletion ODT/ODTDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ public function doPageFormatChange ($parent = NULL) {

// It is iassumed the proper media selector has been set by calling setMediaSelector()
if (($this->CSSUsage == 'basic' || $this->CSSUsage == 'full') && $this->importnew != NULL) {
ODTImport::set_page_properties ($this->params, $style_obj);
ODTImport::set_page_properties($this->params, $style_obj);
}

// Save style data in page style array, in common styles and set current page format
Expand Down
28 changes: 16 additions & 12 deletions ODT/ODTImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -709,24 +709,28 @@ static protected function importStyle(ODTInternalParams $params, cssdocument $ht

static public function import_styles_from_css (ODTInternalParams $params, $media_sel=NULL, $registrations=NULL, $listAlign='right') {
if ( $params->import != NULL ) {
$save = $params->import->getMedia ();
$params->import->setMedia ($media_sel);
if (!empty($media_sel)) {
$save = $params->import->getMedia();
$params->import->setMedia($media_sel);
}

// Make a copy of the stack to be sure we do not leave anything behind after import.
$stack = clone $params->htmlStack;
$stack->restoreToRoot ();
$stack->restoreToRoot();

self::import_styles_from_css_internal ($params, $stack, $registrations, $listAlign);
self::import_styles_from_css_internal($params, $stack, $registrations, $listAlign);

$params->import->setMedia ($save);
if (!empty($media_sel)) {
$params->import->setMedia($save);
}
}
}

static public function set_page_properties (ODTInternalParams $params, ODTPageLayoutStyle $pageStyle, $media_sel=NULL) {
static public function set_page_properties(ODTInternalParams $params, ODTPageLayoutStyle $pageStyle, $media_sel=NULL) {
if ( $params->import != NULL ) {
if ($media_sel != NULL ) {
if (!empty($media_sel)) {
$save = $params->import->getMedia ();
$params->import->setMedia ($media_sel);
$params->import->setMedia($media_sel);
}

$stack = clone $params->htmlStack;
Expand All @@ -745,7 +749,7 @@ static public function set_page_properties (ODTInternalParams $params, ODTPageLa
}
}

if ($media_sel != NULL ) {
if (!empty($media_sel)) {
$params->import->setMedia ($save);
}
}
Expand Down Expand Up @@ -802,8 +806,8 @@ static protected function importFootnoteStyle(ODTInternalParams $params) {
$disabled ['padding-right'] = 1;
$disabled ['padding-bottom'] = 1;
$disabled ['padding-left'] = 1;
$styleName = $params->styleset->getStyleName (footnote);

$styleName = $params->styleset->getStyleName('footnote');
$footnote = $params->styleset->getStyle($styleName);
if ($footnote != NULL && $body != NULL) {
ODTParagraphStyle::copyLayoutProperties ($body, $footnote, $disabled);
Expand All @@ -815,7 +819,7 @@ static protected function import_styles_from_css_internal(ODTInternalParams $par
$name = $params->styleset->getStyleName('first page');
$first_page = $params->styleset->getStyle($name);
if ($first_page != NULL) {
self::set_page_properties ($params, $first_page, $htmlStack, NULL);
self::set_page_properties($params, $first_page);
}

// Import styles which only require a simple import based on element name and attributes
Expand Down
4 changes: 2 additions & 2 deletions ODT/ODTUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,8 @@ public static function generateODTfromHTMLCode(ODTInternalParams $params, $HTMLC

// Set new media selector (remember old one)
$media = $params->import->getMedia ();
if (!empty($options ['media_selector'])) {
$params->import->setMedia ($options ['media_selector']);
if (!empty($options['media_selector'])) {
$params->import->setMedia($options['media_selector']);
}

if (!empty($options ['element'])) {
Expand Down
13 changes: 6 additions & 7 deletions ODT/css/cssimportnew.php
Original file line number Diff line number Diff line change
Expand Up @@ -779,10 +779,9 @@ public function toString () {
* @param string $media Media selector to match
* @return boolean
*/
public function matches (iElementCSSMatchable $element, &$specificity, $media = NULL) {

$media = trim ($media);
if ( !empty($this->media) && $media != $this->media ) {
public function matches(iElementCSSMatchable $element, &$specificity, $media = NULL) {
$media = trim($media);
if ( !empty($this->media) && $media !== $this->media ) {
// Wrong media
//print ("\nNo-Match ".$this->media."==".$media); //Debuging
return false;
Expand Down Expand Up @@ -923,7 +922,7 @@ protected function deleteComments (&$contents) {
*
* @param string $media
*/
public function setMedia ($media) {
public function setMedia($media) {
$this->media = $media;
}

Expand All @@ -932,7 +931,7 @@ public function setMedia ($media) {
*
* @return string
*/
public function getMedia () {
public function getMedia() {
return $this->media;
}

Expand Down Expand Up @@ -1060,7 +1059,7 @@ public function getPropertyForElement ($name, iElementCSSMatchable $element) {
$value = NULL;
$highest = 0;
foreach ($this->rules as $rule) {
$matched = $rule->matches ($element, $specificity, $this->media);
$matched = $rule->matches($element, $specificity, $this->media);
if ( $matched !== false ) {
$current = $rule->getProperty ($name);

Expand Down
2 changes: 1 addition & 1 deletion ODT/styles/ODTMasterPageStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getElementName() {
* @param $properties Properties to be imported
* @param $disabled Properties to be ignored
*/
public function importProperties($properties, $disabled) {
public function importProperties($properties, $disabled=array()) {
$this->importPropertiesInternal(self::$master_fields, $properties, $disabled, $this->master_style);
}

Expand Down
2 changes: 1 addition & 1 deletion ODT/styles/ODTPageLayoutStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function getElementName() {
* @param $properties Properties to be imported
* @param $disabled Properties to be ignored
*/
public function importProperties($properties, $disabled) {
public function importProperties($properties, $disabled=array()) {
$this->importPropertiesInternal(self::$page_layout_fields, $properties, $disabled, $this->page_layout_style);
$this->importPropertiesInternal(self::$layout_props_fields, $properties, $disabled, $this->layout_props);
$this->importPropertiesInternal(self::$bgi_fields, $properties, $disabled, $this->bgi_props);
Expand Down
2 changes: 1 addition & 1 deletion ODT/styles/ODTParagraphStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function __construct() {
* @param $properties Properties to be imported
* @param $disabled Properties to be ignored
*/
public function importProperties($properties, $disabled) {
public function importProperties($properties, $disabled=array()) {
foreach ($properties as $property => $value) {
if ($disabled [$property] == 0) {
$this->setProperty($property, $value);
Expand Down
2 changes: 1 addition & 1 deletion ODT/styles/ODTStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ abstract public function getElementName();
* @param $properties Properties to be imported
* @param $disabled Properties to be ignored
*/
abstract public function importProperties($properties, $disabled);
abstract public function importProperties($properties, $disabled=array());

/**
* Check if a style is a common style.
Expand Down
2 changes: 1 addition & 1 deletion ODT/styles/ODTTableCellStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function __construct() {
* @param $properties Properties to be imported
* @param $disabled Properties to be ignored
*/
public function importProperties($properties, $disabled) {
public function importProperties($properties, $disabled=array()) {
$this->importPropertiesInternal(ODTStyleStyle::getStyleProperties (), $properties, $disabled);
$this->importPropertiesInternal(ODTTextStyle::getTextProperties (), $properties, $disabled);
$this->importPropertiesInternal(ODTParagraphStyle::getParagraphProperties (), $properties, $disabled);
Expand Down
2 changes: 1 addition & 1 deletion ODT/styles/ODTTableColumnStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct() {
* @param $properties Properties to be imported
* @param $disabled Properties to be ignored
*/
public function importProperties($properties, $disabled) {
public function importProperties($properties, $disabled=array()) {
$this->importPropertiesInternal(ODTStyleStyle::getStyleProperties (), $properties, $disabled);
$this->importPropertiesInternal(self::$table_column_fields, $properties, $disabled);
$this->setProperty('style-family', $this->getFamily());
Expand Down
2 changes: 1 addition & 1 deletion ODT/styles/ODTTableRowStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct() {
* @param $properties Properties to be imported
* @param $disabled Properties to be ignored
*/
public function importProperties($properties, $disabled) {
public function importProperties($properties, $disabled=array()) {
$this->importPropertiesInternal(ODTStyleStyle::getStyleProperties (), $properties, $disabled);
$this->importPropertiesInternal(self::$table_row_fields, $properties, $disabled);
$this->setProperty('style-family', $this->getFamily());
Expand Down
2 changes: 1 addition & 1 deletion ODT/styles/ODTTableStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function __construct() {
* @param $properties Properties to be imported
* @param $disabled Properties to be ignored
*/
public function importProperties($properties, $disabled) {
public function importProperties($properties, $disabled=array()) {
$this->importPropertiesInternal(ODTStyleStyle::getStyleProperties (), $properties, $disabled);
$this->importPropertiesInternal(self::$table_fields, $properties, $disabled);
$this->setProperty('style-family', $this->getFamily());
Expand Down
2 changes: 1 addition & 1 deletion ODT/styles/ODTTextListStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function getElementName() {
* @param $properties Properties to be imported
* @param $disabled Properties to be ignored
*/
public function importProperties($properties, $disabled) {
public function importProperties($properties, $disabled=array()) {
$this->importPropertiesInternal(ODTTextStyle::getTextProperties (), $properties, $disabled);
$this->importPropertiesInternal(self::$list_fields, $properties, $disabled);
}
Expand Down
2 changes: 1 addition & 1 deletion ODT/styles/ODTTextOutlineStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getElementName() {
* @param $properties Properties to be imported
* @param $disabled Properties to be ignored
*/
public function importProperties($properties, $disabled) {
public function importProperties($properties, $disabled=array()) {
$this->importPropertiesInternal(ODTTextStyle::getTextProperties (), $properties, $disabled);
$this->importPropertiesInternal(self::$outline_fields, $properties, $disabled);
}
Expand Down
2 changes: 1 addition & 1 deletion ODT/styles/ODTTextStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function __construct() {
* @param $properties Properties to be imported
* @param $disabled Properties to be ignored
*/
public function importProperties($properties, $disabled) {
public function importProperties($properties, $disabled=array()) {
$this->importPropertiesInternal(ODTStyleStyle::getStyleProperties (), $properties, $disabled);
$this->importPropertiesInternal(self::$text_fields, $properties, $disabled);
$this->setProperty('style-family', $this->getFamily());
Expand Down
2 changes: 1 addition & 1 deletion ODT/styles/ODTUnknownStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function setElementName($element_name) {
* @param $properties Properties to be imported
* @param $disabled Properties to be ignored
*/
public function importProperties($properties, $disabled) {
public function importProperties($properties, $disabled=array()) {
}

/**
Expand Down
2 changes: 1 addition & 1 deletion renderer/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function load_css() {
$this->document->setCSSUsage('off');
break;
}
$this->document->setMediaSelector ($this->config->getParam('media_sel'));
$this->document->setMediaSelector($this->config->getParam('media_sel'));

// Put some root element on the HTML stack which should always
// be present for our CSS matching
Expand Down

0 comments on commit 40d14f4

Please sign in to comment.