Bug 34697 - Print Current Page in Print dialog - Calc [Writer, Draw, Impress are finished]
Summary: Print Current Page in Print dialog - Calc [Writer, Draw, Impress are finished]
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.3.1 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: target:3.7.0
Keywords:
: 38830 42337 60453 (view as bug list)
Depends on:
Blocks: Print-Dialog Calc-UX
  Show dependency treegraph
 
Reported: 2011-02-24 22:39 UTC by sasha.libreoffice
Modified: 2022-03-06 22:48 UTC (History)
17 users (show)

See Also:
Crash report or crash signature:


Attachments
The patch for printing current page bug (20.74 KB, patch)
2011-07-17 16:57 UTC, tatung
Details
New patch with coding convention for printing current page bug (20.63 KB, patch)
2011-07-18 00:34 UTC, tatung
Details
modified patch, see comment 6 (3.17 KB, text/plain)
2011-07-18 07:49 UTC, Korrawit Pruegsanusak
Details
Screenshots of this features on calc, impress and writer (112.98 KB, image/png)
2011-08-16 21:09 UTC, Nguyen Vu Hung
Details
Screenshots of this features on impress (139.62 KB, image/png)
2011-08-16 21:10 UTC, Nguyen Vu Hung
Details
Screenshots of this features on writer (90.52 KB, image/png)
2011-08-16 21:10 UTC, Nguyen Vu Hung
Details
Screenshots of this features writer (patch applied) (87.12 KB, image/png)
2011-08-16 21:10 UTC, Nguyen Vu Hung
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sasha.libreoffice 2011-02-24 22:39:35 UTC
Thanks for new dialog Print with interesting options, especially for "Page layout" tab. It is useful. Thanks for ability to resize dialog.
But here is one problem: no option "Pirnt current page" on tab "General" on "Range and copies" part of window.
In open office this option works this way: in field "Pages" was automatically placed number of page, where cursor placed.
Comment 1 Cédric Bosdonnat 2011-02-25 03:21:48 UTC
Changed the priority to enhancement.
This is even an EasyHack. Code pointers to get started:

http://opengrok.libreoffice.org/search?q=%22Range+and+copies%22
Comment 2 Skyler Hawthorne 2011-03-24 14:38:24 UTC Comment hidden (obsolete)
Comment 3 Stefan Knorr (astron) 2011-07-15 06:45:42 UTC
*** Bug 38830 has been marked as a duplicate of this bug. ***
Comment 4 tatung 2011-07-17 16:57:26 UTC
Created attachment 49228 [details]
The patch for printing current page bug

We've tried to make it as OOO did. When the print dialog appears, the current page will be passed to SwPrintUIOption and stored in mhst11_nCrsrCurPage variable. The text box of Pages radio button (below All pages options) will be set to the current page.

PS: We are trying to add another radiobuton like Current Page option.
Comment 5 tatung 2011-07-18 00:34:17 UTC
Created attachment 49235 [details]
New patch with coding convention for printing current page bug

Same patch as before but follow coding convention
Comment 6 Korrawit Pruegsanusak 2011-07-18 07:49:07 UTC
Created attachment 49253 [details]
modified patch, see comment 6

May I, newbie in this project, post some of my nitpicking for your patch?

- You should ignore the whitespace-only changes, such as, delete trailing whitespace, and deleting blank lines without nearby coding change.
- The SCM-like comments aren't necessary. We're using git and diff which can track the change powerfully. These means: /*~~~v*/ and /*~~~^*/ should be ignored, too.

For the technical point, I wonder:
- whether we're using "short" data type? IMHO we're using sal_uInt16(?)
- whether we should copy&paste, then modify some of the overloaded constructor? IMHO the copy&paste isn't good idea, so can we just change the old constructor into new one?
- whether we could use only "m_nCrsrCurPage" instead of "SwPrintUIOptions::m_nCrsrCurPage" in the printdata.cxx ?
But please wait for more experienced developers to confirm these.

- Last nitpicking, what does "MHST" means? If it means your name, please also ignore it.

PS. I've attached modified patch which:
- ignores all whitespace-only changes and SCM-like comments
- changes old constructor into new one without duplicating it, extracting your changes into it
- ignores some (IMHO) obvious comments

but *not*:
- changes the "short" into other data type
- changes "SwPrintUIOptions::m_nCrsrCurPage"
- ignores "MHST"
- build and test at all

