[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/libs/kotext/styles
From:       Pierre Ducroquet <pinaraf () gmail ! com>
Date:       2007-12-31 23:00:19
Message-ID: 1199142019.573121.31418.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 755282 by ducroquet:

Happy new year !!
For my first commit in 2008, a small gift : much better saving support for paragraph and character style.
(still missing : font name in character, and border in paragraph)



 M  +35 -21    KoCharacterStyle.cpp  
 M  +42 -2     KoParagraphStyle.cpp  


--- trunk/koffice/libs/kotext/styles/KoCharacterStyle.cpp #755281:755282
@@ -767,8 +767,6 @@
                     // Remember : Qt and CSS/XSL doesn't have the same scale...
                     target->addProperty("fo:font-weight", boldness*10, KoGenStyle::TextType);
                 }
-            } else {
-                kDebug(32500) << "What is this ???" << d->stylesPrivate->value(key);
             }
         } else if (key == QTextFormat::FontItalic) {
             if (d->stylesPrivate->value(key).toBool()) {
@@ -779,19 +777,13 @@
         } else if (key == UnderlineStyle) {
             bool ok = false;
             int style = d->stylesPrivate->value(key).toInt(&ok);
-            if (ok) {
+            if (ok)
                 target->addProperty("style:text-underline-style", \
                exportOasisLineStyle((KoCharacterStyle::LineStyle) style), KoGenStyle::TextType);
-            } else {
-                kDebug(32500) << "What is this ???" << d->stylesPrivate->value(key);
-            }
         } else if (key == UnderlineType) {
             bool ok = false;
             int type = d->stylesPrivate->value(key).toInt(&ok);
-            if (ok) {
+            if (ok)
                 target->addProperty("style:text-underline-type", \
                exportOasisLineType((KoCharacterStyle::LineType) type), KoGenStyle::TextType);
-            } else {
-                kDebug(32500) << "What is this ???" << d->stylesPrivate->value(key);
-            }
         } else if (key == UnderlineColor) {
             QColor color = d->stylesPrivate->value(key).value<QColor>();
             if (color.isValid())
@@ -799,33 +791,55 @@
         } else if (key == StrikeOutStyle) {
             bool ok = false;
             int style = d->stylesPrivate->value(key).toInt(&ok);
-            if (ok) {
+            if (ok)
                 target->addProperty("style:text-line-through-style", \
                exportOasisLineStyle((KoCharacterStyle::LineStyle) style), KoGenStyle::TextType);
-            } else {
-                kDebug(32500) << "What is this ???" << d->stylesPrivate->value(key);
-            }
         } else if (key == StrikeOutType) {
             bool ok = false;
             int type = d->stylesPrivate->value(key).toInt(&ok);
-            if (ok) {
+            if (ok)
                 target->addProperty("style:text-line-through-type", \
                exportOasisLineType((KoCharacterStyle::LineType) type), KoGenStyle::TextType);
-            } else {
-                kDebug(32500) << "What is this ???" << d->stylesPrivate->value(key);
-            }
         } else if (key == StrikeOutColor) {
             QColor color = d->stylesPrivate->value(key).value<QColor>();
             if (color.isValid())
                 target->addProperty("style:text-line-through-color", color.name(), \
                KoGenStyle::TextType);
-        }  else if (key == QTextFormat::BackgroundBrush) {
+        } else if (key == QTextFormat::BackgroundBrush) {
             QBrush brush = d->stylesPrivate->value(key).value<QBrush>();
             if (brush.style() == Qt::NoBrush)
                 target->addProperty("fo:background-color", "transparent", KoGenStyle::TextType);
             else
                 target->addProperty("fo:background-color", brush.color().name(), KoGenStyle::TextType);
-        } else {
-//             kDebug(32500) << "Storing the key " << key << "=>" << d->stylesPrivate->value(key);
+        } else if (key == QTextFormat::ForegroundBrush) {
+            QBrush brush = d->stylesPrivate->value(key).value<QBrush>();
+            if (brush.style() == Qt::NoBrush)
+                target->addProperty("fo:color", "transparent", KoGenStyle::TextType);
+            else
+                target->addProperty("fo:color", brush.color().name(), KoGenStyle::TextType);
+        } else if (key == QTextFormat::TextVerticalAlignment) {
+            if (verticalAlignment() == QTextCharFormat::AlignSuperScript)
+                target->addProperty("style:text-position", "super", KoGenStyle::TextType);
+            else if (verticalAlignment() == QTextCharFormat::AlignSubScript)
+                target->addProperty("style:text-position", "sub", KoGenStyle::TextType);
+        } else if (key == KoCharacterStyle::TransformText) {
+            Transform transform = (Transform) d->stylesPrivate->value(key).value<int>();
+            switch (transform) {
+                case SmallCaps:
+                    target->addProperty("fo:font-variant", "small-caps", KoGenStyle::TextType);
+                    break;
+                case AllUppercase:
+                    target->addProperty("fo:text-transform", "uppercase", KoGenStyle::TextType);
+                    break;
+                case AllLowercase:
+                    target->addProperty("fo:text-transform", "lowercase", KoGenStyle::TextType);
+                    break;
+                case Capitalize:
+                    target->addProperty("fo:text-transform", "capitalize", KoGenStyle::TextType);
+                    break;
+            }
+        } else if (key == QTextFormat::FontPointSize) {
+            target->addAttributePt("fo:font-size", fontPointSize());
         }
     }
