fpspreadsheet: Add conditional define FPS_CHARTS (active by default) to compile the lib with and without chart support.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9108 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
ccea3cb07d
commit
4f0e2e8b83
@ -26,14 +26,16 @@ unit fpsOpenDocument;
|
||||
{$mode objfpc}{$H+}
|
||||
{$include ..\fps.inc}
|
||||
|
||||
{$define DEBUG_CHART_STYLES}
|
||||
{$IFDEF FPS_CHARTS}
|
||||
{$define DEBUG_CHART_STYLES}
|
||||
{$ENDIF}
|
||||
|
||||
{$WARN 6058 off : Call to subroutine "$1" marked as inline is not inlined}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF DEBUG_CHART_STYLES}
|
||||
{$IF DEFINED(DEBUG_CHART_STYLES) or DEFINED(FPSpreadDebug)}
|
||||
LazLoggerBase,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils,
|
||||
@ -44,8 +46,12 @@ uses
|
||||
{$ELSE}
|
||||
fpszipper,
|
||||
{$ENDIF}
|
||||
fpstypes, fpsReaderWriter, fpsutils, fpsHeaderFooterParser,
|
||||
fpsNumFormat, fpsxmlcommon, fpsPagelayout, fpsChart;
|
||||
fpstypes, fpsReaderWriter, fpsUtils, fpsHeaderFooterParser,
|
||||
fpsNumFormat, fpsXMLCommon,
|
||||
{$IFDEF FPS_CHARTS}
|
||||
fpsChart,
|
||||
{$ENDIF}
|
||||
fpsPagelayout;
|
||||
|
||||
type
|
||||
TDateModeODS=(
|
||||
@ -124,14 +130,18 @@ type
|
||||
FRepeatedRows: TsRowColRange;
|
||||
FManifestFileEntries: TFPList;
|
||||
|
||||
{$IFDEF FPS_CHARTS}
|
||||
FChartReader: TsBasicSpreadChartReader;
|
||||
{$ENDIF}
|
||||
|
||||
procedure ApplyColData;
|
||||
procedure ApplyStyleToCell(ACell: PCell; AStyleIndex: Integer);
|
||||
function ApplyStyleToCell(ACell: PCell; AStyleName: String): Boolean;
|
||||
function ApplyTableStyle(ASheet: TsBasicWorksheet;
|
||||
AStyleName: String): Boolean;
|
||||
{$IFDEF FPS_CHARTS}
|
||||
function CollectChartFilesFromManifest: Boolean;
|
||||
{$ENDIF}
|
||||
function ExtractBoolFromNode(ANode: TDOMNode): Boolean;
|
||||
function ExtractDateTimeFromNode(ANode: TDOMNode;
|
||||
ANumFormat: TsNumberFormat; const AFormatStr: String): TDateTime;
|
||||
@ -244,8 +254,9 @@ type
|
||||
FHeaderFooterFontList: TObjectList;
|
||||
FHasColFormats: Boolean;
|
||||
FHasRowFormats: Boolean;
|
||||
|
||||
{$IFDEF FPS_CHARTS}
|
||||
FChartWriter: TsBasicSpreadChartWriter;
|
||||
{$ENDIF}
|
||||
|
||||
// Routines to write parts of files
|
||||
procedure WriteAutomaticStyles(AStream: TStream);
|
||||
@ -372,13 +383,14 @@ var
|
||||
implementation
|
||||
|
||||
uses
|
||||
{$IFDEF FPSpreadDebug}
|
||||
LazLogger,
|
||||
{$ENDIF}
|
||||
StrUtils, Variants, LazFileUtils, URIParser, LazUTF8,
|
||||
{%H-}fpsPatches,
|
||||
fpsStrings, fpsStreams, fpsCrypto, fpsClasses, fpSpreadsheet,
|
||||
fpsExprParser, fpsImages, fpsConditionalFormat, fpsOpenDocumentChart;
|
||||
fpsExprParser, fpsImages,
|
||||
{$IFDEF FPS_CHARTS}
|
||||
fpsOpenDocumentChart,
|
||||
{$ENDIF}
|
||||
fpsConditionalFormat;
|
||||
|
||||
const
|
||||
LE = LineEnding;
|
||||
@ -391,10 +403,10 @@ const
|
||||
OPENDOC_PATH_SETTINGS = 'settings.xml';
|
||||
OPENDOC_PATH_STYLES = 'styles.xml';
|
||||
OPENDOC_PATH_MIMETYPE = 'mimetype';
|
||||
{%H-}OPENDOC_PATH_METAINF = 'META-INF/';
|
||||
{%H-}OPENDOC_PATH_METAINF = 'META-INF/';
|
||||
OPENDOC_PATH_METAINF_MANIFEST = 'META-INF/manifest.xml';
|
||||
OPENDOC_PATH_CHART_CONTENT = 'Object %d/content.xml';
|
||||
OPENDOC_PATH_CHART_STYLES = 'Object %d/styles.xml';
|
||||
OPENDOC_PATH_CHART_CONTENT = 'Object %d/content.xml';
|
||||
OPENDOC_PATH_CHART_STYLES = 'Object %d/styles.xml';
|
||||
|
||||
{ OpenDocument schemas constants }
|
||||
SCHEMAS_XMLNS_OFFICE = 'urn:oasis:names:tc:opendocument:xmlns:office:1.0';
|
||||
@ -1216,7 +1228,9 @@ constructor TsSpreadOpenDocReader.Create(AWorkbook: TsBasicWorkbook);
|
||||
begin
|
||||
inherited Create(AWorkbook);
|
||||
|
||||
{$IFDEF FPS_CHARTS}
|
||||
FChartReader := TsSpreadOpenDocChartReader.Create(self);
|
||||
{$ENDIF}
|
||||
|
||||
InitOpenDocLimitations(FLimitations);
|
||||
|
||||
@ -1283,7 +1297,9 @@ begin
|
||||
|
||||
FHeaderFooterFontList.Free;
|
||||
|
||||
{$IFDEF FPS_CHARTS}
|
||||
FChartReader.Free;
|
||||
{$ENDIF}
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
@ -1485,6 +1501,7 @@ begin
|
||||
Result := true;
|
||||
end;
|
||||
|
||||
{$IFDEF FPS_CHARTS}
|
||||
{ Searches the manifest file entries for the names of files needed by charts.
|
||||
Returns false if there no charts are found.
|
||||
The found filenames are passed over to the chart reader for further processing. }
|
||||
@ -1532,6 +1549,7 @@ begin
|
||||
FileList.Free;
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
{ Extracts a boolean value from a "boolean" cell node.
|
||||
Is called from ReadBoolean }
|
||||
@ -3178,9 +3196,11 @@ begin
|
||||
XMLStream.Free;
|
||||
end;
|
||||
|
||||
{$IFDEF FPS_CHARTS}
|
||||
// Reading of charts
|
||||
if CollectChartFilesFromManifest then
|
||||
FChartReader.ReadCharts(AStream);
|
||||
{$ENDIF}
|
||||
|
||||
// Active sheet
|
||||
if FActiveSheet <> '' then
|
||||
@ -4996,8 +5016,10 @@ procedure TsSpreadOpenDocReader.ReadShape(ANode: TDOMNode;
|
||||
href: String;
|
||||
img: PsImage;
|
||||
entry: TsOpenDocManifestFileEntry;
|
||||
chart: TsChart;
|
||||
handled: Boolean;
|
||||
{$IFDEF FPS_CHARTS}
|
||||
chart: TsChart;
|
||||
{$ENDIF}
|
||||
begin
|
||||
nodeName := ANode.NodeName;
|
||||
x := PtsToMM(HTMLLengthStrToPts(GetAttrValue(ANode, 'svg:x')));
|
||||
@ -5011,6 +5033,7 @@ procedure TsSpreadOpenDocReader.ReadShape(ANode: TDOMNode;
|
||||
href := GetAttrValue(childNode, 'xlink:href');
|
||||
if href <> '' then
|
||||
begin
|
||||
{$IFDEF FPS_CHARTS}
|
||||
if nodeName = 'draw:object' then
|
||||
begin
|
||||
// Is it a chart?
|
||||
@ -5032,6 +5055,7 @@ procedure TsSpreadOpenDocReader.ReadShape(ANode: TDOMNode;
|
||||
Continue;
|
||||
end;
|
||||
end else
|
||||
{$ENDIF}
|
||||
if nodeName = 'draw:image' then
|
||||
begin
|
||||
// It is an embedded image.
|
||||
@ -5806,14 +5830,18 @@ begin
|
||||
FSContent := CreateTempStream(FWorkbook, 'fpsC');
|
||||
FSMimeType := CreateTempStream(FWorkbook, 'fpsMT');
|
||||
FSMetaInfManifest := CreateTempStream(FWorkbook, 'fpsMIM');
|
||||
{$IFDEF FPS_CHARTS}
|
||||
FChartWriter.CreateStreams;
|
||||
{$ENDIF}
|
||||
// FSSheets will be created when needed.
|
||||
end;
|
||||
|
||||
{ Destroys the temporary streams that were created by the writer }
|
||||
procedure TsSpreadOpenDocWriter.DestroyStreams;
|
||||
begin
|
||||
{$IFDEF FPS_CHARTS}
|
||||
FChartWriter.DestroyStreams;
|
||||
{$ENDIF}
|
||||
DestroyTempStream(FSMeta);
|
||||
DestroyTempStream(FSSettings);
|
||||
DestroyTempStream(FSStyles);
|
||||
@ -5918,7 +5946,9 @@ begin
|
||||
WriteSettings();
|
||||
WriteStyles();
|
||||
WriteContent;
|
||||
{$IFDEF FPS_CHARTS}
|
||||
FChartWriter.WriteCharts;
|
||||
{$ENDIF}
|
||||
|
||||
{ Now compress the files }
|
||||
FZip := TZipper.Create;
|
||||
@ -5931,7 +5961,9 @@ begin
|
||||
FZip.Entries.AddFileEntry(FSMimetype, OPENDOC_PATH_MIMETYPE);
|
||||
FZip.Entries.AddFileEntry(FSMetaInfManifest, OPENDOC_PATH_METAINF_MANIFEST);
|
||||
ZipPictures(FZip);
|
||||
{$IFDEF FPS_CHARTS}
|
||||
TsSpreadOpenDocChartWriter(FChartWriter).AddChartsToZip(FZip);
|
||||
{$ENDIF}
|
||||
|
||||
ResetStreams;
|
||||
|
||||
@ -6128,7 +6160,9 @@ begin
|
||||
FSContent.Position := 0;
|
||||
FSMimeType.Position := 0;
|
||||
FSMetaInfManifest.Position := 0;
|
||||
{$IFDEF FPS_CHARTS}
|
||||
FChartWriter.ResetStreams;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{ Writes the node "office:automatic-styles". Although this node occurs in both
|
||||
@ -6237,7 +6271,9 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{$IFDEF FPS_CHARTS}
|
||||
TsSpreadOpenDocChartWriter(FChartWriter).AddToMetaInfManifest(FSMetaInfManifest);
|
||||
{$ENDIF}
|
||||
|
||||
AppendToStream(FSMetaInfManifest,
|
||||
'</manifest:manifest>');
|
||||
@ -7153,6 +7189,7 @@ end;
|
||||
|
||||
procedure TsSpreadOpenDocWriter.WriteGraphicStyles(AStream: TStream);
|
||||
begin
|
||||
{$IFDEF FPS_CHARTS}
|
||||
if TsWorkbook(FWorkbook).GetChartCount = 0 then
|
||||
exit;
|
||||
|
||||
@ -7164,6 +7201,7 @@ begin
|
||||
'<style:paragraph-properties fo:text-align="center"/>' +
|
||||
'</style:style>'
|
||||
);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TsSpreadOpenDocWriter.WriteMasterStyles(AStream: TStream);
|
||||
@ -7419,6 +7457,7 @@ end;
|
||||
|
||||
procedure TsSpreadOpenDocWriter.WriteParagraphStyles(AStream: TStream);
|
||||
begin
|
||||
{$IFDEF FPS_CHARTS}
|
||||
if TsWorkbook(FWorkbook).GetChartCount = 0 then
|
||||
exit;
|
||||
|
||||
@ -7428,6 +7467,7 @@ begin
|
||||
'<style:paragraph-properties fo:text-align="center"/>' +
|
||||
'</style:style>'
|
||||
);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TsSpreadOpenDocWriter.WritePrintContentStyleXMLAsString(
|
||||
@ -8169,7 +8209,9 @@ constructor TsSpreadOpenDocWriter.Create(AWorkbook: TsBasicWorkbook);
|
||||
begin
|
||||
inherited Create(AWorkbook);
|
||||
|
||||
{$IFDEF FPS_CHARTS}
|
||||
FChartWriter := TsSpreadOpenDocChartWriter.Create(self);
|
||||
{$ENDIF}
|
||||
|
||||
FColumnStyleList := TFPList.Create;
|
||||
FRowStyleList := TFPList.Create;
|
||||
@ -8196,7 +8238,9 @@ begin
|
||||
FRichTextFontList.Free; // Do not destroy fonts, they are owned by Workbook
|
||||
FHeaderFooterFontList.Free;
|
||||
|
||||
{$IFDEF FPS_CHARTS}
|
||||
FChartWriter.Free;
|
||||
{$ENDIF}
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
@ -9012,8 +9056,6 @@ var
|
||||
sheet: TsWorksheet absolute ASheet;
|
||||
i: Integer;
|
||||
sheetIdx: Integer;
|
||||
chart: TsChart;
|
||||
series: TsChartSeries;
|
||||
img: TsImage;
|
||||
imgType: TsImageType;
|
||||
r1,c1,r2,c2: Cardinal;
|
||||
@ -9023,13 +9065,18 @@ var
|
||||
xml: String;
|
||||
target, bookmark: String;
|
||||
u: TURI;
|
||||
{$IFDEF FPS_CHARTS}
|
||||
chart: TsChart;
|
||||
series: TsChartSeries;
|
||||
{$ENDIF}
|
||||
begin
|
||||
if (sheet.GetImageCount = 0) and (sheet.GetChartCount = 0) then
|
||||
if (sheet.GetImageCount = 0) {$IFDEF FPS_CHARTS}and (sheet.GetChartCount = 0){$ENDIF} then
|
||||
exit;
|
||||
|
||||
AppendToStream(AStream,
|
||||
'<table:shapes>');
|
||||
|
||||
{$IFDEF FPS_CHARTS}
|
||||
sheetIdx := sheet.Index;
|
||||
for i:=0 to TsWorkbook(FWorkbook).GetChartCount-1 do
|
||||
begin
|
||||
@ -9096,6 +9143,7 @@ begin
|
||||
|
||||
AppendToStream(AStream, xml);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
for i:=0 to (ASheet as TsWorksheet).GetImageCount-1 do
|
||||
begin
|
||||
|
@ -1,9 +1,12 @@
|
||||
unit fpsOpenDocumentChart;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$include ..\fps.inc}
|
||||
|
||||
interface
|
||||
|
||||
{$IFDEF FPS_CHARTS}
|
||||
|
||||
uses
|
||||
Classes, SysUtils, StrUtils, Contnrs, FPImage,
|
||||
{$IF FPC_FULLVERSION >= 20701}
|
||||
@ -156,8 +159,12 @@ type
|
||||
procedure WriteCharts; override;
|
||||
end;
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
implementation
|
||||
|
||||
{$IFDEF FPS_CHARTS}
|
||||
|
||||
uses
|
||||
fpsOpenDocument;
|
||||
|
||||
@ -4227,5 +4234,7 @@ begin
|
||||
inc(AStyleID);
|
||||
end;
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
||||
|
||||
|
@ -24,7 +24,11 @@ uses
|
||||
{$endif}{$endif}{$endif}
|
||||
Classes, SysUtils, fpimage, avglvltree, lconvencoding,
|
||||
fpsTypes, fpsExprParser, fpsClasses, fpsNumFormat, fpsPageLayout,
|
||||
fpsImages, fpsConditionalFormat, fpsChart;
|
||||
fpsImages,
|
||||
{$ifdef FPS_CHARTS}
|
||||
fpsChart,
|
||||
{$endif}
|
||||
fpsConditionalFormat;
|
||||
|
||||
type
|
||||
{ Forward declarations }
|
||||
@ -251,7 +255,9 @@ type
|
||||
procedure WriteNumber(ACell: PCell; ANumber: Double;
|
||||
ANumFormat: TsNumberFormat; ANumFormatString: String); overload;
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
function WriteChartColor(ARow, Acol: Cardinal; AColor: TsColor): PCell;
|
||||
{$endif}
|
||||
|
||||
function WriteRPNFormula(ARow, ACol: Cardinal;
|
||||
AFormula: TsRPNFormula): PCell; overload;
|
||||
@ -635,8 +641,10 @@ type
|
||||
ARowOffs1, AColOffs1: Double; out ARowOffs2, AColOffs2: Double;
|
||||
out x,y: Double);
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
{ Chart support }
|
||||
function GetChartCount: Integer;
|
||||
{$endif}
|
||||
|
||||
{ Protection }
|
||||
procedure Protect(AEnable: Boolean);
|
||||
@ -784,7 +792,9 @@ type
|
||||
FCellFormatList: TsCellFormatList;
|
||||
FConditionalFormatList: TsConditionalFormatList;
|
||||
FEmbeddedObjList: TFPList;
|
||||
{$ifdef FPS_CHARTS}
|
||||
FCharts: TsChartList;
|
||||
{$endif}
|
||||
|
||||
{ Internal methods }
|
||||
class procedure GetFormatFromFileHeader(const AFileName: TFileName;
|
||||
@ -925,11 +935,13 @@ type
|
||||
function HasEmbeddedSheetImages: Boolean;
|
||||
procedure RemoveAllEmbeddedObj;
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
{ Charts }
|
||||
function AddChart(ASheet: TsBasicWorksheet; ARow, ACol: Cardinal;
|
||||
AWidth, AHeight: Double; AOffsetX: Double = 0.0; AOffsetY: Double = 0.0): TsChart;
|
||||
function GetChartByIndex(AIndex: Integer): TsChart;
|
||||
function GetChartCount: Integer;
|
||||
{$endif}
|
||||
|
||||
{ Utilities }
|
||||
function ConvertUnits(AValue: Double; AFromUnits, AToUnits: TsSizeUnits): Double;
|
||||
@ -1555,6 +1567,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Determines the count of charts on this worksheet
|
||||
-------------------------------------------------------------------------------}
|
||||
@ -1572,6 +1585,7 @@ begin
|
||||
if chart.SheetIndex = idx then inc(Result);
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Calculates all formulas of the worksheet
|
||||
@ -4384,6 +4398,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Writes an rgb color value as number to the specified cell. As requested by
|
||||
the chart module the bytes for red and blue are exchanged.
|
||||
@ -4392,7 +4407,7 @@ function TsWorksheet.WriteChartColor(ARow, ACol: Cardinal; AColor: TsColor): PCe
|
||||
begin
|
||||
Result := WriteNumber(ARow, ACol, FlipColorBytes(AColor));
|
||||
end;
|
||||
|
||||
{$endif}
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Writes an empty cell
|
||||
@ -6556,7 +6571,9 @@ begin
|
||||
FCellFormatList := TsCellFormatList.Create(false);
|
||||
FConditionalFormatList := TsConditionalFormatList.Create;
|
||||
FEmbeddedObjList := TFPList.Create;
|
||||
{$ifdef FPS_CHARTS}
|
||||
FCharts := TsChartList.Create;
|
||||
{$endif}
|
||||
|
||||
// Add default cell format
|
||||
InitFormatRecord(fmt);
|
||||
@ -6589,7 +6606,9 @@ begin
|
||||
|
||||
RemoveAllEmbeddedObj;
|
||||
FEmbeddedObjList.Free;
|
||||
{$ifdef FPS_CHARTS}
|
||||
FCharts.Free;
|
||||
{$endif}
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
@ -7807,7 +7826,10 @@ end;
|
||||
{$include fpspreadsheet_hyperlinks.inc} // hyperlinks
|
||||
{$include fpspreadsheet_embobj.inc} // embedded objects
|
||||
{$include fpspreadsheet_clipbrd.inc} // clipboard access
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
{$include fpspreadsheet_chart.inc} // chart support
|
||||
{$endif}
|
||||
|
||||
|
||||
end. {** End Unit: fpspreadsheet }
|
||||
|
@ -19,6 +19,8 @@ unit fpsReaderWriter;
|
||||
{$mode delphi}{$H+}
|
||||
{$endif}
|
||||
|
||||
{$include ..\fps.inc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
@ -197,6 +199,7 @@ type
|
||||
property NumFormatList: TStringList read FNumFormatList;
|
||||
end;
|
||||
|
||||
{$IFDEF FPS_CHARTS}
|
||||
{@@ Helper class for the spreadsheet reader to keep processing of charts
|
||||
out of the main reader unit. }
|
||||
TsBasicSpreadChartReader = class
|
||||
@ -221,6 +224,7 @@ type
|
||||
procedure WriteCharts; virtual; abstract;
|
||||
property Writer: TsBasicSpreadWriter read FWriter;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
type
|
||||
TsSpreadFileAccess = (faRead, faWrite);
|
||||
@ -937,6 +941,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{$IFDEF FPS_CHARTS}
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TsBasicSpreadChartReader }
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -957,6 +962,7 @@ constructor TsBasicSpreadChartWriter.Create(AWriter: TsBasicSpreadWriter);
|
||||
begin
|
||||
FWriter := AWriter;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
|
@ -67,13 +67,6 @@ implementation
|
||||
|
||||
uses
|
||||
LazUTF8,
|
||||
(*
|
||||
{$IF FPC_FULLVERSION >= 20701}
|
||||
zipper,
|
||||
{$ELSE}
|
||||
fpszipper,
|
||||
{$ENDIF}
|
||||
*)
|
||||
fpsStreams, fpsUtils;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
|
@ -184,11 +184,13 @@ type
|
||||
procedure WriteCFColorRangeRule(AStream: TStream; ARule: TsCFColorRangeRule; APriority: Integer);
|
||||
procedure WriteCFDataBarRule(AStream: TStream; ARule: TsCFDatabarRule; APriority: Integer);
|
||||
procedure WriteCFIconSetRule(AStream: TStream; ARule: TsCFIconSetRule; APriority: Integer);
|
||||
{$ifdef FPS_CHARTS}
|
||||
procedure WriteChart(AStream: TStream; AChartIndex: Integer);
|
||||
procedure WriteChartColors;
|
||||
procedure WriteChartRels;
|
||||
procedure WriteCharts;
|
||||
procedure WriteChartStyles;
|
||||
{$endif}
|
||||
procedure WriteColBreaks(AStream: TStream; AWorksheet: TsBasicWorksheet);
|
||||
procedure WriteCols(AStream: TStream; AWorksheet: TsBasicWorksheet);
|
||||
procedure WriteComments(AWorksheet: TsBasicWorksheet);
|
||||
@ -4726,7 +4728,7 @@ begin
|
||||
end;
|
||||
|
||||
// Charts or embedded images next
|
||||
if (sheet.GetImageCount > 0) or (book.GetChartCount > 0) then
|
||||
if (sheet.GetImageCount > 0) {$ifdef FPS_CHARTS}or (book.GetChartCount > 0){$endif} then
|
||||
begin
|
||||
ADrawing_rId := next_rId;
|
||||
inc(next_rId);
|
||||
@ -5145,7 +5147,7 @@ begin
|
||||
'</cfRule>');
|
||||
end;
|
||||
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
procedure TsSpreadOOXMLWriter.WriteChart(AStream: TStream;
|
||||
AChartIndex: Integer);
|
||||
|
||||
@ -5246,7 +5248,9 @@ begin
|
||||
'</c:chartSpace>' + LE
|
||||
);
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
procedure TsSpreadOOXMLWriter.WriteChartColors;
|
||||
var
|
||||
i, n: Integer;
|
||||
@ -5306,7 +5310,9 @@ begin
|
||||
);
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
{ Write the relationship file for all workbook's chart. The file defines which
|
||||
xml files contain the ChartStyles and Colors needed by each chart. }
|
||||
procedure TsSpreadOOXMLWriter.WriteChartRels;
|
||||
@ -5332,7 +5338,9 @@ begin
|
||||
]));
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
procedure TsSpreadOOXMLWriter.WriteCharts;
|
||||
var
|
||||
i, n: Integer;
|
||||
@ -5347,7 +5355,9 @@ begin
|
||||
WriteChart(FSCharts[i], i);
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
procedure TsSpreadOOXMLWriter.WriteChartStyles;
|
||||
var
|
||||
i, n: Integer;
|
||||
@ -5901,6 +5911,7 @@ begin
|
||||
);
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
procedure TsSpreadOOXMLWriter.WriteColBreaks(AStream: TStream;
|
||||
AWorksheet: TsBasicWorksheet);
|
||||
@ -7217,7 +7228,7 @@ var
|
||||
sheetIdx: Integer;
|
||||
chart: TsChart;
|
||||
begin
|
||||
if (sheet.GetImageCount = 0) and (sheet.GetChartCount = 0) then
|
||||
if (sheet.GetImageCount = 0) {$ifdef FPS_CHARTS}and (sheet.GetChartCount = 0){$endif} then
|
||||
exit;
|
||||
|
||||
SetLength(FSDrawings, FCurSheetNum + 1);
|
||||
@ -7238,6 +7249,7 @@ begin
|
||||
inc(rId, 1);
|
||||
end;
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
// Repeat for each chart
|
||||
sheetIdx := sheet.Index;
|
||||
j := 1; // Counts the charts in the current sheet
|
||||
@ -7251,6 +7263,7 @@ begin
|
||||
inc(rId);
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
// Close node
|
||||
AppendToStream(FSDrawings[FCurSheetNum],
|
||||
@ -7274,7 +7287,7 @@ var
|
||||
sheet: TsWorksheet absolute AWorksheet;
|
||||
sheetIdx: Integer;
|
||||
begin
|
||||
if (sheet.GetImageCount = 0) and (sheet.GetChartCount = 0) then
|
||||
if (sheet.GetImageCount = 0) {$ifdef FPS_CHARTS}and (sheet.GetChartCount = 0){$endif} then
|
||||
exit;
|
||||
|
||||
SetLength(FSDrawingsRels, FCurSheetNum + 1);
|
||||
@ -7317,6 +7330,7 @@ begin
|
||||
inc(rId);
|
||||
end;
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
// Repeat for each chart
|
||||
sheetIdx := sheet.Index;
|
||||
for i := 0 to TsWorkbook(FWorkbook).GetChartCount - 1 do
|
||||
@ -7331,6 +7345,7 @@ begin
|
||||
inc(rId);
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
AppendToStream(FSDrawingsRels[FCurSheetNum],
|
||||
'</Relationships>');
|
||||
@ -7697,7 +7712,7 @@ begin
|
||||
|
||||
// Anything to write?
|
||||
if (sheet.Comments.Count = 0) and (sheet.Hyperlinks.Count = 0) and
|
||||
(sheet.GetImageCount = 0) and (sheet.GetChartCount = 0) and
|
||||
(sheet.GetImageCount = 0) {$ifdef FPS_CHARTS}and (sheet.GetChartCount = 0){$endif} and
|
||||
(not (sheet.PageLayout.HasHeaderFooterImages))
|
||||
then
|
||||
exit;
|
||||
@ -7750,7 +7765,7 @@ begin
|
||||
// Relationships for charts or embedded images
|
||||
// relationship with to the ../drawings/drawingX.xml file containing all
|
||||
// chart/image infos. X is the 1-based sheet index
|
||||
if (sheet.GetImageCount > 0) or (sheet.GetChartCount > 0) then
|
||||
if (sheet.GetImageCount > 0) {$ifdef FPS_CHARTS}or (sheet.GetChartCount > 0){$endif} then
|
||||
AppendToStream(FSSheetRels[FCurSheetNum], Format(
|
||||
' <Relationship Id="rId%d" Target="../drawings/drawing%d.xml" Type="%s" />' + LineEnding,
|
||||
[rId_Drawing, FCurSheetNum + 1, SCHEMAS_DRAWING]
|
||||
@ -8010,11 +8025,13 @@ begin
|
||||
'</sst>');
|
||||
end;
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
{ Write all charts }
|
||||
WriteChartRels;
|
||||
WriteChartStyles;
|
||||
WriteChartColors;
|
||||
WriteCharts;
|
||||
{$endif}
|
||||
|
||||
{ Workbook relations - Mark relation to all sheets }
|
||||
WriteWorkbookRels(FSWorkbookRels);
|
||||
@ -8064,6 +8081,7 @@ begin
|
||||
AppendToStream(FSContentTypes,
|
||||
'<Override PartName="/xl/workbook.xml" ContentType="' + MIME_SHEET + '" />' + LineEnding);
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
n := 1;
|
||||
for i:=0 to book.GetWorksheetCount-1 do
|
||||
begin
|
||||
@ -8076,6 +8094,7 @@ begin
|
||||
inc(n);
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
for i:=1 to book.GetWorksheetCount do
|
||||
begin
|
||||
@ -8488,7 +8507,7 @@ begin
|
||||
which contains the image/chart-related data of all images/charts in this sheet.
|
||||
The file in turn requires an entry "drawingX.xml.rels" in the drawings rels
|
||||
folder }
|
||||
if (worksheet.GetImageCount > 0) or (worksheet.GetChartCount > 0) then
|
||||
if (worksheet.GetImageCount > 0) {$ifdef FPS_CHARTS}or (worksheet.GetChartCount > 0){$endif} then
|
||||
AppendToStream(FSSheets[FCurSheetNum], Format(
|
||||
'<drawing r:id="rId%d" />', [rId_Drawing]));
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
unit fpsvisualreg;
|
||||
|
||||
{$MODE objfpc}{$H+}
|
||||
|
||||
{$INCLUDE ..\fps.inc}
|
||||
{$DEFINE REGISTER_ALL_FILE_FORMATS}
|
||||
|
||||
{$R ../../resource/fpsvisualreg.res}
|
||||
@ -19,7 +21,12 @@ uses
|
||||
{$IFDEF REGISTER_ALL_FILE_FORMATS}
|
||||
{%H-}fpsallformats,
|
||||
{$ENDIF}
|
||||
fpspreadsheetctrls, fpspreadsheetgrid, fpspreadsheetchart, fpsactions;
|
||||
fpspreadsheetctrls,
|
||||
fpspreadsheetgrid,
|
||||
{$IFDEF FPS_CHARTS}
|
||||
fpspreadsheetchart,
|
||||
{$ENDIF}
|
||||
fpsactions;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Registers the visual spreadsheet components in the Lazarus component palette,
|
||||
@ -35,9 +42,11 @@ begin
|
||||
TsSpreadsheetInspector
|
||||
]);
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
RegisterComponents('Chart', [
|
||||
TsWorkbookChartSource
|
||||
]);
|
||||
{$endif}
|
||||
|
||||
RegisterActions('FPSpreadsheet', [
|
||||
// Worksheet-releated actions
|
||||
|
@ -67,3 +67,5 @@
|
||||
Therefore, the following define must be activated if FPC is v3.3 or older. }
|
||||
{$DEFINE FPS_PATCHED_ZIPPER}
|
||||
|
||||
{ The next define activates chart support. }
|
||||
{$DEFINE FPS_CHARTS}
|
||||
|
@ -13,9 +13,12 @@ LICENSE: See the file COPYING.modifiedLGPL.txt, included in the Lazarus
|
||||
unit fpspreadsheetchart;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$include ..\fps.inc}
|
||||
|
||||
interface
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
|
||||
uses
|
||||
// RTL/FCL
|
||||
Classes, Contnrs, SysUtils, Types, FPCanvas,
|
||||
@ -191,9 +194,12 @@ type
|
||||
|
||||
procedure Convert_sChartLine_to_Pen(AChart: TsChart; ALine: TsChartLine; APen: TPen);
|
||||
|
||||
{$endif}
|
||||
|
||||
implementation
|
||||
|
||||
{$ifdef FPS_CHARTS}
|
||||
|
||||
uses
|
||||
Math;
|
||||
|
||||
@ -2451,4 +2457,6 @@ begin
|
||||
AChartSeries.TickWidthStyle := twsPercentMin;
|
||||
end;
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
||||
|
@ -23,6 +23,7 @@
|
||||
unit fpspreadsheetctrls;
|
||||
|
||||
{$MODE objfpc}{$H+}
|
||||
{$include ..\fps.inc}
|
||||
|
||||
interface
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user