diff options
author | thestig <thestig@chromium.org> | 2015-03-05 13:06:02 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-05 21:07:12 +0000 |
commit | b335e7d621465955cf8b733660f82ffe0aab6de2 (patch) | |
tree | c1bb8f6fa3a2cc37147bf82b54d937e8e08ecb39 /pdf | |
parent | c285abaea4ed9dbe8c9dcc285d6d4acc8676cd2f (diff) | |
download | chromium_src-b335e7d621465955cf8b733660f82ffe0aab6de2.zip chromium_src-b335e7d621465955cf8b733660f82ffe0aab6de2.tar.gz chromium_src-b335e7d621465955cf8b733660f82ffe0aab6de2.tar.bz2 |
Print Preview: Support the duplex preset in PDFs.
The preset from the PDF document gets plumbed all the way to print
preview, but the ShortEdge setting is ignored at the end because print
preview does not support it yet.
BUG=169120
Review URL: https://codereview.chromium.org/974183003
Cr-Commit-Position: refs/heads/master@{#319324}
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/instance.cc | 2 | ||||
-rw-r--r-- | pdf/out_of_process_instance.cc | 6 | ||||
-rw-r--r-- | pdf/pdf_engine.h | 23 | ||||
-rw-r--r-- | pdf/pdfium/pdfium_assert_matching_enums.cc | 6 | ||||
-rw-r--r-- | pdf/pdfium/pdfium_engine.cc | 4 | ||||
-rw-r--r-- | pdf/pdfium/pdfium_engine.h | 1 |
6 files changed, 29 insertions, 13 deletions
diff --git a/pdf/instance.cc b/pdf/instance.cc index 93daf6f..724f7d6 100644 --- a/pdf/instance.cc +++ b/pdf/instance.cc @@ -674,6 +674,8 @@ pp::Var Instance::GetInstanceObject() { void Instance::GetPrintPresetOptionsFromDocument( PP_PdfPrintPresetOptions_Dev* options) { options->is_scaling_disabled = PP_FromBool(IsPrintScalingDisabled()); + options->duplex = + static_cast<PP_PrivateDuplexMode_Dev>(engine_->GetDuplexType()); options->copies = engine_->GetCopiesToPrint(); } diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc index ef83cd9..ee4cd9f 100644 --- a/pdf/out_of_process_instance.cc +++ b/pdf/out_of_process_instance.cc @@ -603,6 +603,8 @@ void OutOfProcessInstance::DidChangeView(const pp::View& view) { void OutOfProcessInstance::GetPrintPresetOptionsFromDocument( PP_PdfPrintPresetOptions_Dev* options) { options->is_scaling_disabled = PP_FromBool(IsPrintScalingDisabled()); + options->duplex = + static_cast<PP_PrivateDuplexMode_Dev>(engine_->GetDuplexType()); options->copies = engine_->GetCopiesToPrint(); } @@ -1183,7 +1185,7 @@ void OutOfProcessInstance::DocumentLoadFailed() { // Send a progress value of -1 to indicate a failure. pp::VarDictionary message; message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); - message.Set(pp::Var(kJSProgressPercentage), pp::Var(-1)) ; + message.Set(pp::Var(kJSProgressPercentage), pp::Var(-1)); PostMessage(message); } @@ -1250,7 +1252,7 @@ void OutOfProcessInstance::DocumentLoadProgress(uint32 available, last_progress_sent_ = progress; pp::VarDictionary message; message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); - message.Set(pp::Var(kJSProgressPercentage), pp::Var(progress)) ; + message.Set(pp::Var(kJSProgressPercentage), pp::Var(progress)); PostMessage(message); } } diff --git a/pdf/pdf_engine.h b/pdf/pdf_engine.h index 5f196d1..bcfa7e6 100644 --- a/pdf/pdf_engine.h +++ b/pdf/pdf_engine.h @@ -49,7 +49,6 @@ void ShutdownSDK(); // This class encapsulates a PDF rendering engine. class PDFEngine { public: - enum DocumentPermission { PERMISSION_COPY, PERMISSION_COPY_ACCESSIBLE, @@ -178,7 +177,7 @@ class PDFEngine { virtual uint32 GetBackgroundColor() = 0; // Sets selection status. - virtual void IsSelectingChanged(bool is_selecting){}; + virtual void IsSelectingChanged(bool is_selecting) {} }; // Factory method to create an instance of the PDF Engine. @@ -251,6 +250,8 @@ class PDFEngine { virtual bool GetPrintScaling() = 0; // Returns number of copies to be printed. virtual int GetCopiesToPrint() = 0; + // Returns the duplex setting. + virtual int GetDuplexType() = 0; // Returns a VarArray of Bookmarks, each a VarDictionary containing the // following key/values: @@ -280,15 +281,15 @@ class PDFEngine { class PDFEngineExports { public: struct RenderingSettings { - RenderingSettings(int dpi_x, - int dpi_y, - const pp::Rect& bounds, - bool fit_to_bounds, - bool stretch_to_bounds, - bool keep_aspect_ratio, - bool center_in_bounds, - bool autorotate) - : dpi_x(dpi_x), dpi_y(dpi_y), bounds(bounds), + RenderingSettings(int dpi_x, + int dpi_y, + const pp::Rect& bounds, + bool fit_to_bounds, + bool stretch_to_bounds, + bool keep_aspect_ratio, + bool center_in_bounds, + bool autorotate) + : dpi_x(dpi_x), dpi_y(dpi_y), bounds(bounds), fit_to_bounds(fit_to_bounds), stretch_to_bounds(stretch_to_bounds), keep_aspect_ratio(keep_aspect_ratio), center_in_bounds(center_in_bounds), autorotate(autorotate) { diff --git a/pdf/pdfium/pdfium_assert_matching_enums.cc b/pdf/pdfium/pdfium_assert_matching_enums.cc index afb6542..559ae6b 100644 --- a/pdf/pdfium/pdfium_assert_matching_enums.cc +++ b/pdf/pdfium/pdfium_assert_matching_enums.cc @@ -5,6 +5,7 @@ #include "base/basictypes.h" #include "ppapi/c/pp_input_event.h" #include "ppapi/c/private/ppb_pdf.h" +#include "ppapi/c/private/ppp_pdf.h" #include "third_party/pdfium/fpdfsdk/include/fpdf_fwlevent.h" #include "third_party/pdfium/fpdfsdk/include/fpdf_sysfontinfo.h" #include "ui/events/keycodes/keyboard_codes.h" @@ -206,3 +207,8 @@ STATIC_ASSERT_MATCH(PP_PRIVATEFONTCHARSET_HANGUL, FXFONT_HANGEUL_CHARSET); STATIC_ASSERT_MATCH(PP_PRIVATEFONTCHARSET_GB2312, FXFONT_GB2312_CHARSET); STATIC_ASSERT_MATCH(PP_PRIVATEFONTCHARSET_CHINESEBIG5, FXFONT_CHINESEBIG5_CHARSET); + +STATIC_ASSERT_MATCH(PP_PRIVATEDUPLEXMODE_NONE, DuplexUndefined); +STATIC_ASSERT_MATCH(PP_PRIVATEDUPLEXMODE_SIMPLEX, Simplex); +STATIC_ASSERT_MATCH(PP_PRIVATEDUPLEXMODE_SHORT_EDGE, DuplexFlipShortEdge); +STATIC_ASSERT_MATCH(PP_PRIVATEDUPLEXMODE_LONG_EDGE, DuplexFlipLongEdge); diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc index d247db0..ddc1696 100644 --- a/pdf/pdfium/pdfium_engine.cc +++ b/pdf/pdfium/pdfium_engine.cc @@ -2457,6 +2457,10 @@ int PDFiumEngine::GetCopiesToPrint() { return FPDF_VIEWERREF_GetNumCopies(doc_); } +int PDFiumEngine::GetDuplexType() { + return static_cast<int>(FPDF_VIEWERREF_GetDuplex(doc_)); +} + void PDFiumEngine::AppendBlankPages(int num_pages) { DCHECK(num_pages != 0); diff --git a/pdf/pdfium/pdfium_engine.h b/pdf/pdfium/pdfium_engine.h index ac05303..2dc65b4 100644 --- a/pdf/pdfium/pdfium_engine.h +++ b/pdf/pdfium/pdfium_engine.h @@ -93,6 +93,7 @@ class PDFiumEngine : public PDFEngine, virtual std::string GetPageAsJSON(int index); virtual bool GetPrintScaling(); virtual int GetCopiesToPrint(); + virtual int GetDuplexType(); virtual void AppendBlankPages(int num_pages); virtual void AppendPage(PDFEngine* engine, int index); virtual pp::Point GetScrollPosition(); |