| 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_EMF_WIN_H_ | 5 #ifndef PRINTING_EMF_WIN_H_ |
| 6 #define PRINTING_EMF_WIN_H_ | 6 #define PRINTING_EMF_WIN_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "printing/metafile.h" | 13 #include "printing/metafile.h" |
| 14 | 14 |
| 15 class FilePath; | 15 class FilePath; |
| 16 | 16 |
| 17 namespace gfx { | 17 namespace gfx { |
| 18 class Point; | 18 class Point; |
| 19 class Rect; | 19 class Rect; |
| 20 class Size; | 20 class Size; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace printing { | 23 namespace printing { |
| 24 | 24 |
| 25 // Simple wrapper class that manage an EMF data stream and its virtual HDC. | 25 // Simple wrapper class that manage an EMF data stream and its virtual HDC. |
| 26 class Emf : public Metafile { | 26 class PRINTING_EXPORT Emf : public Metafile { |
| 27 public: | 27 public: |
| 28 class Record; | 28 class Record; |
| 29 class Enumerator; | 29 class Enumerator; |
| 30 struct EnumerationContext; | 30 struct EnumerationContext; |
| 31 | 31 |
| 32 // Generates a virtual HDC that will record every GDI commands and compile | 32 // Generates a virtual HDC that will record every GDI commands and compile |
| 33 // it in a EMF data stream. | 33 // it in a EMF data stream. |
| 34 Emf(); | 34 Emf(); |
| 35 virtual ~Emf(); | 35 virtual ~Emf(); |
| 36 | 36 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 struct Emf::EnumerationContext { | 113 struct Emf::EnumerationContext { |
| 114 HANDLETABLE* handle_table; | 114 HANDLETABLE* handle_table; |
| 115 int objects_count; | 115 int objects_count; |
| 116 HDC hdc; | 116 HDC hdc; |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 // One EMF record. It keeps pointers to the EMF buffer held by Emf::emf_. | 119 // One EMF record. It keeps pointers to the EMF buffer held by Emf::emf_. |
| 120 // The entries become invalid once Emf::CloseEmf() is called. | 120 // The entries become invalid once Emf::CloseEmf() is called. |
| 121 class Emf::Record { | 121 class PRINTING_EXPORT Emf::Record { |
| 122 public: | 122 public: |
| 123 // Plays the record. | 123 // Plays the record. |
| 124 bool Play() const; | 124 bool Play() const; |
| 125 | 125 |
| 126 // Plays the record working around quirks with SetLayout, | 126 // Plays the record working around quirks with SetLayout, |
| 127 // SetWorldTransform and ModifyWorldTransform. See implementation for details. | 127 // SetWorldTransform and ModifyWorldTransform. See implementation for details. |
| 128 bool SafePlayback(const XFORM* base_matrix) const; | 128 bool SafePlayback(const XFORM* base_matrix) const; |
| 129 | 129 |
| 130 // Access the underlying EMF record. | 130 // Access the underlying EMF record. |
| 131 const ENHMETARECORD* record() const { return record_; } | 131 const ENHMETARECORD* record() const { return record_; } |
| 132 | 132 |
| 133 protected: | 133 protected: |
| 134 Record(const EnumerationContext* context, | 134 Record(const EnumerationContext* context, |
| 135 const ENHMETARECORD* record); | 135 const ENHMETARECORD* record); |
| 136 | 136 |
| 137 private: | 137 private: |
| 138 friend class Emf; | 138 friend class Emf; |
| 139 friend class Enumerator; | 139 friend class Enumerator; |
| 140 const ENHMETARECORD* record_; | 140 const ENHMETARECORD* record_; |
| 141 const EnumerationContext* context_; | 141 const EnumerationContext* context_; |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 // Retrieves individual records out of a Emf buffer. The main use is to skip | 144 // Retrieves individual records out of a Emf buffer. The main use is to skip |
| 145 // over records that are unsupported on a specific printer or to play back | 145 // over records that are unsupported on a specific printer or to play back |
| 146 // only a part of an EMF buffer. | 146 // only a part of an EMF buffer. |
| 147 class Emf::Enumerator { | 147 class PRINTING_EXPORT Emf::Enumerator { |
| 148 public: | 148 public: |
| 149 // Iterator type used for iterating the records. | 149 // Iterator type used for iterating the records. |
| 150 typedef std::vector<Record>::const_iterator const_iterator; | 150 typedef std::vector<Record>::const_iterator const_iterator; |
| 151 | 151 |
| 152 // Enumerates the records at construction time. |hdc| and |rect| are | 152 // Enumerates the records at construction time. |hdc| and |rect| are |
| 153 // both optional at the same time or must both be valid. | 153 // both optional at the same time or must both be valid. |
| 154 // Warning: |emf| must be kept valid for the time this object is alive. | 154 // Warning: |emf| must be kept valid for the time this object is alive. |
| 155 Enumerator(const Emf& emf, HDC hdc, const RECT* rect); | 155 Enumerator(const Emf& emf, HDC hdc, const RECT* rect); |
| 156 | 156 |
| 157 // Retrieves the first Record. | 157 // Retrieves the first Record. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 174 std::vector<Record> items_; | 174 std::vector<Record> items_; |
| 175 | 175 |
| 176 EnumerationContext context_; | 176 EnumerationContext context_; |
| 177 | 177 |
| 178 DISALLOW_COPY_AND_ASSIGN(Enumerator); | 178 DISALLOW_COPY_AND_ASSIGN(Enumerator); |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 } // namespace printing | 181 } // namespace printing |
| 182 | 182 |
| 183 #endif // PRINTING_EMF_WIN_H_ | 183 #endif // PRINTING_EMF_WIN_H_ |
| OLD | NEW |