fpspreadsheet: Clean up. Silence some hints.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3473 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-08-12 14:52:57 +00:00
parent f35eae9379
commit 5bc25c482e
10 changed files with 225 additions and 228 deletions

View File

@ -1550,6 +1550,7 @@ var
d: TDate; d: TDate;
data: TsArgNumberArray; data: TsArgNumberArray;
n: Integer; n: Integer;
dow: Integer;
begin begin
n := 1; n := 1;
if NumArgs = 2 then begin if NumArgs = 2 then begin
@ -1560,8 +1561,18 @@ begin
exit; exit;
end; end;
end; end;
if PopDateValue(Args, d, Result) then if PopDateValue(Args, d, Result) then begin
Result := CreateNumberArg(DayOfWeek(d)); dow := DayOfWeek(d); // Sunday = 1 ... Saturday = 7
case n of
1: ;
2: if dow > 1 then dow := dow - 1 else dow := 7;
3: if dow > 1 then dow := dow - 2 else dow := 6;
else
Result := CreateErrorArg(errOverflow); // #NUM!
exit;
end;
Result := CreateNumberArg(dow);
end;
end; end;
function fpsYEAR(Args: TsArgumentStack; NumArgs: Integer): TsArgument; function fpsYEAR(Args: TsArgumentStack; NumArgs: Integer): TsArgument;

View File

@ -205,8 +205,8 @@ const
OPENDOC_PATH_SETTINGS = 'settings.xml'; OPENDOC_PATH_SETTINGS = 'settings.xml';
OPENDOC_PATH_STYLES = 'styles.xml'; OPENDOC_PATH_STYLES = 'styles.xml';
OPENDOC_PATH_MIMETYPE = 'mimetype'; OPENDOC_PATH_MIMETYPE = 'mimetype';
OPENDOC_PATH_METAINF = 'META-INF' + '/'; {%H-}OPENDOC_PATH_METAINF = 'META-INF' + '/';
OPENDOC_PATH_METAINF_MANIFEST = 'META-INF' + '/' + 'manifest.xml'; {%H-}OPENDOC_PATH_METAINF_MANIFEST = 'META-INF' + '/' + 'manifest.xml';
{ OpenDocument schemas constants } { OpenDocument schemas constants }
SCHEMAS_XMLNS_OFFICE = 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'; SCHEMAS_XMLNS_OFFICE = 'urn:oasis:names:tc:opendocument:xmlns:office:1.0';
@ -293,47 +293,17 @@ type
AutoRowHeight: Boolean; AutoRowHeight: Boolean;
end; end;
(* --- presently not used, but this may change... ---
{ Row data items stored in the RowList of the reader } { Row data items stored in the RowList of the reader }
TRowData = class TRowData = class
Row: Integer; Row: Integer;
RowStyleIndex: Integer; // index into FRowStyleList of reader RowStyleIndex: Integer; // index into FRowStyleList of reader
DefaultCellStyleIndex: Integer; // Index of default row style in FCellStyleList of reader DefaultCellStyleIndex: Integer; // Index of default row style in FCellStyleList of reader
end; end;
(*
{ Utilities }
function DecodeODSTime(ATimeStr: String; out AHours, AMinutes, ASeconds, AMilliseconds: Word): Boolean;
var
p: Integer;
val: String;
hrStr: String;
minStr: String;
secStr: String;
msecStr: String;
begin
Result := false;
ATimeStr := Uppercase(ATimeStr);
if ATimeStr = '' then
exit;
if ATimeStr[1] <> 'P' then
exit;
if (Length(ATimeStr) < 2) or (ATimeStr[2] <> 'T') then
exit;
p := 3;
val := '';
while p <= Length(ATimeStr) do begin
case ATimeStr[p] of
'0'..'9': val := val + ATimeStr[p];
'H': begin hrStr := val; val := ''; end;
'M': begin minStr := val; val := ''; end;
'S': begin secStr := val; val := ''; end;
',', '.':
end;
end;
end;
*) *)
{ TsSpreadOpenDocNumFormatList } { TsSpreadOpenDocNumFormatList }
procedure TsSpreadOpenDocNumFormatList.AddBuiltinFormats; procedure TsSpreadOpenDocNumFormatList.AddBuiltinFormats;
@ -2924,8 +2894,8 @@ var
k: Integer; k: Integer;
h, h_mm: Single; // row height in "lines" and millimeters, respectively h, h_mm: Single; // row height in "lines" and millimeters, respectively
h1: Single; h1: Single;
colsRepeated: Integer; colsRepeated: Cardinal;
rowsRepeated: Integer; rowsRepeated: Cardinal;
colsRepeatedStr: String; colsRepeatedStr: String;
rowsRepeatedStr: String; rowsRepeatedStr: String;
firstCol, firstRow, lastCol, lastRow: Cardinal; firstCol, firstRow, lastCol, lastRow: Cardinal;
@ -3486,8 +3456,8 @@ var
h, h_mm: Single; // row height in "lines" and millimeters, respectively h, h_mm: Single; // row height in "lines" and millimeters, respectively
k: Integer; k: Integer;
rowStyleData: TRowStyleData; rowStyleData: TRowStyleData;
rowsRepeated: Integer; rowsRepeated: Cardinal;
colsRepeated: Integer; colsRepeated: Cardinal;
colsRepeatedStr: String; colsRepeatedStr: String;
defFontSize: Single; defFontSize: Single;
lastCol, lastRow: Cardinal; lastCol, lastRow: Cardinal;

