[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/filters/kspread/excel/import
From: Sebastian Sauer <mail () dipe ! org>
Date: 2010-03-02 21:58:44
Message-ID: 1267567124.114425.20969.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1098113 by sebsauer:
cleanup a bit
M +40 -80 excelimport.cc
--- trunk/koffice/filters/kspread/excel/import/excelimport.cc #1098112:1098113
@@ -27,7 +27,7 @@
#include <QDate>
#include <QBuffer>
#include <QFontMetricsF>
-
+#include <QPair>
#include <kdebug.h>
#include <KoFilterChain.h>
#include <KoGlobal.h>
@@ -133,7 +133,9 @@
QList<QString> sheetStyles;
QHash<FormatFont, QString> fontStyles;
QString subScriptStyle, superScriptStyle;
- QList<ChartObject*> charts;
+
+ typedef QPair<QString,ChartObject*> Chart;
+ QList<Chart> charts;
QHash<int,int> rowsRepeatedHash;
int rowsRepeated(Row* row, int rowIndex);
@@ -141,7 +143,7 @@
int rowsCountTotal, rowsCountDone;
void addProgress(int addValue);
- bool createStyles(KoOdfWriteStore* store, KoXmlWriter* manifestWriter);
+ bool createStyles(KoStore* store, KoXmlWriter* manifestWriter, KoGenStyles* \
mainStyles); bool createContent(KoOdfWriteStore* store);
bool createMeta(KoOdfWriteStore* store);
bool createSettings(KoOdfWriteStore* store);
@@ -255,7 +257,7 @@
}
// store document styles
- if ( !d->createStyles( &oasisStore, manifestWriter ) )
+ if ( !d->createStyles( d->storeout, manifestWriter, d->mainStyles ) )
{
kWarning() << "Couldn't open the file 'styles.xml'.";
delete d->workbook;
@@ -388,13 +390,15 @@
return store->closeContentWriter();
}
+
+
// Writes the styles.xml
-bool ExcelImport::Private::createStyles(KoOdfWriteStore* store, KoXmlWriter* \
manifestWriter) +bool ExcelImport::Private::createStyles(KoStore* store, KoXmlWriter* \
manifestWriter, KoGenStyles* mainStyles) {
Q_UNUSED(manifestWriter);
- if (!store->store()->open("styles.xml"))
+ if (!store->open("styles.xml"))
return false;
- KoStoreDevice dev(store->store());
+ KoStoreDevice dev(store);
KoXmlWriter* stylesWriter = new KoXmlWriter(&dev);
stylesWriter->startDocument("office:document-styles");
@@ -432,7 +436,7 @@
stylesWriter->endDocument();
delete stylesWriter;
- return store->store()->close();
+ return store->close();
}
// Writes meta-informations into the meta.xml
@@ -1458,31 +1462,25 @@
//<draw:frame table:end-cell-address="Sheet1.I17" table:end-x="0.5217in" \
table:end-y="0.1382in" draw:z-index="0" draw:style-name="gr1" svg:width="3.1492in" \
svg:height="2.7555in" svg:x="0.0398in" svg:y="0.0394in">
//<draw:object draw:notify-on-update-of-ranges="Sheet1.C2:Sheet1.E2" \
xlink:href="./Object 1" xlink:type="simple" xlink:show="embed" \
xlink:actuate="onLoad"/> //</draw:frame>
- this->charts << chart;
+ const QString href = QString("Object%1").arg(this->charts.count());
+ this->charts << Chart(href, chart);
DrawingObject* drawobj = chart->drawingObject();
Q_ASSERT(drawobj);
- const QString href = QString("./Object%1").arg(this->charts.count());
xmlWriter->startElement("draw:frame");
-#if 0 //FIXME
+ //xmlWriter->addAttribute("table:end-cell-address", "Sheet1.H20");
+ //xmlWriter->addAttribute("table:end-x", "0.2953in");
+ //xmlWriter->addAttribute("table:end-y", "0.0232in");
xmlWriter->addAttribute("table:end-cell-address", \
columnName(drawobj->m_colR) + QString::number(drawobj->m_rwB));
xmlWriter->addAttribute("svg:x", \
QString::number(columnWidth(cell->sheet(),drawobj->m_colL,drawobj->m_dxL))+"pt");
xmlWriter->addAttribute("svg:y", \
QString::number(rowHeight(cell->sheet(),drawobj->m_rwT,drawobj->m_dyT))+"pt");
xmlWriter->addAttribute("svg:width", \
QString::number(columnWidth(cell->sheet(),drawobj->m_colR-drawobj->m_colL,drawobj->m_dxR))+"pt");
xmlWriter->addAttribute("svg:height", \
QString::number(rowHeight(cell->sheet(),drawobj->m_rwB-drawobj->m_rwT,drawobj->m_dyB))+"pt");
-#else
- xmlWriter->addAttribute("table:end-cell-address", "Sheet1.H20");
- xmlWriter->addAttribute("table:end-x", "0.2953in");
- xmlWriter->addAttribute("table:end-y", "0.0232in");
- xmlWriter->addAttribute("draw:z-index", "0");
- xmlWriter->addAttribute("svg:x", "0.702in");
- xmlWriter->addAttribute("svg:y", "0.1016in");
- xmlWriter->addAttribute("svg:width", "3.1492in");
- xmlWriter->addAttribute("svg:height", "2.7555in");
-#endif
+ //xmlWriter->addAttribute("draw:z-index", "0");
+
xmlWriter->startElement("draw:object");
xmlWriter->addAttribute("draw:notify-on-update-of-ranges", \
"Sheet1.D2:Sheet1.F2");
- xmlWriter->addAttribute("xlink:href", href);
+ xmlWriter->addAttribute("xlink:href", "./" + href);
xmlWriter->addAttribute("xlink:type", "simple");
xmlWriter->addAttribute("xlink:show", "embed");
xmlWriter->addAttribute("xlink:actuate", "onLoad");
@@ -1499,9 +1497,9 @@
KoGenStyles styles;
KoGenStyles mainStyles;
- for(int i = 0; i < this->charts.count(); ++i) {
- ChartObject *chart = this->charts[i];
- const QString href = QString("Object%1").arg(i+1); // don't use relative \
directories here + foreach(const Chart &_chart, this->charts) {
+ const QString href = _chart.first;
+ ChartObject *chart = _chart.second;
this->storeout->pushDirectory();
this->storeout->enterDirectory(href);
@@ -1522,7 +1520,6 @@
//style.addProperty("draw:stroke", "solid");
//style.addProperty("draw:fill-color", "#ff0000");
//bodyWriter->addAttribute("chart:style-name", styles.lookup(style, "ch"));
- bodyWriter->addAttribute("chart:style-name", "ch94");
//<chart:legend chart:legend-position="end" svg:x="7.031cm" svg:y="2.843cm" \
chart:style-name="ch2"/>
@@ -1536,13 +1533,12 @@
//chartstyle.addProperty("chart:sort-by-x-values", "false");
//chartstyle.addProperty("chart:right-angled-axes", "true");
//bodyWriter->addAttribute("chart:style-name", styles.lookup(chartstyle, \
"ch"));
- bodyWriter->addAttribute("chart:style-name", "ch98");
bodyWriter->addAttribute("table:cell-range-address", "Sheet1.C2:Sheet1.E2"); //FIXME
-bodyWriter->addAttribute("svg:x", "0.16cm"); //FIXME
-bodyWriter->addAttribute("svg:y", "0.14cm"); //FIXME
-bodyWriter->addAttribute("svg:width", "6.712cm"); //FIXME
-bodyWriter->addAttribute("svg:height", "6.58cm"); //FIXME
+ //bodyWriter->addAttribute("svg:x", "0.16cm"); //FIXME
+ //bodyWriter->addAttribute("svg:y", "0.14cm"); //FIXME
+ //bodyWriter->addAttribute("svg:width", "6.712cm"); //FIXME
+ //bodyWriter->addAttribute("svg:height", "6.58cm"); //FIXME
//<chart:axis chart:dimension="x" chart:name="primary-x" \
chart:style-name="ch4"/>
//<chart:axis chart:dimension="y" chart:name="primary-y" \
chart:style-name="ch5"><chart:grid chart:style-name="ch6" \
chart:class="major"/></chart:axis> @@ -1555,15 +1551,17 @@
//bodyWriter->addAttribute("chart:style-name", styles.lookup(seriesstyle, \
"ch"));
bodyWriter->addAttribute("chart:values-cell-range-address", "Sheet1.C2:Sheet1.E2"); \
//FIXME
-bodyWriter->addAttribute("chart:class", "chart:circle"); //FIXME
-for(int j=0; j < 3; ++j) {
- //KoGenStyle gs(KoGenStyle::StyleGraphicAuto, "chart");
- //gs.addProperty("draw:fill-color", "#004586");
- bodyWriter->startElement("chart:data-point");
- //bodyWriter->addAttribute("chart-style-name", styles.lookup(gs, "ch"));
- bodyWriter->addAttribute("chart-style-name", "ch97");
- bodyWriter->endElement();
-}
+ bodyWriter->addAttribute("chart:class", "chart:circle"); //FIXME
+
+ /*
+ for(int j=0; j < 3; ++j) {
+ //KoGenStyle gs(KoGenStyle::StyleGraphicAuto, "chart");
+ //gs.addProperty("draw:fill-color", "#004586");
+ bodyWriter->startElement("chart:data-point");
+ //bodyWriter->addAttribute("chart-style-name", styles.lookup(gs, "ch"));
+ bodyWriter->endElement();
+ }
+ */
//<chart:data-point chart:style-name="ch8"/>
//<chart:data-point chart:style-name="ch9"/>
//<chart:data-point chart:style-name="ch10"/>
@@ -1579,47 +1577,9 @@
styles.saveOdfAutomaticStyles(contentWriter, false);
s.closeContentWriter();
- if(this->storeout->open("styles.xml")) {
- KoStoreDevice dev(this->storeout);
- KoXmlWriter* stylesWriter = new KoXmlWriter(&dev);
+ //KoOdfWriteStore oasisStore(d->storeout);
+ createStyles(this->storeout, manifestWriter, &mainStyles);
- stylesWriter->startDocument("office:document-styles");
- stylesWriter->startElement("office:document-styles");
- stylesWriter->addAttribute("xmlns:office", \
"urn:oasis:names:tc:opendocument:xmlns:office:1.0");
- stylesWriter->addAttribute("xmlns:style", \
"urn:oasis:names:tc:opendocument:xmlns:style:1.0");
- stylesWriter->addAttribute("xmlns:text", \
"urn:oasis:names:tc:opendocument:xmlns:text:1.0");
- stylesWriter->addAttribute("xmlns:table", \
"urn:oasis:names:tc:opendocument:xmlns:table:1.0");
- stylesWriter->addAttribute("xmlns:draw", \
"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0");
- stylesWriter->addAttribute("xmlns:fo", \
"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
- stylesWriter->addAttribute("xmlns:svg", \
"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
- stylesWriter->addAttribute("xmlns:xlink", \
"http://www.w3.org/1999/xlink");
- stylesWriter->addAttribute("xmlns:chart", \
"urn:oasis:names:tc:opendocument:xmlns:chart:1.0");
- stylesWriter->addAttribute("xmlns:dc", \
"http://purl.org/dc/elements/1.1/");
- stylesWriter->addAttribute("xmlns:meta", \
"urn:oasis:names:tc:opendocument:xmlns:meta:1.0");
- stylesWriter->addAttribute("xmlns:number", \
"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0");
- //stylesWriter->addAttribute("xmlns:presentation", \
"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0");
- //stylesWriter->addAttribute("xmlns:dr3d", \
"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0");
- stylesWriter->addAttribute("xmlns:math", \
"http://www.w3.org/1998/Math/MathML");
- //stylesWriter->addAttribute("xmlns:form", \
"urn:oasis:names:tc:opendocument:xmlns:form:1.0");
- //stylesWriter->addAttribute("xmlns:script", \
"urn:oasis:names:tc:opendocument:xmlns:script:1.0");
- //stylesWriter->addAttribute("xmlns:dom", \
"http://www.w3.org/2001/xml-events");
- //stylesWriter->addAttribute("xmlns:xforms", \
"http://www.w3.org/2002/xforms");
- //stylesWriter->addAttribute("xmlns:xsd", \
"http://www.w3.org/2001/XMLSchema");
- //stylesWriter->addAttribute("xmlns:xsi", \
"http://www.w3.org/2001/XMLSchema-instance");
- stylesWriter->addAttribute("xmlns:of", \
"urn:oasis:names:tc:opendocument:xmlns:of:1.2");
- //stylesWriter->addAttribute("xmlns:rdfa", \
"http://docs.oasis-open.org/opendocument/meta/rdfa#");
- stylesWriter->addAttribute("office:version", "1.2");
-
- mainStyles.saveOdfMasterStyles(stylesWriter);
- mainStyles.saveOdfDocumentStyles(stylesWriter); // office:style
- mainStyles.saveOdfAutomaticStyles(stylesWriter, false); // \
office:automatic-styles
-
- stylesWriter->endElement(); // office:document-styles
- stylesWriter->endDocument();
- delete stylesWriter;
- this->storeout->close();
- }
-
manifestWriter->addManifestEntry(href, \
"application/vnd.oasis.opendocument.chart");
manifestWriter->addManifestEntry(QString("%1/styles.xml").arg(href), \
"text/xml");
manifestWriter->addManifestEntry(QString("%1/content.xml").arg(href), \
"text/xml");
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic