You've already forked lazarus-ccr
fpspreadsheet: Write row/column hidden flag to XLSX, BIFF8 and BIFF2
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6632 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -3904,6 +3904,7 @@ var
|
|||||||
rec: TColRecord;
|
rec: TColRecord;
|
||||||
w: Integer;
|
w: Integer;
|
||||||
width: Single;
|
width: Single;
|
||||||
|
optn: Word;
|
||||||
begin
|
begin
|
||||||
if Assigned(ACol) then
|
if Assigned(ACol) then
|
||||||
begin
|
begin
|
||||||
@ -3927,9 +3928,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
w := round(width * 256);
|
w := round(width * 256);
|
||||||
|
|
||||||
|
optn := 0;
|
||||||
|
if ACol^.Hidden then optn := optn + $0001;
|
||||||
|
// outline, collapsed flags are not used
|
||||||
|
|
||||||
rec.ColWidth := WordToLE(w);
|
rec.ColWidth := WordToLE(w);
|
||||||
rec.XFIndex := WordToLE(FindXFIndex(ACol^.FormatIndex)); // Index of XF record
|
rec.XFIndex := WordToLE(FindXFIndex(ACol^.FormatIndex)); // Index of XF record
|
||||||
rec.OptionFlags := 0; // hidden, outline, collapsed flags are not used
|
rec.OptionFlags := WordToLE(optn);
|
||||||
rec.NotUsed := 0;
|
rec.NotUsed := 0;
|
||||||
|
|
||||||
{ Write out }
|
{ Write out }
|
||||||
@ -4787,6 +4792,7 @@ begin
|
|||||||
|
|
||||||
{ Option flags }
|
{ Option flags }
|
||||||
dw := $00000100; // bit 8 is always 1
|
dw := $00000100; // bit 8 is always 1
|
||||||
|
if Assigned(ARow) and ARow^.Hidden then dw := dw or $00000020;
|
||||||
if spaceabove then dw := dw or $10000000;
|
if spaceabove then dw := dw or $10000000;
|
||||||
if spacebelow then dw := dw or $20000000;
|
if spacebelow then dw := dw or $20000000;
|
||||||
if (ARow <> nil) and (ARow^.RowHeightType = rhtCustom) then // Custom row height
|
if (ARow <> nil) and (ARow^.RowHeightType = rhtCustom) then // Custom row height
|
||||||
|
@ -2985,6 +2985,7 @@ var
|
|||||||
customWidth: String;
|
customWidth: String;
|
||||||
customStyle: String;
|
customStyle: String;
|
||||||
sheet: TsWorksheet absolute AWorksheet;
|
sheet: TsWorksheet absolute AWorksheet;
|
||||||
|
hiddenStr: String;
|
||||||
begin
|
begin
|
||||||
AppendToStream(AStream,
|
AppendToStream(AStream,
|
||||||
'<cols>');
|
'<cols>');
|
||||||
@ -2996,6 +2997,7 @@ begin
|
|||||||
|
|
||||||
// The column width is needed in suChars here.
|
// The column width is needed in suChars here.
|
||||||
w := sheet.ReadDefaultColWidth(suChars);
|
w := sheet.ReadDefaultColWidth(suChars);
|
||||||
|
hiddenStr := '';
|
||||||
if lCol <> nil then begin
|
if lCol <> nil then begin
|
||||||
if lCol^.ColWidthType = cwtCustom then begin
|
if lCol^.ColWidthType = cwtCustom then begin
|
||||||
w := (FWorkbook as TsWorkbook).ConvertUnits(lCol^.Width, FWorkbook.Units, suChars);
|
w := (FWorkbook as TsWorkbook).ConvertUnits(lCol^.Width, FWorkbook.Units, suChars);
|
||||||
@ -3003,10 +3005,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
if lCol^.FormatIndex > 0 then
|
if lCol^.FormatIndex > 0 then
|
||||||
customStyle := Format('style="%d" ', [lCol^.FormatIndex]);
|
customStyle := Format('style="%d" ', [lCol^.FormatIndex]);
|
||||||
|
if lCol^.Hidden then hiddenStr := ' hidden="1"';
|
||||||
end;
|
end;
|
||||||
AppendToStream(AStream, Format(
|
AppendToStream(AStream, Format(
|
||||||
'<col min="%d" max="%d" width="%.2f" %s%s />',
|
'<col min="%d" max="%d" width="%.2f" %s%s%s />',
|
||||||
[c+1, c+1, w, customWidth, customStyle], FPointSeparatorSettings)
|
[c+1, c+1, w, customWidth, customStyle, hiddenStr], FPointSeparatorSettings)
|
||||||
);
|
);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3457,6 +3460,8 @@ begin
|
|||||||
s := s + ' customHeight="1"';
|
s := s + ' customHeight="1"';
|
||||||
if row^.FormatIndex > 0 then
|
if row^.FormatIndex > 0 then
|
||||||
s := s + Format(' s="%d" customFormat="1"', [row^.FormatIndex]);
|
s := s + Format(' s="%d" customFormat="1"', [row^.FormatIndex]);
|
||||||
|
if row^.Hidden then
|
||||||
|
s := s + ' hidden="1"';
|
||||||
end;
|
end;
|
||||||
AppendToStream(AStream, Format(
|
AppendToStream(AStream, Format(
|
||||||
'<row r="%d" spans="1:%d"%s>', [r+1, sheet.VirtualColCount, s]));
|
'<row r="%d" spans="1:%d"%s>', [r+1, sheet.VirtualColCount, s]));
|
||||||
@ -3522,6 +3527,8 @@ begin
|
|||||||
s := s + ' customHeight="1"';
|
s := s + ' customHeight="1"';
|
||||||
if row^.FormatIndex > 0 then
|
if row^.FormatIndex > 0 then
|
||||||
s := s + Format(' s="%d" customFormat="1"', [row^.FormatIndex]);
|
s := s + Format(' s="%d" customFormat="1"', [row^.FormatIndex]);
|
||||||
|
if row^.Hidden then
|
||||||
|
s := s + ' hidden="1"';
|
||||||
end;
|
end;
|
||||||
AppendToStream(AStream, Format(
|
AppendToStream(AStream, Format(
|
||||||
'<row r="%d" spans="%d:%d"%s>', [r+1, c1+1, c2+1, s]));
|
'<row r="%d" spans="%d:%d"%s>', [r+1, c1+1, c2+1, s]));
|
||||||
|
@ -1444,12 +1444,15 @@ end;
|
|||||||
has occured at the border of a row header. Sets optimum row height.
|
has occured at the border of a row header. Sets optimum row height.
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
procedure TsCustomWorksheetGrid.AutoAdjustRow(ARow: Integer);
|
procedure TsCustomWorksheetGrid.AutoAdjustRow(ARow: Integer);
|
||||||
|
var
|
||||||
|
h: Integer;
|
||||||
begin
|
begin
|
||||||
inc(FZoomLock);
|
inc(FZoomLock);
|
||||||
if Worksheet <> nil then
|
if Worksheet <> nil then
|
||||||
RowHeights[ARow] := CalcAutoRowHeight(ARow)
|
h := CalcAutoRowHeight(ARow)
|
||||||
else
|
else
|
||||||
RowHeights[ARow] := DefaultRowHeight;
|
h := -1;
|
||||||
|
RowHeights[ARow] := IfThen(h > -1, h, DefaultRowHeight);
|
||||||
HeaderSized(false, ARow);
|
HeaderSized(false, ARow);
|
||||||
dec(FZoomLock);
|
dec(FZoomLock);
|
||||||
end;
|
end;
|
||||||
@ -1521,15 +1524,10 @@ end;
|
|||||||
function TsCustomWorksheetGrid.CalcAutoRowHeight(ARow: Integer): Integer;
|
function TsCustomWorksheetGrid.CalcAutoRowHeight(ARow: Integer): Integer;
|
||||||
var
|
var
|
||||||
c: Integer;
|
c: Integer;
|
||||||
h: Integer;
|
|
||||||
begin
|
begin
|
||||||
h := 0;
|
Result := -1;
|
||||||
for c := FHeaderCount to ColCount-1 do
|
for c := FHeaderCount to ColCount-1 do
|
||||||
h := Max(h, GetCellHeight(c, ARow)); // Zoom factor is applied to font size
|
Result := Max(Result, GetCellHeight(c, ARow)); // Zoom factor is applied to font size
|
||||||
if h = 0 then
|
|
||||||
Result := DefaultRowHeight // Zoom factor applied by getter function
|
|
||||||
else
|
|
||||||
Result := h;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
@ -1815,6 +1813,7 @@ procedure TsCustomWorksheetGrid.ChangedFontHandler(ASender: TObject;
|
|||||||
var
|
var
|
||||||
lRow: PRow;
|
lRow: PRow;
|
||||||
gr: Integer; // row index in grid units
|
gr: Integer; // row index in grid units
|
||||||
|
h: Integer;
|
||||||
begin
|
begin
|
||||||
Unused(ASender, ACol);
|
Unused(ASender, ACol);
|
||||||
if (Worksheet <> nil) then begin
|
if (Worksheet <> nil) then begin
|
||||||
@ -1823,7 +1822,8 @@ begin
|
|||||||
// There is no row record --> row height changes according to font height
|
// There is no row record --> row height changes according to font height
|
||||||
// Otherwise the row height would be fixed according to the value in the row record.
|
// Otherwise the row height would be fixed according to the value in the row record.
|
||||||
gr := GetGridRow(ARow); // convert row index to grid units
|
gr := GetGridRow(ARow); // convert row index to grid units
|
||||||
RowHeights[gr] := CalcAutoRowHeight(gr);
|
h := CalcAutoRowHeight(gr);
|
||||||
|
RowHeights[gr] := IfThen(h > -1, h, DefaultRowHeight);
|
||||||
end;
|
end;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
@ -3745,7 +3745,7 @@ var
|
|||||||
txtRot: TsTextRotation;
|
txtRot: TsTextRotation;
|
||||||
RTL: Boolean;
|
RTL: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := -1;
|
||||||
if (ACol < FHeaderCount) or (ARow < FHeaderCount) then
|
if (ACol < FHeaderCount) or (ARow < FHeaderCount) then
|
||||||
exit;
|
exit;
|
||||||
if Worksheet = nil then
|
if Worksheet = nil then
|
||||||
@ -5777,11 +5777,11 @@ begin
|
|||||||
if (lRow <> nil) then begin
|
if (lRow <> nil) then begin
|
||||||
case lRow^.RowHeightType of
|
case lRow^.RowHeightType of
|
||||||
rhtCustom:
|
rhtCustom:
|
||||||
begin
|
if lRow^.Height > 0 then begin
|
||||||
h := round(CalcRowHeightFromSheet(lRow^.Height) * ZoomFactor);
|
h := round(CalcRowHeightFromSheet(lRow^.Height) * ZoomFactor);
|
||||||
if AEnforceCalcRowHeight then begin
|
if AEnforceCalcRowHeight then begin
|
||||||
h := CalcAutoRowHeight(ARow);
|
h := CalcAutoRowHeight(ARow);
|
||||||
if h = 0 then begin
|
if h = -1 then begin
|
||||||
h := DefaultRowHeight;
|
h := DefaultRowHeight;
|
||||||
lRow^.RowHeightType := rhtDefault;
|
lRow^.RowHeightType := rhtDefault;
|
||||||
end else
|
end else
|
||||||
@ -5795,7 +5795,7 @@ begin
|
|||||||
if doCalcRowHeight then begin
|
if doCalcRowHeight then begin
|
||||||
// Calculate current grid row height in pixels by iterating over all cells in row
|
// Calculate current grid row height in pixels by iterating over all cells in row
|
||||||
h := CalcAutoRowHeight(ARow); // ZoomFactor already applied to font heights
|
h := CalcAutoRowHeight(ARow); // ZoomFactor already applied to font heights
|
||||||
if h = 0 then begin
|
if h = -1 then begin
|
||||||
h := DefaultRowHeight; // Zoom factor applied by getter function
|
h := DefaultRowHeight; // Zoom factor applied by getter function
|
||||||
lRow^.RowHeightType := rhtDefault;
|
lRow^.RowHeightType := rhtDefault;
|
||||||
end else
|
end else
|
||||||
@ -5817,8 +5817,10 @@ begin
|
|||||||
begin
|
begin
|
||||||
// Case 1: This row does contain cells
|
// Case 1: This row does contain cells
|
||||||
lRow := Worksheet.AddRow(sr);
|
lRow := Worksheet.AddRow(sr);
|
||||||
|
h := -1;
|
||||||
if AEnforceCalcRowHeight then
|
if AEnforceCalcRowHeight then
|
||||||
h := CalcAutoRowHeight(ARow) else
|
h := CalcAutoRowHeight(ARow);
|
||||||
|
if h = -1 then
|
||||||
h := DefaultRowHeight;
|
h := DefaultRowHeight;
|
||||||
lRow^.Height := CalcRowHeightToSheet(round(h / ZoomFactor));
|
lRow^.Height := CalcRowHeightToSheet(round(h / ZoomFactor));
|
||||||
if h <> DefaultRowHeight then
|
if h <> DefaultRowHeight then
|
||||||
@ -5830,7 +5832,7 @@ begin
|
|||||||
h := DefaultRowHeight; // Zoom factor is applied by getter function
|
h := DefaultRowHeight; // Zoom factor is applied by getter function
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if h = 0 then
|
if h = -1 then
|
||||||
h := DefaultRowHeight; // Zoom factor is applied by getter function
|
h := DefaultRowHeight; // Zoom factor is applied by getter function
|
||||||
|
|
||||||
inc(FZoomLock); // We don't want to modify the sheet row heights here.
|
inc(FZoomLock); // We don't want to modify the sheet row heights here.
|
||||||
|
Reference in New Issue
Block a user