[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: KSpread: OpenDocument Saving Speedup (Part 3: Row Processing)
From: Stefan Nikolaus <stefan.nikolaus () kdemail ! net>
Date: 2006-04-29 14:18:21
Message-ID: 200604291618.24333.stefan.nikolaus () kdemail ! net
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Hi again,
the last chunk of the saving speedup.
This time the row processing - this implicits the processing of cells.
Basic idea here is to substitute the check for empty cells - which was done by
iterating all cell indices from 1 to max. column index and checking wether
there's a non-default cell - by using the Cluster::getFirstCellRow method.
This gives us a pointer to the first cell in the row or 0, if there's none.
I forgot something to say, which apllies to all three chunks: There's an
special handling of the default cell/column/row when determining the
repetition. This prevent the creation of a KoGenStyle and should therefore be
faster.
In this part was the error. For the repetition I checked only for differing
row styles. *cough* And not wether the rows were empty. *cough*
Bye,
Stefan
["saving-speedup-3.diff" (text/x-diff)]
Index: kspread_sheet.cc
===================================================================
--- kspread_sheet.cc (Revision 535363)
+++ kspread_sheet.cc (Arbeitskopie)
@@ -7354,63 +7354,94 @@
i += repeated;
}
+ // saving the rows and the cells
+ // we have to loop through all rows of the used area
for ( i = 1; i <= maxRows; ++i )
{
+ kdDebug() << "Sheet::saveOasisColRowCell: row: " << i << endl;
const RowFormat* row = rowFormat( i );
+
KoGenStyle currentRowStyle( Doc::STYLE_ROW, "table-row" );
currentRowStyle.addPropertyPt( "style:row-height", row->dblHeight());/*FIXME \
pt and not mm */
currentRowStyle.addProperty( "fo:break-before", "auto" );/*FIXME auto or not \
?*/
xmlWriter.startElement( "table:table-row" );
+
+ // TODO skip attribute saving for default row
+
xmlWriter.addAttribute( "table:style-name", mainStyles.lookup( \
currentRowStyle, "ro" ) ); int repeated = 1;
- if ( !rowAsCell( i, maxCols ) )
+ // empty row?
+ if ( !getFirstCellRow( i ) )
{
- bool hide = row->isHide();
+ kdDebug() << "Sheet::saveOasisColRowCell: first row loop:"
+ << " i: " << i
+ << " row: " << row->row() << endl;
+ bool isHidden = row->isHide();
+ bool isDefault = row->isDefault();
int j = i + 1;
- while ( j <= maxRows )
+
+ // search for
+ // next non-empty row
+ // or
+ // next row with different Format
+ while ( j <= maxRows && !getFirstCellRow( j ) )
{
- const RowFormat *nextRow = rowFormat( j );
- KoGenStyle nextRowStyle( Doc::STYLE_ROW, "table-row" );
- nextRowStyle.addPropertyPt( "style:row-height", nextRow->dblHeight() \
);/*FIXME pt and not mm */
- nextRowStyle.addProperty( "fo:break-before", "auto" );/*FIXME auto \
or not ?*/ + RowFormat* nextRow = rowFormat( j );
+ kdDebug() << "Sheet::saveOasisColRowCell: second row loop:"
+ << " j: " << j
+ << " row: " << nextRow->row() << endl;
- //FIXME all the time repeate == 2
- if ( ( nextRowStyle==currentRowStyle ) && ( hide == \
nextRow->isHide() ) &&!rowAsCell( j, maxCols ) )
- ++repeated;
- else
- break;
+ // if the reference row has the default row format
+ if ( isDefault )
+ {
+ // if the next is not default, stop here
+ if ( !nextRow->isDefault() )
+ break;
+ // otherwise, jump to the next
++j;
+ continue;
+ }
+
+ // create the Oasis representation of the format for the comparison
+ KoGenStyle nextRowStyle( Doc::STYLE_ROW, "table-row" );
+ nextRowStyle.addPropertyPt( "style:row-height", nextRow->dblHeight() \
);/*FIXME pt and not mm */ + nextRowStyle.addProperty( \
"fo:break-before", "auto" );/*FIXME auto or not ?*/ +
+ // TODO default cell style (name)
+
+ // if the formats differ, stop here
+ if ( isHidden != nextRow->isHide() ||
+ !(nextRowStyle == currentRowStyle) )
+ {
+ break;
+ }
+ // otherwise, process the next
+ ++j;
}
- i += repeated-1; /*it's double incremented into loop for*/
- if ( row->isHide() )
- xmlWriter.addAttribute( "table:visibility", "collapse" );
- if ( repeated > 1 )
+ repeated = j - i;
+
+ if ( repeated > 1 )
xmlWriter.addAttribute( "table:number-rows-repeated", repeated );
+
+ kdDebug() << "Sheet::saveOasisColRowCell: empty row " << i << " "
+ << "repeated " << repeated << " time(s)" << endl;
+
+ // copy the index for the next row to process
+ i = j - 1; /*it's already incremented in the for loop*/
}
- else
+ else // row is not empty
{
- if ( row->isHide() )
- xmlWriter.addAttribute( "table:visibility", "collapse" );
saveOasisCells( xmlWriter, mainStyles, i, maxCols, valStyle );
}
+
+ if ( row->isHide() )
+ xmlWriter.addAttribute( "table:visibility", "collapse" );
+
xmlWriter.endElement();
}
}
-bool Sheet::rowAsCell( int row, int maxCols )
-{
- int i = 1;
- while ( i <= maxCols )
- {
- Cell* cell = cellAt( i, row );
- if ( !cell->isDefault() )
- return true;
- i++;
- }
- return false;
-}
-
void Sheet::saveOasisCells( KoXmlWriter& xmlWriter, KoGenStyles &mainStyles, int \
row, int maxCols, GenValidationStyles &valStyle ) {
int i = 1;
Index: kspread_sheet.h
===================================================================
--- kspread_sheet.h (Revision 535363)
+++ kspread_sheet.h (Arbeitskopie)
@@ -1298,8 +1298,6 @@
void maxRowCols( int & maxCols, int & maxRows );
- bool rowAsCell( int row, int maxCols );
-
QString getPart( const QDomNode & part );
void replaceMacro( QString & text, const QString & old, const QString & newS );
[Attachment #8 (application/pgp-signature)]
_______________________________________________
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