Qt/Qt5: improved startup time of qt/qt5 apps which does not use printers. QtDefaultPrinter handle is created on demand from now on.

git-svn-id: trunk@63001 -
This commit is contained in:
zeljko 2020-04-16 16:02:31 +00:00
parent 8fc4375ced
commit e3713e12b6
2 changed files with 150 additions and 116 deletions

View File

@ -600,7 +600,9 @@ type
FPrinterContext: TQtDeviceContext; FPrinterContext: TQtDeviceContext;
private private
FPrinterActive: Boolean; FPrinterActive: Boolean;
FPrintQuality: QPrinterPrinterMode;
function GetDuplexMode: QPrinterDuplexMode; function GetDuplexMode: QPrinterDuplexMode;
function GetHandle: QPrinterH;
function getPrinterContext: TQtDeviceContext; function getPrinterContext: TQtDeviceContext;
function getCollateCopies: Boolean; function getCollateCopies: Boolean;
function getColorMode: QPrinterColorMode; function getColorMode: QPrinterColorMode;
@ -676,7 +678,7 @@ type
property Duplex: QPrinterDuplexMode read GetDuplexMode write SetDuplexMode; property Duplex: QPrinterDuplexMode read GetDuplexMode write SetDuplexMode;
property FontEmbedding: Boolean read getFontEmbedding write setFontEmbedding; property FontEmbedding: Boolean read getFontEmbedding write setFontEmbedding;
property FullPage: Boolean read getFullPage write setFullPage; property FullPage: Boolean read getFullPage write setFullPage;
property Handle: QPrinterH read FHandle; property Handle: QPrinterH read GetHandle;
property NumCopies: Integer read getNumCopies write setNumCopies; property NumCopies: Integer read getNumCopies write setNumCopies;
property Orientation: QPrinterOrientation read getOrientation write setOrientation; property Orientation: QPrinterOrientation read getOrientation write setOrientation;
property OutputFormat: QPrinterOutputFormat read getOutputFormat write setOutputFormat; property OutputFormat: QPrinterOutputFormat read getOutputFormat write setOutputFormat;
@ -690,6 +692,7 @@ type
property PrintRange: QPrinterPrintRange read getPrintRange write setPrintRange; property PrintRange: QPrinterPrintRange read getPrintRange write setPrintRange;
property PrinterState: QPrinterPrinterState read getPrinterState; property PrinterState: QPrinterPrinterState read getPrinterState;
property PrintProgram: WideString read getPrintProgram write setPrintProgram; property PrintProgram: WideString read getPrintProgram write setPrintProgram;
property PrintQuality: QPrinterPrinterMode read FPrintQuality write FPrintQuality;
property Resolution: Integer read getResolution write setResolution; property Resolution: Integer read getResolution write setResolution;
end; end;
@ -4210,20 +4213,27 @@ end;
constructor TQtPrinter.Create; constructor TQtPrinter.Create;
begin begin
FPrinterActive := False; FPrinterActive := False;
FHandle := QPrinter_create(QPrinterHighResolution); FPrintQuality := QPrinterHighResolution;
FHandle := nil;
// QPrinter_create(FPrintQuality);
end; end;
constructor TQtPrinter.Create(AMode: QPrinterPrinterMode); constructor TQtPrinter.Create(AMode: QPrinterPrinterMode);
begin begin
FPrinterActive := False; FPrinterActive := False;
FHandle := QPrinter_create(AMode); FPrintQuality := AMode;
FHandle := nil;
// QPrinter_create(AMode);
end; end;
destructor TQtPrinter.Destroy; destructor TQtPrinter.Destroy;
begin begin
endDoc; endDoc;
if FHandle <> nil then if Assigned(FHandle) then
begin
QPrinter_destroy(FHandle); QPrinter_destroy(FHandle);
FHandle := nil;
end;
inherited Destroy; inherited Destroy;
end; end;
@ -4307,96 +4317,103 @@ end;
function TQtPrinter.GetDuplexMode: QPrinterDuplexMode; function TQtPrinter.GetDuplexMode: QPrinterDuplexMode;
begin begin
Result := QPrinter_duplex(FHandle); Result := QPrinter_duplex(Handle);
end;
function TQtPrinter.GetHandle: QPrinterH;
begin
if not Assigned(FHandle) then
FHandle := QPrinter_create(FPrintQuality);
Result := FHandle;
end; end;
function TQtPrinter.getCollateCopies: Boolean; function TQtPrinter.getCollateCopies: Boolean;
begin begin
Result := QPrinter_collateCopies(FHandle); Result := QPrinter_collateCopies(Handle);
end; end;
function TQtPrinter.getColorMode: QPrinterColorMode; function TQtPrinter.getColorMode: QPrinterColorMode;
begin begin
Result := QPrinter_colorMode(FHandle); Result := QPrinter_colorMode(Handle);
end; end;
function TQtPrinter.getCreator: WideString; function TQtPrinter.getCreator: WideString;
var var
Str: WideString; Str: WideString;
begin begin
QPrinter_creator(FHandle, @Str); QPrinter_creator(Handle, @Str);
Result := Str; Result := Str;
end; end;
function TQtPrinter.getDevType: Integer; function TQtPrinter.getDevType: Integer;
begin begin
Result := QPrinter_devType(FHandle); Result := QPrinter_devType(Handle);
end; end;
function TQtPrinter.getDocName: WideString; function TQtPrinter.getDocName: WideString;
var var
Str: WideString; Str: WideString;
begin begin
QPrinter_docName(FHandle, @Str); QPrinter_docName(Handle, @Str);
Result := Str; Result := Str;
end; end;
function TQtPrinter.getDoubleSidedPrinting: Boolean; function TQtPrinter.getDoubleSidedPrinting: Boolean;
begin begin
Result := QPrinter_doubleSidedPrinting(FHandle); Result := QPrinter_doubleSidedPrinting(Handle);
end; end;
function TQtPrinter.getFontEmbedding: Boolean; function TQtPrinter.getFontEmbedding: Boolean;
begin begin
Result := QPrinter_fontEmbeddingEnabled(FHandle); Result := QPrinter_fontEmbeddingEnabled(Handle);
end; end;
function TQtPrinter.getFullPage: Boolean; function TQtPrinter.getFullPage: Boolean;
begin begin
Result := QPrinter_fullPage(FHandle); Result := QPrinter_fullPage(Handle);
end; end;
procedure TQtPrinter.setOutputFormat(const AValue: QPrinterOutputFormat); procedure TQtPrinter.setOutputFormat(const AValue: QPrinterOutputFormat);
begin begin
QPrinter_setOutputFormat(FHandle, AValue); QPrinter_setOutputFormat(Handle, AValue);
end; end;
procedure TQtPrinter.setPaperSource(const AValue: QPrinterPaperSource); procedure TQtPrinter.setPaperSource(const AValue: QPrinterPaperSource);
begin begin
QPrinter_setPaperSource(FHandle, AValue); QPrinter_setPaperSource(Handle, AValue);
end; end;
function TQtPrinter.getOutputFormat: QPrinterOutputFormat; function TQtPrinter.getOutputFormat: QPrinterOutputFormat;
begin begin
Result := QPrinter_outputFormat(FHandle); Result := QPrinter_outputFormat(Handle);
end; end;
function TQtPrinter.getPaperSource: QPrinterPaperSource; function TQtPrinter.getPaperSource: QPrinterPaperSource;
begin begin
Result := QPrinter_paperSource(FHandle); Result := QPrinter_paperSource(Handle);
end; end;
function TQtPrinter.getPrintProgram: WideString; function TQtPrinter.getPrintProgram: WideString;
var var
Str: WideString; Str: WideString;
begin begin
QPrinter_printProgram(FHandle, @Str); QPrinter_printProgram(Handle, @Str);
Result := Str; Result := Str;
end; end;
function TQtPrinter.getPrintRange: QPrinterPrintRange; function TQtPrinter.getPrintRange: QPrinterPrintRange;
begin begin
Result := QPrinter_printRange(FHandle); Result := QPrinter_printRange(Handle);
end; end;
procedure TQtPrinter.setCollateCopies(const AValue: Boolean); procedure TQtPrinter.setCollateCopies(const AValue: Boolean);
begin begin
QPrinter_setCollateCopies(FHandle, AValue); QPrinter_setCollateCopies(Handle, AValue);
end; end;
procedure TQtPrinter.setColorMode(const AValue: QPrinterColorMode); procedure TQtPrinter.setColorMode(const AValue: QPrinterColorMode);
begin begin
QPrinter_setColorMode(FHandle, AValue); QPrinter_setColorMode(Handle, AValue);
end; end;
procedure TQtPrinter.setCreator(const AValue: WideString); procedure TQtPrinter.setCreator(const AValue: WideString);
@ -4404,7 +4421,7 @@ var
Str: WideString; Str: WideString;
begin begin
Str := AValue; Str := AValue;
QPrinter_setCreator(FHandle, @Str); QPrinter_setCreator(Handle, @Str);
end; end;
procedure TQtPrinter.setDocName(const AValue: WideString); procedure TQtPrinter.setDocName(const AValue: WideString);
@ -4412,27 +4429,27 @@ var
Str: WideString; Str: WideString;
begin begin
Str := AValue; Str := AValue;
QPrinter_setDocName(FHandle, @Str); QPrinter_setDocName(Handle, @Str);
end; end;
procedure TQtPrinter.setDoubleSidedPrinting(const AValue: Boolean); procedure TQtPrinter.setDoubleSidedPrinting(const AValue: Boolean);
begin begin
QPrinter_setDoubleSidedPrinting(FHandle, AValue); QPrinter_setDoubleSidedPrinting(Handle, AValue);
end; end;
procedure TQtPrinter.SetDuplexMode(AValue: QPrinterDuplexMode); procedure TQtPrinter.SetDuplexMode(AValue: QPrinterDuplexMode);
begin begin
QPrinter_setDuplex(FHandle, AValue); QPrinter_setDuplex(Handle, AValue);
end; end;
procedure TQtPrinter.setFontEmbedding(const AValue: Boolean); procedure TQtPrinter.setFontEmbedding(const AValue: Boolean);
begin begin
QPrinter_setFontEmbeddingEnabled(FHandle, AValue); QPrinter_setFontEmbeddingEnabled(Handle, AValue);
end; end;
procedure TQtPrinter.setFullPage(const AValue: Boolean); procedure TQtPrinter.setFullPage(const AValue: Boolean);
begin begin
QPrinter_setFullPage(FHandle, AValue); QPrinter_setFullPage(Handle, AValue);
end; end;
procedure TQtPrinter.setPrinterName(const AValue: WideString); procedure TQtPrinter.setPrinterName(const AValue: WideString);
@ -4441,14 +4458,14 @@ var
begin begin
Str := AValue; Str := AValue;
if getPrinterName <> AValue then if getPrinterName <> AValue then
QPrinter_setPrinterName(FHandle, @Str); QPrinter_setPrinterName(Handle, @Str);
end; end;
function TQtPrinter.getPrinterName: WideString; function TQtPrinter.getPrinterName: WideString;
var var
Str: WideString; Str: WideString;
begin begin
QPrinter_printerName(FHandle, @Str); QPrinter_printerName(Handle, @Str);
Result := Str; Result := Str;
end; end;
@ -4457,45 +4474,45 @@ var
Str: WideString; Str: WideString;
begin begin
Str := AValue; Str := AValue;
QPrinter_setOutputFileName(FHandle, @Str); QPrinter_setOutputFileName(Handle, @Str);
end; end;
function TQtPrinter.getOutputFileName: WideString; function TQtPrinter.getOutputFileName: WideString;
var var
Str: WideString; Str: WideString;
begin begin
QPrinter_outputFileName(FHandle, @Str); QPrinter_outputFileName(Handle, @Str);
Result := Str; Result := Str;
end; end;
procedure TQtPrinter.setOrientation(const AValue: QPrinterOrientation); procedure TQtPrinter.setOrientation(const AValue: QPrinterOrientation);
begin begin
QPrinter_setOrientation(FHandle, AValue); QPrinter_setOrientation(Handle, AValue);
end; end;
function TQtPrinter.getOrientation: QPrinterOrientation; function TQtPrinter.getOrientation: QPrinterOrientation;
begin begin
Result := QPrinter_orientation(FHandle); Result := QPrinter_orientation(Handle);
end; end;
procedure TQtPrinter.setPageSize(const AValue: QPrinterPageSize); procedure TQtPrinter.setPageSize(const AValue: QPrinterPageSize);
begin begin
QPrinter_setPaperSize(FHandle, AValue); QPrinter_setPaperSize(Handle, AValue);
end; end;
function TQtPrinter.getPageSize: QPrinterPageSize; function TQtPrinter.getPageSize: QPrinterPageSize;
begin begin
Result := QPrinter_paperSize(FHandle); Result := QPrinter_paperSize(Handle);
end; end;
procedure TQtPrinter.setPageOrder(const AValue: QPrinterPageOrder); procedure TQtPrinter.setPageOrder(const AValue: QPrinterPageOrder);
begin begin
QPrinter_setPageOrder(FHandle, AValue); QPrinter_setPageOrder(Handle, AValue);
end; end;
function TQtPrinter.getPageOrder: QPrinterPageOrder; function TQtPrinter.getPageOrder: QPrinterPageOrder;
begin begin
Result := QPrinter_pageOrder(FHandle); Result := QPrinter_pageOrder(Handle);
end; end;
procedure TQtPrinter.setPrintProgram(const AValue: WideString); procedure TQtPrinter.setPrintProgram(const AValue: WideString);
@ -4503,77 +4520,77 @@ var
Str: WideString; Str: WideString;
begin begin
Str := AValue; Str := AValue;
QPrinter_setPrintProgram(FHandle, @Str); QPrinter_setPrintProgram(Handle, @Str);
end; end;
procedure TQtPrinter.setPrintRange(const AValue: QPrinterPrintRange); procedure TQtPrinter.setPrintRange(const AValue: QPrinterPrintRange);
begin begin
QPrinter_setPrintRange(FHandle, AValue); QPrinter_setPrintRange(Handle, AValue);
end; end;
procedure TQtPrinter.setResolution(const AValue: Integer); procedure TQtPrinter.setResolution(const AValue: Integer);
begin begin
QPrinter_setResolution(FHandle, AValue); QPrinter_setResolution(Handle, AValue);
end; end;
function TQtPrinter.getResolution: Integer; function TQtPrinter.getResolution: Integer;
begin begin
Result := QPrinter_resolution(FHandle); Result := QPrinter_resolution(Handle);
end; end;
function TQtPrinter.getNumCopies: Integer; function TQtPrinter.getNumCopies: Integer;
begin begin
Result := QPrinter_numCopies(FHandle); Result := QPrinter_numCopies(Handle);
end; end;
procedure TQtPrinter.setNumCopies(const AValue: Integer); procedure TQtPrinter.setNumCopies(const AValue: Integer);
begin begin
QPrinter_setNumCopies(FHandle, AValue); QPrinter_setNumCopies(Handle, AValue);
end; end;
function TQtPrinter.getPrinterState: QPrinterPrinterState; function TQtPrinter.getPrinterState: QPrinterPrinterState;
begin begin
Result := QPrinter_printerState(FHandle); Result := QPrinter_printerState(Handle);
end; end;
function TQtPrinter.NewPage: Boolean; function TQtPrinter.NewPage: Boolean;
begin begin
Result := QPrinter_newPage(FHandle); Result := QPrinter_newPage(Handle);
end; end;
function TQtPrinter.Abort: Boolean; function TQtPrinter.Abort: Boolean;
begin begin
Result := QPrinter_abort(FHandle); Result := QPrinter_abort(Handle);
end; end;
procedure TQtPrinter.setFromPageToPage(const AFromPage, AToPage: Integer); procedure TQtPrinter.setFromPageToPage(const AFromPage, AToPage: Integer);
begin begin
QPrinter_setFromTo(FHandle, AFromPage, AToPage); QPrinter_setFromTo(Handle, AFromPage, AToPage);
end; end;
function TQtPrinter.fromPage: Integer; function TQtPrinter.fromPage: Integer;
begin begin
Result := QPrinter_fromPage(FHandle); Result := QPrinter_fromPage(Handle);
end; end;
function TQtPrinter.toPage: Integer; function TQtPrinter.toPage: Integer;
begin begin
Result := QPrinter_toPage(FHandle); Result := QPrinter_toPage(Handle);
end; end;
function TQtPrinter.PaintEngine: QPaintEngineH; function TQtPrinter.PaintEngine: QPaintEngineH;
begin begin
Result := QPrinter_paintEngine(FHandle); Result := QPrinter_paintEngine(Handle);
end; end;
function TQtPrinter.PageRect: TRect; function TQtPrinter.PageRect: TRect;
begin begin
QPrinter_pageRect(FHandle, @Result); QPrinter_pageRect(Handle, @Result);
end; end;
function TQtPrinter.PaperRect: TRect; function TQtPrinter.PaperRect: TRect;
begin begin
QPrinter_paperRect(FHandle, @Result); QPrinter_paperRect(Handle, @Result);
end; end;
function TQtPrinter.PageRect(AUnits: QPrinterUnit): TRect; function TQtPrinter.PageRect(AUnits: QPrinterUnit): TRect;
@ -4581,7 +4598,7 @@ var
R: QRectFH; R: QRectFH;
begin begin
R := QRectF_create(); R := QRectF_create();
QPrinter_pageRect(FHandle, R, AUnits); QPrinter_pageRect(Handle, R, AUnits);
QRectF_toRect(R, @Result); QRectF_toRect(R, @Result);
QRectF_destroy(R); QRectF_destroy(R);
end; end;
@ -4591,14 +4608,14 @@ var
R: QRectFH; R: QRectFH;
begin begin
R := QRectF_create(); R := QRectF_create();
QPrinter_paperRect(FHandle, R, AUnits); QPrinter_paperRect(Handle, R, AUnits);
QRectF_toRect(R, @Result); QRectF_toRect(R, @Result);
QRectF_destroy(R); QRectF_destroy(R);
end; end;
function TQtPrinter.PrintEngine: QPrintEngineH; function TQtPrinter.PrintEngine: QPrintEngineH;
begin begin
Result := QPrinter_printEngine(FHandle); Result := QPrinter_printEngine(Handle);
end; end;
function TQtPrinter.GetPaperSize(AUnits: QPrinterUnit): TSize; function TQtPrinter.GetPaperSize(AUnits: QPrinterUnit): TSize;
@ -4606,7 +4623,7 @@ var
SizeF: QSizeFH; SizeF: QSizeFH;
begin begin
SizeF := QSizeF_create(0, 0); SizeF := QSizeF_create(0, 0);
QPrinter_paperSize(FHandle, SizeF, AUnits); QPrinter_paperSize(Handle, SizeF, AUnits);
Result.cx := Round(QSizeF_width(SizeF)); Result.cx := Round(QSizeF_width(SizeF));
Result.cy := Round(QSizeF_height(SizeF)); Result.cy := Round(QSizeF_height(SizeF));
QSizeF_destroy(SizeF); QSizeF_destroy(SizeF);
@ -4618,7 +4635,7 @@ var
begin begin
SizeF := QSizeF_create(@ASize); SizeF := QSizeF_create(@ASize);
try try
QPrinter_setPaperSize(FHandle, SizeF, AUnits); QPrinter_setPaperSize(Handle, SizeF, AUnits);
finally finally
QSizeF_destroy(SizeF); QSizeF_destroy(SizeF);
end; end;
@ -4626,7 +4643,7 @@ end;
function TQtPrinter.SupportedResolutions: TPtrIntArray; function TQtPrinter.SupportedResolutions: TPtrIntArray;
begin begin
QPrinter_supportedResolutions(FHandle, @Result); QPrinter_supportedResolutions(Handle, @Result);
end; end;

View File

@ -597,7 +597,9 @@ type
FPrinterContext: TQtDeviceContext; FPrinterContext: TQtDeviceContext;
private private
FPrinterActive: Boolean; FPrinterActive: Boolean;
FPrintQuality: QPrinterPrinterMode;
function GetDuplexMode: QPrinterDuplexMode; function GetDuplexMode: QPrinterDuplexMode;
function GetHandle: QPrinterH;
function getPrinterContext: TQtDeviceContext; function getPrinterContext: TQtDeviceContext;
function getCollateCopies: Boolean; function getCollateCopies: Boolean;
function getColorMode: QPrinterColorMode; function getColorMode: QPrinterColorMode;
@ -673,7 +675,7 @@ type
property Duplex: QPrinterDuplexMode read GetDuplexMode write SetDuplexMode; property Duplex: QPrinterDuplexMode read GetDuplexMode write SetDuplexMode;
property FontEmbedding: Boolean read getFontEmbedding write setFontEmbedding; property FontEmbedding: Boolean read getFontEmbedding write setFontEmbedding;
property FullPage: Boolean read getFullPage write setFullPage; property FullPage: Boolean read getFullPage write setFullPage;
property Handle: QPrinterH read FHandle; property Handle: QPrinterH read GetHandle;
property NumCopies: Integer read getNumCopies write setNumCopies; property NumCopies: Integer read getNumCopies write setNumCopies;
property Orientation: QPrinterOrientation read getOrientation write setOrientation; property Orientation: QPrinterOrientation read getOrientation write setOrientation;
property OutputFormat: QPrinterOutputFormat read getOutputFormat write setOutputFormat; property OutputFormat: QPrinterOutputFormat read getOutputFormat write setOutputFormat;
@ -687,6 +689,7 @@ type
property PrintRange: QPrinterPrintRange read getPrintRange write setPrintRange; property PrintRange: QPrinterPrintRange read getPrintRange write setPrintRange;
property PrinterState: QPrinterPrinterState read getPrinterState; property PrinterState: QPrinterPrinterState read getPrinterState;
property PrintProgram: WideString read getPrintProgram write setPrintProgram; property PrintProgram: WideString read getPrintProgram write setPrintProgram;
property PrintQuality: QPrinterPrinterMode read FPrintQuality write FPrintQuality;
property Resolution: Integer read getResolution write setResolution; property Resolution: Integer read getResolution write setResolution;
end; end;
@ -4199,20 +4202,27 @@ end;
constructor TQtPrinter.Create; constructor TQtPrinter.Create;
begin begin
FPrinterActive := False; FPrinterActive := False;
FHandle := QPrinter_create(QPrinterHighResolution); FPrintQuality := QPrinterHighResolution;
FHandle := nil;
// QPrinter_create(QPrinterHighResolution);
end; end;
constructor TQtPrinter.Create(AMode: QPrinterPrinterMode); constructor TQtPrinter.Create(AMode: QPrinterPrinterMode);
begin begin
FPrinterActive := False; FPrinterActive := False;
FHandle := QPrinter_create(AMode); FPrintQuality := AMode; // QPrinterHighResolution;
FHandle := nil;
// FHandle := QPrinter_create(AMode);
end; end;
destructor TQtPrinter.Destroy; destructor TQtPrinter.Destroy;
begin begin
endDoc; endDoc;
if FHandle <> nil then if Assigned(FHandle) then
begin
QPrinter_destroy(FHandle); QPrinter_destroy(FHandle);
FHandle := nil;
end;
inherited Destroy; inherited Destroy;
end; end;
@ -4299,96 +4309,103 @@ end;
function TQtPrinter.GetDuplexMode: QPrinterDuplexMode; function TQtPrinter.GetDuplexMode: QPrinterDuplexMode;
begin begin
Result := QPrinter_duplex(FHandle); Result := QPrinter_duplex(Handle);
end;
function TQtPrinter.GetHandle: QPrinterH;
begin
if not Assigned(FHandle) then
FHandle := QPrinter_Create(FPrintQuality);
Result := FHandle;
end; end;
function TQtPrinter.getCollateCopies: Boolean; function TQtPrinter.getCollateCopies: Boolean;
begin begin
Result := QPrinter_collateCopies(FHandle); Result := QPrinter_collateCopies(Handle);
end; end;
function TQtPrinter.getColorMode: QPrinterColorMode; function TQtPrinter.getColorMode: QPrinterColorMode;
begin begin
Result := QPrinter_colorMode(FHandle); Result := QPrinter_colorMode(Handle);
end; end;
function TQtPrinter.getCreator: WideString; function TQtPrinter.getCreator: WideString;
var var
Str: WideString; Str: WideString;
begin begin
QPrinter_creator(FHandle, @Str); QPrinter_creator(Handle, @Str);
Result := UTF16ToUTF8(Str); Result := UTF16ToUTF8(Str);
end; end;
function TQtPrinter.getDevType: Integer; function TQtPrinter.getDevType: Integer;
begin begin
Result := QPrinter_devType(FHandle); Result := QPrinter_devType(Handle);
end; end;
function TQtPrinter.getDocName: WideString; function TQtPrinter.getDocName: WideString;
var var
Str: WideString; Str: WideString;
begin begin
QPrinter_docName(FHandle, @Str); QPrinter_docName(Handle, @Str);
Result := UTF16ToUTF8(Str); Result := UTF16ToUTF8(Str);
end; end;
function TQtPrinter.getDoubleSidedPrinting: Boolean; function TQtPrinter.getDoubleSidedPrinting: Boolean;
begin begin
Result := QPrinter_doubleSidedPrinting(FHandle); Result := QPrinter_doubleSidedPrinting(Handle);
end; end;
function TQtPrinter.getFontEmbedding: Boolean; function TQtPrinter.getFontEmbedding: Boolean;
begin begin
Result := QPrinter_fontEmbeddingEnabled(FHandle); Result := QPrinter_fontEmbeddingEnabled(Handle);
end; end;
function TQtPrinter.getFullPage: Boolean; function TQtPrinter.getFullPage: Boolean;
begin begin
Result := QPrinter_fullPage(FHandle); Result := QPrinter_fullPage(Handle);
end; end;
procedure TQtPrinter.setOutputFormat(const AValue: QPrinterOutputFormat); procedure TQtPrinter.setOutputFormat(const AValue: QPrinterOutputFormat);
begin begin
QPrinter_setOutputFormat(FHandle, AValue); QPrinter_setOutputFormat(Handle, AValue);
end; end;
procedure TQtPrinter.setPaperSource(const AValue: QPrinterPaperSource); procedure TQtPrinter.setPaperSource(const AValue: QPrinterPaperSource);
begin begin
QPrinter_setPaperSource(FHandle, AValue); QPrinter_setPaperSource(Handle, AValue);
end; end;
function TQtPrinter.getOutputFormat: QPrinterOutputFormat; function TQtPrinter.getOutputFormat: QPrinterOutputFormat;
begin begin
Result := QPrinter_outputFormat(FHandle); Result := QPrinter_outputFormat(Handle);
end; end;
function TQtPrinter.getPaperSource: QPrinterPaperSource; function TQtPrinter.getPaperSource: QPrinterPaperSource;
begin begin
Result := QPrinter_paperSource(FHandle); Result := QPrinter_paperSource(Handle);
end; end;
function TQtPrinter.getPrintProgram: WideString; function TQtPrinter.getPrintProgram: WideString;
var var
Str: WideString; Str: WideString;
begin begin
QPrinter_printProgram(FHandle, @Str); QPrinter_printProgram(Handle, @Str);
Result := UTF16ToUTF8(Str); Result := UTF16ToUTF8(Str);
end; end;
function TQtPrinter.getPrintRange: QPrinterPrintRange; function TQtPrinter.getPrintRange: QPrinterPrintRange;
begin begin
Result := QPrinter_printRange(FHandle); Result := QPrinter_printRange(Handle);
end; end;
procedure TQtPrinter.setCollateCopies(const AValue: Boolean); procedure TQtPrinter.setCollateCopies(const AValue: Boolean);
begin begin
QPrinter_setCollateCopies(FHandle, AValue); QPrinter_setCollateCopies(Handle, AValue);
end; end;
procedure TQtPrinter.setColorMode(const AValue: QPrinterColorMode); procedure TQtPrinter.setColorMode(const AValue: QPrinterColorMode);
begin begin
QPrinter_setColorMode(FHandle, AValue); QPrinter_setColorMode(Handle, AValue);
end; end;
procedure TQtPrinter.setCreator(const AValue: WideString); procedure TQtPrinter.setCreator(const AValue: WideString);
@ -4396,7 +4413,7 @@ var
Str: WideString; Str: WideString;
begin begin
Str := GetUtf8String(AValue); Str := GetUtf8String(AValue);
QPrinter_setCreator(FHandle, @Str); QPrinter_setCreator(Handle, @Str);
end; end;
procedure TQtPrinter.setDocName(const AValue: WideString); procedure TQtPrinter.setDocName(const AValue: WideString);
@ -4404,27 +4421,27 @@ var
Str: WideString; Str: WideString;
begin begin
Str := GetUtf8String(AValue); Str := GetUtf8String(AValue);
QPrinter_setDocName(FHandle, @Str); QPrinter_setDocName(Handle, @Str);
end; end;
procedure TQtPrinter.setDoubleSidedPrinting(const AValue: Boolean); procedure TQtPrinter.setDoubleSidedPrinting(const AValue: Boolean);
begin begin
QPrinter_setDoubleSidedPrinting(FHandle, AValue); QPrinter_setDoubleSidedPrinting(Handle, AValue);
end; end;
procedure TQtPrinter.SetDuplexMode(AValue: QPrinterDuplexMode); procedure TQtPrinter.SetDuplexMode(AValue: QPrinterDuplexMode);
begin begin
QPrinter_setDuplex(FHandle, AValue); QPrinter_setDuplex(Handle, AValue);
end; end;
procedure TQtPrinter.setFontEmbedding(const AValue: Boolean); procedure TQtPrinter.setFontEmbedding(const AValue: Boolean);
begin begin
QPrinter_setFontEmbeddingEnabled(FHandle, AValue); QPrinter_setFontEmbeddingEnabled(Handle, AValue);
end; end;
procedure TQtPrinter.setFullPage(const AValue: Boolean); procedure TQtPrinter.setFullPage(const AValue: Boolean);
begin begin
QPrinter_setFullPage(FHandle, AValue); QPrinter_setFullPage(Handle, AValue);
end; end;
procedure TQtPrinter.setPrinterName(const AValue: WideString); procedure TQtPrinter.setPrinterName(const AValue: WideString);
@ -4433,14 +4450,14 @@ var
begin begin
Str := GetUtf8String(AValue); Str := GetUtf8String(AValue);
if getPrinterName <> Str then if getPrinterName <> Str then
QPrinter_setPrinterName(FHandle, @Str); QPrinter_setPrinterName(Handle, @Str);
end; end;
function TQtPrinter.getPrinterName: WideString; function TQtPrinter.getPrinterName: WideString;
var var
Str: WideString; Str: WideString;
begin begin
QPrinter_printerName(FHandle, @Str); QPrinter_printerName(Handle, @Str);
Result := UTF16ToUTF8(Str); Result := UTF16ToUTF8(Str);
end; end;
@ -4449,45 +4466,45 @@ var
Str: WideString; Str: WideString;
begin begin
Str := GetUtf8String(AValue); Str := GetUtf8String(AValue);
QPrinter_setOutputFileName(FHandle, @Str); QPrinter_setOutputFileName(Handle, @Str);
end; end;
function TQtPrinter.getOutputFileName: WideString; function TQtPrinter.getOutputFileName: WideString;
var var
Str: WideString; Str: WideString;
begin begin
QPrinter_outputFileName(FHandle, @Str); QPrinter_outputFileName(Handle, @Str);
Result := UTF16ToUTF8(Str); Result := UTF16ToUTF8(Str);
end; end;
procedure TQtPrinter.setOrientation(const AValue: QPrinterOrientation); procedure TQtPrinter.setOrientation(const AValue: QPrinterOrientation);
begin begin
QPrinter_setOrientation(FHandle, AValue); QPrinter_setOrientation(Handle, AValue);
end; end;
function TQtPrinter.getOrientation: QPrinterOrientation; function TQtPrinter.getOrientation: QPrinterOrientation;
begin begin
Result := QPrinter_orientation(FHandle); Result := QPrinter_orientation(Handle);
end; end;
procedure TQtPrinter.setPageSize(const AValue: QPagedPaintDevicePageSize); procedure TQtPrinter.setPageSize(const AValue: QPagedPaintDevicePageSize);
begin begin
QPrinter_setPaperSize(FHandle, AValue); QPrinter_setPaperSize(Handle, AValue);
end; end;
function TQtPrinter.getPageSize: QPagedPaintDevicePageSize; function TQtPrinter.getPageSize: QPagedPaintDevicePageSize;
begin begin
Result := QPrinter_paperSize(FHandle); Result := QPrinter_paperSize(Handle);
end; end;
procedure TQtPrinter.setPageOrder(const AValue: QPrinterPageOrder); procedure TQtPrinter.setPageOrder(const AValue: QPrinterPageOrder);
begin begin
QPrinter_setPageOrder(FHandle, AValue); QPrinter_setPageOrder(Handle, AValue);
end; end;
function TQtPrinter.getPageOrder: QPrinterPageOrder; function TQtPrinter.getPageOrder: QPrinterPageOrder;
begin begin
Result := QPrinter_pageOrder(FHandle); Result := QPrinter_pageOrder(Handle);
end; end;
procedure TQtPrinter.setPrintProgram(const AValue: WideString); procedure TQtPrinter.setPrintProgram(const AValue: WideString);
@ -4495,77 +4512,77 @@ var
Str: WideString; Str: WideString;
begin begin
Str := GetUtf8String(AValue); Str := GetUtf8String(AValue);
QPrinter_setPrintProgram(FHandle, @Str); QPrinter_setPrintProgram(Handle, @Str);
end; end;
procedure TQtPrinter.setPrintRange(const AValue: QPrinterPrintRange); procedure TQtPrinter.setPrintRange(const AValue: QPrinterPrintRange);
begin begin
QPrinter_setPrintRange(FHandle, AValue); QPrinter_setPrintRange(Handle, AValue);
end; end;
procedure TQtPrinter.setResolution(const AValue: Integer); procedure TQtPrinter.setResolution(const AValue: Integer);
begin begin
QPrinter_setResolution(FHandle, AValue); QPrinter_setResolution(Handle, AValue);
end; end;
function TQtPrinter.getResolution: Integer; function TQtPrinter.getResolution: Integer;
begin begin
Result := QPrinter_resolution(FHandle); Result := QPrinter_resolution(Handle);
end; end;
function TQtPrinter.getNumCopies: Integer; function TQtPrinter.getNumCopies: Integer;
begin begin
Result := QPrinter_numCopies(FHandle); Result := QPrinter_numCopies(Handle);
end; end;
procedure TQtPrinter.setNumCopies(const AValue: Integer); procedure TQtPrinter.setNumCopies(const AValue: Integer);
begin begin
QPrinter_setNumCopies(FHandle, AValue); QPrinter_setNumCopies(Handle, AValue);
end; end;
function TQtPrinter.getPrinterState: QPrinterPrinterState; function TQtPrinter.getPrinterState: QPrinterPrinterState;
begin begin
Result := QPrinter_printerState(FHandle); Result := QPrinter_printerState(Handle);
end; end;
function TQtPrinter.NewPage: Boolean; function TQtPrinter.NewPage: Boolean;
begin begin
Result := QPrinter_newPage(FHandle); Result := QPrinter_newPage(Handle);
end; end;
function TQtPrinter.Abort: Boolean; function TQtPrinter.Abort: Boolean;
begin begin
Result := QPrinter_abort(FHandle); Result := QPrinter_abort(Handle);
end; end;
procedure TQtPrinter.setFromPageToPage(const AFromPage, AToPage: Integer); procedure TQtPrinter.setFromPageToPage(const AFromPage, AToPage: Integer);
begin begin
QPrinter_setFromTo(FHandle, AFromPage, AToPage); QPrinter_setFromTo(Handle, AFromPage, AToPage);
end; end;
function TQtPrinter.fromPage: Integer; function TQtPrinter.fromPage: Integer;
begin begin
Result := QPrinter_fromPage(FHandle); Result := QPrinter_fromPage(Handle);
end; end;
function TQtPrinter.toPage: Integer; function TQtPrinter.toPage: Integer;
begin begin
Result := QPrinter_toPage(FHandle); Result := QPrinter_toPage(Handle);
end; end;
function TQtPrinter.PaintEngine: QPaintEngineH; function TQtPrinter.PaintEngine: QPaintEngineH;
begin begin
Result := QPrinter_paintEngine(FHandle); Result := QPrinter_paintEngine(Handle);
end; end;
function TQtPrinter.PageRect: TRect; function TQtPrinter.PageRect: TRect;
begin begin
QPrinter_pageRect(FHandle, @Result); QPrinter_pageRect(Handle, @Result);
end; end;
function TQtPrinter.PaperRect: TRect; function TQtPrinter.PaperRect: TRect;
begin begin
QPrinter_paperRect(FHandle, @Result); QPrinter_paperRect(Handle, @Result);
end; end;
function TQtPrinter.PageRect(AUnits: QPrinterUnit): TRect; function TQtPrinter.PageRect(AUnits: QPrinterUnit): TRect;
@ -4573,7 +4590,7 @@ var
R: QRectFH; R: QRectFH;
begin begin
R := QRectF_create(); R := QRectF_create();
QPrinter_pageRect(FHandle, R, AUnits); QPrinter_pageRect(Handle, R, AUnits);
QRectF_toRect(R, @Result); QRectF_toRect(R, @Result);
QRectF_destroy(R); QRectF_destroy(R);
end; end;
@ -4583,14 +4600,14 @@ var
R: QRectFH; R: QRectFH;
begin begin
R := QRectF_create(); R := QRectF_create();
QPrinter_paperRect(FHandle, R, AUnits); QPrinter_paperRect(Handle, R, AUnits);
QRectF_toRect(R, @Result); QRectF_toRect(R, @Result);
QRectF_destroy(R); QRectF_destroy(R);
end; end;
function TQtPrinter.PrintEngine: QPrintEngineH; function TQtPrinter.PrintEngine: QPrintEngineH;
begin begin
Result := QPrinter_printEngine(FHandle); Result := QPrinter_printEngine(Handle);
end; end;
function TQtPrinter.GetPaperSize(AUnits: QPrinterUnit): TSize; function TQtPrinter.GetPaperSize(AUnits: QPrinterUnit): TSize;
@ -4598,7 +4615,7 @@ var
SizeF: QSizeFH; SizeF: QSizeFH;
begin begin
SizeF := QSizeF_create(0, 0); SizeF := QSizeF_create(0, 0);
QPrinter_paperSize(FHandle, SizeF, AUnits); QPrinter_paperSize(Handle, SizeF, AUnits);
Result.cx := Round(QSizeF_width(SizeF)); Result.cx := Round(QSizeF_width(SizeF));
Result.cy := Round(QSizeF_height(SizeF)); Result.cy := Round(QSizeF_height(SizeF));
QSizeF_destroy(SizeF); QSizeF_destroy(SizeF);
@ -4610,7 +4627,7 @@ var
begin begin
SizeF := QSizeF_create(@ASize); SizeF := QSizeF_create(@ASize);
try try
QPrinter_setPaperSize(FHandle, SizeF, AUnits); QPrinter_setPaperSize(Handle, SizeF, AUnits);
finally finally
QSizeF_destroy(SizeF); QSizeF_destroy(SizeF);
end; end;
@ -4618,7 +4635,7 @@ end;
function TQtPrinter.SupportedResolutions: TPtrIntArray; function TQtPrinter.SupportedResolutions: TPtrIntArray;
begin begin
QPrinter_supportedResolutions(FHandle, @Result); QPrinter_supportedResolutions(Handle, @Result);
end; end;