<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"><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 class="im">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 style>Right. But that would not help with documents already out there, or documents not produced by us.</div><div style><br></div><div style>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 style><br></div><div style>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 style><br></div><div style>
/**</div><div style> * Returns a table of contents entry style for the given @a outlineLevel.</div><div style> *</div><div style> * If there's no such style in the manager, a default one will be created and returned.</div>
<div style> */</div><div style>KoParagraphStyle *tableOfContentsEntryStyle(int outlineLevel);</div><div style><br></div><div style>/**</div><div style> * Returns a bibliography entry style for the given @a bibliographyType.</div>
<div style> *</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 style>KoParagraphStyle *bibliographyEntryStyle(const QString &bibliographyType);</div>
<div style><br></div><div style>As en example, the first one would be something like:</div><div style><br></div><div style>KoParagraphStyle *KoStyleManager::tableOfContentsEntryStyle(int outlineLevel) {<br></div><div style>
    ParagraphStyle *tocStyle = paragraphStyle(QString("Contents %1").arg(outlineLevel));</div><div style>    if (!tocStyle) {</div><div style>        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 style>    return tocStyle;</div><div style>}</div><div style>
<br></div><div style>And the code that uses the existing <span style="color:rgb(0,0,0)">defaultTableOfContentsEntryStyle</span><span style="color:rgb(0,0,0)">(</span><span style="font-weight:600;color:rgb(0,0,128)">int</span><span style="color:rgb(0,0,0)">)/</span><span style="color:rgb(0,0,0)">defaultBibliographyEntryStyle</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">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 style><br></div><div style>Was this what you had in mind Camilla? What do others think?</div><div style><br></div><div style>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 style><br></div><div style>Regards,</div><div style>Elvis</div><div style><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 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">
<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 class=""><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">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></div></div>