diff --git a/components/fpspreadsheet/source/common/fpsopendocument.pas b/components/fpspreadsheet/source/common/fpsopendocument.pas index 8f33377a0..71c8d000a 100644 --- a/components/fpspreadsheet/source/common/fpsopendocument.pas +++ b/components/fpspreadsheet/source/common/fpsopendocument.pas @@ -273,6 +273,7 @@ type function WriteHorAlignmentStyleXMLAsString(const AFormat: TsCellFormat): String; function WriteNumFormatStyleXMLAsString(const AFormat: TsCellFormat): String; function WritePageLayoutXMLAsString(AStyleName: String; const APageLayout: TsPageLayout): String; + function WritePrintContentStyleXMLAsString(const AFormat: TsCellFormat): String; function WritePrintRangesXMLAsString(ASheet: TsBasicWorksheet): String; function WriteSheetProtectionXMLAsString(ASheet: TsBasicWorksheet): String; function WriteSheetProtectionDetailsXMLAsString(ASheet: TsBasicWorksheet): String; @@ -5349,6 +5350,11 @@ begin // formulas... if AFormat.Protection <> DEFAULT_CELL_PROTECTION then Include(AFormat.UsedFormattingFields, uffProtection); + + // Disable cell printing + s := GetAttrValue(ANode, 'style:print-content'); + if s = 'false' then + Include(AFormat.UsedFormattingFields, uffDoNotPrint); end; procedure TsSpreadOpenDocReader.ReadStyle_TextProperties(ANode: TDOMNode; @@ -6348,7 +6354,8 @@ begin WriteBackgroundColorStyleXMLAsString(AFormat) + WriteWordwrapStyleXMLAsString(AFormat) + WriteTextRotationStyleXMLAsString(AFormat) + - WriteVertAlignmentStyleXMLAsString(AFormat); + WriteVertAlignmentStyleXMLAsString(AFormat) + + WritePrintContentStyleXMLAsString(AFormat); if addProtection then s := s + WriteCellProtectionStyleXMLAsString(AFormat); if s <> '' then @@ -7323,6 +7330,15 @@ begin end; +function TsSpreadOpenDocWriter.WritePrintContentStyleXMLAsString( + const AFormat: TsCellFormat): String; +begin + if (uffDoNotPrint in AFormat.UsedFormattingFields) then + Result := 'style:print-content="false"' + else + Result := ''; +end; + procedure TsSpreadOpenDocWriter.WriteRowsAndCells(AStream: TStream; ASheet: TsBasicWorksheet); var diff --git a/components/fpspreadsheet/source/common/fpspreadsheet.pas b/components/fpspreadsheet/source/common/fpspreadsheet.pas index 66aec1c26..26b4b1bb3 100644 --- a/components/fpspreadsheet/source/common/fpspreadsheet.pas +++ b/components/fpspreadsheet/source/common/fpspreadsheet.pas @@ -188,6 +188,7 @@ type function ReadWordwrap(ACell: PCell): boolean; function ReadBiDiMode(ACell: PCell): TsBiDiMode; function ReadCellProtection(ACell: PCell): TsCellProtections; + function ReadDoNotPrintCell(ACell: PCell): Boolean; function IsEmpty: Boolean; @@ -379,6 +380,9 @@ type procedure WriteCellProtection(ACell: PCell; AValue: TsCellProtections); overload; + function WriteDoNotPrintCell(ARow, ACol: Cardinal; AValue: boolean): PCell; overload; + procedure WriteDoNotPrintCell(ACell: PCell; AValue: Boolean); overload; + { Conditional formatting } // cell-related comparisons diff --git a/components/fpspreadsheet/source/common/fpspreadsheet_fmt.inc b/components/fpspreadsheet/source/common/fpspreadsheet_fmt.inc index 1863f8c84..21d04e307 100644 --- a/components/fpspreadsheet/source/common/fpspreadsheet_fmt.inc +++ b/components/fpspreadsheet/source/common/fpspreadsheet_fmt.inc @@ -194,6 +194,20 @@ begin end; end; +{@@ ---------------------------------------------------------------------------- + Returns whether the cell is not allowed to be printed. +-------------------------------------------------------------------------------} +function TsWorksheet.ReadDoNotPrintCell(ACell: PCell): Boolean; +var + fmt: PsCellFormat; +begin + Result := false; + if ACell <> nil then + begin + fmt := Workbook.GetPointerToCellFormat(ACell^.FormatIndex); + Result := uffDoNotPrint in fmt.UsedFormattingFields; + end; +end; {@@ ---------------------------------------------------------------------------- Returns the horizontal alignment of a specific cell @@ -720,6 +734,28 @@ begin ChangedCell(ACell^.Row, ACell^.Col); end; +function TsWorksheet.WriteDoNotPrintCell(ARow, ACol: Cardinal; + AValue: boolean): PCell; +begin + Result := GetCell(ARow, ACol); + WriteDoNotPrintCell(Result, AValue); +end; + +procedure TsWorksheet.WriteDoNotPrintCell(ACell: PCell; AValue: Boolean); +var + fmt: TsCellFormat; +begin + if ACell = nil then + exit; + fmt := Workbook.GetCellFormat(ACell^.FormatIndex); + if AValue then + Include(fmt.UsedFormattingfields, uffDoNotPrint) + else + Exclude(fmt.UsedFormattingFields, uffDoNotPrint); + ACell^.FormatIndex := Workbook.AddCellFormat(fmt); + ChangedCell(ACell^.Row, ACell^.Col); +end; + {@@ ---------------------------------------------------------------------------- Defines the horizontal alignment of text in a cell. diff --git a/components/fpspreadsheet/source/common/fpstypes.pas b/components/fpspreadsheet/source/common/fpstypes.pas index 2c863dcd8..f3f3d5e5b 100644 --- a/components/fpspreadsheet/source/common/fpstypes.pas +++ b/components/fpspreadsheet/source/common/fpstypes.pas @@ -421,10 +421,11 @@ type @value uffHorAlign The cell format supports horizontal text alignment. @value uffVertAlign The cell format supports vertical text alignment @value uffBiDi The cell format supports right-to-left text display. - @value uffProtection The cell format supports locking of cells. } + @value uffProtection The cell format supports locking of cells. + @value uffDoNotPrint The cell is not printed. } TsUsedFormattingField = (uffTextRotation, uffFont, uffBorder, uffBackground, uffNumberFormat, uffWordWrap, uffHorAlign, uffVertAlign, uffBiDi, - uffProtection + uffProtection, uffDoNotPrint ); { NOTE: "uffBackgroundColor" of older versions replaced by "uffBackground" }