Commit 0525b371 authored by Thomas Zander's avatar Thomas Zander

Fixes in the static factory method on KoParagraphStyle

svn path=/trunk/koffice/; revision=649563
parent 6cf45a71
......@@ -159,3 +159,19 @@ bool KoListStyle::operator==(const KoListStyle &other) const {
QTextList *KoListStyle::textList(const QTextDocument *doc) {
return m_textLists[doc];
}
// static
KoListStyle* KoListStyle::fromTextList(QTextList *list) {
KoListStyle *answer = new KoListStyle();
QTextListFormat format = list->format();
int i=0;
while(properties[i] != -1) {
int key = properties[i];
if(format.hasProperty(key))
answer->setProperty(key, format.property(key));
i++;
}
return answer;
}
......@@ -158,6 +158,8 @@ public:
QTextList *textList(const QTextDocument *doc);
static KoListStyle* fromTextList(QTextList *list);
protected:
friend class KoParagraphStyle;
void addUser() { m_refCount++; }
......
......@@ -19,6 +19,8 @@
#include "KoCharacterStyle.h"
#include "KoListStyle.h"
#include "KoTextBlockData.h"
#include "KoTextDocumentLayout.h"
#include "KoStyleManager.h"
#include "Styles_p.h"
......@@ -974,11 +976,32 @@ void KoParagraphStyle::loadOasis(KoStyleStack& styleStack) {
}
// static
KoParagraphStyle *KoParagraphStyle::fromBlockFormat(const QTextBlockFormat &format) {
KoParagraphStyle *answer = new KoParagraphStyle();
answer->remove(PercentLineHeight);
delete answer->characterStyle(); // TODO instead replace it with a character style from a QTextCharFormat
answer->d->charStyle = 0;
KoParagraphStyle *KoParagraphStyle::fromBlock(const QTextBlock &block) {
QTextBlockFormat format = block.blockFormat();
KoParagraphStyle *answer = 0;
KoCharacterStyle *charStyle = 0;
int styleId = format.intProperty(StyleId);
if(styleId > 0) {
KoTextDocumentLayout *layout = dynamic_cast<KoTextDocumentLayout*> (block.document()->documentLayout());
if(layout) {
KoStyleManager *sm = layout->styleManager();
if(sm) {
KoParagraphStyle *style = sm->paragraphStyle(styleId);
if(style)
answer = new KoParagraphStyle(*style);
charStyle = sm->characterStyle(format.intProperty(KoCharacterStyle::StyleId));
}
}
}
if(answer == 0) {
answer = new KoParagraphStyle();
answer->remove(PercentLineHeight);
delete answer->characterStyle();
}
answer->d->charStyle = charStyle;
if(block.textList())
answer->d->listStyle = KoListStyle::fromTextList(block.textList());
int i=0;
while(properties[i] != -1) {
......@@ -988,8 +1011,6 @@ KoParagraphStyle *KoParagraphStyle::fromBlockFormat(const QTextBlockFormat &form
i++;
}
// listStyle ??
return answer;
}
......
......@@ -132,30 +132,31 @@ public:
* Note that lineSpacing() is added to this.
* @see setLineSpacingFromFont
*/
void setLineHeightPercent(int lineHeight)
;
void setLineHeightPercent(int lineHeight);
/// @see setLineHeightPercent
int lineHeightPercent() const;
/**
* Sets the line height to a specific pt-based height, ignoring the font size.
* Note that lineSpacing() is added to this.
*/
void setLineHeightAbsolute(double height)
;
void setLineHeightAbsolute(double height);
/// @see setLineHeightAbsolute
double lineHeightAbsolute() const;
/**
* Sets the line height to have a minimum height in pt.
*/
void setMinimumLineHeight(double height);
/// @see setMinimumLineHeight
double minimumLineHeight() const;
/**
* Sets the space between two lines to be a specific height. The total linespacing will become
* the line height + this height. Where the line height is dependent on the font.
*/
void setLineSpacing(double spacing)
;
void setLineSpacing(double spacing);
/// @see setLineSpacing
double lineSpacing() const;
/**
......@@ -320,7 +321,7 @@ public:
QColor bottomBorderColor();
// ************ properties from QTextFormat
// ************ properties from QTextBlockFormat
/// duplicated property from QTextBlockFormat
void setTopMargin(double topMargin);
/// duplicated property from QTextBlockFormat
......@@ -436,7 +437,7 @@ as this is a duplicate of leftMargin, lets make it very clear we are using that
*/
void loadOasis(KoStyleStack& styleStack);
static KoParagraphStyle *fromBlockFormat(const QTextBlockFormat &format);
static KoParagraphStyle *fromBlock(const QTextBlock &block);
private:
void setProperty(int key, const QVariant &value);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment