| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // TODO(slightlyoff): Add any required LICENSE block changes for MSFT code | 5 // TODO(slightlyoff): Add any required LICENSE block changes for MSFT code |
| 6 // inclusion. | 6 // inclusion. |
| 7 | 7 |
| 8 // ole_document_impl.h : IOleDocument implementation | 8 // ole_document_impl.h : IOleDocument implementation |
| 9 // | 9 // |
| 10 // This file is a modified version of the OleDocument.h file, which is | 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 | 11 // part of the ActiveDoc MSDN sample. The modifications are largely |
| (...skipping 20 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 ////////////////////////////////////////////////////////////////////////////// | 33 ////////////////////////////////////////////////////////////////////////////// |
| 34 // IOleDocumentImpl | 34 // IOleDocumentImpl |
| 35 template <class T> | 35 template <class T> |
| 36 class ATL_NO_VTABLE IOleDocumentImpl : public IOleDocument { | 36 class ATL_NO_VTABLE IOleDocumentImpl : public IOleDocument { |
| 37 public: | 37 public: |
| 38 STDMETHOD(CreateView)(IOleInPlaceSite* in_place_site, | 38 STDMETHOD(CreateView)(IOleInPlaceSite* in_place_site, |
| 39 IStream* stream, | 39 IStream* stream, |
| 40 DWORD reserved , | 40 DWORD reserved , |
| 41 IOleDocumentView** new_view) { | 41 IOleDocumentView** new_view) { |
| 42 DLOG(INFO) << __FUNCTION__; | 42 DVLOG(1) << __FUNCTION__; |
| 43 if (new_view == NULL) | 43 if (new_view == NULL) |
| 44 return E_POINTER; | 44 return E_POINTER; |
| 45 T* t = static_cast<T*>(this); | 45 T* t = static_cast<T*>(this); |
| 46 // If we've already created a view then we can't create another as we | 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 | 47 // currently only support the ability to create one view |
| 48 if (t->m_spInPlaceSite) { | 48 if (t->m_spInPlaceSite) |
| 49 return E_FAIL; | 49 return E_FAIL; |
| 50 } | |
| 51 IOleDocumentView* view; | 50 IOleDocumentView* view; |
| 52 t->GetUnknown()->QueryInterface(IID_IOleDocumentView, | 51 t->GetUnknown()->QueryInterface(IID_IOleDocumentView, |
| 53 reinterpret_cast<void**>(&view)); | 52 reinterpret_cast<void**>(&view)); |
| 54 // If we support IOleDocument we should support IOleDocumentView | 53 // If we support IOleDocument we should support IOleDocumentView |
| 55 ATLENSURE(view != NULL); | 54 ATLENSURE(view != NULL); |
| 56 // If they've given us a site then use it | 55 // If they've given us a site then use it |
| 57 if (in_place_site != NULL) { | 56 if (in_place_site != NULL) |
| 58 view->SetInPlaceSite(in_place_site); | 57 view->SetInPlaceSite(in_place_site); |
| 59 } | |
| 60 // If they have given us an IStream pointer then use it to | 58 // If they have given us an IStream pointer then use it to |
| 61 // initialize the view | 59 // initialize the view |
| 62 if (stream != NULL) { | 60 if (stream != NULL) |
| 63 view->ApplyViewState(stream); | 61 view->ApplyViewState(stream); |
| 64 } | |
| 65 // Return the view | 62 // Return the view |
| 66 *new_view = view; | 63 *new_view = view; |
| 67 return S_OK; | 64 return S_OK; |
| 68 } | 65 } |
| 69 | 66 |
| 70 STDMETHOD(GetDocMiscStatus)(DWORD* status) { | 67 STDMETHOD(GetDocMiscStatus)(DWORD* status) { |
| 71 DLOG(INFO) << __FUNCTION__; | 68 DVLOG(1) << __FUNCTION__; |
| 72 if (NULL == status) { | 69 if (NULL == status) |
| 73 return E_POINTER; | 70 return E_POINTER; |
| 74 } | |
| 75 *status = DOCMISC_NOFILESUPPORT; | 71 *status = DOCMISC_NOFILESUPPORT; |
| 76 return S_OK; | 72 return S_OK; |
| 77 } | 73 } |
| 78 | 74 |
| 79 STDMETHOD(EnumViews)(IEnumOleDocumentViews** enum_views, | 75 STDMETHOD(EnumViews)(IEnumOleDocumentViews** enum_views, |
| 80 IOleDocumentView** view) { | 76 IOleDocumentView** view) { |
| 81 DLOG(INFO) << __FUNCTION__; | 77 DVLOG(1) << __FUNCTION__; |
| 82 if (view == NULL) | 78 if (view == NULL) |
| 83 return E_POINTER; | 79 return E_POINTER; |
| 84 T* t = static_cast<T*>(this); | 80 T* t = static_cast<T*>(this); |
| 85 // We only support one view | 81 // We only support one view |
| 86 return t->_InternalQueryInterface(IID_IOleDocumentView, | 82 return t->_InternalQueryInterface(IID_IOleDocumentView, |
| 87 reinterpret_cast<void**>(view)); | 83 reinterpret_cast<void**>(view)); |
| 88 } | 84 } |
| 89 }; | 85 }; |
| 90 | 86 |
| 91 ////////////////////////////////////////////////////////////////////////////// | 87 ////////////////////////////////////////////////////////////////////////////// |
| 92 // IOleDocumentViewImpl | 88 // IOleDocumentViewImpl |
| 93 | 89 |
| 94 template <class T> | 90 template <class T> |
| 95 class ATL_NO_VTABLE IOleDocumentViewImpl : public IOleDocumentView { | 91 class ATL_NO_VTABLE IOleDocumentViewImpl : public IOleDocumentView { |
| 96 public: | 92 public: |
| 97 STDMETHOD(SetInPlaceSite)(IOleInPlaceSite* in_place_site) { | 93 STDMETHOD(SetInPlaceSite)(IOleInPlaceSite* in_place_site) { |
| 98 DLOG(INFO) << __FUNCTION__; | 94 DVLOG(1) << __FUNCTION__; |
| 99 T* t = static_cast<T*>(this); | 95 T* t = static_cast<T*>(this); |
| 100 if (t->m_spInPlaceSite) { | 96 if (t->m_spInPlaceSite) { |
| 101 // If we already have a site get rid of it | 97 // If we already have a site get rid of it |
| 102 UIActivate(FALSE); | 98 UIActivate(FALSE); |
| 103 HRESULT hr = t->InPlaceDeactivate(); | 99 HRESULT hr = t->InPlaceDeactivate(); |
| 104 if (FAILED(hr)) { | 100 if (FAILED(hr)) |
| 105 return hr; | 101 return hr; |
| 106 } | |
| 107 DCHECK(!t->m_bInPlaceActive); | 102 DCHECK(!t->m_bInPlaceActive); |
| 108 } | 103 } |
| 109 if (in_place_site != NULL) { | 104 if (in_place_site != NULL) { |
| 110 t->m_spInPlaceSite.Release(); | 105 t->m_spInPlaceSite.Release(); |
| 111 in_place_site->QueryInterface( | 106 in_place_site->QueryInterface( |
| 112 IID_IOleInPlaceSiteWindowless, | 107 IID_IOleInPlaceSiteWindowless, |
| 113 reinterpret_cast<void **>(&t->m_spInPlaceSite)); | 108 reinterpret_cast<void **>(&t->m_spInPlaceSite)); |
| 114 if (!t->m_spInPlaceSite) { | 109 if (!t->m_spInPlaceSite) { |
| 115 // TODO(sanjeevr): This is a super-hack because m_spInPlaceSite | 110 // TODO(sanjeevr): This is a super-hack because m_spInPlaceSite |
| 116 // is an IOleInPlaceSiteWindowless pointer and we are setting | 111 // is an IOleInPlaceSiteWindowless pointer and we are setting |
| 117 // an IOleInPlaceSite pointer into it. The problem is that ATL | 112 // an IOleInPlaceSite pointer into it. The problem is that ATL |
| 118 // (CComControlBase) uses this in a schizophrenic manner based | 113 // (CComControlBase) uses this in a schizophrenic manner based |
| 119 // on the m_bWndLess flag. Ouch, ouch, ouch! Find a way to clean | 114 // on the m_bWndLess flag. Ouch, ouch, ouch! Find a way to clean |
| 120 // this up. | 115 // this up. |
| 121 // Disclaimer: I did not invent this hack, it exists in the MSDN | 116 // 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 | 117 // sample from where this code has been derived and it also exists |
| 123 // in ATL itself (look at atlctl.h line 938). | 118 // in ATL itself (look at atlctl.h line 938). |
| 124 t->m_spInPlaceSite = | 119 t->m_spInPlaceSite = |
| 125 reinterpret_cast<IOleInPlaceSiteWindowless*>(in_place_site); | 120 reinterpret_cast<IOleInPlaceSiteWindowless*>(in_place_site); |
| 126 } | 121 } |
| 127 } | 122 } |
| 128 return S_OK; | 123 return S_OK; |
| 129 } | 124 } |
| 130 | 125 |
| 131 STDMETHOD(GetInPlaceSite)(IOleInPlaceSite** in_place_site) { | 126 STDMETHOD(GetInPlaceSite)(IOleInPlaceSite** in_place_site) { |
| 132 DLOG(INFO) << __FUNCTION__; | 127 DVLOG(1) << __FUNCTION__; |
| 133 if (in_place_site == NULL) { | 128 if (in_place_site == NULL) |
| 134 return E_POINTER; | 129 return E_POINTER; |
| 135 } | |
| 136 T* t = static_cast<T*>(this); | 130 T* t = static_cast<T*>(this); |
| 137 return t->m_spInPlaceSite->QueryInterface( | 131 return t->m_spInPlaceSite->QueryInterface( |
| 138 IID_IOleInPlaceSite, | 132 IID_IOleInPlaceSite, |
| 139 reinterpret_cast<LPVOID *>(in_place_site)); | 133 reinterpret_cast<LPVOID *>(in_place_site)); |
| 140 } | 134 } |
| 141 | 135 |
| 142 STDMETHOD(GetDocument)(IUnknown** document) { | 136 STDMETHOD(GetDocument)(IUnknown** document) { |
| 143 DLOG(INFO) << __FUNCTION__; | 137 DVLOG(1) << __FUNCTION__; |
| 144 if (document == NULL) { | 138 if (document == NULL) |
| 145 return E_POINTER; | 139 return E_POINTER; |
| 146 } | |
| 147 T* t = static_cast<T*>(this); | 140 T* t = static_cast<T*>(this); |
| 148 *document = t->GetUnknown(); | 141 *document = t->GetUnknown(); |
| 149 (*document)->AddRef(); | 142 (*document)->AddRef(); |
| 150 return S_OK; | 143 return S_OK; |
| 151 } | 144 } |
| 152 | 145 |
| 153 STDMETHOD(SetRect)(LPRECT view_rect) { | 146 STDMETHOD(SetRect)(LPRECT view_rect) { |
| 154 static bool is_resizing = false; | 147 static bool is_resizing = false; |
| 155 if (is_resizing) { | 148 if (is_resizing) |
| 156 return S_OK; | 149 return S_OK; |
| 157 } | |
| 158 is_resizing = true; | 150 is_resizing = true; |
| 159 DLOG(INFO) << __FUNCTION__ << " " << view_rect->left << "," << | 151 DVLOG(1) << __FUNCTION__ << " " << view_rect->left << "," |
| 160 view_rect->top << "," << view_rect->right << "," << view_rect->bottom; | 152 << view_rect->top << "," << view_rect->right << "," |
| 153 << view_rect->bottom; |
| 161 T* t = static_cast<T*>(this); | 154 T* t = static_cast<T*>(this); |
| 162 t->SetObjectRects(view_rect, view_rect); | 155 t->SetObjectRects(view_rect, view_rect); |
| 163 is_resizing = false; | 156 is_resizing = false; |
| 164 return S_OK; | 157 return S_OK; |
| 165 } | 158 } |
| 166 | 159 |
| 167 STDMETHOD(GetRect)(LPRECT view_rect) { | 160 STDMETHOD(GetRect)(LPRECT view_rect) { |
| 168 DLOG(INFO) << __FUNCTION__; | 161 DVLOG(1) << __FUNCTION__; |
| 169 if (view_rect == NULL) { | 162 if (view_rect == NULL) |
| 170 return E_POINTER; | 163 return E_POINTER; |
| 171 } | |
| 172 T* t = static_cast<T*>(this); | 164 T* t = static_cast<T*>(this); |
| 173 *view_rect = t->m_rcPos; | 165 *view_rect = t->m_rcPos; |
| 174 return S_OK; | 166 return S_OK; |
| 175 } | 167 } |
| 176 | 168 |
| 177 STDMETHOD(SetRectComplex)(LPRECT view_rect, | 169 STDMETHOD(SetRectComplex)(LPRECT view_rect, |
| 178 LPRECT hscroll_rect, | 170 LPRECT hscroll_rect, |
| 179 LPRECT vscroll_rect, | 171 LPRECT vscroll_rect, |
| 180 LPRECT size_box_rect) { | 172 LPRECT size_box_rect) { |
| 181 DLOG(INFO) << __FUNCTION__ << " not implemented"; | 173 DVLOG(1) << __FUNCTION__ << " not implemented"; |
| 182 return E_NOTIMPL; | 174 return E_NOTIMPL; |
| 183 } | 175 } |
| 184 | 176 |
| 185 STDMETHOD(Show)(BOOL show) { | 177 STDMETHOD(Show)(BOOL show) { |
| 186 DLOG(INFO) << __FUNCTION__; | 178 DVLOG(1) << __FUNCTION__; |
| 187 T* t = static_cast<T*>(this); | 179 T* t = static_cast<T*>(this); |
| 188 HRESULT hr = S_OK; | 180 HRESULT hr = S_OK; |
| 189 if (show) { | 181 if (show) { |
| 190 if (!t->m_bUIActive) | 182 if (!t->m_bUIActive) |
| 191 hr = t->ActiveXDocActivate(OLEIVERB_INPLACEACTIVATE); | 183 hr = t->ActiveXDocActivate(OLEIVERB_INPLACEACTIVATE); |
| 192 } else { | 184 } else { |
| 193 hr = t->UIActivate(FALSE); | 185 hr = t->UIActivate(FALSE); |
| 194 ::ShowWindow(t->m_hWnd, SW_HIDE); | 186 ::ShowWindow(t->m_hWnd, SW_HIDE); |
| 195 } | 187 } |
| 196 return hr; | 188 return hr; |
| 197 } | 189 } |
| 198 | 190 |
| 199 STDMETHOD(UIActivate)(BOOL ui_activate) { | 191 STDMETHOD(UIActivate)(BOOL ui_activate) { |
| 200 DLOG(INFO) << __FUNCTION__; | 192 DVLOG(1) << __FUNCTION__; |
| 201 T* t = static_cast<T*>(this); | 193 T* t = static_cast<T*>(this); |
| 202 HRESULT hr = S_OK; | 194 HRESULT hr = S_OK; |
| 203 if (ui_activate) { | 195 if (ui_activate) { |
| 204 // We must know the client site first | 196 // We must know the client site first |
| 205 if (t->m_spInPlaceSite == NULL) { | 197 if (t->m_spInPlaceSite == NULL) |
| 206 return E_UNEXPECTED; | 198 return E_UNEXPECTED; |
| 207 } | 199 if (!t->m_bUIActive) |
| 208 if (!t->m_bUIActive) { | |
| 209 hr = t->ActiveXDocActivate(OLEIVERB_UIACTIVATE); | 200 hr = t->ActiveXDocActivate(OLEIVERB_UIACTIVATE); |
| 210 } | |
| 211 } else { | 201 } else { |
| 212 // Menu integration is still not complete, so do not destroy | 202 // Menu integration is still not complete, so do not destroy |
| 213 // IE's menus. If we call InPlaceMenuDestroy here, menu items such | 203 // IE's menus. If we call InPlaceMenuDestroy here, menu items such |
| 214 // as Print etc will be disabled and we will not get calls to QueryStatus | 204 // as Print etc will be disabled and we will not get calls to QueryStatus |
| 215 // for those commands. | 205 // for those commands. |
| 216 // t->InPlaceMenuDestroy(); | 206 // t->InPlaceMenuDestroy(); |
| 217 // t->DestroyToolbar(); | 207 // t->DestroyToolbar(); |
| 218 hr = t->UIDeactivate(); | 208 hr = t->UIDeactivate(); |
| 219 } | 209 } |
| 220 return hr; | 210 return hr; |
| 221 } | 211 } |
| 222 | 212 |
| 223 STDMETHOD(Open)() { | 213 STDMETHOD(Open)() { |
| 224 DLOG(INFO) << __FUNCTION__ << " not implemented"; | 214 DVLOG(1) << __FUNCTION__ << " not implemented"; |
| 225 return E_NOTIMPL; | 215 return E_NOTIMPL; |
| 226 } | 216 } |
| 227 | 217 |
| 228 STDMETHOD(CloseView)(DWORD reserved) { | 218 STDMETHOD(CloseView)(DWORD reserved) { |
| 229 DLOG(INFO) << __FUNCTION__; | 219 DVLOG(1) << __FUNCTION__; |
| 230 T* t = static_cast<T*>(this); | 220 T* t = static_cast<T*>(this); |
| 231 t->Show(FALSE); | 221 t->Show(FALSE); |
| 232 t->SetInPlaceSite(NULL); | 222 t->SetInPlaceSite(NULL); |
| 233 return S_OK; | 223 return S_OK; |
| 234 } | 224 } |
| 235 | 225 |
| 236 STDMETHOD(SaveViewState)(LPSTREAM stream) { | 226 STDMETHOD(SaveViewState)(LPSTREAM stream) { |
| 237 DLOG(INFO) << __FUNCTION__ << " not implemented"; | 227 DVLOG(1) << __FUNCTION__ << " not implemented"; |
| 238 return E_NOTIMPL; | 228 return E_NOTIMPL; |
| 239 } | 229 } |
| 240 | 230 |
| 241 STDMETHOD(ApplyViewState)(LPSTREAM stream) { | 231 STDMETHOD(ApplyViewState)(LPSTREAM stream) { |
| 242 DLOG(INFO) << __FUNCTION__ << " not implemented"; | 232 DVLOG(1) << __FUNCTION__ << " not implemented"; |
| 243 return E_NOTIMPL; | 233 return E_NOTIMPL; |
| 244 } | 234 } |
| 245 | 235 |
| 246 STDMETHOD(Clone)(IOleInPlaceSite* new_in_place_site, | 236 STDMETHOD(Clone)(IOleInPlaceSite* new_in_place_site, |
| 247 IOleDocumentView** new_view) { | 237 IOleDocumentView** new_view) { |
| 248 DLOG(INFO) << __FUNCTION__ << " not implemented"; | 238 DVLOG(1) << __FUNCTION__ << " not implemented"; |
| 249 return E_NOTIMPL; | 239 return E_NOTIMPL; |
| 250 } | 240 } |
| 251 | 241 |
| 252 HRESULT ActiveXDocActivate(LONG verb) { | 242 HRESULT ActiveXDocActivate(LONG verb) { |
| 253 return E_NOTIMPL; | 243 return E_NOTIMPL; |
| 254 } | 244 } |
| 255 }; | 245 }; |
| 256 | 246 |
| 257 #endif // CHROME_FRAME_OLE_DOCUMENT_IMPL_H_ | 247 #endif // CHROME_FRAME_OLE_DOCUMENT_IMPL_H_ |
| OLD | NEW |