[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/libs/kotext/styles
From: Jos van den Oever <jos () vandenoever ! info>
Date: 2010-08-16 8:18:29
Message-ID: 20100816081829.F19FBAC854 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1164193 by vandenoever:
Revert commit 1163903.
M +15 -17 KoCharacterStyle.cpp
--- trunk/koffice/libs/kotext/styles/KoCharacterStyle.cpp #1164192:1164193
@@ -80,7 +80,7 @@
void setApplicationDefaults(KoOdfLoadingContext &context);
//This should be called after all charFormat properties are merged to the cursor.
- void ensureMinimalProperties(QTextCharFormat &format);
+ void ensureMinimalProperties(QTextCursor &cursor, bool blockCharFormatAlso);
StylePrivate hardCodedDefaultStyle;
@@ -113,8 +113,9 @@
}
}
-void KoCharacterStyle::Private::ensureMinimalProperties(QTextCharFormat &format)
+void KoCharacterStyle::Private::ensureMinimalProperties(QTextCursor &cursor, bool blockCharFormatAlso)
{
+ QTextCharFormat format = cursor.charFormat();
QMap<int, QVariant> props = hardCodedDefaultStyle.properties();
QMap<int, QVariant>::const_iterator it = props.constBegin();
while (it != props.constEnd()) {
@@ -123,6 +124,9 @@
}
++it;
}
+ cursor.mergeCharFormat(format);
+ if (blockCharFormatAlso)
+ cursor.mergeBlockCharFormat(format);
}
KoCharacterStyle::KoCharacterStyle(QObject *parent)
@@ -212,26 +216,20 @@
void KoCharacterStyle::applyStyle(QTextBlock &block) const
{
QTextCursor cursor(block);
+ QTextCharFormat cf;
cursor.setPosition(block.position() + block.length() - 1, QTextCursor::KeepAnchor);
-
- // this is suboptimal code: the minimal defaults should be applied first, not last
- QTextCharFormat format = cursor.charFormat();
- applyStyle(format);
- d->ensureMinimalProperties(format);
- cursor.setCharFormat(format);
-
- format = cursor.blockCharFormat();
- applyStyle(format);
- d->ensureMinimalProperties(format);
- cursor.setBlockCharFormat(format);
+ applyStyle(cf);
+ cursor.mergeCharFormat(cf);
+ cursor.mergeBlockCharFormat(cf);
+ d->ensureMinimalProperties(cursor, true);
}
void KoCharacterStyle::applyStyle(QTextCursor *selection) const
{
- QTextCharFormat format = selection->charFormat();
- applyStyle(format);
- d->ensureMinimalProperties(format);
- selection->setCharFormat(format);
+ QTextCharFormat cf;
+ applyStyle(cf);
+ selection->mergeCharFormat(cf);
+ d->ensureMinimalProperties(*selection, false);
}
void KoCharacterStyle::unapplyStyle(QTextCharFormat &format) const
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic