[calligra] libs/kotext/styles: Fix saving line-height to ODF. Just because the property exists doesn't mean it's valid.
Pierre
pinaraf at pinaraf.info
Tue Jul 12 00:43:34 BST 2011
On Friday 08 July 2011 18:51:17 Sebastian Sauer wrote:
> Git commit 9f017cf21d343c1408214499bd878b987d8daf6f by Sebastian Sauer.
> Committed on 08/07/2011 at 18:43.
> Pushed by sebsauer into branch 'master'.
>
> Fix saving line-height to ODF. Just because the property exists doesn't
> mean it's valid.
>
> M +3 -3 libs/kotext/styles/KoParagraphStyle.cpp
>
> http://commits.kde.org/calligra/9f017cf21d343c1408214499bd878b987d8daf6f
>
> diff --git a/libs/kotext/styles/KoParagraphStyle.cpp
> b/libs/kotext/styles/KoParagraphStyle.cpp index ac5d1d5..987b2bd 100644
> --- a/libs/kotext/styles/KoParagraphStyle.cpp
> +++ b/libs/kotext/styles/KoParagraphStyle.cpp
> @@ -283,7 +283,7 @@ void KoParagraphStyle::unapplyStyle(QTextBlock &block)
> const void KoParagraphStyle::setLineHeightPercent(int lineHeight)
> {
> setProperty(PercentLineHeight, lineHeight);
> - setProperty(FixedLineHeight, 0);
> + setProperty(FixedLineHeight, 0.0);
> remove(NormalLineHeight);
> }
>
> @@ -1946,10 +1946,10 @@ void KoParagraphStyle::saveOdf(KoGenStyle &style,
> KoGenStyles &mainStyles) } else if (key == KoParagraphStyle::LineSpacing
> && lineSpacing() != 0) { style.addPropertyPt("style:line-spacing",
> lineSpacing(), KoGenStyle::ParagraphType); writtenLineSpacing = true;
> - } else if (key == KoParagraphStyle::PercentLineHeight) {
> + } else if (key == KoParagraphStyle::PercentLineHeight &&
> lineHeightPercent() != 0) { style.addProperty("fo:line-height",
> QString("%1%").arg(lineHeightPercent()), KoGenStyle::ParagraphType);
> writtenLineSpacing = true;
> - } else if (key == KoParagraphStyle::FixedLineHeight &&
> lineHeightAbsolute() >= 0) { + } else if (key ==
> KoParagraphStyle::FixedLineHeight && lineHeightAbsolute() != 0) {
> style.addPropertyPt("fo:line-height", lineHeightAbsolute(),
> KoGenStyle::ParagraphType); writtenLineSpacing = true;
> } else if (key == KoParagraphStyle::LineSpacingFromFont &&
> lineHeightAbsolute() == 0) {
I don't disagree with the idea of this change, but this is not really a bug in
calligra itself.
I will fix the unit test you broke, by adding a specific exception for this
property. But the following code in OpenDocument relax ng is wrong :
<attribute name="fo:line-height">
<choice>
<value>normal</value>
<ref name="nonNegativeLength"/>
<ref name="percent"/>
</choice>
</attribute>
Since nonNegativeLength can be zero, it means that 0 is a valid line-height...
Still, the specification doesn't tell us what it means.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/calligra-devel/attachments/20110712/7ad7da3b/attachment.sig>
More information about the calligra-devel
mailing list