Re: Question for C++ guru's..

From: Jean Bréfort <jean.brefort_at_normalesup.org>
Date: Tue Dec 26 2006 - 11:02:29 CET

Le mardi 26 décembre 2006 à 14:21 +1100, msevior@physics.unimelb.edu.au
a écrit :
> Hi everyone,
> After a little investigating I found that the reason printing
> on unix is not working right is because the virtual methods
> are called.
> GR_UnixPangoGraphics is defined with this inheritence..
>
> class ABI_EXPORT GR_UnixPangoGraphics : public GR_UnixGraphics
>
> and has these methods..
>
>
> virtual UT_uint32 getFontAscent(GR_Font *);
> virtual UT_uint32 getFontDescent(GR_Font *);
> virtual UT_uint32 getFontHeight(GR_Font *);
>
> XAP_UnixGnomePrintGraphics is defined this way
>
> class XAP_UnixGnomePrintGraphics : public GR_Graphics
>
> has the same virtual methods..
>
>
>
> virtual UT_uint32 getFontAscent(GR_Font *);
> virtual UT_uint32 getFontDescent(GR_Font *);
> virtual UT_uint32 getFontHeight(GR_Font *);
>
> Now the constructor of XAP_UnixGnomePrintGraphics also contonstructs
> GR_UnixPangoGraphics, then in fp_Run.cpp::_inheritProperties we calculate
> the height of the run with this call...
>
> _setHeight(getGraphics()->getFontHeight(pFont));
>
> Which resolves to
>
> GR_UnixPangoGraphics::getFontHeight(GR_Font *)
>
> and not to
>
> XAP_UnixGnomePrintGraphics::getFontHeight(GR_Font *)

I don't understand the above. As I understand things, when printing, we
use a GR_UnixPangoPrintGraphics which owns the
XAP_UnixGnomePrintGraphics instance. If you want to call
XAP_UnixGnomePrintGraphics::getFontHeight, you just need to override
getFontHeight in GR_UnixPangoPrintGraphics:

UT_uint32 GR_UnixPrintPangoGraphics::getFontHeight(GR_Font *font)
{
        return m_pGnomePrint->getFontHeight(font);
}

> Which is why the line spacing when printing is wrong.
>
> Do any of our C++ guru's know what is going on and how to fix it?
>
> Cheers
>
> Martin
>
>

-- 
Jean Bréfort <jean.brefort@normalesup.org>
Received on Tue Dec 26 11:04:04 2006

This archive was generated by hypermail 2.1.8 : Tue Dec 26 2006 - 11:04:05 CET