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

List:       kde-commits
Subject:    koffice/filters/kspread/excel
From:       Marijn Kruisselbrink <m.kruisselbrink () student ! tue ! nl>
Date:       2010-08-29 20:54:27
Message-ID: 20100829205427.15543AC876 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1169654 by mkruisselbrink:

initial start of writing actual cell content

 M  +66 -5     export/ExcelExport.cpp  
 M  +1 -1      sidewinder/records.xml  


--- trunk/koffice/filters/kspread/excel/export/ExcelExport.cpp #1169653:1169654
@@ -31,6 +31,7 @@
 #include <KoPostscriptPaintDevice.h>
 
 #include <part/Doc.h>
+#include <CellStorage.h>
 #include <Map.h>
 #include <Sheet.h>
 #include <RowColumnFormat.h>
@@ -221,11 +222,14 @@
         o.writeRecord(b);
     }
 
-    {
+    QRect area = sheet->usedArea();
+
         IndexRecord ir(0);
-        // TODO
+    ir.setRowMin(area.top()-1);
+    ir.setRowMaxPlus1(area.bottom());
+    int dbCellCount = ((area.height()+1)+31) / 32;
+    ir.setRowBlockCount(dbCellCount);
         o.writeRecord(ir);
-    }
 
     o.writeRecord(CalcModeRecord(0));
     o.writeRecord(CalcCountRecord(0));
@@ -247,8 +251,7 @@
     o.writeRecord(VCenterRecord(0));
     o.writeRecord(SetupRecord(0));
 
-    QRect area = sheet->usedArea();
-
+    ir.setDefColWidthPosition(o.pos());
     o.writeRecord(DefaultColWidthRecord(0)); // TODO: real defaultColWidthRecord
     {
         ColInfoRecord cir(0);
@@ -279,7 +282,65 @@
     }
 
     // Row, CELL, DbCell
+    for (int i = 0; i < dbCellCount; i++) {
+        int firstRow = i*32 + area.top();
+        int lastRowP1 = qMin(firstRow+32, area.bottom());
+        qint64 firstRowPos = o.pos();
 
+        qint64 lastStart = -1;
+        for (int row = firstRow; row < lastRowP1; row++) {
+            RowRecord rr(0);
+
+            KSpread::Cell first = sheet->cellStorage()->firstInRow(row);
+            if (first.isNull()) first = KSpread::Cell(sheet, 1, row);
+            KSpread::Cell last = sheet->cellStorage()->lastInRow(row);
+            if (last.isNull()) last = first;
+            const KSpread::RowFormat* format = sheet->rowFormat(row);
+
+            rr.setRow(row-1);
+            rr.setFirstColumn(first.column()-1);
+            rr.setLastColumnPlus1(last.column());
+            rr.setHeight(format->height() * 20);
+
+            o.writeRecord(rr);
+            if (row == firstRow) lastStart = o.pos();
+        }
+
+        DBCellRecord db(0);
+        db.setRowCount(lastRowP1 - firstRow);
+        for (int row = firstRow; row < lastRowP1; row++) {
+            db.setCellOffset(row - firstRow, o.pos() - lastStart);
+            lastStart = o.pos();
+
+            KSpread::Cell first = sheet->cellStorage()->firstInRow(row);
+            if (first.isNull()) first = KSpread::Cell(sheet, 1, row);
+            KSpread::Cell last = sheet->cellStorage()->lastInRow(row);
+            if (last.isNull()) last = first;
+
+            for (int col = first.column(); col <= last.column(); col++) {
+                KSpread::Cell cell(sheet, col, row);
+
+                if (cell.value().isNumber()) {
+                    NumberRecord nr(0);
+                    nr.setRow(row-1);
+                    nr.setColumn(col-1);
+                    nr.setNumber(cell.value().asFloat());
+                    o.writeRecord(nr);
+                } else /*if (cell.isEmpty())*/ {
+                    BlankRecord br(0);
+                    br.setRow(row-1);
+                    br.setColumn(col-1);
+                    o.writeRecord(br);
+                }
+            }
+        }
+
+        db.setFirstRowOffset(o.pos() - firstRowPos);
+        o.writeRecord(db);
+    }
+
+    o.rewriteRecord(ir);
+
     o.writeRecord(Window2Record(0));
 
     // MergeCells
--- trunk/koffice/filters/kspread/excel/sidewinder/records.xml #1169653:1169654
@@ -1357,7 +1357,7 @@
 
 <record name="DBCell" id="0x00d7">
   <field name="firstRowOffset"  type="unsigned" size="32" />
-  <array length="(recordSize() - 4) / 2" lengthField="cellCount">
+  <array length="(recordSize() - 4) / 2" lengthField="rowCount">
     <field name="cellOffset"    type="unsigned" size="16" />
   </array>
 </record>
[prev in list] [next in list] [prev in thread] [next in thread] 

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