summaryrefslogtreecommitdiffstats
path: root/printing
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 23:40:27 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 23:40:27 +0000
commitda4eefdf3f571bd8835a2be18b267a7685c75cbd (patch)
tree465c74a28a33ebc6079e697a791313490db9fe5b /printing
parent6c1319541aee6ff89c06457b46d46bbcbcfe868f (diff)
downloadchromium_src-da4eefdf3f571bd8835a2be18b267a7685c75cbd.zip
chromium_src-da4eefdf3f571bd8835a2be18b267a7685c75cbd.tar.gz
chromium_src-da4eefdf3f571bd8835a2be18b267a7685c75cbd.tar.bz2
Linux Printing: Properly print a subset of all pages.
BUG=59732 TEST=Open a 10 PDF, print pages 6,7,8 or pages 6-8. Review URL: http://codereview.chromium.org/6592093 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76835 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rw-r--r--printing/printed_document.cc16
-rw-r--r--printing/printed_document.h5
-rw-r--r--printing/printed_document_cairo.cc9
3 files changed, 23 insertions, 7 deletions
diff --git a/printing/printed_document.cc b/printing/printed_document.cc
index 3d8f156..1f2a939 100644
--- a/printing/printed_document.cc
+++ b/printing/printed_document.cc
@@ -80,6 +80,12 @@ void PrintedDocument::SetPage(int page_number,
{
base::AutoLock lock(lock_);
mutable_.pages_[page_number] = page;
+
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
+ if (page_number < mutable_.first_page)
+ mutable_.first_page = page_number;
+#endif
+
if (mutable_.shrink_factor == 0) {
mutable_.shrink_factor = shrink;
} else {
@@ -111,11 +117,10 @@ bool PrintedDocument::IsComplete() const {
return false;
for (; page != PageNumber::npos(); ++page) {
- bool metafile_must_be_valid =
-#if defined(OS_WIN) || defined(OS_MAC)
- true;
+#if defined(OS_WIN) || defined(OS_MACOSX)
+ const bool metafile_must_be_valid = true;
#elif defined(OS_POSIX)
- (page.ToInt() == 0);
+ const bool metafile_must_be_valid = (page.ToInt() == mutable_.first_page);
#endif
PrintedPages::const_iterator itr = mutable_.pages_.find(page.ToInt());
if (itr == mutable_.pages_.end() || !itr->second.get())
@@ -279,6 +284,9 @@ PrintedDocument::Mutable::Mutable(PrintedPagesSource* source)
expected_page_count_(0),
page_count_(0),
shrink_factor(0) {
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
+ first_page = INT_MAX;
+#endif
}
PrintedDocument::Mutable::~Mutable() {
diff --git a/printing/printed_document.h b/printing/printed_document.h
index 14e5e8c..18a6800 100644
--- a/printing/printed_document.h
+++ b/printing/printed_document.h
@@ -139,6 +139,11 @@ class PrintedDocument : public base::RefCountedThreadSafe<PrintedDocument> {
// Shrink done in comparison to desired_dpi.
double shrink_factor;
+
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
+ // Page number of the first page.
+ int first_page;
+#endif
};
// Contains all the immutable stuff. All this stuff can be accessed without
diff --git a/printing/printed_document_cairo.cc b/printing/printed_document_cairo.cc
index 9992bc6..cb9bbd0 100644
--- a/printing/printed_document_cairo.cc
+++ b/printing/printed_document_cairo.cc
@@ -24,9 +24,12 @@ void PrintedDocument::RenderPrintedPage(
DCHECK(context);
#if !defined(OS_CHROMEOS)
- if (page.page_number() == 1) {
- reinterpret_cast<PrintingContextCairo*>(context)->PrintDocument(
- page.native_metafile());
+ {
+ base::AutoLock lock(lock_);
+ if (page.page_number() - 1 == mutable_.first_page) {
+ reinterpret_cast<PrintingContextCairo*>(context)->PrintDocument(
+ page.native_metafile());
+ }
}
#endif // !defined(OS_CHROMEOS)
}