Bug 149439 - CUPS printing custom usercode with lpoptions isn't shown in Libreoffice
Summary: CUPS printing custom usercode with lpoptions isn't shown in Libreoffice
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Printing and PDF export (show other bugs)
Version:
(earliest affected)
7.3.3.2 release
Hardware: x86-64 (AMD64) Linux (All)
: low minor
Assignee: Caolán McNamara
URL: https://ask.libreoffice.org/t/custom-...
Whiteboard: target:7.5.0
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-03 08:28 UTC by TxOfficial
Modified: 2022-07-29 11:43 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description TxOfficial 2022-06-03 08:28:44 UTC
Description:
Hello together,

i have a problem when i try to use lpoptions with a custom usercode in libre. I still raised a ticket on the github cups site but they said that this must be a problem/bug within libre. Can you please have a look to the cups ticket and tell me how i can escalate it to the correct development team of libre?

[custom usercode with lpoptions isn’t shown in Libreoffice · Issue #405 · OpenPrinting/cups (github.com)]

https://github.com/OpenPrinting/cups/issues/405

The cups developer still checked the API function and this should work correctly. Can you please check this function from your side?

Many thanks and best regards..

Steps to Reproduce:
1.Create a cups printer named "test" with a PPD from openprinting.org with customer usercode function. I used this PPD file:

https://www.openprinting.org/download/PPD/Ricoh/PS/Ricoh-IM_C3000_PS.ppd

2. use "lpoptions -p test -o UserCode=Custom.0850" to set the usercode "0850"

3. start libre office and check the predefined value. This will be set to custom but without the value "0850" so that the generated print data doesn't contain the customer usercode.

4.this only happens when you use custom.xxxx . When you use one of the three predefined values 1001,1002, or 1003 it works. 
 

Actual Results:
No custom usercode in the print datastream

Expected Results:
Custom usercode "0850" in the print datastream 


Reproducible: Always


User Profile Reset: No



Additional Info:
Please check the already open Cups error report for more details about the CUPS API:

https://github.com/OpenPrinting/cups/issues/405

There are also screenshots attached, that show the problem.
Comment 1 Buovjaga 2022-07-01 08:54:02 UTC
(In reply to TxOfficial from comment #0)
> Steps to Reproduce:
> 1.Create a cups printer named "test" with a PPD from openprinting.org with
> customer usercode function. I used this PPD file:
> 
> https://www.openprinting.org/download/PPD/Ricoh/PS/Ricoh-IM_C3000_PS.ppd

To make things quicker for us testers, can you share the command to do this in the terminal?
Comment 2 V Stuart Foote 2022-07-02 13:03:05 UTC
Discussion of github CUPS issue in comment 0 suggests we need to revisit use of the CUPS APIs.

cupsMgr.cxx uses cupsGetDests() and cupsGetDests2()

Setting the printer configuration via command line lpoptions call is external, and not the issue, I think.

Believe we'd need to expose the printer name and user code via the cupsGetDests2 called array. Or possibly use the cupsGetNamedDest().  

@Caolán, you'd brought in use of cupsGetDests2() to fix rhbz#1267635, but last work was OOo era at CUPS 1.2
Comment 3 V Stuart Foote 2022-07-02 13:09:42 UTC
(In reply to V Stuart Foote from comment #2)
> but last work was OOo era at CUPS 1.2

by that I meant any "refactoring" of course, the maintenance of CUPS has been continuous.
Comment 4 TxOfficial 2022-07-04 09:29:41 UTC
@Buovjaga: the command line to create a new printer is:

lpadmin -p <printername> -P ~/Downloads/Ricoh-IM_C3000_PS.ppd -v "lpd://<ipadress>/lp"

The option -v can also contain any other URI, depends on the printer. Sometimes i use a windows shared printer by lpd to capture the outgoing datastream after the backend.

@V Stuart Foote: I am not sure but i think in CUPS 1.2 was the possibiliy of free text/custom values not available. I think this function was released in any later cups versions. 

If i can help anywhere please let me know.

Many thanks and best regards.
Tim
Comment 5 Buovjaga 2022-07-04 10:08:12 UTC
Thanks for the command.

(In reply to TxOfficial from comment #0)
> 3. start libre office and check the predefined value. This will be set to
> custom but without the value "0850" so that the generated print data doesn't
> contain the customer usercode.

For this, I figured out I need to go to File - Print - Properties - Device - Option: User Code (up to 8 digits).

Arch Linux 64-bit
Version: 7.3.4.2 / LibreOffice Community
Build ID: 30(Build:2)
CPU threads: 8; OS: Linux 5.18; UI render: default; VCL: VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
7.3.4-2
Calc: threaded
Comment 6 TxOfficial 2022-07-19 06:47:23 UTC Comment hidden (obsolete)
Comment 7 Buovjaga 2022-07-19 06:51:30 UTC
(In reply to TxOfficial from comment #6)
> Hello together,
> 
> i am not sure how this problem can be fixed or how the progress of this bug
> report move forward? Any idea from your side what i can do to fix this or is
> anybody there who can pick up and assign this case?
> 
> I am a little bit lost in space, because i dont know the official procedure
> how such a bug will be fixed.

The official procedure is that anyone can announce they will fix the bug, but we can't force people to do it. If you want timely fixes, paid support is available: https://www.libreoffice.org/get-help/professional-support/

If you want to fix it yourself based on the hints mentioned in comment 2, you are free to do so: https://wiki.documentfoundation.org/Development/GetInvolved
Comment 8 Caolán McNamara 2022-07-19 16:36:27 UTC
https://gerrit.libreoffice.org/c/core/+/137237 might be sufficient. I see the default custom value in the dialog at least afterwards.
Comment 9 Commit Notification 2022-07-19 19:48:22 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/21a31eefab1401d288dbb8220f3df3365be9efaf

tdf#149439 set initial customoption values from lpoptions when present

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Caolán McNamara 2022-07-21 07:49:40 UTC
Its worth checking a daily now to see if it works like it should or if it just superficially changed in the UI
Comment 11 TxOfficial 2022-07-22 10:06:03 UTC
Hello together,

many thanks for the change it works now. But only if you set lpoptions before you start Libre. As working example:

1. lpoptions -p <printername> -o UserCode=Custom.1234
2. Start Libre and print works with the usercode 1234

Not working example:

1. lpoptions -p <printername> -o UserCode=Custom.1234
2. Start Libre and print works with the usercode 1234
3. execute "lpoptions -p <printername> -o UserCode=Custom.5678" in command line
4. Print from Libre use the old Usercode "1234" and not "5678".

(5. restart Libre and print use Usercode "5678")

I am not sure if its possible to read the value every time when you open the print dialog, so that a restart of Libre is not necessary.

Many thanks and best regards..
Comment 12 Caolán McNamara 2022-07-26 19:34:06 UTC
we do a kind of sync each time the print dialog is opened, so I think I can shoehorn something in there
Comment 13 Commit Notification 2022-07-27 08:45:39 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/93f28ca499c6d15415f359a9e868a72bbcdc9b4b

tdf#149439 Update Custom values that may have changed since last printer check

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 14 Caolán McNamara 2022-07-29 11:43:00 UTC
Should be worth rechecking a new daily, seems to do the right thing for me