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;
data: TsArgNumberArray;
n: Integer;
dow: Integer;
begin
n := 1;
if NumArgs = 2 then begin
@ -1560,8 +1561,18 @@ begin
exit;
end;
end;
if PopDateValue(Args, d, Result) then
Result := CreateNumberArg(DayOfWeek(d));
if PopDateValue(Args, d, Result) then begin
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;
function fpsYEAR(Args: TsArgumentStack; NumArgs: Integer): TsArgument;

View File

@ -205,8 +205,8 @@ const
OPENDOC_PATH_SETTINGS = 'settings.xml';
OPENDOC_PATH_STYLES = 'styles.xml';
OPENDOC_PATH_MIMETYPE = 'mimetype';
OPENDOC_PATH_METAINF = 'META-INF' + '/';
OPENDOC_PATH_METAINF_MANIFEST = 'META-INF' + '/' + 'manifest.xml';
{%H-}OPENDOC_PATH_METAINF = 'META-INF' + '/';
{%H-}OPENDOC_PATH_METAINF_MANIFEST = 'META-INF' + '/' + 'manifest.xml';
{ OpenDocument schemas constants }
SCHEMAS_XMLNS_OFFICE = 'urn:oasis:names:tc:opendocument:xmlns:office:1.0';
@ -293,47 +293,17 @@ type
AutoRowHeight: Boolean;
end;
(* --- presently not used, but this may change... ---
{ Row data items stored in the RowList of the reader }
TRowData = class
Row: Integer;
RowStyleIndex: Integer; // index into FRowStyleList of reader
DefaultCellStyleIndex: Integer; // Index of default row style in FCellStyleList of reader
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 }
procedure TsSpreadOpenDocNumFormatList.AddBuiltinFormats;
@ -2924,8 +2894,8 @@ var
k: Integer;
h, h_mm: Single; // row height in "lines" and millimeters, respectively
h1: Single;
colsRepeated: Integer;
rowsRepeated: Integer;
colsRepeated: Cardinal;
rowsRepeated: Cardinal;
colsRepeatedStr: String;
rowsRepeatedStr: String;
firstCol, firstRow, lastCol, lastRow: Cardinal;
@ -3486,8 +3456,8 @@ var
h, h_mm: Single; // row height in "lines" and millimeters, respectively
k: Integer;
rowStyleData: TRowStyleData;
rowsRepeated: Integer;
colsRepeated: Integer;
rowsRepeated: Cardinal;
colsRepeated: Cardinal;
colsRepeatedStr: String;
defFontSize: Single;
lastCol, lastRow: Cardinal;

View File

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

View File

@ -459,7 +459,7 @@ function ParseCellString(const AStr: String; out ACellRow, ACellCol: Cardinal;
// Scan letters
while (i <= Length(AStr)) do 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);
end
else
@ -478,7 +478,7 @@ function ParseCellString(const AStr: String; out ACellRow, ACellCol: Cardinal;
// Scan digits
while (i <= Length(AStr)) do 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);
end
else begin
@ -2009,9 +2009,9 @@ const
procedure RGBtoHLS(const R, G, B: Byte; out H, L, S: Byte);
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
diff: Byte;
diff: Integer;
begin
// calculate lightness
cMax := MaxIntValue([R, G, B]);
@ -2067,7 +2067,7 @@ procedure HLStoRGB(const H, L, S: Byte; out R, G, B: Byte);
end;
var
n1, n2: Byte;
n1, n2: Integer;
begin
if S = 0
then begin

View File

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

View File

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

View File

