Jose' Matos wrote:

> On Wednesday 26 November 2003 20:18, Martin Vermeer wrote:
>>
>> In principle. Doing so now would break all insets that are
>> different for linuxdoc and docbook (and that's most of them!)
>>
>> An in-between kludge at this point could be to test for
>> linuxdoc/docbook at line 227 of output_docbook.C and call either
>> simpleDocBookOnePar() or simpleLinuxDocOnePar(). Of course after
>> adapting the linuxdoc layout files to use the new parametrization.
> 
>   I will adapt the linuxdoc code to the new scheme.
>   With the exception of insets, as you noted, all the other parts
>   are equal.

José, in that case, you might use boost::bind and boost::function to 
call the correct inset member function.

        boost::function<int (InsetOld const &)> inset_exporter;
        if (using_linuxdoc) {
                // inset_exporter(inset) is equivalent to 
                // inset.linuxdoc(buf, os, runparams)
                inset_exporter =
                        boost::bind(&InsetOld::linuxdoc, _1, 
                                boost::cref(buf),
                                boost::ref(os),
                                boost::cref(runparams));
        } else {
                // inset_exporter(inset) is equivalent to 
                // inset.docbook(buf, os, runparams)
                inset_exporter =
                        boost::bind(&InsetOld::docbook, _1, 
                                boost::cref(buf),
                                boost::ref(os),
                                boost::cref(runparams));
        }

To be used, so:
        paragraph.simpleSGMLOnePar(buf, os, outerfont, runparams,
                                   inset_exporter)

The relevant code in simpleSGMLOnePar would be:

void Paragraph::simpleSGMLOnePar(Buffer const & buf,
       ostream & os,
       LyXFont const & outerfont,
       OutputParams const & runparams,
       boost::function<void (InsetOld const &)> inset_exporter)
{
        ...
        if (c == Paragraph::META_INSET) {
                InsetOld const & inset = *getInset(i);
                inset_exporter(inset);
                font_old = font;
                continue;
        }
        ...
}

Perhaps this helps?
-- 
Angus

Reply via email to