fpspreadsheet: Redo prev two commits in a more general way.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6590 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-08-11 08:24:08 +00:00
parent f10b07cd0f
commit 089a63532a
3 changed files with 128 additions and 98 deletions

View File

@ -676,7 +676,7 @@ type
TsWorkbookProtection = (bpLockRevision, bpLockStructure, bpLockWindows); TsWorkbookProtection = (bpLockRevision, bpLockStructure, bpLockWindows);
TsWorkbookProtections = set of TsWorkbookProtection; TsWorkbookProtections = set of TsWorkbookProtection;
{@@ Worksheet protection options. All selected items are locked. } {@@ Worksheet protection options. All used items are locked. }
TsWorksheetProtection = ( TsWorksheetProtection = (
spFormatCells, spFormatColumns, spFormatRows, spFormatCells, spFormatColumns, spFormatRows,
spDeleteColumns, spDeleteRows, spDeleteColumns, spDeleteRows,

View File

@ -363,6 +363,16 @@ begin
ALimitations.MaxCharsInTextCell := 32767; ALimitations.MaxCharsInTextCell := 32767;
end; end;
function StrIsTrue(s: String): boolean;
begin
Result := (s = '1') or (Lowercase(s) = 'true');
end;
function StrIsFalse(s: String): boolean;
begin
Result := (s = '0') or (Lowercase(s) = 'false');
end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TsSpreadOOXMLReader } { TsSpreadOOXMLReader }
@ -584,11 +594,11 @@ begin
nodeName := borderNode.NodeName; nodeName := borderNode.NodeName;
if nodeName = 'border' then begin if nodeName = 'border' then begin
borders := []; borders := [];
s := Lowercase(GetAttrValue(borderNode, 'diagonalUp')); s := GetAttrValue(borderNode, 'diagonalUp');
if (s = '1') or (s = 'true') then if strIsTrue(s) then
Include(borders, cbDiagUp); Include(borders, cbDiagUp);
s := LowerCase(GetAttrValue(borderNode, 'diagonalDown')); s := GetAttrValue(borderNode, 'diagonalDown');
if (s = '1') or (s = 'true') then if StrIsTrue(s) then
Include(borders, cbDiagDown); Include(borders, cbDiagDown);
edgeNode := borderNode.FirstChild; edgeNode := borderNode.FirstChild;
while Assigned(edgeNode) do begin while Assigned(edgeNode) do begin
@ -867,7 +877,7 @@ begin
// to check against "<>0" instead of "=1" // to check against "<>0" instead of "=1"
s1 := GetAttrValue(node, 'numFmtId'); s1 := GetAttrValue(node, 'numFmtId');
s2 := GetAttrValue(node, 'applyNumberFormat'); s2 := GetAttrValue(node, 'applyNumberFormat');
if (s1 <> '') and (s2 <> '0') then if (s1 <> '') and not StrIsFalse(s2) then //(s2 <> '0') and (s2 <> 'false') then
begin begin
numFmtIndex := StrToInt(s1); numFmtIndex := StrToInt(s1);
numFmtStr := NumFormatList[numFmtIndex]; numFmtStr := NumFormatList[numFmtIndex];
@ -892,8 +902,8 @@ begin
end; end;
s1 := GetAttrValue(node, 'fontId'); s1 := GetAttrValue(node, 'fontId');
s2 := GetAttrValue(node, 'applyFont'); s2 := Lowercase(GetAttrValue(node, 'applyFont'));
if (s1 <> '') and (s2 <> '0') then if (s1 <> '') and not StrIsFalse(s2) then //(s2 <> '0') and (s2 <> 'false') then
begin begin
fnt := TsFont(FFontList.Items[StrToInt(s1)]); fnt := TsFont(FFontList.Items[StrToInt(s1)]);
fmt.FontIndex := book.FindFont(fnt.FontName, fnt.Size, fnt.Style, fnt.Color, fnt.Position); fmt.FontIndex := book.FindFont(fnt.FontName, fnt.Size, fnt.Style, fnt.Color, fnt.Position);
@ -904,8 +914,8 @@ begin
end; end;
s1 := GetAttrValue(node, 'fillId'); s1 := GetAttrValue(node, 'fillId');
s2 := GetAttrValue(node, 'applyFill'); s2 := Lowercase(GetAttrValue(node, 'applyFill'));
if (s1 <> '') and (s2 <> '0') then if (s1 <> '') and not StrIsFalse(s2) then //(s2 <> '0') and (s2 <> 'false') then
begin begin
fillIndex := StrToInt(s1); fillIndex := StrToInt(s1);
fillData := TFillListData(FFillList[fillIndex]); fillData := TFillListData(FFillList[fillIndex]);
@ -923,8 +933,8 @@ begin
end; end;
s1 := GetAttrValue(node, 'borderId'); s1 := GetAttrValue(node, 'borderId');
s2 := GetAttrValue(node, 'applyBorder'); s2 := Lowercase(GetAttrValue(node, 'applyBorder'));
if (s1 <> '') and (s2 <> '0') then if (s1 <> '') and not StrIsFalse(s2) then //(s2 <> '0') and (s2 <> 'false') then
begin begin
borderIndex := StrToInt(s1); borderIndex := StrToInt(s1);
borderData := TBorderListData(FBorderList[borderIndex]); borderData := TBorderListData(FBorderList[borderIndex]);
@ -935,8 +945,9 @@ begin
end; end;
end; end;
s2 := GetAttrValue(node, 'applyAlignment'); s2 := Lowercase(GetAttrValue(node, 'applyAlignment'));
if (s2 <> '0') and (s2 <> '') then begin if StrIsTrue(s2) then // if (s2 <> '0') and (s2 <> '') and (s2 <> 'false') then
begin
childNode := node.FirstChild; childNode := node.FirstChild;
while Assigned(childNode) do begin while Assigned(childNode) do begin
nodeName := childNode.NodeName; nodeName := childNode.NodeName;
@ -965,8 +976,8 @@ begin
if (s1 = '1') or (s1 = '2') then if (s1 = '1') or (s1 = '2') then
fmt.BiDiMode := TsBiDiMode(StrToInt(s1)); fmt.BiDiMode := TsBiDiMode(StrToInt(s1));
s1 := Lowercase(GetAttrValue(childNode, 'wrapText')); s1 := GetAttrValue(childNode, 'wrapText');
if (s1 <> '') and (s1 <> '0') and (s1 <> 'false') then if StrIsTrue(s1) then //(s1 <> '') and (s1 <> '0') and (s1 <> 'false') then
Include(fmt.UsedFormattingFields, uffWordWrap); Include(fmt.UsedFormattingFields, uffWordWrap);
s1 := GetAttrValue(childNode, 'textRotation'); s1 := GetAttrValue(childNode, 'textRotation');
@ -986,8 +997,8 @@ begin
end; end;
// protection // protection
s2 := GetAttrValue(node, 'applyProtection'); s2 := Lowercase(GetAttrValue(node, 'applyProtection'));
if (s2 <> '0') and (s2 <> '') then if StrIsTrue(s2) then //(s2 <> '0') and (s2 <> '') and (s2 <> 'false') then
begin begin
cp := [cpLockCell]; cp := [cpLockCell];
childNode := node.FirstChild; childNode := node.FirstChild;
@ -995,11 +1006,11 @@ begin
nodeName := childNode.NodeName; nodeName := childNode.NodeName;
if nodeName = 'protection' then if nodeName = 'protection' then
begin begin
s1 := LowerCase(GetAttrValue(childNode, 'locked')); s1 := GetAttrValue(childNode, 'locked');
if (s1 = '0') or (s1 = 'false') then if StrIsFalse(s1) then
Exclude(cp, cpLockCell); Exclude(cp, cpLockCell);
s1 := Lowercase(GetAttrValue(childNode, 'hidden')); s1 := GetAttrValue(childNode, 'hidden');
if (s1 = '1') or (s1 = 'true') then if StrIsTrue(s1) then
Include(cp, cpHideFormulas); Include(cp, cpHideFormulas);
end; end;
childNode := childNode.NextSibling; childNode := childNode.NextSibling;
@ -1136,8 +1147,9 @@ begin
s := GetAttrValue(colNode, 'max'); s := GetAttrValue(colNode, 'max');
if s <> '' then col2 := StrToInt(s)-1 else col2 := col1; if s <> '' then col2 := StrToInt(s)-1 else col2 := col1;
s := Lowercase(GetAttrValue(colNode, 'customWidth')); s := GetAttrValue(colNode, 'customWidth');
if (s = '1') or (s = 'true') then begin if StrIsTrue(s) then //(s = '1') or (s = 'true') then
begin
s := GetAttrValue(colNode, 'width'); s := GetAttrValue(colNode, 'width');
if (s <> '') and TryStrToFloat(s, w, FPointSeparatorSettings) then if (s <> '') and TryStrToFloat(s, w, FPointSeparatorSettings) then
begin begin
@ -1223,7 +1235,8 @@ var
begin begin
if Assigned(ANode) then begin if Assigned(ANode) then begin
s := Lowercase(GetAttrValue(ANode, 'date1904')); s := Lowercase(GetAttrValue(ANode, 'date1904'));
if (s = '1') or (s = 'true') then FDateMode := dm1904 if StrIsTrue(s) then // (s = '1') or (s = 'true') then
FDateMode := dm1904
end; end;
end; end;
@ -1489,25 +1502,29 @@ begin
else else
if nodename = 'b' then if nodename = 'b' then
begin begin
if GetAttrValue(node, 'val') <> 'false' then s := GetAttrValue(node, 'val');
if (s = '') or StrIsTrue(s) then // if GetAttrValue(node, 'val') <> 'false' then
fntStyles := fntStyles + [fssBold]; fntStyles := fntStyles + [fssBold];
end end
else else
if nodename = 'i' then if nodename = 'i' then
begin begin
if GetAttrValue(node, 'val') <> 'false' then s := GetAttrValue(node, 'val');
if (s = '') or StrIsTrue(s) then // if GetAttrValue(node, 'val') <> 'false' then
fntStyles := fntStyles + [fssItalic]; fntStyles := fntStyles + [fssItalic];
end end
else else
if nodename = 'u' then if nodename = 'u' then
begin begin
if GetAttrValue(node, 'val') <> 'false' then s := GetAttrValue(node, 'val');
if (s = '') or StrIsTrue(s) then // if GetAttrValue(node, 'val') <> 'false' then
fntStyles := fntStyles+ [fssUnderline] fntStyles := fntStyles+ [fssUnderline]
end end
else else
if nodename = 'strike' then if nodename = 'strike' then
begin begin
if GetAttrValue(node, 'val') <> 'false' then s := GetAttrValue(node, 'val');
if (s = '') or StrIsTrue(s) then // if GetAttrValue(node, 'val') <> 'false' then
fntStyles := fntStyles + [fssStrikeout]; fntStyles := fntStyles + [fssStrikeout];
end end
else else
@ -1589,12 +1606,12 @@ begin
if ANode = nil then if ANode = nil then
exit; exit;
s := Lowercase(GetAttrValue(ANode, 'differentOddEven')); s := GetAttrValue(ANode, 'differentOddEven');
if (s = '1') or (s = 'true') then if StrIsTrue(s) then //(s = '1') or (s = 'true') then
with sheet.PageLayout do Options := Options + [poDifferentOddEven]; with sheet.PageLayout do Options := Options + [poDifferentOddEven];
s := Lowercase(GetAttrValue(ANode, 'differentFirst')); s := Lowercase(GetAttrValue(ANode, 'differentFirst'));
if (s = '1') or (s = 'true') then if StrIsTrue(s) then //(s = '1') or (s = 'true') then
with sheet.PageLayout do Options := Options + [poDifferentFirst]; with sheet.PageLayout do Options := Options + [poDifferentFirst];
node := ANode.FirstChild; node := ANode.FirstChild;
@ -1837,12 +1854,12 @@ begin
// Monochrome // Monochrome
s := LowerCase(GetAttrValue(ANode, 'blackAndWhite')); s := LowerCase(GetAttrValue(ANode, 'blackAndWhite'));
if (s = '1') or (s = 'true') then if StrIsTrue(s) then //(s = '1') or (s = 'true') then
with sheet.PageLayout do Options := Options + [poMonochrome]; with sheet.PageLayout do Options := Options + [poMonochrome];
// Quality // Quality
s := Lowercase(GetAttrValue(ANode, 'draft')); s := Lowercase(GetAttrValue(ANode, 'draft'));
if (s = '1') or (s = 'true') then if StrIsTrue(s) then //(s = '1') or (s = 'true') then
with sheet.PageLayout do Options := Options + [poDraftQuality]; with sheet.PageLayout do Options := Options + [poDraftQuality];
end; end;
@ -1905,11 +1922,11 @@ begin
if ANode = nil then if ANode = nil then
exit; exit;
s := Lowercase(GetAttrValue(ANode, 'headings')); s := Lowercase(GetAttrValue(ANode, 'headings'));
if (s = '1') or (s = 'true') then if StrIsTrue(s) then //(s = '1') or (s = 'true') then
with sheet.PageLayout do Options := Options + [poPrintHeaders]; with sheet.PageLayout do Options := Options + [poPrintHeaders];
s := Lowercase(GetAttrValue(ANode, 'gridLines')); s := Lowercase(GetAttrValue(ANode, 'gridLines'));
if (s = '1') or (s = 'true') then if StrIsTrue(s) then //(s = '1') or (s = 'true') then
with sheet.PageLayout do Options := Options + [poPrintGridLines]; with sheet.PageLayout do Options := Options + [poPrintGridLines];
end; end;
@ -1927,7 +1944,7 @@ begin
{ Row height type } { Row height type }
s := Lowercase(GetAttrValue(ANode, 'customHeight')); s := Lowercase(GetAttrValue(ANode, 'customHeight'));
if (s = '1') or (s = 'true') then if StrIsTrue(s) then //(s = '1') or (s = 'true') then
lRow.RowHeightType := rhtCustom lRow.RowHeightType := rhtCustom
else else
lRow.RowHeightType := rhtAuto; lRow.RowHeightType := rhtAuto;
@ -1952,7 +1969,8 @@ begin
{ Row format } { Row format }
lRow.FormatIndex := 0; // Default format lRow.FormatIndex := 0; // Default format
s := Lowercase(GetAttrValue(ANode, 'customFormat')); s := Lowercase(GetAttrValue(ANode, 'customFormat'));
if (s = '1') or (s = 'true') then begin if StrIsTrue(s) then //(s = '1') or (s = 'true') then
begin
s := GetAttrValue(ANode, 's'); s := GetAttrValue(ANode, 's');
if s <> '' then begin if s <> '' then begin
idx := FCellFormatList.FindIndexOfID(StrToInt(s)); idx := FCellFormatList.FindIndexOfID(StrToInt(s));
@ -2115,111 +2133,117 @@ begin
shp := DEFAULT_SHEET_PROTECTION; shp := DEFAULT_SHEET_PROTECTION;
// Attribute not found -> property = false // Attribute not found -> property = false
s := LowerCase(GetAttrValue(ANode, 'sheet')); s := GetAttrValue(ANode, 'sheet');
if (s = '1') or (s = 'true') then if StrIsTrue(s) then //(s = '1') or (s = 'true') then
Include(shp, spCells) Include(shp, spCells)
else if (s = '0') or (s = '') or (s = 'false') then else if (s = '') or StrIsFalse(s) then //(s = '0') or (s = '') or (s = 'false') then
Exclude(shp, spCells); Exclude(shp, spCells);
s := Lowercase(GetAttrValue(ANode, 'selectLockedCells')); s := GetAttrValue(ANode, 'selectLockedCells');
if (s = '1') or (s = 'true') then if StrIsTrue(s) then //(s = '1') or (s = 'true') then
Include(shp, spSelectLockedCells) Include(shp, spSelectLockedCells)
else if (s = '0') or (s = '') or (s = 'false') then else if (s = '') or StrIsFalse(s) then //(s = '0') or (s = '') or (s = 'false') then
Exclude(shp, spSelectLockedCells); Exclude(shp, spSelectLockedCells);
s := LowerCase(GetAttrValue(ANode, 'selectUnlockedCells')); s := GetAttrValue(ANode, 'selectUnlockedCells');
if (s = '1') or (s = 'true') then if StrIsTrue(s) then //(s = '1') or (s = 'true') then
Include(shp, spSelectUnlockedCells) Include(shp, spSelectUnlockedCells)
else if (s = '') or (s = '0') or (s = 'false') then else if (s = '') or StrIsFalse(s) then //if (s = '') or (s = '0') or (s = 'false') then
Exclude(shp, spSelectUnlockedCells); Exclude(shp, spSelectUnlockedCells);
s := Lowercase(GetAttrValue(ANode, 'objects')); s := GetAttrValue(ANode, 'objects');
if (s = '1') or (s = 'true') then if StrIsTrue(s) then // (s = '1') or (s = 'true') then
Include(shp, spObjects) Include(shp, spObjects)
else else
if (s = '') or (s = '0') or (s = 'false') then if (s = '') or StrIsFalse(s) then //(s = '') or (s = '0') or (s = 'false') then
Exclude(shp, spObjects); Exclude(shp, spObjects);
// these options are currently not supported by fpspreadsheet // these options are currently not supported by fpspreadsheet
{ {
s := GetAttrValue(ANode, 'scenarios'); s := GetAttrValue(ANode, 'scenarios');
if (s = '1') then Include(shp, spScenarios) else if StrIsTrue(s) then
if (s = '') or (s = '0') then Exclude(shp, spScenarios); Include(shp, spScenarios)
else if (s = '') or StrIsFalse(s) then
Exclude(shp, spScenarios);
} }
// Attribute not found -> property = true // Attribute not found -> property = true
{ {
s := GetAttrValue(ANode, 'autoFilter'); s := GetAttrValue(ANode, 'autoFilter');
if (s = '0') then Exclude(shp, spAutoFilter) else if StrIsFalse(s) then
if (s = '') or (s = '1') then Include(shp, spAutoFilter); Exclude(shp, spAutoFilter)
else if (s = '') or StrIsTrue(s) then
Include(shp, spAutoFilter);
} }
s := LowerCase(GetAttrValue(ANode, 'deleteColumns')); s := GetAttrValue(ANode, 'deleteColumns');
if (s = '0') or (s = 'true') then if StrIsFalse(s) then // (s = '0') or (s = 'true') then
Exclude(shp, spDeleteColumns) Exclude(shp, spDeleteColumns)
else else
if (s = '') or (s = '1') or (s = 'false') then if (s = '') or StrIsTrue(s) then // (s = '1') or (s = 'false') then
Include(shp, spDeleteColumns); Include(shp, spDeleteColumns);
s := Lowercase(GetAttrValue(ANode, 'deleteRows')); s := GetAttrValue(ANode, 'deleteRows');
if (s = '0') or (s = 'false') then if StrIsFalse(s) then //(s = '0') or (s = 'false') then
Exclude(shp, spDeleteRows) Exclude(shp, spDeleteRows)
else else
if (s = '') or (s = '1') or (s = 'true') then if (s = '') or StrIsTrue(s) then //(s = '1') or (s = 'true') then
Include(shp, spDeleteRows); Include(shp, spDeleteRows);
s := Lowercase(GetAttrValue(ANode, 'formatCells')); s := GetAttrValue(ANode, 'formatCells');
if (s = '0') or (s = 'false') then if StrIsFalse(s) then // (s = '0') or (s = 'false') then
Exclude(shp, spFormatCells) Exclude(shp, spFormatCells)
else else
if (s = '') or (s = '1') or (s = 'true') then if (s = '') or StrIsTrue(s) then //(s = '1') or (s = 'true') then
Include(shp, spFormatCells); Include(shp, spFormatCells);
s := Lowercase(GetAttrValue(ANode, 'formatColumns')); s := GetAttrValue(ANode, 'formatColumns');
if (s = '0') or (s = 'false') then if StrIsFalse(s) then //(s = '0') or (s = 'false') then
Exclude(shp, spFormatColumns) Exclude(shp, spFormatColumns)
else else
if (s = '') or (s = '1') or (s = 'true') then if (s = '') or StrIsTrue(s) then // (s = '1') or (s = 'true') then
Include(shp, spFormatColumns); Include(shp, spFormatColumns);
s := Lowercase(GetAttrValue(ANode, 'formatRows')); s := GetAttrValue(ANode, 'formatRows');
if (s = '0') or (s = 'false') then if StrIsFalse(s) then // (s = '0') or (s = 'false') then
Exclude(shp, spFormatRows) Exclude(shp, spFormatRows)
else else
if (s = '') or (s = '1') or (s = 'true') then if (s = '') or StrIsTrue(s) then // (s = '1') or (s = 'true') then
Include(shp, spFormatRows); Include(shp, spFormatRows);
s := Lowercase(GetAttrValue(ANode, 'insertColumns')); s := GetAttrValue(ANode, 'insertColumns');
if (s = '0') or (s = 'false') then if StrIsFalse(s) then // (s = '0') or (s = 'false') then
Exclude(shp, spInsertColumns) Exclude(shp, spInsertColumns)
else else
if (s = '') or (s = '1') or (s = 'true') then if (s = '') or StrIsTrue(s) then // (s = '1') or (s = 'true') then
Include(shp, spInsertColumns); Include(shp, spInsertColumns);
s := Lowercase(GetAttrValue(ANode, 'insertHyperlinks')); s := GetAttrValue(ANode, 'insertHyperlinks');
if (s = '0') or (s = 'false') then if StrIsFalse(s) then //(s = '0') or (s = 'false') then
Exclude(shp, spInsertHyperlinks) Exclude(shp, spInsertHyperlinks)
else else
if (s = '') or (s = '1') or (s = 'true') then if (s = '') or StrIsTrue(s) then //(s = '1') or (s = 'true') then
Include(shp, spInsertHyperlinks); Include(shp, spInsertHyperlinks);
s := GetAttrValue(ANode, 'insertRows'); s := GetAttrValue(ANode, 'insertRows');
if (s = '0') then Exclude(shp, spInsertRows) else if StrIsFalse(s) then // (s = '0') then
if (s = '') or (s = '1') then Include(shp, spInsertRows); Exclude(shp, spInsertRows)
else if (s = '') or StrIsTrue(s) then // (s = '1') then
Include(shp, spInsertRows);
s := Lowercase(GetAttrValue(ANode, 'sort')); s := GetAttrValue(ANode, 'sort');
if (s = '0') or (s = 'false') then if StrIsFalse(s) then // (s = '0') or (s = 'false') then
Exclude(shp, spSort) Exclude(shp, spSort)
else else
if (s = '') or (s = '1') or (s = 'true') then if (s = '') or StrIsTrue(s) then // (s = '1') or (s = 'true') then
Include(shp, spSort); Include(shp, spSort);
// Currently no pivottable support in fpspreadsheet // Currently no pivottable support in fpspreadsheet
{ {
s := Lowercase(GetAttrValue(ANode, 'pivotTables')); s := GetAttrValue(ANode, 'pivotTables');
if (s = '0') or (s = 'false') then if StrIsFalse(s) then
Exclude(shp, spPivotTables) Exclude(shp, spPivotTables)
else if (s = '') or (s = '1') or (s = 'true') then else if (s = '') or StrIsTrue(s) then
Include(shp, spPivotTables); Include(shp, spPivotTables);
} }
@ -2246,20 +2270,20 @@ begin
while Assigned(sheetViewNode) do begin while Assigned(sheetViewNode) do begin
nodeName := sheetViewNode.NodeName; nodeName := sheetViewNode.NodeName;
if nodeName = 'sheetView' then begin if nodeName = 'sheetView' then begin
s := Lowercase(GetAttrValue(sheetViewNode, 'showGridLines')); s := GetAttrValue(sheetViewNode, 'showGridLines');
if (s = '0') or (s = 'false') then if StrIsFalse(s) then //(s = '0') or (s = 'false') then
sheet.Options := AWorksheet.Options - [soShowGridLines]; sheet.Options := AWorksheet.Options - [soShowGridLines];
s := LowerCase(GetAttrValue(sheetViewNode, 'showRowColHeaders')); s := GetAttrValue(sheetViewNode, 'showRowColHeaders');
if (s = '0') or (s = 'false') then if StrIsFalse(s) then //(s = '0') or (s = 'false') then
sheet.Options := AWorksheet.Options - [soShowHeaders]; sheet.Options := AWorksheet.Options - [soShowHeaders];
s := Lowercase(GetAttrValue(sheetViewNode, 'tabSelected')); s := GetAttrValue(sheetViewNode, 'tabSelected');
if (s = '1') or (s = 'false') then if StrIsTrue(s) then //(s = '1') or (s = 'true') then
(FWorkbook as TsWorkbook).ActiveWorksheet := sheet; (FWorkbook as TsWorkbook).ActiveWorksheet := sheet;
s := Lowercase(GetAttrValue(sheetViewNode, 'windowProtection')); s := Lowercase(GetAttrValue(sheetViewNode, 'windowProtection'));
if (s = '1') or (s = 'true') then if StrIsTrue(s) then //(s = '1') or (s = 'true') then
sheet.Options := sheet.Options + [soPanesProtection]; sheet.Options := sheet.Options + [soPanesProtection];
s := GetAttrValue(sheetViewNode, 'zoomScale'); s := GetAttrValue(sheetViewNode, 'zoomScale');
@ -2267,9 +2291,9 @@ begin
sheet.ZoomFactor := StrToFloat(s, FPointSeparatorSettings) * 0.01; sheet.ZoomFactor := StrToFloat(s, FPointSeparatorSettings) * 0.01;
s := Lowercase(GetAttrValue(sheetViewNode, 'rightToLeft')); s := Lowercase(GetAttrValue(sheetViewNode, 'rightToLeft'));
if (s = '0') or (s = 'false') then if (s = '') or StrIsFalse(s) then //(s = '0') or (s = 'false') then
sheet.BiDiMode := bdLTR sheet.BiDiMode := bdLTR
else if (s = '1') or (s = 'true') then else if StrIsTrue(s) then //(s = '1') or (s = 'true') then
sheet.BiDiMode := bdRTL; sheet.BiDiMode := bdRTL;
childNode := sheetViewNode.FirstChild; childNode := sheetViewNode.FirstChild;
@ -2429,16 +2453,16 @@ begin
end; end;
Workbook.RevisionsCrypto := wbc; Workbook.RevisionsCrypto := wbc;
} }
s := Lowercase(GetAttrValue(ANode, 'lockStructure')); s := GetAttrValue(ANode, 'lockStructure');
if (s = '1') or (s = 'true')then if StrIsTrue(s) then // (s = '1') or (s = 'true')then
Include(wbp, bpLockStructure); Include(wbp, bpLockStructure);
s := Lowercase(GetAttrValue(ANode, 'lockWindows')); s := GetAttrValue(ANode, 'lockWindows');
if (s = '1') or (s = 'true') then if StrIsTrue(s) then //(s = '1') or (s = 'true') then
Include(wbp, bpLockWindows); Include(wbp, bpLockWindows);
s := Lowercase(GetAttrValue(ANode, 'lockRevision')); s := GetAttrValue(ANode, 'lockRevision');
if (s = '1') or (s = 'true') then if StrIsTrue(s) then //(s = '1') or (s = 'true') then
Include(wbp, bpLockRevision); Include(wbp, bpLockRevision);
Workbook.Protection := wbp; Workbook.Protection := wbp;

View File

@ -116,6 +116,7 @@ type
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
procedure ExecuteTarget(Target: TObject); override; procedure ExecuteTarget(Target: TObject); override;
procedure UpdateTarget(Target: TObject); override;
published published
property Zoom: Integer read FZoom write SetZoom default 100; property Zoom: Integer read FZoom write SetZoom default 100;
end; end;
@ -880,6 +881,11 @@ begin
FZoom := AValue; FZoom := AValue;
end; end;
procedure TsWorksheetZoomAction.UpdateTarget(Target: TObject);
begin
Checked := (Worksheet <> nil) and (round(Worksheet.ZoomFactor*100) = FZoom);
end;
{ TsCopyAction } { TsCopyAction }