<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div></div>
<div>
<div id="appendonsend" style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>De :</b> Michael Stahl <mst@libreoffice.org><br>
<b>Envoyé :</b> lundi 8 juillet 2019 13:15<br>
<b>À :</b> Tomaž Vajngerl; Adrien Ollier<br>
<b>Cc :</b> libreoffice@lists.freedesktop.org<br>
<b>Objet :</b> Re: tdf#74702 2/2</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">On 08.07.19 13:06, Tomaž Vajngerl wrote:<br>
> Hi,<br>
> <br>
> On 06.07.19 19:59, Adrien Ollier wrote:<br>
> ....<br>
> <br>
> <br>
> Well IMHO the problem that you even have to think about this is that <br>
> OutputDevice is a enormous class, and then you have to deal with another <br>
> even more enormous subclass vcl::Window, which should never be a <br>
> subclass of OutputDevice in the first place. However the work to change <br>
> that is quite big and non-trivial. <br>
<br>
i rarely work with VCL's implementation so i can't really have an <br>
informed opinion but if you say that delegation instead of inheritance <br>
would be an improvement here i'm all for it.</div>
<div class="PlainText"><br>
</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">Hello Michael,</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">thank you for your answer.</div>
<div class="PlainText">Can you explain what delegation means for you? I don't understand what you mean.</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">Also, I quite disagree with you.</div>
<div class="PlainText">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:</div>
<div class="PlainText"><br>
</div>
<div class="PlainText"><span></span><span style="font-family:"Courier New",monospace">#include <iostream></span><br>
<div><br>
</div>
<div><span style="font-family:"Courier New",monospace">struct A</span><br>
</div>
<div><span style="font-family:"Courier New",monospace">{</span><br>
</div>
<div><span style="font-family:"Courier New",monospace"> A() = default;</span><br>
</div>
<div><span style="font-family:"Courier New",monospace"> A(const A&) = default;</span><br>
</div>
<div><span style="font-family:"Courier New",monospace"> A(A&&) = default;</span><br>
</div>
<div><span style="font-family:"Courier New",monospace"> virtual ~A() = default;</span><br>
</div>
<div><span style="font-family:"Courier New",monospace">};</span><br>
</div>
<div><br>
</div>
<div><span style="font-family:"Courier New",monospace">struct B : A {};</span><br>
</div>
<div><br>
</div>
<div><span style="font-family:"Courier New",monospace">struct C</span><br>
</div>
<div><span style="font-family:"Courier New",monospace">{</span><br>
</div>
<div><span style="font-family:"Courier New",monospace"> virtual A* getNewInstance() const { return new A{}; }</span><br>
</div>
<div><span style="font-family:"Courier New",monospace">};</span><br>
</div>
<div><br>
</div>
<div><span style="font-family:"Courier New",monospace">struct D : C</span><br>
</div>
<div><span style="font-family:"Courier New",monospace">{</span><br>
</div>
<div><span style="font-family:"Courier New",monospace"> B* getNewInstance() const override { return new B{}; }</span><br>
</div>
<div><span style="font-family:"Courier New",monospace">};</span><br>
</div>
<div><br>
</div>
<div><span style="font-family:"Courier New",monospace">int main(int argc, char* argv[])</span><br>
</div>
<div><span style="font-family:"Courier New",monospace">{</span><br>
</div>
<div><span style="font-family:"Courier New",monospace"> D d;</span><br>
</div>
<div><span style="font-family:"Courier New",monospace"> A* a = d.getNewInstance();</span><br>
</div>
<div><span style="font-family:"Courier New",monospace"> delete a;</span><br>
</div>
<div><span style="font-family:"Courier New",monospace"> </span><br>
</div>
<div><span style="font-family:"Courier New",monospace"> return 0;</span><br>
</div>
<span style="font-family:"Courier New",monospace">}</span></div>
<div class="PlainText"><span style="font-family:Calibri,Helvetica,sans-serif"><br>
</span></div>
<div class="PlainText"><span style="font-family:Calibri,Helvetica,sans-serif">Also, let's take a concrete example:</span></div>
<div class="PlainText"><span style="font-family:Calibri,Helvetica,sans-serif"><a href="https://opengrok.libreoffice.org/xref/core/canvas/source/vcl/canvashelper.cxx?r=c88f7603" id="LPlnk799971"></a><a href="https://opengrok.libreoffice.org/xref/core/vcl/source/control/edit.cxx?r=d00ee2cb" id="LPlnk715579">https://opengrok.libreoffice.org/xref/core/vcl/source/control/edit.cxx?r=d00ee2cb</a><br>
</span></div>
<div class="PlainText"><span style="font-family:Calibri,Helvetica,sans-serif">void Edit::Draw(OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags)<br>
</span></div>
<div class="PlainText"><span style="font-family:Calibri,Helvetica,sans-serif">see l.1771<br>
</span></div>
<div class="PlainText"><span style="font-family:Calibri,Helvetica,sans-serif"><br>
</span></div>
</span></font><font size="2"><span style="font-size:11pt"></span></font>Can you tell me how you would remove the use of GetOutDevType?<br>
<br>
<font size="2"><span style="font-size:11pt">
<div class="PlainText"><span style="font-family:Calibri,Helvetica,sans-serif"><br>
</span></div>
<div class="PlainText"><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; line-height: normal;">Regards,</span></div>
<div class="PlainText"><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; line-height: normal;">Adrien Ollier</span><span style="font-family:Calibri,Helvetica,sans-serif"><br>
</span></div>
</span></font></div>
</div>
</body>
</html>