summaryrefslogtreecommitdiffstats
path: root/printing
diff options
context:
space:
mode:
Diffstat (limited to 'printing')
-rw-r--r--printing/emf_win.cc3
-rw-r--r--printing/emf_win.h5
-rw-r--r--printing/emf_win_unittest.cc1
3 files changed, 6 insertions, 3 deletions
diff --git a/printing/emf_win.cc b/printing/emf_win.cc
index 467d4b3..849e125 100644
--- a/printing/emf_win.cc
+++ b/printing/emf_win.cc
@@ -49,7 +49,7 @@ bool DIBFormatNativelySupported(HDC dc, uint32 escape, const BYTE* bits,
return !!supported;
}
-Emf::Emf() : emf_(NULL), hdc_(NULL) {
+Emf::Emf() : emf_(NULL), hdc_(NULL), page_count_(0) {
}
Emf::~Emf() {
@@ -421,6 +421,7 @@ bool Emf::StartPage(const gfx::Size& /*page_size*/,
DCHECK(hdc_);
if (!hdc_)
return false;
+ page_count_++;
PageBreakRecord record(PageBreakRecord::START_PAGE);
return !!GdiComment(hdc_, sizeof(record),
reinterpret_cast<const BYTE *>(&record));
diff --git a/printing/emf_win.h b/printing/emf_win.h
index 5f9bd5a..ecc1028 100644
--- a/printing/emf_win.h
+++ b/printing/emf_win.h
@@ -70,8 +70,7 @@ class Emf : public NativeMetafile {
virtual gfx::Rect GetPageBounds(unsigned int page_number) const;
virtual unsigned int GetPageCount() const {
- // TODO(dpapad): count the number of times StartPage() is called
- return 1;
+ return page_count_;
}
virtual HDC context() const {
@@ -106,6 +105,8 @@ class Emf : public NativeMetafile {
// Valid when generating EMF data through a virtual HDC.
HDC hdc_;
+ int page_count_;
+
DISALLOW_COPY_AND_ASSIGN(Emf);
};
diff --git a/printing/emf_win_unittest.cc b/printing/emf_win_unittest.cc
index b401f5b..3ea1282 100644
--- a/printing/emf_win_unittest.cc
+++ b/printing/emf_win_unittest.cc
@@ -141,6 +141,7 @@ TEST_F(EmfPrintingTest, PageBreak) {
EXPECT_TRUE(emf.FinishPage());
--pages;
}
+ EXPECT_EQ(3U, emf.GetPageCount());
EXPECT_TRUE(emf.FinishDocument());
size = emf.GetDataSize();
EXPECT_TRUE(emf.GetDataAsVector(&data));