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

List:       kde-commits
Subject:    =?utf-8?q?=5Bcalligra=5D_libs/kotext=3A_Finish_support_for_KoTab?=
From:       Pierre Ducroquet <pinaraf () pinaraf ! info>
Date:       2011-04-02 21:46:18
Message-ID: 20110402214618.7B500A609B () git ! kde ! org
[Download RAW message or body]

Git commit 47876f20432913a98687621d25f27914a7faf27d by Pierre Ducroquet.
Committed on 02/04/2011 at 23:47.
Pushed by ducroquet into branch 'master'.

Finish support for KoTableColumnStyle properties. According to the unit test results, \
it is 100% complete regarding ODF 1.1 spec.

M  +18   -0    libs/kotext/KoText.cpp     
M  +13   -0    libs/kotext/KoText.h     
M  +12   -18   libs/kotext/styles/KoTableColumnStyle.cpp     
M  +4    -4    libs/kotext/styles/KoTableColumnStyle.h     

http://commits.kde.org/calligra/47876f20432913a98687621d25f27914a7faf27d

diff --git a/libs/kotext/KoText.cpp b/libs/kotext/KoText.cpp
index 9480895..15bbedf 100644
--- a/libs/kotext/KoText.cpp
+++ b/libs/kotext/KoText.cpp
@@ -139,3 +139,21 @@ KoText::Direction KoText::directionFromString(const QString \
&writingMode)  return KoText::InheritDirection;
     return KoText::AutoDirection;
 }
+
+KoText::KoTextBreakProperty KoText::textBreakFromString(const QString& textBreak)
+{
+    if (textBreak == "page")
+        return KoText::PageBreak;
+    if (textBreak == "column")
+        return KoText::ColumnBreak;
+    return KoText::NoBreak;
+}
+
+QString KoText::textBreakToString(KoText::KoTextBreakProperty textBreak)
+{
+    if (textBreak == KoText::PageBreak)
+        return "page";
+    if (textBreak == KoText::ColumnBreak)
+        return "column";
+    return "auto";
+}
diff --git a/libs/kotext/KoText.h b/libs/kotext/KoText.h
index c450332..dce12a1 100644
--- a/libs/kotext/KoText.h
+++ b/libs/kotext/KoText.h
@@ -107,6 +107,19 @@ enum KoTextFrameProperty {
 
 /// convert the string version of directions (as specified in XSL and ODF) to the \
Direction enum  KOTEXT_EXPORT Direction directionFromString(const QString \
&direction); +
+/// There are several possible text breaks
+enum KoTextBreakProperty {
+    NoBreak,         ///< No text break
+    ColumnBreak,     ///< Column break
+    PageBreak        ///< Page break
+};
+
+/// convert the string version of text break (as specified in ODF) to the \
KoTextBreakProperty enum +KOTEXT_EXPORT KoTextBreakProperty textBreakFromString(const \
QString &textBreak); +/// convert the KoTextBreakProperty enum to the string version \
of text break (as specified in ODF) +KOTEXT_EXPORT QString textBreakToString \
(KoTextBreakProperty textBreak); +
 }
 
 Q_DECLARE_METATYPE(KoText::Tab)
diff --git a/libs/kotext/styles/KoTableColumnStyle.cpp \
b/libs/kotext/styles/KoTableColumnStyle.cpp index 5fdcf33..068ed09 100644
--- a/libs/kotext/styles/KoTableColumnStyle.cpp
+++ b/libs/kotext/styles/KoTableColumnStyle.cpp
@@ -168,24 +168,24 @@ qreal KoTableColumnStyle::relativeColumnWidth() const
     return propertyDouble(RelativeColumnWidth);
 }
 
-void KoTableColumnStyle::setBreakBefore(bool on)
+void KoTableColumnStyle::setBreakBefore(KoText::KoTextBreakProperty state)
 {
-    setProperty(BreakBefore, on);
+    setProperty(BreakBefore, state);
 }
 
-bool KoTableColumnStyle::breakBefore() const
+KoText::KoTextBreakProperty KoTableColumnStyle::breakBefore() const
 {
-    return propertyBoolean(BreakBefore);
+    return (KoText::KoTextBreakProperty) propertyInt(BreakBefore);
 }
 
