You've already forked lazarus-ccr
fpspreadsheet: Add 2nd html format for copying to clipboard.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4359 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -1677,15 +1677,17 @@ end;
|
|||||||
|
|
||||||
procedure TsHTMLWriter.WriteToClipboardStream(AStream: TStream);
|
procedure TsHTMLWriter.WriteToClipboardStream(AStream: TStream);
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF MSWINDOWS}
|
||||||
FClipboardMode := true;
|
FClipboardMode := true;
|
||||||
AppendToStream(AStream, Format(
|
AppendToStream(AStream, Format(
|
||||||
NATIVE_HEADER, [0, 0, 0, 0])); // value will be replaced at end
|
NATIVE_HEADER, [0, 0, 0, 0])); // value will be replaced at end
|
||||||
|
|
||||||
WriteToStream(AStream);
|
WriteToStream(AStream);
|
||||||
|
|
||||||
AStream.Position := 0;
|
AStream.Position := 0;
|
||||||
AppendToStream(AStream, Format(
|
AppendToStream(AStream, Format(
|
||||||
NATIVE_HEADER, [FStartHTMLPos, FEndHTMLPos, FStartFragmentPos, FEndFragmentPos]));
|
NATIVE_HEADER, [FStartHTMLPos, FEndHTMLPos, FStartFragmentPos, FEndFragmentPos]));
|
||||||
|
{$ELSE}
|
||||||
|
WriteToStream(AStream);
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsHTMLWriter.WriteToStream(AStream: TStream);
|
procedure TsHTMLWriter.WriteToStream(AStream: TStream);
|
||||||
|
@@ -471,6 +471,7 @@ var
|
|||||||
cfBiff8Format: Integer = 0;
|
cfBiff8Format: Integer = 0;
|
||||||
cfBiff5Format: Integer = 0;
|
cfBiff5Format: Integer = 0;
|
||||||
cfHTMLFormat: Integer = 0;
|
cfHTMLFormat: Integer = 0;
|
||||||
|
cfTextHTMLFormat: Integer = 0;
|
||||||
cfCSVFormat: Integer = 0;
|
cfCSVFormat: Integer = 0;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
@@ -1174,6 +1175,10 @@ begin
|
|||||||
if cfHTMLFormat = 0 then
|
if cfHTMLFormat = 0 then
|
||||||
cfHTMLFormat := RegisterClipboardFormat('HTML Format');
|
cfHTMLFormat := RegisterClipboardFormat('HTML Format');
|
||||||
|
|
||||||
|
cfTextHTMLFormat := Clipboard.FindFormatID('text/html');
|
||||||
|
if cfTextHTMLFormat = 0 then
|
||||||
|
cfTextHTMLFormat := RegisterClipboardFormat('text/html');
|
||||||
|
|
||||||
// dto with CSV clipboard format
|
// dto with CSV clipboard format
|
||||||
cfCSVFormat := Clipboard.FindFormatID('CSV');
|
cfCSVFormat := Clipboard.FindFormatID('CSV');
|
||||||
if cfCSVFormat = 0 then
|
if cfCSVFormat = 0 then
|
||||||
@@ -1189,10 +1194,13 @@ begin
|
|||||||
// Then write BIFF5 format
|
// Then write BIFF5 format
|
||||||
FWorkbook.CopyToClipboardStream(stream, sfExcel5);
|
FWorkbook.CopyToClipboardStream(stream, sfExcel5);
|
||||||
Clipboard.AddFormat(cfBiff5Format, stream);
|
Clipboard.AddFormat(cfBiff5Format, stream);
|
||||||
|
(stream as TMemoryStream).Clear;
|
||||||
|
|
||||||
// Then write HTML format
|
// Then write HTML format
|
||||||
FWorkbook.CopyToClipboardStream(stream, sfHTML);
|
FWorkbook.CopyToClipboardStream(stream, sfHTML);
|
||||||
Clipboard.AddFormat(cfHTMLFormat, stream);
|
Clipboard.AddFormat(cfHTMLFormat, stream);
|
||||||
|
Clipboard.AddFormat(cfTextHTMLFormat, stream);
|
||||||
|
(stream as TMemoryStream).Clear;
|
||||||
|
|
||||||
// Then write CSV format
|
// Then write CSV format
|
||||||
csv := CSVParams;
|
csv := CSVParams;
|
||||||
@@ -1201,12 +1209,14 @@ begin
|
|||||||
CsvParams.SheetIndex := FWorkbook.GetWorksheetIndex(FWorkbook.ActiveWorksheet);
|
CsvParams.SheetIndex := FWorkbook.GetWorksheetIndex(FWorkbook.ActiveWorksheet);
|
||||||
FWorkbook.CopyToClipboardStream(stream, sfCSV);
|
FWorkbook.CopyToClipboardStream(stream, sfCSV);
|
||||||
Clipboard.AddFormat(cfCSVFormat, stream);
|
Clipboard.AddFormat(cfCSVFormat, stream);
|
||||||
|
(stream as TMemoryStream).Clear;
|
||||||
|
|
||||||
// Finally write TEXT format
|
// Finally write TEXT format
|
||||||
CsvParams.Delimiter := #9;
|
CsvParams.Delimiter := #9;
|
||||||
FWorkbook.CopyToClipboardStream(stream, sfCSV);
|
FWorkbook.CopyToClipboardStream(stream, sfCSV);
|
||||||
Clipboard.AddFormat(CF_TEXT, stream);
|
Clipboard.AddFormat(CF_TEXT, stream);
|
||||||
CSVParams := csv;
|
CSVParams := csv;
|
||||||
|
(stream as TMemoryStream).Clear;
|
||||||
|
|
||||||
// To do: XML format
|
// To do: XML format
|
||||||
// I don't know which format is written by xlsx and ods natively.
|
// I don't know which format is written by xlsx and ods natively.
|
||||||
|
Reference in New Issue
Block a user