[calligra] libs/textlayout: fix -line height in presenter
Cyrille Berger Skott
cberger at cberger.net
Fri May 6 17:02:29 BST 2011
Hi,
It looks like this commit break the TestBlockLayout test:
http://my.cdash.org/testDetails.php?test=5977633&build=185137
On Friday 06 May 2011, Hanzes Matus wrote:
> Git commit df1f2daf633d2454807289b87c980841cbfae8a4 by Hanzes Matus.
> Committed on 06/05/2011 at 14:40.
> Pushed by hanzes into branch 'master'.
>
> fix -line height in presenter
>
> Line height in presenter should be font metric independent.
>
> M +46 -47 libs/textlayout/KoTextLayoutArea.cpp
>
> http://commits.kde.org/calligra/df1f2daf633d2454807289b87c980841cbfae8a4
>
> diff --git a/libs/textlayout/KoTextLayoutArea.cpp
> b/libs/textlayout/KoTextLayoutArea.cpp index 99ea277..39594e0 100644
> --- a/libs/textlayout/KoTextLayoutArea.cpp
> +++ b/libs/textlayout/KoTextLayoutArea.cpp
> @@ -69,6 +69,7 @@
> extern int qt_defaultDpiY();
>
> #define DropCapsAdditionalFormattingId 25602902
> +#define PresenterFontStretch 1.2
>
> KoTextLayoutArea::KoTextLayoutArea(KoTextLayoutArea *p,
> KoTextDocumentLayout *documentLayout)
>
> : m_parent(p)
>
> @@ -922,59 +923,57 @@ qreal KoTextLayoutArea::addLine(QTextLine &line,
> FrameIterator *cursor, KoTextBl }
> } else { // not fixed lineheight
> const bool useFontProperties =
> format.boolProperty(KoParagraphStyle::LineSpacingFromFont); - if
> (useFontProperties) {
> - height = line.height();
> - } else {
> - if (cursor->fragmentIterator.atEnd()) {// no text in parag.
>
> - qreal fontStretch = 1;
> - // stretch line height to ms-word size
> - if
> (block.charFormat().hasProperty(KoCharacterStyle::FontStretch)) { -
> fontStretch =
> block.charFormat().property(KoCharacterStyle::FontStretch).toDouble(); -
> }
> - height = block.charFormat().fontPointSize() * fontStretch;
> - } else {
> -
> - qreal fontStretch = 1;
> - // stretch line height to ms-word size
> - if
> (cursor->fragmentIterator.fragment().charFormat().hasProperty(KoCharacterS
> tyle::FontStretch)) { - fontStretch =
> cursor->fragmentIterator.fragment().charFormat().property(KoCharacterStyle
> ::FontStretch).toDouble(); + if (cursor->fragmentIterator.atEnd())
> {// no text in parag. + //stretch line height to powerpoint
> size
> + qreal fontStretch = PresenterFontStretch;
> + // stretch line height to ms-word size
> + if (!useFontProperties &&
> block.charFormat().hasProperty(KoCharacterStyle::FontStretch)) { +
> fontStretch =
> block.charFormat().property(KoCharacterStyle::FontStretch).toDouble(); +
> }
> + height = block.charFormat().fontPointSize() * fontStretch;
> + } else {
> + //stretch line height to powerpoint size
> + qreal fontStretch = PresenterFontStretch;
> + // stretch line height to ms-word size
> + if (!useFontProperties &&
> cursor->fragmentIterator.fragment().charFormat().hasProperty(KoCharacterSt
> yle::FontStretch)) { + fontStretch =
> cursor->fragmentIterator.fragment().charFormat().property(KoCharacterStyle
> ::FontStretch).toDouble(); + }
> + // read max font height
> + height = qMax(height,
> cursor->fragmentIterator.fragment().charFormat().fontPointSize() *
> fontStretch); +
> + KoInlineObjectExtent pos =
> m_documentLayout->inlineObjectExtent(cursor->fragmentIterator.fragment());
> + objectAscent = qMax(objectAscent, pos.m_ascent);
> + objectDescent = qMax(objectDescent, pos.m_descent);
> +
> + while (!(cursor->fragmentIterator.atEnd() ||
> cursor->fragmentIterator.fragment().contains( +
> block.position() + line.textStart() + line.textLength() - 1))) { +
> cursor->fragmentIterator++;
> + if (cursor->fragmentIterator.atEnd()) {
> + break;
> }
> - // read max font height
> - height = qMax(height,
> cursor->fragmentIterator.fragment().charFormat().fontPointSize() *
> fontStretch); -
> - KoInlineObjectExtent pos =
> m_documentLayout->inlineObjectExtent(cursor->fragmentIterator.fragment());
> - objectAscent = qMax(objectAscent, pos.m_ascent);
> - objectDescent = qMax(objectDescent, pos.m_descent);
> -
> - while (!(cursor->fragmentIterator.atEnd() ||
> cursor->fragmentIterator.fragment().contains( -
> block.position() + line.textStart() + line.textLength() - 1))) { -
> cursor->fragmentIterator++;
> - if (cursor->fragmentIterator.atEnd()) {
> - break;
> - }
> - if (!m_documentLayout->changeTracker()
> - ||
> !m_documentLayout->changeTracker()->displayChanges() -
> ||
> !m_documentLayout->changeTracker()->containsInlineChanges(cursor->fragment
> Iterator.fragment().charFormat()) - ||
> !m_documentLayout->changeTracker()->elementById(cursor->fragmentIterator.f
> ragment().charFormat().property(KoCharacterStyle::ChangeTrackerId).toInt())
> ->isEnabled() - ||
> (m_documentLayout->changeTracker()->elementById(cursor->fragmentIterator.f
> ragment().charFormat().property(KoCharacterStyle::ChangeTrackerId).toInt())
> ->getChangeType() != KoGenChange::DeleteChange) - ||
> m_documentLayout->changeTracker()->displayChanges()) { -
> qreal fontStretch = 1;
> - // stretch line height to ms-word size
> - if
> (cursor->fragmentIterator.fragment().charFormat().hasProperty(KoCharacterS
> tyle::FontStretch)) { - fontStretch =
> cursor->fragmentIterator.fragment().charFormat().property(KoCharacterStyle
> ::FontStretch).toDouble(); - }
> - // read max font height
> - height = qMax(height,
> cursor->fragmentIterator.fragment().charFormat().fontPointSize() *
> fontStretch); -
> - KoInlineObjectExtent pos =
> m_documentLayout->inlineObjectExtent(cursor->fragmentIterator.fragment());
> - objectAscent = qMax(objectAscent, pos.m_ascent);
> - objectDescent = qMax(objectDescent,
> pos.m_descent); + if (!m_documentLayout->changeTracker()
> + ||
> !m_documentLayout->changeTracker()->displayChanges() +
> ||
> !m_documentLayout->changeTracker()->containsInlineChanges(cursor->fragment
> Iterator.fragment().charFormat()) + ||
> !m_documentLayout->changeTracker()->elementById(cursor->fragmentIterator.f
> ragment().charFormat().property(KoCharacterStyle::ChangeTrackerId).toInt())
> ->isEnabled() + ||
> (m_documentLayout->changeTracker()->elementById(cursor->fragmentIterator.f
> ragment().charFormat().property(KoCharacterStyle::ChangeTrackerId).toInt())
> ->getChangeType() != KoGenChange::DeleteChange) + ||
> m_documentLayout->changeTracker()->displayChanges()) { +
> //stretch line height to powerpoint size
> + qreal fontStretch = PresenterFontStretch;
> + // stretch line height to ms-word size
> + if (!useFontProperties &&
> cursor->fragmentIterator.fragment().charFormat().hasProperty(KoCharacterSt
> yle::FontStretch)) { + fontStretch =
> cursor->fragmentIterator.fragment().charFormat().property(KoCharacterStyle
> ::FontStretch).toDouble(); }
> + // read max font height
> + height = qMax(height,
> cursor->fragmentIterator.fragment().charFormat().fontPointSize() *
> fontStretch); +
> + KoInlineObjectExtent pos =
> m_documentLayout->inlineObjectExtent(cursor->fragmentIterator.fragment());
> + objectAscent = qMax(objectAscent, pos.m_ascent); +
> objectDescent = qMax(objectDescent, pos.m_descent); }
> }
> - if (height < 0.01) height = 12; // default size for
> uninitialized styles. }
> + if (height < 0.01) height = 12; // default size for uninitialized
> styles. }
>
> // add linespacing
--
Cyrille Berger Skott
More information about the calligra-devel
mailing list