Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenselection.c
Go to the documentation of this file.
00001 /* 00002 * Copyright 2006 Jacek Caban for CodeWeavers 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00017 */ 00018 00019 #include <stdarg.h> 00020 00021 #define COBJMACROS 00022 00023 #include "windef.h" 00024 #include "winbase.h" 00025 #include "winuser.h" 00026 #include "ole2.h" 00027 00028 #include "wine/debug.h" 00029 #include "wine/unicode.h" 00030 00031 #include "mshtml_private.h" 00032 00033 WINE_DEFAULT_DEBUG_CHANNEL(mshtml); 00034 00035 typedef struct { 00036 const IHTMLSelectionObjectVtbl *lpHTMLSelectionObjectVtbl; 00037 00038 LONG ref; 00039 00040 nsISelection *nsselection; 00041 HTMLDocumentNode *doc; 00042 00043 struct list entry; 00044 } HTMLSelectionObject; 00045 00046 #define HTMLSELOBJ(x) ((IHTMLSelectionObject*) &(x)->lpHTMLSelectionObjectVtbl) 00047 00048 #define HTMLSELOBJ_THIS(iface) DEFINE_THIS(HTMLSelectionObject, HTMLSelectionObject, iface) 00049 00050 static HRESULT WINAPI HTMLSelectionObject_QueryInterface(IHTMLSelectionObject *iface, 00051 REFIID riid, void **ppv) 00052 { 00053 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface); 00054 00055 *ppv = NULL; 00056 00057 if(IsEqualGUID(&IID_IUnknown, riid)) { 00058 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); 00059 *ppv = HTMLSELOBJ(This); 00060 }else if(IsEqualGUID(&IID_IDispatch, riid)) { 00061 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); 00062 *ppv = HTMLSELOBJ(This); 00063 }else if(IsEqualGUID(&IID_IHTMLSelectionObject, riid)) { 00064 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); 00065 *ppv = HTMLSELOBJ(This); 00066 } 00067 00068 if(*ppv) { 00069 IUnknown_AddRef((IUnknown*)*ppv); 00070 return S_OK; 00071 } 00072 00073 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); 00074 return E_NOINTERFACE; 00075 } 00076 00077 static ULONG WINAPI HTMLSelectionObject_AddRef(IHTMLSelectionObject *iface) 00078 { 00079 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface); 00080 LONG ref = InterlockedIncrement(&This->ref); 00081 00082 TRACE("(%p) ref=%d\n", This, ref); 00083 00084 return ref; 00085 } 00086 00087 static ULONG WINAPI HTMLSelectionObject_Release(IHTMLSelectionObject *iface) 00088 { 00089 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface); 00090 LONG ref = InterlockedDecrement(&This->ref); 00091 00092 TRACE("(%p) ref=%d\n", This, ref); 00093 00094 if(!ref) { 00095 if(This->nsselection) 00096 nsISelection_Release(This->nsselection); 00097 if(This->doc) 00098 list_remove(&This->entry); 00099 heap_free(This); 00100 } 00101 00102 return ref; 00103 } 00104 00105 static HRESULT WINAPI HTMLSelectionObject_GetTypeInfoCount(IHTMLSelectionObject *iface, UINT *pctinfo) 00106 { 00107 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface); 00108 FIXME("(%p)->(%p)\n", This, pctinfo); 00109 return E_NOTIMPL; 00110 } 00111 00112 static HRESULT WINAPI HTMLSelectionObject_GetTypeInfo(IHTMLSelectionObject *iface, UINT iTInfo, 00113 LCID lcid, ITypeInfo **ppTInfo) 00114 { 00115 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface); 00116 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo); 00117 return E_NOTIMPL; 00118 } 00119 00120 static HRESULT WINAPI HTMLSelectionObject_GetIDsOfNames(IHTMLSelectionObject *iface, REFIID riid, 00121 LPOLESTR *rgszNames, UINT cNames, 00122 LCID lcid, DISPID *rgDispId) 00123 { 00124 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface); 00125 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, 00126 lcid, rgDispId); 00127 return E_NOTIMPL; 00128 } 00129 00130 static HRESULT WINAPI HTMLSelectionObject_Invoke(IHTMLSelectionObject *iface, DISPID dispIdMember, 00131 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, 00132 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) 00133 { 00134 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface); 00135 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), 00136 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); 00137 return E_NOTIMPL; 00138 } 00139 00140 static HRESULT WINAPI HTMLSelectionObject_createRange(IHTMLSelectionObject *iface, IDispatch **range) 00141 { 00142 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface); 00143 IHTMLTxtRange *range_obj = NULL; 00144 nsIDOMRange *nsrange = NULL; 00145 HRESULT hres; 00146 00147 TRACE("(%p)->(%p)\n", This, range); 00148 00149 if(This->nsselection) { 00150 PRInt32 nsrange_cnt = 0; 00151 nsresult nsres; 00152 00153 nsISelection_GetRangeCount(This->nsselection, &nsrange_cnt); 00154 if(!nsrange_cnt) { 00155 nsIDOMHTMLElement *nsbody = NULL; 00156 00157 TRACE("nsrange_cnt = 0\n"); 00158 00159 if(!This->doc->nsdoc) { 00160 WARN("nsdoc is NULL\n"); 00161 return E_UNEXPECTED; 00162 } 00163 00164 nsres = nsIDOMHTMLDocument_GetBody(This->doc->nsdoc, &nsbody); 00165 if(NS_FAILED(nsres) || !nsbody) { 00166 ERR("Could not get body: %08x\n", nsres); 00167 return E_FAIL; 00168 } 00169 00170 nsres = nsISelection_Collapse(This->nsselection, (nsIDOMNode*)nsbody, 0); 00171 nsIDOMHTMLElement_Release(nsbody); 00172 if(NS_FAILED(nsres)) 00173 ERR("Collapse failed: %08x\n", nsres); 00174 }else if(nsrange_cnt > 1) { 00175 FIXME("range_cnt = %d\n", nsrange_cnt); 00176 } 00177 00178 nsres = nsISelection_GetRangeAt(This->nsselection, 0, &nsrange); 00179 if(NS_FAILED(nsres)) 00180 ERR("GetRangeAt failed: %08x\n", nsres); 00181 } 00182 00183 hres = HTMLTxtRange_Create(This->doc, nsrange, &range_obj); 00184 00185 if (nsrange) nsIDOMRange_Release(nsrange); 00186 *range = (IDispatch*)range_obj; 00187 return hres; 00188 } 00189 00190 static HRESULT WINAPI HTMLSelectionObject_empty(IHTMLSelectionObject *iface) 00191 { 00192 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface); 00193 FIXME("(%p)\n", This); 00194 return E_NOTIMPL; 00195 } 00196 00197 static HRESULT WINAPI HTMLSelectionObject_clear(IHTMLSelectionObject *iface) 00198 { 00199 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface); 00200 FIXME("(%p)\n", This); 00201 return E_NOTIMPL; 00202 } 00203 00204 static HRESULT WINAPI HTMLSelectionObject_get_type(IHTMLSelectionObject *iface, BSTR *p) 00205 { 00206 HTMLSelectionObject *This = HTMLSELOBJ_THIS(iface); 00207 PRBool collapsed = TRUE; 00208 00209 static const WCHAR wszNone[] = {'N','o','n','e',0}; 00210 static const WCHAR wszText[] = {'T','e','x','t',0}; 00211 00212 TRACE("(%p)->(%p)\n", This, p); 00213 00214 if(This->nsselection) 00215 nsISelection_GetIsCollapsed(This->nsselection, &collapsed); 00216 00217 *p = SysAllocString(collapsed ? wszNone : wszText); /* FIXME: control */ 00218 TRACE("ret %s\n", debugstr_w(*p)); 00219 return S_OK; 00220 } 00221 00222 #undef HTMLSELOBJ_THIS 00223 00224 static const IHTMLSelectionObjectVtbl HTMLSelectionObjectVtbl = { 00225 HTMLSelectionObject_QueryInterface, 00226 HTMLSelectionObject_AddRef, 00227 HTMLSelectionObject_Release, 00228 HTMLSelectionObject_GetTypeInfoCount, 00229 HTMLSelectionObject_GetTypeInfo, 00230 HTMLSelectionObject_GetIDsOfNames, 00231 HTMLSelectionObject_Invoke, 00232 HTMLSelectionObject_createRange, 00233 HTMLSelectionObject_empty, 00234 HTMLSelectionObject_clear, 00235 HTMLSelectionObject_get_type 00236 }; 00237 00238 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode *doc, nsISelection *nsselection, IHTMLSelectionObject **ret) 00239 { 00240 HTMLSelectionObject *selection; 00241 00242 selection = heap_alloc(sizeof(HTMLSelectionObject)); 00243 if(!selection) 00244 return E_OUTOFMEMORY; 00245 00246 selection->lpHTMLSelectionObjectVtbl = &HTMLSelectionObjectVtbl; 00247 selection->ref = 1; 00248 selection->nsselection = nsselection; /* We shouldn't call AddRef here */ 00249 00250 selection->doc = doc; 00251 list_add_head(&doc->selection_list, &selection->entry); 00252 00253 *ret = HTMLSELOBJ(selection); 00254 return S_OK; 00255 } 00256 00257 void detach_selection(HTMLDocumentNode *This) 00258 { 00259 HTMLSelectionObject *iter; 00260 00261 LIST_FOR_EACH_ENTRY(iter, &This->selection_list, HTMLSelectionObject, entry) { 00262 iter->doc = NULL; 00263 } 00264 } Generated on Sat May 26 2012 04:16:04 for ReactOS by
1.7.6.1
|