| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PRINTING_NATIVE_METAFILE_H_ | 5 #ifndef PRINTING_NATIVE_METAFILE_H_ |
| 6 #define PRINTING_NATIVE_METAFILE_H_ | 6 #define PRINTING_NATIVE_METAFILE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 virtual bool SaveTo(const FilePath& file_path) const = 0; | 91 virtual bool SaveTo(const FilePath& file_path) const = 0; |
| 92 | 92 |
| 93 // Returns the bounds of the given page. Pages use a 1-based index. | 93 // Returns the bounds of the given page. Pages use a 1-based index. |
| 94 virtual gfx::Rect GetPageBounds(unsigned int page_number) const = 0; | 94 virtual gfx::Rect GetPageBounds(unsigned int page_number) const = 0; |
| 95 virtual unsigned int GetPageCount() const = 0; | 95 virtual unsigned int GetPageCount() const = 0; |
| 96 | 96 |
| 97 // Get the context for rendering to the PDF. | 97 // Get the context for rendering to the PDF. |
| 98 virtual gfx::NativeDrawingContext context() const = 0; | 98 virtual gfx::NativeDrawingContext context() const = 0; |
| 99 | 99 |
| 100 #if defined(OS_WIN) | 100 #if defined(OS_WIN) |
| 101 // Generates a virtual HDC that will record every GDI commands and compile it | |
| 102 // in a EMF data stream. | |
| 103 // hdc is used to setup the default DPI and color settings. hdc is optional. | |
| 104 // rect specifies the dimensions (in .01-millimeter units) of the EMF. rect is | |
| 105 // optional. | |
| 106 virtual bool CreateDc(gfx::NativeDrawingContext sibling, | |
| 107 const RECT* rect) = 0; | |
| 108 | |
| 109 // Similar to the above method but the metafile is backed by a file. | |
| 110 virtual bool CreateFileBackedDc(gfx::NativeDrawingContext sibling, | |
| 111 const RECT* rect, | |
| 112 const FilePath& path) = 0; | |
| 113 | |
| 114 // TODO(maruel): CreateFromFile(). If ever used. Maybe users would like to | |
| 115 // have the ability to save web pages to an EMF file? Afterward, it is easy to | |
| 116 // convert to PDF or PS. | |
| 117 // Load a metafile fromdisk. | |
| 118 virtual bool CreateFromFile(const FilePath& metafile_path) = 0; | |
| 119 | |
| 120 // Closes the HDC created by CreateDc() and generates the compiled EMF | |
| 121 // data. | |
| 122 virtual void CloseEmf() = 0; | |
| 123 | |
| 124 // "Plays" the EMF buffer in a HDC. It is the same effect as calling the | 101 // "Plays" the EMF buffer in a HDC. It is the same effect as calling the |
| 125 // original GDI function that were called when recording the EMF. |rect| is in | 102 // original GDI function that were called when recording the EMF. |rect| is in |
| 126 // "logical units" and is optional. If |rect| is NULL, the natural EMF bounds | 103 // "logical units" and is optional. If |rect| is NULL, the natural EMF bounds |
| 127 // are used. | 104 // are used. |
| 128 // Note: Windows has been known to have stack buffer overflow in its GDI | 105 // Note: Windows has been known to have stack buffer overflow in its GDI |
| 129 // functions, whether used directly or indirectly through precompiled EMF | 106 // functions, whether used directly or indirectly through precompiled EMF |
| 130 // data. We have to accept the risk here. Since it is used only for printing, | 107 // data. We have to accept the risk here. Since it is used only for printing, |
| 131 // it requires user intervention. | 108 // it requires user intervention. |
| 132 virtual bool Playback(gfx::NativeDrawingContext hdc, | 109 virtual bool Playback(gfx::NativeDrawingContext hdc, |
| 133 const RECT* rect) const = 0; | 110 const RECT* rect) const = 0; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // Returns true if writing succeeded. | 154 // Returns true if writing succeeded. |
| 178 virtual bool SaveToFD(const base::FileDescriptor& fd) const = 0; | 155 virtual bool SaveToFD(const base::FileDescriptor& fd) const = 0; |
| 179 #endif // if defined(OS_CHROMEOS) | 156 #endif // if defined(OS_CHROMEOS) |
| 180 | 157 |
| 181 #endif | 158 #endif |
| 182 }; | 159 }; |
| 183 | 160 |
| 184 } // namespace printing | 161 } // namespace printing |
| 185 | 162 |
| 186 #endif // PRINTING_NATIVE_METAFILE_H_ | 163 #endif // PRINTING_NATIVE_METAFILE_H_ |
| OLD | NEW |