diff options
Diffstat (limited to 'printing')
-rw-r--r-- | printing/emf_win.cc | 16 | ||||
-rw-r--r-- | printing/emf_win.h | 6 | ||||
-rw-r--r-- | printing/emf_win_unittest.cc | 6 | ||||
-rw-r--r-- | printing/image.cc | 2 | ||||
-rw-r--r-- | printing/pdf_metafile_mac.cc | 5 | ||||
-rw-r--r-- | printing/pdf_metafile_mac.h | 2 |
6 files changed, 15 insertions, 22 deletions
diff --git a/printing/emf_win.cc b/printing/emf_win.cc index de3b7db..b7c6198 100644 --- a/printing/emf_win.cc +++ b/printing/emf_win.cc @@ -54,6 +54,14 @@ Emf::~Emf() { DCHECK(!emf_ && !hdc_); } +bool Emf::Init(const void* src_buffer, uint32 src_buffer_size) { + DCHECK(!emf_ && !hdc_); + emf_ = SetEnhMetaFileBits(src_buffer_size, + reinterpret_cast<const BYTE*>(src_buffer)); + DCHECK(emf_); + return emf_ != NULL; +} + bool Emf::CreateDc(HDC sibling, const RECT* rect) { DCHECK(!emf_ && !hdc_); hdc_ = CreateEnhMetaFile(sibling, NULL, rect, NULL); @@ -70,14 +78,6 @@ bool Emf::CreateFileBackedDc(HDC sibling, const RECT* rect, return hdc_ != NULL; } - -bool Emf::CreateFromData(const void* buffer, uint32 size) { - DCHECK(!emf_ && !hdc_); - emf_ = SetEnhMetaFileBits(size, reinterpret_cast<const BYTE*>(buffer)); - DCHECK(emf_); - return emf_ != NULL; -} - bool Emf::CreateFromFile(const FilePath& metafile_path) { DCHECK(!emf_ && !hdc_); emf_ = GetEnhMetaFile(metafile_path.value().c_str()); diff --git a/printing/emf_win.h b/printing/emf_win.h index 459886e..f8a0558 100644 --- a/printing/emf_win.h +++ b/printing/emf_win.h @@ -28,6 +28,9 @@ class Emf { Emf(); ~Emf(); + // Initializes the Emf with the data in |src_buffer|. Returns true on success. + bool Init(const void* src_buffer, uint32 src_buffer_size); + // Generates a virtual HDC that will record every GDI commands and compile it // in a EMF data stream. // hdc is used to setup the default DPI and color settings. hdc is optional. @@ -38,9 +41,6 @@ class Emf { // Similar to the above method but the metafile is backed by a file. bool CreateFileBackedDc(HDC sibling, const RECT* rect, const FilePath& path); - // Load a EMF data stream. buffer contains EMF data. - bool CreateFromData(const void* buffer, uint32 size); - // Load an EMF file. bool CreateFromFile(const FilePath& metafile_path); diff --git a/printing/emf_win_unittest.cc b/printing/emf_win_unittest.cc index bfd56b8..d0e9684 100644 --- a/printing/emf_win_unittest.cc +++ b/printing/emf_win_unittest.cc @@ -59,7 +59,7 @@ TEST(EmfTest, DC) { // Playback the data. hdc = CreateCompatibleDC(NULL); EXPECT_TRUE(hdc); - EXPECT_TRUE(emf.CreateFromData(&data.front(), size)); + EXPECT_TRUE(emf.Init(&data.front(), size)); RECT output_rect = {0, 0, 10, 10}; EXPECT_TRUE(emf.Playback(hdc, &output_rect)); EXPECT_TRUE(DeleteDC(hdc)); @@ -91,7 +91,7 @@ TEST_F(EmfPrintingTest, Enumerate) { std::string emf_data; file_util::ReadFileToString(emf_file, &emf_data); ASSERT_TRUE(emf_data.size()); - EXPECT_TRUE(emf.CreateFromData(&emf_data[0], emf_data.size())); + EXPECT_TRUE(emf.Init(&emf_data[0], emf_data.size())); // This will print to file. The reason is that when running inside a // unit_test, printing::PrintingContext automatically dumps its files to the @@ -144,7 +144,7 @@ TEST_F(EmfPrintingTest, PageBreak) { di.cbSize = sizeof(DOCINFO); di.lpszDocName = L"Test Job"; int job_id = ::StartDoc(dc.Get(), &di); - EXPECT_TRUE(emf.CreateFromData(&data.front(), size)); + EXPECT_TRUE(emf.Init(&data.front(), size)); EXPECT_TRUE(emf.SafePlayback(dc.Get())); ::EndDoc(dc.Get()); // Since presumably the printer is not real, let us just delete the job from diff --git a/printing/image.cc b/printing/image.cc index efa645d..51b5ea7 100644 --- a/printing/image.cc +++ b/printing/image.cc @@ -194,7 +194,7 @@ bool Image::LoadMetafile(const std::string& data) { DCHECK(!data.empty()); #if defined(OS_WIN) || defined(OS_MACOSX) NativeMetafile metafile; - metafile.CreateFromData(data.data(), data.size()); + metafile.Init(data.data(), data.size()); return LoadMetafile(metafile); #else NOTIMPLEMENTED(); diff --git a/printing/pdf_metafile_mac.cc b/printing/pdf_metafile_mac.cc index 1726ba0..9520369 100644 --- a/printing/pdf_metafile_mac.cc +++ b/printing/pdf_metafile_mac.cc @@ -57,11 +57,6 @@ bool PdfMetafile::Init(const void* src_buffer, uint32 src_buffer_size) { return true; } -bool PdfMetafile::CreateFromData(const void* src_buffer, - uint32 src_buffer_size) { - return Init(src_buffer, src_buffer_size); -} - void PdfMetafile::StartPage(double width, double height, double scale_factor) { DCHECK(context_.get()); DCHECK(!page_is_open_); diff --git a/printing/pdf_metafile_mac.h b/printing/pdf_metafile_mac.h index 264e970..0a0ea3c 100644 --- a/printing/pdf_metafile_mac.h +++ b/printing/pdf_metafile_mac.h @@ -37,8 +37,6 @@ class PdfMetafile { // Initializes a copy of metafile from PDF data. Returns true on success. bool Init(const void* src_buffer, uint32 src_buffer_size); - // Alias for Init, for compatibility with Emf-based code. - bool CreateFromData(const void* src_buffer, uint32 src_buffer_size); // Prepares a new pdf page with the given width and height and a scale // factor to use for the drawing. |