From 5fd5231014baee4170c7c6314527aeb792eb5a30 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 23 Sep 2014 14:15:28 +0000 Subject: [PATCH] fpspreadsheet: Fix insert/delete column/row issues for shared formulas. Complete shared formula test cases on insert/delete columns and rows. Duplicate these test cases for OOXML. All passed. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3595 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/fpspreadsheet.pas | 225 +--- .../fpspreadsheet/tests/insertdeletetests.pas | 1029 +++++++++++++++-- .../fpspreadsheet/tests/spreadtestgui.lpi | 5 +- 3 files changed, 997 insertions(+), 262 deletions(-) diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas index 92bfa8fc9..fb8e6be18 100755 --- a/components/fpspreadsheet/fpspreadsheet.pas +++ b/components/fpspreadsheet/fpspreadsheet.pas @@ -501,8 +501,6 @@ type procedure ChangedCell(ARow, ACol: Cardinal); procedure ChangedFont(ARow, ACol: Cardinal); - function InsertColToFormula(ACol: Cardinal; ACell: PCell): String; - procedure RemoveCell(ARow, ACol: Cardinal); public @@ -687,6 +685,7 @@ type function FindSharedFormulaBase(ACell: PCell): PCell; function FindSharedFormulaRange(ACell: PCell; out ARow1, ACol1, ARow2, ACol2: Cardinal): Boolean; procedure FixSharedFormulas; + procedure SplitSharedFormula(ACell: PCell); function UseSharedFormula(ARow, ACol: Cardinal; ASharedFormulaBase: PCell): PCell; { Data manipulation methods - For Cells } @@ -3073,6 +3072,45 @@ begin FLastRowIndex := GetLastRowIndex(true); end; +{@@ ---------------------------------------------------------------------------- + Splits a shared formula range to which the specified cell belongs into + individual cells. Each cell gets same the formula as it had in the block. + This is required because insertion and deletion of columns/rows make shared + formulas very complicated. +-------------------------------------------------------------------------------} +procedure TsWorksheet.SplitSharedFormula(ACell: PCell); +var + r, c: Cardinal; + baseRow, baseCol: Cardinal; + lastRow, lastCol: Cardinal; + cell: PCell; + rpnFormula: TsRPNFormula; +begin + if (ACell = nil) or (ACell^.SharedFormulaBase = nil) then + exit; + lastRow := GetLastOccupiedRowIndex; + lastCol := GetLastOccupiedColIndex; + baseRow := ACell^.SharedFormulaBase^.Row; + baseCol := ACell^.SharedFormulaBase^.Col; + for r := baseRow to lastRow do + for c := baseCol to lastCol do + begin + cell := FindCell(r, c); + if (cell = nil) or (cell^.SharedFormulaBase = nil) then + continue; + if (cell^.SharedFormulaBase^.Row = baseRow) and + (cell^.SharedFormulaBase^.Col = baseCol) then + begin + // This method converts the shared formula to an rpn formula as seen from cell... + rpnFormula := BuildRPNFormula(cell); + // ... and this reconstructs the string formula, again as seen from cell. + cell^.FormulaValue := ConvertRPNFormulaToStringFormula(rpnFormula); + // Remove the SharedFormulaBase information --> cell is isolated. + cell^.SharedFormulaBase := nil; + end; + end; +end; + {@@ ---------------------------------------------------------------------------- Defines a cell range sharing the "same" formula. Note that relative cell references are updated for each cell in the range. @@ -5117,6 +5155,15 @@ var rLast, cLast: Cardinal; cell, nextcell, gapcell, oldbase, newbase: PCell; begin + // Handling of shared formula references is too complicated for me... + // Splits them into isolated cell formulas + cellNode := FCells.FindLowest; + while Assigned(cellnode) do begin + cell := PCell(cellNode.Data); + SplitSharedFormula(cell); + cellNode := FCells.FindSuccessor(cellnode); + end; + // Update column index of cell records cellnode := FCells.FindLowest; while Assigned(cellnode) do begin @@ -5133,10 +5180,9 @@ begin // Update first and last column index UpdateCaches; - // Fix merged cells and shared formulas: If the inserted column runs through a - // block of merged cells or a shared formula the block is cut into two pieces. - // Here we fill the gap with dummy cells and set their MergeBase / SharedFormulaBase - // correctly. + // Fix merged cells: If the inserted column runs through a block of + // merged cells the block is cut into two pieces. Here we fill the gap + // with dummy cells and set their MergeBase correctly. if ACol > 0 then begin rLast := GetLastOccupiedRowIndex; @@ -5159,115 +5205,6 @@ begin gapcell := GetCell(r, ACol); gapcell^.Mergebase := cell^.MergeBase; end; - end - else - // A shared formula block is found immediately to the left of the - // inserted column. If it extends to the right we have to create a new - // shared formula base in the upper left cell. Note: Excel does not - // extend the shared formula to the inserted column. - if cell^.SharedFormulaBase <> nil then begin - oldbase := cell^.SharedFormulaBase; - // Does it extend to the right of the new column? - nextcell := FindCell(r, ACol+1); - if Assigned(nextcell) and (nextcell^.SharedFormulaBase = oldbase) then - begin - // Yes. - // It next cell is in the top row of the block we make it a shared formula base - if r = oldbase^.Row then - begin - newbase := nextcell; - nextcell^.SharedFormulaBase := nextcell; - nextcell^.FormulaValue := InsertColToFormula(ACol, oldbase); // ?? - // Note: the references are not correct here - we fix that later! - end; - // Use the new shared formulabase in all cells of the old block at the right - for cc := ACol+1 to cLast do - begin - cell := FindCell(r, cc); - if (cell = nil) or (cell^.SharedFormulaBase <> oldbase) then - break; - cell^.SharedFormulaBase := newbase; - end; - end; - end; - - (* - else - // A shared formula block is found immediately before the inserted column - if cell^.SharedFormulaBase <> nil then begin - // Does it extend beyond the newly inserted column? - nextcell := FindCell(r, ACol+1); - if Assigned(nextcell) and (nextcell^.SharedFormulaBase = cell^.SharedFormulaBase) then - begin - // Yes - we add a cell into the gap - gapcell := GetCell(r, ACol); - // If this is the first row of the shared formula block we must define - // a new shared formula because cell references may differ by 1 on both - // sides of the inserted column! - if r = cell^.SharedFormulaBase^.Row then - begin - gapcell^.SharedFormulaBase := gapcell; - gapcell^.FormulaValue := cell^.SharedFormulaBase.FormulaValue; - gapcell^.FormulaValue := InsertColToFormula(ACol, gapcell); - newbase := gapcell; - end - else - // Link to the new base - gapcell^.SharedFormulaBase := newbase; - // Link all cells to the right of the inserted column to the new base - for ic := ACol+1 to cLast do - begin - cell := FindCell(r, ic); - if cell^.SharedFormulaBase = nextcell^.SharedFormulaBase then - cell^.SharedFormulaBase := newbase - else - break; - end; - end; - end; - *) - end; - - // Fix shared formulas: - // A shared formula block may break into two pieces if cell references Cell references to the left and to the right of - // Seek along the column immediately to the left of the inserted column - c := ACol - 1; - for r := 0 to rLast do - begin - cell := FindCell(r, c); - if not Assigned(cell) then - Continue; - // A shared formula block is found immediately to the left of the inserted column. - // If it extends beyond the new column we have to redefine the shared - // formula in the right split-off part because column offsets to the left - // part are greater by 1 now. - // Excel does not extend the shared formula into the new column, though. - if cell^.SharedFormulaBase <> nil then - begin - oldbase := cell^.SharedFormulaBase; - // Does it extend beyond the newly inserted column? - nextcell := FindCell(r, ACol+1); - if Assigned(nextcell) and (nextcell^.SharedFormulaBase = cell^.SharedFormulaBase) then - begin - // Yes. If we are at the first row of the old shared formula block we - // have to define a new base in nextcell. But the formula must be - // corrected for the inserted column! - if r = cell^.SharedFormulaBase^.Row then begin - nextcell^.SharedFormulaBase := nextcell; - nextcell^.FormulaValue := cell^.SharedFormulaBase^.FormulaValue; - nextcell^.FormulaValue := InsertColToFormula(ACol, nextcell); - newbase := nextcell; - end; - // Now link all cells to the right of the new column (which still - // use the old base) to the new base - for cc := ACol+1 to cLast do - begin - cell := FindCell(r, cc); - if (cell = nil) or (cell^.SharedFormulaBase <> oldbase) then - break; - cell^.SharedFormulaBase := newbase; - end; - end; end; end; end; @@ -5293,8 +5230,6 @@ begin // Update formulas if HasFormula(cell) and (cell^.FormulaValue <> '' ) then - cell^.FormulaValue := InsertColToFormula(col, cell); - { begin // (1) create an rpn formula formula := BuildRPNFormula(cell); @@ -5314,35 +5249,6 @@ begin // (3) convert rpn formula back to string formula cell^.FormulaValue := ConvertRPNFormulaToStringFormula(formula); end; - } -end; - -{@@ ---------------------------------------------------------------------------- - The formula of the specified cell must be modified because a column is - inserted: Cell references pointing to the left of the inserted column remain - unchanged, but cell references pointing to the inserted column or its right - must have a higher column index by 1. - Returns the modified string formula. --------------------------------------------------------------------------------} -function TsWorksheet.InsertColToFormula(ACol: Cardinal; ACell: PCell): String; -var - rpnFormula: TsRPNFormula; - i: Integer; -begin - rpnFormula := BuildRPNFormula(ACell); - for i:=0 to Length(rpnFormula) - 1 do - begin - case rpnFormula[i].ElementKind of - fekCell, fekCellRef: - if rpnFormula[i].Col >= ACol then inc(rpnFormula[i].Col); - fekCellRange: - begin - if rpnFormula[i].Col >= ACol then inc(rpnFormula[i].Col); - if rpnFormula[i].Col2 >= ACol then inc(rpnFormula[i].Col2); - end; - end; - end; - Result := ConvertRPNFormulaToStringFormula(rpnFormula); end; {@@ ---------------------------------------------------------------------------- @@ -5360,6 +5266,15 @@ var r, c, cc, r1, c1, r2, c2: Cardinal; cell, nextcell, gapcell: PCell; begin + // Handling of shared formula references is too complicated for me... + // Splits them into isolated cell formulas + cellNode := FCells.FindLowest; + while Assigned(cellnode) do begin + cell := PCell(cellNode.Data); + SplitSharedFormula(cell); + cellNode := FCells.FindSuccessor(cellnode); + end; + // Update row index of cell records cellnode := FCells.FindLowest; while Assigned(cellnode) do begin @@ -5376,10 +5291,9 @@ begin // Update first and last row index UpdateCaches; - // Fix merged cells and shared formulas: If the inserted row runs through a - // block of merged cells or a shared formula the block is cut into two pieces. - // Here we fill the gap with dummy cells and set their MergeBase / SharedFormulaBase - // correctly. + // Fix merged cells: If the inserted row runs through a block of merged + // cells the block is cut into two pieces. Here we fill the gap with + // dummy cells and set their MergeBase correctly. if ARow > 0 then begin r := ARow - 1; @@ -5400,17 +5314,6 @@ begin gapcell := GetCell(ARow, c); gapcell^.Mergebase := cell^.MergeBase; end; - end else - // A shared formula block is found - if cell^.SharedFormulaBase <> nil then begin - // Does it extend beyond the newly inserted row? - nextcell := FindCell(ARow+1, c); - if Assigned(nextcell) and (nextcell^.SharedFormulaBase = cell^.SharedFormulaBase) then - begin - // Yes - we add a cell into the gap and share the formula of the base - gapcell := GetCell(ARow, c); - gapcell^.SharedFormulaBase := cell^.SharedFormulaBase; - end; end; end; end; diff --git a/components/fpspreadsheet/tests/insertdeletetests.pas b/components/fpspreadsheet/tests/insertdeletetests.pas index 2e2acc882..37d553a51 100644 --- a/components/fpspreadsheet/tests/insertdeletetests.pas +++ b/components/fpspreadsheet/tests/insertdeletetests.pas @@ -24,15 +24,19 @@ type DeleteRow: Integer; Formula: String; SollFormula: String; - SharedFormulaRowCount: Integer; + SharedFormulaRowCount: Integer; // Size of shared formula block before insert/delete SharedFormulaColCount: Integer; - MergedColCount: Integer; + SharedFormulaBaseCol_After: Integer; // Position of shared formula base after insert/delete + SharedFormulaBaseRow_After: Integer; + SharedFormulaRowCount_After: Integer; // Size of shared formula block after insert/delete + SharedFormulaColCount_After: Integer; + MergedColCount: Integer; // size of merged block before insert/delete MergedRowCount: Integer; SollLayout: String; end; var - InsDelTestData: array[0..25] of TInsDelTestDataItem; + InsDelTestData: array[0..39] of TInsDelTestDataItem; procedure InitTestData; @@ -44,47 +48,127 @@ type // Set up expected values: procedure SetUp; override; procedure TearDown; override; - procedure TestWriteRead_InsDelColRow(ATestIndex: Integer); + procedure TestWriteRead_InsDelColRow(ATestIndex: Integer; + AFormat: TsSpreadsheetFormat); published + + // *** Excel 8 tests *** + // Writes out simple cell layout and inserts columns - procedure TestWriteRead_InsDelColRow_0; // before first - procedure TestWriteRead_InsDelColRow_1; // middle - procedure TestWriteRead_InsDelColRow_2; // before last + procedure TestWriteRead_InsDelColRow_0_BIFF8; // before first + procedure TestWriteRead_InsDelColRow_1_BIFF8; // middle + procedure TestWriteRead_InsDelColRow_2_BIFF8; // before last // Writes out simple cell layout and deletes columns - procedure TestWriteRead_InsDelColRow_3; // first - procedure TestWriteRead_InsDelColRow_4; // middle - procedure TestWriteRead_InsDelColRow_5; // last + procedure TestWriteRead_InsDelColRow_3_BIFF8; // first + procedure TestWriteRead_InsDelColRow_4_BIFF8; // middle + procedure TestWriteRead_InsDelColRow_5_BIFF8; // last // Writes out simple cell layout and inserts rows - procedure TestWriteRead_InsDelColRow_6; // before first - procedure TestWriteRead_InsDelColRow_7; // middle - procedure TestWriteRead_InsDelColRow_8; // before last + procedure TestWriteRead_InsDelColRow_6_BIFF8; // before first + procedure TestWriteRead_InsDelColRow_7_BIFF8; // middle + procedure TestWriteRead_InsDelColRow_8_BIFF8; // before last // Writes out simple cell layout and deletes rows - procedure TestWriteRead_InsDelColRow_9; // first - procedure TestWriteRead_InsDelColRow_10; // middle - procedure TestWriteRead_InsDelColRow_11; // last + procedure TestWriteRead_InsDelColRow_9_BIFF8; // first + procedure TestWriteRead_InsDelColRow_10_BIFF8; // middle + procedure TestWriteRead_InsDelColRow_11_BIFF8; // last // Writes out cell layout with formula and inserts columns - procedure TestWriteRead_InsDelColRow_12; // before formula cell - procedure TestWriteRead_InsDelColRow_13; // after formula cell + procedure TestWriteRead_InsDelColRow_12_BIFF8; // before formula cell + procedure TestWriteRead_InsDelColRow_13_BIFF8; // after formula cell // Writes out cell layout with formula and inserts rows - procedure TestWriteRead_InsDelColRow_14; // before formula cell - procedure TestWriteRead_InsDelColRow_15; // after formula cell + procedure TestWriteRead_InsDelColRow_14_BIFF8; // before formula cell + procedure TestWriteRead_InsDelColRow_15_BIFF8; // after formula cell // Writes out cell layout with formula and deletes columns - procedure TestWriteRead_InsDelColRow_16; // before formula cell - procedure TestWriteRead_InsDelColRow_17; // after formula cell - procedure TestWriteRead_InsDelColRow_18; // cell in formula + procedure TestWriteRead_InsDelColRow_16_BIFF8; // before formula cell + procedure TestWriteRead_InsDelColRow_17_BIFF8; // after formula cell + procedure TestWriteRead_InsDelColRow_18_BIFF8; // cell in formula // Writes out cell layout with formula and deletes rows - procedure TestWriteRead_InsDelColRow_19; // before formula cell - procedure TestWriteRead_InsDelColRow_20; // after formula cell - procedure TestWriteRead_InsDelColRow_21; // cell in formula + procedure TestWriteRead_InsDelColRow_19_BIFF8; // before formula cell + procedure TestWriteRead_InsDelColRow_20_BIFF8; // after formula cell + procedure TestWriteRead_InsDelColRow_21_BIFF8; // cell in formula // Writes out cell layout with shared formula - procedure TestWriteRead_InsDelColRow_22; // no insert/delete; just test shared formula + procedure TestWriteRead_InsDelColRow_22_BIFF8; // no insert/delete; just test shared formula // ... and inserts columns - procedure TestWriteRead_InsDelColRow_23; // column before shared formula cells - procedure TestWriteRead_InsDelColRow_24; // column after shared formula cells - procedure TestWriteRead_InsDelColRow_25; // column through cells addressed by shared formula + procedure TestWriteRead_InsDelColRow_23_BIFF8; // column before shared formula cells + procedure TestWriteRead_InsDelColRow_24_BIFF8; // column after shared formula cells + procedure TestWriteRead_InsDelColRow_25_BIFF8; // column through cells addressed by shared formula + procedure TestWriteRead_InsDelColRow_26_BIFF8; // column through shared formula block + procedure TestWriteRead_InsDelColRow_27_BIFF8; // column behind shared formula block + // ... and inserts rows + procedure TestWriteRead_InsDelColRow_28_BIFF8; // row before shared formula + procedure TestWriteRead_InsDelColRow_29_BIFF8; // row after shared formula cells + procedure TestWriteRead_InsDelColRow_30_BIFF8; // row through shared formula block + procedure TestWriteRead_InsDelColRow_31_BIFF8; // row below shared formula block + // ... and deletes columns + procedure TestWriteRead_InsDelColRow_32_BIFF8; // column before shared formula cells + procedure TestWriteRead_InsDelColRow_33_BIFF8; // column after shared formula cells + procedure TestWriteRead_InsDelColRow_34_BIFF8; // column in shared formula block, no formula cell + procedure TestWriteRead_InsDelColRow_35_BIFF8; // column used in shared formula + // ... and deletes rows + procedure TestWriteRead_InsDelColRow_36_BIFF8; // row above shared formula cells + procedure TestWriteRead_InsDelColRow_37_BIFF8; // row below shared formula cells + procedure TestWriteRead_InsDelColRow_38_BIFF8; // row through shared formula block + procedure TestWriteRead_InsDelColRow_39_BIFF8; // row with cell used in shared formula + + // *** OOXML tests *** + + // Writes out simple cell layout and inserts columns + procedure TestWriteRead_InsDelColRow_0_OOXML; // before first + procedure TestWriteRead_InsDelColRow_1_OOXML; // middle + procedure TestWriteRead_InsDelColRow_2_OOXML; // before last + // Writes out simple cell layout and deletes columns + procedure TestWriteRead_InsDelColRow_3_OOXML; // first + procedure TestWriteRead_InsDelColRow_4_OOXML; // middle + procedure TestWriteRead_InsDelColRow_5_OOXML; // last + // Writes out simple cell layout and inserts rows + procedure TestWriteRead_InsDelColRow_6_OOXML; // before first + procedure TestWriteRead_InsDelColRow_7_OOXML; // middle + procedure TestWriteRead_InsDelColRow_8_OOXML; // before last + // Writes out simple cell layout and deletes rows + procedure TestWriteRead_InsDelColRow_9_OOXML; // first + procedure TestWriteRead_InsDelColRow_10_OOXML; // middle + procedure TestWriteRead_InsDelColRow_11_OOXML; // last + + // Writes out cell layout with formula and inserts columns + procedure TestWriteRead_InsDelColRow_12_OOXML; // before formula cell + procedure TestWriteRead_InsDelColRow_13_OOXML; // after formula cell + // Writes out cell layout with formula and inserts rows + procedure TestWriteRead_InsDelColRow_14_OOXML; // before formula cell + procedure TestWriteRead_InsDelColRow_15_OOXML; // after formula cell + // Writes out cell layout with formula and deletes columns + procedure TestWriteRead_InsDelColRow_16_OOXML; // before formula cell + procedure TestWriteRead_InsDelColRow_17_OOXML; // after formula cell + procedure TestWriteRead_InsDelColRow_18_OOXML; // cell in formula + // Writes out cell layout with formula and deletes rows + procedure TestWriteRead_InsDelColRow_19_OOXML; // before formula cell + procedure TestWriteRead_InsDelColRow_20_OOXML; // after formula cell + procedure TestWriteRead_InsDelColRow_21_OOXML; // cell in formula + + // Writes out cell layout with shared formula + procedure TestWriteRead_InsDelColRow_22_OOXML; // no insert/delete; just test shared formula + // ... and inserts columns + procedure TestWriteRead_InsDelColRow_23_OOXML; // column before shared formula cells + procedure TestWriteRead_InsDelColRow_24_OOXML; // column after shared formula cells + procedure TestWriteRead_InsDelColRow_25_OOXML; // column through cells addressed by shared formula + procedure TestWriteRead_InsDelColRow_26_OOXML; // column through shared formula block + procedure TestWriteRead_InsDelColRow_27_OOXML; // column behind shared formula block + // ... and inserts rows + procedure TestWriteRead_InsDelColRow_28_OOXML; // row before shared formula + procedure TestWriteRead_InsDelColRow_29_OOXML; // row after shared formula cells + procedure TestWriteRead_InsDelColRow_30_OOXML; // row through shared formula block + procedure TestWriteRead_InsDelColRow_31_OOXML; // row below shared formula block + // ... and deletes columns + procedure TestWriteRead_InsDelColRow_32_OOXML; // column before shared formula cells + procedure TestWriteRead_InsDelColRow_33_OOXML; // column after shared formula cells + procedure TestWriteRead_InsDelColRow_34_OOXML; // column in shared formula block, no formula cell + procedure TestWriteRead_InsDelColRow_35_OOXML; // column used in shared formula + // ... and deletes rows + procedure TestWriteRead_InsDelColRow_36_OOXML; // row above shared formula cells + procedure TestWriteRead_InsDelColRow_37_OOXML; // row below shared formula cells + procedure TestWriteRead_InsDelColRow_38_OOXML; // row through shared formula block + procedure TestWriteRead_InsDelColRow_39_OOXML; // row with cell used in shared formula + end; implementation @@ -111,6 +195,10 @@ begin SollFormula := ''; SharedFormulaColCount := 0; SharedFormulaRowCount := 0; + SharedFormulaBaseCol_After := -1; + SharedFormulaBaseRow_After := -1; + SharedFormulaColCount_After := 0; + SharedFormulaRowCount_After := 0; MergedColCount := 0; MergedRowCount := 0; end; @@ -510,6 +598,10 @@ begin Formula := 'A3-$B$2'; SharedFormulaColCount := 2; SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 3; + SharedFormulaBaseRow_After := 2; + SharedFormulaColCount_After := 2; + SharedFormulaRowCount_After := 3; SollFormula := 'A3-$B$2,B3-$B$2;'+ 'A4-$B$2,B4-$B$2;'+ 'A5-$B$2,B5-$B$2'; @@ -534,6 +626,10 @@ begin Formula := 'A3-$B$2'; SharedFormulaColCount := 2; SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 4; // Position of shared formula after insert op + SharedFormulaBaseRow_After := 2; + SharedFormulaColCount_After := 2; // Size of shared formula block after insert op + SharedFormulaRowCount_After := 3; SollFormula := 'B3-$C$2,C3-$C$2;'+ // all column indexes increase by 1 due to added col in front 'B4-$C$2,C4-$C$2;'+ 'B5-$C$2,C5-$C$2'; @@ -558,6 +654,10 @@ begin Formula := 'A3-$B$2'; SharedFormulaColCount := 2; SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 3; + SharedFormulaBaseRow_After := 2; + SharedFormulaColCount_After := 2; + SharedFormulaRowCount_After := 3; SollFormula := 'A3-$B$2,B3-$B$2;'+ // formulas unchanged by insert 'A4-$B$2,B4-$B$2;'+ 'A5-$B$2,B5-$B$2'; @@ -582,7 +682,11 @@ begin Formula := 'A3-$B$2'; SharedFormulaColCount := 2; SharedFormulaRowCount := 3; - SollFormula := 'A3-$C$2,C3-$C$2;'+ // some column indexes increase by 1, some unchanged + SharedFormulaBaseCol_After := 4; + SharedFormulaBaseRow_After := 2; + SharedFormulaColCount_After := 2; + SharedFormulaRowCount_After := 3; + SollFormula := 'A3-$C$2,C3-$C$2;'+ 'A4-$C$2,C4-$C$2;'+ 'A5-$C$2,C5-$C$2'; SollLayout := '1 2345678|'+ @@ -592,6 +696,400 @@ begin '5 6723012|'+ '6 7890123'; end; + + // Insert column to run through formula block (col = 4) + with InsDelTestData[26] do begin + Layout := '12345678|'+ + '23456789|'+ + '345S 890|'+ // "S" = shared formula (2 cols x 3 rows) + '456 901|'+ + '567 012|'+ + '67890123'; + InsertCol := 4; + Formula := 'A3-$B$2'; + SharedFormulaColCount := 2; + SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 3; + SharedFormulaBaseRow_After := 2; + SharedFormulaColCount_After := 3; + SharedFormulaRowCount_After := 3; + SollFormula := 'A3-$B$2,'',B3-$B$2;'+ + 'A4-$B$2,'',B4-$B$2;'+ + 'A5-$B$2,'',B5-$B$2'; + SollLayout := '1234 5678|'+ + '2345 6789|'+ + '3450 1890|'+ + '4561 2901|'+ + '5672 3012|'+ + '6789 0123'; + end; + + // Insert column behind shared formula block (col = 7) + with InsDelTestData[27] do begin + Layout := '12345678|'+ + '23456789|'+ + '345S 890|'+ // "S" = shared formula (2 cols x 3 rows) + '456 901|'+ + '567 012|'+ + '67890123'; + InsertCol := 7; + Formula := 'A3-$B$2'; + SharedFormulaColCount := 2; + SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 3; + SharedFormulaBaseRow_After := 2; + SharedFormulaColCount_After := 2; + SharedFormulaRowCount_After := 3; + SollFormula := 'A3-$B$2,B3-$B$2;'+ + 'A4-$B$2,B4-$B$2;'+ + 'A5-$B$2,B5-$B$2'; + SollLayout := '1234567 8|'+ + '2345678 9|'+ + '3450189 0|'+ + '4561290 1|'+ + '5672301 2|'+ + '6789012 3'; + end; + + // Insert row before any cell referred to by the shared formula (row = 0) + with InsDelTestData[28] do begin + Layout := '12345678|'+ + '23456789|'+ + '345S 890|'+ // "S" = shared formula (2 cols x 3 rows) + '456 901|'+ + '567 012|'+ + '67890123'; + InsertRow := 0; + Formula := 'A3-$B$2'; + SharedFormulaColCount := 2; + SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 3; // Position of shared formula after insert op + SharedFormulaBaseRow_After := 3; + SharedFormulaColCount_After := 2; // Size of shared formula block after insert op + SharedFormulaRowCount_After := 3; + SollFormula := 'A4-$B$3,B4-$B$3;'+ // all row indexes increase by 1 due to added row in front + 'A5-$B$3,B5-$B$3;'+ + 'A6-$B$3,B6-$B$3'; + // comma-separated --> cells along row; semicolon separates rows + SollLayout := ' |'+ + '12345678|'+ + '23456789|'+ + '34501890|'+ + '45612901|'+ + '56723012|'+ + '67890123'; + end; + + // Insert row through cells referred to by the shared formula (row = 2) + with InsDelTestData[29] do begin + Layout := '12345678|'+ + '23456789|'+ + '345S 890|'+ // "S" = shared formula (2 cols x 3 rows) + '456 901|'+ + '567 012|'+ + '67890123'; + InsertRow := 2; + Formula := 'A3-$B$2'; + SharedFormulaColCount := 2; + SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 3; // Position of shared formula after insert op + SharedFormulaBaseRow_After := 3; + SharedFormulaColCount_After := 2; // Size of shared formula block after insert op + SharedFormulaRowCount_After := 3; + SollFormula := 'A4-$B$2,B4-$B$2;'+ // row 3 --> 4 + 'A5-$B$2,B5-$B$2;'+ + 'A6-$B$2,B6-$B$2'; + // comma-separated --> cells along row; semicolon separates rows + SollLayout := '12345678|'+ + '23456789|'+ + ' |'+ + '34501890|'+ + '45612901|'+ + '56723012|'+ + '67890123'; + end; + + // Insert row through shared formula block (row = 3) + with InsDelTestData[30] do begin + Layout := '12345678|'+ + '23456789|'+ + '345S 890|'+ // "S" = shared formula (2 cols x 3 rows) + '456 901|'+ + '567 012|'+ + '67890123'; + InsertRow := 3; + Formula := 'A3-$B$2'; + SharedFormulaColCount := 2; + SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 3; // Position of shared formula after insert op + SharedFormulaBaseRow_After := 2; + SharedFormulaColCount_After := 2; // Size of shared formula block after insert op + SharedFormulaRowCount_After := 4; + SollFormula := 'A3-$B$2,B3-$B$2;'+ + ' , ;'+ + 'A5-$B$2,B5-$B$2;'+ + 'A6-$B$2,B6-$B$2'; + // comma-separated --> cells along row; semicolon separates rows + SollLayout := '12345678|'+ + '23456789|'+ + '34501890|'+ + ' |'+ + '45612901|'+ + '56723012|'+ + '67890123'; + end; + + // Insert row below shared formula block (row = 5) + with InsDelTestData[31] do begin + Layout := '12345678|'+ + '23456789|'+ + '345S 890|'+ // "S" = shared formula (2 cols x 3 rows) + '456 901|'+ + '567 012|'+ + '67890123'; + InsertRow := 5; + Formula := 'A3-$B$2'; + SharedFormulaColCount := 2; + SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 3; // Position of shared formula after insert op + SharedFormulaBaseRow_After := 2; + SharedFormulaColCount_After := 2; // Size of shared formula block after insert op + SharedFormulaRowCount_After := 3; + SollFormula := 'A3-$B$2,B3-$B$2;'+ + 'A4-$B$2,B4-$B$2;'+ + 'A5-$B$2,B5-$B$2'; + // comma-separated --> cells along row; semicolon separates rows + SollLayout := '12345678|'+ + '23456789|'+ + '34501890|'+ + '45612901|'+ + '56723012|'+ + ' |'+ + '67890123'; + end; + + // Delete column 0 (this is before any cell of the shared formula) + with InsDelTestData[32] do begin + Layout := '12345678|'+ + '23456789|'+ + '345S 890|'+ // "S" = shared formula (2 cols x 3 rows) + '456 901|'+ + '567 012|'+ + '67890123'; + DeleteCol := 0; + Formula := 'B3-$C$2'; + SharedFormulaColCount := 2; + SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 2; // Position of shared formula after delete op + SharedFormulaBaseRow_After := 2; + SharedFormulaColCount_After := 2; // Size of shared formula block after insert op + SharedFormulaRowCount_After := 3; + SollFormula := 'A3-$B$2,B3-$B$2;'+ // all column indexes decrease by 1 due to deleted col in front + 'A4-$B$2,B4-$B$2;'+ + 'A5-$B$2,B5-$B$2'; + // comma-separated --> cells along row; semicolon separates rows + SollLayout := '2345678|'+ + '3456789|'+ + '4501890|'+ + '5612901|'+ + '6723012|'+ + '7890123'; + end; + + // Delete last column (this is behind any cell of the shared formula) + with InsDelTestData[33] do begin + Layout := '12345678|'+ + '23456789|'+ + '345S 890|'+ // "S" = shared formula (2 cols x 3 rows) + '456 901|'+ + '567 012|'+ + '67890123'; + DeleteCol := 7; + Formula := 'B3-$C$2'; + SharedFormulaColCount := 2; + SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 3; // Position of shared formula after delete op + SharedFormulaBaseRow_After := 2; + SharedFormulaColCount_After := 2; // Size of shared formula block after insert op + SharedFormulaRowCount_After := 3; + SollFormula := 'B3-$C$2,C3-$C$2;'+ // all column indexes unchanged due to delete behind + 'B4-$C$2,C4-$C$2;'+ + 'B5-$C$2,C5-$C$2'; + // comma-separated --> cells along row; semicolon separates rows + SollLayout := '1234567|'+ + '2345678|'+ + '3450189|'+ + '4561290|'+ + '5672301|'+ + '6789012'; + end; + + // Delete in shared formula block, but no formula cell affected + with InsDelTestData[34] do begin + Layout := '12345678|'+ + '23456789|'+ + '345S 890|'+ // "S" = shared formula (2 cols x 3 rows) + '456 901|'+ + '567 012|'+ + '67890123'; + DeleteCol := 4; + Formula := 'B3-$C$2'; + SharedFormulaColCount := 2; + SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 3; // Position of shared formula after delete op + SharedFormulaBaseRow_After := 2; + SharedFormulaColCount_After := 1; // Size of shared formula block after insert op + SharedFormulaRowCount_After := 3; + SollFormula := 'B3-$C$2;'+ + 'B4-$C$2;'+ + 'B5-$C$2'; + // comma-separated --> cells along row; semicolon separates rows + SollLayout := '1234678|'+ + '2345789|'+ + '3450890|'+ + '4561901|'+ + '5672012|'+ + '6789123'; + end; + + // Delete column used in shared formula base + with InsDelTestData[35] do begin + Layout := '12345678|'+ + '23456789|'+ + '345S 890|'+ // "S" = shared formula (2 cols x 3 rows) + '456 901|'+ + '567 012|'+ + '67890123'; + DeleteCol := 1; + Formula := 'B3-$C$2'; + SharedFormulaColCount := 2; + SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 2; // Position of shared formula after delete op + SharedFormulaBaseRow_After := 2; + SharedFormulaColCount_After := 2; // Size of shared formula block after insert op + SharedFormulaRowCount_After := 3; + SollFormula := '#REF!-$B$2,#REF!-$B$2;'+ + '#REF!-$B$2,#REF!-$B$2;'+ + '#REF!-$B$2,#REF!-$B$2'; + // comma-separated --> cells along row; semicolon separates rows + SollLayout := '1345678|'+ + '2456789|'+ + '35EE890|'+ + '46EE901|'+ + '57EE012|'+ + '6890123'; + end; + + // Delete row 0 (this is before any cell of the shared formula) + with InsDelTestData[36] do begin + Layout := '12345678|'+ + '23456789|'+ + '345S 890|'+ // "S" = shared formula (2 cols x 3 rows) + '456 901|'+ + '567 012|'+ + '67890123'; + DeleteRow := 0; + Formula := 'B3-$C$2'; + SharedFormulaColCount := 2; + SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 3; // Position of shared formula after delete op + SharedFormulaBaseRow_After := 1; + SharedFormulaColCount_After := 2; // Size of shared formula block after insert op + SharedFormulaRowCount_After := 3; + SollFormula := 'B2-$C$1,C2-$C$1;'+ // all row indexes decrease by 1 due to deleted row in front + 'B3-$C$1,C3-$C$1;'+ + 'B4-$C$1,C4-$C$1'; + // comma-separated --> cells along row; semicolon separates rows + SollLayout := '23456789|'+ + '34501890|'+ + '45612901|'+ + '56723012|'+ + '67890123'; + end; + + // Delete lsst row (this is below any cell of the shared formula) + with InsDelTestData[37] do begin + Layout := '12345678|'+ + '23456789|'+ + '345S 890|'+ // "S" = shared formula (2 cols x 3 rows) + '456 901|'+ + '567 012|'+ + '67890123'; + DeleteRow := 5; + Formula := 'B3-$C$2'; + SharedFormulaColCount := 2; + SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 3; // Position of shared formula after delete op + SharedFormulaBaseRow_After := 2; + SharedFormulaColCount_After := 2; // Size of shared formula block after insert op + SharedFormulaRowCount_After := 3; + SollFormula := 'B3-$C$2,C3-$C$2;'+ // all row indexes unchanged + 'B4-$C$2,C4-$C$2;'+ + 'B5-$C$2,C5-$C$2'; + // comma-separated --> cells along row; semicolon separates rows + SollLayout := '12345678|'+ + '23456789|'+ + '34501890|'+ + '45612901|'+ + '56723012|'; + end; + + // Delete row through shared formula block + with InsDelTestData[38] do begin + Layout := '12345678|'+ + '23456789|'+ + '345S 890|'+ // "S" = shared formula (2 cols x 3 rows) + '456 901|'+ + '567 012|'+ + '67890123'; + DeleteRow := 3; + Formula := 'B3-$C$2'; + SharedFormulaColCount := 2; + SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 3; // Position of shared formula after delete op + SharedFormulaBaseRow_After := 2; + SharedFormulaColCount_After := 2; // Size of shared formula block after insert op + SharedFormulaRowCount_After := 2; + SollFormula := 'B3-$C$2,C3-$C$2;'+ + 'B4-$C$2,C4-$C$2;'+ + 'B5-$C$2,C5-$C$2'; + // comma-separated --> cells along row; semicolon separates rows + SollLayout := '12345678|'+ + '23456789|'+ + '34501890|'+ + // '45612901|'+ + '56723012|'+ + '67890123';; + end; + + // Delete row through shared formula block + with InsDelTestData[39] do begin + Layout := '12345678|'+ + '23456789|'+ + '345S 890|'+ // "S" = shared formula (2 cols x 3 rows) + '456 901|'+ + '567 012|'+ + '67890123'; + DeleteRow := 1; + Formula := 'B3-$C$2'; + SharedFormulaColCount := 2; + SharedFormulaRowCount := 3; + SharedFormulaBaseCol_After := 3; // Position of shared formula after delete op + SharedFormulaBaseRow_After := 1; + SharedFormulaColCount_After := 2; // Size of shared formula block after insert op + SharedFormulaRowCount_After := 3; + SollFormula := 'B2-#REF!,C2-#REF!;'+ // Confirmed by Excel + 'B3-#REF!,C3-#REF!;'+ + 'B4-#REF!,C4-#REF!'; + // comma-separated --> cells along row; semicolon separates rows + SollLayout := '12345678|'+ // Confirmed by Excel + // '23456789|'+ + '345EE890|'+ + '456EE901|'+ + '567EE012|'+ + '67890123';; + end; + end; @@ -609,9 +1107,7 @@ begin end; procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow( - ATestIndex: Integer); -const - AFormat = sfExcel8; + ATestIndex: Integer; AFormat: TsSpreadsheetFormat); var MyWorksheet: TsWorksheet; MyWorkbook: TsWorkbook; @@ -623,29 +1119,28 @@ var expected: String; actual: String; expectedFormulas: array of array of String; - begin TempFile := GetTempFileName; L := TStringList.Create; try // Extract soll formulas into a 2D array in case of shared formulas - if (InsDelTestData[ATestIndex].SharedFormulaRowCount > 0) or - (InsDelTestData[ATestIndex].SharedFormulaColCount > 0) then + if (InsDelTestData[ATestIndex].SharedFormulaRowCount_After > 0) or + (InsDelTestData[ATestIndex].SharedFormulaColCount_After > 0) then begin with InsDelTestData[ATestIndex] do - SetLength(expectedFormulas, SharedFormulaRowCount, SharedFormulaColCount); + SetLength(expectedFormulas, SharedFormulaRowCount_After, SharedFormulaColCount_After); L.Delimiter := ';'; L.DelimitedText := InsDelTestData[ATestIndex].SollFormula; LL := TStringList.Create; try LL.Delimiter := ','; - for row := 0 to InsDelTestData[ATestIndex].SharedFormulaRowCount-1 do + for row := 0 to InsDelTestData[ATestIndex].SharedFormulaRowCount_After-1 do begin s := L[row]; LL.DelimitedText := L[row]; - for col := 0 to InsDelTestData[ATestIndex].SharedFormulaColCount-1 do - expectedFormulas[row, col] := LL[col]; + for col := 0 to InsDelTestData[ATestIndex].SharedFormulaColCount_After-1 do + expectedFormulas[row, col] := trim(LL[col]); end; finally LL.Free; @@ -672,8 +1167,8 @@ begin 'S' : MyWorksheet.WriteSharedFormula( row, col, - row + InsDelTestData[ATestIndex].SharedFormulaRowCount-1, - col + InsDelTestData[ATestIndex].SharedFormulaColCount-1, + row + InsDelTestData[ATestIndex].SharedFormulaRowCount - 1, + col + InsDelTestData[ATestIndex].SharedFormulaColCount - 1, InsDelTestData[ATestIndex].Formula ); end; @@ -717,6 +1212,7 @@ begin for col := 0 to MyWorksheet.GetLastColIndex do begin MyCell := MyWorksheet.FindCell(row, col); + if MyCell = nil then actual := actual + ' ' else @@ -727,9 +1223,12 @@ begin end; if HasFormula(MyCell) then begin - if MyCell^.SharedFormulaBase <> nil then + if (InsDelTestData[ATestIndex].SharedFormulaRowCount_After > 0) or + (InsDelTestData[ATestIndex].SharedFormulaColCount_After > 0) + then CheckEquals( - expectedFormulas[row-MyCell^.SharedFormulaBase^.Row, col-MyCell^.SharedFormulaBase^.Col], + expectedFormulas[row-InsDelTestData[ATestIndex].SharedFormulaBaseRow_After, + col-InsDelTestData[ATestIndex].SharedFormulaBaseCol_After], MyWorksheet.ReadFormulaAsString(MyCell), 'Shared formula mismatch, cell ' + CellNotation(MyWorksheet, Row, Col) ) @@ -755,162 +1254,496 @@ begin end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_0; +{------------------------------------------------------------------------------} +{ BIFF8 tests } +{------------------------------------------------------------------------------} + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_0_BIFF8; // insert a column before the first one begin - TestWriteRead_InsDelColRow(0); + TestWriteRead_InsDelColRow(0, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_1; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_1_BIFF8; // insert a column before column 2 begin - TestWriteRead_InsDelColRow(1); + TestWriteRead_InsDelColRow(1, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_2; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_2_BIFF8; // insert a column before the last one begin - TestWriteRead_InsDelColRow(2); + TestWriteRead_InsDelColRow(2, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_3; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_3_BIFF8; // delete column 0 begin - TestWriteRead_InsDelColRow(3); + TestWriteRead_InsDelColRow(3, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_4; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_4_BIFF8; // delete column 2 begin - TestWriteRead_InsDelColRow(4); + TestWriteRead_InsDelColRow(4, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_5; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_5_BIFF8; // delete last column begin - TestWriteRead_InsDelColRow(5); + TestWriteRead_InsDelColRow(5, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_6; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_6_BIFF8; // insert row before first one begin - TestWriteRead_InsDelColRow(6); + TestWriteRead_InsDelColRow(6, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_7; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_7_BIFF8; // insert row before #2 begin - TestWriteRead_InsDelColRow(7); + TestWriteRead_InsDelColRow(7, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_8; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_8_BIFF8; // insert row before last one begin - TestWriteRead_InsDelColRow(8); + TestWriteRead_InsDelColRow(8, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_9; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_9_BIFF8; // delete first row begin - TestWriteRead_InsDelColRow(9); + TestWriteRead_InsDelColRow(9, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_10; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_10_BIFF8; // delete row #2 begin - TestWriteRead_InsDelColRow(10); + TestWriteRead_InsDelColRow(10, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_11; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_11_BIFF8; // delete last row begin - TestWriteRead_InsDelColRow(11); + TestWriteRead_InsDelColRow(11, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_12; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_12_BIFF8; // insert column before formula cell begin - TestWriteRead_InsDelColRow(12); + TestWriteRead_InsDelColRow(12, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_13; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_13_BIFF8; // insert column after formula cell begin - TestWriteRead_InsDelColRow(13); + TestWriteRead_InsDelColRow(13, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_14; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_14_BIFF8; // insert row before formula cell begin - TestWriteRead_InsDelColRow(14); + TestWriteRead_InsDelColRow(14, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_15; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_15_BIFF8; // insert row after formula cell begin - TestWriteRead_InsDelColRow(15); + TestWriteRead_InsDelColRow(15, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_16; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_16_BIFF8; // delete column before formula cell begin - TestWriteRead_InsDelColRow(16); + TestWriteRead_InsDelColRow(16, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_17; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_17_BIFF8; // delete column after formula cell begin - TestWriteRead_InsDelColRow(17); + TestWriteRead_InsDelColRow(17, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_18; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_18_BIFF8; // delete column containing a cell used in formula begin - TestWriteRead_InsDelColRow(18); + TestWriteRead_InsDelColRow(18, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_19; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_19_BIFF8; // delete row before formula cell begin - TestWriteRead_InsDelColRow(19); + TestWriteRead_InsDelColRow(19, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_20; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_20_BIFF8; // delete row after formula cell begin - TestWriteRead_InsDelColRow(20); + TestWriteRead_InsDelColRow(20, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_21; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_21_BIFF8; // delete row containing a cell used in formula begin - TestWriteRead_InsDelColRow(21); + TestWriteRead_InsDelColRow(21, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_22; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_22_BIFF8; // no insert/delete; just test shared formula begin - TestWriteRead_InsDelColRow(22); + TestWriteRead_InsDelColRow(22, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_23; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_23_BIFF8; // insert column before any cell addressed by the shared formula begin - TestWriteRead_InsDelColRow(23); + TestWriteRead_InsDelColRow(23, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_24; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_24_BIFF8; // insert column after any cell addressed by the shared formula begin - TestWriteRead_InsDelColRow(24); + TestWriteRead_InsDelColRow(24, sfExcel8); end; -procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_25; -// column through cells addressed by shared formula +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_25_BIFF8; +// insert column through cells addressed by shared formula begin - TestWriteRead_InsDelColRow(25); + TestWriteRead_InsDelColRow(25, sfExcel8); end; +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_26_BIFF8; +// insert column through shared formula block +begin + TestWriteRead_InsDelColRow(26, sfExcel8); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_27_BIFF8; +// insert column behind shared formula block +begin + TestWriteRead_InsDelColRow(27, sfExcel8); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_28_BIFF8; +// insert row before anything affected by the shared formula +begin + TestWriteRead_InsDelColRow(28, sfExcel8); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_29_BIFF8; +// insert row after shared formula cells +begin + TestWriteRead_InsDelColRow(29, sfExcel8); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_30_BIFF8; +// insert row through shared formula block +begin + TestWriteRead_InsDelColRow(30, sfExcel8); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_31_BIFF8; +// insert row below shared formula block +begin + TestWriteRead_InsDelColRow(31, sfExcel8); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_32_BIFF8; +// delete column before any cell referenced by the shared formula(s) +begin + TestWriteRead_InsDelColRow(32, sfExcel8); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_33_BIFF8; +// delete column after any cell referenced by the shared formula(s) +begin + TestWriteRead_InsDelColRow(33, sfExcel8); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_34_BIFF8; +// delete column in shared formula block, but no formula cell affected +begin + TestWriteRead_InsDelColRow(34, sfExcel8); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_35_BIFF8; +// delete column used in shared formula +begin + TestWriteRead_InsDelColRow(35, sfExcel8); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_36_BIFF8; +// delete row above shared formula and the used cells +begin + TestWriteRead_InsDelColRow(36, sfExcel8); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_37_BIFF8; +// delete row below shared formula and the used cells +begin + TestWriteRead_InsDelColRow(37, sfExcel8); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_38_BIFF8; +// delete row through shared formula block +begin + TestWriteRead_InsDelColRow(38, sfExcel8); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_39_BIFF8; +// delete row with cell used in shared formula block +begin + TestWriteRead_InsDelColRow(39, sfExcel8); +end; + + +{ -----------------------------------------------------------------------------} +{ OOXML Tests } +{ -----------------------------------------------------------------------------} + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_0_OOXML; +// insert a column before the first one +begin + TestWriteRead_InsDelColRow(0, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_1_OOXML; +// insert a column before column 2 +begin + TestWriteRead_InsDelColRow(1, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_2_OOXML; +// insert a column before the last one +begin + TestWriteRead_InsDelColRow(2, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_3_OOXML; +// delete column 0 +begin + TestWriteRead_InsDelColRow(3, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_4_OOXML; +// delete column 2 +begin + TestWriteRead_InsDelColRow(4, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_5_OOXML; +// delete last column +begin + TestWriteRead_InsDelColRow(5, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_6_OOXML; +// insert row before first one +begin + TestWriteRead_InsDelColRow(6, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_7_OOXML; +// insert row before #2 +begin + TestWriteRead_InsDelColRow(7, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_8_OOXML; +// insert row before last one +begin + TestWriteRead_InsDelColRow(8, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_9_OOXML; +// delete first row +begin + TestWriteRead_InsDelColRow(9, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_10_OOXML; +// delete row #2 +begin + TestWriteRead_InsDelColRow(10, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_11_OOXML; +// delete last row +begin + TestWriteRead_InsDelColRow(11, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_12_OOXML; +// insert column before formula cell +begin + TestWriteRead_InsDelColRow(12, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_13_OOXML; +// insert column after formula cell +begin + TestWriteRead_InsDelColRow(13, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_14_OOXML; +// insert row before formula cell +begin + TestWriteRead_InsDelColRow(14, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_15_OOXML; +// insert row after formula cell +begin + TestWriteRead_InsDelColRow(15, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_16_OOXML; +// delete column before formula cell +begin + TestWriteRead_InsDelColRow(16, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_17_OOXML; +// delete column after formula cell +begin + TestWriteRead_InsDelColRow(17, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_18_OOXML; +// delete column containing a cell used in formula +begin + TestWriteRead_InsDelColRow(18, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_19_OOXML; +// delete row before formula cell +begin + TestWriteRead_InsDelColRow(19, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_20_OOXML; +// delete row after formula cell +begin + TestWriteRead_InsDelColRow(20, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_21_OOXML; +// delete row containing a cell used in formula +begin + TestWriteRead_InsDelColRow(21, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_22_OOXML; +// no insert/delete; just test shared formula +begin + TestWriteRead_InsDelColRow(22, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_23_OOXML; +// insert column before any cell addressed by the shared formula +begin + TestWriteRead_InsDelColRow(23, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_24_OOXML; +// insert column after any cell addressed by the shared formula +begin + TestWriteRead_InsDelColRow(24, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_25_OOXML; +// insert column through cells addressed by shared formula +begin + TestWriteRead_InsDelColRow(25, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_26_OOXML; +// insert column through shared formula block +begin + TestWriteRead_InsDelColRow(26, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_27_OOXML; +// insert column behind shared formula block +begin + TestWriteRead_InsDelColRow(27, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_28_OOXML; +// insert row before anything affected by the shared formula +begin + TestWriteRead_InsDelColRow(28, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_29_OOXML; +// insert row after shared formula cells +begin + TestWriteRead_InsDelColRow(29, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_30_OOXML; +// insert row through shared formula block +begin + TestWriteRead_InsDelColRow(30, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_31_OOXML; +// insert row below shared formula block +begin + TestWriteRead_InsDelColRow(31, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_32_OOXML; +// delete column before any cell referenced by the shared formula(s) +begin + TestWriteRead_InsDelColRow(32, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_33_OOXML; +// delete column after any cell referenced by the shared formula(s) +begin + TestWriteRead_InsDelColRow(33, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_34_OOXML; +// delete column in shared formula block, but no formula cell affected +begin + TestWriteRead_InsDelColRow(34, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_35_OOXML; +// delete column used in shared formula +begin + TestWriteRead_InsDelColRow(35, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_36_OOXML; +// delete row above shared formula and the used cells +begin + TestWriteRead_InsDelColRow(36, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_37_OOXML; +// delete row below shared formula and the used cells +begin + TestWriteRead_InsDelColRow(37, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_38_OOXML; +// delete row through shared formula block +begin + TestWriteRead_InsDelColRow(38, sfOOXML); +end; + +procedure TSpreadWriteRead_InsDelColRow_Tests.TestWriteRead_InsDelColRow_39_OOXML; +// delete row with cell used in shared formula block +begin + TestWriteRead_InsDelColRow(39, sfOOXML); +end; + + initialization RegisterTest(TSpreadWriteRead_InsDelColRow_Tests); diff --git a/components/fpspreadsheet/tests/spreadtestgui.lpi b/components/fpspreadsheet/tests/spreadtestgui.lpi index d8730cf04..8b11c02d0 100644 --- a/components/fpspreadsheet/tests/spreadtestgui.lpi +++ b/components/fpspreadsheet/tests/spreadtestgui.lpi @@ -48,6 +48,7 @@ + @@ -56,7 +57,6 @@ - @@ -71,11 +71,11 @@ + - @@ -96,7 +96,6 @@ -