Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Side by Side Diff: chrome_frame/ole_document_impl.h

Issue 218019: Initial import of the Chrome Frame codebase. Integration in chrome.gyp coming... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 | « chrome_frame/ns_isupports_impl.h ('k') | chrome_frame/plugin_url_request.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // TODO(slightlyoff): Add any required LICENSE block changes for MSFT code
6 // inclusion.
7
8 // ole_document_impl.h : IOleDocument implementation
9 //
10 // This file is a modified version of the OleDocument.h file, which is
11 // part of the ActiveDoc MSDN sample. The modifications are largely
12 // conversions to Google coding guidelines. Below if the original header
13 // from the file.
14
15 // This is a part of the Active Template Library.
16 // Copyright (c) Microsoft Corporation. All rights reserved.
17 //
18 // This source code is only intended as a supplement to the
19 // Active Template Library Reference and related
20 // electronic documentation provided with the library.
21 // See these sources for detailed information regarding the
22 // Active Template Library product.
23
24 #ifndef CHROME_FRAME_OLE_DOCUMENT_IMPL_H_
25 #define CHROME_FRAME_OLE_DOCUMENT_IMPL_H_
26
27 // TODO(sanjeevr): Revisit this impl file and cleanup dependencies
28 #include <atlbase.h>
29 #include <docobj.h>
30
31 #include "base/logging.h"
32
33 //////////////////////////////////////////////////////////////////////////////
34 // IOleDocumentImpl
35 template <class T>
36 class ATL_NO_VTABLE IOleDocumentImpl : public IOleDocument {
37 public:
38 STDMETHOD(CreateView)(IOleInPlaceSite* in_place_site,
39 IStream* stream,
40 DWORD reserved ,
41 IOleDocumentView** new_view) {
42 DLOG(INFO) << __FUNCTION__;
43 if (new_view == NULL)
44 return E_POINTER;
45 T* t = static_cast<T*>(this);
46 // If we've already created a view then we can't create another as we
47 // currently only support the ability to create one view
48 if (t->m_spInPlaceSite) {
49 return E_FAIL;
50 }
51 IOleDocumentView* view;
52 t->GetUnknown()->QueryInterface(IID_IOleDocumentView,
53 reinterpret_cast<void**>(&view));
54 // If we support IOleDocument we should support IOleDocumentView
55 ATLENSURE(view != NULL);
56 // If they've given us a site then use it
57 if (in_place_site != NULL) {
58 view->SetInPlaceSite(in_place_site);
59 }
60 // If they have given us an IStream pointer then use it to
61 // initialize the view
62 if (stream != NULL) {
63 view->ApplyViewState(stream);
64 }
65 // Return the view
66 *new_view = view;
67 return S_OK;
68 }
69
70 STDMETHOD(GetDocMiscStatus)(DWORD* status) {
71 DLOG(INFO) << __FUNCTION__;
72 if (NULL == status) {
73 return E_POINTER;
74 }
75 *status = DOCMISC_NOFILESUPPORT;
76 return S_OK;
77 }
78
79 STDMETHOD(EnumViews)(IEnumOleDocumentViews** enum_views,
80 IOleDocumentView** view) {
81 DLOG(INFO) << __FUNCTION__;
82 if (view == NULL)
83 return E_POINTER;
84 T* t = static_cast<T*>(this);
85 // We only support one view
86 return t->_InternalQueryInterface(IID_IOleDocumentView,
87 reinterpret_cast<void**>(view));
88 }
89 };
90
91 //////////////////////////////////////////////////////////////////////////////
92 // IOleDocumentViewImpl
93
94 template <class T>
95 class ATL_NO_VTABLE IOleDocumentViewImpl : public IOleDocumentView {
96 public:
97 STDMETHOD(SetInPlaceSite)(IOleInPlaceSite* in_place_site) {
98 DLOG(INFO) << __FUNCTION__;
99 T* t = static_cast<T*>(this);
100 if (t->m_spInPlaceSite) {
101 // If we already have a site get rid of it
102 UIActivate(FALSE);
103 HRESULT hr = t->InPlaceDeactivate();
104 if (FAILED(hr)) {
105 return hr;
106 }
107 DCHECK(!t->m_bInPlaceActive);
108 }
109 if (in_place_site != NULL) {
110 t->m_spInPlaceSite.Release();
111 in_place_site->QueryInterface(
112 IID_IOleInPlaceSiteWindowless,
113 reinterpret_cast<void **>(&t->m_spInPlaceSite));
114 if (!t->m_spInPlaceSite) {
115 // TODO(sanjeevr): This is a super-hack because m_spInPlaceSite
116 // is an IOleInPlaceSiteWindowless pointer and we are setting
117 // an IOleInPlaceSite pointer into it. The problem is that ATL
118 // (CComControlBase) uses this in a schizophrenic manner based
119 // on the m_bWndLess flag. Ouch, ouch, ouch! Find a way to clean
120 // this up.
121 // Disclaimer: I did not invent this hack, it exists in the MSDN
122 // sample from where this code has been derived and it also exists
123 // in ATL itself (look at atlctl.h line 938).
124 t->m_spInPlaceSite =
125 reinterpret_cast<IOleInPlaceSiteWindowless*>(in_place_site);
126 }
127 }
128 return S_OK;
129 }
130
131 STDMETHOD(GetInPlaceSite)(IOleInPlaceSite** in_place_site) {
132 DLOG(INFO) << __FUNCTION__;
133 if (in_place_site == NULL) {
134 return E_POINTER;
135 }
136 T* t = static_cast<T*>(this);
137 return t->m_spInPlaceSite->QueryInterface(
138 IID_IOleInPlaceSite,
139 reinterpret_cast<LPVOID *>(in_place_site));
140 }
141
142 STDMETHOD(GetDocument)(IUnknown** document) {
143 DLOG(INFO) << __FUNCTION__;
144 if (document == NULL) {
145 return E_POINTER;
146 }
147 T* t = static_cast<T*>(this);
148 *document = t->GetUnknown();
149 (*document)->AddRef();
150 return S_OK;
151 }
152
153 STDMETHOD(SetRect)(LPRECT view_rect) {
154 static bool is_resizing = false;
155 if (is_resizing) {
156 return S_OK;
157 }
158 is_resizing = true;
159 DLOG(INFO) << __FUNCTION__ << " " << view_rect->left << "," <<
160 view_rect->top << "," << view_rect->right << "," << view_rect->bottom;
161 T* t = static_cast<T*>(this);
162 t->SetObjectRects(view_rect, view_rect);
163 is_resizing = false;
164 return S_OK;
165 }
166
167 STDMETHOD(GetRect)(LPRECT view_rect) {
168 DLOG(INFO) << __FUNCTION__;
169 if (view_rect == NULL) {
170 return E_POINTER;
171 }
172 T* t = static_cast<T*>(this);
173 *view_rect = t->m_rcPos;
174 return S_OK;
175 }
176
177 STDMETHOD(SetRectComplex)(LPRECT view_rect,
178 LPRECT hscroll_rect,
179 LPRECT vscroll_rect,
180 LPRECT size_box_rect) {
181 DLOG(INFO) << __FUNCTION__ << " not implemented";
182 return E_NOTIMPL;
183 }
184
185 STDMETHOD(Show)(BOOL show) {
186 DLOG(INFO) << __FUNCTION__;
187 T* t = static_cast<T*>(this);
188 HRESULT hr = S_OK;
189 if (show) {
190 if (!t->m_bUIActive)
191 hr = t->ActiveXDocActivate(OLEIVERB_INPLACEACTIVATE);
192 } else {
193 hr = t->UIActivate(FALSE);
194 ::ShowWindow(t->m_hWnd, SW_HIDE);
195 }
196 return hr;
197 }
198
199 STDMETHOD(UIActivate)(BOOL ui_activate) {
200 DLOG(INFO) << __FUNCTION__;
201 T* t = static_cast<T*>(this);
202 HRESULT hr = S_OK;
203 if (ui_activate) {
204 // We must know the client site first
205 if (t->m_spInPlaceSite == NULL) {
206 return E_UNEXPECTED;
207 }
208 if (!t->m_bUIActive) {
209 hr = t->ActiveXDocActivate(OLEIVERB_UIACTIVATE);
210 }
211 } else {
212 t->InPlaceMenuDestroy();
213 // t->DestroyToolbar();
214 hr = t->UIDeactivate();
215 }
216 return hr;
217 }
218
219 STDMETHOD(Open)() {
220 DLOG(INFO) << __FUNCTION__ << " not implemented";
221 return E_NOTIMPL;
222 }
223
224 STDMETHOD(CloseView)(DWORD reserved) {
225 DLOG(INFO) << __FUNCTION__;
226 T* t = static_cast<T*>(this);
227 t->Show(FALSE);
228 t->SetInPlaceSite(NULL);
229 return S_OK;
230 }
231
232 STDMETHOD(SaveViewState)(LPSTREAM stream) {
233 DLOG(INFO) << __FUNCTION__ << " not implemented";
234 return E_NOTIMPL;
235 }
236
237 STDMETHOD(ApplyViewState)(LPSTREAM stream) {
238 DLOG(INFO) << __FUNCTION__ << " not implemented";
239 return E_NOTIMPL;
240 }
241
242 STDMETHOD(Clone)(IOleInPlaceSite* new_in_place_site,
243 IOleDocumentView** new_view) {
244 DLOG(INFO) << __FUNCTION__ << " not implemented";
245 return E_NOTIMPL;
246 }
247
248 HRESULT ActiveXDocActivate(LONG verb) {
249 return E_NOTIMPL;
250 }
251 };
252
253 #endif // CHROME_FRAME_OLE_DOCUMENT_IMPL_H_
OLDNEW
« no previous file with comments | « chrome_frame/ns_isupports_impl.h ('k') | chrome_frame/plugin_url_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698