[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: precision in OpenDocument
From: "Ariya Hidayat" <ariya () kde ! org>
Date: 2006-04-19 18:56:48
Message-ID: ba035dd10604191156r111fade1rb53ac03d12a74839 () mail ! gmail ! com
[Download RAW message or body]
The attached patch solves the problem with explicit precision in the
cell formatting when importing Excel documents. For some reasons, this
still does not solve bug 125520 and 118331 yet.
["precision.patch" (text/x-patch)]
Index: lib/kofficecore/KoOasisStyles.cpp
===================================================================
--- lib/kofficecore/KoOasisStyles.cpp (revision 531642)
+++ lib/kofficecore/KoOasisStyles.cpp (working copy)
@@ -227,7 +227,7 @@
void KoOasisStyles::importDataStyle( const QDomElement& parent )
{
QString format;
- int precision = 0;
+ int precision = -1;
int leadingZ = 1;
bool thousandsSep = false;
//todo negred
@@ -441,8 +441,13 @@
numeric.formatStr=format;
numeric.prefix=prefix;
numeric.suffix=suffix;
+ numeric.precision = precision;
kdDebug()<<" finish insert format :"<<format<<" prefix :"<<prefix<<" suffix \
:"<<suffix<<endl; m_dataFormats.insert( styleName, numeric );
+
+ KoOasisNumericFormat numFormat;
+ numFormat.precision = precision;
+ m_numericFormats.insert( styleName, numFormat );
}
#define addTextNumber( text, elementWriter ) { \
Index: lib/kofficecore/KoOasisStyles.h
===================================================================
--- lib/kofficecore/KoOasisStyles.h (revision 531642)
+++ lib/kofficecore/KoOasisStyles.h (working copy)
@@ -31,6 +31,13 @@
class KoGenStyle;
class KoStyleStack;
+// FIXME this is to maintain binary compatibility of KoOasisStyles in 1.5.x
+// TODO merge with KoOasisStyles::NumericStyleFormat in KOffice 2.0
+struct KOFFICECORE_EXPORT KoOasisNumericFormat
+{
+ int precision;
+};
+
/**
* Repository of styles used during loading of OASIS/OOo file
*/
@@ -97,6 +104,7 @@
QString formatStr;
QString prefix;
QString suffix;
+ int precision;
};
typedef QMap<QString, NumericStyleFormat> DataFormatsMap;
@@ -104,6 +112,9 @@
/// Key: format name. Value:
const DataFormatsMap& dataFormats() const { return m_dataFormats; }
+ typedef QMap<QString, KoOasisNumericFormat> NumericFormatsMap;
+ const NumericFormatsMap& numericFormats() const { return m_numericFormats; }
+
static QString saveOasisDateStyle( KoGenStyles &mainStyles, const QString & \
_format, bool klocaleFormat );
static QString saveOasisTimeStyle( KoGenStyles &mainStyles, const QString & \
_format, bool klocaleFormat ); static QString saveOasisFractionStyle( KoGenStyles \
&mainStyles, const QString & _format, const QString &_prefix = QString::null , const \
QString &_suffix= QString::null ); @@ -143,7 +154,9 @@
QDict<QDomElement> m_listStyles;
QDict<QDomElement> m_drawStyles;
+
DataFormatsMap m_dataFormats;
+ NumericFormatsMap m_numericFormats;
class Private;
Private * const d;
Index: kspread/kspread_style.cc
===================================================================
--- kspread/kspread_style.cc (revision 531643)
+++ kspread/kspread_style.cc (working copy)
@@ -177,26 +177,37 @@
//kdDebug()<< " oasisStyles.dataFormats()[...] prefix :"<< \
oasisStyles.dataFormats()[element.attributeNS( KoXmlNS::style, "data-style-name" , \
QString::null)].prefix<<endl; //kdDebug()<< " oasisStyles.dataFormats()[...] suffix \
:"<< oasisStyles.dataFormats()[element.attributeNS( KoXmlNS::style, "data-style-name" \
, QString::null)].suffix<<endl;
- str = element.attributeNS( KoXmlNS::style, "data-style-name" , \
QString::null); + QString styleName = element.attributeNS( KoXmlNS::style, \
"data-style-name" , QString::null); +
+ const KoOasisStyles::NumericStyleFormat& dataFormat = \
oasisStyles.dataFormats()[styleName];
- QString tmp = oasisStyles.dataFormats()[str].prefix;
- if ( !tmp.isEmpty() )
+ bool hasNumericFormat = oasisStyles.numericFormats().contains(styleName);
+ const KoOasisNumericFormat& numFormat = \
oasisStyles.numericFormats()[styleName]; +
+ if ( !dataFormat.prefix.isEmpty() )
{
- m_prefix = tmp;
+ m_prefix = dataFormat.prefix;
m_featuresSet |= SPrefix;
}
- tmp = oasisStyles.dataFormats()[str].suffix;
- if ( !tmp.isEmpty() )
+
+ if ( !dataFormat.suffix.isEmpty() )
{
- m_postfix = tmp;
+ m_postfix = dataFormat.suffix;
m_featuresSet |= SPostfix;
}
- tmp = oasisStyles.dataFormats()[str].formatStr;
- if ( !tmp.isEmpty() )
+
+ if ( !dataFormat.formatStr.isEmpty() )
{
- m_formatType = Style::formatType( tmp );
+ m_formatType = Style::formatType( dataFormat.formatStr );
m_featuresSet |= SFormatType;
}
+
+ if ( hasNumericFormat )
+ {
+ m_precision = numFormat.precision;
+ m_featuresSet |= SPrecision;
+ }
+
}
styleStack.setTypeProperties( "text" );
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic