From 2c489449328336bb19354574add43420a63f5035 Mon Sep 17 00:00:00 2001 From: jesus Date: Thu, 25 Feb 2010 22:13:20 +0000 Subject: [PATCH] Printers, CUPS, do not mix paper and paper sources in list of supported papers git-svn-id: trunk@23793 - --- components/printers/unix/cupsprinters.inc | 36 +++++++++++++++++---- components/printers/unix/cupsprinters_h.inc | 1 + 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/components/printers/unix/cupsprinters.inc b/components/printers/unix/cupsprinters.inc index 6ea0a7877c..f321f283c7 100644 --- a/components/printers/unix/cupsprinters.inc +++ b/components/printers/unix/cupsprinters.inc @@ -827,12 +827,33 @@ begin end; procedure TCUPSPrinter.DoEnumPapers(Lst: TStrings); +var + choice: Pppd_choice_t; + Option: Pppd_option_t; + c: Integer; begin //DebugLn(['TCUPSPrinter.DoEnumPapers ',dbgsName(Self)]); - inherited DoEnumPapers(Lst); - - GetEnumAttributeString('media-supported',Lst); - + + //TODO: note that we are returning here the list of paper "keys" + // not the human readable paper names. Modify cups support + // to return human readable paper names. + + Lst.Clear; + FCupsDefaultPaper := ''; + if CupsPPD<>nil then + begin + Option := ppdFindOption(CupsPPD, PChar('PageSize')); + Choice := Option^.choices; + fCupsDefaultPaper := Choice^.choice; + c := 0; + while (Choice<>nil) and (c'' then + fCachedGetDefaultPaperName:= FCupsDefaultPaper + else + fCachedGetDefaultPaperName:= GetAttributeString('media-default',fCachedGetDefaultPaperName); {$IFDEF UseCache} Include(FStates,cpsDefaultPaperNameValid); diff --git a/components/printers/unix/cupsprinters_h.inc b/components/printers/unix/cupsprinters_h.inc index 265046d014..8fdede2255 100644 --- a/components/printers/unix/cupsprinters_h.inc +++ b/components/printers/unix/cupsprinters_h.inc @@ -87,6 +87,7 @@ type fCachePaperRectName: string; fCachePaperRect: TPaperRect; fCachePaperRectResult: Integer; + fCupsDefaultPaper: string; FBeginDocCount: Integer; fRawModeStream: TMemoryStream; FOutputFilename: string;