-void KoTableColumnStyle::setBreakAfter(bool on)
+void KoTableColumnStyle::setBreakAfter(KoText::KoTextBreakProperty state)
 {
-    setProperty(BreakAfter, on);
+    setProperty(BreakAfter, state);
 }
 
-bool KoTableColumnStyle::breakAfter() const
+KoText::KoTextBreakProperty KoTableColumnStyle::breakAfter() const
 {
-    return propertyBoolean(BreakAfter);
+    return (KoText::KoTextBreakProperty) propertyInt(BreakAfter);
 }
 
 KoTableColumnStyle *KoTableColumnStyle::parentStyle() const
@@ -274,10 +274,10 @@ void KoTableColumnStyle::loadOdfProperties(KoStyleStack \
&styleStack)  
     // The fo:break-before and fo:break-after attributes insert a page or column \
break before or after a column.  if (styleStack.hasProperty(KoXmlNS::fo, \
                "break-before")) {
-        setBreakBefore(styleStack.property(KoXmlNS::fo, "break-before") != "auto");
+        setBreakBefore(KoText::textBreakFromString(styleStack.property(KoXmlNS::fo, \
"break-before")));  }
     if (styleStack.hasProperty(KoXmlNS::fo, "break-after")) {
-        setBreakAfter(styleStack.property(KoXmlNS::fo, "break-after") != "auto");
+        setBreakAfter(KoText::textBreakFromString(styleStack.property(KoXmlNS::fo, \
"break-after")));  }
 }
 
@@ -301,15 +301,9 @@ void KoTableColumnStyle::saveOdf(KoGenStyle &style) const
     QList<int> keys = d->stylesPrivate.keys();
     foreach(int key, keys) {
         if (key == KoTableColumnStyle::BreakBefore) {
-            if (breakBefore())
-                style.addProperty("fo:break-before", "page", \
                KoGenStyle::TableColumnType);
-            else
-                style.addProperty("fo:break-before", "auto", \
KoGenStyle::TableColumnType); +            style.addProperty("fo:break-before", \
KoText::textBreakToString(breakBefore()), KoGenStyle::TableColumnType);  } else if \
                (key == KoTableColumnStyle::BreakAfter) {
-            if (breakAfter())
-                style.addProperty("fo:break-after", "page", \
                KoGenStyle::TableColumnType);
-            else
-                style.addProperty("fo:break-after", "auto", \
KoGenStyle::TableColumnType); +            style.addProperty("fo:break-after", \
KoText::textBreakToString(breakAfter()), KoGenStyle::TableColumnType);  } else if \
                (key == KoTableColumnStyle::OptimalColumnWidth) {
             style.addProperty("style:use-optimal-column-width", \
optimalColumnWidth(), KoGenStyle::TableColumnType);  } else if (key == \
                KoTableColumnStyle::ColumnWidth) {
diff --git a/libs/kotext/styles/KoTableColumnStyle.h \
b/libs/kotext/styles/KoTableColumnStyle.h index bd5859a..d0a1c99 100644
--- a/libs/kotext/styles/KoTableColumnStyle.h
+++ b/libs/kotext/styles/KoTableColumnStyle.h
@@ -94,16 +94,16 @@ public:
     void setOptimalColumnWidth(bool state);
     
     /// Set break before. See  §7.19.2 of [XSL].
-    void setBreakBefore(bool on);
+    void setBreakBefore(KoText::KoTextBreakProperty state);
 
     /// Get break before. See  §7.19.2 of [XSL].
-    bool breakBefore() const;
+    KoText::KoTextBreakProperty breakBefore() const;
 
     /// Set break after. See  §7.19.1 of [XSL].
-    void setBreakAfter(bool on);
+    void setBreakAfter(KoText::KoTextBreakProperty state);
 
     /// Get break after. See  §7.19.1 of [XSL].
-    bool breakAfter() const;
+    KoText::KoTextBreakProperty breakAfter() const;
 
     /// Set the parent style this one inherits its unset properties from.
     void setParentStyle(KoTableColumnStyle *parent);


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

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