From de5e05ec86df844c4723c974f7e02390caac1101 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 2 Aug 2014 22:31:19 +0000 Subject: [PATCH] fpspreadsheet: Clean-up of demos (sometimes the default built mode was lost). Add some more overloaded methods to TsWorksheet having the cell as an argument instead of row/col index. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3411 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../examples/fpsgrid/fpsgrid.lpi | 75 +------ .../examples/fpsspeedtest/fpsspeedtest.lpi | 5 + .../examples/ooxmldemo/ooxmlread.lpi | 44 +--- .../examples/other/demo_formula_func.lpi | 44 +--- .../examples/other/demo_recursive_calc.lpi | 44 +--- .../examples/other/demo_virtualmode_read.lpi | 49 +---- .../examples/other/demo_virtualmode_write.lpi | 49 +---- .../examples/other/demo_write_formatting.lpi | 49 +---- .../examples/other/demo_write_formula.lpi | 12 +- .../examples/other/demo_write_formula.pas | 46 ++-- .../examples/spready/spready.lpi | 74 +------ components/fpspreadsheet/fpspreadsheet.pas | 203 ++++++++++++++---- .../fpspreadsheet/tests/spreadtestgui.lpi | 46 +--- 13 files changed, 237 insertions(+), 503 deletions(-) diff --git a/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi b/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi index ffd561731..0943006f2 100644 --- a/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi +++ b/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi @@ -15,78 +15,8 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -144,9 +74,6 @@ - - - diff --git a/components/fpspreadsheet/examples/fpsspeedtest/fpsspeedtest.lpi b/components/fpspreadsheet/examples/fpsspeedtest/fpsspeedtest.lpi index 05d314092..c8699c9cf 100644 --- a/components/fpspreadsheet/examples/fpsspeedtest/fpsspeedtest.lpi +++ b/components/fpspreadsheet/examples/fpsspeedtest/fpsspeedtest.lpi @@ -63,6 +63,11 @@ + + + + + diff --git a/components/fpspreadsheet/examples/ooxmldemo/ooxmlread.lpi b/components/fpspreadsheet/examples/ooxmldemo/ooxmlread.lpi index 477663263..22e3446e0 100644 --- a/components/fpspreadsheet/examples/ooxmldemo/ooxmlread.lpi +++ b/components/fpspreadsheet/examples/ooxmldemo/ooxmlread.lpi @@ -15,39 +15,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -91,18 +60,9 @@ - - - - - - - - - diff --git a/components/fpspreadsheet/examples/other/demo_formula_func.lpi b/components/fpspreadsheet/examples/other/demo_formula_func.lpi index f64220d06..87ec5202c 100644 --- a/components/fpspreadsheet/examples/other/demo_formula_func.lpi +++ b/components/fpspreadsheet/examples/other/demo_formula_func.lpi @@ -20,35 +20,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -87,19 +60,16 @@ - - - - - + + + + + - - - diff --git a/components/fpspreadsheet/examples/other/demo_recursive_calc.lpi b/components/fpspreadsheet/examples/other/demo_recursive_calc.lpi index 6687127b3..cb3eee288 100644 --- a/components/fpspreadsheet/examples/other/demo_recursive_calc.lpi +++ b/components/fpspreadsheet/examples/other/demo_recursive_calc.lpi @@ -20,35 +20,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -82,19 +55,16 @@ - - - - - + + + + + - - - diff --git a/components/fpspreadsheet/examples/other/demo_virtualmode_read.lpi b/components/fpspreadsheet/examples/other/demo_virtualmode_read.lpi index b2338f288..e3620db2c 100644 --- a/components/fpspreadsheet/examples/other/demo_virtualmode_read.lpi +++ b/components/fpspreadsheet/examples/other/demo_virtualmode_read.lpi @@ -20,40 +20,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -86,19 +54,16 @@ - - - - - + + + + + - - - diff --git a/components/fpspreadsheet/examples/other/demo_virtualmode_write.lpi b/components/fpspreadsheet/examples/other/demo_virtualmode_write.lpi index de6bb423a..78aa8f512 100644 --- a/components/fpspreadsheet/examples/other/demo_virtualmode_write.lpi +++ b/components/fpspreadsheet/examples/other/demo_virtualmode_write.lpi @@ -20,40 +20,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -86,19 +54,16 @@ - - - - - + + + + + - - - diff --git a/components/fpspreadsheet/examples/other/demo_write_formatting.lpi b/components/fpspreadsheet/examples/other/demo_write_formatting.lpi index 35a109e19..ca37245d7 100644 --- a/components/fpspreadsheet/examples/other/demo_write_formatting.lpi +++ b/components/fpspreadsheet/examples/other/demo_write_formatting.lpi @@ -10,7 +10,7 @@ - + <Title Value="demo_write_formatting"/> <ResourceType Value="res"/> <UseXPManifest Value="True"/> </General> @@ -20,35 +20,8 @@ <VersionInfo> <StringTable ProductVersion=""/> </VersionInfo> - <BuildModes Count="2"> - <Item1 Name="Debug" Default="True"/> - <Item2 Name="Release"> - <CompilerOptions> - <Version Value="11"/> - <PathDelim Value="\"/> - <Target> - <Filename Value="demo_write_formatting"/> - </Target> - <SearchPaths> - <IncludeFiles Value="$(ProjOutDir)"/> - <OtherUnitFiles Value="..\.."/> - <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> - </SearchPaths> - <CodeGeneration> - <SmartLinkUnit Value="True"/> - </CodeGeneration> - <Linking> - <Debugging> - <GenerateDebugInfo Value="False"/> - <StripSymbols Value="True"/> - </Debugging> - <LinkSmart Value="True"/> - </Linking> - <Other> - <CompilerPath Value="$(CompPath)"/> - </Other> - </CompilerOptions> - </Item2> + <BuildModes Count="1"> + <Item1 Name="Default" Default="True"/> </BuildModes> <PublishOptions> <Version Value="2"/> @@ -69,7 +42,6 @@ <Unit0> <Filename Value="demo_write_formatting.pas"/> <IsPartOfProject Value="True"/> - <UnitName Value="demo_write_formatting"/> </Unit0> </Units> </ProjectOptions> @@ -77,25 +49,22 @@ <Version Value="11"/> <PathDelim Value="\"/> <Target> - <Filename Value="test_write_formatting"/> + <Filename Value="demo_write_formatting"/> </Target> <SearchPaths> <IncludeFiles Value="$(ProjOutDir)"/> <OtherUnitFiles Value="..\.."/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> </SearchPaths> - <CodeGeneration> - <Optimizations> - <OptimizationLevel Value="0"/> - </Optimizations> - </CodeGeneration> + <Parsing> + <SyntaxOptions> + <UseAnsiStrings Value="False"/> + </SyntaxOptions> + </Parsing> <Linking> <Debugging> <UseExternalDbgSyms Value="True"/> </Debugging> </Linking> - <Other> - <CompilerPath Value="$(CompPath)"/> - </Other> </CompilerOptions> </CONFIG> diff --git a/components/fpspreadsheet/examples/other/demo_write_formula.lpi b/components/fpspreadsheet/examples/other/demo_write_formula.lpi index 998b43bca..d22c820d0 100644 --- a/components/fpspreadsheet/examples/other/demo_write_formula.lpi +++ b/components/fpspreadsheet/examples/other/demo_write_formula.lpi @@ -42,9 +42,6 @@ </Debugging> <LinkSmart Value="True"/> </Linking> - <Other> - <CompilerPath Value="$(CompPath)"/> - </Other> </CompilerOptions> </Item2> </BuildModes> @@ -68,6 +65,7 @@ <Unit0> <Filename Value="demo_write_formula.pas"/> <IsPartOfProject Value="True"/> + <UnitName Value="demo_write_formula"/> </Unit0> </Units> </ProjectOptions> @@ -81,6 +79,11 @@ <OtherUnitFiles Value="../.."/> <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> </SearchPaths> + <Parsing> + <SyntaxOptions> + <UseAnsiStrings Value="False"/> + </SyntaxOptions> + </Parsing> <CodeGeneration> <Optimizations> <OptimizationLevel Value="0"/> @@ -91,9 +94,6 @@ <UseExternalDbgSyms Value="True"/> </Debugging> </Linking> - <Other> - <CompilerPath Value="$(CompPath)"/> - </Other> </CompilerOptions> <Debugging> <Exceptions Count="3"> diff --git a/components/fpspreadsheet/examples/other/demo_write_formula.pas b/components/fpspreadsheet/examples/other/demo_write_formula.pas index 895456d0c..646e1dd15 100644 --- a/components/fpspreadsheet/examples/other/demo_write_formula.pas +++ b/components/fpspreadsheet/examples/other/demo_write_formula.pas @@ -30,47 +30,42 @@ begin MyWorksheet.WriteUTF8Text(0, 1, 'Text Formula');// B1 MyWorksheet.WriteUTF8Text(0, 2, 'RPN');// C1 + MyWorksheet.WriteNumber(0, 4, -3.14); // E1 + MyWorksheet.WriteNumber(1, 4, 100); // E2 + MyWorksheet.WriteNumber(2, 4, 200); // E3 + Myworksheet.WriteNumber(3, 4, 300); // E4 + MyWorksheet.WriteNumber(4, 4, 250); // E5 + // =Sum(E2:e5) MyWorksheet.WriteUTF8Text(1, 0, '=Sum(E2:e5)'); // A2 // - MyFormula.FormulaStr := '=Sum(DE:e5)'; + MyFormula.FormulaStr := '=Sum(E2:e5)'; MyFormula.DoubleValue := 0.0; MyWorksheet.WriteFormula(1, 1, MyFormula); // B2 // - SetLength(MyRPNFormula, 2); - MyRPNFormula[0].ElementKind := fekCellRange; - MyRPNFormula[0].Row := 1; - MyRPNFormula[0].Row2 := 4; - MyRPNFormula[0].Col := 4; - MyRPNFormula[0].Col2 := 4; - MyRPNFormula[1].ElementKind := fekOpSUM; - MyWorksheet.WriteRPNFormula(1, 2, MyRPNFormula); // C2 + MyWorksheet.WriteRPNFormula(1, 2, CreateRPNFormula( // C2 + RPNCellRange('E2:E5', + RPNFunc(fekSum, 1, nil)))); // Write the formula =ABS(E1) MyWorksheet.WriteUTF8Text(2, 0, '=ABS(E1)'); // A3 // - SetLength(MyRPNFormula, 2); - MyRPNFormula[0].ElementKind := fekCell; - MyRPNFormula[0].Col := 4; - MyRPNFormula[0].Row := 0; - MyRPNFormula[1].ElementKind := fekABS; - MyWorksheet.WriteRPNFormula(2, 2, MyRPNFormula); + MyWorksheet.WriteRPNFormula(2, 2, CreateRPNFormula( // C3 + RPNCellValue('E1', + RPNFunc(fekAbs, nil)))); // Write the formula =4+5 MyWorksheet.WriteUTF8Text(3, 0, '=4+5'); // A4 // - SetLength(MyRPNFormula, 3); - MyRPNFormula[0].ElementKind := fekNum; - MyRPNFormula[0].DoubleValue := 4.0; - MyRPNFormula[1].ElementKind := fekNum; - MyRPNFormula[1].DoubleValue := 5.0; - MyRPNFormula[2].ElementKind := fekAdd; - MyWorksheet.WriteRPNFormula(3, 2, MyRPNFormula); + MyWorksheet.WriteRPNFormula(3, 2, CreateRPNFormula( //C4 + RPNNumber(4.0, + RPNNumber(5.0, + RPNFunc(fekAdd, nil))))); end; procedure WriteSecondWorksheet(); begin -{ MyWorksheet := MyWorkbook.AddWorksheet('Worksheet2'); + MyWorksheet := MyWorkbook.AddWorksheet('Worksheet2'); // Write some cells @@ -78,9 +73,8 @@ begin MyWorksheet.WriteUTF8Text(1, 1, 'Relatório'); MyCell := MyWorksheet.GetCell(1, 1); - MyCell^.Border := [cbNorth, cbWest, cbSouth]; - MyCell^.BackgroundColor := scGrey20pct; - MyCell^.UsedFormattingFields := [uffBorder, uffBackgroundColor, uffBold];} + MyWorksheet.WriteBorders(MyCell, [cbNorth, cbWest, cbSouth]); + Myworksheet.WriteBackgroundColor(MyCell, scGray20pct); end; const diff --git a/components/fpspreadsheet/examples/spready/spready.lpi b/components/fpspreadsheet/examples/spready/spready.lpi index 0a7efc66c..55aa499e8 100644 --- a/components/fpspreadsheet/examples/spready/spready.lpi +++ b/components/fpspreadsheet/examples/spready/spready.lpi @@ -15,80 +15,8 @@ <CharSet Value=""/> <StringTable ProductVersion=""/> </VersionInfo> - <BuildModes Count="3"> + <BuildModes Count="1"> <Item1 Name="default" Default="True"/> - <Item2 Name="Debug"> - <CompilerOptions> - <Version Value="11"/> - <PathDelim Value="\"/> - <Target> - <Filename Value="spready"/> - </Target> - <SearchPaths> - <IncludeFiles Value="$(ProjOutDir)"/> - <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> - </SearchPaths> - <Parsing> - <SyntaxOptions> - <IncludeAssertionCode Value="True"/> - <UseAnsiStrings Value="False"/> - </SyntaxOptions> - </Parsing> - <CodeGeneration> - <Checks> - <IOChecks Value="True"/> - <OverflowChecks Value="True"/> - <StackChecks Value="True"/> - </Checks> - </CodeGeneration> - <Linking> - <Debugging> - <DebugInfoType Value="dsStabs"/> - <UseExternalDbgSyms Value="True"/> - </Debugging> - <Options> - <Win32> - <GraphicApplication Value="True"/> - </Win32> - </Options> - </Linking> - </CompilerOptions> - </Item2> - <Item3 Name="Release"> - <CompilerOptions> - <Version Value="11"/> - <PathDelim Value="\"/> - <Target> - <Filename Value="spready"/> - </Target> - <SearchPaths> - <IncludeFiles Value="$(ProjOutDir)"/> - <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> - </SearchPaths> - <Parsing> - <SyntaxOptions> - <UseAnsiStrings Value="False"/> - </SyntaxOptions> - </Parsing> - <CodeGeneration> - <SmartLinkUnit Value="True"/> - <Optimizations> - <OptimizationLevel Value="3"/> - </Optimizations> - </CodeGeneration> - <Linking> - <Debugging> - <GenerateDebugInfo Value="False"/> - </Debugging> - <LinkSmart Value="True"/> - <Options> - <Win32> - <GraphicApplication Value="True"/> - </Win32> - </Options> - </Linking> - </CompilerOptions> - </Item3> </BuildModes> <PublishOptions> <Version Value="2"/> diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas index 99889ca0d..9d6305d0f 100755 --- a/components/fpspreadsheet/fpspreadsheet.pas +++ b/components/fpspreadsheet/fpspreadsheet.pas @@ -598,17 +598,27 @@ type procedure WriteUTF8Text(ACell: PCell; AText: ansistring); overload; { Writing of cell attributes } - procedure WriteBackgroundColor(ARow, ACol: Cardinal; AColor: TsColor); + procedure WriteBackgroundColor(ARow, ACol: Cardinal; AColor: TsColor); overload; + procedure WriteBackgroundColor(ACell: PCell; AColor: TsColor); overload; - procedure WriteBorderColor(ARow, ACol: Cardinal; ABorder: TsCellBorder; AColor: TsColor); + procedure WriteBorderColor(ARow, ACol: Cardinal; ABorder: TsCellBorder; AColor: TsColor); overload; + procedure WriteBorderColor(ACell: PCell; ABorder: TsCellBorder; AColor: TsColor); overload; procedure WriteBorderLineStyle(ARow, ACol: Cardinal; ABorder: TsCellBorder; - ALineStyle: TsLineStyle); - procedure WriteBorders(ARow, ACol: Cardinal; ABorders: TsCellBorders); + ALineStyle: TsLineStyle); overload; + procedure WriteBorderLineStyle(ACell: PCell; ABorder: TsCellBorder; + ALineStyle: TsLineStyle); overload; + procedure WriteBorders(ARow, ACol: Cardinal; ABorders: TsCellBorders); overload; + procedure WriteBorders(ACell: PCell; ABorders: TsCellBorders); overload; procedure WriteBorderStyle(ARow, ACol: Cardinal; ABorder: TsCellBorder; AStyle: TsCellBorderStyle); overload; + procedure WriteBorderStyle(ACell: PCell; ABorder: TsCellBorder; + AStyle: TsCellBorderStyle); overload; procedure WriteBorderStyle(ARow, ACol: Cardinal; ABorder: TsCellBorder; ALineStyle: TsLineStyle; AColor: TsColor); overload; - procedure WriteBorderStyles(ARow, ACol: Cardinal; const AStyles: TsCellBorderStyles); + procedure WriteBorderStyle(ACell: PCell; ABorder: TsCellBorder; + ALineStyle: TsLineStyle; AColor: TsColor); overload; + procedure WriteBorderStyles(ARow, ACol: Cardinal; const AStyles: TsCellBorderStyles); overload; + procedure WriteBorderStyles(ACell: PCell; const AStyles: TsCellBorderStyles); overload; procedure WriteDecimals(ARow, ACol: Cardinal; ADecimals: byte); overload; procedure WriteDecimals(ACell: PCell; ADecimals: Byte); overload; @@ -3564,17 +3574,29 @@ end; } procedure TsWorksheet.WriteBackgroundColor(ARow, ACol: Cardinal; AColor: TsColor); -var - ACell: PCell; begin - ACell := GetCell(ARow, ACol); - if AColor = scTransparent then - Exclude(ACell^.UsedFormattingFields, uffBackgroundColor) - else begin - Include(ACell^.UsedFormattingFields, uffBackgroundColor); - ACell^.BackgroundColor := AColor; + WriteBackgroundColor(GetCell(ARow, ACol), AColor); +end; + +{@@ + Sets the color of a background color of a cell. + + @param ACell Pointer to cell + @param AColor Index of the new background color into the workbook's + color palette. Use the color index scTransparent to + erase an existing background color. +} +procedure TsWorksheet.WriteBackgroundColor(ACell: PCell; AColor: TsColor); +begin + if ACell <> nil then begin + if AColor = scTransparent then + Exclude(ACell^.UsedFormattingFields, uffBackgroundColor) + else begin + Include(ACell^.UsedFormattingFields, uffBackgroundColor); + ACell^.BackgroundColor := AColor; + end; + ChangedCell(ACell^.Row, ACell^.Col); end; - ChangedCell(ARow, ACol); end; {@@ @@ -3590,12 +3612,27 @@ end; } procedure TsWorksheet.WriteBorderColor(ARow, ACol: Cardinal; ABorder: TsCellBorder; AColor: TsColor); -var - lCell: PCell; begin - lCell := GetCell(ARow, ACol); - lCell^.BorderStyles[ABorder].Color := AColor; - ChangedCell(ARow, ACol); + WriteBorderColor(GetCell(ARow, ACol), ABorder, AColor); +end; + +{@@ + Sets the color of a cell border line. + Note: the border must be included in Borders set in order to be shown! + + @param ACell Pointer to cell + @param ABorder Indicates to which border (left/top etc) this color is + to be applied + @param AColor Index of the new border color into the workbook's + color palette. + } +procedure TsWorksheet.WriteBorderColor(ACell: PCell; ABorder: TsCellBorder; + AColor: TsColor); +begin + if ACell <> nil then begin + ACell^.BorderStyles[ABorder].Color := AColor; + ChangedCell(ACell^.Row, ACell^.Col); + end; end; {@@ @@ -3612,12 +3649,28 @@ end; } procedure TsWorksheet.WriteBorderLineStyle(ARow, ACol: Cardinal; ABorder: TsCellBorder; ALineStyle: TsLineStyle); -var - lCell: PCell; begin - lCell := GetCell(ARow, ACol); - lCell^.BorderStyles[ABorder].LineStyle := ALineStyle; - ChangedCell(ARow, ACol); + WriteBorderLineStyle(GetCell(ARow, ACol), ABorder, ALineStyle); +end; + +{@@ + Sets the linestyle of a cell border. + Note: the border must be included in the "Borders" set in order to be shown! + + @param ACell Pointer to cell + @param ABorder Indicates to which border (left/top etc) this color is + to be applied + @param ALineStyle Identifier of the new line style to be applied. + + @see TsLineStyle +} +procedure TsWorksheet.WriteBorderLineStyle(ACell: PCell; + ABorder: TsCellBorder; ALineStyle: TsLineStyle); +begin + if ACell <> nil then begin + ACell^.BorderStyles[ABorder].LineStyle := ALineStyle; + ChangedCell(ACell^.Row, ACell^.Col); + end; end; {@@ @@ -3632,13 +3685,27 @@ end; @see TsCellBorder } procedure TsWorksheet.WriteBorders(ARow, ACol: Cardinal; ABorders: TsCellBorders); -var - lCell: PCell; begin - lCell := GetCell(ARow, ACol); - Include(lCell^.UsedFormattingFields, uffBorder); - lCell^.Border := ABorders; - ChangedCell(ARow, ACol); + WriteBorders(GetCell(ARow, ACol), ABorders); +end; + +{@@ + Shows the cell borders included in the set ABorders. No border lines are drawn + for those not included. + + The borders are drawn using the "BorderStyles" assigned to the cell. + + @param ACell Pointer to cell + @param ABorders Set with elements to identify the border(s) to will be shown + @see TsCellBorder +} +procedure TsWorksheet.WriteBorders(ACell: PCell; ABorders: TsCellBorders); +begin + if ACell <> nil then begin + Include(ACell^.UsedFormattingFields, uffBorder); + ACell^.Border := ABorders; + ChangedCell(ACell^.Row, ACell^.Col); + end; end; {@@ @@ -3653,12 +3720,26 @@ end; } procedure TsWorksheet.WriteBorderStyle(ARow, ACol: Cardinal; ABorder: TsCellBorder; AStyle: TsCellBorderStyle); -var - lCell: PCell; begin - lCell := GetCell(ARow, ACol); - lCell^.BorderStyles[ABorder] := AStyle; - ChangedCell(ARow, ACol); + WriteBorderStyle(GetCell(ARow, ACol), ABorder, AStyle); +end; + +{@@ + Sets the style of a cell border, i.e. line style and line color. + Note: the border must be included in the "Borders" set in order to be shown! + + @param ACell Pointer to cell + @param ABorder Identifies the border to be modified (left/top/right/bottom) + @param AStyle record of parameters controlling how the border line is drawn + (line style, line color) +} +procedure TsWorksheet.WriteBorderStyle(ACell: PCell; ABorder: TsCellBorder; + AStyle: TsCellBorderStyle); +begin + if ACell <> nil then begin + ACell^.BorderStyles[ABorder] := AStyle; + ChangedCell(ACell^.Row, ACell^.Col); + end; end; {@@ @@ -3675,13 +3756,29 @@ end; } procedure TsWorksheet.WriteBorderStyle(ARow, ACol: Cardinal; ABorder: TsCellBorder; ALineStyle: TsLinestyle; AColor: TsColor); -var - lCell: PCell; begin - lCell := GetCell(ARow, ACol); - lCell^.BorderStyles[ABorder].LineStyle := ALineStyle; - lCell^.BorderStyles[ABorder].Color := AColor; - ChangedCell(ARow, ACol); + WriteBorderStyle(GetCell(ARow, ACol), ABorder, ALineStyle, AColor); +end; + +{@@ + Sets line style and line color of a cell border. + Note: the border must be included in the "Borders" set in order to be shown! + + @param ACell Pointer to cell + @param ABorder Identifier of the border to be modified + @param ALineStyle Identifier for the new line style of the border + @param AColor Palette index for the color of the border line + + @see WriteBorderStyles +} +procedure TsWorksheet.WriteBorderStyle(ACell: PCell; ABorder: TsCellBorder; + ALineStyle: TsLinestyle; AColor: TsColor); +begin + if ACell <> nil then begin + ACell^.BorderStyles[ABorder].LineStyle := ALineStyle; + ACell^.BorderStyles[ABorder].Color := AColor; + ChangedCell(ACell^.Row, ACell^.Col); + end; end; {@@ @@ -3696,13 +3793,29 @@ end; } procedure TsWorksheet.WriteBorderStyles(ARow, ACol: Cardinal; const AStyles: TsCellBorderStyles); +begin + WriteBorderStyles(GetCell(ARow, ACol), AStyles); +end; + +{@@ + Sets the style of all cell border of a cell, i.e. line style and line color. + Note: Only those borders included in the "Borders" set are shown! + + @param ACell Pointer to cell + @param ACol Column index of the considered cell + @param AStyles Array of CellBorderStyles for each cell border. + + @see WriteBorderStyle +} +procedure TsWorksheet.WriteBorderStyles(ACell: PCell; + const AStyles: TsCellBorderStyles); var b: TsCellBorder; - cell: PCell; begin - cell := GetCell(ARow, ACol); - for b in TsCellBorder do cell^.BorderStyles[b] := AStyles[b]; - ChangedCell(ARow, ACol); + if Assigned(ACell) then begin + for b in TsCellBorder do ACell^.BorderStyles[b] := AStyles[b]; + ChangedCell(ACell^.Row, ACell^.Col); + end; end; {@@ diff --git a/components/fpspreadsheet/tests/spreadtestgui.lpi b/components/fpspreadsheet/tests/spreadtestgui.lpi index 0431b3378..e985a9241 100644 --- a/components/fpspreadsheet/tests/spreadtestgui.lpi +++ b/components/fpspreadsheet/tests/spreadtestgui.lpi @@ -15,40 +15,8 @@ <VersionInfo> <StringTable ProductVersion=""/> </VersionInfo> - <BuildModes Count="2"> - <Item1 Name="Release" Default="True"/> - <Item2 Name="Debug"> - <CompilerOptions> - <Version Value="11"/> - <PathDelim Value="\"/> - <Target> - <Filename Value="spreadtestgui"/> - </Target> - <SearchPaths> - <IncludeFiles Value="$(ProjOutDir)"/> - <OtherUnitFiles Value=".."/> - <UnitOutputDirectory Value="units\$(TargetCPU)-$(TargetOS)"/> - </SearchPaths> - <Parsing> - <SyntaxOptions> - <IncludeAssertionCode Value="True"/> - </SyntaxOptions> - </Parsing> - <CodeGeneration> - <Checks> - <IOChecks Value="True"/> - <OverflowChecks Value="True"/> - <StackChecks Value="True"/> - </Checks> - </CodeGeneration> - <Linking> - <Debugging> - <DebugInfoType Value="dsDwarf2Set"/> - <UseExternalDbgSyms Value="True"/> - </Debugging> - </Linking> - </CompilerOptions> - </Item2> + <BuildModes Count="1"> + <Item1 Name="Default" Default="True"/> </BuildModes> <PublishOptions> <Version Value="2"/> @@ -152,11 +120,11 @@ <OtherUnitFiles Value=".."/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> </SearchPaths> - <CodeGeneration> - <Optimizations> - <OptimizationLevel Value="0"/> - </Optimizations> - </CodeGeneration> + <Linking> + <Debugging> + <DebugInfoType Value="dsDwarf2Set"/> + </Debugging> + </Linking> </CompilerOptions> <Debugging> <Exceptions Count="6">