<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://git.reviewboard.kde.org/r/107601/">http://git.reviewboard.kde.org/r/107601/</a>
     </td>
    </tr>
   </table>
   <br />


<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for Calligra and C. Boemann.</div>
<div>By Friedrich W. H. Kossebau.</div>


<p style="color: grey;"><i>Updated Dec. 6, 2012, 12:45 p.m.</i></p>



<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Changes</h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Renamed enum KoTextRange::RelativeContentPosition to KoTextRange::TagType, and also return to pass KoTextRange::saveOdf(...) always the position the ranges are about.
Before for the end tags the position right before the end position was passed and needed to be matched, which only confuses (e.g. myself when saving the endtags at the begin of a block, where I was +1 off).</pre>
  </td>
 </tr>
</table>




<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">After lots of experiments here finally something relatively elegant (though you should have seen my intermediate hacks to understand ;) ).

Fixes the bugs seen with e.g. orpheus on saving bookmarks, at least for me. I think/hope I catched all cases which can be there by the parameters from & to, the possible textblock contents and the possible textranges.
Usage of KoTextRangeManager::textRangesChangingWithin(...) and KoTextRange::saveOdf(...) can be surely improved, but for now this here is at least a working fix.

Here my rationale for the patch:
Start and end tags of textranges can appear on positions in a text block.
in front of the first text element, between the elements, or behind the last.
A textblock is composed of no or many text fragments.
If there is no element at all, the only possible position is 0 (relative to the
begin of the block).
Start tags are ideally written in front of the content they are tagging,
and not behind the previous content. That way tags which are at the very begin
of the text do not need special handling.
End tags are ideally written directly behind the content, and not in front of
the next content. That way end tags which are at the very end of the text
do not need special handling.
Then there is the case of start tags which are at the final position of a text block:
the content they belong to includes the block end/border, so they need to be
written at the place of the last position.

</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Oh yes. Created reports with lots of tables & charts, updated them, saved, updated, loaded, updated, added new tables & charts, updated, saved, updated, loaded, .... And no longer any issue then, so far.</pre>
  </td>
 </tr>
</table>




<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> (updated)</h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>libs/kotext/KoAnnotation.h <span style="color: grey">(0dfb43c)</span></li>

 <li>libs/kotext/KoAnnotation.cpp <span style="color: grey">(a700f02)</span></li>

 <li>libs/kotext/KoBookmark.h <span style="color: grey">(c64cbe1)</span></li>

 <li>libs/kotext/KoBookmark.cpp <span style="color: grey">(5538e5f)</span></li>

 <li>libs/kotext/KoTextRange.h <span style="color: grey">(c728798)</span></li>

 <li>libs/kotext/opendocument/KoTextWriter_p.cpp <span style="color: grey">(9cc353c)</span></li>

</ul>

<p><a href="http://git.reviewboard.kde.org/r/107601/diff/" style="margin-left: 3em;">View Diff</a></p>




  </td>
 </tr>
</table>




  </div>
 </body>
</html>