Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(544)

Side by Side Diff: printing/emf_win.h

Issue 10557019: Fixed clipping printing with EMF. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | printing/emf_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9
10 #include <vector> 10 #include <vector>
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 // Valid when generating EMF data through a virtual HDC. 107 // Valid when generating EMF data through a virtual HDC.
108 HDC hdc_; 108 HDC hdc_;
109 109
110 int page_count_; 110 int page_count_;
111 111
112 DISALLOW_COPY_AND_ASSIGN(Emf); 112 DISALLOW_COPY_AND_ASSIGN(Emf);
113 }; 113 };
114 114
115 struct Emf::EnumerationContext { 115 struct Emf::EnumerationContext {
116 EnumerationContext();
Albert Bodenhamer 2012/06/18 19:08:53 If you're going to add a constructor, make this a
Vitaly Buka (NO REVIEWS) 2012/06/18 19:33:06 Actually according out coding style even methods a
117
116 HANDLETABLE* handle_table; 118 HANDLETABLE* handle_table;
117 int objects_count; 119 int objects_count;
118 HDC hdc; 120 HDC hdc;
121 const XFORM* base_matrix;
122 int dc_on_page_start;
119 }; 123 };
120 124
121 // One EMF record. It keeps pointers to the EMF buffer held by Emf::emf_. 125 // One EMF record. It keeps pointers to the EMF buffer held by Emf::emf_.
122 // The entries become invalid once Emf::CloseEmf() is called. 126 // The entries become invalid once Emf::CloseEmf() is called.
123 class PRINTING_EXPORT Emf::Record { 127 class PRINTING_EXPORT Emf::Record {
124 public: 128 public:
125 // Plays the record. 129 // Plays the record.
126 bool Play() const; 130 bool Play(EnumerationContext* context) const;
127 131
128 // Plays the record working around quirks with SetLayout, 132 // Plays the record working around quirks with SetLayout,
129 // SetWorldTransform and ModifyWorldTransform. See implementation for details. 133 // SetWorldTransform and ModifyWorldTransform. See implementation for details.
130 bool SafePlayback(const XFORM* base_matrix) const; 134 bool SafePlayback(EnumerationContext* context) const;
131 135
132 // Access the underlying EMF record. 136 // Access the underlying EMF record.
133 const ENHMETARECORD* record() const { return record_; } 137 const ENHMETARECORD* record() const { return record_; }
134 138
135 protected: 139 protected:
136 Record(const EnumerationContext* context, 140 explicit Record(const ENHMETARECORD* record);
137 const ENHMETARECORD* record);
138 141
139 private: 142 private:
140 friend class Emf; 143 friend class Emf;
141 friend class Enumerator; 144 friend class Enumerator;
142 const ENHMETARECORD* record_; 145 const ENHMETARECORD* record_;
143 const EnumerationContext* context_;
144 }; 146 };
145 147
146 // Retrieves individual records out of a Emf buffer. The main use is to skip 148 // Retrieves individual records out of a Emf buffer. The main use is to skip
147 // over records that are unsupported on a specific printer or to play back 149 // over records that are unsupported on a specific printer or to play back
148 // only a part of an EMF buffer. 150 // only a part of an EMF buffer.
149 class PRINTING_EXPORT Emf::Enumerator { 151 class PRINTING_EXPORT Emf::Enumerator {
150 public: 152 public:
151 // Iterator type used for iterating the records. 153 // Iterator type used for iterating the records.
152 typedef std::vector<Record>::const_iterator const_iterator; 154 typedef std::vector<Record>::const_iterator const_iterator;
153 155
154 // Enumerates the records at construction time. |hdc| and |rect| are 156 // Enumerates the records at construction time. |hdc| and |rect| are
155 // both optional at the same time or must both be valid. 157 // both optional at the same time or must both be valid.
156 // Warning: |emf| must be kept valid for the time this object is alive. 158 // Warning: |emf| must be kept valid for the time this object is alive.
157 Enumerator(const Emf& emf, HDC hdc, const RECT* rect); 159 Enumerator(const Emf& emf, HDC hdc, const RECT* rect);
158 160
159 // Retrieves the first Record. 161 // Retrieves the first Record.
160 const_iterator begin() const; 162 const_iterator begin() const;
161 163
162 // Retrieves the end of the array. 164 // Retrieves the end of the array.
163 const_iterator end() const; 165 const_iterator end() const;
164 166
165 private: 167 private:
168 FRIEND_TEST_ALL_PREFIXES(EmfPrintingTest, Enumerate);
169
166 // Processes one EMF record and saves it in the items_ array. 170 // Processes one EMF record and saves it in the items_ array.
167 static int CALLBACK EnhMetaFileProc(HDC hdc, 171 static int CALLBACK EnhMetaFileProc(HDC hdc,
168 HANDLETABLE* handle_table, 172 HANDLETABLE* handle_table,
169 const ENHMETARECORD* record, 173 const ENHMETARECORD* record,
170 int objects_count, 174 int objects_count,
171 LPARAM param); 175 LPARAM param);
172 176
173 // The collection of every EMF records in the currently loaded EMF buffer. 177 // The collection of every EMF records in the currently loaded EMF buffer.
174 // Initialized by Enumerate(). It keeps pointers to the EMF buffer held by 178 // Initialized by Enumerate(). It keeps pointers to the EMF buffer held by
175 // Emf::emf_. The entries become invalid once Emf::CloseEmf() is called. 179 // Emf::emf_. The entries become invalid once Emf::CloseEmf() is called.
176 std::vector<Record> items_; 180 std::vector<Record> items_;
177 181
178 EnumerationContext context_; 182 EnumerationContext context_;
179 183
180 DISALLOW_COPY_AND_ASSIGN(Enumerator); 184 DISALLOW_COPY_AND_ASSIGN(Enumerator);
181 }; 185 };
182 186
183 } // namespace printing 187 } // namespace printing
184 188
185 #endif // PRINTING_EMF_WIN_H_ 189 #endif // PRINTING_EMF_WIN_H_
OLDNEW
« no previous file with comments | « no previous file | printing/emf_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698