+    //TODO: font name and family
 }
 
 #include "KoCharacterStyle.moc"
--- trunk/koffice/libs/kotext/styles/KoParagraphStyle.cpp #755281:755282
@@ -1192,10 +1192,50 @@
                 if (!direction.isEmpty())
                     target->addProperty("style:writing-mode", direction, KoGenStyle::ParagraphType);
             }
-        } else {
-            //kDebug(32500) << "Storing the key " << key << "=>" << d->stylesPrivate->value(key);
+        } else if (key == KoParagraphStyle::BreakBefore) {
+            if (breakBefore())
+                target->addProperty("fo:breaf-before", "page", KoGenStyle::ParagraphType);
+        } else if (key == KoParagraphStyle::BreakAfter) {
+            if (breakBefore())
+                target->addProperty("fo:breaf-after", "page", KoGenStyle::ParagraphType);
+        } else if (key == QTextFormat::BackgroundBrush) {
+            QBrush backBrush = background();
+            if (backBrush.style() != Qt::NoBrush)
+                target->addProperty("fo:background-color", backBrush.color().name(), \
KoGenStyle::ParagraphType); +            else
+                target->addProperty("fo:background-color", "transparent", KoGenStyle::ParagraphType);
+        // Padding
+        } else if (key == KoParagraphStyle::LeftPadding) {
+            target->addAttributePt("fo:padding-left", leftPadding());
+        } else if (key == KoParagraphStyle::RightPadding) {
+            target->addAttributePt("fo:padding-right", rightPadding());
+        } else if (key == KoParagraphStyle::TopPadding) {
+            target->addAttributePt("fo:padding-top", topPadding());
+        } else if (key == KoParagraphStyle::BottomPadding) {
+            target->addAttributePt("fo:padding-bottom", bottomPadding());
+        // Margin
+        } else if (key == QTextFormat::BlockLeftMargin) {
+            target->addAttributePt("fo:margin-left", leftMargin());
+        } else if (key == QTextFormat::BlockRightMargin) {
+            target->addAttributePt("fo:margin-right", rightMargin());
+        } else if (key == QTextFormat::BlockTopMargin) {
+            target->addAttributePt("fo:margin-top", topMargin());
+        } else if (key == QTextFormat::BlockBottomMargin) {
+            target->addAttributePt("fo:margin-bottom", bottomMargin());
+        // Line spacing
+        } else if (key == KoParagraphStyle::MinimumLineHeight) {
+            target->addAttributePt("style:line-height-at-least", minimumLineHeight());
+        } else if (key == KoParagraphStyle::LineSpacing) {
+            target->addAttributePt("style:line-spacing", lineSpacing());
+        } else if (key == KoParagraphStyle::PercentLineHeight) {
+            target->addProperty("fo:line-height", QString("%1%").arg(lineHeightPercent()), \
KoGenStyle::ParagraphType); +        } else if (key == KoParagraphStyle::FixedLineHeight) {
+            target->addAttributePt("fo:line-height", lineHeightAbsolute());
+        } else if (key == QTextFormat::TextIndent) {
+            target->addAttributePt("fo:text-indent", textIndent());
         }
     }
+    // TODO : save border information
 }
 
 #include "KoParagraphStyle.moc"


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic