<div>hi Luke,</div><div><br></div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">

I should have known better than to think it was that easy. :)</blockquote><div>I think it ought to be that easy... More documentation would speedup development and reduce bugs dramatically...</div><div>(Maybe we should write a few doxygen comments for EditEngine, if we figure out how it works).</div>

<div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">

I had a very bad solution that seemed to work but made the unit tests<br>not work.<br>I replaced SetText with:<br>   SmGetActiveView()-&gt;GetEditWindow()-&gt;SelectAll();<br>   SmGetActiveView()-&gt;GetEditWindow()-&gt;InsertText(formula);</blockquote>

</div><div>Why is this a bad solution ?</div><div>Any idea, why this doesn&#39;t work with the unit tests ?</div><div>It seems like it might be a fairly good solution... Unless undo/redo manages selections too... So that this becomes two steps ?</div>

<div><br></div><div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex">


I&#39;m very sorry for bothering you with solutions that don&#39;t work.<br></blockquote><div>Don&#39;t be, it also happens to me... That&#39;s why the visual formula editor had bugs to begin with, and it&#39;s no unlikely that we&#39;ll find more :)</div>

<div>Besides if we don&#39;t propose patches, or partially working fixes... and discuss these we&#39;ll never get undo integration to work properly.</div></div><br clear="all">--<br>Regards Jonas Finnemann Jensen.<br>
<br><br><div class="gmail_quote">On Mon, Feb 14, 2011 at 01:13, Luke Dixon <span dir="ltr">&lt;<a href="mailto:6b8b4567@gmail.com" target="_blank">6b8b4567@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Hi Jonas,<br>
<div><br>
On Sun, 2011-02-13 at 21:44 +0100, Jonas Finnemann Jensen wrote:<br>
<br>
&gt; It would be major step to get that issue fixed... And you&#39;re going the<br>
&gt; right way, but your patch doesn&#39;t work if the formula is written in<br>
&gt; multiple lines...<br>
&gt; try, writing the formula 3+3+3 \n \n \n \n +4+4 (replace \n by line<br>
&gt; break not NEWLINE but whitespace linebreak).<br>
&gt; Then in visual editor delete +3, go into the command editor again and<br>
&gt; back into the visual editor and notice that it now says 3+3+4+4+4+4.<br>
&gt; The command editor will say  { 3 + 3 + 4 + 4 }  \n \n \n \n +4+4,<br>
&gt; because the SetText(0, formula) only replaced the first paragraph...<br>
&gt;<br>
<br>
</div>Ah, I guess I got a bit too excited too quickly. I should have known<br>
better than to think it was that easy. :)<br>
<div><br>
&gt;<br>
&gt; What I understand from editeng_8.cxx line 1621 (see [1]) is that the<br>
&gt; number you pass in setText(0, formula), is the paragraph to be<br>
&gt; replaced by the text...<br>
&gt; The method signature is EditEngine::SetText( sal_uInt16 nPara, const<br>
&gt; XubString&amp; rTxt ), and it calls SelectParagraph(nPara)........<br>
&gt; At least that&#39;s what I can decrypt from the sources... (I think I&#39;ve<br>
&gt; seen ROT13 variants that was easier to read).<br>
&gt;<br>
<br>
</div>Yeah, I saw nPara, and thought about it for a couple of seconds, figured<br>
that since SmNodeToTextVisitor puts it all on one line it would be okay.<br>
I thought that through badly :(<br>
<div><br>
&gt;<br>
&gt; I have no idea how to solve this... Maybe we can<br>
&gt; call EditEngine::UndoActionStart(USHORT nId) (see [2])<br>
&gt; and EditEngine::UndoActionEnd(USHORT nId), before and after the called<br>
&gt; to EditEngine::SetText(formula)...<br>
&gt; But in that case I don&#39;t know if we can pass any value as nId, the<br>
&gt; existing ones are defined in [3] (line 64).<br>
&gt; The only place I can see EDITUNDO_INSERT used is to call<br>
&gt; UndoActionStart/End and in one switch case where labels are<br>
&gt; generated...<br>
&gt;<br>
<br>
</div>I had a very bad solution that seemed to work but made the unit tests<br>
not work.<br>
I replaced SetText with:<br>
    SmGetActiveView()-&gt;GetEditWindow()-&gt;SelectAll();<br>
    SmGetActiveView()-&gt;GetEditWindow()-&gt;InsertText(formula);<br>
<br>
but it would really need to be done properly.<br>
<div><br>
&gt;<br>
&gt; We can probably enable the visual editor as an non-default editing<br>
&gt; mode (i.e. activated from toolbar) once the formatting issue is<br>
&gt; addressed... Then when we&#39;ve integrated it properly, so that users of<br>
&gt; the command editor doesn&#39;t feel any uncomfort, we can make it<br>
&gt; default...<br>
&gt; But as long as it discards formatting information (font, bold, color,<br>
&gt; alignment, etc) we probably shouldn&#39;t enable it by default... Users<br>
&gt; hate regressions, especially if it eats all their formatting<br>
&gt; information without asking nicely first :)<br>
&gt;<br>
<br>
</div>Oh yeah, forgot about the formatting. Yes, I agree. I guess I just got a<br>
little excited.<br>
<br>
I&#39;m very sorry for bothering you with solutions that don&#39;t work.<br>
Thanks for putting up with me. :)<br>
<br>
Regards,<br>
<font color="#888888">Luke<br>
<br>
<br>
</font></blockquote></div><br>