@ -218,92 +218,92 @@ var
implementation
uses
Math, fpsStreams;
fpsStreams;
const
{ Excel record IDs }
// see: in xlscommon
{ Excel record IDs }
// see: in xlscommon
{ BOF record constants }
INT_BOF_BIFF5_VER = $0500;
INT_BOF_WORKBOOK_GLOBALS= $0005;
INT_BOF_VB_MODULE = $0006;
INT_BOF_SHEET = $0010;
INT_BOF_CHART = $0020;
INT_BOF_MACRO_SHEET = $0040;
INT_BOF_WORKSPACE = $0100;
INT_BOF_BUILD_ID = $1FD2;
INT_BOF_BUILD_YEAR = $07CD;
{ BOF record constants }
INT_BOF_BIFF5_VER = $0500;
INT_BOF_WORKBOOK_GLOBALS= $0005;
{%H-}INT_BOF_VB_MODULE = $0006;
INT_BOF_SHEET = $0010;
{%H-}INT_BOF_CHART = $0020;
{%H-}INT_BOF_MACRO_SHEET = $0040;
{%H-}INT_BOF_WORKSPACE = $0100;
INT_BOF_BUILD_ID = $1FD2;
INT_BOF_BUILD_YEAR = $07CD;
{ FONT record constants }
INT_FONT_WEIGHT_NORMAL = $0190;
{ FONT record constants }
INT_FONT_WEIGHT_NORMAL = $0190;
BYTE_ANSILatin1 = $00;
BYTE_SYSTEM_DEFAULT = $01;
BYTE_SYMBOL = $02;
BYTE_Apple_Roman = $4D;
BYTE_ANSI_Japanese_Shift_JIS = $80;
BYTE_ANSI_Korean_Hangul = $81;
BYTE_ANSI_Korean_Johab = $81;
BYTE_ANSI_Chinese_Simplified_GBK = $86;
BYTE_ANSI_Chinese_Traditional_BIG5 = $88;
BYTE_ANSI_Greek = $A1;
BYTE_ANSI_Turkish = $A2;
BYTE_ANSI_Vietnamese = $A3;
BYTE_ANSI_Hebrew = $B1;
BYTE_ANSI_Arabic = $B2;
BYTE_ANSI_Baltic = $BA;
BYTE_ANSI_Cyrillic = $CC;
BYTE_ANSI_Thai = $DE;
BYTE_ANSI_Latin2 = $EE;
BYTE_OEM_Latin1 = $FF;
{%H-}BYTE_ANSILatin1 = $00;
{%H-}BYTE_SYSTEM_DEFAULT = $01;
{%H-}BYTE_SYMBOL = $02;
{%H-}BYTE_Apple_Roman = $4D;
{%H-}BYTE_ANSI_Japanese_Shift_JIS = $80;
{%H-}BYTE_ANSI_Korean_Hangul = $81;
{%H-}BYTE_ANSI_Korean_Johab = $81;
{%H-}BYTE_ANSI_Chinese_Simplified_GBK = $86;
{%H-}BYTE_ANSI_Chinese_Traditional_BIG5 = $88;
{%H-}BYTE_ANSI_Greek = $A1;
{%H-}BYTE_ANSI_Turkish = $A2;
{%H-}BYTE_ANSI_Vietnamese = $A3;
{%H-}BYTE_ANSI_Hebrew = $B1;
{%H-}BYTE_ANSI_Arabic = $B2;
{%H-}BYTE_ANSI_Baltic = $BA;
{%H-}BYTE_ANSI_Cyrillic = $CC;
{%H-}BYTE_ANSI_Thai = $DE;
{%H-}BYTE_ANSI_Latin2 = $EE;
{%H-}BYTE_OEM_Latin1 = $FF;
{ FORMULA record constants }
MASK_FORMULA_RECALCULATE_ALWAYS = $0001;
MASK_FORMULA_RECALCULATE_ON_OPEN = $0002;
MASK_FORMULA_SHARED_FORMULA = $0008;
{ FORMULA record constants }
{%H-}MASK_FORMULA_RECALCULATE_ALWAYS = $0001;
{%H-}MASK_FORMULA_RECALCULATE_ON_OPEN = $0002;
{%H-}MASK_FORMULA_SHARED_FORMULA = $0008;
{ STYLE record constants }
MASK_STYLE_BUILT_IN = $8000;
{ STYLE record constants }
MASK_STYLE_BUILT_IN = $8000;
{ WINDOW1 record constants }
MASK_WINDOW1_OPTION_WINDOW_HIDDEN = $0001;
MASK_WINDOW1_OPTION_WINDOW_MINIMISED = $0002;
MASK_WINDOW1_OPTION_HORZ_SCROLL_VISIBLE = $0008;
MASK_WINDOW1_OPTION_VERT_SCROLL_VISIBLE = $0010;
MASK_WINDOW1_OPTION_WORKSHEET_TAB_VISIBLE = $0020;
{ WINDOW1 record constants }
{%H-}MASK_WINDOW1_OPTION_WINDOW_HIDDEN = $0001;
{%H-}MASK_WINDOW1_OPTION_WINDOW_MINIMISED = $0002;
{%H-}MASK_WINDOW1_OPTION_HORZ_SCROLL_VISIBLE = $0008;
{%H-}MASK_WINDOW1_OPTION_VERT_SCROLL_VISIBLE = $0010;
{%H-}MASK_WINDOW1_OPTION_WORKSHEET_TAB_VISIBLE = $0020;
{ XF substructures }
{ XF substructures --- see xlscommon! }
XF_ROTATION_HORIZONTAL = 0;
XF_ROTATION_STACKED = 1;
XF_ROTATION_90DEG_CCW = 2;
XF_ROTATION_90DEG_CW = 3;
{ XF substructures --- see xlscommon! }
XF_ROTATION_HORIZONTAL = 0;
XF_ROTATION_STACKED = 1;
XF_ROTATION_90DEG_CCW = 2;
XF_ROTATION_90DEG_CW = 3;
{ XF CELL BORDER }
MASK_XF_BORDER_LEFT = $00000038;
MASK_XF_BORDER_RIGHT = $000001C0;
MASK_XF_BORDER_TOP = $00000007;
MASK_XF_BORDER_BOTTOM = $01C00000;
{ XF CELL BORDER }
MASK_XF_BORDER_LEFT = $00000038;
MASK_XF_BORDER_RIGHT = $000001C0;
MASK_XF_BORDER_TOP = $00000007;
MASK_XF_BORDER_BOTTOM = $01C00000;
{ XF CELL BORDER COLORS }
MASK_XF_BORDER_LEFT_COLOR = $007F0000;
MASK_XF_BORDER_RIGHT_COLOR = $3F800000;
MASK_XF_BORDER_TOP_COLOR = $0000FE00;
MASK_XF_BORDER_BOTTOM_COLOR = $FE000000;
{ XF CELL BORDER COLORS }
MASK_XF_BORDER_LEFT_COLOR = $007F0000;
MASK_XF_BORDER_RIGHT_COLOR = $3F800000;
MASK_XF_BORDER_TOP_COLOR = $0000FE00;
MASK_XF_BORDER_BOTTOM_COLOR = $FE000000;
{ XF CELL BACKGROUND }
MASK_XF_BKGR_PATTERN_COLOR = $0000007F;
MASK_XF_BKGR_BACKGROUND_COLOR = $00003F80;
MASK_XF_BKGR_FILLPATTERN = $003F0000;
{ XF CELL BACKGROUND }
MASK_XF_BKGR_PATTERN_COLOR = $0000007F;
{%H-}MASK_XF_BKGR_BACKGROUND_COLOR = $00003F80;
MASK_XF_BKGR_FILLPATTERN = $003F0000;
TEXT_ROTATIONS: Array[TsTextRotation] of Byte = (
XF_ROTATION_HORIZONTAL,
XF_ROTATION_90DEG_CW,
XF_ROTATION_90DEG_CCW,
XF_ROTATION_STACKED
);
TEXT_ROTATIONS: Array[TsTextRotation] of Byte = (
XF_ROTATION_HORIZONTAL,
XF_ROTATION_90DEG_CW,
XF_ROTATION_90DEG_CCW,
XF_ROTATION_STACKED
);
type
TBIFF5DimensionsRecord = packed record
@ -565,7 +565,10 @@ begin
rec.RecordID := WordToLE(INT_EXCEL_ID_DIMENSIONS);
rec.RecordSize := WordToLE(10);
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.LastColPlus1 := WordToLE(lastCol+1);
rec.NotUsed := 0;
@ -1166,14 +1169,14 @@ begin
end;
// Border lines
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
dw2 := (ABorderStyles[cbNorth].Color shl 9) or // Top line color
(ABorderStyles[cbWest].Color shl 16) or // Left line color
(ABorderStyles[cbEast].Color shl 23); // Right line color
if cbNorth in ABorders then dw2 := dw2 or (ord(ABorderStyles[cbNorth].LineStyle)+1);
if cbWest in ABorders then dw2 := dw2 or ((ord(ABorderStyles[cbWest].LineStyle)+1) shl 3);
if cbEast in ABorders then dw2 := dw2 or ((ord(ABorderStyles[cbEast].LineStyle)+1) shl 6);
if cbNorth in ABorders then dw2 := dw2 or (DWord(ABorderStyles[cbNorth].LineStyle)+1);
if cbWest in ABorders then dw2 := dw2 or ((DWord(ABorderStyles[cbWest].LineStyle)+1) shl 3);
if cbEast in ABorders then dw2 := dw2 or ((DWord(ABorderStyles[cbEast].LineStyle)+1) shl 6);
AStream.WriteDWord(DWordToLE(dw1));
AStream.WriteDWord(DWordToLE(dw2));
end;

