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

php 8.1 compatibility with method _addStringAsSVGImage() #274

Open schplurtz opened 2 years ago

schplurtz commented 2 years ago

Hi,

As DW Igor is approaching, I try the a2s plugin with Igor RC 2 and PHP 8.1

When I want to export to odt a DW page with an SVG image made by a2s, it fails. with Error: Non-static method ODTImage::addStringAsSVGImage() cannot be called statically error.

Is it me who is not using the right method in the a2s renderer, or is this a bug in the odt plugin ?

Just below, the error stack trace and the code I use in the a2s plugin.

2022-06-30 06:00:12Error: Non-static method ODTImage::addStringAsSVGImage() cannot be called statically /opt/www/she1dai1ohth1weej/lib/plugins/odt/ODT/ODTDocument.php(1610)
    #0 /opt/www/she1dai1ohth1weej/lib/plugins/odt/renderer/page.php(1608): ODTDocument->addStringAsSVGImage()
    #1 /opt/www/she1dai1ohth1weej/lib/plugins/a2s/syntax.php(181): renderer_plugin_odt_page->_addStringAsSVGImage()
    #2 /opt/www/she1dai1ohth1weej/lib/plugins/a2s/syntax.php(141): syntax_plugin_a2s->_render_odt()
    #3 /opt/www/she1dai1ohth1weej/inc/parser/renderer.php(117): syntax_plugin_a2s->render()
    #4 /opt/www/she1dai1ohth1weej/inc/parserutils.php(682): Doku_Renderer->plugin()
    #5 /opt/www/she1dai1ohth1weej/inc/parserutils.php(149): p_render()
    #6 /opt/www/she1dai1ohth1weej/inc/Action/Export.php(88): p_cached_output()
    #7 /opt/www/she1dai1ohth1weej/inc/ActionRouter.php(83): dokuwiki\Action\Export->preProcess()
    #8 /opt/www/she1dai1ohth1weej/inc/ActionRouter.php(48): dokuwiki\ActionRouter->setupAction()
    #9 /opt/www/she1dai1ohth1weej/inc/ActionRouter.php(60): dokuwiki\ActionRouter->__construct()
    #10 /opt/www/she1dai1ohth1weej/inc/actions.php(16): dokuwiki\ActionRouter::getInstance()
    #11 /opt/www/she1dai1ohth1weej/doku.php(126): act_dispatch()
    #12 {main}

    /**
     * Render odt output.
     *
     * @param Doku_Renderer  $renderer  The renderer
     * @param int            $state     The state
     * @param string         $txtdata   Textual data that handle() associated with this state
     * @param string         $align     img align
     * @return bool If rendering was successful.
     */
    protected function _render_odt(Doku_Renderer $renderer, $state, $txtdata, $align) {
        if($state === DOKU_LEXER_UNMATCHED) {
            $dim=$this->_extract_XY_4svg( $txtdata );
            $renderer->_addStringAsSVGImage(self::$opening.$txtdata, $dim[0], $dim[1], $align);
        }
        return true;
    }