Print to File writes to incorrect file

Bug #1807744 reported by KarlRelton
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
LibreOffice
Unknown
Unknown
libreoffice (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

This bug only occurs when using the GTK3 dialogues (libreoffice-gtk3 installed).

Under certain conditions print to file over-writes an existing pdf file in the chosen folder which doesn't match the name chosen by the user (and without any warning or confirmation dialog).

Steps to reproduce are:
1) Create an empty directory (folder)
2) Put in directory a dummy pdf (e.g. touch sample.pdf)
3) Open libreoffice and create a writer document with a few words
4) Save the libreoffice document to the directory as a regular writer doc (e.g. 'test.odt')
5) Do 'File -> Print' and choose 'Print to File'
6) In the (gtk3) File-chooser dialog:
  6a) navigate to the folder created in step 2
  6b) select 'Any Type' in the 'types of file shown' selector
  6c) click on the file name 'test.odt'
  6d) in the 'Name' text field, then edit the name from 'test.odt' to 'test_2.pdf'
  6e) then press 'Enter' (or click on 'Select')
7) Observe that in the folder there is no file 'test_2.pdf'. However the dummy file 'sample.pdf' has been over-written and contains the pdf that resulted from the 'print to file' operation

-->What should of happened is that the file 'test_2.pdf' should have been created as a pdf of the writer document.

------
Some notes:

- Occurs in Libreoffice 6.1.2.1 (Build ID: 1:6.1.2-0ubuntu1.1) and older versions
- Only occurs using the gtk3 file browser. Native libreoffice is okay (not tested old gtk2 code)
- Only occurs if you first click on 'Any Type'. If you simply type a file name without first going to 'Any Type' it doesn't manifest the bug
- Only occurs if the file name you type has the '.pdf' extension. If you do a name without it, then it doesn't manifest the bug

lsb_release -rd
Description: Ubuntu 18.10
Release: 18.10

Revision history for this message
KarlRelton (karllinuxtest-relton) wrote :

This screenshot manages to show the problem.

Here I have typed in the 'Name' field 'test_2.pdf' when I already have that filename in my folder (as well as the dummy sample.pdf). I then press Enter, expecting to get the confirmation dialogue box asking about overwriting the file.

The confirmation box appears, but look at it carefully compared to what the FileChooser GTK3 widget is now showing behind it: the confirmation box shows name 'test_2.pdf' (which is what I typed), and the GTK3 widget not shows 'sample.pdf' (and also has changed the type selector to 'Portable Document Format'. Pressing 'okay' results in 'sample.pdf' being overwritten.

I think the bug happens when the dialogue self-flips the type selector to 'Portable Document Format'.

Revision history for this message
KarlRelton (karllinuxtest-relton) wrote :

>I think the bug happens when the dialogue self-flips the type selector to 'Portable Document Format'.

Yep ... if I manually flip the type selector to 'Portable Document Format' it loses my desired file name and pseudo-randomly selects a pdf file from the list of files in the folder.

So there are actually 2 incorrect behaviours going on:
1) changing type selector to 'Portable Document Format' should not change the file name in the 'name' field IF the user has already made some edits in that field (i.e. has taken the trouble to choose a name)

2) pressing Enter (or Save button) should not trigger the type selector to change

Revision history for this message
Olivier Tilloy (osomon) wrote :

I cannot observe the issue here (tested in disco and cosmic). I followed the instructions step by step and ended up with a "test_2.pdf" file in the folder.

Also, the print-to-file GTK3 dialogue doesn't have a PDF type selector, only "All Formats", "PostScript" and "Any type".

Can you please run "apport-collect 1807744" to attach useful debug information to the bug?

Changed in libreoffice (Ubuntu):
status: New → Incomplete
Revision history for this message
KarlRelton (karllinuxtest-relton) wrote :

Okay - your print defaults are to 'print to ps' rather than 'print to pdf'.

So to recreate the steps you can either:

a) Go to Tools -> Options -> Print -> and enable 'PDF as standard print job format, then re-run the steps

OR

b) wherever in my steps I say 'pdf' or filename.pdf, change to 'ps' and filename.ps

Revision history for this message
Olivier Tilloy (osomon) wrote :

Neither option made a difference here.

 a) 'PDF as a standard print job format' was already checked

 b) tried ps instead of pdf, but 'test_2.ps' gets written as expected

Revision history for this message
KarlRelton (karllinuxtest-relton) wrote :

Hmmm - somewhat curious that your setup is locked into ps and mine is pdf with no apparent way of switching.

But in step 6-c it is important to click on a file name in the chooser, and then edit it in the type in field. The bug doesn't manifest if you just edit the name type in field to the desired file name.

Revision history for this message
KarlRelton (karllinuxtest-relton) wrote :

Right - I have managed to force over my libreoffice to using ps (uncheck the 'PDF as standard print job format' option, click Okay, and let lo restart).

When in 'PS' mode, you are correct that the bug as I have described does not manifest. I conclude that it only manifests when in 'PDF' mode.

However, even in 'PS' mode you can see a strain of the bug. Ensure you have in your directory a 'sample.ps' file (can be empty). Follow through steps 1 to 6d (changing pdf to ps).

Then click on 'Any Type' and change to 'PostScript'. On my system I then observe that my edited filename in the name type-in field has been changed, and another ps file (probably sample.ps) has been selected in the chooser.

Revision history for this message
Olivier Tilloy (osomon) wrote :

I can confirm the issue described in comment #7 (the "strain of the bug").

Not sure whether it's a GTK3 bug or a libreoffice one. Would you mind filing an upstream bug report at https://bugs.documentfoundation.org/enter_bug.cgi?product=LibreOffice&format=guided and sharing the link to it here? Thanks!

Changed in libreoffice (Ubuntu):
status: Incomplete → New
Revision history for this message
KarlRelton (karllinuxtest-relton) wrote :
Changed in libreoffice (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.