tdf#123734 Prepend "Custom." for values of custom PPD options

CUPS supports using custom options in PPDs, which go beyond
what is specified in the PPD specification, s. doc at at [1].

[2] mentions that the "Custom." prefix is needed when specifying
custom page sizes:

> When Custom is listed for the PageSize option, you can specify custom
> media sizes using one of the following forms:
>
>    lp -o media=Custom.WIDTHxLENGTH filename
>    lp -o media=Custom.WIDTHxLENGTHin filename
>    lp -o media=Custom.WIDTHxLENGTHcm filename
>    lp -o media=Custom.WIDTHxLENGTHmm filename

While I did not find any explicit documentation that the same
is true for CUPS-specific custom options, this is apparently the case.
(The "CustomPageSize" keyword is expclicitly specified in the PPD
specification [3], section 5.16 "Custom Page Sizes" and thus not
a CUPS-specific custom option.)

This can be seen e.g. by the fact that after setting the default
value for a PPD option to such a custom value, the corresponding
entry in the PPD does get the "Custom." prefix, e.g.

    *DefaultPassword: Custom.12345

for the sample PPD from tdf#123734.

For more details, s.a. the discussion on the similar bug report
for Gtk+ at [4], where e.g. comment 0 says:

> According to the cups people, the value should have been
> "Custom.ThisIsAtest" in this case. Without the "Custom." part,
> this is not used by the cups filters.

Therefore, add the "Custom." prefix for custom options, but don't show
them in the UI.

[1] https://www.cups.org/doc/spec-ppd.html#OPTIONS
[2] https://www.cups.org/doc/options.html
[3] https://web.archive.org/web/20161017222612/http://partners.adobe.com/public/developer/en/ps/5003.PPD_Spec_v4.3.pdf
[4] https://bugzilla.gnome.org/show_bug.cgi?id=543520

Change-Id: I570d8b55212c6fc33405460f11d152e86cedb0f9
Reviewed-on: https://gerrit.libreoffice.org/82722
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn 2019-11-14 17:34:40 +01:00
parent feec8e3c34
commit 3c825bcc48

View File

@ -411,7 +411,9 @@ IMPL_LINK(RTSDevicePage, ModifyHdl, weld::Entry&, rEdit, void)
{
if (m_pCustomValue)
{
m_pCustomValue->m_aCustomOption = rEdit.get_text();
// tdf#123734 Custom PPD option values are a CUPS extension to PPDs and the user-set value
// needs to be prefixed with "Custom." in order to be processed properly
m_pCustomValue->m_aCustomOption = "Custom." + rEdit.get_text();
}
}
@ -477,7 +479,8 @@ void RTSDevicePage::ValueBoxChanged( const PPDKey* pKey )
{
m_pCustomValue = pValue;
m_pParent->m_aJobData.m_aContext.setValue(pKey, pValue);
m_xCustomEdit->set_text(m_pCustomValue->m_aCustomOption);
// don't show the "Custom." prefix in the UI, s.a. comment in ModifyHdl
m_xCustomEdit->set_text(m_pCustomValue->m_aCustomOption.replaceFirst("Custom.", ""));
m_xCustomEdit->show();
m_aReselectCustomIdle.Start();
}