View File

@ -222,64 +222,64 @@ uses
fpsStreams;
const
{ Excel record IDs }
INT_EXCEL_ID_SST = $00FC; //BIFF8 only
INT_EXCEL_ID_LABELSST = $00FD; //BIFF8 only
INT_EXCEL_ID_FORCEFULLCALCULATION = $08A3;
{ Excel record IDs }
INT_EXCEL_ID_SST = $00FC; //BIFF8 only
INT_EXCEL_ID_LABELSST = $00FD; //BIFF8 only
{%H-}INT_EXCEL_ID_FORCEFULLCALCULATION = $08A3;
{ Cell Addresses constants }
MASK_EXCEL_COL_BITS_BIFF8 = $00FF;
MASK_EXCEL_RELATIVE_COL_BIFF8 = $4000; // This is according to Microsoft documentation,
MASK_EXCEL_RELATIVE_ROW_BIFF8 = $8000; // but opposite to OpenOffice documentation!
{ Cell Addresses constants }
MASK_EXCEL_COL_BITS_BIFF8 = $00FF;
MASK_EXCEL_RELATIVE_COL_BIFF8 = $4000; // This is according to Microsoft documentation,
MASK_EXCEL_RELATIVE_ROW_BIFF8 = $8000; // but opposite to OpenOffice documentation!
{ BOF record constants }
INT_BOF_BIFF8_VER = $0600;
INT_BOF_WORKBOOK_GLOBALS= $0005;
INT_BOF_VB_MODULE = $0006;
INT_BOF_SHEET = $0010;
INT_BOF_CHART = $0020;
INT_BOF_MACRO_SHEET = $0040;
INT_BOF_WORKSPACE = $0100;
INT_BOF_BUILD_ID = $1FD2;
INT_BOF_BUILD_YEAR = $07CD;
{ BOF record constants }
INT_BOF_BIFF8_VER = $0600;
INT_BOF_WORKBOOK_GLOBALS= $0005;
{%H-}INT_BOF_VB_MODULE = $0006;
INT_BOF_SHEET = $0010;
{%H-}INT_BOF_CHART = $0020;
{%H-}INT_BOF_MACRO_SHEET = $0040;
{%H-}INT_BOF_WORKSPACE = $0100;
INT_BOF_BUILD_ID = $1FD2;
INT_BOF_BUILD_YEAR = $07CD;
{ STYLE record constants }
MASK_STYLE_BUILT_IN = $8000;
{ STYLE record constants }
MASK_STYLE_BUILT_IN = $8000;
{ XF substructures }
{ XF substructures }
{ XF_ROTATION }
XF_ROTATION_HORIZONTAL = 0;
XF_ROTATION_90DEG_CCW = 90;
XF_ROTATION_90DEG_CW = 180;
XF_ROTATION_STACKED = 255; // Letters stacked top to bottom, but not rotated
{ XF_ROTATION }
XF_ROTATION_HORIZONTAL = 0;
XF_ROTATION_90DEG_CCW = 90;
XF_ROTATION_90DEG_CW = 180;
XF_ROTATION_STACKED = 255; // Letters stacked top to bottom, but not rotated
{ XF CELL BORDER LINE STYLES }
MASK_XF_BORDER_LEFT = $0000000F;
MASK_XF_BORDER_RIGHT = $000000F0;
MASK_XF_BORDER_TOP = $00000F00;
MASK_XF_BORDER_BOTTOM = $0000F000;
MASK_XF_BORDER_DIAGONAL = $01E00000;
{ XF CELL BORDER LINE STYLES }
MASK_XF_BORDER_LEFT = $0000000F;
MASK_XF_BORDER_RIGHT = $000000F0;
MASK_XF_BORDER_TOP = $00000F00;
MASK_XF_BORDER_BOTTOM = $0000F000;
MASK_XF_BORDER_DIAGONAL = $01E00000;
MASK_XF_BORDER_SHOW_DIAGONAL_DOWN = $40000000;
MASK_XF_BORDER_SHOW_DIAGONAL_UP = $80000000;
MASK_XF_BORDER_SHOW_DIAGONAL_DOWN = $40000000;
MASK_XF_BORDER_SHOW_DIAGONAL_UP = $80000000;
{ XF CELL BORDER COLORS }
MASK_XF_BORDER_LEFT_COLOR = $007F0000;
MASK_XF_BORDER_RIGHT_COLOR = $3F800000;
MASK_XF_BORDER_TOP_COLOR = $0000007F;
MASK_XF_BORDER_BOTTOM_COLOR = $00003F80;
MASK_XF_BORDER_DIAGONAL_COLOR = $001FC000;
{ XF CELL BORDER COLORS }
MASK_XF_BORDER_LEFT_COLOR = $007F0000;
MASK_XF_BORDER_RIGHT_COLOR = $3F800000;
MASK_XF_BORDER_TOP_COLOR = $0000007F;
MASK_XF_BORDER_BOTTOM_COLOR = $00003F80;
MASK_XF_BORDER_DIAGONAL_COLOR = $001FC000;
{ XF CELL BACKGROUND PATTERN }
MASK_XF_BACKGROUND_PATTERN = $FC000000;
{ XF CELL BACKGROUND PATTERN }
MASK_XF_BACKGROUND_PATTERN = $FC000000;
TEXT_ROTATIONS: Array[TsTextRotation] of Byte = (
XF_ROTATION_HORIZONTAL,
XF_ROTATION_90DEG_CW,
XF_ROTATION_90DEG_CCW,
XF_ROTATION_STACKED
);
TEXT_ROTATIONS: Array[TsTextRotation] of Byte = (
XF_ROTATION_HORIZONTAL,
XF_ROTATION_90DEG_CW,
XF_ROTATION_90DEG_CCW,
XF_ROTATION_STACKED
);
type
TBIFF8DimensionsRecord = packed record
@ -794,6 +794,9 @@ procedure TsSpreadBIFF8Writer.WriteFormula(AStream: TStream; const ARow,
RPNLength: Word;
TokenArraySizePos, RecordSizePos, FinalPos: Int64;}
begin
Unused(AStream);
Unused(ARow, ACol);
Unused(AFormula, ACell);
(*
if (ARow >= FLimitations.MaxRows) or (ACol >= FLimitations.MaxCols) then
exit;
@ -1220,13 +1223,13 @@ begin
// Border line styles
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
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
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
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
XFBorderDWord1 := XFBorderDWord1 or $40000000;
if cbDiagUp in ABorders then
@ -1240,7 +1243,7 @@ begin
// Diagonal line style
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.
// Add a background, if desired

View File

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

View File

@ -170,45 +170,45 @@ uses
const
{ OOXML general XML constants }
XML_HEADER = '<?xml version="1.0" encoding="utf-8" ?>';
XML_HEADER = '<?xml version="1.0" encoding="utf-8" ?>';
{ OOXML Directory structure constants }
// Note: directory separators are always / because the .xlsx is a zip file which
// requires / instead of \, even on Windows; see
// http://www.pkware.com/documents/casestudies/APPNOTE.TXT
// 4.4.17.1 All slashes MUST be forward slashes '/' as opposed to backwards slashes '\'
OOXML_PATH_TYPES = '[Content_Types].xml';
OOXML_PATH_RELS = '_rels/';
OOXML_PATH_RELS_RELS = '_rels/.rels';
OOXML_PATH_XL = 'xl/';
OOXML_PATH_XL_RELS = 'xl/_rels/';
OOXML_PATH_XL_RELS_RELS = 'xl/_rels/workbook.xml.rels';
OOXML_PATH_XL_WORKBOOK = 'xl/workbook.xml';
OOXML_PATH_XL_STYLES = 'xl/styles.xml';
OOXML_PATH_XL_STRINGS = 'xl/sharedStrings.xml';
OOXML_PATH_XL_WORKSHEETS = 'xl/worksheets/';
OOXML_PATH_XL_THEME = 'xl/theme/theme1.xml';
OOXML_PATH_TYPES = '[Content_Types].xml';
{%H-}OOXML_PATH_RELS = '_rels/';
OOXML_PATH_RELS_RELS = '_rels/.rels';
{%H-}OOXML_PATH_XL = 'xl/';
{%H-}OOXML_PATH_XL_RELS = 'xl/_rels/';
OOXML_PATH_XL_RELS_RELS = 'xl/_rels/workbook.xml.rels';
OOXML_PATH_XL_WORKBOOK = 'xl/workbook.xml';
OOXML_PATH_XL_STYLES = 'xl/styles.xml';
OOXML_PATH_XL_STRINGS = 'xl/sharedStrings.xml';
OOXML_PATH_XL_WORKSHEETS = 'xl/worksheets/';
OOXML_PATH_XL_THEME = 'xl/theme/theme1.xml';
{ OOXML schemas constants }
SCHEMAS_TYPES = 'http://schemas.openxmlformats.org/package/2006/content-types';
SCHEMAS_RELS = 'http://schemas.openxmlformats.org/package/2006/relationships';
SCHEMAS_DOC_RELS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships';
SCHEMAS_DOCUMENT = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument';
SCHEMAS_WORKSHEET = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet';
SCHEMAS_STYLES = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles';
SCHEMAS_STRINGS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings';
SCHEMAS_SPREADML = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main';
{ OOXML schemas constants }
SCHEMAS_TYPES = 'http://schemas.openxmlformats.org/package/2006/content-types';
SCHEMAS_RELS = 'http://schemas.openxmlformats.org/package/2006/relationships';
SCHEMAS_DOC_RELS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships';
SCHEMAS_DOCUMENT = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument';
SCHEMAS_WORKSHEET = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet';
SCHEMAS_STYLES = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles';
SCHEMAS_STRINGS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings';
SCHEMAS_SPREADML = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main';
{ OOXML mime types constants }
MIME_XML = 'application/xml';
MIME_RELS = 'application/vnd.openxmlformats-package.relationships+xml';
MIME_SPREADML = 'application/vnd.openxmlformats-officedocument.spreadsheetml';
MIME_SHEET = MIME_SPREADML + '.sheet.main+xml';
MIME_WORKSHEET = MIME_SPREADML + '.worksheet+xml';
MIME_STYLES = MIME_SPREADML + '.styles+xml';
MIME_STRINGS = MIME_SPREADML + '.sharedStrings+xml';
{%H-}MIME_XML = 'application/xml';
MIME_RELS = 'application/vnd.openxmlformats-package.relationships+xml';
MIME_SPREADML = 'application/vnd.openxmlformats-officedocument.spreadsheetml';
MIME_SHEET = MIME_SPREADML + '.sheet.main+xml';
MIME_WORKSHEET = MIME_SPREADML + '.worksheet+xml';
MIME_STYLES = MIME_SPREADML + '.styles+xml';
MIME_STRINGS = MIME_SPREADML + '.sharedStrings+xml';
LAST_PALETTE_COLOR = $3F; // 63
LAST_PALETTE_COLOR = $3F; // 63
var
// the palette of the 64 default colors as "big-endian color" values
@ -1166,13 +1166,14 @@ procedure TsSpreadOOXMLReader.ReadSheetList(ANode: TDOMNode; AList: TStrings);
var
node: TDOMNode;
sheetName: String;
sheetId: String;
//sheetId: String;
begin
node := ANode.FirstChild;
while node <> nil do begin
sheetName := GetAttrValue(node, 'name');
sheetId := GetAttrValue(node, 'sheetId');
AList.AddObject(sheetName, pointer(PtrInt(StrToInt(sheetId))));
//sheetId := GetAttrValue(node, 'sheetId');
AList.Add(sheetName);
// AList.AddObject(sheetName, pointer(PtrInt(StrToInt(sheetId))));
node := node.NextSibling;
end;
end;
@ -1560,10 +1561,13 @@ end;
"FormattingStyles" which correspond to the section cellXfs of the styles.xml
file. }
function TsSpreadOOXMLWriter.GetStyleIndex(ACell: PCell): Cardinal;
var
idx: Integer;
begin
Result := FindFormattingInList(ACell);
if Result = -1 then
Result := 0;
idx := FindFormattingInList(ACell);
if idx = -1 then
idx := 0;
Result := idx;
end;
{ Creates a list of all border styles found in the workbook.