lpaulsen93 / dokuwiki-plugin-odt

Exports a page to the Open Document format used by OpenOffice.org and other word processors
http://www.dokuwiki.org/plugin:odt
13 stars 26 forks source link

Additional PHP 8.2 fixes #294

Closed eduardomozart closed 1 year ago

eduardomozart commented 1 year ago

Hello, This commit reimplements some PHP 8 fixes removed in #290 and fixes new issues. Now it's possible to export pages to ODT without any PHP 8 warning (on my tests) even with display_errors set to On. Most of the removed fixes in #290 was mine because I wrongly fix some issues into the wrong way. Most of DokuWiki PHP 8+ issues is fixed using "isset", but I had to study ODT plugin further to make it right.

Some of the fixes on this PR are:

  1. Fix ODT Frame rendering PHP8 Warnings. Wrap plug-in render correctly if $elementObj isn't set and without set position, background-image and pic_positions params (Wrap plug-in do not set them), and they are not being used on ODT 2019-07-27 version too, so it's safe to assume null values for them.
  2. Linebreaks wasn't being rendered so codeblocks was being rendered in-line. My fix on #283 break it. Now it's working as it should.
  3. Fix CSS import rendering. Some elements (like Wrap plugin) wasn't set background-color and other CSS properties on exported ODT file because I misunderstood how this import works on my fix #283. I reverted those changes in #290 and now it's working as it should on PHP 8 without warnings.
  4. Max width calculation was failling on Table elements. The "ternite" user attempt to fix this using is_numeric verification but it was failing and the Wrap plug-in table wasn't being shown because the max_width variable receives a value with pt suffix on it, so to avoid division by zero or non-numeric value warnings was necessary to remove the pt suffix from it.
  5. Fix Paragraph <style> tag rendering on content.xml ODT file by fixing ODTParagraphStyle.php and ODTStyle.php files. My fix on #283 was doing the wrong assumption about the logic on ODTParagraphStyle.php file and no custom styles was being applied for paragraphs. The consequence of this was the misalignment of Wrap elements (it wasn't being centered) because it's CSS properties wasn't being applied.
  6. When exporting Wrap plug-in boxes it seems to append px to the unit so it was throwing a PHP 8 warning of non-numeric value because ODTUnit expects values without px prefix so I trim it from the value if it's there.