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;