Best Regards
Comment 7 tatung 2011-07-18 08:03:23 UTC
Thank you for your comment, Korrawit. 
I'll fix the patch as you comment.
However, there is one thing. It's the constructor. I don't know if others will
call the constructor from other code. Therefore, making a new constructor
(IMHO) will be safer. Anyway, copy&paste the old constructor is quite lame :) I
really want to call the old constructor from the new one but the problem is
that I don't know how to set the value of the text box after it is constructed
(in old constructor).
Comment 8 Stefan Knorr (astron) 2011-07-18 23:19:21 UTC
Hi, first of all: sorry, if these comments are unqualified. Here they are:

* I can't really program but I would have expected the change to be made here:
http://opengrok.libreoffice.org/xref/libs-gui/vcl/source/gdi/print3.cxx#378

* Second, the patch seems to take the position of the cursor to determine which page is the current page. Is there a way to instead use the page that's currently visible in the main window? I think that would be much more logical and also not be prone to errors when there is no cursor (reading mode).

Tatung, thanks for your work, by the way.
Comment 9 tatung 2011-07-19 07:36:05 UTC
Hi Aaron, all,

 * You're right that the change should be made from print3.cxx. However, I don't know how to get the current page in print3.cxx. In unotxdoc.cxx, I can get the current page where the cursor is from SwDocShell. Is there any way to get it in print3.cxx?
 
 * For the first patch, I've just tried to make it as OOO did :D. I also want to use the page that is currently visible but still don't know how to get that page number :D. I see that when we scroll the document, a floating tooltip of the page number appears. I really want to know how to get that number! Any hint?

An thank you for your comment :D

BRs
Comment 10 tommy27 2011-07-26 19:23:13 UTC
I use this macro to print current page.
just assign it to an hotkey or toolbar button

Sub PrintCurrentPage 

Dim oDoc,oVC,CurrentPage 
oDoc = ThisComponent 
oVC = oDoc.CurrentController.getViewCursor 
CurrentPage = Str(oVC.getPage) 
dim document   as object 
dim dispatcher as object 
document = ThisComponent.CurrentController.Frame 
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 
dim args1(2) as new com.sun.star.beans.PropertyValue 
args1(0).Name = "Copies" 
args1(0).Value = 1 
args1(1).Name = "RangeText" 
args1(1).Value = CurrentPage 
args1(2).Name = "Collate" 
args1(2).Value = false 
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args1()) 
End Sub
Comment 11 sasha.libreoffice 2011-08-02 02:53:00 UTC Comment hidden (obsolete)
Comment 12 Björn Michaelsen 2011-08-02 03:42:08 UTC
text from dupe 38830:

Print current page

Background: In previous versions of OOo, there used to be a possiblity to print
current page easily, but it got lost with the rework of the print dialog. The
previous printing dialog made sure to set the field "Pages" according the
currently active page number when the dialog was opened. It seems there is a
demand for this feature, so it might be good to get it back :-)

Code pointers: For Writer, should be possible to pass the current page number
to the SwPrintUIOptions's constructor wherever it is being constructed,
probably in SwDocShell. If that is correct, in SwDocShell you have
GetWrtShell(), and can do the same as this.

Something similar will be necessary for the other apps too.

Specification pointers: OOo CWS printerpullpages specification for mockups, OOo
3.1 printing dialog screenshots. Please also see: Bug 34697

Skills: building, C++
Comment 13 Jan Holesovsky 2011-08-08 00:48:04 UTC
The following went in for Writer in the end:

http://cgit.freedesktop.org/libreoffice/core/commit/?id=be6629ac7481dd68cb2f2b52927f1dcd975d6ac9

- no need to remember the current page value, ie. removed m_nCrsrCurPage, it is not used anywhere else than in the constructor
- use sal_uInt16 instead of short, it is the type that is returned by GetPageNum()
- removed the MHST, no idea what it means

Hopefully this patch might be an inspiration for Calc, Impress, and Draw too :-)  I am letting the bug open to track the other apps, and changed the title accordingly.
Comment 14 Nguyen Vu Hung 2011-08-16 21:09:10 UTC
Created attachment 50298 [details]
Screenshots of this features on calc, impress and writer
Comment 15 Nguyen Vu Hung 2011-08-16 21:10:08 UTC
Created attachment 50299 [details]
Screenshots of this features on impress
Comment 16 Nguyen Vu Hung 2011-08-16 21:10:32 UTC
Created attachment 50300 [details]
Screenshots of this features on writer
Comment 17 Nguyen Vu Hung 2011-08-16 21:10:57 UTC
Created attachment 50301 [details]
Screenshots of this features writer (patch applied)
Comment 18 Björn Michaelsen 2011-09-28 04:25:14 UTC
Whats the state of this? It seems something went into master, but there is still stuff needed to be merged?

