From 786668a3bbcda7b6abfc7d1d91aed87c9fde4469 Mon Sep 17 00:00:00 2001 From: "locka%iol.ie" Date: Fri, 13 Jun 2003 11:44:24 +0000 Subject: [PATCH] Remove files that have moved into common activex lib. b=206901 r=dbradley@netscape.com sr=alecf@netscape.com --- .../activex/src/control/CPMozillaControl.h | 951 ----------- .../activex/src/control/ControlEventSink.cpp | 217 --- .../activex/src/control/ControlEventSink.h | 93 -- .../activex/src/control/ControlSite.cpp | 1412 ----------------- .../browser/activex/src/control/ControlSite.h | 395 ----- .../src/control/ControlSiteIPFrame.cpp | 136 -- .../activex/src/control/ControlSiteIPFrame.h | 78 - .../activex/src/control/IEHtmlElement.cpp | 757 --------- .../activex/src/control/IEHtmlElement.h | 160 -- .../src/control/IEHtmlElementCollection.cpp | 611 ------- .../src/control/IEHtmlElementCollection.h | 99 -- .../activex/src/control/IEHtmlNode.cpp | 124 -- .../browser/activex/src/control/IEHtmlNode.h | 61 - .../activex/src/control/IHTMLLocationImpl.h | 187 --- .../src/control/IOleCommandTargetImpl.h | 290 ---- .../activex/src/control/IWebBrowserImpl.h | 1204 -------------- .../activex/src/control/ItemContainer.cpp | 136 -- .../activex/src/control/ItemContainer.h | 77 - .../activex/src/control/PropertyBag.cpp | 115 -- .../browser/activex/src/control/PropertyBag.h | 69 - .../activex/src/control/PropertyList.h | 158 -- 21 files changed, 7330 deletions(-) delete mode 100644 embedding/browser/activex/src/control/CPMozillaControl.h delete mode 100644 embedding/browser/activex/src/control/ControlEventSink.cpp delete mode 100644 embedding/browser/activex/src/control/ControlEventSink.h delete mode 100644 embedding/browser/activex/src/control/ControlSite.cpp delete mode 100644 embedding/browser/activex/src/control/ControlSite.h delete mode 100644 embedding/browser/activex/src/control/ControlSiteIPFrame.cpp delete mode 100644 embedding/browser/activex/src/control/ControlSiteIPFrame.h delete mode 100644 embedding/browser/activex/src/control/IEHtmlElement.cpp delete mode 100644 embedding/browser/activex/src/control/IEHtmlElement.h delete mode 100644 embedding/browser/activex/src/control/IEHtmlElementCollection.cpp delete mode 100644 embedding/browser/activex/src/control/IEHtmlElementCollection.h delete mode 100644 embedding/browser/activex/src/control/IEHtmlNode.cpp delete mode 100644 embedding/browser/activex/src/control/IEHtmlNode.h delete mode 100644 embedding/browser/activex/src/control/IHTMLLocationImpl.h delete mode 100644 embedding/browser/activex/src/control/IOleCommandTargetImpl.h delete mode 100644 embedding/browser/activex/src/control/IWebBrowserImpl.h delete mode 100644 embedding/browser/activex/src/control/ItemContainer.cpp delete mode 100644 embedding/browser/activex/src/control/ItemContainer.h delete mode 100644 embedding/browser/activex/src/control/PropertyBag.cpp delete mode 100644 embedding/browser/activex/src/control/PropertyBag.h delete mode 100644 embedding/browser/activex/src/control/PropertyList.h diff --git a/embedding/browser/activex/src/control/CPMozillaControl.h b/embedding/browser/activex/src/control/CPMozillaControl.h deleted file mode 100644 index c78ae04244f6..000000000000 --- a/embedding/browser/activex/src/control/CPMozillaControl.h +++ /dev/null @@ -1,951 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef CPMOZILLACONTROL_H -#define CPMOZILLACONTROL_H - -////////////////////////////////////////////////////////////////////////////// -// CProxyDWebBrowserEvents -template -class CProxyDWebBrowserEvents : public IConnectionPointImpl -{ -public: -//methods: -//DWebBrowserEvents : IDispatch -public: - void Fire_BeforeNavigate( - BSTR URL, - long Flags, - BSTR TargetFrameName, - VARIANT * PostData, - BSTR Headers, - VARIANT_BOOL * Cancel) - { - VARIANTARG* pvars = new VARIANTARG[6]; - for (int i = 0; i < 6; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[5].vt = VT_BSTR; - pvars[5].bstrVal= URL; - pvars[4].vt = VT_I4; - pvars[4].lVal= Flags; - pvars[3].vt = VT_BSTR; - pvars[3].bstrVal= TargetFrameName; - pvars[2].vt = VT_VARIANT | VT_BYREF; - pvars[2].byref= PostData; - pvars[1].vt = VT_BSTR; - pvars[1].bstrVal= Headers; - pvars[0].vt = VT_BOOL | VT_BYREF; - pvars[0].byref= Cancel; - DISPPARAMS disp = { pvars, NULL, 6, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x64, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_NavigateComplete( - BSTR URL) - { - VARIANTARG* pvars = new VARIANTARG[1]; - for (int i = 0; i < 1; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[0].vt = VT_BSTR; - pvars[0].bstrVal= URL; - DISPPARAMS disp = { pvars, NULL, 1, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x65, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_StatusTextChange( - BSTR Text) - { - VARIANTARG* pvars = new VARIANTARG[1]; - for (int i = 0; i < 1; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[0].vt = VT_BSTR; - pvars[0].bstrVal= Text; - DISPPARAMS disp = { pvars, NULL, 1, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x66, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_ProgressChange( - long Progress, - long ProgressMax) - { - VARIANTARG* pvars = new VARIANTARG[2]; - for (int i = 0; i < 2; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[1].vt = VT_I4; - pvars[1].lVal= Progress; - pvars[0].vt = VT_I4; - pvars[0].lVal= ProgressMax; - DISPPARAMS disp = { pvars, NULL, 2, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x6c, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_DownloadComplete() - { - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - DISPPARAMS disp = { NULL, NULL, 0, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x68, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - } - void Fire_CommandStateChange( - long Command, - VARIANT_BOOL Enable) - { - VARIANTARG* pvars = new VARIANTARG[2]; - for (int i = 0; i < 2; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[1].vt = VT_I4; - pvars[1].lVal= Command; - pvars[0].vt = VT_BOOL; - pvars[0].boolVal= Enable; - DISPPARAMS disp = { pvars, NULL, 2, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x69, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_DownloadBegin() - { - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - DISPPARAMS disp = { NULL, NULL, 0, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x6a, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - } - void Fire_NewWindow( - BSTR URL, - long Flags, - BSTR TargetFrameName, - VARIANT * PostData, - BSTR Headers, - VARIANT_BOOL * Processed) - { - VARIANTARG* pvars = new VARIANTARG[6]; - for (int i = 0; i < 6; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[5].vt = VT_BSTR; - pvars[5].bstrVal= URL; - pvars[4].vt = VT_I4; - pvars[4].lVal= Flags; - pvars[3].vt = VT_BSTR; - pvars[3].bstrVal= TargetFrameName; - pvars[2].vt = VT_VARIANT | VT_BYREF; - pvars[2].byref= PostData; - pvars[1].vt = VT_BSTR; - pvars[1].bstrVal= Headers; - pvars[0].vt = VT_BOOL | VT_BYREF; - pvars[0].byref= Processed; - DISPPARAMS disp = { pvars, NULL, 6, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x6b, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_TitleChange( - BSTR Text) - { - VARIANTARG* pvars = new VARIANTARG[1]; - for (int i = 0; i < 1; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[0].vt = VT_BSTR; - pvars[0].bstrVal= Text; - DISPPARAMS disp = { pvars, NULL, 1, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x71, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_FrameBeforeNavigate( - BSTR URL, - long Flags, - BSTR TargetFrameName, - VARIANT * PostData, - BSTR Headers, - VARIANT_BOOL * Cancel) - { - VARIANTARG* pvars = new VARIANTARG[6]; - for (int i = 0; i < 6; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[5].vt = VT_BSTR; - pvars[5].bstrVal= URL; - pvars[4].vt = VT_I4; - pvars[4].lVal= Flags; - pvars[3].vt = VT_BSTR; - pvars[3].bstrVal= TargetFrameName; - pvars[2].vt = VT_VARIANT | VT_BYREF; - pvars[2].byref= PostData; - pvars[1].vt = VT_BSTR; - pvars[1].bstrVal= Headers; - pvars[0].vt = VT_BOOL | VT_BYREF; - pvars[0].byref= Cancel; - DISPPARAMS disp = { pvars, NULL, 6, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0xc8, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_FrameNavigateComplete( - BSTR URL) - { - VARIANTARG* pvars = new VARIANTARG[1]; - for (int i = 0; i < 1; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[0].vt = VT_BSTR; - pvars[0].bstrVal= URL; - DISPPARAMS disp = { pvars, NULL, 1, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0xc9, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_FrameNewWindow( - BSTR URL, - long Flags, - BSTR TargetFrameName, - VARIANT * PostData, - BSTR Headers, - VARIANT_BOOL * Processed) - { - VARIANTARG* pvars = new VARIANTARG[6]; - for (int i = 0; i < 6; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[5].vt = VT_BSTR; - pvars[5].bstrVal= URL; - pvars[4].vt = VT_I4; - pvars[4].lVal= Flags; - pvars[3].vt = VT_BSTR; - pvars[3].bstrVal= TargetFrameName; - pvars[2].vt = VT_VARIANT | VT_BYREF; - pvars[2].byref= PostData; - pvars[1].vt = VT_BSTR; - pvars[1].bstrVal= Headers; - pvars[0].vt = VT_BOOL | VT_BYREF; - pvars[0].byref= Processed; - DISPPARAMS disp = { pvars, NULL, 6, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0xcc, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_Quit( - VARIANT_BOOL * Cancel) - { - VARIANTARG* pvars = new VARIANTARG[1]; - for (int i = 0; i < 1; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[0].vt = VT_BOOL | VT_BYREF; - pvars[0].byref= Cancel; - DISPPARAMS disp = { pvars, NULL, 1, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x67, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_WindowMove() - { - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - DISPPARAMS disp = { NULL, NULL, 0, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x6d, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - } - void Fire_WindowResize() - { - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - DISPPARAMS disp = { NULL, NULL, 0, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x6e, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - } - void Fire_WindowActivate() - { - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - DISPPARAMS disp = { NULL, NULL, 0, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x6f, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - } - void Fire_PropertyChange( - BSTR Property) - { - VARIANTARG* pvars = new VARIANTARG[1]; - for (int i = 0; i < 1; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[0].vt = VT_BSTR; - pvars[0].bstrVal= Property; - DISPPARAMS disp = { pvars, NULL, 1, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x70, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - -}; - - -////////////////////////////////////////////////////////////////////////////// -// CProxyDWebBrowserEvents2 -template -class CProxyDWebBrowserEvents2 : public IConnectionPointImpl -{ -public: -//methods: -//DWebBrowserEvents2 : IDispatch -public: - void Fire_StatusTextChange( - BSTR Text) - { - VARIANTARG* pvars = new VARIANTARG[1]; - for (int i = 0; i < 1; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[0].vt = VT_BSTR; - pvars[0].bstrVal= Text; - DISPPARAMS disp = { pvars, NULL, 1, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x66, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_ProgressChange( - long Progress, - long ProgressMax) - { - VARIANTARG* pvars = new VARIANTARG[2]; - for (int i = 0; i < 2; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[1].vt = VT_I4; - pvars[1].lVal= Progress; - pvars[0].vt = VT_I4; - pvars[0].lVal= ProgressMax; - DISPPARAMS disp = { pvars, NULL, 2, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x6c, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_CommandStateChange( - long Command, - VARIANT_BOOL Enable) - { - VARIANTARG* pvars = new VARIANTARG[2]; - for (int i = 0; i < 2; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[1].vt = VT_I4; - pvars[1].lVal= Command; - pvars[0].vt = VT_BOOL; - pvars[0].boolVal= Enable; - DISPPARAMS disp = { pvars, NULL, 2, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x69, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_DownloadBegin() - { - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - DISPPARAMS disp = { NULL, NULL, 0, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x6a, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - } - void Fire_DownloadComplete() - { - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - DISPPARAMS disp = { NULL, NULL, 0, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x68, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - } - void Fire_TitleChange( - BSTR Text) - { - VARIANTARG* pvars = new VARIANTARG[1]; - for (int i = 0; i < 1; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[0].vt = VT_BSTR; - pvars[0].bstrVal= Text; - DISPPARAMS disp = { pvars, NULL, 1, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x71, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_PropertyChange( - BSTR szProperty) - { - VARIANTARG* pvars = new VARIANTARG[1]; - for (int i = 0; i < 1; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[0].vt = VT_BSTR; - pvars[0].bstrVal= szProperty; - DISPPARAMS disp = { pvars, NULL, 1, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x70, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_BeforeNavigate2( - IDispatch * pDisp, - VARIANT * URL, - VARIANT * Flags, - VARIANT * TargetFrameName, - VARIANT * PostData, - VARIANT * Headers, - VARIANT_BOOL * Cancel) - { - VARIANTARG* pvars = new VARIANTARG[7]; - for (int i = 0; i < 7; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[6].vt = VT_DISPATCH; - pvars[6].pdispVal= pDisp; - pvars[5].vt = VT_VARIANT | VT_BYREF; - pvars[5].byref= URL; - pvars[4].vt = VT_VARIANT | VT_BYREF; - pvars[4].byref= Flags; - pvars[3].vt = VT_VARIANT | VT_BYREF; - pvars[3].byref= TargetFrameName; - pvars[2].vt = VT_VARIANT | VT_BYREF; - pvars[2].byref= PostData; - pvars[1].vt = VT_VARIANT | VT_BYREF; - pvars[1].byref= Headers; - pvars[0].vt = VT_BOOL | VT_BYREF; - pvars[0].byref= Cancel; - DISPPARAMS disp = { pvars, NULL, 7, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0xfa, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_NewWindow2( - IDispatch * * ppDisp, - VARIANT_BOOL * Cancel) - { - VARIANTARG* pvars = new VARIANTARG[2]; - for (int i = 0; i < 2; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[1].vt = VT_DISPATCH | VT_BYREF; - pvars[1].byref= ppDisp; - pvars[0].vt = VT_BOOL | VT_BYREF; - pvars[0].byref= Cancel; - DISPPARAMS disp = { pvars, NULL, 2, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0xfb, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_NavigateComplete2( - IDispatch * pDisp, - VARIANT * URL) - { - VARIANTARG* pvars = new VARIANTARG[2]; - for (int i = 0; i < 2; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[1].vt = VT_DISPATCH; - pvars[1].pdispVal= pDisp; - pvars[0].vt = VT_VARIANT | VT_BYREF; - pvars[0].byref= URL; - DISPPARAMS disp = { pvars, NULL, 2, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0xfc, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_DocumentComplete( - IDispatch * pDisp, - VARIANT * URL) - { - VARIANTARG* pvars = new VARIANTARG[2]; - for (int i = 0; i < 2; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[1].vt = VT_DISPATCH; - pvars[1].pdispVal= pDisp; - pvars[0].vt = VT_VARIANT | VT_BYREF; - pvars[0].byref= URL; - DISPPARAMS disp = { pvars, NULL, 2, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x103, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_OnQuit() - { - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - DISPPARAMS disp = { NULL, NULL, 0, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0xfd, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - } - void Fire_OnVisible( - VARIANT_BOOL Visible) - { - VARIANTARG* pvars = new VARIANTARG[1]; - for (int i = 0; i < 1; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[0].vt = VT_BOOL; - pvars[0].boolVal= Visible; - DISPPARAMS disp = { pvars, NULL, 1, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0xfe, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_OnToolBar( - VARIANT_BOOL ToolBar) - { - VARIANTARG* pvars = new VARIANTARG[1]; - for (int i = 0; i < 1; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[0].vt = VT_BOOL; - pvars[0].boolVal= ToolBar; - DISPPARAMS disp = { pvars, NULL, 1, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0xff, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_OnMenuBar( - VARIANT_BOOL MenuBar) - { - VARIANTARG* pvars = new VARIANTARG[1]; - for (int i = 0; i < 1; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[0].vt = VT_BOOL; - pvars[0].boolVal= MenuBar; - DISPPARAMS disp = { pvars, NULL, 1, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x100, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_OnStatusBar( - VARIANT_BOOL StatusBar) - { - VARIANTARG* pvars = new VARIANTARG[1]; - for (int i = 0; i < 1; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[0].vt = VT_BOOL; - pvars[0].boolVal= StatusBar; - DISPPARAMS disp = { pvars, NULL, 1, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x101, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_OnFullScreen( - VARIANT_BOOL FullScreen) - { - VARIANTARG* pvars = new VARIANTARG[1]; - for (int i = 0; i < 1; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[0].vt = VT_BOOL; - pvars[0].boolVal= FullScreen; - DISPPARAMS disp = { pvars, NULL, 1, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x102, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - void Fire_OnTheaterMode( - VARIANT_BOOL TheaterMode) - { - VARIANTARG* pvars = new VARIANTARG[1]; - for (int i = 0; i < 1; i++) - VariantInit(&pvars[i]); - T* pT = (T*)this; - pT->Lock(); - IUnknown** pp = m_vec.begin(); - while (pp < m_vec.end()) - { - if (*pp != NULL) - { - pvars[0].vt = VT_BOOL; - pvars[0].boolVal= TheaterMode; - DISPPARAMS disp = { pvars, NULL, 1, 0 }; - IDispatch* pDispatch = reinterpret_cast(*pp); - pDispatch->Invoke(0x104, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); - } - pp++; - } - pT->Unlock(); - delete[] pvars; - } - -}; - - -#endif \ No newline at end of file diff --git a/embedding/browser/activex/src/control/ControlEventSink.cpp b/embedding/browser/activex/src/control/ControlEventSink.cpp deleted file mode 100644 index a325b49c59ea..000000000000 --- a/embedding/browser/activex/src/control/ControlEventSink.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Adam Lock - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "StdAfx.h" - -#include "ControlEventSink.h" - -CControlEventSink::CControlEventSink() : - m_dwEventCookie(0), - m_EventIID(GUID_NULL) -{ -} - -CControlEventSink::~CControlEventSink() -{ - UnsubscribeFromEvents(); -} - -BOOL -CControlEventSink::GetEventSinkIID(IUnknown *pControl, IID &iid, ITypeInfo **typeInfo) -{ - iid = GUID_NULL; - if (!pControl) - { - return E_INVALIDARG; - } - - // IProvideClassInfo2 way is easiest -// CComQIPtr classInfo2 = pControl; -// if (classInfo2) -// { -// classInfo2->GetGUID(GUIDKIND_DEFAULT_SOURCE_DISP_IID, &iid); -// if (!::IsEqualIID(iid, GUID_NULL)) -// { -// return TRUE; -// } -// } - - // Yuck, the hard way - CComQIPtr classInfo = pControl; - if (!classInfo) - { - return FALSE; - } - - // Search the class type information for the default source interface - // which is the outgoing event sink. - - CComPtr classTypeInfo; - classInfo->GetClassInfo(&classTypeInfo); - if (!classTypeInfo) - { - return FALSE; - } - TYPEATTR *classAttr = NULL; - if (FAILED(classTypeInfo->GetTypeAttr(&classAttr))) - { - return FALSE; - } - INT implFlags = 0; - for (UINT i = 0; i < classAttr->cImplTypes; i++) - { - // Search for the interface with the [default, source] attr - if (SUCCEEDED(classTypeInfo->GetImplTypeFlags(i, &implFlags)) && - implFlags == (IMPLTYPEFLAG_FDEFAULT | IMPLTYPEFLAG_FSOURCE)) - { - CComPtr eventSinkTypeInfo; - HREFTYPE hRefType; - if (SUCCEEDED(classTypeInfo->GetRefTypeOfImplType(i, &hRefType)) && - SUCCEEDED(classTypeInfo->GetRefTypeInfo(hRefType, &eventSinkTypeInfo))) - { - TYPEATTR *eventSinkAttr = NULL; - if (SUCCEEDED(eventSinkTypeInfo->GetTypeAttr(&eventSinkAttr))) - { - iid = eventSinkAttr->guid; - if (typeInfo) - { - *typeInfo = eventSinkTypeInfo.p; - (*typeInfo)->AddRef(); - } - eventSinkTypeInfo->ReleaseTypeAttr(eventSinkAttr); - } - } - break; - } - } - classTypeInfo->ReleaseTypeAttr(classAttr); - - return (!::IsEqualIID(iid, GUID_NULL)); -} - -void CControlEventSink::UnsubscribeFromEvents() -{ - if (m_spEventCP) - { - // Unsubscribe and reset - m_spEventCP->Unadvise(m_dwEventCookie); - m_dwEventCookie = 0; - m_spEventCP.Release(); - } -} - -HRESULT CControlEventSink::SubscribeToEvents(IUnknown *pControl) -{ - if (!pControl) - { - return E_INVALIDARG; - } - - // Throw away any existing connections - UnsubscribeFromEvents(); - - // Grab the outgoing event sink IID which will be used to subscribe - // to events via the connection point container. - - IID iidEventSink; - CComPtr typeInfo; - if (!GetEventSinkIID(pControl, iidEventSink, &typeInfo)) - { - return E_FAIL; - } - - // Get the connection point - CComQIPtr ccp = pControl; - CComPtr cp; - if (!ccp) - { - return E_FAIL; - } - - // Custom IID - m_EventIID = iidEventSink; - DWORD dwCookie = 0; - if (!ccp || - FAILED(ccp->FindConnectionPoint(m_EventIID, &cp)) || - FAILED(cp->Advise(this, &m_dwEventCookie))) - { - return E_FAIL; - } - - m_spEventCP = cp; - m_dwEventCookie = dwCookie; - m_spEventSinkTypeInfo = typeInfo; - return S_OK; -} - -HRESULT -CControlEventSink::InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) -{ - // Override me! - return E_NOTIMPL; -} - -/////////////////////////////////////////////////////////////////////////////// -// IDispatch implementation - - -HRESULT STDMETHODCALLTYPE CControlEventSink::GetTypeInfoCount(/* [out] */ UINT __RPC_FAR *pctinfo) -{ - return E_NOTIMPL; -} - - -HRESULT STDMETHODCALLTYPE CControlEventSink::GetTypeInfo(/* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo) -{ - return E_NOTIMPL; -} - - -HRESULT STDMETHODCALLTYPE CControlEventSink::GetIDsOfNames(/* [in] */ REFIID riid, /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, /* [in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID __RPC_FAR *rgDispId) -{ - return E_NOTIMPL; -} - - -HRESULT STDMETHODCALLTYPE CControlEventSink::Invoke(/* [in] */ DISPID dispIdMember, /* [in] */ REFIID riid, /* [in] */ LCID lcid, /* [in] */ WORD wFlags, /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, /* [out] */ VARIANT __RPC_FAR *pVarResult, /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, /* [out] */ UINT __RPC_FAR *puArgErr) -{ - return InternalInvoke(dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); -} - - diff --git a/embedding/browser/activex/src/control/ControlEventSink.h b/embedding/browser/activex/src/control/ControlEventSink.h deleted file mode 100644 index 12e0e86374ed..000000000000 --- a/embedding/browser/activex/src/control/ControlEventSink.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Adam Lock - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef CONTROLEVENTSINK_H -#define CONTROLEVENTSINK_H - -// This class listens for events from the specified control - -class CControlEventSink : - public CComObjectRootEx, - public IDispatch -{ -public: - CControlEventSink(); - - // Current event connection point - CComPtr m_spEventCP; - CComPtr m_spEventSinkTypeInfo; - DWORD m_dwEventCookie; - IID m_EventIID; - -protected: - virtual ~CControlEventSink(); - - static HRESULT WINAPI SinkQI(void* pv, REFIID riid, LPVOID* ppv, DWORD dw) - { - CControlEventSink *pThis = (CControlEventSink *) pv; - if (!IsEqualIID(pThis->m_EventIID, GUID_NULL) && - IsEqualIID(pThis->m_EventIID, riid)) - { - return pThis->QueryInterface(__uuidof(IDispatch), ppv); - } - return E_NOINTERFACE; - } - -public: - -BEGIN_COM_MAP(CControlEventSink) - COM_INTERFACE_ENTRY(IDispatch) - COM_INTERFACE_ENTRY_FUNC_BLIND(0, SinkQI) -END_COM_MAP() - - virtual HRESULT SubscribeToEvents(IUnknown *pControl); - virtual void UnsubscribeFromEvents(); - virtual BOOL GetEventSinkIID(IUnknown *pControl, IID &iid, ITypeInfo **typeInfo); - virtual HRESULT InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr); - -// IDispatch - virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(/* [out] */ UINT __RPC_FAR *pctinfo); - virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(/* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo); - virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(/* [in] */ REFIID riid, /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, /* [in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID __RPC_FAR *rgDispId); - virtual /* [local] */ HRESULT STDMETHODCALLTYPE Invoke(/* [in] */ DISPID dispIdMember, /* [in] */ REFIID riid, /* [in] */ LCID lcid, /* [in] */ WORD wFlags, /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, /* [out] */ VARIANT __RPC_FAR *pVarResult, /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, /* [out] */ UINT __RPC_FAR *puArgErr); -}; - -typedef CComObject CControlEventSinkInstance; - -#endif \ No newline at end of file diff --git a/embedding/browser/activex/src/control/ControlSite.cpp b/embedding/browser/activex/src/control/ControlSite.cpp deleted file mode 100644 index 1a5cc5d8d24b..000000000000 --- a/embedding/browser/activex/src/control/ControlSite.cpp +++ /dev/null @@ -1,1412 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "StdAfx.h" - -#include - -#include "ControlSite.h" - -std::list CControlSite::m_cControlList; - -class CDefaultControlSiteSecurityPolicy : public CControlSiteSecurityPolicy -{ - // Test if the specified class id implements the specified category - BOOL ClassImplementsCategory(const CLSID & clsid, const CATID &catid, BOOL &bClassExists); -public: - // Test if the class is safe to host - virtual BOOL IsClassSafeToHost(const CLSID & clsid); - // Test if the specified class is marked safe for scripting - virtual BOOL IsClassMarkedSafeForScripting(const CLSID & clsid, BOOL &bClassExists); - // Test if the instantiated object is safe for scripting on the specified interface - virtual BOOL IsObjectSafeForScripting(IUnknown *pObject, const IID &iid); -}; - -BOOL -CDefaultControlSiteSecurityPolicy::ClassImplementsCategory(const CLSID &clsid, const CATID &catid, BOOL &bClassExists) -{ - bClassExists = FALSE; - - // Test if there is a CLSID entry. If there isn't then obviously - // the object doesn't exist and therefore doesn't implement any category. - // In this situation, the function returns REGDB_E_CLASSNOTREG. - - CRegKey key; - if (key.Open(HKEY_CLASSES_ROOT, _T("CLSID"), KEY_READ) != ERROR_SUCCESS) - { - // Must fail if we can't even open this! - return FALSE; - } - LPOLESTR szCLSID = NULL; - if (FAILED(StringFromCLSID(clsid, &szCLSID))) - { - return FALSE; - } - USES_CONVERSION; - CRegKey keyCLSID; - LONG lResult = keyCLSID.Open(key, W2CT(szCLSID), KEY_READ); - CoTaskMemFree(szCLSID); - if (lResult != ERROR_SUCCESS) - { - // Class doesn't exist - return FALSE; - } - keyCLSID.Close(); - - // CLSID exists, so try checking what categories it implements - bClassExists = TRUE; - CIPtr(ICatInformation) spCatInfo; - HRESULT hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr, NULL, CLSCTX_INPROC_SERVER, IID_ICatInformation, (LPVOID*) &spCatInfo); - if (spCatInfo == NULL) - { - // Must fail if we can't open the category manager - return FALSE; - } - - // See what categories the class implements - CIPtr(IEnumCATID) spEnumCATID; - if (FAILED(spCatInfo->EnumImplCategoriesOfClass(clsid, &spEnumCATID))) - { - // Can't enumerate classes in category so fail - return FALSE; - } - - // Search for matching categories - BOOL bFound = FALSE; - CATID catidNext = GUID_NULL; - while (spEnumCATID->Next(1, &catidNext, NULL) == S_OK) - { - if (::IsEqualCATID(catid, catidNext)) - { - return TRUE; - } - } - return FALSE; -} - -// Test if the class is safe to host -BOOL CDefaultControlSiteSecurityPolicy::IsClassSafeToHost(const CLSID & clsid) -{ - return TRUE; -} - -// Test if the specified class is marked safe for scripting -BOOL CDefaultControlSiteSecurityPolicy::IsClassMarkedSafeForScripting(const CLSID & clsid, BOOL &bClassExists) -{ - // Test the category the object belongs to - return ClassImplementsCategory(clsid, CATID_SafeForScripting, bClassExists); -} - -// Test if the instantiated object is safe for scripting on the specified interface -BOOL CDefaultControlSiteSecurityPolicy::IsObjectSafeForScripting(IUnknown *pObject, const IID &iid) -{ - if (!pObject) { - return FALSE; - } - // Ask the control if its safe for scripting - CComQIPtr spObjectSafety = pObject; - if (!spObjectSafety) - { - return FALSE; - } - - DWORD dwSupported = 0; // Supported options (mask) - DWORD dwEnabled = 0; // Enabled options - - // Assume scripting via IDispatch - if (FAILED(spObjectSafety->GetInterfaceSafetyOptions( - iid, &dwSupported, &dwEnabled))) - { - // Interface is not safe or failure. - return FALSE; - } - - // Test if safe for scripting - if (!(dwEnabled & dwSupported) & INTERFACESAFE_FOR_UNTRUSTED_CALLER) - { - return FALSE; - } - - return TRUE; -} - -/////////////////////////////////////////////////////////////////////////////// - -// Constructor -CControlSite::CControlSite() -{ - NG_TRACE_METHOD(CControlSite::CControlSite); - - m_hWndParent = NULL; - m_CLSID = CLSID_NULL; - m_bSetClientSiteFirst = FALSE; - m_bVisibleAtRuntime = TRUE; - memset(&m_rcObjectPos, 0, sizeof(m_rcObjectPos)); - - m_bInPlaceActive = FALSE; - m_bUIActive = FALSE; - m_bInPlaceLocked = FALSE; - m_bWindowless = FALSE; - m_bSupportWindowlessActivation = TRUE; - m_bSafeForScriptingObjectsOnly = FALSE; - m_pDefaultSecurityPolicy = new CDefaultControlSiteSecurityPolicy; - m_pSecurityPolicy = m_pDefaultSecurityPolicy; - - // Initialise ambient properties - m_nAmbientLocale = 0; - m_clrAmbientForeColor = ::GetSysColor(COLOR_WINDOWTEXT); - m_clrAmbientBackColor = ::GetSysColor(COLOR_WINDOW); - m_bAmbientUserMode = true; - m_bAmbientShowHatching = true; - m_bAmbientShowGrabHandles = true; - m_bAmbientAppearance = true; // 3d - - // Windowless variables - m_hDCBuffer = NULL; - m_hRgnBuffer = NULL; - m_hBMBufferOld = NULL; - m_hBMBuffer = NULL; - - // Add the control to the list - m_cControlList.push_back(this); -} - - -// Destructor -CControlSite::~CControlSite() -{ - NG_TRACE_METHOD(CControlSite::~CControlSite); - Detach(); - m_cControlList.remove(this); - - if (m_pDefaultSecurityPolicy) - delete m_pDefaultSecurityPolicy; -} - -// Create the specified control, optionally providing properties to initialise -// it with and a name. -HRESULT CControlSite::Create(REFCLSID clsid, PropertyList &pl, - LPCWSTR szCodebase, IBindCtx *pBindContext) -{ - NG_TRACE_METHOD(CControlSite::Create); - - m_CLSID = clsid; - m_ParameterList = pl; - - // See if security policy will allow the control to be hosted - if (m_pSecurityPolicy && !m_pSecurityPolicy->IsClassSafeToHost(clsid)) - { - return E_FAIL; - } - - // See if object is script safe - BOOL checkForObjectSafety = FALSE; - if (m_pSecurityPolicy && m_bSafeForScriptingObjectsOnly) - { - BOOL bClassExists = FALSE; - BOOL bIsSafe = m_pSecurityPolicy->IsClassMarkedSafeForScripting(clsid, bClassExists); - if (!bClassExists && szCodebase) - { - // Class doesn't exist, so allow code below to fetch it - } - else if (!bIsSafe) - { - // The class is not flagged as safe for scripting, so - // we'll have to create it to ask it if its safe. - checkForObjectSafety = TRUE; - } - } - - // Create the object - CComPtr spObject; - HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown, (void **) &spObject); - if (SUCCEEDED(hr) && checkForObjectSafety) - { - // Assume scripting via IDispatch - if (!m_pSecurityPolicy->IsObjectSafeForScripting(spObject, __uuidof(IDispatch))) - { - return E_FAIL; - } - // Drop through, success! - } - - // Do we need to download the control? - if (FAILED(hr) && szCodebase) - { - wchar_t *szURL = NULL; - - // Test if the code base ends in #version=a,b,c,d - DWORD dwFileVersionMS = 0xffffffff; - DWORD dwFileVersionLS = 0xffffffff; - wchar_t *szHash = wcsrchr(szCodebase, wchar_t('#')); - if (szHash) - { - if (wcsnicmp(szHash, L"#version=", 9) == 0) - { - int a, b, c, d; - if (swscanf(szHash + 9, L"%d,%d,%d,%d", &a, &b, &c, &d) == 4) - { - dwFileVersionMS = MAKELONG(b,a); - dwFileVersionLS = MAKELONG(d,c); - } - } - szURL = _wcsdup(szCodebase); - // Terminate at the hash mark - if (szURL) - szURL[szHash - szCodebase] = wchar_t('\0'); - } - else - { - szURL = _wcsdup(szCodebase); - } - if (!szURL) - return E_OUTOFMEMORY; - - CComPtr spBindContext; - CComPtr spBindStatusCallback; - CComPtr spOldBSC; - - // Create our own bind context or use the one provided? - BOOL useInternalBSC = FALSE; - if (!pBindContext) - { - useInternalBSC = TRUE; - hr = CreateBindCtx(0, &spBindContext); - if (FAILED(hr)) - { - free(szURL); - return hr; - } - spBindStatusCallback = dynamic_cast(this); - hr = RegisterBindStatusCallback(spBindContext, spBindStatusCallback, &spOldBSC, 0); - if (FAILED(hr)) - { - free(szURL); - return hr; - } - } - else - { - spBindContext = pBindContext; - } - - hr = CoGetClassObjectFromURL(clsid, szURL, dwFileVersionMS, dwFileVersionLS, - NULL, spBindContext, CLSCTX_ALL, NULL, IID_IUnknown, (void **) &m_spObject); - - free(szURL); - - // Handle the internal binding synchronously so the object exists - // or an error code is available when the method returns. - if (useInternalBSC) - { - if (MK_S_ASYNCHRONOUS == hr) - { - m_bBindingInProgress = TRUE; - m_hrBindResult = E_FAIL; - - // Spin around waiting for binding to complete - HANDLE hFakeEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL); - while (m_bBindingInProgress) - { - MSG msg; - // Process pending messages - while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) - { - if (!::GetMessage(&msg, NULL, 0, 0)) - { - m_bBindingInProgress = FALSE; - break; - } - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); - } - if (!m_bBindingInProgress) - break; - // Sleep for a bit or the next msg to appear - ::MsgWaitForMultipleObjects(1, &hFakeEvent, FALSE, 500, QS_ALLEVENTS); - } - ::CloseHandle(hFakeEvent); - - // Set the result - hr = m_hrBindResult; - } - - // Destroy the bind status callback & context - if (spBindStatusCallback) - { - RevokeBindStatusCallback(spBindContext, spBindStatusCallback); - spBindContext.Release(); - } - } - } - - if (spObject) - m_spObject = spObject; - - return hr; -} - - -// Attach the created control to a window and activate it -HRESULT CControlSite::Attach(HWND hwndParent, const RECT &rcPos, IUnknown *pInitStream) -{ - NG_TRACE_METHOD(CControlSite::Attach); - - if (hwndParent == NULL) - { - NG_ASSERT(0); - return E_INVALIDARG; - } - - m_hWndParent = hwndParent; - m_rcObjectPos = rcPos; - - // Object must have been created - if (m_spObject == NULL) - { - return E_UNEXPECTED; - } - - m_spIViewObject = m_spObject; - m_spIOleObject = m_spObject; - - if (m_spIOleObject == NULL) - { - return E_FAIL; - } - - DWORD dwMiscStatus; - m_spIOleObject->GetMiscStatus(DVASPECT_CONTENT, &dwMiscStatus); - - if (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST) - { - m_bSetClientSiteFirst = TRUE; - } - if (dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME) - { - m_bVisibleAtRuntime = FALSE; - } - - // Some objects like to have the client site as the first thing - // to be initialised (for ambient properties and so forth) - if (m_bSetClientSiteFirst) - { - m_spIOleObject->SetClientSite(this); - } - - // If there is a parameter list for the object and no init stream then - // create one here. - CPropertyBagInstance *pPropertyBag = NULL; - if (pInitStream == NULL && m_ParameterList.GetSize() > 0) - { - CPropertyBagInstance::CreateInstance(&pPropertyBag); - pPropertyBag->AddRef(); - for (unsigned long i = 0; i < m_ParameterList.GetSize(); i++) - { - pPropertyBag->Write(m_ParameterList.GetNameOf(i), - const_cast(m_ParameterList.GetValueOf(i))); - } - pInitStream = (IPersistPropertyBag *) pPropertyBag; - } - - // Initialise the control from store if one is provided - if (pInitStream) - { - CComQIPtr spPropertyBag = pInitStream; - CComQIPtr spStream = pInitStream; - CComQIPtr spIPersistStream = m_spIOleObject; - CComQIPtr spIPersistPropertyBag = m_spIOleObject; - - if (spIPersistPropertyBag && spPropertyBag) - { - spIPersistPropertyBag->Load(spPropertyBag, NULL); - } - else if (spIPersistStream && spStream) - { - spIPersistStream->Load(spStream); - } - } - else - { - // Initialise the object if possible - CComQIPtr spIPersistStreamInit = m_spIOleObject; - if (spIPersistStreamInit) - { - spIPersistStreamInit->InitNew(); - } - } - - m_spIOleInPlaceObject = m_spObject; - m_spIOleInPlaceObjectWindowless = m_spObject; - - m_spIOleInPlaceObject->SetObjectRects(&m_rcObjectPos, &m_rcObjectPos); - - // In-place activate the object - if (m_bVisibleAtRuntime) - { - DoVerb(OLEIVERB_INPLACEACTIVATE); - } - - // For those objects which haven't had their client site set yet, - // it's done here. - if (!m_bSetClientSiteFirst) - { - m_spIOleObject->SetClientSite(this); - } - - return S_OK; -} - - -// Unhook the control from the window and throw it all away -HRESULT CControlSite::Detach() -{ - NG_TRACE_METHOD(CControlSite::Detach); - - if (m_spIOleInPlaceObjectWindowless) - { - m_spIOleInPlaceObjectWindowless.Release(); - } - - if (m_spIOleInPlaceObject) - { - m_spIOleInPlaceObject->InPlaceDeactivate(); - m_spIOleInPlaceObject.Release(); - } - - if (m_spIOleObject) - { - m_spIOleObject->Close(OLECLOSE_NOSAVE); - m_spIOleObject->SetClientSite(NULL); - m_spIOleObject.Release(); - } - - m_spIViewObject.Release(); - m_spObject.Release(); - - return S_OK; -} - - -// Return the IUnknown of the contained control -HRESULT CControlSite::GetControlUnknown(IUnknown **ppObject) -{ - *ppObject = NULL; - if (m_spObject) - { - m_spObject->QueryInterface(IID_IUnknown, (void **) ppObject); - } - return S_OK; -} - - -// Subscribe to an event sink on the control -HRESULT CControlSite::Advise(IUnknown *pIUnkSink, const IID &iid, DWORD *pdwCookie) -{ - if (m_spObject == NULL) - { - return E_UNEXPECTED; - } - - if (pIUnkSink == NULL || pdwCookie == NULL) - { - return E_INVALIDARG; - } - - return AtlAdvise(m_spObject, pIUnkSink, iid, pdwCookie); -} - - -// Unsubscribe event sink from the control -HRESULT CControlSite::Unadvise(const IID &iid, DWORD dwCookie) -{ - if (m_spObject == NULL) - { - return E_UNEXPECTED; - } - - return AtlUnadvise(m_spObject, iid, dwCookie); -} - - -// Draw the control -HRESULT CControlSite::Draw(HDC hdc) -{ - NG_TRACE_METHOD(CControlSite::Draw); - - // Draw only when control is windowless or deactivated - if (m_spIViewObject) - { - if (m_bWindowless || !m_bInPlaceActive) - { - RECTL *prcBounds = (m_bWindowless) ? NULL : (RECTL *) &m_rcObjectPos; - m_spIViewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL, NULL, hdc, prcBounds, NULL, NULL, 0); - } - } - else - { - // Draw something to indicate no control is there - HBRUSH hbr = CreateSolidBrush(RGB(200,200,200)); - FillRect(hdc, &m_rcObjectPos, hbr); - DeleteObject(hbr); - } - - return S_OK; -} - - -// Execute the specified verb -HRESULT CControlSite::DoVerb(LONG nVerb, LPMSG lpMsg) -{ - NG_TRACE_METHOD(CControlSite::DoVerb); - - if (m_spIOleObject == NULL) - { - return E_FAIL; - } - - return m_spIOleObject->DoVerb(nVerb, lpMsg, this, 0, m_hWndParent, &m_rcObjectPos); -} - - -// Set the position on the control -HRESULT CControlSite::SetPosition(const RECT &rcPos) -{ - NG_TRACE_METHOD(CControlSite::SetPosition); - m_rcObjectPos = rcPos; - if (m_spIOleInPlaceObject) - { - m_spIOleInPlaceObject->SetObjectRects(&m_rcObjectPos, &m_rcObjectPos); - } - return S_OK; -} - - -void CControlSite::FireAmbientPropertyChange(DISPID id) -{ - if (m_spObject) - { - CIPtr(IOleControl) spControl = m_spObject; - if (spControl) - { - spControl->OnAmbientPropertyChange(id); - } - } -} - - -void CControlSite::SetAmbientUserMode(BOOL bUserMode) -{ - bool bNewMode = bUserMode ? true : false; - if (m_bAmbientUserMode != bNewMode) - { - m_bAmbientUserMode = bNewMode; - FireAmbientPropertyChange(DISPID_AMBIENT_USERMODE); - } -} - -/////////////////////////////////////////////////////////////////////////////// -// CControlSiteSecurityPolicy implementation - -// Test if the class is safe to host -BOOL CControlSite::IsClassSafeToHost(const CLSID & clsid) -{ - if (m_pSecurityPolicy) - return m_pSecurityPolicy->IsClassSafeToHost(clsid); - return TRUE; -} - -// Test if the specified class is marked safe for scripting -BOOL CControlSite::IsClassMarkedSafeForScripting(const CLSID & clsid, BOOL &bClassExists) -{ - if (m_pSecurityPolicy) - return m_pSecurityPolicy->IsClassMarkedSafeForScripting(clsid, bClassExists); - return TRUE; -} - -// Test if the instantiated object is safe for scripting on the specified interface -BOOL CControlSite::IsObjectSafeForScripting(IUnknown *pObject, const IID &iid) -{ - if (m_pSecurityPolicy) - return m_pSecurityPolicy->IsObjectSafeForScripting(pObject, iid); - return TRUE; -} - -BOOL CControlSite::IsObjectSafeForScripting(const IID &iid) -{ - return IsObjectSafeForScripting(m_spObject, iid); -} - -/////////////////////////////////////////////////////////////////////////////// -// IServiceProvider implementation - -HRESULT STDMETHODCALLTYPE CControlSite::QueryService(REFGUID guidService, REFIID riid, void** ppv) -{ - if (m_spServiceProvider) - return m_spServiceProvider->QueryService(guidService, riid, ppv); - return E_NOINTERFACE; -} - - -/////////////////////////////////////////////////////////////////////////////// -// IDispatch implementation - - -HRESULT STDMETHODCALLTYPE CControlSite::GetTypeInfoCount(/* [out] */ UINT __RPC_FAR *pctinfo) -{ - return E_NOTIMPL; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::GetTypeInfo(/* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo) -{ - return E_NOTIMPL; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::GetIDsOfNames(/* [in] */ REFIID riid, /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, /* [in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID __RPC_FAR *rgDispId) -{ - return E_NOTIMPL; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::Invoke(/* [in] */ DISPID dispIdMember, /* [in] */ REFIID riid, /* [in] */ LCID lcid, /* [in] */ WORD wFlags, /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, /* [out] */ VARIANT __RPC_FAR *pVarResult, /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, /* [out] */ UINT __RPC_FAR *puArgErr) -{ - if (wFlags & DISPATCH_PROPERTYGET) - { - CComVariant vResult; - - switch (dispIdMember) - { - case DISPID_AMBIENT_APPEARANCE: - vResult = CComVariant(m_bAmbientAppearance); - break; - - case DISPID_AMBIENT_FORECOLOR: - vResult = CComVariant((long) m_clrAmbientForeColor); - break; - - case DISPID_AMBIENT_BACKCOLOR: - vResult = CComVariant((long) m_clrAmbientBackColor); - break; - - case DISPID_AMBIENT_LOCALEID: - vResult = CComVariant((long) m_nAmbientLocale); - break; - - case DISPID_AMBIENT_USERMODE: - vResult = CComVariant(m_bAmbientUserMode); - break; - - case DISPID_AMBIENT_SHOWGRABHANDLES: - vResult = CComVariant(m_bAmbientShowGrabHandles); - break; - - case DISPID_AMBIENT_SHOWHATCHING: - vResult = CComVariant(m_bAmbientShowHatching); - break; - - default: - return DISP_E_MEMBERNOTFOUND; - } - - VariantCopy(pVarResult, &vResult); - return S_OK; - } - - return E_FAIL; -} - - -/////////////////////////////////////////////////////////////////////////////// -// IAdviseSink implementation - - -void STDMETHODCALLTYPE CControlSite::OnDataChange(/* [unique][in] */ FORMATETC __RPC_FAR *pFormatetc, /* [unique][in] */ STGMEDIUM __RPC_FAR *pStgmed) -{ -} - - -void STDMETHODCALLTYPE CControlSite::OnViewChange(/* [in] */ DWORD dwAspect, /* [in] */ LONG lindex) -{ - // Redraw the control - InvalidateRect(NULL, FALSE); -} - - -void STDMETHODCALLTYPE CControlSite::OnRename(/* [in] */ IMoniker __RPC_FAR *pmk) -{ -} - - -void STDMETHODCALLTYPE CControlSite::OnSave(void) -{ -} - - -void STDMETHODCALLTYPE CControlSite::OnClose(void) -{ -} - - -/////////////////////////////////////////////////////////////////////////////// -// IAdviseSink2 implementation - - -void STDMETHODCALLTYPE CControlSite::OnLinkSrcChange(/* [unique][in] */ IMoniker __RPC_FAR *pmk) -{ -} - - -/////////////////////////////////////////////////////////////////////////////// -// IAdviseSinkEx implementation - - -void STDMETHODCALLTYPE CControlSite::OnViewStatusChange(/* [in] */ DWORD dwViewStatus) -{ -} - - -/////////////////////////////////////////////////////////////////////////////// -// IOleWindow implementation - -HRESULT STDMETHODCALLTYPE CControlSite::GetWindow(/* [out] */ HWND __RPC_FAR *phwnd) -{ - *phwnd = m_hWndParent; - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::ContextSensitiveHelp(/* [in] */ BOOL fEnterMode) -{ - return S_OK; -} - - -/////////////////////////////////////////////////////////////////////////////// -// IOleClientSite implementation - - -HRESULT STDMETHODCALLTYPE CControlSite::SaveObject(void) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::GetMoniker(/* [in] */ DWORD dwAssign, /* [in] */ DWORD dwWhichMoniker, /* [out] */ IMoniker __RPC_FAR *__RPC_FAR *ppmk) -{ - return E_NOTIMPL; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::GetContainer(/* [out] */ IOleContainer __RPC_FAR *__RPC_FAR *ppContainer) -{ - if (!ppContainer) return E_INVALIDARG; - *ppContainer = m_spContainer; - if (*ppContainer) - { - (*ppContainer)->AddRef(); - } - return (*ppContainer) ? S_OK : E_NOINTERFACE; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::ShowObject(void) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::OnShowWindow(/* [in] */ BOOL fShow) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::RequestNewObjectLayout(void) -{ - return E_NOTIMPL; -} - - -/////////////////////////////////////////////////////////////////////////////// -// IOleInPlaceSite implementation - - -HRESULT STDMETHODCALLTYPE CControlSite::CanInPlaceActivate(void) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::OnInPlaceActivate(void) -{ - m_bInPlaceActive = TRUE; - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::OnUIActivate(void) -{ - m_bUIActive = TRUE; - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::GetWindowContext(/* [out] */ IOleInPlaceFrame __RPC_FAR *__RPC_FAR *ppFrame, /* [out] */ IOleInPlaceUIWindow __RPC_FAR *__RPC_FAR *ppDoc, /* [out] */ LPRECT lprcPosRect, /* [out] */ LPRECT lprcClipRect, /* [out][in] */ LPOLEINPLACEFRAMEINFO lpFrameInfo) -{ - *lprcPosRect = m_rcObjectPos; - *lprcClipRect = m_rcObjectPos; - - CControlSiteIPFrameInstance *pIPFrame = NULL; - CControlSiteIPFrameInstance::CreateInstance(&pIPFrame); - pIPFrame->AddRef(); - - *ppFrame = (IOleInPlaceFrame *) pIPFrame; - *ppDoc = NULL; - - lpFrameInfo->fMDIApp = FALSE; - lpFrameInfo->hwndFrame = NULL; - lpFrameInfo->haccel = NULL; - lpFrameInfo->cAccelEntries = 0; - - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::Scroll(/* [in] */ SIZE scrollExtant) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::OnUIDeactivate(/* [in] */ BOOL fUndoable) -{ - m_bUIActive = FALSE; - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::OnInPlaceDeactivate(void) -{ - m_bInPlaceActive = FALSE; - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::DiscardUndoState(void) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::DeactivateAndUndo(void) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::OnPosRectChange(/* [in] */ LPCRECT lprcPosRect) -{ - if (lprcPosRect == NULL) - { - return E_INVALIDARG; - } - SetPosition(m_rcObjectPos); - return S_OK; -} - - -/////////////////////////////////////////////////////////////////////////////// -// IOleInPlaceSiteEx implementation - - -HRESULT STDMETHODCALLTYPE CControlSite::OnInPlaceActivateEx(/* [out] */ BOOL __RPC_FAR *pfNoRedraw, /* [in] */ DWORD dwFlags) -{ - m_bInPlaceActive = TRUE; - - if (pfNoRedraw) - { - *pfNoRedraw = FALSE; - } - if (dwFlags & ACTIVATE_WINDOWLESS) - { - if (!m_bSupportWindowlessActivation) - { - return E_INVALIDARG; - } - m_bWindowless = TRUE; - } - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::OnInPlaceDeactivateEx(/* [in] */ BOOL fNoRedraw) -{ - m_bInPlaceActive = FALSE; - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::RequestUIActivate(void) -{ - return S_FALSE; -} - - -/////////////////////////////////////////////////////////////////////////////// -// IOleInPlaceSiteWindowless implementation - - -HRESULT STDMETHODCALLTYPE CControlSite::CanWindowlessActivate(void) -{ - // Allow windowless activation? - return (m_bSupportWindowlessActivation) ? S_OK : S_FALSE; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::GetCapture(void) -{ - // TODO capture the mouse for the object - return S_FALSE; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::SetCapture(/* [in] */ BOOL fCapture) -{ - // TODO capture the mouse for the object - return S_FALSE; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::GetFocus(void) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::SetFocus(/* [in] */ BOOL fFocus) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::GetDC(/* [in] */ LPCRECT pRect, /* [in] */ DWORD grfFlags, /* [out] */ HDC __RPC_FAR *phDC) -{ - if (phDC == NULL) - { - return E_INVALIDARG; - } - - // Can't do nested painting - if (m_hDCBuffer != NULL) - { - return E_UNEXPECTED; - } - - m_rcBuffer = m_rcObjectPos; - if (pRect != NULL) - { - m_rcBuffer = *pRect; - } - - m_hBMBuffer = NULL; - m_dwBufferFlags = grfFlags; - - // See if the control wants a DC that is onscreen or offscreen - if (m_dwBufferFlags & OLEDC_OFFSCREEN) - { - m_hDCBuffer = CreateCompatibleDC(NULL); - if (m_hDCBuffer == NULL) - { - // Error - return E_OUTOFMEMORY; - } - - long cx = m_rcBuffer.right - m_rcBuffer.left; - long cy = m_rcBuffer.bottom - m_rcBuffer.top; - - m_hBMBuffer = CreateCompatibleBitmap(m_hDCBuffer, cx, cy); - m_hBMBufferOld = (HBITMAP) SelectObject(m_hDCBuffer, m_hBMBuffer); - SetViewportOrgEx(m_hDCBuffer, m_rcBuffer.left, m_rcBuffer.top, NULL); - - // TODO When OLEDC_PAINTBKGND we must draw every site behind this one - } - else - { - // TODO When OLEDC_PAINTBKGND we must draw every site behind this one - - // Get the window DC - m_hDCBuffer = GetWindowDC(m_hWndParent); - if (m_hDCBuffer == NULL) - { - // Error - return E_OUTOFMEMORY; - } - - // Clip the control so it can't trash anywhere it isn't allowed to draw - if (!(m_dwBufferFlags & OLEDC_NODRAW)) - { - m_hRgnBuffer = CreateRectRgnIndirect(&m_rcBuffer); - - // TODO Clip out opaque areas of sites behind this one - - SelectClipRgn(m_hDCBuffer, m_hRgnBuffer); - } - } - - *phDC = m_hDCBuffer; - - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::ReleaseDC(/* [in] */ HDC hDC) -{ - // Release the DC - if (hDC == NULL || hDC != m_hDCBuffer) - { - return E_INVALIDARG; - } - - // Test if the DC was offscreen or onscreen - if ((m_dwBufferFlags & OLEDC_OFFSCREEN) && - !(m_dwBufferFlags & OLEDC_NODRAW)) - { - // BitBlt the buffer into the control's object - SetViewportOrgEx(m_hDCBuffer, 0, 0, NULL); - HDC hdc = GetWindowDC(m_hWndParent); - - long cx = m_rcBuffer.right - m_rcBuffer.left; - long cy = m_rcBuffer.bottom - m_rcBuffer.top; - - BitBlt(hdc, m_rcBuffer.left, m_rcBuffer.top, cx, cy, m_hDCBuffer, 0, 0, SRCCOPY); - - ::ReleaseDC(m_hWndParent, hdc); - } - else - { - // TODO If OLEDC_PAINTBKGND is set draw the DVASPECT_CONTENT of every object above this one - } - - // Clean up settings ready for next drawing - if (m_hRgnBuffer) - { - SelectClipRgn(m_hDCBuffer, NULL); - DeleteObject(m_hRgnBuffer); - m_hRgnBuffer = NULL; - } - - SelectObject(m_hDCBuffer, m_hBMBufferOld); - if (m_hBMBuffer) - { - DeleteObject(m_hBMBuffer); - m_hBMBuffer = NULL; - } - - // Delete the DC - if (m_dwBufferFlags & OLEDC_OFFSCREEN) - { - ::DeleteDC(m_hDCBuffer); - } - else - { - ::ReleaseDC(m_hWndParent, m_hDCBuffer); - } - m_hDCBuffer = NULL; - - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::InvalidateRect(/* [in] */ LPCRECT pRect, /* [in] */ BOOL fErase) -{ - // Clip the rectangle against the object's size and invalidate it - RECT rcI = { 0, 0, 0, 0 }; - if (pRect == NULL) - { - rcI = m_rcObjectPos; - } - else - { - IntersectRect(&rcI, &m_rcObjectPos, pRect); - } - ::InvalidateRect(m_hWndParent, &rcI, fErase); - - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CControlSite::InvalidateRgn(/* [in] */ HRGN hRGN, /* [in] */ BOOL fErase) -{ - if (hRGN == NULL) - { - ::InvalidateRect(m_hWndParent, &m_rcObjectPos, fErase); - } - else - { - // Clip the region with the object's bounding area - HRGN hrgnClip = CreateRectRgnIndirect(&m_rcObjectPos); - if (CombineRgn(hrgnClip, hrgnClip, hRGN, RGN_AND) != ERROR) - { - ::InvalidateRgn(m_hWndParent, hrgnClip, fErase); - } - DeleteObject(hrgnClip); - } - - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CControlSite::ScrollRect(/* [in] */ INT dx, /* [in] */ INT dy, /* [in] */ LPCRECT pRectScroll, /* [in] */ LPCRECT pRectClip) -{ - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CControlSite::AdjustRect(/* [out][in] */ LPRECT prc) -{ - if (prc == NULL) - { - return E_INVALIDARG; - } - - // Clip the rectangle against the object position - RECT rcI = { 0, 0, 0, 0 }; - IntersectRect(&rcI, &m_rcObjectPos, prc); - *prc = rcI; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CControlSite::OnDefWindowMessage(/* [in] */ UINT msg, /* [in] */ WPARAM wParam, /* [in] */ LPARAM lParam, /* [out] */ LRESULT __RPC_FAR *plResult) -{ - if (plResult == NULL) - { - return E_INVALIDARG; - } - - // Pass the message to the windowless control - if (m_bWindowless && m_spIOleInPlaceObjectWindowless) - { - return m_spIOleInPlaceObjectWindowless->OnWindowMessage(msg, wParam, lParam, plResult); - } - - return S_FALSE; -} - - -/////////////////////////////////////////////////////////////////////////////// -// IOleControlSite implementation - - -HRESULT STDMETHODCALLTYPE CControlSite::OnControlInfoChanged(void) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::LockInPlaceActive(/* [in] */ BOOL fLock) -{ - m_bInPlaceLocked = fLock; - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::GetExtendedControl(/* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDisp) -{ - return E_NOTIMPL; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::TransformCoords(/* [out][in] */ POINTL __RPC_FAR *pPtlHimetric, /* [out][in] */ POINTF __RPC_FAR *pPtfContainer, /* [in] */ DWORD dwFlags) -{ - HRESULT hr = S_OK; - - if (pPtlHimetric == NULL) - { - return E_INVALIDARG; - } - if (pPtfContainer == NULL) - { - return E_INVALIDARG; - } - - HDC hdc = ::GetDC(m_hWndParent); - ::SetMapMode(hdc, MM_HIMETRIC); - POINT rgptConvert[2]; - rgptConvert[0].x = 0; - rgptConvert[0].y = 0; - - if (dwFlags & XFORMCOORDS_HIMETRICTOCONTAINER) - { - rgptConvert[1].x = pPtlHimetric->x; - rgptConvert[1].y = pPtlHimetric->y; - ::LPtoDP(hdc, rgptConvert, 2); - if (dwFlags & XFORMCOORDS_SIZE) - { - pPtfContainer->x = (float)(rgptConvert[1].x - rgptConvert[0].x); - pPtfContainer->y = (float)(rgptConvert[0].y - rgptConvert[1].y); - } - else if (dwFlags & XFORMCOORDS_POSITION) - { - pPtfContainer->x = (float)rgptConvert[1].x; - pPtfContainer->y = (float)rgptConvert[1].y; - } - else - { - hr = E_INVALIDARG; - } - } - else if (dwFlags & XFORMCOORDS_CONTAINERTOHIMETRIC) - { - rgptConvert[1].x = (int)(pPtfContainer->x); - rgptConvert[1].y = (int)(pPtfContainer->y); - ::DPtoLP(hdc, rgptConvert, 2); - if (dwFlags & XFORMCOORDS_SIZE) - { - pPtlHimetric->x = rgptConvert[1].x - rgptConvert[0].x; - pPtlHimetric->y = rgptConvert[0].y - rgptConvert[1].y; - } - else if (dwFlags & XFORMCOORDS_POSITION) - { - pPtlHimetric->x = rgptConvert[1].x; - pPtlHimetric->y = rgptConvert[1].y; - } - else - { - hr = E_INVALIDARG; - } - } - else - { - hr = E_INVALIDARG; - } - - ::ReleaseDC(m_hWndParent, hdc); - - return hr; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::TranslateAccelerator(/* [in] */ MSG __RPC_FAR *pMsg, /* [in] */ DWORD grfModifiers) -{ - return E_NOTIMPL; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::OnFocus(/* [in] */ BOOL fGotFocus) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSite::ShowPropertyFrame(void) -{ - return E_NOTIMPL; -} - -/////////////////////////////////////////////////////////////////////////////// -// IBindStatusCallback implementation - -HRESULT STDMETHODCALLTYPE CControlSite::OnStartBinding(DWORD dwReserved, - IBinding __RPC_FAR *pib) -{ - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CControlSite::GetPriority(LONG __RPC_FAR *pnPriority) -{ - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CControlSite::OnLowResource(DWORD reserved) -{ - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CControlSite::OnProgress(ULONG ulProgress, - ULONG ulProgressMax, - ULONG ulStatusCode, - LPCWSTR szStatusText) -{ - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CControlSite::OnStopBinding(HRESULT hresult, LPCWSTR szError) -{ - m_bBindingInProgress = FALSE; - m_hrBindResult = hresult; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CControlSite::GetBindInfo(DWORD __RPC_FAR *pgrfBINDF, - BINDINFO __RPC_FAR *pbindInfo) -{ - *pgrfBINDF = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | - BINDF_GETNEWESTVERSION | BINDF_NOWRITECACHE; - pbindInfo->cbSize = sizeof(BINDINFO); - pbindInfo->szExtraInfo = NULL; - memset(&pbindInfo->stgmedData, 0, sizeof(STGMEDIUM)); - pbindInfo->grfBindInfoF = 0; - pbindInfo->dwBindVerb = 0; - pbindInfo->szCustomVerb = NULL; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CControlSite::OnDataAvailable(DWORD grfBSCF, - DWORD dwSize, - FORMATETC __RPC_FAR *pformatetc, - STGMEDIUM __RPC_FAR *pstgmed) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CControlSite::OnObjectAvailable(REFIID riid, - IUnknown __RPC_FAR *punk) -{ - return S_OK; -} - -// IWindowForBindingUI -HRESULT STDMETHODCALLTYPE CControlSite::GetWindow( - /* [in] */ REFGUID rguidReason, - /* [out] */ HWND *phwnd) -{ - *phwnd = NULL; - return S_OK; -} - - diff --git a/embedding/browser/activex/src/control/ControlSite.h b/embedding/browser/activex/src/control/ControlSite.h deleted file mode 100644 index dc8a38806241..000000000000 --- a/embedding/browser/activex/src/control/ControlSite.h +++ /dev/null @@ -1,395 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Adam Lock - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef CONTROLSITE_H -#define CONTROLSITE_H - -#include "IOleCommandTargetImpl.h" - -// If you created a class derived from CControlSite, use the following macro -// in the interface map of the derived class to include all the necessary -// interfaces. -#define CCONTROLSITE_INTERFACES() \ - COM_INTERFACE_ENTRY(IOleWindow) \ - COM_INTERFACE_ENTRY(IOleClientSite) \ - COM_INTERFACE_ENTRY(IOleInPlaceSite) \ - COM_INTERFACE_ENTRY_IID(IID_IOleInPlaceSite, IOleInPlaceSiteWindowless) \ - COM_INTERFACE_ENTRY_IID(IID_IOleInPlaceSiteEx, IOleInPlaceSiteWindowless) \ - COM_INTERFACE_ENTRY(IOleControlSite) \ - COM_INTERFACE_ENTRY(IDispatch) \ - COM_INTERFACE_ENTRY_IID(IID_IAdviseSink, IAdviseSinkEx) \ - COM_INTERFACE_ENTRY_IID(IID_IAdviseSink2, IAdviseSinkEx) \ - COM_INTERFACE_ENTRY_IID(IID_IAdviseSinkEx, IAdviseSinkEx) \ - COM_INTERFACE_ENTRY(IOleCommandTarget) \ - COM_INTERFACE_ENTRY(IServiceProvider) \ - COM_INTERFACE_ENTRY(IBindStatusCallback) \ - COM_INTERFACE_ENTRY(IWindowForBindingUI) - -// Temoporarily removed by bug 200680. Stops controls misbehaving and calling -// windowless methods when they shouldn't. -// COM_INTERFACE_ENTRY_IID(IID_IOleInPlaceSiteWindowless, IOleInPlaceSiteWindowless) \ - - -// Class that defines the control's security policy with regards to -// what controls it hosts etc. - -class CControlSiteSecurityPolicy -{ -public: - // Test if the class is safe to host - virtual BOOL IsClassSafeToHost(const CLSID & clsid) = 0; - // Test if the specified class is marked safe for scripting - virtual BOOL IsClassMarkedSafeForScripting(const CLSID & clsid, BOOL &bClassExists) = 0; - // Test if the instantiated object is safe for scripting on the specified interface - virtual BOOL IsObjectSafeForScripting(IUnknown *pObject, const IID &iid) = 0; -}; - -// -// Class for hosting an ActiveX control -// -// This class supports both windowed and windowless classes. The normal -// steps to hosting a control are this: -// -// CControlSiteInstance *pSite = NULL; -// CControlSiteInstance::CreateInstance(&pSite); -// pSite->AddRef(); -// pSite->Create(clsidControlToCreate); -// pSite->Attach(hwndParentWindow, rcPosition); -// -// Where propertyList is a named list of values to initialise the new object -// with, hwndParentWindow is the window in which the control is being created, -// and rcPosition is the position in window coordinates where the control will -// be rendered. -// -// Destruction is this: -// -// pSite->Detach(); -// pSite->Release(); -// pSite = NULL; - -class CControlSite : public CComObjectRootEx, - public CControlSiteSecurityPolicy, - public IOleClientSite, - public IOleInPlaceSiteWindowless, - public IOleControlSite, - public IAdviseSinkEx, - public IDispatch, - public IServiceProvider, - public IOleCommandTargetImpl, - public IBindStatusCallback, - public IWindowForBindingUI -{ -public: -// Site management values - // Handle to parent window - HWND m_hWndParent; - // Position of the site and the contained object - RECT m_rcObjectPos; - // Flag indicating if client site should be set early or late - unsigned m_bSetClientSiteFirst:1; - // Flag indicating whether control is visible or not - unsigned m_bVisibleAtRuntime:1; - // Flag indicating if control is in-place active - unsigned m_bInPlaceActive:1; - // Flag indicating if control is UI active - unsigned m_bUIActive:1; - // Flag indicating if control is in-place locked and cannot be deactivated - unsigned m_bInPlaceLocked:1; - // Flag indicating if the site allows windowless controls - unsigned m_bSupportWindowlessActivation:1; - // Flag indicating if control is windowless (after being created) - unsigned m_bWindowless:1; - // Flag indicating if only safely scriptable controls are allowed - unsigned m_bSafeForScriptingObjectsOnly:1; - // Pointer to an externally registered service provider - CComPtr m_spServiceProvider; - // Pointer to the OLE container - CComPtr m_spContainer; - -protected: -// Pointers to object interfaces - // Raw pointer to the object - CComPtr m_spObject; - // Pointer to objects IViewObject interface - CComQIPtr m_spIViewObject; - // Pointer to object's IOleObject interface - CComQIPtr m_spIOleObject; - // Pointer to object's IOleInPlaceObject interface - CComQIPtr m_spIOleInPlaceObject; - // Pointer to object's IOleInPlaceObjectWindowless interface - CComQIPtr m_spIOleInPlaceObjectWindowless; - // CLSID of the control - CLSID m_CLSID; - // Parameter list - PropertyList m_ParameterList; - // Default security policy - CControlSiteSecurityPolicy *m_pDefaultSecurityPolicy; - // Pointer to the security policy - CControlSiteSecurityPolicy *m_pSecurityPolicy; - -// Binding variables - // Flag indicating whether binding is in progress - unsigned m_bBindingInProgress; - // Result from the binding operation - HRESULT m_hrBindResult; - -// Double buffer drawing variables used for windowless controls - // Area of buffer - RECT m_rcBuffer; - // Bitmap to buffer - HBITMAP m_hBMBuffer; - // Bitmap to buffer - HBITMAP m_hBMBufferOld; - // Device context - HDC m_hDCBuffer; - // Clipping area of site - HRGN m_hRgnBuffer; - // Flags indicating how the buffer was painted - DWORD m_dwBufferFlags; - -// Ambient properties - // Locale ID - LCID m_nAmbientLocale; - // Foreground colour - COLORREF m_clrAmbientForeColor; - // Background colour - COLORREF m_clrAmbientBackColor; - // Flag indicating if control should hatch itself - bool m_bAmbientShowHatching:1; - // Flag indicating if control should have grab handles - bool m_bAmbientShowGrabHandles:1; - // Flag indicating if control is in edit/user mode - bool m_bAmbientUserMode:1; - // Flag indicating if control has a 3d border or not - bool m_bAmbientAppearance:1; - -protected: - // Notifies the attached control of a change to an ambient property - virtual void FireAmbientPropertyChange(DISPID id); - -public: -// Construction and destruction - // Constructor - CControlSite(); - // Destructor - virtual ~CControlSite(); - -BEGIN_COM_MAP(CControlSite) - CCONTROLSITE_INTERFACES() -END_COM_MAP() - -BEGIN_OLECOMMAND_TABLE() -END_OLECOMMAND_TABLE() - - // List of controls - static std::list m_cControlList; - - // Returns the window used when processing ole commands - HWND GetCommandTargetWindow() - { - return NULL; // TODO - } - -// Object creation and management functions - // Creates and initialises an object - virtual HRESULT Create(REFCLSID clsid, PropertyList &pl = PropertyList(), - LPCWSTR szCodebase = NULL, IBindCtx *pBindContext = NULL); - // Attaches the object to the site - virtual HRESULT Attach(HWND hwndParent, const RECT &rcPos, IUnknown *pInitStream = NULL); - // Detaches the object from the site - virtual HRESULT Detach(); - // Returns the IUnknown pointer for the object - virtual HRESULT GetControlUnknown(IUnknown **ppObject); - // Sets the bounding rectangle for the object - virtual HRESULT SetPosition(const RECT &rcPos); - // Draws the object using the provided DC - virtual HRESULT Draw(HDC hdc); - // Performs the specified action on the object - virtual HRESULT DoVerb(LONG nVerb, LPMSG lpMsg = NULL); - // Sets an advise sink up for changes to the object - virtual HRESULT Advise(IUnknown *pIUnkSink, const IID &iid, DWORD *pdwCookie); - // Removes an advise sink - virtual HRESULT Unadvise(const IID &iid, DWORD dwCookie); - // Register an external service provider object - virtual void SetServiceProvider(IServiceProvider *pSP) - { - m_spServiceProvider = pSP; - } - virtual void SetContainer(IOleContainer *pContainer) - { - m_spContainer = pContainer; - } - // Set the security policy object. Ownership of this object remains with the caller and the security - // policy object is meant to exist for as long as it is set here. - virtual void SetSecurityPolicy(CControlSiteSecurityPolicy *pSecurityPolicy) - { - m_pSecurityPolicy = pSecurityPolicy; - } - virtual CControlSiteSecurityPolicy *GetSecurityPolicy() const - { - return m_pSecurityPolicy; - } - -// Methods to set ambient properties - virtual void SetAmbientUserMode(BOOL bUser); - -// Inline helper methods - // Returns the object's CLSID - virtual const CLSID &GetObjectCLSID() const - { - return m_CLSID; - } - // Tests if the object is valid or not - virtual BOOL IsObjectValid() const - { - return (m_spObject) ? TRUE : FALSE; - } - // Returns the parent window to this one - virtual HWND GetParentWindow() const - { - return m_hWndParent; - } - // Returns the inplace active state of the object - virtual BOOL IsInPlaceActive() const - { - return m_bInPlaceActive; - } - -// CControlSiteSecurityPolicy - // Test if the class is safe to host - virtual BOOL IsClassSafeToHost(const CLSID & clsid); - // Test if the specified class is marked safe for scripting - virtual BOOL IsClassMarkedSafeForScripting(const CLSID & clsid, BOOL &bClassExists); - // Test if the instantiated object is safe for scripting on the specified interface - virtual BOOL IsObjectSafeForScripting(IUnknown *pObject, const IID &iid); - // Test if the instantiated object is safe for scripting on the specified interface - virtual BOOL IsObjectSafeForScripting(const IID &iid); - -// IServiceProvider - virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void** ppv); - -// IDispatch - virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(/* [out] */ UINT __RPC_FAR *pctinfo); - virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(/* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo); - virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(/* [in] */ REFIID riid, /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, /* [in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID __RPC_FAR *rgDispId); - virtual /* [local] */ HRESULT STDMETHODCALLTYPE Invoke(/* [in] */ DISPID dispIdMember, /* [in] */ REFIID riid, /* [in] */ LCID lcid, /* [in] */ WORD wFlags, /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, /* [out] */ VARIANT __RPC_FAR *pVarResult, /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, /* [out] */ UINT __RPC_FAR *puArgErr); - -// IAdviseSink implementation - virtual /* [local] */ void STDMETHODCALLTYPE OnDataChange(/* [unique][in] */ FORMATETC __RPC_FAR *pFormatetc, /* [unique][in] */ STGMEDIUM __RPC_FAR *pStgmed); - virtual /* [local] */ void STDMETHODCALLTYPE OnViewChange(/* [in] */ DWORD dwAspect, /* [in] */ LONG lindex); - virtual /* [local] */ void STDMETHODCALLTYPE OnRename(/* [in] */ IMoniker __RPC_FAR *pmk); - virtual /* [local] */ void STDMETHODCALLTYPE OnSave(void); - virtual /* [local] */ void STDMETHODCALLTYPE OnClose(void); - -// IAdviseSink2 - virtual /* [local] */ void STDMETHODCALLTYPE OnLinkSrcChange(/* [unique][in] */ IMoniker __RPC_FAR *pmk); - -// IAdviseSinkEx implementation - virtual /* [local] */ void STDMETHODCALLTYPE OnViewStatusChange(/* [in] */ DWORD dwViewStatus); - -// IOleWindow implementation - virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE GetWindow(/* [out] */ HWND __RPC_FAR *phwnd); - virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(/* [in] */ BOOL fEnterMode); - -// IOleClientSite implementation - virtual HRESULT STDMETHODCALLTYPE SaveObject(void); - virtual HRESULT STDMETHODCALLTYPE GetMoniker(/* [in] */ DWORD dwAssign, /* [in] */ DWORD dwWhichMoniker, /* [out] */ IMoniker __RPC_FAR *__RPC_FAR *ppmk); - virtual HRESULT STDMETHODCALLTYPE GetContainer(/* [out] */ IOleContainer __RPC_FAR *__RPC_FAR *ppContainer); - virtual HRESULT STDMETHODCALLTYPE ShowObject(void); - virtual HRESULT STDMETHODCALLTYPE OnShowWindow(/* [in] */ BOOL fShow); - virtual HRESULT STDMETHODCALLTYPE RequestNewObjectLayout(void); - -// IOleInPlaceSite implementation - virtual HRESULT STDMETHODCALLTYPE CanInPlaceActivate(void); - virtual HRESULT STDMETHODCALLTYPE OnInPlaceActivate(void); - virtual HRESULT STDMETHODCALLTYPE OnUIActivate(void); - virtual HRESULT STDMETHODCALLTYPE GetWindowContext(/* [out] */ IOleInPlaceFrame __RPC_FAR *__RPC_FAR *ppFrame, /* [out] */ IOleInPlaceUIWindow __RPC_FAR *__RPC_FAR *ppDoc, /* [out] */ LPRECT lprcPosRect, /* [out] */ LPRECT lprcClipRect, /* [out][in] */ LPOLEINPLACEFRAMEINFO lpFrameInfo); - virtual HRESULT STDMETHODCALLTYPE Scroll(/* [in] */ SIZE scrollExtant); - virtual HRESULT STDMETHODCALLTYPE OnUIDeactivate(/* [in] */ BOOL fUndoable); - virtual HRESULT STDMETHODCALLTYPE OnInPlaceDeactivate(void); - virtual HRESULT STDMETHODCALLTYPE DiscardUndoState(void); - virtual HRESULT STDMETHODCALLTYPE DeactivateAndUndo(void); - virtual HRESULT STDMETHODCALLTYPE OnPosRectChange(/* [in] */ LPCRECT lprcPosRect); - -// IOleInPlaceSiteEx implementation - virtual HRESULT STDMETHODCALLTYPE OnInPlaceActivateEx(/* [out] */ BOOL __RPC_FAR *pfNoRedraw, /* [in] */ DWORD dwFlags); - virtual HRESULT STDMETHODCALLTYPE OnInPlaceDeactivateEx(/* [in] */ BOOL fNoRedraw); - virtual HRESULT STDMETHODCALLTYPE RequestUIActivate(void); - -// IOleInPlaceSiteWindowless implementation - virtual HRESULT STDMETHODCALLTYPE CanWindowlessActivate(void); - virtual HRESULT STDMETHODCALLTYPE GetCapture(void); - virtual HRESULT STDMETHODCALLTYPE SetCapture(/* [in] */ BOOL fCapture); - virtual HRESULT STDMETHODCALLTYPE GetFocus(void); - virtual HRESULT STDMETHODCALLTYPE SetFocus(/* [in] */ BOOL fFocus); - virtual HRESULT STDMETHODCALLTYPE GetDC(/* [in] */ LPCRECT pRect, /* [in] */ DWORD grfFlags, /* [out] */ HDC __RPC_FAR *phDC); - virtual HRESULT STDMETHODCALLTYPE ReleaseDC(/* [in] */ HDC hDC); - virtual HRESULT STDMETHODCALLTYPE InvalidateRect(/* [in] */ LPCRECT pRect, /* [in] */ BOOL fErase); - virtual HRESULT STDMETHODCALLTYPE InvalidateRgn(/* [in] */ HRGN hRGN, /* [in] */ BOOL fErase); - virtual HRESULT STDMETHODCALLTYPE ScrollRect(/* [in] */ INT dx, /* [in] */ INT dy, /* [in] */ LPCRECT pRectScroll, /* [in] */ LPCRECT pRectClip); - virtual HRESULT STDMETHODCALLTYPE AdjustRect(/* [out][in] */ LPRECT prc); - virtual HRESULT STDMETHODCALLTYPE OnDefWindowMessage(/* [in] */ UINT msg, /* [in] */ WPARAM wParam, /* [in] */ LPARAM lParam, /* [out] */ LRESULT __RPC_FAR *plResult); - -// IOleControlSite implementation - virtual HRESULT STDMETHODCALLTYPE OnControlInfoChanged(void); - virtual HRESULT STDMETHODCALLTYPE LockInPlaceActive(/* [in] */ BOOL fLock); - virtual HRESULT STDMETHODCALLTYPE GetExtendedControl(/* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDisp); - virtual HRESULT STDMETHODCALLTYPE TransformCoords(/* [out][in] */ POINTL __RPC_FAR *pPtlHimetric, /* [out][in] */ POINTF __RPC_FAR *pPtfContainer, /* [in] */ DWORD dwFlags); - virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator(/* [in] */ MSG __RPC_FAR *pMsg, /* [in] */ DWORD grfModifiers); - virtual HRESULT STDMETHODCALLTYPE OnFocus(/* [in] */ BOOL fGotFocus); - virtual HRESULT STDMETHODCALLTYPE ShowPropertyFrame( void); - -// IBindStatusCallback - virtual HRESULT STDMETHODCALLTYPE OnStartBinding(/* [in] */ DWORD dwReserved, /* [in] */ IBinding __RPC_FAR *pib); - virtual HRESULT STDMETHODCALLTYPE GetPriority(/* [out] */ LONG __RPC_FAR *pnPriority); - virtual HRESULT STDMETHODCALLTYPE OnLowResource(/* [in] */ DWORD reserved); - virtual HRESULT STDMETHODCALLTYPE OnProgress(/* [in] */ ULONG ulProgress, /* [in] */ ULONG ulProgressMax, /* [in] */ ULONG ulStatusCode, /* [in] */ LPCWSTR szStatusText); - virtual HRESULT STDMETHODCALLTYPE OnStopBinding(/* [in] */ HRESULT hresult, /* [unique][in] */ LPCWSTR szError); - virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetBindInfo( /* [out] */ DWORD __RPC_FAR *grfBINDF, /* [unique][out][in] */ BINDINFO __RPC_FAR *pbindinfo); - virtual /* [local] */ HRESULT STDMETHODCALLTYPE OnDataAvailable(/* [in] */ DWORD grfBSCF, /* [in] */ DWORD dwSize, /* [in] */ FORMATETC __RPC_FAR *pformatetc, /* [in] */ STGMEDIUM __RPC_FAR *pstgmed); - virtual HRESULT STDMETHODCALLTYPE OnObjectAvailable(/* [in] */ REFIID riid, /* [iid_is][in] */ IUnknown __RPC_FAR *punk); - -// IWindowForBindingUI - virtual HRESULT STDMETHODCALLTYPE GetWindow(/* [in] */ REFGUID rguidReason, /* [out] */ HWND *phwnd); -}; - -typedef CComObject CControlSiteInstance; - - - -#endif \ No newline at end of file diff --git a/embedding/browser/activex/src/control/ControlSiteIPFrame.cpp b/embedding/browser/activex/src/control/ControlSiteIPFrame.cpp deleted file mode 100644 index 095a4c9c0025..000000000000 --- a/embedding/browser/activex/src/control/ControlSiteIPFrame.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#include "stdafx.h" - - -CControlSiteIPFrame::CControlSiteIPFrame() -{ - m_hwndFrame = NULL; -} - - -CControlSiteIPFrame::~CControlSiteIPFrame() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -// IOleWindow implementation - -HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::GetWindow(/* [out] */ HWND __RPC_FAR *phwnd) -{ - if (phwnd == NULL) - { - return E_INVALIDARG; - } - *phwnd = m_hwndFrame; - - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::ContextSensitiveHelp(/* [in] */ BOOL fEnterMode) -{ - return S_OK; -} - - -/////////////////////////////////////////////////////////////////////////////// -// IOleInPlaceUIWindow implementation - -HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::GetBorder(/* [out] */ LPRECT lprectBorder) -{ - return INPLACE_E_NOTOOLSPACE; -} - - -HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::RequestBorderSpace(/* [unique][in] */ LPCBORDERWIDTHS pborderwidths) -{ - return INPLACE_E_NOTOOLSPACE; -} - - -HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::SetBorderSpace(/* [unique][in] */ LPCBORDERWIDTHS pborderwidths) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::SetActiveObject(/* [unique][in] */ IOleInPlaceActiveObject __RPC_FAR *pActiveObject, /* [unique][string][in] */ LPCOLESTR pszObjName) -{ - return S_OK; -} - - -/////////////////////////////////////////////////////////////////////////////// -// IOleInPlaceFrame implementation - -HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::InsertMenus(/* [in] */ HMENU hmenuShared, /* [out][in] */ LPOLEMENUGROUPWIDTHS lpMenuWidths) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::SetMenu(/* [in] */ HMENU hmenuShared, /* [in] */ HOLEMENU holemenu, /* [in] */ HWND hwndActiveObject) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::RemoveMenus(/* [in] */ HMENU hmenuShared) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::SetStatusText(/* [in] */ LPCOLESTR pszStatusText) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::EnableModeless(/* [in] */ BOOL fEnable) -{ - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::TranslateAccelerator(/* [in] */ LPMSG lpmsg, /* [in] */ WORD wID) -{ - return E_NOTIMPL; -} - diff --git a/embedding/browser/activex/src/control/ControlSiteIPFrame.h b/embedding/browser/activex/src/control/ControlSiteIPFrame.h deleted file mode 100644 index 71c68dc26e2b..000000000000 --- a/embedding/browser/activex/src/control/ControlSiteIPFrame.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef CONTROLSITEIPFRAME_H -#define CONTROLSITEIPFRAME_H - -class CControlSiteIPFrame : public CComObjectRootEx, - public IOleInPlaceFrame -{ -public: - CControlSiteIPFrame(); - virtual ~CControlSiteIPFrame(); - - HWND m_hwndFrame; - -BEGIN_COM_MAP(CControlSiteIPFrame) - COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IOleInPlaceFrame) - COM_INTERFACE_ENTRY_IID(IID_IOleInPlaceUIWindow, IOleInPlaceFrame) - COM_INTERFACE_ENTRY(IOleInPlaceFrame) -END_COM_MAP() - - // IOleWindow - virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE GetWindow(/* [out] */ HWND __RPC_FAR *phwnd); - virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(/* [in] */ BOOL fEnterMode); - - // IOleInPlaceUIWindow implementation - virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE GetBorder(/* [out] */ LPRECT lprectBorder); - virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE RequestBorderSpace(/* [unique][in] */ LPCBORDERWIDTHS pborderwidths); - virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE SetBorderSpace(/* [unique][in] */ LPCBORDERWIDTHS pborderwidths); - virtual HRESULT STDMETHODCALLTYPE SetActiveObject(/* [unique][in] */ IOleInPlaceActiveObject __RPC_FAR *pActiveObject, /* [unique][string][in] */ LPCOLESTR pszObjName); - - // IOleInPlaceFrame implementation - virtual HRESULT STDMETHODCALLTYPE InsertMenus(/* [in] */ HMENU hmenuShared, /* [out][in] */ LPOLEMENUGROUPWIDTHS lpMenuWidths); - virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE SetMenu(/* [in] */ HMENU hmenuShared, /* [in] */ HOLEMENU holemenu, /* [in] */ HWND hwndActiveObject); - virtual HRESULT STDMETHODCALLTYPE RemoveMenus(/* [in] */ HMENU hmenuShared); - virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE SetStatusText(/* [in] */ LPCOLESTR pszStatusText); - virtual HRESULT STDMETHODCALLTYPE EnableModeless(/* [in] */ BOOL fEnable); - virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator(/* [in] */ LPMSG lpmsg, /* [in] */ WORD wID); -}; - -typedef CComObject CControlSiteIPFrameInstance; - -#endif \ No newline at end of file diff --git a/embedding/browser/activex/src/control/IEHtmlElement.cpp b/embedding/browser/activex/src/control/IEHtmlElement.cpp deleted file mode 100644 index 9448ca8fe1ea..000000000000 --- a/embedding/browser/activex/src/control/IEHtmlElement.cpp +++ /dev/null @@ -1,757 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "stdafx.h" - -#include "IEHtmlElement.h" -#include "IEHtmlElementCollection.h" -#include "nsIDOMNSHTMLElement.h" - -CIEHtmlElement::CIEHtmlElement() -{ -} - - -CIEHtmlElement::~CIEHtmlElement() -{ -} - -HRESULT CIEHtmlElement::GetChildren(CIEHtmlElementCollectionInstance **ppCollection) -{ - // Validate parameters - if (ppCollection == NULL) - { - return E_INVALIDARG; - } - - *ppCollection = NULL; - - // Create a collection representing the children of this node - CIEHtmlElementCollectionInstance *pCollection = NULL; - CIEHtmlElementCollection::CreateFromParentNode(this, FALSE, (CIEHtmlElementCollection **) &pCollection); - if (pCollection) - { - pCollection->AddRef(); - *ppCollection = pCollection; - } - - return S_OK; -} - - -/////////////////////////////////////////////////////////////////////////////// -// IHTMLElement implementation - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::setAttribute(BSTR strAttributeName, VARIANT AttributeValue, LONG lFlags) -{ - if (strAttributeName == NULL) - { - return E_INVALIDARG; - } - - nsCOMPtr element = do_QueryInterface(mDOMNode); - if (!element) - { - return E_UNEXPECTED; - } - - // Get the name from the BSTR - USES_CONVERSION; - nsAutoString name(OLE2W(strAttributeName)); - - // Get the value from the variant - CComVariant vValue; - if (FAILED(vValue.ChangeType(VT_BSTR, &AttributeValue))) - { - return E_INVALIDARG; - } - - // Set the attribute - nsAutoString value(OLE2W(vValue.bstrVal)); - element->SetAttribute(name, value); - - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::getAttribute(BSTR strAttributeName, LONG lFlags, VARIANT __RPC_FAR *AttributeValue) -{ - if (strAttributeName == NULL) - { - return E_INVALIDARG; - } - if (AttributeValue == NULL) - { - return E_INVALIDARG; - } - VariantInit(AttributeValue); - - // Get the name from the BSTR - USES_CONVERSION; - nsAutoString name(OLE2W(strAttributeName)); - - nsCOMPtr element = do_QueryInterface(mDOMNode); - if (!element) - { - return E_UNEXPECTED; - } - - BOOL bCaseSensitive = (lFlags == VARIANT_TRUE) ? TRUE : FALSE; - - - // Get the attribute - nsAutoString value; - nsresult rv = element->GetAttribute(name, value); - if (NS_SUCCEEDED(rv)) - { - USES_CONVERSION; - AttributeValue->vt = VT_BSTR; - AttributeValue->bstrVal = SysAllocString(W2COLE(value.get())); - return S_OK; - } - else - { - return S_FALSE; - } - - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::removeAttribute(BSTR strAttributeName, LONG lFlags, VARIANT_BOOL __RPC_FAR *pfSuccess) -{ - if (strAttributeName == NULL) - { - return E_INVALIDARG; - } - - nsCOMPtr element = do_QueryInterface(mDOMNode); - if (!element) - { - return E_UNEXPECTED; - } - - BOOL bCaseSensitive = (lFlags == VARIANT_TRUE) ? TRUE : FALSE; - - // Get the name from the BSTR - USES_CONVERSION; - nsAutoString name(OLE2W(strAttributeName)); - - // Remove the attribute - nsresult nr = element->RemoveAttribute(name); - BOOL bRemoved = (nr == NS_OK) ? TRUE : FALSE; - - if (pfSuccess) - { - *pfSuccess = (bRemoved) ? VARIANT_TRUE : VARIANT_FALSE; - } - - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_className(BSTR v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_className(BSTR __RPC_FAR *p) -{ - if (p == NULL) - { - return E_INVALIDARG; - } - - VARIANT vValue; - VariantInit(&vValue); - BSTR bstrName = SysAllocString(OLESTR("class")); - getAttribute(bstrName, FALSE, &vValue); - SysFreeString(bstrName); - - *p = vValue.bstrVal; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_id(BSTR v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_id(BSTR __RPC_FAR *p) -{ - if (p == NULL) - { - return E_INVALIDARG; - } - - VARIANT vValue; - VariantInit(&vValue); - BSTR bstrName = SysAllocString(OLESTR("id")); - getAttribute(bstrName, FALSE, &vValue); - SysFreeString(bstrName); - - *p = vValue.bstrVal; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_tagName(BSTR __RPC_FAR *p) -{ - if (p == NULL) - { - return E_INVALIDARG; - } - - nsCOMPtr element = do_QueryInterface(mDOMNode); - if (!element) - { - return E_UNEXPECTED; - } - - nsAutoString tagName; - element->GetTagName(tagName); - - USES_CONVERSION; - *p = SysAllocString(W2COLE(tagName.get())); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_parentElement(IHTMLElement __RPC_FAR *__RPC_FAR *p) -{ - if (p == NULL) - { - return E_INVALIDARG; - } - - *p = NULL; - if (mParent) - { - IDispatch *pDisp = reinterpret_cast(mParent); - pDisp->QueryInterface(IID_IHTMLElement, (void **) p); - } - - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_style(IHTMLStyle __RPC_FAR *__RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onhelp(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onhelp(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onclick(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onclick(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_ondblclick(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_ondblclick(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onkeydown(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onkeydown(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onkeyup(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onkeyup(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onkeypress(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onkeypress(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onmouseout(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onmouseout(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onmouseover(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onmouseover(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onmousemove(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onmousemove(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onmousedown(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onmousedown(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onmouseup(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onmouseup(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_document(IDispatch __RPC_FAR *__RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_title(BSTR v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_title(BSTR __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_language(BSTR v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_language(BSTR __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onselectstart(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onselectstart(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::scrollIntoView(VARIANT varargStart) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::contains(IHTMLElement __RPC_FAR *pChild, VARIANT_BOOL __RPC_FAR *pfResult) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_sourceIndex(long __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_recordNumber(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_lang(BSTR v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_lang(BSTR __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_offsetLeft(long __RPC_FAR *p) -{ - nsCOMPtr nodeAsHTMLElement = do_QueryInterface(mDOMNode); - if (!nodeAsHTMLElement) - { - return E_NOINTERFACE; - } - - PRInt32 nData; - nodeAsHTMLElement->GetOffsetLeft(&nData); - *p = nData; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_offsetTop(long __RPC_FAR *p) -{ - nsCOMPtr nodeAsHTMLElement = do_QueryInterface(mDOMNode); - if (!nodeAsHTMLElement) - { - return E_NOINTERFACE; - } - - PRInt32 nData; - nodeAsHTMLElement->GetOffsetTop(&nData); - *p = nData; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_offsetWidth(long __RPC_FAR *p) -{ - nsCOMPtr nodeAsHTMLElement = do_QueryInterface(mDOMNode); - if (!nodeAsHTMLElement) - { - return E_NOINTERFACE; - } - - PRInt32 nData; - nodeAsHTMLElement->GetOffsetWidth(&nData); - *p = nData; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_offsetHeight(long __RPC_FAR *p) -{ - nsCOMPtr nodeAsHTMLElement = do_QueryInterface(mDOMNode); - if (!nodeAsHTMLElement) - { - return E_NOINTERFACE; - } - - PRInt32 nData; - nodeAsHTMLElement->GetOffsetHeight(&nData); - *p = nData; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_offsetParent(IHTMLElement __RPC_FAR *__RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_innerHTML(BSTR v) -{ - nsCOMPtr elementHTML = do_QueryInterface(mDOMNode); - if (!elementHTML) - { - return E_UNEXPECTED; - } - - USES_CONVERSION; - nsAutoString innerHTML(OLE2W(v)); - elementHTML->SetInnerHTML(innerHTML); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_innerHTML(BSTR __RPC_FAR *p) -{ - nsCOMPtr elementHTML = do_QueryInterface(mDOMNode); - if (!elementHTML) - { - return E_UNEXPECTED; - } - - nsAutoString innerHTML; - elementHTML->GetInnerHTML(innerHTML); - - USES_CONVERSION; - *p = SysAllocString(W2COLE(innerHTML.get())); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_innerText(BSTR v) -{ - nsCOMPtr elementHTML = do_QueryInterface(mDOMNode); - if (!elementHTML) - { - return E_UNEXPECTED; - } - - USES_CONVERSION; - nsAutoString innerHTML(OLE2W(v)); - elementHTML->SetInnerHTML(innerHTML); - - return S_OK; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_innerText(BSTR __RPC_FAR *p) -{ - return get_innerHTML(p); -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_outerHTML(BSTR v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_outerHTML(BSTR __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_outerText(BSTR v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_outerText(BSTR __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::insertAdjacentHTML(BSTR where, BSTR html) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::insertAdjacentText(BSTR where, BSTR text) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_parentTextEdit(IHTMLElement __RPC_FAR *__RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_isTextEdit(VARIANT_BOOL __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::click(void) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_filters(IHTMLFiltersCollection __RPC_FAR *__RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_ondragstart(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_ondragstart(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::toString(BSTR __RPC_FAR *String) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onbeforeupdate(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onbeforeupdate(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onafterupdate(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onafterupdate(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onerrorupdate(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onerrorupdate(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onrowexit(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onrowexit(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onrowenter(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onrowenter(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_ondatasetchanged(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_ondatasetchanged(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_ondataavailable(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_ondataavailable(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_ondatasetcomplete(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_ondatasetcomplete(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onfilterchange(VARIANT v) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onfilterchange(VARIANT __RPC_FAR *p) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_children(IDispatch __RPC_FAR *__RPC_FAR *p) -{ - // Validate parameters - if (p == NULL) - { - return E_INVALIDARG; - } - - *p = NULL; - - // Create a collection representing the children of this node - CIEHtmlElementCollectionInstance *pCollection = NULL; - HRESULT hr = GetChildren(&pCollection); - if (SUCCEEDED(hr)) - { - *p = pCollection; - } - - return hr; -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_all(IDispatch __RPC_FAR *__RPC_FAR *p) -{ - // Validate parameters - if (p == NULL) - { - return E_INVALIDARG; - } - - *p = NULL; - - // TODO get ALL contained elements, not just the immediate children - - CIEHtmlElementCollectionInstance *pCollection = NULL; - CIEHtmlElementCollection::CreateFromParentNode(this, TRUE, (CIEHtmlElementCollection **) &pCollection); - if (pCollection) - { - pCollection->AddRef(); - *p = pCollection; - } - - return S_OK; -} - diff --git a/embedding/browser/activex/src/control/IEHtmlElement.h b/embedding/browser/activex/src/control/IEHtmlElement.h deleted file mode 100644 index d6dfe34848d8..000000000000 --- a/embedding/browser/activex/src/control/IEHtmlElement.h +++ /dev/null @@ -1,160 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef IEHTMLELEMENT_H -#define IEHTMLELEMENT_H - -#include "IEHtmlNode.h" -#include "IEHtmlElementCollection.h" - -class CIEHtmlElement : - public CIEHtmlNode, - public IDispatchImpl -{ -public: - CIEHtmlElement(); - -protected: - virtual ~CIEHtmlElement(); - -public: - -BEGIN_COM_MAP(CIEHtmlElement) - COM_INTERFACE_ENTRY_IID(IID_IDispatch, IHTMLElement) - COM_INTERFACE_ENTRY_IID(IID_IHTMLElement, IHTMLElement) -END_COM_MAP() - - virtual HRESULT GetChildren(CIEHtmlElementCollectionInstance **ppCollection); - - // Implementation of IHTMLElement - virtual HRESULT STDMETHODCALLTYPE setAttribute(BSTR strAttributeName, VARIANT AttributeValue, LONG lFlags); - virtual HRESULT STDMETHODCALLTYPE getAttribute(BSTR strAttributeName, LONG lFlags, VARIANT __RPC_FAR *AttributeValue); - virtual HRESULT STDMETHODCALLTYPE removeAttribute(BSTR strAttributeName, LONG lFlags, VARIANT_BOOL __RPC_FAR *pfSuccess); - virtual HRESULT STDMETHODCALLTYPE put_className(BSTR v); - virtual HRESULT STDMETHODCALLTYPE get_className(BSTR __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_id(BSTR v); - virtual HRESULT STDMETHODCALLTYPE get_id(BSTR __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE get_tagName(BSTR __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE get_parentElement(IHTMLElement __RPC_FAR *__RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE get_style(IHTMLStyle __RPC_FAR *__RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onhelp(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onhelp(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onclick(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onclick(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_ondblclick(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_ondblclick(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onkeydown(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onkeydown(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onkeyup(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onkeyup(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onkeypress(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onkeypress(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onmouseout(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onmouseout(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onmouseover(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onmouseover(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onmousemove(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onmousemove(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onmousedown(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onmousedown(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onmouseup(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onmouseup(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE get_document(IDispatch __RPC_FAR *__RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_title(BSTR v); - virtual HRESULT STDMETHODCALLTYPE get_title(BSTR __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_language(BSTR v); - virtual HRESULT STDMETHODCALLTYPE get_language(BSTR __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onselectstart(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onselectstart(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE scrollIntoView(VARIANT varargStart); - virtual HRESULT STDMETHODCALLTYPE contains(IHTMLElement __RPC_FAR *pChild, VARIANT_BOOL __RPC_FAR *pfResult); - virtual HRESULT STDMETHODCALLTYPE get_sourceIndex(long __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE get_recordNumber(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_lang(BSTR v); - virtual HRESULT STDMETHODCALLTYPE get_lang(BSTR __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE get_offsetLeft(long __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE get_offsetTop(long __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE get_offsetWidth(long __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE get_offsetHeight(long __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE get_offsetParent(IHTMLElement __RPC_FAR *__RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_innerHTML(BSTR v); - virtual HRESULT STDMETHODCALLTYPE get_innerHTML(BSTR __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_innerText(BSTR v); - virtual HRESULT STDMETHODCALLTYPE get_innerText(BSTR __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_outerHTML(BSTR v); - virtual HRESULT STDMETHODCALLTYPE get_outerHTML(BSTR __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_outerText(BSTR v); - virtual HRESULT STDMETHODCALLTYPE get_outerText(BSTR __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE insertAdjacentHTML(BSTR where, BSTR html); - virtual HRESULT STDMETHODCALLTYPE insertAdjacentText(BSTR where, BSTR text); - virtual HRESULT STDMETHODCALLTYPE get_parentTextEdit(IHTMLElement __RPC_FAR *__RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE get_isTextEdit(VARIANT_BOOL __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE click(void); - virtual HRESULT STDMETHODCALLTYPE get_filters(IHTMLFiltersCollection __RPC_FAR *__RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_ondragstart(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_ondragstart(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE toString(BSTR __RPC_FAR *String); - virtual HRESULT STDMETHODCALLTYPE put_onbeforeupdate(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onbeforeupdate(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onafterupdate(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onafterupdate(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onerrorupdate(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onerrorupdate(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onrowexit(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onrowexit(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onrowenter(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onrowenter(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_ondatasetchanged(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_ondatasetchanged(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_ondataavailable(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_ondataavailable(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_ondatasetcomplete(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_ondatasetcomplete(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE put_onfilterchange(VARIANT v); - virtual HRESULT STDMETHODCALLTYPE get_onfilterchange(VARIANT __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE get_children(IDispatch __RPC_FAR *__RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE get_all(IDispatch __RPC_FAR *__RPC_FAR *p); -}; - -#define CIEHTMLELEMENT_INTERFACES \ - COM_INTERFACE_ENTRY_IID(IID_IDispatch, IHTMLElement) \ - COM_INTERFACE_ENTRY_IID(IID_IHTMLElement, IHTMLElement) - -typedef CComObject CIEHtmlElementInstance; - -#endif \ No newline at end of file diff --git a/embedding/browser/activex/src/control/IEHtmlElementCollection.cpp b/embedding/browser/activex/src/control/IEHtmlElementCollection.cpp deleted file mode 100644 index 4335bdb912b6..000000000000 --- a/embedding/browser/activex/src/control/IEHtmlElementCollection.cpp +++ /dev/null @@ -1,611 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#include "stdafx.h" - -#include - -#include "IEHtmlElement.h" -#include "IEHtmlElementCollection.h" - -#include "nsIDOMDocumentTraversal.h" -#include "nsIDOMTreeWalker.h" -#include "nsIDOMNodeFilter.h" - -CIEHtmlElementCollection::CIEHtmlElementCollection() -{ - mNodeList = NULL; - mNodeListCount = 0; - mNodeListCapacity = 0; -} - -CIEHtmlElementCollection::~CIEHtmlElementCollection() -{ - // Clean the node list - if (mNodeList) - { - for (PRUint32 i = 0; i < mNodeListCount; i++) - { - IDispatch *pDisp = mNodeList[i]; - if (pDisp) - { - pDisp->Release(); - } - } - free(mNodeList); - mNodeList = NULL; - mNodeListCount = 0; - mNodeListCapacity = 0; - } -} - -HRESULT CIEHtmlElementCollection::PopulateFromDOMHTMLCollection(nsIDOMHTMLCollection *pNodeList) -{ - if (pNodeList == nsnull) - { - return S_OK; - } - - // Recurse through the children of the node (and the children of that) - // to populate the collection - - // Iterate through items in list - PRUint32 length = 0; - pNodeList->GetLength(&length); - for (PRUint32 i = 0; i < length; i++) - { - // Get the next item from the list - nsCOMPtr childNode; - pNodeList->Item(i, getter_AddRefs(childNode)); - if (!childNode) - { - // Empty node (unexpected, but try and carry on anyway) - NG_ASSERT(0); - continue; - } - - // Skip nodes representing, text, attributes etc. - PRUint16 nodeType; - childNode->GetNodeType(&nodeType); - if (nodeType != nsIDOMNode::ELEMENT_NODE) - { - continue; - } - - // Create an equivalent IE element - CIEHtmlNode *pHtmlNode = NULL; - CIEHtmlElementInstance *pHtmlElement = NULL; - CIEHtmlElementInstance::FindFromDOMNode(childNode, &pHtmlNode); - if (!pHtmlNode) - { - CIEHtmlElementInstance::CreateInstance(&pHtmlElement); - pHtmlElement->SetDOMNode(childNode); - pHtmlElement->SetParent(mParent); - } - else - { - pHtmlElement = (CIEHtmlElementInstance *) pHtmlNode; - } - if (pHtmlElement) - { - AddNode(pHtmlElement); - } - } - return S_OK; -} - -HRESULT CIEHtmlElementCollection::PopulateFromDOMNode(nsIDOMNode *aDOMNode, BOOL bRecurseChildren) -{ - if (aDOMNode == nsnull) - { - NG_ASSERT(0); - return E_INVALIDARG; - } - - PRBool hasChildNodes = PR_FALSE; - aDOMNode->HasChildNodes(&hasChildNodes); - if (hasChildNodes) - { - if (bRecurseChildren) - { - nsresult rv; - - // Search through parent nodes, looking for the DOM document - nsCOMPtr docAsNode = aDOMNode; - nsCOMPtr doc = do_QueryInterface(aDOMNode); - while (!doc) { - docAsNode->GetParentNode(getter_AddRefs(docAsNode)); - if (!docAsNode) - { - return E_FAIL; - } - doc = do_QueryInterface(docAsNode); - } - - // Walk the DOM - nsCOMPtr trav = do_QueryInterface(doc, &rv); - NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); - nsCOMPtr walker; - rv = trav->CreateTreeWalker(docAsNode, - nsIDOMNodeFilter::SHOW_ELEMENT, - nsnull, PR_TRUE, getter_AddRefs(walker)); - NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); - - // We're not interested in the document node, so we always start - // with the next one, walking through them all to make the collection - nsCOMPtr currentNode; - walker->NextNode(getter_AddRefs(currentNode)); - while (currentNode) - { - // Create an equivalent IE element - CIEHtmlNode *pHtmlNode = NULL; - CIEHtmlElementInstance *pHtmlElement = NULL; - CIEHtmlElementInstance::FindFromDOMNode(currentNode, &pHtmlNode); - if (!pHtmlNode) - { - CIEHtmlElementInstance::CreateInstance(&pHtmlElement); - pHtmlElement->SetDOMNode(currentNode); - pHtmlElement->SetParent(mParent); - } - else - { - pHtmlElement = (CIEHtmlElementInstance *) pHtmlNode; - } - if (pHtmlElement) - { - AddNode(pHtmlElement); - } - walker->NextNode(getter_AddRefs(currentNode)); - } - } - else - { - nsCOMPtr nodeList; - aDOMNode->GetChildNodes(getter_AddRefs(nodeList)); - mDOMNodeList = nodeList; - } - } - return S_OK; -} - - -HRESULT CIEHtmlElementCollection::CreateFromDOMHTMLCollection(CIEHtmlNode *pParentNode, nsIDOMHTMLCollection *pNodeList, CIEHtmlElementCollection **pInstance) -{ - if (pInstance == NULL || pParentNode == NULL) - { - NG_ASSERT(0); - return E_INVALIDARG; - } - - // Get the DOM node from the parent node - if (!pParentNode->mDOMNode) - { - NG_ASSERT(0); - return E_INVALIDARG; - } - - *pInstance = NULL; - - // Create a collection object - CIEHtmlElementCollectionInstance *pCollection = NULL; - CIEHtmlElementCollectionInstance::CreateInstance(&pCollection); - if (pCollection == NULL) - { - NG_ASSERT(0); - return E_OUTOFMEMORY; - } - - // Initialise and populate the collection - pCollection->SetParent(pParentNode); - pCollection->PopulateFromDOMHTMLCollection(pNodeList); - - *pInstance = pCollection; - - return S_OK; -} - -HRESULT CIEHtmlElementCollection::CreateFromParentNode(CIEHtmlNode *pParentNode, BOOL bRecurseChildren, CIEHtmlElementCollection **pInstance) -{ - if (pInstance == NULL || pParentNode == NULL) - { - NG_ASSERT(0); - return E_INVALIDARG; - } - - // Get the DOM node from the parent node - if (!pParentNode->mDOMNode) - { - NG_ASSERT(0); - return E_INVALIDARG; - } - - *pInstance = NULL; - - // Create a collection object - CIEHtmlElementCollectionInstance *pCollection = NULL; - CIEHtmlElementCollectionInstance::CreateInstance(&pCollection); - if (pCollection == NULL) - { - NG_ASSERT(0); - return E_OUTOFMEMORY; - } - - // Initialise and populate the collection - pCollection->SetParent(pParentNode); - pCollection->PopulateFromDOMNode(pParentNode->mDOMNode, bRecurseChildren); - - *pInstance = pCollection; - - return S_OK; -} - - -HRESULT CIEHtmlElementCollection::AddNode(IDispatch *pNode) -{ - if (pNode == NULL) - { - NG_ASSERT(0); - return E_INVALIDARG; - } - - const PRUint32 c_NodeListResizeBy = 100; - - if (mNodeList == NULL) - { - mNodeListCapacity = c_NodeListResizeBy; - mNodeList = (IDispatch **) malloc(sizeof(IDispatch *) * mNodeListCapacity); - mNodeListCount = 0; - } - else if (mNodeListCount == mNodeListCapacity) - { - mNodeListCapacity += c_NodeListResizeBy; - mNodeList = (IDispatch **) realloc(mNodeList, sizeof(IDispatch *) * mNodeListCapacity); - } - - if (mNodeList == NULL) - { - NG_ASSERT(0); - return E_OUTOFMEMORY; - } - - pNode->AddRef(); - mNodeList[mNodeListCount++] = pNode; - - return S_OK; -} - - -/////////////////////////////////////////////////////////////////////////////// -// IHTMLElementCollection methods - - -HRESULT STDMETHODCALLTYPE CIEHtmlElementCollection::toString(BSTR __RPC_FAR *String) -{ - if (String == NULL) - { - return E_INVALIDARG; - } - *String = SysAllocString(OLESTR("ElementCollection")); - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CIEHtmlElementCollection::put_length(long v) -{ - // What is the point of this method? - return S_OK; -} - - -HRESULT STDMETHODCALLTYPE CIEHtmlElementCollection::get_length(long __RPC_FAR *p) -{ - if (p == NULL) - { - return E_INVALIDARG; - } - - // Return the size of the collection - if (mDOMNodeList) - { - // Count the number of elements in the list - PRUint32 elementCount = 0; - PRUint32 length = 0; - mDOMNodeList->GetLength(&length); - for (PRUint32 i = 0; i < length; i++) - { - // Get the next item from the list - nsCOMPtr childNode; - mDOMNodeList->Item(i, getter_AddRefs(childNode)); - if (!childNode) - { - // Empty node (unexpected, but try and carry on anyway) - NG_ASSERT(0); - continue; - } - - // Only count elements - PRUint16 nodeType; - childNode->GetNodeType(&nodeType); - if (nodeType == nsIDOMNode::ELEMENT_NODE) - { - elementCount++; - } - } - *p = elementCount; - } - else - { - *p = mNodeListCount; - } - return S_OK; -} - -typedef CComObject > > CComEnumVARIANT; - -HRESULT STDMETHODCALLTYPE CIEHtmlElementCollection::get__newEnum(IUnknown __RPC_FAR *__RPC_FAR *p) -{ - NG_TRACE_METHOD(CIEHtmlElementCollection::get__newEnum); - - if (p == NULL) - { - return E_INVALIDARG; - } - - *p = NULL; - - // Create a new IEnumVARIANT object - CComEnumVARIANT *pEnumVARIANT = NULL; - CComEnumVARIANT::CreateInstance(&pEnumVARIANT); - if (pEnumVARIANT == NULL) - { - NG_ASSERT(0); - return E_OUTOFMEMORY; - } - - int nObject = 0; - long nObjects = 0; - get_length(&nObjects); - - // Create an array of VARIANTs - VARIANT *avObjects = new VARIANT[nObjects]; - if (avObjects == NULL) - { - NG_ASSERT(0); - return E_OUTOFMEMORY; - } - - if (mDOMNodeList) - { - // Fill the variant array with elements from the DOM node list - PRUint32 length = 0; - mDOMNodeList->GetLength(&length); - for (PRUint32 i = 0; i < length; i++) - { - // Get the next item from the list - nsCOMPtr childNode; - mDOMNodeList->Item(i, getter_AddRefs(childNode)); - if (!childNode) - { - // Empty node (unexpected, but try and carry on anyway) - NG_ASSERT(0); - continue; - } - - // Skip nodes representing, text, attributes etc. - PRUint16 nodeType; - childNode->GetNodeType(&nodeType); - if (nodeType != nsIDOMNode::ELEMENT_NODE) - { - continue; - } - - // Store the element in the array - CIEHtmlNode *pHtmlNode = NULL; - CIEHtmlElementInstance *pHtmlElement = NULL; - CIEHtmlElementInstance::FindFromDOMNode(childNode, &pHtmlNode); - if (!pHtmlNode) - { - CIEHtmlElementInstance::CreateInstance(&pHtmlElement); - pHtmlElement->SetDOMNode(childNode); - pHtmlElement->SetParent(mParent); - } - else - { - pHtmlElement = (CIEHtmlElementInstance *) pHtmlNode; - } - - VARIANT *pVariant = &avObjects[nObject++]; - VariantInit(pVariant); - pVariant->vt = VT_UNKNOWN; - pHtmlElement->QueryInterface(IID_IUnknown, (void **) &pVariant->punkVal); - } - } - else - { - // Copy the contents of the collection to the array - for (nObject = 0; nObject < nObjects; nObject++) - { - VARIANT *pVariant = &avObjects[nObject]; - IUnknown *pUnkObject = mNodeList[nObject]; - VariantInit(pVariant); - pVariant->vt = VT_UNKNOWN; - pVariant->punkVal = pUnkObject; - pUnkObject->AddRef(); - } - } - - // Copy the variants to the enumeration object - pEnumVARIANT->Init(&avObjects[0], &avObjects[nObjects], NULL, AtlFlagCopy); - - // Cleanup the array - for (nObject = 0; nObject < nObjects; nObject++) - { - VARIANT *pVariant = &avObjects[nObject]; - VariantClear(pVariant); - } - delete []avObjects; - - return pEnumVARIANT->QueryInterface(IID_IUnknown, (void**) p); -} - - -HRESULT STDMETHODCALLTYPE CIEHtmlElementCollection::item(VARIANT name, VARIANT index, IDispatch __RPC_FAR *__RPC_FAR *pdisp) -{ - NG_TRACE_METHOD(CIEHtmlElementCollection::item); - - if (pdisp == NULL) - { - return E_INVALIDARG; - } - - *pdisp = NULL; - - // Note: parameter "name" contains the index unless its a string - // in which case index does. Sensible huh? - - CComVariant vIndex; - if (SUCCEEDED(vIndex.ChangeType(VT_I4, &name)) || - SUCCEEDED(vIndex.ChangeType(VT_I4, &index))) - { - int nIndex = vIndex.lVal; - if (nIndex < 0) - { - return E_INVALIDARG; - } - - if (mDOMNodeList) - { - // Search for the Nth element in the list - PRUint32 elementCount = 0; - PRUint32 length = 0; - mDOMNodeList->GetLength(&length); - for (PRUint32 i = 0; i < length; i++) - { - // Get the next item from the list - nsCOMPtr childNode; - mDOMNodeList->Item(i, getter_AddRefs(childNode)); - if (!childNode) - { - // Empty node (unexpected, but try and carry on anyway) - NG_ASSERT(0); - continue; - } - - // Skip nodes representing, text, attributes etc. - PRUint16 nodeType; - childNode->GetNodeType(&nodeType); - if (nodeType != nsIDOMNode::ELEMENT_NODE) - { - continue; - } - - // Have we found the element we need? - if (elementCount == nIndex) - { - // Return the element - CIEHtmlNode *pHtmlNode = NULL; - CIEHtmlElementInstance *pHtmlElement = NULL; - CIEHtmlElementInstance::FindFromDOMNode(childNode, &pHtmlNode); - if (!pHtmlNode) - { - CIEHtmlElementInstance::CreateInstance(&pHtmlElement); - pHtmlElement->SetDOMNode(childNode); - pHtmlElement->SetParent(mParent); - } - else - { - pHtmlElement = (CIEHtmlElementInstance *) pHtmlNode; - } - pHtmlElement->QueryInterface(IID_IDispatch, (void **) pdisp); - return S_OK; - } - elementCount++; - } - // Index must have been out of range - return E_INVALIDARG; - } - else - { - // Test for stupid values - if (nIndex >= mNodeListCount) - { - return E_INVALIDARG; - } - - *pdisp = NULL; - IDispatch *pNode = mNodeList[nIndex]; - if (pNode == NULL) - { - NG_ASSERT(0); - return E_UNEXPECTED; - } - pNode->QueryInterface(IID_IDispatch, (void **) pdisp); - } - - return S_OK; - } - else if (SUCCEEDED(vIndex.ChangeType(VT_BSTR, &index))) - { - // If this parameter contains a string, the method returns - // a collection of objects, where the value of the name or - // id property for each object is equal to the string. - - // TODO all of the above! - return E_NOTIMPL; - } - else - { - return E_INVALIDARG; - } -} - -HRESULT STDMETHODCALLTYPE CIEHtmlElementCollection::tags(VARIANT tagName, IDispatch __RPC_FAR *__RPC_FAR *pdisp) -{ - if (pdisp == NULL) - { - return E_INVALIDARG; - } - - *pdisp = NULL; - - // TODO - // iterate through collection looking for elements with matching tags - - return E_NOTIMPL; -} - diff --git a/embedding/browser/activex/src/control/IEHtmlElementCollection.h b/embedding/browser/activex/src/control/IEHtmlElementCollection.h deleted file mode 100644 index 1d5fedc19856..000000000000 --- a/embedding/browser/activex/src/control/IEHtmlElementCollection.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef IEHTMLNODECOLLECTION_H -#define IEHTMLNODECOLLECTION_H - -#include "nsIDOMHTMLCollection.h" -#include "nsIDOMNodeList.h" - -#include "IEHtmlNode.h" - -class CIEHtmlElement; - -class CIEHtmlElementCollection : - public CIEHtmlNode, - public IDispatchImpl -{ -private: - // Hold a DOM node list - nsCOMPtr mDOMNodeList; - // Or hold a static collection - IDispatch **mNodeList; - PRUint32 mNodeListCount; - PRUint32 mNodeListCapacity; - -public: - CIEHtmlElementCollection(); - -protected: - virtual ~CIEHtmlElementCollection(); - -public: - // Adds a node to the collection - virtual HRESULT AddNode(IDispatch *pNode); - - virtual HRESULT PopulateFromDOMHTMLCollection(nsIDOMHTMLCollection *pNodeList); - - // Populates the collection with items from the DOM node - virtual HRESULT PopulateFromDOMNode(nsIDOMNode *pIDOMNode, BOOL bRecurseChildren); - - // Helper method creates a collection from a parent node - static HRESULT CreateFromParentNode(CIEHtmlNode *pParentNode, BOOL bRecurseChildren, CIEHtmlElementCollection **pInstance); - - // Helper method creates a collection from the specified HTML collection - static HRESULT CreateFromDOMHTMLCollection(CIEHtmlNode *pParentNode, nsIDOMHTMLCollection *pNodeList, CIEHtmlElementCollection **pInstance); - - -BEGIN_COM_MAP(CIEHtmlElementCollection) - COM_INTERFACE_ENTRY_IID(IID_IDispatch, IHTMLElementCollection) - COM_INTERFACE_ENTRY_IID(IID_IHTMLElementCollection, IHTMLElementCollection) -END_COM_MAP() - - // IHTMLElementCollection methods - virtual HRESULT STDMETHODCALLTYPE toString(BSTR __RPC_FAR *String); - virtual HRESULT STDMETHODCALLTYPE put_length(long v); - virtual HRESULT STDMETHODCALLTYPE get_length(long __RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE get__newEnum(IUnknown __RPC_FAR *__RPC_FAR *p); - virtual HRESULT STDMETHODCALLTYPE item(VARIANT name, VARIANT index, IDispatch __RPC_FAR *__RPC_FAR *pdisp); - virtual HRESULT STDMETHODCALLTYPE tags(VARIANT tagName, IDispatch __RPC_FAR *__RPC_FAR *pdisp); -}; - -typedef CComObject CIEHtmlElementCollectionInstance; - -#endif \ No newline at end of file diff --git a/embedding/browser/activex/src/control/IEHtmlNode.cpp b/embedding/browser/activex/src/control/IEHtmlNode.cpp deleted file mode 100644 index 7e6a1778c51a..000000000000 --- a/embedding/browser/activex/src/control/IEHtmlNode.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#include "stdafx.h" -#include "IEHtmlNode.h" - -#include "plhash.h" - -static PLHashTable *g_NodeLookupTable; - -static PLHashNumber PR_CALLBACK HashFunction(const void *key) -{ - return (PRUint32) key; -} - -PRIntn PR_CALLBACK HashComparator(const void *v1, const void *v2) -{ - if (v1 == v2) - { - return 1; - } - return 0; -} - - -CIEHtmlNode::CIEHtmlNode() : - mParent(NULL) -{ -} - -CIEHtmlNode::~CIEHtmlNode() -{ - SetDOMNode(nsnull); -} - - -HRESULT CIEHtmlNode::SetParent(CIEHtmlNode *pParent) -{ - mParent = pParent; - return S_OK; -} - - -HRESULT CIEHtmlNode::FindFromDOMNode(nsIDOMNode *pIDOMNode, CIEHtmlNode **pHtmlNode) -{ - if (pIDOMNode == nsnull) - { - return E_FAIL; - } - - if (g_NodeLookupTable == NULL) - { - return E_FAIL; - } - - nsCOMPtr nodeAsSupports = do_QueryInterface(pIDOMNode); - *pHtmlNode = (CIEHtmlNode *) PL_HashTableLookup(g_NodeLookupTable, nodeAsSupports); - - return S_OK; -} - -HRESULT CIEHtmlNode::SetDOMNode(nsIDOMNode *pIDOMNode) -{ - if (pIDOMNode) - { - if (g_NodeLookupTable == NULL) - { - g_NodeLookupTable = PL_NewHashTable(123, HashFunction, HashComparator, NULL, NULL, NULL); - } - - mDOMNode = pIDOMNode; - nsCOMPtr nodeAsSupports= do_QueryInterface(mDOMNode); - PL_HashTableAdd(g_NodeLookupTable, nodeAsSupports, this); - } - else if (mDOMNode) - { - // Remove the entry from the hashtable - nsCOMPtr nodeAsSupports = do_QueryInterface(mDOMNode); - PL_HashTableRemove(g_NodeLookupTable, nodeAsSupports); - mDOMNode = nsnull; - - if (g_NodeLookupTable->nentries == 0) - { - PL_HashTableDestroy(g_NodeLookupTable); - g_NodeLookupTable = NULL; - } - } - return S_OK; -} diff --git a/embedding/browser/activex/src/control/IEHtmlNode.h b/embedding/browser/activex/src/control/IEHtmlNode.h deleted file mode 100644 index a066fe3f810c..000000000000 --- a/embedding/browser/activex/src/control/IEHtmlNode.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef IEHTMLNODE_H -#define IEHTMLNODE_H - - -class CIEHtmlNode : - public CComObjectRootEx -{ -protected: - CIEHtmlNode(); - virtual ~CIEHtmlNode(); - -public: - CIEHtmlNode *mParent; - nsCOMPtr mDOMNode; - - static HRESULT FindFromDOMNode(nsIDOMNode *pIDOMNode, CIEHtmlNode **pHtmlNode); - virtual HRESULT SetParent(CIEHtmlNode *mParent); - virtual HRESULT SetDOMNode(nsIDOMNode *pIDOMNode); -}; - -typedef CComObject CIEHtmlNodeInstance; - -#endif \ No newline at end of file diff --git a/embedding/browser/activex/src/control/IHTMLLocationImpl.h b/embedding/browser/activex/src/control/IHTMLLocationImpl.h deleted file mode 100644 index 4ddac8b02065..000000000000 --- a/embedding/browser/activex/src/control/IHTMLLocationImpl.h +++ /dev/null @@ -1,187 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef IHTMLLOCATIONIMPL_H -#define IHTMLLOCATIONIMPL_H - -#include "nsIDOMLocation.h" - -#define IHTMLLOCATION_GET_IMPL(prop) \ - if (!p) return E_INVALIDARG; \ - nsCOMPtr location; \ - if (NS_FAILED(GetDOMLocation(getter_AddRefs(location))) || !location) \ - return E_UNEXPECTED; \ - nsAutoString value; \ - NS_ENSURE_SUCCESS(location->Get ## prop(value), E_UNEXPECTED); \ - *p = ::SysAllocString(value.get()); \ - return (*p) ? S_OK : E_OUTOFMEMORY; - -#define IHTMLLOCATION_PUT_IMPL(prop) \ - return E_NOTIMPL; // For now - -template -class IHTMLLocationImpl : - public IDispatchImpl -{ -protected: -// Methods to be implemented by the derived class - virtual nsresult GetDOMLocation(nsIDOMLocation **aLocation) = 0; -public: - -// IHTMLLocation - virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_href( - /* [in] */ BSTR v) - { - IHTMLLOCATION_PUT_IMPL(Href); - } - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_href( - /* [out][retval] */ BSTR *p) - { - IHTMLLOCATION_GET_IMPL(Href); - } - virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_protocol( - /* [in] */ BSTR v) - { - IHTMLLOCATION_PUT_IMPL(Protocol); - } - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_protocol( - /* [out][retval] */ BSTR *p) - { - IHTMLLOCATION_GET_IMPL(Protocol); - } - virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_host( - /* [in] */ BSTR v) - { - IHTMLLOCATION_PUT_IMPL(Host); - } - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_host( - /* [out][retval] */ BSTR *p) - { - IHTMLLOCATION_GET_IMPL(Host); - } - virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_hostname( - /* [in] */ BSTR v) - { - IHTMLLOCATION_PUT_IMPL(Hostname); - } - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_hostname( - /* [out][retval] */ BSTR *p) - { - IHTMLLOCATION_GET_IMPL(Hostname); - } - virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_port( - /* [in] */ BSTR v) - { - IHTMLLOCATION_PUT_IMPL(Port); - } - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_port( - /* [out][retval] */ BSTR *p) - { - IHTMLLOCATION_GET_IMPL(Port); - } - virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_pathname( - /* [in] */ BSTR v) - { - IHTMLLOCATION_PUT_IMPL(Pathname); - } - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_pathname( - /* [out][retval] */ BSTR *p) - { - IHTMLLOCATION_GET_IMPL(Pathname); - } - virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_search( - /* [in] */ BSTR v) - { - IHTMLLOCATION_PUT_IMPL(Search); - } - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_search( - /* [out][retval] */ BSTR *p) - { - IHTMLLOCATION_GET_IMPL(Search); - } - virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_hash( - /* [in] */ BSTR v) - { - IHTMLLOCATION_PUT_IMPL(Hash); - } - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_hash( - /* [out][retval] */ BSTR *p) - { - IHTMLLOCATION_GET_IMPL(Hash); - } - virtual /* [id] */ HRESULT STDMETHODCALLTYPE reload( - /* [in][defaultvalue] */ VARIANT_BOOL flag) - { - nsCOMPtr location; - if (NS_FAILED(GetDOMLocation(getter_AddRefs(location))) || !location) - return E_UNEXPECTED; - return NS_SUCCEEDED(location->Reload(flag)) ? S_OK : E_FAIL; - } - virtual /* [id] */ HRESULT STDMETHODCALLTYPE replace( - /* [in] */ BSTR bstr) - { - nsCOMPtr location; - if (NS_FAILED(GetDOMLocation(getter_AddRefs(location))) || !location) - return E_UNEXPECTED; - nsAutoString value(bstr); - return NS_SUCCEEDED(location->Replace(value)) ? S_OK : E_FAIL; - } - virtual /* [id] */ HRESULT STDMETHODCALLTYPE assign( - /* [in] */ BSTR bstr) - { - nsCOMPtr location; - if (NS_FAILED(GetDOMLocation(getter_AddRefs(location))) || !location) - return E_UNEXPECTED; - nsAutoString value(bstr); - return NS_SUCCEEDED(location->Assign(value)) ? S_OK : E_FAIL; - } - virtual /* [id] */ HRESULT STDMETHODCALLTYPE toString( - /* [out][retval] */ BSTR *string) - { - if (!string) return E_INVALIDARG; - nsCOMPtr location; - if (NS_FAILED(GetDOMLocation(getter_AddRefs(location))) || !location) - return E_UNEXPECTED; - nsAutoString value; - NS_ENSURE_SUCCESS(location->ToString(value), E_UNEXPECTED); - *string = ::SysAllocString(value.get()); - return (*string) ? S_OK : E_OUTOFMEMORY; - } -}; - -#endif \ No newline at end of file diff --git a/embedding/browser/activex/src/control/IOleCommandTargetImpl.h b/embedding/browser/activex/src/control/IOleCommandTargetImpl.h deleted file mode 100644 index 3eefc7450860..000000000000 --- a/embedding/browser/activex/src/control/IOleCommandTargetImpl.h +++ /dev/null @@ -1,290 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef IOLECOMMANDIMPL_H -#define IOLECOMMANDIMPL_H - -// Implementation of the IOleCommandTarget interface. The template is -// reasonably generic and reusable which is a good thing given how needlessly -// complicated this interface is. Blame Microsoft for that and not me. -// -// To use this class, derive your class from it like this: -// -// class CComMyClass : public IOleCommandTargetImpl -// { -// ... Ensure IOleCommandTarget is listed in the interface map ... -// BEGIN_COM_MAP(CComMyClass) -// COM_INTERFACE_ENTRY(IOleCommandTarget) -// // etc. -// END_COM_MAP() -// ... And then later on define the command target table ... -// BEGIN_OLECOMMAND_TABLE() -// OLECOMMAND_MESSAGE(OLECMDID_PRINT, NULL, ID_PRINT, L"Print", L"Print the page") -// OLECOMMAND_MESSAGE(OLECMDID_SAVEAS, NULL, 0, L"SaveAs", L"Save the page") -// OLECOMMAND_HANDLER(IDM_EDITMODE, &CGID_MSHTML, EditModeHandler, L"EditMode", L"Switch to edit mode") -// END_OLECOMMAND_TABLE() -// ... Now the window that OLECOMMAND_MESSAGE sends WM_COMMANDs to ... -// HWND GetCommandTargetWindow() const -// { -// return m_hWnd; -// } -// ... Now procedures that OLECOMMAND_HANDLER calls ... -// static HRESULT _stdcall EditModeHandler(CMozillaBrowser *pThis, const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut); -// } -// -// The command table defines which commands the object supports. Commands are -// defined by a command id and a command group plus a WM_COMMAND id or procedure, -// and a verb and short description. -// -// Notice that there are two macros for handling Ole Commands. The first, -// OLECOMMAND_MESSAGE sends a WM_COMMAND message to the window returned from -// GetCommandTargetWindow() (that the derived class must implement if it uses -// this macro). -// -// The second, OLECOMMAND_HANDLER calls a static handler procedure that -// conforms to the OleCommandProc typedef. The first parameter, pThis means -// the static handler has access to the methods and variables in the class -// instance. -// -// The OLECOMMAND_HANDLER macro is generally more useful when a command -// takes parameters or needs to return a result to the caller. -// -template< class T > -class IOleCommandTargetImpl : public IOleCommandTarget -{ - struct OleExecData - { - const GUID *pguidCmdGroup; - DWORD nCmdID; - DWORD nCmdexecopt; - VARIANT *pvaIn; - VARIANT *pvaOut; - }; - -public: - typedef HRESULT (_stdcall *OleCommandProc)(T *pT, const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut); - - struct OleCommandInfo - { - ULONG nCmdID; - const GUID *pCmdGUID; - ULONG nWindowsCmdID; - OleCommandProc pfnCommandProc; - wchar_t *szVerbText; - wchar_t *szStatusText; - }; - - // Query the status of the specified commands (test if is it supported etc.) - virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID __RPC_FAR *pguidCmdGroup, ULONG cCmds, OLECMD __RPC_FAR prgCmds[], OLECMDTEXT __RPC_FAR *pCmdText) - { - T* pT = static_cast(this); - - if (prgCmds == NULL) - { - return E_INVALIDARG; - } - - OleCommandInfo *pCommands = pT->GetCommandTable(); - NG_ASSERT(pCommands); - - BOOL bCmdGroupFound = FALSE; - BOOL bTextSet = FALSE; - - // Iterate through list of commands and flag them as supported/unsupported - for (ULONG nCmd = 0; nCmd < cCmds; nCmd++) - { - // Unsupported by default - prgCmds[nCmd].cmdf = 0; - - // Search the support command list - for (int nSupported = 0; pCommands[nSupported].pCmdGUID != &GUID_NULL; nSupported++) - { - OleCommandInfo *pCI = &pCommands[nSupported]; - - if (pguidCmdGroup && pCI->pCmdGUID && memcmp(pguidCmdGroup, pCI->pCmdGUID, sizeof(GUID)) == 0) - { - continue; - } - bCmdGroupFound = TRUE; - - if (pCI->nCmdID != prgCmds[nCmd].cmdID) - { - continue; - } - - // Command is supported so flag it and possibly enable it - prgCmds[nCmd].cmdf = OLECMDF_SUPPORTED; - if (pCI->nWindowsCmdID != 0) - { - prgCmds[nCmd].cmdf |= OLECMDF_ENABLED; - } - - // Copy the status/verb text for the first supported command only - if (!bTextSet && pCmdText) - { - // See what text the caller wants - wchar_t *pszTextToCopy = NULL; - if (pCmdText->cmdtextf & OLECMDTEXTF_NAME) - { - pszTextToCopy = pCI->szVerbText; - } - else if (pCmdText->cmdtextf & OLECMDTEXTF_STATUS) - { - pszTextToCopy = pCI->szStatusText; - } - - // Copy the text - pCmdText->cwActual = 0; - memset(pCmdText->rgwz, 0, pCmdText->cwBuf * sizeof(wchar_t)); - if (pszTextToCopy) - { - // Don't exceed the provided buffer size - size_t nTextLen = wcslen(pszTextToCopy); - if (nTextLen > pCmdText->cwBuf) - { - nTextLen = pCmdText->cwBuf; - } - - wcsncpy(pCmdText->rgwz, pszTextToCopy, nTextLen); - pCmdText->cwActual = nTextLen; - } - - bTextSet = TRUE; - } - break; - } - } - - // Was the command group found? - if (!bCmdGroupFound) - { - OLECMDERR_E_UNKNOWNGROUP; - } - - return S_OK; - } - - - // Execute the specified command - virtual HRESULT STDMETHODCALLTYPE Exec(const GUID __RPC_FAR *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT __RPC_FAR *pvaIn, VARIANT __RPC_FAR *pvaOut) - { - T* pT = static_cast(this); - BOOL bCmdGroupFound = FALSE; - - OleCommandInfo *pCommands = pT->GetCommandTable(); - NG_ASSERT(pCommands); - - // Search the support command list - for (int nSupported = 0; pCommands[nSupported].pCmdGUID != &GUID_NULL; nSupported++) - { - OleCommandInfo *pCI = &pCommands[nSupported]; - - if (pguidCmdGroup && pCI->pCmdGUID && memcmp(pguidCmdGroup, pCI->pCmdGUID, sizeof(GUID)) == 0) - { - continue; - } - bCmdGroupFound = TRUE; - - if (pCI->nCmdID != nCmdID) - { - continue; - } - - // Send ourselves a WM_COMMAND windows message with the associated - // identifier and exec data - OleExecData cData; - cData.pguidCmdGroup = pguidCmdGroup; - cData.nCmdID = nCmdID; - cData.nCmdexecopt = nCmdexecopt; - cData.pvaIn = pvaIn; - cData.pvaOut = pvaOut; - - if (pCI->pfnCommandProc) - { - pCI->pfnCommandProc(pT, pCI->pCmdGUID, pCI->nCmdID, nCmdexecopt, pvaIn, pvaOut); - } - else if (pCI->nWindowsCmdID != 0 && - !(nCmdexecopt & OLECMDEXECOPT_SHOWHELP)) - { - HWND hwndTarget = pT->GetCommandTargetWindow(); - if (hwndTarget) - { - ::SendMessage(hwndTarget, WM_COMMAND, LOWORD(pCI->nWindowsCmdID), (LPARAM) &cData); - } - } - else - { - // Command supported but not implemented - continue; - } - - return S_OK; - } - - // Was the command group found? - if (!bCmdGroupFound) - { - OLECMDERR_E_UNKNOWNGROUP; - } - - return OLECMDERR_E_NOTSUPPORTED; - } -}; - -// Macros to be placed in any class derived from the IOleCommandTargetImpl -// class. These define what commands are exposed from the object. - -#define BEGIN_OLECOMMAND_TABLE() \ - OleCommandInfo *GetCommandTable() \ - { \ - static OleCommandInfo s_aSupportedCommands[] = \ - { - -#define OLECOMMAND_MESSAGE(id, group, cmd, verb, desc) \ - { id, group, cmd, NULL, verb, desc }, - -#define OLECOMMAND_HANDLER(id, group, handler, verb, desc) \ - { id, group, 0, handler, verb, desc }, - -#define END_OLECOMMAND_TABLE() \ - { 0, &GUID_NULL, 0, NULL, NULL, NULL } \ - }; \ - return s_aSupportedCommands; \ - }; - -#endif \ No newline at end of file diff --git a/embedding/browser/activex/src/control/IWebBrowserImpl.h b/embedding/browser/activex/src/control/IWebBrowserImpl.h deleted file mode 100644 index f17006b37c3e..000000000000 --- a/embedding/browser/activex/src/control/IWebBrowserImpl.h +++ /dev/null @@ -1,1204 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef IWEBBROWSERIMPL_H -#define IWEBBROWSERIMPL_H - -#include - -#include "nsIWebNavigation.h" -#include "nsIPref.h" -#include "nsIDOMWindow.h" -#include "nsIBaseWindow.h" -#include "nsIWindowWatcher.h" -#include "nsIInputStream.h" -#include "nsIByteArrayInputStream.h" -#include "nsIURI.h" - -#include "PropertyList.h" - -// CPMozillaControl.h was autogenerated by the ATL proxy wizard so don't edit it! -#include "CPMozillaControl.h" - -#define ENSURE_BROWSER_IS_VALID() \ - if (!BrowserIsValid()) \ - { \ - NS_ASSERTION(0, "Browser is not valid"); \ - return SetErrorInfo(E_UNEXPECTED, L"Browser is not in a valid state"); \ - } - -#define ENSURE_GET_WEBNAV() \ - nsCOMPtr webNav; \ - nsresult rv = GetWebNavigation(getter_AddRefs(webNav)); \ - if (NS_FAILED(rv)) \ - { \ - NG_ASSERT(0); \ - return SetErrorInfo(E_UNEXPECTED, L"Could not obtain nsIWebNavigation interface"); \ - } - -template -class IWebBrowserImpl : - public CStockPropImpl, - public CProxyDWebBrowserEvents, - public CProxyDWebBrowserEvents2 -{ -public: - IWebBrowserImpl() - { - // Ready state of control - mBrowserReadyState = READYSTATE_UNINITIALIZED; - // Flag indicates if the browser is busy - mBusyFlag = PR_FALSE; - } - -public: -// Methods to be implemented by the derived class - // Return the nsIWebNavigation object - virtual nsresult GetWebNavigation(nsIWebNavigation **aWebNav) = 0; - // Return the nsIDOMWindow object - virtual nsresult GetDOMWindow(nsIDOMWindow **aDOMWindow) = 0; - // Return the nsIPref object - virtual nsresult GetPrefs(nsIPref **aPrefs) = 0; - // Return the valid state of the browser - virtual PRBool BrowserIsValid() = 0; - -public: -// Properties related to this interface - // Post data from last navigate operation - CComVariant mLastPostData; - // Ready status of the browser - READYSTATE mBrowserReadyState; - // Controls starts off unbusy - PRBool mBusyFlag; - // Property list - PropertyList mPropertyList; - -// Helper methods - - // - // Sets error information for VB programmers and the like who want to know why - // some method call failed. - // - virtual HRESULT SetErrorInfo(HRESULT hr, LPCOLESTR lpszDesc = NULL) - { - if (lpszDesc == NULL) - { - // Fill in a few generic descriptions - switch (hr) - { - case E_UNEXPECTED: - lpszDesc = L"Method was called while control was uninitialized"; - break; - case E_INVALIDARG: - lpszDesc = L"Method was called with an invalid parameter"; - break; - } - } - AtlSetErrorInfo(*pclsid, lpszDesc, 0, NULL, GUID_NULL, hr, NULL); - return hr; - } - - -// IWebBrowser implementation - virtual HRESULT STDMETHODCALLTYPE GoBack(void) - { - NG_TRACE_METHOD(IWebBrowserImpl::GoBack); - ENSURE_BROWSER_IS_VALID(); - ENSURE_GET_WEBNAV(); - - PRBool aCanGoBack = PR_FALSE; - webNav->GetCanGoBack(&aCanGoBack); - if (aCanGoBack == PR_TRUE) - { - webNav->GoBack(); - } - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE GoForward(void) - { - NG_TRACE_METHOD(IWebBrowserImpl::GoBack); - ENSURE_BROWSER_IS_VALID(); - ENSURE_GET_WEBNAV(); - - PRBool aCanGoForward = PR_FALSE; - webNav->GetCanGoForward(&aCanGoForward); - if (aCanGoForward == PR_TRUE) - { - webNav->GoForward(); - } - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE GoHome(void) - { - NG_TRACE_METHOD(IWebBrowserImpl::GoHome); - ENSURE_BROWSER_IS_VALID(); - - CComBSTR bstrUrl(L"http://home.netscape.com/"); - - // Find the home page stored in prefs - nsCOMPtr prefs; - if (NS_SUCCEEDED(GetPrefs(getter_AddRefs(prefs)))) - { - nsXPIDLString homePage; - nsresult rv; - rv = prefs->GetLocalizedUnicharPref("browser.startup.homepage", getter_Copies(homePage)); - if (rv == NS_OK) - { - bstrUrl = homePage.get();; - } - } - - // Navigate to the home page - Navigate(bstrUrl, NULL, NULL, NULL, NULL); - - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE GoSearch(void) - { - NG_TRACE_METHOD(IWebBrowserImpl::GoSearch); - ENSURE_BROWSER_IS_VALID(); - - CComBSTR bstrUrl(L"http://search.netscape.com/"); - - // Find the home page stored in prefs - nsCOMPtr prefs; - if (NS_SUCCEEDED(GetPrefs(getter_AddRefs(prefs)))) - { - // TODO find and navigate to the search page stored in prefs - // and not this hard coded address - } - - // Navigate to the search page - Navigate(bstrUrl, NULL, NULL, NULL, NULL); - - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE Navigate(BSTR URL, VARIANT __RPC_FAR *Flags, VARIANT __RPC_FAR *TargetFrameName, VARIANT __RPC_FAR *PostData, VARIANT __RPC_FAR *Headers) - { - NG_TRACE_METHOD(IWebBrowserImpl::Navigate); - ENSURE_BROWSER_IS_VALID(); - - // Extract the URL parameter - if (URL == NULL) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - - PRBool openInNewWindow = PR_FALSE; - PRUint32 loadFlags = nsIWebNavigation::LOAD_FLAGS_NONE; - - // Extract the navigate flags parameter - LONG lFlags = 0; - if (Flags && - Flags->vt != VT_ERROR && - Flags->vt != VT_EMPTY && - Flags->vt != VT_NULL) - { - CComVariant vFlags; - if ( vFlags.ChangeType(VT_I4, Flags) != S_OK ) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - lFlags = vFlags.lVal; - } - if (lFlags & navOpenInNewWindow) - { - openInNewWindow = PR_TRUE; - } - if (lFlags & navNoHistory) - { - // Disable history - loadFlags |= nsIWebNavigation::LOAD_FLAGS_BYPASS_HISTORY; - } - if (lFlags & navNoReadFromCache) - { - // Disable read from cache - loadFlags |= nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE; - - } - if (lFlags & navNoWriteToCache) - { - // Disable write to cache - loadFlags |= nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE; - } - - // Extract the target frame parameter - nsCOMPtr targetNav; - if (TargetFrameName && - TargetFrameName->vt == VT_BSTR && - TargetFrameName->bstrVal) - { - // Search for the named frame - nsCOMPtr window; - GetDOMWindow(getter_AddRefs(window)); - if (window) - { - nsCOMPtr windowWatcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID); - if (windowWatcher) - { - nsCOMPtr targetWindow; - windowWatcher->GetWindowByName(TargetFrameName->bstrVal, window, - getter_AddRefs(targetWindow)); - if (targetWindow) - { - targetNav = do_GetInterface(targetWindow); - } - } - } - // No target nav? Open in new window - if (!targetNav) - openInNewWindow = PR_TRUE; - } - - // Open in new window - if (openInNewWindow) - { - CIPtr(IDispatch) spDispNew; - VARIANT_BOOL bCancel = VARIANT_FALSE; - - // Test if the event sink can give us a new window to navigate into - Fire_NewWindow2(&spDispNew, &bCancel); - - lFlags &= ~(navOpenInNewWindow); - if ((bCancel == VARIANT_FALSE) && spDispNew) - { - CIPtr(IWebBrowser2) spOther = spDispNew; - if (spOther) - { - CComVariant vURL(URL); - CComVariant vFlags(lFlags); - return spOther->Navigate2(&vURL, &vFlags, TargetFrameName, PostData, Headers); - } - } - - // NOTE: The IE control will launch an instance of iexplore.exe and - // return an interface to that if the client does not respond to - // FireNewWindow2, but the Mozilla control will not. Potentially - // it could also open an instance of IE for such occasions. - // - - // Can't open a new window without client support - return S_OK; - } - - // As documented in MSDN: - // - // The post data specified by PostData is passed as a SAFEARRAY - // structure. The variant should be of type VT_ARRAY and point to - // a SAFEARRAY. The SAFEARRAY should be of element type VT_UI1, - // dimension one, and have an element count equal to the number of - // bytes of post data. - - // Extract the post data parameter - nsCOMPtr postDataStream; - mLastPostData.Clear(); - if (PostData && - PostData->vt == (VT_ARRAY | VT_UI1) && - PostData->parray) - { - mLastPostData.Copy(PostData); - - unsigned long nSizeData = PostData->parray->rgsabound[0].cElements; - if (nSizeData > 0) - { - char szCL[64]; - sprintf(szCL, "Content-Length: %lu\r\n\r\n", nSizeData); - unsigned long nSizeCL = strlen(szCL); - unsigned long nSize = nSizeCL + nSizeData; - - char *tmp = (char *) nsMemory::Alloc(nSize + 1); // byte stream owns this mem - if (tmp) - { - - // Copy the array data into a buffer - SafeArrayLock(PostData->parray); - memcpy(tmp, szCL, nSizeCL); - memcpy(tmp + nSizeCL, PostData->parray->pvData, nSizeData); - tmp[nSize] = '\0'; - SafeArrayUnlock(PostData->parray); - - // Create a byte array input stream object. - nsCOMPtr stream; - nsresult rv = NS_NewByteArrayInputStream( - getter_AddRefs(stream), tmp, nSize); - if (NS_FAILED(rv) || !stream) - { - NG_ASSERT(0); - nsMemory::Free(tmp); - return SetErrorInfo(E_UNEXPECTED); - } - - postDataStream = stream; - } - } - } - - // Extract the headers parameter - nsCOMPtr headersStream; - if (Headers && - Headers->vt == VT_BSTR && - Headers->bstrVal) - { - - USES_CONVERSION; - char *headers = OLE2A(Headers->bstrVal); - if (headers) - { - size_t nSize = SysStringLen(Headers->bstrVal) + 1; - char *tmp = (char *) nsMemory::Alloc(nSize); // byteArray stream owns this mem - if (tmp) - { - // Copy BSTR to buffer - WideCharToMultiByte(CP_ACP, 0, Headers->bstrVal, nSize - 1, tmp, nSize, NULL, NULL); - tmp[nSize - 1] = '\0'; - - // Create a byte array input stream object which will own the buffer - nsCOMPtr stream; - nsresult rv = - NS_NewByteArrayInputStream(getter_AddRefs(stream), tmp, nSize); - if (NS_FAILED(rv) || !stream) - { - NG_ASSERT(0); - nsMemory::Free(tmp); - } - headersStream = do_QueryInterface(stream); - } - } - } - - // Use the specified target or the top level web navigation - nsCOMPtr webNavToUse; - if (targetNav) - { - webNavToUse = targetNav; - } - else - { - GetWebNavigation(getter_AddRefs(webNavToUse)); - } - - // Load the URL - nsresult rv = NS_ERROR_FAILURE; - if (webNavToUse) - { - rv = webNavToUse->LoadURI(URL, - loadFlags, nsnull, postDataStream, headersStream); - } - - return NS_SUCCEEDED(rv) ? S_OK : E_FAIL; - } - - virtual HRESULT STDMETHODCALLTYPE Refresh(void) - { - NG_TRACE_METHOD(IWebBrowserImpl::Refresh); - // Reload the page - CComVariant vRefreshType(REFRESH_NORMAL); - return Refresh2(&vRefreshType); - } - - virtual HRESULT STDMETHODCALLTYPE Refresh2(VARIANT __RPC_FAR *Level) - { - NG_TRACE_METHOD(IWebBrowserImpl::Refresh2); - - ENSURE_BROWSER_IS_VALID(); - ENSURE_GET_WEBNAV(); - NG_ASSERT_NULL_OR_POINTER(Level, VARIANT); - - // Check the requested refresh type - OLECMDID_REFRESHFLAG iRefreshLevel = OLECMDIDF_REFRESH_NORMAL; - if (Level) - { - CComVariant vLevelAsInt; - if ( vLevelAsInt.ChangeType(VT_I4, Level) != S_OK ) - { - NG_ASSERT(0); - return SetErrorInfo(E_UNEXPECTED); - } - iRefreshLevel = (OLECMDID_REFRESHFLAG) vLevelAsInt.iVal; - } - - // Turn the IE refresh type into the nearest NG equivalent - PRUint32 flags = nsIWebNavigation::LOAD_FLAGS_NONE; - switch (iRefreshLevel & OLECMDIDF_REFRESH_LEVELMASK) - { - case OLECMDIDF_REFRESH_NORMAL: - case OLECMDIDF_REFRESH_IFEXPIRED: - case OLECMDIDF_REFRESH_CONTINUE: - case OLECMDIDF_REFRESH_NO_CACHE: - case OLECMDIDF_REFRESH_RELOAD: - flags = nsIWebNavigation::LOAD_FLAGS_NONE; - break; - case OLECMDIDF_REFRESH_COMPLETELY: - flags = nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE | nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY; - break; - default: - // No idea what refresh type this is supposed to be - NG_ASSERT(0); - return SetErrorInfo(E_UNEXPECTED); - } - - webNav->Reload(flags); - - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE Stop(void) - { - NG_TRACE_METHOD(IWebBrowserImpl::Stop); - ENSURE_BROWSER_IS_VALID(); - ENSURE_GET_WEBNAV(); - webNav->Stop(nsIWebNavigation::STOP_ALL); - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE get_Application(IDispatch __RPC_FAR *__RPC_FAR *ppDisp) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_Application); - ENSURE_BROWSER_IS_VALID(); - if (!ppDisp) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - // Return a pointer to this controls dispatch interface - *ppDisp = (IDispatch *) this; - (*ppDisp)->AddRef(); - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE get_Parent(IDispatch __RPC_FAR *__RPC_FAR *ppDisp) - { - // TODO - return E_NOTIMPL; - } - virtual HRESULT STDMETHODCALLTYPE get_Container(IDispatch __RPC_FAR *__RPC_FAR *ppDisp) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_Container); - ENSURE_BROWSER_IS_VALID(); - if (!ppDisp) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - //TODO: Implement get_Container: Retrieve a pointer to the IDispatch interface of the container. - *ppDisp = NULL; - return SetErrorInfo(E_UNEXPECTED); - } - virtual HRESULT STDMETHODCALLTYPE get_Document(IDispatch __RPC_FAR *__RPC_FAR *ppDisp) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_Document); - ENSURE_BROWSER_IS_VALID(); - if (!ppDisp) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - *ppDisp = NULL; - return E_NOTIMPL; - } - virtual HRESULT STDMETHODCALLTYPE get_TopLevelContainer(VARIANT_BOOL __RPC_FAR *pBool) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_TopLevelContainer); - ENSURE_BROWSER_IS_VALID(); - if (!pBool) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - //TODO: Implement get_TopLevelContainer - *pBool = VARIANT_TRUE; - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_Type(BSTR __RPC_FAR *Type) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_Type); - ENSURE_BROWSER_IS_VALID(); - - //NOTE: This code should work in theory, but can't be verified because GetDoctype - // has not been implemented yet. -#if 0 - nsIDOMDocument *pIDOMDocument = nsnull; - if ( SUCCEEDED(GetDOMDocument(&pIDOMDocument)) ) - { - nsIDOMDocumentType *pIDOMDocumentType = nsnull; - if ( SUCCEEDED(pIDOMDocument->GetDoctype(&pIDOMDocumentType)) ) - { - nsAutoString docName; - pIDOMDocumentType->GetName(docName); - //NG_TRACE("pIDOMDocumentType returns: %s", docName); - //Still need to manipulate docName so that it goes into *Type param of this function. - } - } -#endif - //TODO: Implement get_Type - return SetErrorInfo(E_FAIL, L"get_Type: failed"); - } - - virtual HRESULT STDMETHODCALLTYPE get_Left(long __RPC_FAR *pl) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_Left); - ENSURE_BROWSER_IS_VALID(); - if (pl == NULL) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - - //TODO: Implement get_Left - Should return the left position of this control. - *pl = 0; - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE put_Left(long Left) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_Left); - ENSURE_BROWSER_IS_VALID(); - //TODO: Implement put_Left - Should set the left position of this control. - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE get_Top(long __RPC_FAR *pl) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_Top); - ENSURE_BROWSER_IS_VALID(); - if (pl == NULL) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - //TODO: Implement get_Top - Should return the top position of this control. - *pl = 0; - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE put_Top(long Top) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_Top); - ENSURE_BROWSER_IS_VALID(); - //TODO: Implement set_Top - Should set the top position of this control. - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE get_Width(long __RPC_FAR *pl) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_Width); - ENSURE_BROWSER_IS_VALID(); - //TODO: Implement get_Width- Should return the width of this control. - if (pl == NULL) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - *pl = 0; - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE put_Width(long Width) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_Width); - ENSURE_BROWSER_IS_VALID(); - //TODO: Implement put_Width - Should set the width of this control. - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE get_Height(long __RPC_FAR *pl) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_Height); - ENSURE_BROWSER_IS_VALID(); - if (pl == NULL) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - - //TODO: Implement get_Height - Should return the hieght of this control. - *pl = 0; - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE put_Height(long Height) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_Height); - ENSURE_BROWSER_IS_VALID(); - //TODO: Implement put_Height - Should set the height of this control. - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_LocationName(BSTR __RPC_FAR *LocationName) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_LocationName); - ENSURE_BROWSER_IS_VALID(); - if (LocationName == NULL) - { - return SetErrorInfo(E_INVALIDARG); - } - // Get the url from the web shell - nsXPIDLString szLocationName; - ENSURE_GET_WEBNAV(); - nsCOMPtr baseWindow = do_QueryInterface(webNav); - baseWindow->GetTitle(getter_Copies(szLocationName)); - if (nsnull == (const PRUnichar *) szLocationName) - { - return SetErrorInfo(E_UNEXPECTED); - } - - // Convert the string to a BSTR - USES_CONVERSION; - LPCOLESTR pszConvertedLocationName = W2COLE((const PRUnichar *) szLocationName); - *LocationName = SysAllocString(pszConvertedLocationName); - - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_LocationURL(BSTR __RPC_FAR *LocationURL) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_LocationURL); - ENSURE_BROWSER_IS_VALID(); - - if (LocationURL == NULL) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - nsCOMPtr uri; - // Get the current url from the browser - nsCOMPtr webNav; - GetWebNavigation(getter_AddRefs(webNav)); - if (webNav) - { - webNav->GetCurrentURI(getter_AddRefs(uri)); - } - if (uri) - { - USES_CONVERSION; - nsCAutoString aURI; - uri->GetAsciiSpec(aURI); - *LocationURL = SysAllocString(A2OLE(aURI.get())); - } - else - { - *LocationURL = NULL; - } - - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_Busy(VARIANT_BOOL __RPC_FAR *pBool) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_Busy); - ENSURE_BROWSER_IS_VALID(); - if (!pBool) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - *pBool = (mBusyFlag) ? VARIANT_TRUE : VARIANT_FALSE; - return S_OK; - } - -// IWebBrowserApp implementation - virtual HRESULT STDMETHODCALLTYPE Quit(void) - { - NG_TRACE_METHOD(IWebBrowserImpl::Quit); - ENSURE_BROWSER_IS_VALID(); - - //This generates an exception in the IE control. - // TODO fire quit event - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE ClientToWindow(int __RPC_FAR *pcx, int __RPC_FAR *pcy) - { - NG_TRACE_METHOD(IWebBrowserImpl::ClientToWindow); - ENSURE_BROWSER_IS_VALID(); - - //This generates an exception in the IE control. - // TODO convert points to be relative to browser - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE PutProperty(BSTR Property, VARIANT vtValue) - { - NG_TRACE_METHOD(IWebBrowserImpl::PutProperty); - ENSURE_BROWSER_IS_VALID(); - if (Property == NULL) - { - return SetErrorInfo(E_INVALIDARG); - } - mPropertyList.AddOrReplaceNamedProperty(Property, vtValue); - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE GetProperty(BSTR Property, VARIANT __RPC_FAR *pvtValue) - { - NG_TRACE_METHOD(IWebBrowserImpl::GetProperty); - ENSURE_BROWSER_IS_VALID(); - NG_ASSERT(Property); - NG_ASSERT_POINTER(pvtValue, VARIANT); - if (Property == NULL || pvtValue == NULL) - { - return SetErrorInfo(E_INVALIDARG); - } - VariantInit(pvtValue); - for (unsigned long i = 0; i < mPropertyList.GetSize(); i++) - { - if (wcsicmp(mPropertyList.GetNameOf(i), Property) == 0) - { - // Copy the new value - VariantCopy(pvtValue, const_cast(mPropertyList.GetValueOf(i))); - return S_OK; - } - } - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_Name(BSTR __RPC_FAR *Name) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_Name); - ENSURE_BROWSER_IS_VALID(); - - NG_ASSERT_POINTER(Name, BSTR); - if (Name == NULL) - { - return SetErrorInfo(E_INVALIDARG); - } - - // TODO: Implement get_Name (get Mozilla's executable name) - *Name = SysAllocString(L"Mozilla Web Browser Control"); - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_HWND(long __RPC_FAR *pHWND) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_HWND); - ENSURE_BROWSER_IS_VALID(); - NG_ASSERT_POINTER(pHWND, HWND); - if (pHWND == NULL) - { - return SetErrorInfo(E_INVALIDARG); - } - - //This is supposed to return a handle to the IE main window. Since that doesn't exist - //in the control's case, this shouldn't do anything. - *pHWND = NULL; - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_FullName(BSTR __RPC_FAR *FullName) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_FullName); - ENSURE_BROWSER_IS_VALID(); - - NG_ASSERT_POINTER(FullName, BSTR); - if (FullName == NULL) - { - return SetErrorInfo(E_INVALIDARG); - } - - // TODO: Implement get_FullName (Return the full path of the executable containing this control) - *FullName = SysAllocString(L""); // TODO get Mozilla's executable name - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_Path(BSTR __RPC_FAR *Path) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_Path); - ENSURE_BROWSER_IS_VALID(); - - NG_ASSERT_POINTER(Path, BSTR); - if (Path == NULL) - { - return SetErrorInfo(E_INVALIDARG); - } - - // TODO: Implement get_Path (get Mozilla's path) - *Path = SysAllocString(L""); - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_Visible(VARIANT_BOOL __RPC_FAR *pBool) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_Visible); - ENSURE_BROWSER_IS_VALID(); - - NG_ASSERT_POINTER(pBool, VARIANT_BOOL); - if (pBool == NULL) - { - return SetErrorInfo(E_INVALIDARG); - } - - //TODO: Implement get_Visible? - *pBool = VARIANT_TRUE; - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE put_Visible(VARIANT_BOOL Value) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_Visible); - ENSURE_BROWSER_IS_VALID(); - - //TODO: Implement put_Visible? - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_StatusBar(VARIANT_BOOL __RPC_FAR *pBool) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_StatusBar); - ENSURE_BROWSER_IS_VALID(); - NG_ASSERT_POINTER(pBool, int); - if (pBool == NULL) - { - return SetErrorInfo(E_INVALIDARG); - } - //There is no StatusBar in this control. - *pBool = VARIANT_FALSE; - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE put_StatusBar(VARIANT_BOOL Value) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_StatusBar); - ENSURE_BROWSER_IS_VALID(); - //There is no StatusBar in this control. - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_StatusText(BSTR __RPC_FAR *StatusText) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_StatusText); - ENSURE_BROWSER_IS_VALID(); - NG_ASSERT_POINTER(StatusText, BSTR); - if (StatusText == NULL) - { - return SetErrorInfo(E_INVALIDARG); - } - - //TODO: Implement get_StatusText - //NOTE: This function is related to the MS status bar which doesn't exist in this control. Needs more - // investigation, but probably doesn't apply. - *StatusText = SysAllocString(L""); - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE put_StatusText(BSTR StatusText) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_StatusText); - ENSURE_BROWSER_IS_VALID(); - //TODO: Implement put_StatusText - //NOTE: This function is related to the MS status bar which doesn't exist in this control. Needs more - // investigation, but probably doesn't apply. - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_ToolBar(int __RPC_FAR *Value) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_ToolBar); - ENSURE_BROWSER_IS_VALID(); - NG_ASSERT_POINTER(Value, int); - if (Value == NULL) - { - return SetErrorInfo(E_INVALIDARG); - } - - //There is no ToolBar in this control. - *Value = FALSE; - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE put_ToolBar(int Value) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_ToolBar); - ENSURE_BROWSER_IS_VALID(); - //There is no ToolBar in this control. - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_MenuBar(VARIANT_BOOL __RPC_FAR *Value) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_MenuBar); - ENSURE_BROWSER_IS_VALID(); - NG_ASSERT_POINTER(Value, int); - if (Value == NULL) - { - return SetErrorInfo(E_INVALIDARG); - } - - //There is no MenuBar in this control. - *Value = VARIANT_FALSE; - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE put_MenuBar(VARIANT_BOOL Value) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_MenuBar); - ENSURE_BROWSER_IS_VALID(); - //There is no MenuBar in this control. - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_FullScreen(VARIANT_BOOL __RPC_FAR *pbFullScreen) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_FullScreen); - ENSURE_BROWSER_IS_VALID(); - NG_ASSERT_POINTER(pbFullScreen, VARIANT_BOOL); - if (pbFullScreen == NULL) - { - return SetErrorInfo(E_INVALIDARG); - } - - //FullScreen mode doesn't really apply to this control. - *pbFullScreen = VARIANT_FALSE; - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE put_FullScreen(VARIANT_BOOL bFullScreen) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_FullScreen); - ENSURE_BROWSER_IS_VALID(); - //FullScreen mode doesn't really apply to this control. - return S_OK; - } - -// IWebBrowser2 implementation - virtual HRESULT STDMETHODCALLTYPE Navigate2(VARIANT __RPC_FAR *URL, VARIANT __RPC_FAR *Flags, VARIANT __RPC_FAR *TargetFrameName, VARIANT __RPC_FAR *PostData, VARIANT __RPC_FAR *Headers) - { - NG_TRACE_METHOD(IWebBrowserImpl::Navigate2); - CComVariant vURLAsString; - if (vURLAsString.ChangeType(VT_BSTR, URL) != S_OK) - { - return SetErrorInfo(E_INVALIDARG); - } - return Navigate(vURLAsString.bstrVal, Flags, TargetFrameName, PostData, Headers); - } - - virtual HRESULT STDMETHODCALLTYPE QueryStatusWB(OLECMDID cmdID, OLECMDF __RPC_FAR *pcmdf) - { - NG_TRACE_METHOD(IWebBrowserImpl::QueryStatusWB); - ENSURE_BROWSER_IS_VALID(); - if (pcmdf == NULL) - { - return SetErrorInfo(E_INVALIDARG); - } - // Call through to IOleCommandTarget::QueryStatus - CComQIPtr cmdTarget = this; - if (cmdTarget) - { - OLECMD cmd; - HRESULT hr; - - cmd.cmdID = cmdID; - cmd.cmdf = 0; - hr = cmdTarget->QueryStatus(NULL, 1, &cmd, NULL); - if (SUCCEEDED(hr)) - { - *pcmdf = (OLECMDF) cmd.cmdf; - } - return hr; - } - return E_NOTIMPL; - } - - virtual HRESULT STDMETHODCALLTYPE ExecWB(OLECMDID cmdID, OLECMDEXECOPT cmdexecopt, VARIANT __RPC_FAR *pvaIn, VARIANT __RPC_FAR *pvaOut) - { - NG_TRACE_METHOD(IWebBrowserImpl::ExecWB); - ENSURE_BROWSER_IS_VALID(); - // Call through to IOleCommandTarget::Exec - CComQIPtr cmdTarget = this; - if (cmdTarget) - { - return cmdTarget->Exec(NULL, cmdID, cmdexecopt, pvaIn, pvaOut); - } - return E_NOTIMPL; - } - - virtual HRESULT STDMETHODCALLTYPE ShowBrowserBar(VARIANT __RPC_FAR *pvaClsid, VARIANT __RPC_FAR *pvarShow, VARIANT __RPC_FAR *pvarSize) - { - NG_TRACE_METHOD(IWebBrowserImpl::ShowBrowserBar); - ENSURE_BROWSER_IS_VALID(); - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_ReadyState(READYSTATE __RPC_FAR *plReadyState) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_ReadyState); - // Note: may be called when browser is not yet initialized so there - // is no validity check here. - if (plReadyState == NULL) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - *plReadyState = mBrowserReadyState; - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_Offline(VARIANT_BOOL __RPC_FAR *pbOffline) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_Offline); - ENSURE_BROWSER_IS_VALID(); - if (pbOffline == NULL) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - //TODO: Implement get_Offline - *pbOffline = VARIANT_FALSE; - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE put_Offline(VARIANT_BOOL bOffline) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_Offline); - ENSURE_BROWSER_IS_VALID(); - //TODO: Implement get_Offline - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_Silent(VARIANT_BOOL __RPC_FAR *pbSilent) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_Silent); - ENSURE_BROWSER_IS_VALID(); - if (pbSilent == NULL) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - //Only really applies to the IE app, not a control - *pbSilent = VARIANT_FALSE; - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE put_Silent(VARIANT_BOOL bSilent) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_Silent); - ENSURE_BROWSER_IS_VALID(); - //Only really applies to the IE app, not a control - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_RegisterAsBrowser(VARIANT_BOOL __RPC_FAR *pbRegister) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_RegisterAsBrowser); - ENSURE_BROWSER_IS_VALID(); - - if (pbRegister == NULL) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - //TODO: Implement get_RegisterAsBrowser - *pbRegister = VARIANT_FALSE; - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE put_RegisterAsBrowser(VARIANT_BOOL bRegister) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_RegisterAsBrowser); - ENSURE_BROWSER_IS_VALID(); - //TODO: Implement put_RegisterAsBrowser - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_RegisterAsDropTarget(VARIANT_BOOL __RPC_FAR *pbRegister) - { - // TODO - return E_NOTIMPL; - } - virtual HRESULT STDMETHODCALLTYPE put_RegisterAsDropTarget(VARIANT_BOOL bRegister) - { - // TODO - return E_NOTIMPL; - } - - virtual HRESULT STDMETHODCALLTYPE get_TheaterMode(VARIANT_BOOL __RPC_FAR *pbRegister) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_TheaterMode); - ENSURE_BROWSER_IS_VALID(); - if (pbRegister == NULL) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - // TheaterMode doesn't apply to this control. - *pbRegister = VARIANT_FALSE; - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE put_TheaterMode(VARIANT_BOOL bRegister) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_TheaterMode); - ENSURE_BROWSER_IS_VALID(); - //There is no TheaterMode in this control. - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_AddressBar(VARIANT_BOOL __RPC_FAR *Value) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_AddressBar); - ENSURE_BROWSER_IS_VALID(); - if (Value == NULL) - { - return SetErrorInfo(E_INVALIDARG); - } - //There is no AddressBar in this control. - *Value = VARIANT_FALSE; - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE put_AddressBar(VARIANT_BOOL Value) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_AddressBar); - ENSURE_BROWSER_IS_VALID(); - //There is no AddressBar in this control. - return S_OK; - } - - virtual HRESULT STDMETHODCALLTYPE get_Resizable(VARIANT_BOOL __RPC_FAR *Value) - { - NG_TRACE_METHOD(IWebBrowserImpl::get_Resizable); - ENSURE_BROWSER_IS_VALID(); - if (Value == NULL) - { - NG_ASSERT(0); - return SetErrorInfo(E_INVALIDARG); - } - //TODO: Not sure if this should actually be implemented or not. - *Value = VARIANT_TRUE; - return S_OK; - } - virtual HRESULT STDMETHODCALLTYPE put_Resizable(VARIANT_BOOL Value) - { - NG_TRACE_METHOD(IWebBrowserImpl::put_Resizable); - ENSURE_BROWSER_IS_VALID(); - //TODO: Not sure if this should actually be implemented or not. - return S_OK; - } -}; - -#endif diff --git a/embedding/browser/activex/src/control/ItemContainer.cpp b/embedding/browser/activex/src/control/ItemContainer.cpp deleted file mode 100644 index 1f14ea152b64..000000000000 --- a/embedding/browser/activex/src/control/ItemContainer.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "stdafx.h" - -CItemContainer::CItemContainer() -{ -} - -CItemContainer::~CItemContainer() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -// IParseDisplayName implementation - - -HRESULT STDMETHODCALLTYPE CItemContainer::ParseDisplayName(/* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ LPOLESTR pszDisplayName, /* [out] */ ULONG __RPC_FAR *pchEaten, /* [out] */ IMoniker __RPC_FAR *__RPC_FAR *ppmkOut) -{ - // TODO - return E_NOTIMPL; -} - - -/////////////////////////////////////////////////////////////////////////////// -// IOleContainer implementation - - -HRESULT STDMETHODCALLTYPE CItemContainer::EnumObjects(/* [in] */ DWORD grfFlags, /* [out] */ IEnumUnknown __RPC_FAR *__RPC_FAR *ppenum) -{ - HRESULT hr = E_NOTIMPL; -/* - if (ppenum == NULL) - { - return E_POINTER; - } - - *ppenum = NULL; - typedef CComObject, CNamedObjectList > > enumunk; - enumunk* p = NULL; - p = new enumunk; - if(p == NULL) - { - return E_OUTOFMEMORY; - } - - hr = p->Init(); - if (SUCCEEDED(hr)) - { - hr = p->QueryInterface(IID_IEnumUnknown, (void**) ppenum); - } - if (FAILED(hRes)) - { - delete p; - } -*/ - return hr; -} - - -HRESULT STDMETHODCALLTYPE CItemContainer::LockContainer(/* [in] */ BOOL fLock) -{ - // TODO - return S_OK; -} - - -/////////////////////////////////////////////////////////////////////////////// -// IOleItemContainer implementation - - -HRESULT STDMETHODCALLTYPE CItemContainer::GetObject(/* [in] */ LPOLESTR pszItem, /* [in] */ DWORD dwSpeedNeeded, /* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ REFIID riid, /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject) -{ - if (pszItem == NULL) - { - return E_INVALIDARG; - } - if (ppvObject == NULL) - { - return E_INVALIDARG; - } - - *ppvObject = NULL; - - return MK_E_NOOBJECT; -} - - -HRESULT STDMETHODCALLTYPE CItemContainer::GetObjectStorage(/* [in] */ LPOLESTR pszItem, /* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ REFIID riid, /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvStorage) -{ - // TODO - return MK_E_NOOBJECT; -} - - -HRESULT STDMETHODCALLTYPE CItemContainer::IsRunning(/* [in] */ LPOLESTR pszItem) -{ - // TODO - return MK_E_NOOBJECT; -} diff --git a/embedding/browser/activex/src/control/ItemContainer.h b/embedding/browser/activex/src/control/ItemContainer.h deleted file mode 100644 index b9d030c2a5cc..000000000000 --- a/embedding/browser/activex/src/control/ItemContainer.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef ITEMCONTAINER_H -#define ITEMCONTAINER_H - -// Class for managing a list of named objects. - -class CItemContainer : public CComObjectRootEx, - public IOleItemContainer -{ - // List of all named objects managed by the container - CNamedObjectList m_cObjectList; -public: - - CItemContainer(); - virtual ~CItemContainer(); - -BEGIN_COM_MAP(CItemContainer) - COM_INTERFACE_ENTRY_IID(IID_IParseDisplayName, IOleItemContainer) - COM_INTERFACE_ENTRY_IID(IID_IOleContainer, IOleItemContainer) - COM_INTERFACE_ENTRY_IID(IID_IOleItemContainer, IOleItemContainer) -END_COM_MAP() - - // IParseDisplayName implementation - virtual HRESULT STDMETHODCALLTYPE ParseDisplayName(/* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ LPOLESTR pszDisplayName, /* [out] */ ULONG __RPC_FAR *pchEaten, /* [out] */ IMoniker __RPC_FAR *__RPC_FAR *ppmkOut); - - // IOleContainer implementation - virtual HRESULT STDMETHODCALLTYPE EnumObjects(/* [in] */ DWORD grfFlags, /* [out] */ IEnumUnknown __RPC_FAR *__RPC_FAR *ppenum); - virtual HRESULT STDMETHODCALLTYPE LockContainer(/* [in] */ BOOL fLock); - - // IOleItemContainer implementation - virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetObject(/* [in] */ LPOLESTR pszItem, /* [in] */ DWORD dwSpeedNeeded, /* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ REFIID riid, /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetObjectStorage(/* [in] */ LPOLESTR pszItem, /* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ REFIID riid, /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvStorage); - virtual HRESULT STDMETHODCALLTYPE IsRunning(/* [in] */ LPOLESTR pszItem); -}; - -typedef CComObject CItemContainerInstance; - - -#endif \ No newline at end of file diff --git a/embedding/browser/activex/src/control/PropertyBag.cpp b/embedding/browser/activex/src/control/PropertyBag.cpp deleted file mode 100644 index b303b914205d..000000000000 --- a/embedding/browser/activex/src/control/PropertyBag.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "StdAfx.h" - -#include "PropertyBag.h" - - -CPropertyBag::CPropertyBag() -{ -} - - -CPropertyBag::~CPropertyBag() -{ -} - - -/////////////////////////////////////////////////////////////////////////////// -// IPropertyBag implementation - -HRESULT STDMETHODCALLTYPE CPropertyBag::Read(/* [in] */ LPCOLESTR pszPropName, /* [out][in] */ VARIANT __RPC_FAR *pVar, /* [in] */ IErrorLog __RPC_FAR *pErrorLog) -{ - if (pszPropName == NULL) - { - return E_INVALIDARG; - } - if (pVar == NULL) - { - return E_INVALIDARG; - } - - VARTYPE vt = pVar->vt; - VariantInit(pVar); - - for (unsigned long i = 0; i < m_PropertyList.GetSize(); i++) - { - if (wcsicmp(m_PropertyList.GetNameOf(i), pszPropName) == 0) - { - const VARIANT *pvSrc = m_PropertyList.GetValueOf(i); - if (!pvSrc) - { - return E_FAIL; - } - CComVariant vNew; - HRESULT hr = (vt == VT_EMPTY) ? - vNew.Copy(pvSrc) : vNew.ChangeType(vt, pvSrc); - if (FAILED(hr)) - { - return E_FAIL; - } - // Copy the new value - vNew.Detach(pVar); - return S_OK; - } - } - - // Property does not exist in the bag - return E_FAIL; -} - - -HRESULT STDMETHODCALLTYPE CPropertyBag::Write(/* [in] */ LPCOLESTR pszPropName, /* [in] */ VARIANT __RPC_FAR *pVar) -{ - if (pszPropName == NULL) - { - return E_INVALIDARG; - } - if (pVar == NULL) - { - return E_INVALIDARG; - } - - CComBSTR bstrName(pszPropName); - m_PropertyList.AddOrReplaceNamedProperty(bstrName, *pVar); - - return S_OK; -} - diff --git a/embedding/browser/activex/src/control/PropertyBag.h b/embedding/browser/activex/src/control/PropertyBag.h deleted file mode 100644 index 43cf5af90159..000000000000 --- a/embedding/browser/activex/src/control/PropertyBag.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Adam Lock - * - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef PROPERTYBAG_H -#define PROPERTYBAG_H - - -// Object wrapper for property list. This class can be set up with a -// list of properties and used to initialise a control with them - -class CPropertyBag : public CComObjectRootEx, - public IPropertyBag -{ - // List of properties in the bag - PropertyList m_PropertyList; - -public: - // Constructor - CPropertyBag(); - // Destructor - virtual ~CPropertyBag(); - -BEGIN_COM_MAP(CPropertyBag) - COM_INTERFACE_ENTRY(IPropertyBag) -END_COM_MAP() - -// IPropertyBag methods - virtual /* [local] */ HRESULT STDMETHODCALLTYPE Read(/* [in] */ LPCOLESTR pszPropName, /* [out][in] */ VARIANT __RPC_FAR *pVar, /* [in] */ IErrorLog __RPC_FAR *pErrorLog); - virtual HRESULT STDMETHODCALLTYPE Write(/* [in] */ LPCOLESTR pszPropName, /* [in] */ VARIANT __RPC_FAR *pVar); -}; - -typedef CComObject CPropertyBagInstance; - -#endif \ No newline at end of file diff --git a/embedding/browser/activex/src/control/PropertyList.h b/embedding/browser/activex/src/control/PropertyList.h deleted file mode 100644 index 4760d998b021..000000000000 --- a/embedding/browser/activex/src/control/PropertyList.h +++ /dev/null @@ -1,158 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Adam Lock - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef PROPERTYLIST_H -#define PROPERTYLIST_H - -// A simple array class for managing name/value pairs typically fed to controls -// during initialization by IPersistPropertyBag - -class PropertyList -{ - struct Property { - BSTR bstrName; - VARIANT vValue; - } *mProperties; - unsigned long mListSize; - unsigned long mMaxListSize; - - bool EnsureMoreSpace() - { - // Ensure enough space exists to accomodate a new item - const unsigned long kGrowBy = 10; - if (!mProperties) - { - mProperties = (Property *) malloc(sizeof(Property) * kGrowBy); - if (!mProperties) - return false; - mMaxListSize = kGrowBy; - } - else if (mListSize == mMaxListSize) - { - Property *pNewProperties; - pNewProperties = (Property *) realloc(mProperties, sizeof(Property) * (mMaxListSize + kGrowBy)); - if (!pNewProperties) - return false; - mProperties = pNewProperties; - mMaxListSize += kGrowBy; - } - return true; - } - -public: - PropertyList() : - mProperties(NULL), - mListSize(0), - mMaxListSize(0) - { - } - ~PropertyList() - { - } - void Clear() - { - if (mProperties) - { - for (unsigned long i = 0; i < mListSize; i++) - { - SysFreeString(mProperties[i].bstrName); // Safe even if NULL - VariantClear(&mProperties[i].vValue); - } - free(mProperties); - mProperties = NULL; - } - mListSize = 0; - mMaxListSize = 0; - } - unsigned long GetSize() const - { - return mListSize; - } - const BSTR GetNameOf(unsigned long nIndex) const - { - if (nIndex > mListSize) - { - return NULL; - } - return mProperties[nIndex].bstrName; - } - const VARIANT *GetValueOf(unsigned long nIndex) const - { - if (nIndex > mListSize) - { - return NULL; - } - return &mProperties[nIndex].vValue; - } - bool AddOrReplaceNamedProperty(const BSTR bstrName, const VARIANT &vValue) - { - if (!bstrName) - return false; - for (unsigned long i = 0; i < GetSize(); i++) - { - // Case insensitive - if (wcsicmp(mProperties[i].bstrName, bstrName) == 0) - { - return SUCCEEDED( - VariantCopy(&mProperties[i].vValue, const_cast(&vValue))); - } - } - return AddNamedProperty(bstrName, vValue); - } - bool AddNamedProperty(const BSTR bstrName, const VARIANT &vValue) - { - if (!bstrName || !EnsureMoreSpace()) - return false; - Property *pProp = &mProperties[mListSize]; - pProp->bstrName = ::SysAllocString(bstrName); - if (!pProp->bstrName) - { - return false; - } - VariantInit(&pProp->vValue); - if (FAILED(VariantCopy(&pProp->vValue, const_cast(&vValue)))) - { - SysFreeString(pProp->bstrName); - return false; - } - mListSize++; - return true; - } -}; - -#endif \ No newline at end of file