View File

@ -1159,8 +1159,8 @@ function GetFileFormatName(AFormat: TsSpreadsheetFormat): String;
procedure MakeLEPalette(APalette: PsPalette; APaletteSize: Integer); procedure MakeLEPalette(APalette: PsPalette; APaletteSize: Integer);
function SameCellBorders(ACell1, ACell2: PCell): Boolean; function SameCellBorders(ACell1, ACell2: PCell): Boolean;
procedure InitCell(var ACell: TCell); overload; procedure InitCell(out ACell: TCell); overload;
procedure InitCell(ARow, ACol: Cardinal; var ACell: TCell); overload; procedure InitCell(ARow, ACol: Cardinal; out ACell: TCell); overload;
implementation implementation
@ -1185,10 +1185,8 @@ resourcestring
lpInvalidNumberFormat = 'Trying to use an incompatible number format.'; lpInvalidNumberFormat = 'Trying to use an incompatible number format.';
lpInvalidDateTimeFormat = 'Trying to use an incompatible date/time format.'; lpInvalidDateTimeFormat = 'Trying to use an incompatible date/time format.';
lpNoValidNumberFormatString = 'No valid number format string.'; lpNoValidNumberFormatString = 'No valid number format string.';
lpNoValidDateTimeFormatString = 'No valid date/time format string.';
lpNoValidCellAddress = '"%s" is not a valid cell address.'; lpNoValidCellAddress = '"%s" is not a valid cell address.';
lpNoValidCellRangeAddress = '"%s" is not a valid cell range address.'; lpNoValidCellRangeAddress = '"%s" is not a valid cell range address.';
lpIllegalNumberFormat = 'Illegal number format.';
lpSpecifyNumberOfParams = 'Specify number of parameters for function %s'; lpSpecifyNumberOfParams = 'Specify number of parameters for function %s';
lpIncorrectParamCount = 'Funtion %s requires at least %d and at most %d parameters.'; lpIncorrectParamCount = 'Funtion %s requires at least %d and at most %d parameters.';
lpCircularReference = 'Circular reference found when calculating worksheet formulas'; lpCircularReference = 'Circular reference found when calculating worksheet formulas';
@ -1203,6 +1201,10 @@ resourcestring
lpErrArgError = '#N/A'; lpErrArgError = '#N/A';
lpErrFormulaNotSupported = '<FORMULA?>'; lpErrFormulaNotSupported = '<FORMULA?>';
{%H-}lpNoValidDateTimeFormatString = 'No valid date/time format string.';
{%H-}lpIllegalNumberFormat = 'Illegal number format.';
const const
{ These are reserved system colors by Microsoft { These are reserved system colors by Microsoft
@ -1585,7 +1587,7 @@ end;
{@@ {@@
Initalizes a new cell Initalizes a new cell
} }
procedure InitCell(var ACell: TCell); procedure InitCell(out ACell: TCell);
begin begin
ACell.RPNFormulaValue := nil; ACell.RPNFormulaValue := nil;
ACell.FormulaValue.FormulaStr := ''; ACell.FormulaValue.FormulaStr := '';
@ -1594,7 +1596,7 @@ begin
FillChar(ACell, SizeOf(ACell), 0); FillChar(ACell, SizeOf(ACell), 0);
end; end;
procedure InitCell(ARow, ACol: Cardinal; var ACell: TCell); procedure InitCell(ARow, ACol: Cardinal; out ACell: TCell);
begin begin
InitCell(ACell); InitCell(ACell);
ACell.Row := ARow; ACell.Row := ARow;
@ -5015,6 +5017,7 @@ var
SheetType: TsSpreadsheetFormat; SheetType: TsSpreadsheetFormat;
lException: Exception; lException: Exception;
begin begin
lException := pointer(1);
SheetType := sfExcel8; SheetType := sfExcel8;
while (SheetType in [sfExcel2..sfExcel8, sfOpenDocument, sfOOXML]) and (lException <> nil) do while (SheetType in [sfExcel2..sfExcel8, sfOpenDocument, sfOOXML]) and (lException <> nil) do
begin begin
@ -6400,7 +6403,6 @@ var
i, n: Integer; i, n: Integer;
b: TsCellBorder; b: TsCellBorder;
equ: Boolean; equ: Boolean;
clr: TsColor;
begin begin
Result := -1; Result := -1;
@ -6556,7 +6558,6 @@ procedure TsCustomSpreadWriter.CheckLimitations;
var var
lastCol, lastRow: Cardinal; lastCol, lastRow: Cardinal;
i, n: Integer; i, n: Integer;
fnt: TsFont;
begin begin
Workbook.GetLastRowColIndex(lastRow, lastCol); Workbook.GetLastRowColIndex(lastRow, lastCol);

View File

@ -459,7 +459,7 @@ function ParseCellString(const AStr: String; out ACellRow, ACellCol: Cardinal;
// Scan letters // Scan letters
while (i <= Length(AStr)) do begin while (i <= Length(AStr)) do begin
if (UpCase(AStr[i]) in LETTERS) then begin if (UpCase(AStr[i]) in LETTERS) then begin
ACellCol := ord(UpCase(AStr[i])) - ord('A') + 1 + ACellCol * 26; ACellCol := Cardinal(ord(UpCase(AStr[i])) - ord('A')) + 1 + ACellCol * 26;
inc(i); inc(i);
end end
else else
@ -478,7 +478,7 @@ function ParseCellString(const AStr: String; out ACellRow, ACellCol: Cardinal;
// Scan digits // Scan digits
while (i <= Length(AStr)) do begin while (i <= Length(AStr)) do begin
if (AStr[i] in DIGITS) then begin if (AStr[i] in DIGITS) then begin
ACellRow := (ord(AStr[i]) - ord('0')) + ACellRow * 10; ACellRow := Cardinal(ord(AStr[i]) - ord('0')) + ACellRow * 10;
inc(i); inc(i);
end end
else begin else begin
@ -2009,9 +2009,9 @@ const
procedure RGBtoHLS(const R, G, B: Byte; out H, L, S: Byte); procedure RGBtoHLS(const R, G, B: Byte; out H, L, S: Byte);
var var
cMax, cMin: Byte; // max and min RGB values cMax, cMin: Integer; // max and min RGB values
Rdelta, Gdelta, Bdelta: Byte; // intermediate value: % of spread from max Rdelta, Gdelta, Bdelta: Byte; // intermediate value: % of spread from max
diff: Byte; diff: Integer;
begin begin
// calculate lightness // calculate lightness
cMax := MaxIntValue([R, G, B]); cMax := MaxIntValue([R, G, B]);
@ -2067,7 +2067,7 @@ procedure HLStoRGB(const H, L, S: Byte; out R, G, B: Byte);
end; end;
var var
n1, n2: Byte; n1, n2: Integer;
begin begin
if S = 0 if S = 0
then begin then begin

View File

@ -26,7 +26,7 @@ uses
not found. } not found. }
function TsSpreadXMLReader.GetAttrValue(ANode : TDOMNode; AAttrName : string) : string; function TsSpreadXMLReader.GetAttrValue(ANode : TDOMNode; AAttrName : string) : string;
var var
i: integer; i: LongWord;
Found: Boolean; Found: Boolean;
begin begin
Result := ''; Result := '';

View File

@ -164,7 +164,7 @@ const
INT_EXCEL_ID_LABEL = $0004; INT_EXCEL_ID_LABEL = $0004;
INT_EXCEL_ID_ROW = $0008; INT_EXCEL_ID_ROW = $0008;
INT_EXCEL_ID_BOF = $0009; INT_EXCEL_ID_BOF = $0009;
INT_EXCEL_ID_INDEX = $000B; {%H-}INT_EXCEL_ID_INDEX = $000B;
INT_EXCEL_ID_FORMAT = $001E; INT_EXCEL_ID_FORMAT = $001E;
INT_EXCEL_ID_FORMATCOUNT= $001F; INT_EXCEL_ID_FORMATCOUNT= $001F;
INT_EXCEL_ID_COLWIDTH = $0024; INT_EXCEL_ID_COLWIDTH = $0024;
@ -175,8 +175,8 @@ const
{ BOF record constants } { BOF record constants }
INT_EXCEL_SHEET = $0010; INT_EXCEL_SHEET = $0010;
INT_EXCEL_CHART = $0020; {%H-}INT_EXCEL_CHART = $0020;
INT_EXCEL_MACRO_SHEET = $0040; {%H-}INT_EXCEL_MACRO_SHEET = $0040;
type type
TBIFF2DimensionsRecord = packed record TBIFF2DimensionsRecord = packed record
@ -585,8 +585,8 @@ begin
FWorksheet.WriteBlank(cell); FWorksheet.WriteBlank(cell);
end end
else begin else begin
if SizeOf(Double) <> 8 then {if SizeOf(Double) <> 8 then
raise Exception.Create('Double is not 8 bytes'); raise Exception.Create('Double is not 8 bytes');}
// Result is a number or a date/time // Result is a number or a date/time
Move(Data[0], formulaResult, SizeOf(Data)); Move(Data[0], formulaResult, SizeOf(Data));
@ -1158,7 +1158,10 @@ begin
rec.RecordID := WordToLE(INT_EXCEL_ID_DIMENSIONS); rec.RecordID := WordToLE(INT_EXCEL_ID_DIMENSIONS);
rec.RecordSize := WordToLE(8); rec.RecordSize := WordToLE(8);
rec.FirstRow := WordToLE(firstRow); rec.FirstRow := WordToLE(firstRow);
rec.LastRowPlus1 := WordToLE(Min(lastRow+1, $FFFF)); // avoid WORD overflow if lastRow < $FFFF then // avoid WORD overflow when adding 1
rec.LastRowPlus1 := WordToLE(lastRow+1)
else
rec.LastRowPlus1 := $FFFF;
rec.FirstCol := WordToLE(firstCol); rec.FirstCol := WordToLE(firstCol);
rec.LastColPlus1 := WordToLE(lastCol+1); rec.LastColPlus1 := WordToLE(lastCol+1);
@ -1548,7 +1551,6 @@ end;
procedure TsSpreadBIFF2Writer.WriteRPNFormula(AStream: TStream; procedure TsSpreadBIFF2Writer.WriteRPNFormula(AStream: TStream;
const ARow, ACol: Cardinal; const AFormula: TsRPNFormula; ACell: PCell); const ARow, ACol: Cardinal; const AFormula: TsRPNFormula; ACell: PCell);
var var
FormulaResult: double;
RPNLength: Word; RPNLength: Word;
RecordSizePos, FinalPos: Cardinal; RecordSizePos, FinalPos: Cardinal;
xf: Word; xf: Word;
@ -1557,7 +1559,6 @@ begin
exit; exit;
RPNLength := 0; RPNLength := 0;
FormulaResult := 0.0;
xf := FindXFIndex(ACell); xf := FindXFIndex(ACell);
if xf >= 63 then if xf >= 63 then

View File

@ -218,7 +218,7 @@ var
implementation implementation
uses uses
Math, fpsStreams; fpsStreams;
const const
{ Excel record IDs } { Excel record IDs }
@ -227,51 +227,51 @@ const
{ BOF record constants } { BOF record constants }
INT_BOF_BIFF5_VER = $0500; INT_BOF_BIFF5_VER = $0500;
INT_BOF_WORKBOOK_GLOBALS= $0005; INT_BOF_WORKBOOK_GLOBALS= $0005;
INT_BOF_VB_MODULE = $0006; {%H-}INT_BOF_VB_MODULE = $0006;
INT_BOF_SHEET = $0010; INT_BOF_SHEET = $0010;
INT_BOF_CHART = $0020; {%H-}INT_BOF_CHART = $0020;
INT_BOF_MACRO_SHEET = $0040; {%H-}INT_BOF_MACRO_SHEET = $0040;
INT_BOF_WORKSPACE = $0100; {%H-}INT_BOF_WORKSPACE = $0100;
INT_BOF_BUILD_ID = $1FD2; INT_BOF_BUILD_ID = $1FD2;
INT_BOF_BUILD_YEAR = $07CD; INT_BOF_BUILD_YEAR = $07CD;
{ FONT record constants } { FONT record constants }
INT_FONT_WEIGHT_NORMAL = $0190; INT_FONT_WEIGHT_NORMAL = $0190;
BYTE_ANSILatin1 = $00; {%H-}BYTE_ANSILatin1 = $00;
BYTE_SYSTEM_DEFAULT = $01; {%H-}BYTE_SYSTEM_DEFAULT = $01;
BYTE_SYMBOL = $02; {%H-}BYTE_SYMBOL = $02;
BYTE_Apple_Roman = $4D; {%H-}BYTE_Apple_Roman = $4D;
BYTE_ANSI_Japanese_Shift_JIS = $80; {%H-}BYTE_ANSI_Japanese_Shift_JIS = $80;
BYTE_ANSI_Korean_Hangul = $81; {%H-}BYTE_ANSI_Korean_Hangul = $81;
BYTE_ANSI_Korean_Johab = $81; {%H-}BYTE_ANSI_Korean_Johab = $81;
BYTE_ANSI_Chinese_Simplified_GBK = $86; {%H-}BYTE_ANSI_Chinese_Simplified_GBK = $86;
BYTE_ANSI_Chinese_Traditional_BIG5 = $88; {%H-}BYTE_ANSI_Chinese_Traditional_BIG5 = $88;
BYTE_ANSI_Greek = $A1; {%H-}BYTE_ANSI_Greek = $A1;
BYTE_ANSI_Turkish = $A2; {%H-}BYTE_ANSI_Turkish = $A2;
BYTE_ANSI_Vietnamese = $A3; {%H-}BYTE_ANSI_Vietnamese = $A3;
BYTE_ANSI_Hebrew = $B1; {%H-}BYTE_ANSI_Hebrew = $B1;
BYTE_ANSI_Arabic = $B2; {%H-}BYTE_ANSI_Arabic = $B2;
BYTE_ANSI_Baltic = $BA; {%H-}BYTE_ANSI_Baltic = $BA;
BYTE_ANSI_Cyrillic = $CC; {%H-}BYTE_ANSI_Cyrillic = $CC;
BYTE_ANSI_Thai = $DE; {%H-}BYTE_ANSI_Thai = $DE;
BYTE_ANSI_Latin2 = $EE; {%H-}BYTE_ANSI_Latin2 = $EE;
BYTE_OEM_Latin1 = $FF; {%H-}BYTE_OEM_Latin1 = $FF;
{ FORMULA record constants } { FORMULA record constants }
MASK_FORMULA_RECALCULATE_ALWAYS = $0001; {%H-}MASK_FORMULA_RECALCULATE_ALWAYS = $0001;
MASK_FORMULA_RECALCULATE_ON_OPEN = $0002; {%H-}MASK_FORMULA_RECALCULATE_ON_OPEN = $0002;
MASK_FORMULA_SHARED_FORMULA = $0008; {%H-}MASK_FORMULA_SHARED_FORMULA = $0008;
{ STYLE record constants } { STYLE record constants }
MASK_STYLE_BUILT_IN = $8000; MASK_STYLE_BUILT_IN = $8000;
{ WINDOW1 record constants } { WINDOW1 record constants }
MASK_WINDOW1_OPTION_WINDOW_HIDDEN = $0001; {%H-}MASK_WINDOW1_OPTION_WINDOW_HIDDEN = $0001;
MASK_WINDOW1_OPTION_WINDOW_MINIMISED = $0002; {%H-}MASK_WINDOW1_OPTION_WINDOW_MINIMISED = $0002;
MASK_WINDOW1_OPTION_HORZ_SCROLL_VISIBLE = $0008; {%H-}MASK_WINDOW1_OPTION_HORZ_SCROLL_VISIBLE = $0008;
MASK_WINDOW1_OPTION_VERT_SCROLL_VISIBLE = $0010; {%H-}MASK_WINDOW1_OPTION_VERT_SCROLL_VISIBLE = $0010;
MASK_WINDOW1_OPTION_WORKSHEET_TAB_VISIBLE = $0020; {%H-}MASK_WINDOW1_OPTION_WORKSHEET_TAB_VISIBLE = $0020;
{ XF substructures } { XF substructures }
@ -295,7 +295,7 @@ const
{ XF CELL BACKGROUND } { XF CELL BACKGROUND }
MASK_XF_BKGR_PATTERN_COLOR = $0000007F; MASK_XF_BKGR_PATTERN_COLOR = $0000007F;
MASK_XF_BKGR_BACKGROUND_COLOR = $00003F80; {%H-}MASK_XF_BKGR_BACKGROUND_COLOR = $00003F80;
MASK_XF_BKGR_FILLPATTERN = $003F0000; MASK_XF_BKGR_FILLPATTERN = $003F0000;
TEXT_ROTATIONS: Array[TsTextRotation] of Byte = ( TEXT_ROTATIONS: Array[TsTextRotation] of Byte = (
@ -565,7 +565,10 @@ begin
rec.RecordID := WordToLE(INT_EXCEL_ID_DIMENSIONS); rec.RecordID := WordToLE(INT_EXCEL_ID_DIMENSIONS);
rec.RecordSize := WordToLE(10); rec.RecordSize := WordToLE(10);
rec.FirstRow := WordToLE(firstRow); rec.FirstRow := WordToLE(firstRow);
rec.LastRowPlus1 := WordToLE(Min(lastRow+1, $FFFF)); // avoid word overflow if lastRow < $FFFF then // avoid WORD overflow
rec.LastRowPlus1 := WordToLE(lastRow + 1)
else
rec.LastRowPlus1 := $FFFF;
rec.FirstCol := WordToLe(firstCol); rec.FirstCol := WordToLe(firstCol);
rec.LastColPlus1 := WordToLE(lastCol+1); rec.LastColPlus1 := WordToLE(lastCol+1);
rec.NotUsed := 0; rec.NotUsed := 0;
@ -1166,14 +1169,14 @@ begin
end; end;
// Border lines // Border lines
if cbSouth in ABorders then if cbSouth in ABorders then
dw1 := dw1 or ((ord(ABorderStyles[cbSouth].LineStyle)+1) shl 22); dw1 := dw1 or ((DWord(ABorderStyles[cbSouth].LineStyle)+1) shl 22);
dw1 := dw1 or (ABorderStyles[cbSouth].Color shl 25); // Bottom line color dw1 := dw1 or (ABorderStyles[cbSouth].Color shl 25); // Bottom line color
dw2 := (ABorderStyles[cbNorth].Color shl 9) or // Top line color dw2 := (ABorderStyles[cbNorth].Color shl 9) or // Top line color
(ABorderStyles[cbWest].Color shl 16) or // Left line color (ABorderStyles[cbWest].Color shl 16) or // Left line color
(ABorderStyles[cbEast].Color shl 23); // Right line color (ABorderStyles[cbEast].Color shl 23); // Right line color
if cbNorth in ABorders then dw2 := dw2 or (ord(ABorderStyles[cbNorth].LineStyle)+1); if cbNorth in ABorders then dw2 := dw2 or (DWord(ABorderStyles[cbNorth].LineStyle)+1);
if cbWest in ABorders then dw2 := dw2 or ((ord(ABorderStyles[cbWest].LineStyle)+1) shl 3); if cbWest in ABorders then dw2 := dw2 or ((DWord(ABorderStyles[cbWest].LineStyle)+1) shl 3);
if cbEast in ABorders then dw2 := dw2 or ((ord(ABorderStyles[cbEast].LineStyle)+1) shl 6); if cbEast in ABorders then dw2 := dw2 or ((DWord(ABorderStyles[cbEast].LineStyle)+1) shl 6);
AStream.WriteDWord(DWordToLE(dw1)); AStream.WriteDWord(DWordToLE(dw1));
AStream.WriteDWord(DWordToLE(dw2)); AStream.WriteDWord(DWordToLE(dw2));
end; end;

View File

@ -225,7 +225,7 @@ const
{ Excel record IDs } { Excel record IDs }
INT_EXCEL_ID_SST = $00FC; //BIFF8 only INT_EXCEL_ID_SST = $00FC; //BIFF8 only
INT_EXCEL_ID_LABELSST = $00FD; //BIFF8 only INT_EXCEL_ID_LABELSST = $00FD; //BIFF8 only
INT_EXCEL_ID_FORCEFULLCALCULATION = $08A3; {%H-}INT_EXCEL_ID_FORCEFULLCALCULATION = $08A3;
{ Cell Addresses constants } { Cell Addresses constants }
MASK_EXCEL_COL_BITS_BIFF8 = $00FF; MASK_EXCEL_COL_BITS_BIFF8 = $00FF;
@ -235,11 +235,11 @@ const
{ BOF record constants } { BOF record constants }
INT_BOF_BIFF8_VER = $0600; INT_BOF_BIFF8_VER = $0600;
INT_BOF_WORKBOOK_GLOBALS= $0005; INT_BOF_WORKBOOK_GLOBALS= $0005;
INT_BOF_VB_MODULE = $0006; {%H-}INT_BOF_VB_MODULE = $0006;
INT_BOF_SHEET = $0010; INT_BOF_SHEET = $0010;
INT_BOF_CHART = $0020; {%H-}INT_BOF_CHART = $0020;
INT_BOF_MACRO_SHEET = $0040; {%H-}INT_BOF_MACRO_SHEET = $0040;
INT_BOF_WORKSPACE = $0100; {%H-}INT_BOF_WORKSPACE = $0100;
INT_BOF_BUILD_ID = $1FD2; INT_BOF_BUILD_ID = $1FD2;
INT_BOF_BUILD_YEAR = $07CD; INT_BOF_BUILD_YEAR = $07CD;
@ -794,6 +794,9 @@ procedure TsSpreadBIFF8Writer.WriteFormula(AStream: TStream; const ARow,
RPNLength: Word; RPNLength: Word;
TokenArraySizePos, RecordSizePos, FinalPos: Int64;} TokenArraySizePos, RecordSizePos, FinalPos: Int64;}
begin begin
Unused(AStream);
Unused(ARow, ACol);
Unused(AFormula, ACell);
(* (*
if (ARow >= FLimitations.MaxRows) or (ACol >= FLimitations.MaxCols) then if (ARow >= FLimitations.MaxRows) or (ACol >= FLimitations.MaxCols) then
exit; exit;
@ -1220,13 +1223,13 @@ begin
// Border line styles // Border line styles
if cbWest in ABorders then if cbWest in ABorders then
XFBorderDWord1 := XFBorderDWord1 or (ord(ABorderStyles[cbWest].LineStyle)+1); XFBorderDWord1 := XFBorderDWord1 or (DWord(ABorderStyles[cbWest].LineStyle)+1);
if cbEast in ABorders then if cbEast in ABorders then
XFBorderDWord1 := XFBorderDWord1 or ((ord(ABorderStyles[cbEast].LineStyle)+1) shl 4); XFBorderDWord1 := XFBorderDWord1 or ((DWord(ABorderStyles[cbEast].LineStyle)+1) shl 4);
if cbNorth in ABorders then if cbNorth in ABorders then
XFBorderDWord1 := XFBorderDWord1 or ((ord(ABorderStyles[cbNorth].LineStyle)+1) shl 8); XFBorderDWord1 := XFBorderDWord1 or ((DWord(ABorderStyles[cbNorth].LineStyle)+1) shl 8);
if cbSouth in ABorders then if cbSouth in ABorders then
XFBorderDWord1 := XFBorderDWord1 or ((ord(ABorderStyles[cbSouth].LineStyle)+1) shl 12); XFBorderDWord1 := XFBorderDWord1 or ((DWord(ABorderStyles[cbSouth].LineStyle)+1) shl 12);
if cbDiagDown in ABorders then if cbDiagDown in ABorders then
XFBorderDWord1 := XFBorderDWord1 or $40000000; XFBorderDWord1 := XFBorderDWord1 or $40000000;
if cbDiagUp in ABorders then if cbDiagUp in ABorders then
@ -1240,7 +1243,7 @@ begin
// Diagonal line style // Diagonal line style
if (ABorders + [cbDiagUp, cbDiagDown] <> []) then if (ABorders + [cbDiagUp, cbDiagDown] <> []) then
XFBorderDWord2 := XFBorderDWord2 or ((ord(ABorderStyles[cbDiagUp].LineStyle)+1) shl 21); XFBorderDWord2 := XFBorderDWord2 or ((DWord(ABorderStyles[cbDiagUp].LineStyle)+1) shl 21);
// In BIFF8 both diagonals have the same color - we use the color of the up-diagonal. // In BIFF8 both diagonals have the same color - we use the color of the up-diagonal.
// Add a background, if desired // Add a background, if desired

View File

@ -11,11 +11,13 @@ interface
uses uses
Classes, SysUtils, DateUtils, Classes, SysUtils, DateUtils,
(*
{$ifdef USE_NEW_OLE} {$ifdef USE_NEW_OLE}
fpolebasic, fpolebasic,
{$else} {$else}
fpolestorage, fpolestorage,
{$endif} {$endif}
*)
fpspreadsheet, fpsutils, lconvencoding; fpspreadsheet, fpsutils, lconvencoding;
const const
@ -530,7 +532,7 @@ type
implementation implementation
uses uses
Math, Variants, fpsStreams, fpsNumFormatParser; Math, Variants, fpsNumFormatParser;
{ Helper table for rpn formulas: { Helper table for rpn formulas:
Assignment of FormulaElementKinds (fekXXXX) to EXCEL_TOKEN IDs. } Assignment of FormulaElementKinds (fekXXXX) to EXCEL_TOKEN IDs. }
@ -1210,8 +1212,10 @@ begin
3: FWorksheet.WriteBlank(cell); 3: FWorksheet.WriteBlank(cell);
end end
else begin else begin
{
if SizeOf(Double) <> 8 then if SizeOf(Double) <> 8 then
raise Exception.Create('Double is not 8 bytes'); raise Exception.Create('Double is not 8 bytes');
}
// Result is a number or a date/time // Result is a number or a date/time
Move(Data[0], ResultFormula, SizeOf(Data)); Move(Data[0], ResultFormula, SizeOf(Data));

View File

@ -178,10 +178,10 @@ const
// http://www.pkware.com/documents/casestudies/APPNOTE.TXT // http://www.pkware.com/documents/casestudies/APPNOTE.TXT
// 4.4.17.1 All slashes MUST be forward slashes '/' as opposed to backwards slashes '\' // 4.4.17.1 All slashes MUST be forward slashes '/' as opposed to backwards slashes '\'
OOXML_PATH_TYPES = '[Content_Types].xml'; OOXML_PATH_TYPES = '[Content_Types].xml';
OOXML_PATH_RELS = '_rels/'; {%H-}OOXML_PATH_RELS = '_rels/';
OOXML_PATH_RELS_RELS = '_rels/.rels'; OOXML_PATH_RELS_RELS = '_rels/.rels';
OOXML_PATH_XL = 'xl/'; {%H-}OOXML_PATH_XL = 'xl/';
OOXML_PATH_XL_RELS = 'xl/_rels/'; {%H-}OOXML_PATH_XL_RELS = 'xl/_rels/';
OOXML_PATH_XL_RELS_RELS = 'xl/_rels/workbook.xml.rels'; OOXML_PATH_XL_RELS_RELS = 'xl/_rels/workbook.xml.rels';
OOXML_PATH_XL_WORKBOOK = 'xl/workbook.xml'; OOXML_PATH_XL_WORKBOOK = 'xl/workbook.xml';
OOXML_PATH_XL_STYLES = 'xl/styles.xml'; OOXML_PATH_XL_STYLES = 'xl/styles.xml';
@ -200,7 +200,7 @@ const
SCHEMAS_SPREADML = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'; SCHEMAS_SPREADML = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main';
{ OOXML mime types constants } { OOXML mime types constants }
MIME_XML = 'application/xml'; {%H-}MIME_XML = 'application/xml';
MIME_RELS = 'application/vnd.openxmlformats-package.relationships+xml'; MIME_RELS = 'application/vnd.openxmlformats-package.relationships+xml';
MIME_SPREADML = 'application/vnd.openxmlformats-officedocument.spreadsheetml'; MIME_SPREADML = 'application/vnd.openxmlformats-officedocument.spreadsheetml';
MIME_SHEET = MIME_SPREADML + '.sheet.main+xml'; MIME_SHEET = MIME_SPREADML + '.sheet.main+xml';
@ -1166,13 +1166,14 @@ procedure TsSpreadOOXMLReader.ReadSheetList(ANode: TDOMNode; AList: TStrings);
var var
node: TDOMNode; node: TDOMNode;
sheetName: String; sheetName: String;
sheetId: String; //sheetId: String;
begin begin
node := ANode.FirstChild; node := ANode.FirstChild;
while node <> nil do begin while node <> nil do begin
sheetName := GetAttrValue(node, 'name'); sheetName := GetAttrValue(node, 'name');
sheetId := GetAttrValue(node, 'sheetId'); //sheetId := GetAttrValue(node, 'sheetId');
AList.AddObject(sheetName, pointer(PtrInt(StrToInt(sheetId)))); AList.Add(sheetName);
// AList.AddObject(sheetName, pointer(PtrInt(StrToInt(sheetId))));
node := node.NextSibling; node := node.NextSibling;
end; end;
end; end;
@ -1560,10 +1561,13 @@ end;
"FormattingStyles" which correspond to the section cellXfs of the styles.xml "FormattingStyles" which correspond to the section cellXfs of the styles.xml
file. } file. }
function TsSpreadOOXMLWriter.GetStyleIndex(ACell: PCell): Cardinal; function TsSpreadOOXMLWriter.GetStyleIndex(ACell: PCell): Cardinal;
var
idx: Integer;
begin begin
Result := FindFormattingInList(ACell); idx := FindFormattingInList(ACell);
if Result = -1 then if idx = -1 then
Result := 0; idx := 0;
Result := idx;
end; end;
{ Creates a list of all border styles found in the workbook. { Creates a list of all border styles found in the workbook.