@kendy, Nguyen Vu Hung: Can the involved parties please clarify and please update the bug status/assignee?

This bug is still in the 'featured EasyHacks' list on http://wiki.documentfoundation.org/Development/Easy_Hack, which it obviously shouldnt, if somebody is already working on it, or no more work is needed.
Comment 19 Nguyen Vu Hung 2011-09-28 04:30:08 UTC
Mr. Tung is working on it.

I think he is still having some problems with programs other than Writer (It seems to be fixed for Writer, we saw the commit), but not other program.

@Tung: Can you explaing what problems you are facing?
Comment 20 Björn Michaelsen 2011-09-28 04:45:56 UTC Comment hidden (obsolete)
Comment 21 Korrawit Pruegsanusak 2011-11-01 22:08:30 UTC
*** Bug 42337 has been marked as a duplicate of this bug. ***
Comment 22 krchat 2012-04-14 10:56:45 UTC Comment hidden (obsolete)
Comment 23 Korrawit Pruegsanusak 2012-04-15 01:48:43 UTC Comment hidden (obsolete)
Comment 24 krchat 2012-04-15 03:11:15 UTC Comment hidden (no-value)
Comment 25 krchat 2012-04-15 03:14:33 UTC Comment hidden (no-value)
Comment 26 Stefan Knorr (astron) 2012-04-15 05:15:32 UTC Comment hidden (obsolete)
Comment 27 krchat 2012-04-15 08:06:19 UTC Comment hidden (obsolete)
Comment 28 Korrawit Pruegsanusak 2012-04-16 00:39:48 UTC
(In reply to comment #27)
> I use 3.5.2.2 - but there is not print current page mode in the writer there.

The current page number is shown in the print dialog (see attachment 50301 [details]). So, we don't need explicit 'Print Current Page' button.
Comment 29 sasha.libreoffice 2012-04-16 01:55:37 UTC Comment hidden (obsolete)
Comment 30 Florian Reisinger 2012-05-18 09:50:29 UTC Comment hidden (obsolete)
Comment 31 Michael Stahl (allotropia) 2012-06-29 14:46:39 UTC
Comment on attachment 49235 [details]
New patch with coding convention for printing current page bug

this patch seems to be obsoleted by the subsequent patch.
Comment 32 Michael Stahl (allotropia) 2012-06-29 14:47:57 UTC
Comment on attachment 49253 [details]
modified patch, see comment 6

according to comment #13 this patch was integrated, removing "patch" flag so it does not turn up in bugzilla queries.
Comment 33 Rob Snelders 2012-07-10 22:14:19 UTC
Added a patch to gerrit to change the the 2nd range-option so it displays the current page in Draw and Impress. As is already changed in writer

The current print-dialog for impress is as shown in attachment "Screenshots of this features on impress". But the selection-option (3th range-option) doesn't work ok as it shows the current object you are editing, and that only. Seems a bit useless to me as you can only edit 1 object at a time. Shouldn't that option be removed or it should take the sheets selected in the SlideSorterToolbar (But that would not be natural to understand).
Comment 34 krchat 2012-07-11 07:15:15 UTC Comment hidden (no-value)
Comment 35 krchat 2012-07-11 07:17:59 UTC Comment hidden (no-value)
Comment 36 Stefan Knorr (astron) 2012-07-11 10:50:36 UTC Comment hidden (obsolete)
Comment 37 krchat 2012-07-11 11:18:53 UTC Comment hidden (no-value)
Comment 38 Not Assigned 2012-07-11 19:38:09 UTC
Rob Snelders committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=be68d26b6cba797c7838afd15b098f0b95399d78

fdo#34697 - Print Current Page in Print dialog - Draw, Impress
Comment 39 Jorendc 2013-02-07 23:21:01 UTC
*** Bug 60453 has been marked as a duplicate of this bug. ***
Comment 40 Xisco Faulí 2016-09-15 22:32:46 UTC Comment hidden (obsolete)
Comment 41 Timur 2016-09-19 13:18:58 UTC
I'd say it's as in the title: Calc still not finished.
Comment 42 mkassler 2022-03-06 06:53:13 UTC
I'd like to suggest that 'Print Current Page' be implemented so that pressing a few keys in Writer such as Alt+P would cause the printer to print only the current page. This seems to be implemented in Microsoft Word but isn't implemented in Writer. I understand that one can write a macro to do this, but I'm suggesting that it would be useful to implement this function by pressing just a couple of keys.
Comment 43 mkassler 2022-03-06 22:48:32 UTC
This matter has been raised again. See https://ask.libreoffice.org/t/print-current-page-shortcut/74871/7