fpspreadsheet: Introduce additional parameter ("AParam") when saving workbooks.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4367 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
c10dec52ea
commit
6fb4bb9c9b
@ -51,9 +51,9 @@ type
|
||||
|
||||
public
|
||||
constructor Create(AWorkbook: TsWorkbook); override;
|
||||
procedure WriteToClipboardStream(AStream: TStream); override;
|
||||
procedure WriteToStream(AStream: TStream); override;
|
||||
procedure WriteToStrings(AStrings: TStrings); override;
|
||||
procedure WriteToClipboardStream(AStream: TStream; AParam: Integer = 0); override;
|
||||
procedure WriteToStream(AStream: TStream; AParam: Integer = 0); override;
|
||||
procedure WriteToStrings(AStrings: TStrings; AParam: Integer = 0); override;
|
||||
end;
|
||||
|
||||
TsCSVLineEnding = (leSystem, leCRLF, leCR, leLF);
|
||||
@ -415,29 +415,31 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TsCSVWriter.WriteToClipboardStream(AStream: TStream);
|
||||
procedure TsCSVWriter.WriteToClipboardStream(AStream: TStream;
|
||||
AParam: Integer = 0);
|
||||
begin
|
||||
FClipboardMode := true;
|
||||
WriteToStream(AStream);
|
||||
WriteToStream(AStream, AParam);
|
||||
end;
|
||||
|
||||
procedure TsCSVWriter.WriteToStream(AStream: TStream);
|
||||
procedure TsCSVWriter.WriteToStream(AStream: TStream; AParam: Integer = 0);
|
||||
var
|
||||
n: Integer;
|
||||
begin
|
||||
Unused(AParam);
|
||||
if (CSVParams.SheetIndex >= 0) and (CSVParams.SheetIndex < FWorkbook.GetWorksheetCount)
|
||||
then n := CSVParams.SheetIndex
|
||||
else n := 0;
|
||||
WriteSheet(AStream, FWorkbook.GetWorksheetByIndex(n));
|
||||
end;
|
||||
|
||||
procedure TsCSVWriter.WriteToStrings(AStrings: TStrings);
|
||||
procedure TsCSVWriter.WriteToStrings(AStrings: TStrings; AParam: Integer = 0);
|
||||
var
|
||||
Stream: TStream;
|
||||
begin
|
||||
Stream := TStringStream.Create('');
|
||||
try
|
||||
WriteToStream(Stream);
|
||||
WriteToStream(Stream, AParam);
|
||||
Stream.Position := 0;
|
||||
AStrings.LoadFromStream(Stream);
|
||||
finally
|
||||
|
@ -63,7 +63,7 @@ type
|
||||
TsHTMLWriter = class(TsCustomSpreadWriter)
|
||||
private
|
||||
FPointSeparatorSettings: TFormatSettings;
|
||||
FClipboardMode: Boolean;
|
||||
FParam: Integer;
|
||||
FStartHtmlPos: Int64;
|
||||
FEndHtmlPos: Int64;
|
||||
FStartFragmentPos: Int64;
|
||||
@ -105,9 +105,9 @@ type
|
||||
public
|
||||
constructor Create(AWorkbook: TsWorkbook); override;
|
||||
destructor Destroy; override;
|
||||
procedure WriteToClipboardStream(AStream: TStream); override;
|
||||
procedure WriteToStream(AStream: TStream); override;
|
||||
procedure WriteToStrings(AStrings: TStrings); override;
|
||||
procedure WriteToClipboardStream(AStream: TStream; AParam: Integer = 0); override;
|
||||
procedure WriteToStream(AStream: TStream; AParam: Integer = 0); override;
|
||||
procedure WriteToStrings(AStrings: TStrings; AParam: Integer = 0); override;
|
||||
end;
|
||||
|
||||
TsHTMLParams = record
|
||||
@ -1474,7 +1474,7 @@ var
|
||||
begin
|
||||
AppendToStream(AStream,
|
||||
'<body>');
|
||||
if FClipboardMode or (HTMLParams.SheetIndex < 0) then // active sheet
|
||||
if (FParam = PARAM_WINDOWS_CLIPBOARD_HTML) or (HTMLParams.SheetIndex < 0) then // active sheet
|
||||
begin
|
||||
if FWorkbook.ActiveWorksheet = nil then
|
||||
FWorkbook.SelectWorksheet(FWorkbook.GetWorksheetByIndex(0));
|
||||
@ -1675,23 +1675,37 @@ begin
|
||||
'</style>' + LineEnding);
|
||||
end;
|
||||
|
||||
procedure TsHTMLWriter.WriteToClipboardStream(AStream: TStream);
|
||||
procedure TsHTMLWriter.WriteToClipboardStream(AStream: TStream;
|
||||
AParam: Integer = 0);
|
||||
begin
|
||||
if AParam = PARAM_WINDOWS_CLIPBOARD_HTML then
|
||||
begin
|
||||
AppendToStream(AStream, Format(
|
||||
NATIVE_HEADER, [0, 0, 0, 0])); // value will be replaced at end
|
||||
WriteToStream(AStream, AParam);
|
||||
AStream.Position := 0;
|
||||
AppendToStream(AStream, Format(
|
||||
NATIVE_HEADER, [FStartHTMLPos, FEndHTMLPos, FStartFragmentPos, FEndFragmentPos]));
|
||||
end else
|
||||
WriteToStream(AStream, AParam);
|
||||
{
|
||||
{$IFDEF MSWINDOWS}
|
||||
FClipboardMode := true;
|
||||
AppendToStream(AStream, Format(
|
||||
NATIVE_HEADER, [0, 0, 0, 0])); // value will be replaced at end
|
||||
WriteToStream(AStream);
|
||||
WriteToStream(AStream, AParams);
|
||||
AStream.Position := 0;
|
||||
AppendToStream(AStream, Format(
|
||||
NATIVE_HEADER, [FStartHTMLPos, FEndHTMLPos, FStartFragmentPos, FEndFragmentPos]));
|
||||
{$ELSE}
|
||||
WriteToStream(AStream);
|
||||
WriteToStream(AStream, AParams);
|
||||
{$ENDIF}
|
||||
}
|
||||
end;
|
||||
|
||||
procedure TsHTMLWriter.WriteToStream(AStream: TStream);
|
||||
procedure TsHTMLWriter.WriteToStream(AStream: TStream; AParam: Integer = 0);
|
||||
begin
|
||||
FParam := AParam;
|
||||
|
||||
FWorkbook.UpdateCaches;
|
||||
AppendToStream(AStream,
|
||||
'<!DOCTYPE html>');
|
||||
@ -1712,13 +1726,13 @@ begin
|
||||
FEndHTMLPos := AStream.Position;
|
||||
end;
|
||||
|
||||
procedure TsHTMLWriter.WriteToStrings(AStrings: TStrings);
|
||||
procedure TsHTMLWriter.WriteToStrings(AStrings: TStrings; AParam: Integer = 0);
|
||||
var
|
||||
Stream: TStream;
|
||||
begin
|
||||
Stream := TStringStream.Create('');
|
||||
try
|
||||
WriteToStream(Stream);
|
||||
WriteToStream(Stream, AParam);
|
||||
Stream.Position := 0;
|
||||
AStrings.LoadFromStream(Stream);
|
||||
finally
|
||||
@ -1769,7 +1783,7 @@ begin
|
||||
'<div>' + LineEnding +
|
||||
'<table style="' + style + '">' + LineEnding);
|
||||
|
||||
if FClipboardMode then
|
||||
if (FParam = PARAM_WINDOWS_CLIPBOARD_HTML) then
|
||||
begin
|
||||
AppendToStream(AStream, START_FRAGMENT);
|
||||
FStartFragmentPos := AStream.Position;
|
||||
@ -1882,7 +1896,7 @@ begin
|
||||
'</tr>' + LineEnding);
|
||||
end;
|
||||
|
||||
if FClipboardMode then
|
||||
if (FParam = PARAM_WINDOWS_CLIPBOARD_HTML) then
|
||||
begin
|
||||
AppendToStream(AStream, END_FRAGMENT);
|
||||
FEndFragmentPos := AStream.Position;
|
||||
|
@ -229,12 +229,8 @@ type
|
||||
|
||||
{ General writing methods }
|
||||
procedure WriteStringToFile(AString, AFileName: string);
|
||||
procedure WriteToClipboardStream(AStream: TStream); override;
|
||||
{
|
||||
procedure WriteToFile(const AFileName: string;
|
||||
const AOverwriteExisting: Boolean = False); override;
|
||||
}
|
||||
procedure WriteToStream(AStream: TStream); override;
|
||||
procedure WriteToClipboardStream(AStream: TStream; AParam: Integer = 0); override;
|
||||
procedure WriteToStream(AStream: TStream; AParam: Integer = 0); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -4760,15 +4756,19 @@ begin
|
||||
end;
|
||||
end; *)
|
||||
|
||||
procedure TsSpreadOpenDocWriter.WriteToClipboardStream(AStream: TStream);
|
||||
procedure TsSpreadOpenDocWriter.WriteToClipboardStream(AStream: TStream;
|
||||
AParam: Integer = 0);
|
||||
begin
|
||||
WriteToStream(AStream);
|
||||
WriteToStream(AStream, AParam);
|
||||
end;
|
||||
|
||||
procedure TsSpreadOpenDocWriter.WriteToStream(AStream: TStream);
|
||||
procedure TsSpreadOpenDocWriter.WriteToStream(AStream: TStream;
|
||||
AParam: Integer = 0);
|
||||
var
|
||||
FZip: TZipper;
|
||||
begin
|
||||
Unused(AParam);
|
||||
|
||||
{ Analyze the workbook and collect all information needed }
|
||||
ListAllNumFormats;
|
||||
ListAllColumnStyles;
|
||||
|
@ -667,11 +667,11 @@ type
|
||||
AClipboardMode: Boolean = false);
|
||||
procedure WriteToFile(const AFileName: string;
|
||||
const AFormat: TsSpreadsheetFormat;
|
||||
const AOverwriteExisting: Boolean = False); overload;
|
||||
const AOverwriteExisting: Boolean = False; AParam: Integer = 0); overload;
|
||||
procedure WriteToFile(const AFileName: String;
|
||||
const AOverwriteExisting: Boolean = False); overload;
|
||||
const AOverwriteExisting: Boolean = False; AParam: Integer = 0); overload;
|
||||
procedure WriteToStream(AStream: TStream; AFormat: TsSpreadsheetFormat;
|
||||
AClipboardMode: Boolean = false);
|
||||
AClipboardMode: Boolean = false; AParam: Integer = 0);
|
||||
|
||||
{ Worksheet list handling methods }
|
||||
function AddWorksheet(AName: string;
|
||||
@ -731,9 +731,10 @@ type
|
||||
function GetNumberFormatCount: Integer;
|
||||
|
||||
{ Clipboard }
|
||||
procedure CopyToClipboardStream(AStream: TStream; AFormat: TsSpreadsheetFormat);
|
||||
procedure CopyToClipboardStream(AStream: TStream; AFormat: TsSpreadsheetFormat;
|
||||
AParam: Integer = 0);
|
||||
procedure PasteFromClipboardStream(AStream: TStream; AFormat: TsSpreadsheetFormat;
|
||||
AOperation: TsCopyOperation);
|
||||
AOperation: TsCopyOperation; ATransposed: Boolean = false);
|
||||
(*
|
||||
{ Color handling }
|
||||
function FPSColorToHexString(AColor: TsColor; ARGBColor: TFPColor): String;
|
||||
@ -836,11 +837,11 @@ type
|
||||
{ Helpers }
|
||||
procedure CheckLimitations; virtual;
|
||||
{ General writing methods }
|
||||
procedure WriteToClipboardStream(AStream: TStream); virtual; abstract;
|
||||
procedure WriteToClipboardStream(AStream: TStream; AParam: Integer = 0); virtual; abstract;
|
||||
procedure WriteToFile(const AFileName: string;
|
||||
const AOverwriteExisting: Boolean = False); virtual; abstract;
|
||||
procedure WriteToStream(AStream: TStream); virtual; abstract;
|
||||
procedure WriteToStrings(AStrings: TStrings); virtual; abstract;
|
||||
const AOverwriteExisting: Boolean = False; AParam: Integer = 0); virtual; abstract;
|
||||
procedure WriteToStream(AStream: TStream; AParam: Integer = 0); virtual; abstract;
|
||||
procedure WriteToStrings(AStrings: TStrings; AParam: Integer = 0); virtual; abstract;
|
||||
end;
|
||||
|
||||
{@@ TsSpreadReader class reference type }
|
||||
@ -6896,9 +6897,11 @@ end;
|
||||
@param AOverwriteExisting If the file is already existing it will be
|
||||
overwritten in case of AOverwriteExisting = true.
|
||||
If false an exception will be raised.
|
||||
@param AParam Optional parameter to control writer-specific details.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbook.WriteToFile(const AFileName: string;
|
||||
const AFormat: TsSpreadsheetFormat; const AOverwriteExisting: Boolean = False);
|
||||
const AFormat: TsSpreadsheetFormat; const AOverwriteExisting: Boolean = False;
|
||||
AParam: Integer = 0);
|
||||
var
|
||||
AWriter: TsBasicSpreadWriter;
|
||||
begin
|
||||
@ -6909,7 +6912,7 @@ begin
|
||||
PrepareBeforeSaving;
|
||||
AWriter.CheckLimitations;
|
||||
FReadWriteFlag := rwfWrite;
|
||||
AWriter.WriteToFile(AFileName, AOverwriteExisting);
|
||||
AWriter.WriteToFile(AFileName, AOverwriteExisting, AParam);
|
||||
finally
|
||||
FReadWriteFlag := rwfNormal;
|
||||
AWriter.Free;
|
||||
@ -6924,16 +6927,17 @@ end;
|
||||
@param AOverwriteExisting If the file already exists it will be overwritten
|
||||
of AOverwriteExisting is true. In case of false, an
|
||||
exception will be raised.
|
||||
@param AParam Optional parameter to control writer-specific details
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbook.WriteToFile(const AFileName: String;
|
||||
const AOverwriteExisting: Boolean);
|
||||
const AOverwriteExisting: Boolean; AParam: Integer = 0);
|
||||
var
|
||||
SheetType: TsSpreadsheetFormat;
|
||||
valid: Boolean;
|
||||
begin
|
||||
valid := GetFormatFromFileName(AFileName, SheetType);
|
||||
if valid then
|
||||
WriteToFile(AFileName, SheetType, AOverwriteExisting)
|
||||
WriteToFile(AFileName, SheetType, AOverwriteExisting, AParam)
|
||||
else
|
||||
raise Exception.Create(Format(rsInvalidExtension, [
|
||||
ExtractFileExt(AFileName)
|
||||
@ -6946,9 +6950,12 @@ end;
|
||||
@param AStream Instance of the stream being written to
|
||||
@param AFormat File format to be written.
|
||||
@param AClipboardMode Stream will be used by calling method for clipboard access
|
||||
@param AParam An optional parameter which controls writing of
|
||||
details. The HTML writer, for example, can be forced
|
||||
to write a valid html document in Windows.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbook.WriteToStream(AStream: TStream; AFormat: TsSpreadsheetFormat;
|
||||
AClipboardMode: Boolean = false);
|
||||
AClipboardMode: Boolean = false; AParam: Integer = 0);
|
||||
var
|
||||
AWriter: TsBasicSpreadWriter;
|
||||
begin
|
||||
@ -6958,8 +6965,8 @@ begin
|
||||
AWriter.CheckLimitations;
|
||||
FReadWriteFlag := rwfWrite;
|
||||
if AClipboardMode then
|
||||
AWriter.WriteToClipboardStream(AStream) else
|
||||
AWriter.WriteToStream(AStream);
|
||||
AWriter.WriteToClipboardStream(AStream, AParam) else
|
||||
AWriter.WriteToStream(AStream, AParam);
|
||||
finally
|
||||
FReadWriteFlag := rwfNormal;
|
||||
AWriter.Free;
|
||||
@ -7783,7 +7790,7 @@ end;
|
||||
fpspreadsheet does not "know" the system's clipboard.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbook.CopyToClipboardStream(AStream: TStream;
|
||||
AFormat: TsSpreadsheetFormat);
|
||||
AFormat: TsSpreadsheetFormat; AParam: Integer = 0);
|
||||
var
|
||||
clipbook: TsWorkbook;
|
||||
clipsheet: TsWorksheet;
|
||||
@ -7818,9 +7825,9 @@ begin
|
||||
clipsheet.SetSelection(ActiveWorksheet.GetSelection);
|
||||
clipsheet.SelectCell(ActiveWorksheet.ActiveCellRow, ActiveWorksheet.ActiveCellCol);
|
||||
|
||||
// Write this workbook to a stream. Set the last parameter (ClipboardMode)
|
||||
// Write this workbook to a stream. Set the parameter ClipboardMode
|
||||
// to TRUE to use the dedicated clipboard routine if needed.
|
||||
clipbook.WriteToStream(AStream, AFormat, true);
|
||||
clipbook.WriteToStream(AStream, AFormat, true, AParam);
|
||||
|
||||
// The calling routine which copies the stream to the clipboard requires
|
||||
// the stream to be at its beginning.
|
||||
@ -7837,7 +7844,8 @@ end;
|
||||
calling routine since fpspreadsheet does not "know" the system's clipboard.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbook.PasteFromClipboardStream(AStream: TStream;
|
||||
AFormat: TsSpreadsheetFormat; AOperation: TsCopyOperation);
|
||||
AFormat: TsSpreadsheetFormat; AOperation: TsCopyOperation;
|
||||
ATransposed: Boolean = false);
|
||||
var
|
||||
clipbook: TsWorkbook;
|
||||
clipsheet: TsWorksheet;
|
||||
|
@ -125,7 +125,7 @@ type
|
||||
// procedure ClearCellClipboard;
|
||||
procedure CopyCellsToClipboard;
|
||||
procedure CutCellsToClipboard;
|
||||
procedure PasteCellsFromClipboard(AItem: TsCopyOperation);
|
||||
procedure PasteCellsFromClipboard(AItem: TsCopyOperation; ATransposed: Boolean = false);
|
||||
|
||||
public
|
||||
{@@ Workbook linked to the WorkbookSource }
|
||||
@ -1136,6 +1136,7 @@ var
|
||||
sel: TsCellRangeArray;
|
||||
stream: TStream;
|
||||
savedCSVParams: TsCSVParams;
|
||||
param: Integer;
|
||||
begin
|
||||
sel := FWorksheet.GetSelection;
|
||||
if Length(sel) = 0 then
|
||||
@ -1165,10 +1166,17 @@ begin
|
||||
Clipboard.AddFormat(cfBiff5Format, stream);
|
||||
(stream as TMemoryStream).Clear;
|
||||
|
||||
// Then write HTML format
|
||||
// Then write Windows HTML format
|
||||
{$IFDEF MSWINDOWS}
|
||||
param := PARAM_WINDOWS_CLIPBOARD_HTML;
|
||||
FWorkbook.CopyToClipboardStream(stream, sfHTML, param);
|
||||
if cfHtmlFormat <> 0 then
|
||||
Clipboard.AddFormat(cfHTMLFormat, stream);
|
||||
(stream as TMemoryStream).Clear;
|
||||
{$ENDIF}
|
||||
|
||||
// Write standard html format (MIME-type "text/html")
|
||||
FWorkbook.CopyToClipboardStream(stream, sfHTML);
|
||||
if cfHtmlFormat <> 0 then
|
||||
Clipboard.AddFormat(cfHTMLFormat, stream);
|
||||
if cfTextHtmlFormat <> 0 then
|
||||
Clipboard.AddFormat(cfTextHTMLFormat, stream);
|
||||
(stream as TMemoryStream).Clear;
|
||||
@ -1238,8 +1246,11 @@ end;
|
||||
|
||||
AOperation determines which "item" of the cell (all, values, formats, formula)
|
||||
is pasted.
|
||||
|
||||
If ATranspose is TRUE then rows and columns are interchanged.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbookSource.PasteCellsFromClipboard(AItem: TsCopyOperation);
|
||||
procedure TsWorkbookSource.PasteCellsFromClipboard(AItem: TsCopyOperation;
|
||||
ATransposed: Boolean = false);
|
||||
var
|
||||
r, c, dr, dc, destRow, destCol: LongInt;
|
||||
i, j: Integer;
|
||||
@ -1274,7 +1285,7 @@ begin
|
||||
|
||||
// Paste stream into workbook
|
||||
stream.Position := 0;
|
||||
FWorkbook.PasteFromClipboardStream(stream, fmt, AItem);
|
||||
FWorkbook.PasteFromClipboardStream(stream, fmt, AItem, ATransposed);
|
||||
|
||||
// To do: XML format
|
||||
// I don't know which format is written by xlsx and ods natively.
|
||||
|
@ -128,9 +128,9 @@ type
|
||||
|
||||
{ General writing methods }
|
||||
procedure WriteToFile(const AFileName: string;
|
||||
const AOverwriteExisting: Boolean = False); override;
|
||||
procedure WriteToStream(AStream: TStream); override;
|
||||
procedure WriteToStrings(AStrings: TStrings); override;
|
||||
const AOverwriteExisting: Boolean = False; AParam: Integer = 0); override;
|
||||
procedure WriteToStream(AStream: TStream; AParam: Integer = 0); override;
|
||||
procedure WriteToStrings(AStrings: TStrings; AParam: Integer = 0); override;
|
||||
|
||||
{@@ List of number formats found in the workbook. }
|
||||
property NumFormatList: TStringList read FNumFormatList;
|
||||
@ -610,11 +610,13 @@ end;
|
||||
|
||||
@param AFileName The output file name.
|
||||
@param AOverwriteExisting If the file already exists it will be replaced.
|
||||
@param AParam Optional parameter to control writer-specific details
|
||||
(see PARAM_XXXX declarations)
|
||||
|
||||
@see TsWorkbook
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsCustomSpreadWriter.WriteToFile(const AFileName: string;
|
||||
const AOverwriteExisting: Boolean = False);
|
||||
const AOverwriteExisting: Boolean = False; AParam: Integer = 0);
|
||||
var
|
||||
OutputFile: TStream;
|
||||
lMode: Word;
|
||||
@ -633,7 +635,7 @@ begin
|
||||
OutputFile := TMemoryStream.Create;
|
||||
|
||||
try
|
||||
WriteToStream(OutputFile);
|
||||
WriteToStream(OutputFile, AParam);
|
||||
if OutputFile is TMemoryStream then
|
||||
(OutputFile as TMemoryStream).SaveToFile(AFileName);
|
||||
finally
|
||||
@ -648,11 +650,14 @@ end;
|
||||
Must be overriden in descendent classes for all other cases.
|
||||
|
||||
@param AStream Stream to which the workbook is written
|
||||
@param AParam Optional parameter to control writer-specific details
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsCustomSpreadWriter.WriteToStream(AStream: TStream);
|
||||
procedure TsCustomSpreadWriter.WriteToStream(AStream: TStream;
|
||||
AParam: Integer = 0);
|
||||
var
|
||||
list: TStringList;
|
||||
begin
|
||||
Unused(AParam);
|
||||
list := TStringList.Create;
|
||||
try
|
||||
WriteToStrings(list);
|
||||
@ -666,9 +671,10 @@ end;
|
||||
Writes the worksheet to a list of strings. Not implemented here, needs to
|
||||
be overridden by descendants. See wikitables.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsCustomSpreadWriter.WriteToStrings(AStrings: TStrings);
|
||||
procedure TsCustomSpreadWriter.WriteToStrings(AStrings: TStrings;
|
||||
AParam: Integer = 0);
|
||||
begin
|
||||
Unused(AStrings);
|
||||
Unused(AStrings, AParam);
|
||||
raise Exception.Create(rsUnsupportedWriteFormat);
|
||||
end;
|
||||
|
||||
|
@ -733,6 +733,11 @@ type
|
||||
{@@ Identifier for a copy operation }
|
||||
TsCopyOperation = (coNone, coCopyFormat, coCopyValue, coCopyFormula, coCopyCell);
|
||||
|
||||
// Parameter declarations for TWriter.WriteStream/WriteClipboardStream
|
||||
const
|
||||
{@@ Parameter for HTML writer to create a HTML document for the clipboard
|
||||
according to Windows specification }
|
||||
PARAM_WINDOWS_CLIPBOARD_HTML = 1;
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -85,7 +85,7 @@ type
|
||||
public
|
||||
SubFormat: TsSpreadsheetFormat;
|
||||
{ General writing methods }
|
||||
procedure WriteToStrings(AStrings: TStrings); override;
|
||||
procedure WriteToStrings(AStrings: TStrings; AParams: Integer = 0); override;
|
||||
procedure WriteToStrings_WikiMedia(AStrings: TStrings);
|
||||
end;
|
||||
|
||||
@ -343,8 +343,10 @@ end;
|
||||
|
||||
{ TsWikiTableWriter }
|
||||
|
||||
procedure TsWikiTableWriter.WriteToStrings(AStrings: TStrings);
|
||||
procedure TsWikiTableWriter.WriteToStrings(AStrings: TStrings;
|
||||
AParams: Integer = 0);
|
||||
begin
|
||||
Unused(AParams);
|
||||
case SubFormat of
|
||||
sfWikiTable_WikiMedia: WriteToStrings_WikiMedia(AStrings);
|
||||
end;
|
||||
|
@ -126,8 +126,7 @@ type
|
||||
XFType_Prot: Byte = 0); override;
|
||||
public
|
||||
constructor Create(AWorkbook: TsWorkbook); override;
|
||||
{ General writing methods }
|
||||
procedure WriteToStream(AStream: TStream); override;
|
||||
procedure WriteToStream(AStream: TStream; AParam: Integer = 0); override;
|
||||
end;
|
||||
|
||||
TExcel2Settings = record
|
||||
@ -1284,10 +1283,13 @@ end;
|
||||
Excel 2.x files support only one Worksheet per Workbook,
|
||||
so only the first one will be written.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsSpreadBIFF2Writer.WriteToStream(AStream: TStream);
|
||||
procedure TsSpreadBIFF2Writer.WriteToStream(AStream: TStream;
|
||||
AParam: Integer = 0);
|
||||
var
|
||||
pane: Byte;
|
||||
begin
|
||||
Unused(AParam);
|
||||
|
||||
FWorksheet := Workbook.GetWorksheetByIndex(FSheetIndex);
|
||||
if FWorksheet = nil then
|
||||
raise Exception.Create(rsWorksheetNotFound1);
|
||||
|
@ -118,8 +118,8 @@ type
|
||||
constructor Create(AWorkbook: TsWorkbook); override;
|
||||
{ General writing methods }
|
||||
procedure WriteToFile(const AFileName: string;
|
||||
const AOverwriteExisting: Boolean = False); override;
|
||||
procedure WriteToStream(AStream: TStream); override;
|
||||
const AOverwriteExisting: Boolean = False; AParam: Integer = 0); override;
|
||||
procedure WriteToStream(AStream: TStream; AParam: Integer = 0); override;
|
||||
end;
|
||||
|
||||
TExcel5Settings = record
|
||||
@ -1172,12 +1172,14 @@ end;
|
||||
2 - Write the memory stream data to disk using COM functions
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsSpreadBIFF5Writer.WriteToFile(const AFileName: string;
|
||||
const AOverwriteExisting: Boolean);
|
||||
const AOverwriteExisting: Boolean; AParam: Integer = 0);
|
||||
var
|
||||
stream: TStream;
|
||||
OutputStorage: TOLEStorage;
|
||||
OLEDocument: TOLEDocument;
|
||||
begin
|
||||
Unused(AParam);
|
||||
|
||||
if (boBufStream in Workbook.Options) then
|
||||
stream := TBufStream.Create else
|
||||
stream := TMemoryStream.Create;
|
||||
@ -1200,12 +1202,14 @@ end;
|
||||
Writes an Excel BIFF5 record structure to a stream containing the OLE
|
||||
envelope of the document.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsSpreadBIFF5Writer.WriteToStream(AStream: TStream);
|
||||
procedure TsSpreadBIFF5Writer.WriteToStream(AStream: TStream;
|
||||
AParam: Integer = 0);
|
||||
var
|
||||
OutputStorage: TOLEStorage;
|
||||
OLEDocument: TOLEDocument;
|
||||
stream: TStream;
|
||||
begin
|
||||
Unused(AParam);
|
||||
if (boBufStream in Workbook.Options) then
|
||||
stream := TBufStream.Create else
|
||||
stream := TMemoryStream.Create;
|
||||
|
@ -170,8 +170,8 @@ type
|
||||
constructor Create(AWorkbook: TsWorkbook); override;
|
||||
{ General writing methods }
|
||||
procedure WriteToFile(const AFileName: string;
|
||||
const AOverwriteExisting: Boolean = False); override;
|
||||
procedure WriteToStream(AStream: TStream); override;
|
||||
const AOverwriteExisting: Boolean = False; AParam: Integer = 0); override;
|
||||
procedure WriteToStream(AStream: TStream; AParam: Integer = 0); override;
|
||||
end;
|
||||
|
||||
TExcel8Settings = record
|
||||
@ -2078,12 +2078,13 @@ end;
|
||||
2 - Write the memory stream data to disk using COM functions
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsSpreadBIFF8Writer.WriteToFile(const AFileName: string;
|
||||
const AOverwriteExisting: Boolean);
|
||||
const AOverwriteExisting: Boolean; AParam: Integer = 0);
|
||||
var
|
||||
Stream: TStream;
|
||||
OutputStorage: TOLEStorage;
|
||||
OLEDocument: TOLEDocument;
|
||||
begin
|
||||
Unused(AParam);
|
||||
if (boBufStream in Workbook.Options) then begin
|
||||
Stream := TBufStream.Create
|
||||
end else
|
||||
@ -2107,12 +2108,15 @@ end;
|
||||
Writes an Excel BIFF8 record structure to a stream containing the OLE
|
||||
envelope of the document.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsSpreadBIFF8Writer.WriteToStream(AStream: TStream);
|
||||
procedure TsSpreadBIFF8Writer.WriteToStream(AStream: TStream;
|
||||
AParam: Integer = 0);
|
||||
var
|
||||
OutputStorage: TOLEStorage;
|
||||
OLEDocument: TOLEDocument;
|
||||
stream: TStream;
|
||||
begin
|
||||
Unused(AParam);
|
||||
|
||||
if (boBufStream in Workbook.Options) then
|
||||
stream := TBufStream.Create else
|
||||
stream := TMemoryStream.Create;
|
||||
|
@ -574,7 +574,7 @@ type
|
||||
constructor Create(AWorkbook: TsWorkbook); override;
|
||||
destructor Destroy; override;
|
||||
procedure CheckLimitations; override;
|
||||
procedure WriteToClipboardStream(AStream: TStream); override;
|
||||
procedure WriteToClipboardStream(AStream: TStream; AParam: Integer = 0); override;
|
||||
end;
|
||||
|
||||
procedure AddBuiltinBiffFormats(AList: TStringList;
|
||||
@ -3816,33 +3816,33 @@ begin
|
||||
|
||||
{ Cell range array }
|
||||
|
||||
{ Count of cell ranges }
|
||||
n := ASheet.GetSelectionCount;
|
||||
// Case 1: no selection
|
||||
if n = 0 then
|
||||
begin
|
||||
{ Count of cell ranges }
|
||||
// Count of cell ranges
|
||||
AStream.WriteWord(WordToLE(1));
|
||||
{ Index to first and last row - are the same here }
|
||||
// Index to first and last row - are the same here
|
||||
AStream.WriteWord(WordTOLE(activeCellRow));
|
||||
AStream.WriteWord(WordTOLE(activeCellRow));
|
||||
{ Index to first and last column - they are the same here again. }
|
||||
{ Note: BIFF8 writes bytes here! This is ok because BIFF supports only 256 columns}
|
||||
// Index to first and last column - they are the same here again.
|
||||
// Note: BIFF8 writes bytes here! This is ok because BIFF supports only 256 columns
|
||||
AStream.WriteByte(activeCellCol);
|
||||
AStream.WriteByte(activeCellCol);
|
||||
end else
|
||||
// Case 2: Selections available
|
||||
begin
|
||||
// Count of cell ranges
|
||||
AStream.WriteWord(WordToLE(n));
|
||||
{ Write each selected cell range }
|
||||
// Write each selected cell range
|
||||
for i := 0 to n-1 do
|
||||
begin
|
||||
sel := ASheet.GetSelection[i];
|
||||
{ Index to first and last row of this selected range }
|
||||
// Index to first and last row of this selected range
|
||||
AStream.WriteWord(WordToLE(sel.Row1));
|
||||
AStream.WriteWord(WordToLE(sel.Row2));
|
||||
{ Index to first and last column }
|
||||
{ Note: Even BIFF8 writes bytes here! This is ok because BIFF supports only 256 columns }
|
||||
// Index to first and last column
|
||||
// Note: Even BIFF8 writes bytes here! This is ok because BIFF supports only 256 columns
|
||||
AStream.WriteByte(sel.Col1);
|
||||
AStream.WriteByte(sel.Col2);
|
||||
end;
|
||||
@ -4002,9 +4002,10 @@ begin
|
||||
AStream.WriteWord(WordToLE(w));
|
||||
end;
|
||||
|
||||
procedure TsSpreadBIFFWriter.WriteToClipboardStream(AStream: TStream);
|
||||
procedure TsSpreadBIFFWriter.WriteToClipboardStream(AStream: TStream;
|
||||
AParam: Integer = 0);
|
||||
begin
|
||||
WriteToStream(AStream);
|
||||
WriteToStream(AStream, AParam);
|
||||
end;
|
||||
|
||||
procedure TsSpreadBIFFWriter.WriteVirtualCells(AStream: TStream);
|
||||
|
@ -69,8 +69,8 @@ type
|
||||
|
||||
public
|
||||
constructor Create(AWorkbook: TsWorkbook); override;
|
||||
procedure WriteToFile(const AFileName: string; const AOverwriteExisting: Boolean = False); override;
|
||||
procedure WriteToStream(AStream: TStream); override;
|
||||
// procedure WriteToFile(const AFileName: string; const AOverwriteExisting: Boolean = False); override;
|
||||
procedure WriteToStream(AStream: TStream; AParam: Integer = 0); override;
|
||||
|
||||
end;
|
||||
|
||||
@ -736,7 +736,7 @@ begin
|
||||
AppendToStream(AStream, TABLE_INDENT +
|
||||
'</Table>' + LF);
|
||||
end;
|
||||
|
||||
(*
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Writes an ExcelXML document to the file
|
||||
-------------------------------------------------------------------------------}
|
||||
@ -761,12 +761,16 @@ begin
|
||||
FreeAndNil(stream);
|
||||
end;
|
||||
end;
|
||||
*)
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Writes an ExcelXML document to a stream
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsSpreadExcelXMLWriter.WriteToStream(AStream: TStream);
|
||||
procedure TsSpreadExcelXMLWriter.WriteToStream(AStream: TStream;
|
||||
AParam: Integer = 0);
|
||||
begin
|
||||
Unused(AParam);
|
||||
|
||||
AppendToStream(AStream,
|
||||
'<?xml version="1.0"?>' + LF +
|
||||
'<?mso-application progid="Excel.Sheet"?>' + LF
|
||||
|
@ -189,8 +189,11 @@ type
|
||||
constructor Create(AWorkbook: TsWorkbook); override;
|
||||
{ General writing methods }
|
||||
procedure WriteStringToFile(AFileName, AString: string);
|
||||
procedure WriteToFile(const AFileName: string; const AOverwriteExisting: Boolean = False); override;
|
||||
procedure WriteToStream(AStream: TStream); override;
|
||||
{
|
||||
procedure WriteToFile(const AFileName: string;
|
||||
const AOverwriteExisting: Boolean = False; AParam: Integer = 0); override;
|
||||
}
|
||||
procedure WriteToStream(AStream: TStream; AParam: Integer = 0); override;
|
||||
end;
|
||||
|
||||
|
||||
@ -3716,11 +3719,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
(*
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Writes an OOXML document to the file
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsSpreadOOXMLWriter.WriteToFile(const AFileName: string;
|
||||
const AOverwriteExisting: Boolean);
|
||||
const AOverwriteExisting: Boolean; AParam: Integer = 0);
|
||||
var
|
||||
lStream: TStream;
|
||||
lMode: word;
|
||||
@ -3734,17 +3738,23 @@ begin
|
||||
else
|
||||
lStream := TFileStream.Create(AFileName, lMode);
|
||||
try
|
||||
WriteToStream(lStream);
|
||||
WriteToStream(lStream, AParam);
|
||||
finally
|
||||
FreeAndNil(lStream);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TsSpreadOOXMLWriter.WriteToStream(AStream: TStream);
|
||||
*)
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Writes an OOXML document to a stream
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsSpreadOOXMLWriter.WriteToStream(AStream: TStream;
|
||||
AParam: Integer = 0);
|
||||
var
|
||||
FZip: TZipper;
|
||||
i: Integer;
|
||||
begin
|
||||
Unused(AParam);
|
||||
|
||||
{ Analyze the workbook and collect all information needed }
|
||||
ListAllNumFormats;
|
||||
ListAllFills;
|
||||
|
Loading…
Reference in New Issue
Block a user