Commit 6a06a9fc authored by Pierre Ducroquet's avatar Pierre Ducroquet

Simplify the code

svn path=/trunk/koffice/; revision=689157
parent 6d89a9bb
...@@ -810,7 +810,7 @@ void KoTextLoader::loadSpan(KoTextLoadingContext& context, const KoXmlElement& p ...@@ -810,7 +810,7 @@ void KoTextLoader::loadSpan(KoTextLoadingContext& context, const KoXmlElement& p
{ {
loadFrame(context, ts, cursor); loadFrame(context, ts, cursor);
} }
else if ( isTextNS && localName == "date" ) else if ( isTextNS && (localName == "date" || localName == "time") )
{ {
KoTextDocumentLayout *layout = dynamic_cast<KoTextDocumentLayout*> (cursor.block().document()->documentLayout()); KoTextDocumentLayout *layout = dynamic_cast<KoTextDocumentLayout*> (cursor.block().document()->documentLayout());
if ( layout ) { if ( layout ) {
...@@ -830,44 +830,29 @@ void KoTextLoader::loadSpan(KoTextLoadingContext& context, const KoXmlElement& p ...@@ -830,44 +830,29 @@ void KoTextLoader::loadSpan(KoTextLoadingContext& context, const KoXmlElement& p
} }
} }
kDebug() << "Final date format :" << dateFormat << endl; kDebug() << "Final date format :" << dateFormat << endl;
QDateTime dateTime = QDateTime::fromString(ts.attributeNS(KoXmlNS::text, "date-value"), Qt::ISODate);
KoInlineObject *dateObject = dateFactory->createInlineObject(new KoProperties()); KoInlineObject *dateObject = dateFactory->createInlineObject(new KoProperties());
if (dateFormat.isEmpty()) QString result;
((KoVariable *)dateObject)->setValue(dateTime.date().toString(Qt::LocalDate)); if (localName == "date") {
else QDateTime dateTime = QDateTime::fromString(ts.attributeNS(KoXmlNS::text, "date-value"), Qt::ISODate);
((KoVariable *)dateObject)->setValue(dateTime.date().toString(dateFormat)); KoInlineObject *dateObject = dateFactory->createInlineObject(new KoProperties());
textObjectManager->insertInlineObject(cursor, dateObject); if (dateFormat.isEmpty())
} result = dateTime.date().toString(Qt::LocalDate);
} //((KoVariable *)dateObject)->setValue(dateTime.date().toString(Qt::LocalDate));
} else
} result = dateTime.date().toString(dateFormat);
} //((KoVariable *)dateObject)->setValue(dateTime.date().toString(dateFormat));
} //kDebug() << dateTime.date().toString(dateFormat) << endl;
else if ( isTextNS && localName == "time" ) } else {
{ QDateTime dateTime = QDateTime::fromString(ts.attributeNS(KoXmlNS::text, "time-value"), Qt::ISODate);
KoTextDocumentLayout *layout = dynamic_cast<KoTextDocumentLayout*> (cursor.block().document()->documentLayout()); KoInlineObject *dateObject = dateFactory->createInlineObject(new KoProperties());
if ( layout ) { if (dateFormat.isEmpty())
KoInlineTextObjectManager *textObjectManager = layout->inlineObjectTextManager(); result = dateTime.time().toString(Qt::LocalDate);
if ( textObjectManager ) { //((KoVariable *)dateObject)->setValue(dateTime.time().toString(Qt::LocalDate));
KoVariableManager *varManager = textObjectManager->variableManager(); else
if (varManager) { result = dateTime.time().toString(dateFormat);
if (KoInlineObjectRegistry::instance()->contains("date")) { //((KoVariable *)dateObject)->setValue(dateTime.time().toString(dateFormat));
KoInlineObjectFactory *dateFactory = KoInlineObjectRegistry::instance()->value("date");
if (dateFactory) {
QString dataStyle = ts.attributeNS(KoXmlNS::style, "data-style-name");
QString dateFormat = "";
if (!dataStyle.isEmpty()) {
if (context.oasisStyles().dataFormats().contains(dataStyle)) {
KoOasisStyles::NumericStyleFormat dataFormat = context.oasisStyles().dataFormats().value(dataStyle);
dateFormat = dataFormat.prefix + dataFormat.formatStr + dataFormat.suffix;
}
} }
QDateTime dateTime = QDateTime::fromString(ts.attributeNS(KoXmlNS::text, "time-value"), Qt::ISODate); ((KoVariable *)dateObject)->setValue(result);
KoInlineObject *dateObject = dateFactory->createInlineObject(new KoProperties());
if (dateFormat.isEmpty())
((KoVariable *)dateObject)->setValue(dateTime.time().toString(Qt::LocalDate));
else
((KoVariable *)dateObject)->setValue(dateTime.time().toString(dateFormat));
textObjectManager->insertInlineObject(cursor, dateObject); textObjectManager->insertInlineObject(cursor, dateObject);
} }
} }
......
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