<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 28, 2013 at 2:55 PM, Elvis Stansvik <span dir="ltr"><<a href="mailto:elvstone@gmail.com" target="_blank">elvstone@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">2013/5/28 Gopalakrishna Bhat <span dir="ltr"><<a href="mailto:gopalakbhat@gmail.com" target="_blank">gopalakbhat@gmail.com</a>></span><br>
<div class="gmail_extra"><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div>On Tue, May 28, 2013 at 8:56 AM, Thorsten Zachmann <span dir="ltr"><<a href="mailto:t.zachmann@zagge.de" target="_blank">t.zachmann@zagge.de</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div>On Monday 27 May 2013 21:19:56 Elvis Stansvik wrote:<br>


> Hi all,<br>
><br>
> Currently trying to track down a bug and realized I'm a little unsure about<br>
> something.<br>
><br>
> The style manager creates a bunch of default list/bibliography/ToC styles<br>
> upon construction. What should we do if, during loading, we encounter a<br>
> style who's name clashes with one of these default styles?<br>
><br>
> Intuitively I think we should replace the default style with the one found<br>
> in the ODT, but since the code doesn't seem to do this currently, I thought<br>
> I'd ask.<br>
<br>
</div></div>I think so too. Maybe rename the one found in the defaults.<br></blockquote></div><div>+1 to this but there is a catch here. If we do it this way there will be more default styles that is created on each roundtrip</div>


<div>viz</div><div>DefaultStyle</div><div>DefaultStyle_Save1</div><div>DefaultStyle_Save2.....</div><div>which is unused.</div><div><br></div><div>What we could do is save the DefaultStyle only if it used in the document.  </div>

</div></div></div></blockquote><div><br></div></div><div>Right. But that would not help with documents already out there, or documents not produced by us.</div><div><br></div><div>What Camilla suggested to me on IRC, and which I think sounds sensible, is to make the creation of the default styles happen lazily.</div>

<div><br></div><div>If I understand her right, instead of the style manager creating the default ToC/bibliography styles in its constructor, it would be given an API like:</div><div><br></div><div>
/**</div><div> * Returns a table of contents entry style for the given @a outlineLevel.</div><div> *</div><div> * If there's no such style in the manager, a default one will be created and returned.</div>
<div> */</div><div>KoParagraphStyle *tableOfContentsEntryStyle(int outlineLevel);</div><div><br></div><div>/**</div><div> * Returns a bibliography entry style for the given @a bibliographyType.</div>
<div> *</div> * If there's no such style in the manager, a default one will be created and returned.</div><div class="gmail_quote"> */<br><div>KoParagraphStyle *bibliographyEntryStyle(const QString &bibliographyType);</div>

<div><br></div><div>As en example, the first one would be something like:</div><div><br></div><div>KoParagraphStyle *KoStyleManager::tableOfContentsEntryStyle(int outlineLevel) {<br></div><div>
    ParagraphStyle *tocStyle = paragraphStyle(QString("Contents %1").arg(outlineLevel));</div><div>    if (!tocStyle) {</div><div>        tocStyle = new KoParagraphStyle();</div><div>        tocStyle->setName(QString("Contents %1").arg(outlineLevel));</div>

<div>        tocStyle->setLeftMargin(QTextLength(QTextLength::FixedLength, (outlineLevel - 1) * 8));</div><div>        add(tocStyle);</div><div>    }</div><div>    return tocStyle;</div><div>}</div><div>
<br></div><div>And the code that uses the existing <span style>defaultTableOfContentsEntryStyle</span><span style>(</span><span style="font-weight:600;color:rgb(0,0,128)">int</span><span style>)/</span><span style>defaultBibliographyEntryStyle</span><span style>(</span><span style>QString) API would</span> then be updated to use the new API. From a brief search, this seems to be ToCGenerator, TableOfContentsEntryModel, TableOfContentsTemplate, BibliographyGenerator and BibliographyTemplate.</div>



<div><br></div><div>Was this what you had in mind Camilla? What do others think?</div><div><br></div></div></div></div></blockquote><div style>+1 on this</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div>Then the default styles would not be in the manager at loading time, so no clash would occur. And if the ODF has styles named e.g. "Contents N", they would be the ones picked up.</div>

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

<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Thorsten<br>
_______________________________________________<br>
calligra-devel mailing list<br>
<a href="mailto:calligra-devel@kde.org" target="_blank">calligra-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/calligra-devel" target="_blank">https://mail.kde.org/mailman/listinfo/calligra-devel</a><br>
</blockquote></div></div><br>With regards,</div><div class="gmail_extra">Gopalakrishna<span><font color="#888888"><br clear="all"><div><br></div>-- <br>My blog <a href="http://gkbhat.blogspot.com" target="_blank">http://gkbhat.blogspot.com</a>
</font></span></div></div>
<br>_______________________________________________<br>
calligra-devel mailing list<br>
<a href="mailto:calligra-devel@kde.org" target="_blank">calligra-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/calligra-devel" target="_blank">https://mail.kde.org/mailman/listinfo/calligra-devel</a><br>
<br></blockquote></div></div><br></div></div>
<br>_______________________________________________<br>
calligra-devel mailing list<br>
<a href="mailto:calligra-devel@kde.org">calligra-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/calligra-devel" target="_blank">https://mail.kde.org/mailman/listinfo/calligra-devel</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>My blog <a href="http://gkbhat.blogspot.com">http://gkbhat.blogspot.com</a>
</div></div>