Commit 9b0de172 authored by carlosgc@webkit.org's avatar carlosgc@webkit.org
Browse files

[GTK] Allow printing pages in reverse order in WebKit2 for printers that don't support it

https://bugs.webkit.org/show_bug.cgi?id=78799

Reviewed by Gustavo Noronha Silva.

* UIProcess/API/gtk/WebKitPrintOperation.cpp:
(webkitPrintOperationRunDialogUnix): Enable printing in reverse
order option in print dialog.
* WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp:
(WebKit::PrintPagesData::PrintPagesData): Initialize sheetNumber
and lastPagePosition depending on whether printing is in reverse
order or not.
(WebKit::PrintPagesData::incrementPageSequence): Use a negative
increment step when printing in reverse order. Fix page
incrementing when printing only odd/even pages broken in previous
commit due to merge conflicts.
(WebKit::WebPrintOperationGtk::WebPrintOperationGtk): Initialize
reverse printing to false.
* WebProcess/WebPage/gtk/WebPrintOperationGtk.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108086 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0b8b12c4
2012-02-17 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Allow printing pages in reverse order in WebKit2 for printers that don't support it
https://bugs.webkit.org/show_bug.cgi?id=78799
Reviewed by Gustavo Noronha Silva.
* UIProcess/API/gtk/WebKitPrintOperation.cpp:
(webkitPrintOperationRunDialogUnix): Enable printing in reverse
order option in print dialog.
* WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp:
(WebKit::PrintPagesData::PrintPagesData): Initialize sheetNumber
and lastPagePosition depending on whether printing is in reverse
order or not.
(WebKit::PrintPagesData::incrementPageSequence): Use a negative
increment step when printing in reverse order. Fix page
incrementing when printing only odd/even pages broken in previous
commit due to merge conflicts.
(WebKit::WebPrintOperationGtk::WebPrintOperationGtk): Initialize
reverse printing to false.
* WebProcess/WebPage/gtk/WebPrintOperationGtk.h:
2012-02-17 Carlos Garcia Campos <cgarcia@igalia.com>
 
[GTK] Allow printing only odd/even pages in WebKit2 for printers that don't support it
......@@ -202,7 +202,8 @@ static WebKitPrintOperationResponse webkitPrintOperationRunDialogUnix(WebKitPrin
GtkPrintUnixDialog* printDialog = GTK_PRINT_UNIX_DIALOG(gtk_print_unix_dialog_new(0, parent));
gtk_print_unix_dialog_set_manual_capabilities(printDialog, static_cast<GtkPrintCapabilities>(GTK_PRINT_CAPABILITY_NUMBER_UP
| GTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT
| GTK_PRINT_CAPABILITY_PAGE_SET));
| GTK_PRINT_CAPABILITY_PAGE_SET
| GTK_PRINT_CAPABILITY_REVERSE));
WebKitPrintOperationPrivate* priv = printOperation->priv;
if (priv->printSettings)
......
......@@ -92,6 +92,7 @@ public:
printOperation->m_numberUp = gtk_print_job_get_n_up(printOperation->m_printJob.get());
printOperation->m_numberUpLayout = gtk_print_job_get_n_up_layout(printOperation->m_printJob.get());
printOperation->m_pageSet = gtk_print_job_get_page_set(printOperation->m_printJob.get());
printOperation->m_reverse = gtk_print_job_get_reverse(printOperation->m_printJob.get());
printOperation->print(surface, 72, 72);
}
......@@ -239,16 +240,30 @@ struct PrintPagesData {
else
numberOfSheets = pages.size();
bool reverse = printOperation->reverse();
switch (printOperation->pageSet()) {
case GTK_PAGE_SET_ODD:
lastPagePosition = std::min(((numberOfSheets - 1) - ((numberOfSheets - 1) % 2)) * numberUp - 1, pages.size() - 1);
if (reverse) {
lastPagePosition = std::min(numberUp - 1, pages.size() - 1);
sheetNumber = (numberOfSheets - 1) - (numberOfSheets - 1) % 2;
} else
lastPagePosition = std::min(((numberOfSheets - 1) - ((numberOfSheets - 1) % 2)) * numberUp - 1, pages.size() - 1);
break;
case GTK_PAGE_SET_EVEN:
lastPagePosition = std::min(((numberOfSheets - 1) - (1 - (numberOfSheets - 1) % 2)) * numberUp - 1, pages.size() - 1);
sheetNumber = numberOfSheets > 1 ? 1 : -1;
if (reverse) {
lastPagePosition = std::min(2 * numberUp - 1, pages.size() - 1);
sheetNumber = (numberOfSheets - 1) - (1 - (numberOfSheets - 1) % 2);
} else {
lastPagePosition = std::min(((numberOfSheets - 1) - (1 - (numberOfSheets - 1) % 2)) * numberUp - 1, pages.size() - 1);
sheetNumber = numberOfSheets > 1 ? 1 : -1;
}
break;
case GTK_PAGE_SET_ALL:
lastPagePosition = pages.size() - 1;
if (reverse) {
lastPagePosition = std::min(numberUp - 1, pages.size() - 1);
sheetNumber = pages.size() - 1;
} else
lastPagePosition = pages.size() - 1;
break;
}
......@@ -273,7 +288,9 @@ struct PrintPagesData {
}
if (printOperation->currentPageIsLastPageOfSheet()) {
sheetNumber++;
int step = printOperation->pageSet() == GTK_PAGE_SET_ALL ? 1 : 2;
step *= printOperation->reverse() ? -1 : 1;
sheetNumber += step;
pagePosition = sheetNumber * printOperation->numberUp();
} else
pagePosition++;
......@@ -328,6 +345,7 @@ WebPrintOperationGtk::WebPrintOperationGtk(WebPage* page, const PrintInfo& print
, m_numberUp(1)
, m_numberUpLayout(0)
, m_pageSet(GTK_PAGE_SET_ALL)
, m_reverse(false)
{
}
......
......@@ -64,6 +64,7 @@ public:
unsigned int numberUp() const { return m_numberUp; }
unsigned int numberUpLayout() const { return m_numberUpLayout; }
unsigned int pageSet() const { return m_pageSet; }
bool reverse() const { return m_reverse; }
virtual void startPrint(WebCore::PrintContext*, uint64_t callbackID) = 0;
......@@ -106,6 +107,7 @@ protected:
unsigned int m_numberUp;
unsigned int m_numberUpLayout;
unsigned int m_pageSet;
bool m_reverse;
};
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment