Back to index

lightning-sunbird  0.9+nobinonly
IEHtmlNode.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Adam Lock <adamlock@eircom.net>
00024  *   Alexandre Trémon <atremon@elansoftware.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 #ifndef IEHTMLNODE_H
00040 #define IEHTMLNODE_H
00041 
00042 
00043 #include "nsCOMPtr.h"
00044 #include "nsIDOMNode.h"
00045 
00046 // NOTE: Nasty hack in case arcane SDK doesn't define IHTMLDOMNode
00047 #ifndef __IHTMLDOMNode_INTERFACE_DEFINED__
00048 #define __IHTMLDOMNode_INTERFACE_DEFINED__
00049     MIDL_INTERFACE("3050f5da-98b5-11cf-bb82-00aa00bdce0b")
00050     IHTMLDOMNode : public IDispatch
00051     {
00052     public:
00053         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_nodeType( 
00054             /* [out][retval] */ long *p) = 0;
00055         
00056         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_parentNode( 
00057             /* [out][retval] */ IHTMLDOMNode **p) = 0;
00058         
00059         virtual /* [id] */ HRESULT STDMETHODCALLTYPE hasChildNodes( 
00060             /* [out][retval] */ VARIANT_BOOL *fChildren) = 0;
00061         
00062         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_childNodes( 
00063             /* [out][retval] */ IDispatch **p) = 0;
00064         
00065         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_attributes( 
00066             /* [out][retval] */ IDispatch **p) = 0;
00067         
00068         virtual /* [id] */ HRESULT STDMETHODCALLTYPE insertBefore( 
00069             /* [in] */ IHTMLDOMNode *newChild,
00070             /* [in][optional] */ VARIANT refChild,
00071             /* [out][retval] */ IHTMLDOMNode **node) = 0;
00072         
00073         virtual /* [id] */ HRESULT STDMETHODCALLTYPE removeChild( 
00074             /* [in] */ IHTMLDOMNode *oldChild,
00075             /* [out][retval] */ IHTMLDOMNode **node) = 0;
00076         
00077         virtual /* [id] */ HRESULT STDMETHODCALLTYPE replaceChild( 
00078             /* [in] */ IHTMLDOMNode *newChild,
00079             /* [in] */ IHTMLDOMNode *oldChild,
00080             /* [out][retval] */ IHTMLDOMNode **node) = 0;
00081         
00082         virtual /* [id] */ HRESULT STDMETHODCALLTYPE cloneNode( 
00083             /* [in] */ VARIANT_BOOL fDeep,
00084             /* [out][retval] */ IHTMLDOMNode **clonedNode) = 0;
00085         
00086         virtual /* [id] */ HRESULT STDMETHODCALLTYPE removeNode( 
00087             /* [in][defaultvalue] */ VARIANT_BOOL fDeep,
00088             /* [out][retval] */ IHTMLDOMNode **removed) = 0;
00089         
00090         virtual /* [id] */ HRESULT STDMETHODCALLTYPE swapNode( 
00091             /* [in] */ IHTMLDOMNode *otherNode,
00092             /* [out][retval] */ IHTMLDOMNode **swappedNode) = 0;
00093         
00094         virtual /* [id] */ HRESULT STDMETHODCALLTYPE replaceNode( 
00095             /* [in] */ IHTMLDOMNode *replacement,
00096             /* [out][retval] */ IHTMLDOMNode **replaced) = 0;
00097         
00098         virtual /* [id] */ HRESULT STDMETHODCALLTYPE appendChild( 
00099             /* [in] */ IHTMLDOMNode *newChild,
00100             /* [out][retval] */ IHTMLDOMNode **node) = 0;
00101         
00102         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_nodeName( 
00103             /* [out][retval] */ BSTR *p) = 0;
00104         
00105         virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_nodeValue( 
00106             /* [in] */ VARIANT v) = 0;
00107         
00108         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_nodeValue( 
00109             /* [out][retval] */ VARIANT *p) = 0;
00110         
00111         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_firstChild( 
00112             /* [out][retval] */ IHTMLDOMNode **p) = 0;
00113         
00114         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_lastChild( 
00115             /* [out][retval] */ IHTMLDOMNode **p) = 0;
00116         
00117         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_previousSibling( 
00118             /* [out][retval] */ IHTMLDOMNode **p) = 0;
00119         
00120         virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_nextSibling( 
00121             /* [out][retval] */ IHTMLDOMNode **p) = 0;
00122         
00123     };
00124 #endif
00125 
00126 class CNode :
00127     public CComObjectRootEx<CComMultiThreadModel>
00128 {
00129 protected:
00130     CNode();
00131     virtual ~CNode();
00132 
00133 public:
00134     CNode *mParent;
00135     nsCOMPtr<nsIDOMNode> mDOMNode;
00136 
00137     static HRESULT FindFromDOMNode(nsIDOMNode *pIDOMNode, CNode **pNode);
00138     virtual HRESULT SetParent(CNode *pParent);
00139     virtual HRESULT SetDOMNode(nsIDOMNode *pIDOMNode);
00140 };
00141 
00142 class CIEHtmlDomNode :
00143     public CNode,
00144     public IDispatchImpl<IHTMLDOMNode, &__uuidof(IHTMLDOMNode), &LIBID_MSHTML>
00145 {
00146 public:
00147     DECLARE_AGGREGATABLE(CIEHtmlDomNode)
00148     CIEHtmlDomNode();
00149 
00150     static HRESULT FindFromDOMNode(nsIDOMNode *pIDOMNode, IUnknown **pNode);
00151     static HRESULT FindOrCreateFromDOMNode(nsIDOMNode *pIDOMNode, IUnknown **pNode);
00152     static HRESULT CreateFromDOMNode(nsIDOMNode *pIDOMNode, IUnknown **pNode);
00153     virtual HRESULT SetDOMNode(nsIDOMNode *pIDOMNode);
00154 
00155     DECLARE_GET_CONTROLLING_UNKNOWN()
00156 protected:
00157     virtual ~CIEHtmlDomNode();
00158 
00159 public:
00160 
00161 BEGIN_COM_MAP(CIEHtmlDomNode)
00162     COM_INTERFACE_ENTRY(IDispatch)
00163     COM_INTERFACE_ENTRY(IHTMLDOMNode)
00164     //COM_INTERFACE_ENTRY_FUNC(IID_IHTMLElement, 0, QueryInterfaceOnNode)
00165 END_COM_MAP()
00166 
00167     static HRESULT WINAPI QueryInterfaceOnNode(void* pv, REFIID riid, LPVOID* ppv, DWORD dw);
00168 
00169     //IID_IHTMLDOMNode
00170     virtual HRESULT STDMETHODCALLTYPE get_nodeType(long __RPC_FAR *p);
00171     virtual HRESULT STDMETHODCALLTYPE get_parentNode(IHTMLDOMNode __RPC_FAR *__RPC_FAR *p);
00172     virtual HRESULT STDMETHODCALLTYPE hasChildNodes(VARIANT_BOOL __RPC_FAR *fChildren);
00173     virtual HRESULT STDMETHODCALLTYPE get_childNodes(IDispatch __RPC_FAR *__RPC_FAR *p);
00174     virtual HRESULT STDMETHODCALLTYPE get_attributes(IDispatch __RPC_FAR *__RPC_FAR *p);
00175     virtual HRESULT STDMETHODCALLTYPE insertBefore(IHTMLDOMNode __RPC_FAR *newChild, VARIANT refChild, IHTMLDOMNode __RPC_FAR *__RPC_FAR *node);
00176     virtual HRESULT STDMETHODCALLTYPE removeChild(IHTMLDOMNode __RPC_FAR *oldChild, IHTMLDOMNode __RPC_FAR *__RPC_FAR *node);
00177     virtual HRESULT STDMETHODCALLTYPE replaceChild(IHTMLDOMNode __RPC_FAR *newChild, IHTMLDOMNode __RPC_FAR *oldChild, IHTMLDOMNode __RPC_FAR *__RPC_FAR *node);
00178     virtual HRESULT STDMETHODCALLTYPE cloneNode(VARIANT_BOOL fDeep, IHTMLDOMNode __RPC_FAR *__RPC_FAR *clonedNode);
00179     virtual HRESULT STDMETHODCALLTYPE removeNode(VARIANT_BOOL fDeep, IHTMLDOMNode __RPC_FAR *__RPC_FAR *removed);
00180     virtual HRESULT STDMETHODCALLTYPE swapNode(IHTMLDOMNode __RPC_FAR *otherNode, IHTMLDOMNode __RPC_FAR *__RPC_FAR *swappedNode);
00181     virtual HRESULT STDMETHODCALLTYPE replaceNode(IHTMLDOMNode __RPC_FAR *replacement, IHTMLDOMNode __RPC_FAR *__RPC_FAR *replaced);
00182     virtual HRESULT STDMETHODCALLTYPE appendChild(IHTMLDOMNode __RPC_FAR *newChild, IHTMLDOMNode __RPC_FAR *__RPC_FAR *node);
00183     virtual HRESULT STDMETHODCALLTYPE get_nodeName(BSTR __RPC_FAR *p);
00184     virtual HRESULT STDMETHODCALLTYPE put_nodeValue(VARIANT p);
00185     virtual HRESULT STDMETHODCALLTYPE get_nodeValue(VARIANT __RPC_FAR *p);
00186     virtual HRESULT STDMETHODCALLTYPE get_firstChild(IHTMLDOMNode __RPC_FAR *__RPC_FAR *p);
00187     virtual HRESULT STDMETHODCALLTYPE get_lastChild(IHTMLDOMNode __RPC_FAR *__RPC_FAR *p);
00188     virtual HRESULT STDMETHODCALLTYPE get_previousSibling(IHTMLDOMNode __RPC_FAR *__RPC_FAR *p);
00189     virtual HRESULT STDMETHODCALLTYPE get_nextSibling(IHTMLDOMNode __RPC_FAR *__RPC_FAR *p);
00190 };
00191 
00192 typedef CComObject<CIEHtmlDomNode> CIEHtmlDomNodeInstance;
00193 
00194 #endif