diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 17:20:21 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 17:20:21 +0000 |
commit | 7756e5b1e7919fe530ff1ff27503d4893efcee13 (patch) | |
tree | 5b7ac359e22bf58e5ae72fbdc57a6b6c92efe285 /printing/emf_win.h | |
parent | f3e9d6e12d38ea05e476899eb2620c57d351f74b (diff) | |
download | chromium_src-7756e5b1e7919fe530ff1ff27503d4893efcee13.zip chromium_src-7756e5b1e7919fe530ff1ff27503d4893efcee13.tar.gz chromium_src-7756e5b1e7919fe530ff1ff27503d4893efcee13.tar.bz2 |
Revert 76553 - Applying factory pattern (through NativeMetafileFactory class). It is used to retrieve different printing contexts (based on the platform and user preferences).
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/6544028
TBR=dpapad@chromium.org
Review URL: http://codereview.chromium.org/6594121
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76555 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/emf_win.h')
-rw-r--r-- | printing/emf_win.h | 54 |
1 files changed, 21 insertions, 33 deletions
diff --git a/printing/emf_win.h b/printing/emf_win.h index ba139d8..f8a0558 100644 --- a/printing/emf_win.h +++ b/printing/emf_win.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,8 +9,6 @@ #include <vector> #include "base/basictypes.h" -#include "base/gtest_prod_util.h" -#include "printing/native_metafile_win.h" class FilePath; @@ -21,31 +19,30 @@ class Rect; namespace printing { // Simple wrapper class that manage an EMF data stream and its virtual HDC. -class Emf : public NativeMetafile { +class Emf { public: class Record; class Enumerator; struct EnumerationContext; - virtual ~Emf(); + Emf(); + ~Emf(); // Initializes the Emf with the data in |src_buffer|. Returns true on success. - virtual bool Init(const void* src_buffer, uint32 src_buffer_size); + 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. // rect specifies the dimensions (in .01-millimeter units) of the EMF. rect is // optional. - virtual bool CreateDc(HDC sibling, const RECT* rect); + bool CreateDc(HDC sibling, const RECT* rect); // Similar to the above method but the metafile is backed by a file. - virtual bool CreateFileBackedDc(HDC sibling, - const RECT* rect, - const FilePath& path); + bool CreateFileBackedDc(HDC sibling, const RECT* rect, const FilePath& path); // Load an EMF file. - virtual bool CreateFromFile(const FilePath& metafile_path); + bool CreateFromFile(const FilePath& metafile_path); // TODO(maruel): CreateFromFile(). If ever used. Maybe users would like to // have the ability to save web pages to an EMF file? Afterward, it is easy to @@ -53,10 +50,10 @@ class Emf : public NativeMetafile { // Closes the HDC created by CreateDc() and generates the compiled EMF // data. - virtual bool CloseDc(); + bool CloseDc(); // Closes the EMF data handle when it is not needed anymore. - virtual void CloseEmf(); + void CloseEmf(); // "Plays" the EMF buffer in a HDC. It is the same effect as calling the // original GDI function that were called when recording the EMF. |rect| is in @@ -66,56 +63,47 @@ class Emf : public NativeMetafile { // functions, whether used directly or indirectly through precompiled EMF // data. We have to accept the risk here. Since it is used only for printing, // it requires user intervention. - virtual bool Playback(HDC hdc, const RECT* rect) const; + bool Playback(HDC hdc, const RECT* rect) const; // The slow version of Playback(). It enumerates all the records and play them // back in the HDC. The trick is that it skip over the records known to have // issue with some printers. See Emf::Record::SafePlayback implementation for // details. - virtual bool SafePlayback(HDC hdc) const; + bool SafePlayback(HDC hdc) const; // Retrieves the bounds of the painted area by this EMF buffer. This value // should be passed to Playback to keep the exact same size. - virtual gfx::Rect GetBounds() const; + gfx::Rect GetBounds() const; // Retrieves the EMF stream size. - virtual uint32 GetDataSize() const; + uint32 GetDataSize() const; // Retrieves the EMF stream. - virtual bool GetData(void* buffer, uint32 size) const; + bool GetData(void* buffer, uint32 size) const; // Retrieves the EMF stream. It is an helper function. - virtual bool GetData(std::vector<uint8>* buffer) const; + bool GetData(std::vector<uint8>* buffer) const; - virtual HENHMETAFILE emf() const { + HENHMETAFILE emf() const { return emf_; } - virtual HDC hdc() const { + HDC hdc() const { return hdc_; } // Inserts a custom GDICOMMENT records indicating StartPage/EndPage calls // (since StartPage and EndPage do not work in a metafile DC). Only valid // when hdc_ is non-NULL. - virtual bool StartPage(); - virtual bool EndPage(); + bool StartPage(); + bool EndPage(); // Saves the EMF data to a file as-is. It is recommended to use the .emf file // extension but it is not enforced. This function synchronously writes to the // file. For testing only. - virtual bool SaveTo(const std::wstring& filename) const; - - protected: - Emf(); + bool SaveTo(const std::wstring& filename) const; private: - friend class NativeMetafileFactory; - FRIEND_TEST_ALL_PREFIXES(EmfTest, DC); - FRIEND_TEST_ALL_PREFIXES(EmfTest, FileBackedDC); - FRIEND_TEST_ALL_PREFIXES(EmfPrintingTest, Enumerate); - FRIEND_TEST_ALL_PREFIXES(EmfPrintingTest, PageBreak); - // Playbacks safely one EMF record. static int CALLBACK SafePlaybackProc(HDC hdc, HANDLETABLE* handle_table, |