Bug 152611

Summary: Can save as pdf if I open the Print dialog and click the 'Print' tab while lockExport option is set to true
Product: LibreOffice Reporter: dev.limarev
Component: Printing and PDF exportAssignee: Not Assigned <libreoffice-bugs>
Status: RESOLVED NOTABUG    
Severity: normal CC: samuel.mehrbrodt
Priority: medium    
Version: 7.4.0.3 release   
Hardware: x86-64 (AMD64)   
OS: Windows (All)   
Whiteboard:
Crash report or crash signature: Regression By:

Description dev.limarev 2022-12-20 09:23:20 UTC
Description:
MediaDescriptor lockExport option is set to true with model->setArgs(), but print option is enabled.
Export and Save As options in File menu are disable and do look inactive, but if I open the Print dialog and click the 'Print' button, I can still save as pdf.

Steps to Reproduce:
1.Set lockExport to true
2.Open the Print dialog
3.Click the 'Print' button
4.Prompt to save the document in pdf
5.Save the document

Actual Results:
Document can be exported as pdf and then printed

Expected Results:
Document cannot be saved, but can be printed


Reproducible: Always


User Profile Reset: Yes

Additional Info:
Version: 7.4.0.3 (x64) / LibreOffice Community
Build ID: f85e47c08ddd19c015c0114a68350214f7066f5a
CPU threads: 8; OS: Windows 10.0 Build 17763; UI render: Skia/Raster; VCL: win
Locale: ru-RU (ru_RU); UI: en-US
Calc: threaded
Comment 1 Mike Kaganski 2022-12-21 11:07:12 UTC
For print, there's a separate LockPrint option [1]. A PDF virtual printer is just a printer - how could LibreOffice block it without blocking the whole printing?

[1] https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1document_1_1MediaDescriptor.html#a726c7b60ea2b2c1caa2766576dcaa148
Comment 2 dev.limarev 2022-12-21 11:49:11 UTC
(In reply to Mike Kaganski from comment #1)
> For print, there's a separate LockPrint option [1]. A PDF virtual printer is
> just a printer - how could LibreOffice block it without blocking the whole
> printing?
> 
> [1]
> https://api.libreoffice.org/docs/idl/ref/
> servicecom_1_1sun_1_1star_1_1document_1_1MediaDescriptor.
> html#a726c7b60ea2b2c1caa2766576dcaa148

Thank you for reply!

In my case I want user to be able to print the document, but not to export. That's why I'm not using lockPrint option. So if lockExport is set to true, I expected SaveAs dialogs to be disabled wherever they appear.

Sorry, I'm not sure what is PDF virtual printer exactly means. LibreOffice executes PDF virtual printer by design after 'Print' button was clicked?
PDF virtual printer execution always results in SaveAs dialog?
Comment 3 Mike Kaganski 2022-12-21 12:23:48 UTC
(In reply to dev.limarev from comment #2)
> Sorry, I'm not sure what is PDF virtual printer exactly means. LibreOffice
> executes PDF virtual printer by design after 'Print' button was clicked?
> PDF virtual printer execution always results in SaveAs dialog?

No. But your description ("3.Click the 'Print' button; 4.Prompt to save the document in pdf") indicate that the printer that is selected in the Print dialog is a virtual PDF printer installed on your system (e.g., "Microsoft Print To PDF"). And it's the printer that shows you the "Save As" dialog, not LibreOffice; and LibreOffice can't prevent a third-party printer driver from showing whatever that driver wants...
Comment 4 Mike Kaganski 2022-12-21 12:25:42 UTC
(In reply to dev.limarev from comment #2)
> PDF virtual printer execution always results in SaveAs dialog?

And "yes" to this one :) I should had been more specific in my previous reply: the "No" there was to the "LibreOffice executes PDF virtual printer by design after 'Print' button was clicked?" question.
Comment 5 dev.limarev 2022-12-21 13:13:06 UTC
(In reply to Mike Kaganski from comment #3)
> No. But your description ("3.Click the 'Print' button; 4.Prompt to save the
> document in pdf") indicate that the printer that is selected in the Print
> dialog is a virtual PDF printer installed on your system (e.g., "Microsoft
> Print To PDF"). And it's the printer that shows you the "Save As" dialog,
> not LibreOffice; and LibreOffice can't prevent a third-party printer driver
> from showing whatever that driver wants...

Thank you for detailed explanation! Yep, "Microsoft Print To PDF" was indeed selected. Oh, now I see. If LibreOffice can block some printers, for example "Microsoft Print To PDF"?
Or the only way to have desired behaviour is to turn off these Microsoft printers at system level?
Comment 6 Mike Kaganski 2022-12-22 06:20:46 UTC
(In reply to dev.limarev from comment #5)
> If LibreOffice can block some printers, for example "Microsoft Print To PDF"?
> Or the only way to have desired behaviour is to turn off these Microsoft
> printers at system level?

I suppose that LibreOffice could filter some printers from the list shown here. Yet, it's not only "these Microsoft printers" - there are many virtual printers available: search for "printer" at the related Wikipedia article[1]. Additionally, I believe that the names of these printers on the system could change based on the software version, localization, and number of copies of a printer (it's possible to have several such "printers" installed, with different settings each).

Thus, the correct approach is indeed to avoid such printers on the system level, where exporting is restricted.

[1] https://en.wikipedia.org/wiki/List_of_PDF_software#Creators_3
Comment 7 dev.limarev 2022-12-28 06:37:04 UTC
(In reply to Mike Kaganski from comment #6)

Ok, now I see the whole picture. Really thank you for your help!
This is bug no more.