RE: tdf#74702 2/2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






De : Michael Stahl <mst@xxxxxxxxxxxxxxx>
Envoyé : lundi 8 juillet 2019 13:15
À : Tomaž Vajngerl; Adrien Ollier
Cc : libreoffice@xxxxxxxxxxxxxxxxxxxxx
Objet : Re: tdf#74702 2/2
 
On 08.07.19 13:06, Tomaž Vajngerl wrote:
> Hi,
>
>     On 06.07.19 19:59, Adrien Ollier wrote:
>     ....
>
>
> Well IMHO the problem that you even have to think about this is that
> OutputDevice is a enormous class, and then you have to deal with another
> even more enormous subclass vcl::Window, which should never be a
> subclass of OutputDevice in the first place. However the work to change
> that is quite big and non-trivial.

i rarely work with VCL's implementation so i can't really have an
informed opinion but if you say that delegation instead of inheritance
would be an improvement here i'm all for it.


Hello Michael,

thank you for your answer.
Can you explain what delegation means for you? I don't understand what you mean.

Also, I quite disagree with you.
First, C++ allows an overriding function to have a return type that is a subclass of the return type of the overridden function. You can ensure this by running the following example program:

#include <iostream>

struct A
{
    A() = default;
    A(const A&) = default;
    A(A&&) = default;
    virtual ~A() = default;
};

struct B : A {};

struct C
{
    virtual A* getNewInstance() const { return new A{}; }
};

struct D : C
{
    B* getNewInstance() const override { return new B{}; }
};

int main(int argc, char* argv[])
{
    D d;
    A* a = d.getNewInstance();
    delete a;
   
    return 0;
}

Also, let's take a concrete example:
void Edit::Draw(OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags)
see l.1771

Can you tell me how you would remove the use of GetOutDevType?


Regards,
Adrien Ollier
_______________________________________________
LibreOffice mailing list
LibreOffice@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/libreoffice

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux