ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

htmlbody.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 #include <stdio.h>
00021 
00022 #define COBJMACROS
00023 
00024 #include "windef.h"
00025 #include "winbase.h"
00026 #include "winuser.h"
00027 #include "ole2.h"
00028 
00029 #include "wine/debug.h"
00030 
00031 #include "mshtml_private.h"
00032 
00033 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
00034 
00035 typedef struct {
00036     HTMLTextContainer textcont;
00037 
00038     const IHTMLBodyElementVtbl *lpHTMLBodyElementVtbl;
00039 
00040     ConnectionPoint cp_propnotif;
00041 
00042     nsIDOMHTMLBodyElement *nsbody;
00043 } HTMLBodyElement;
00044 
00045 #define HTMLBODY(x)  (&(x)->lpHTMLBodyElementVtbl)
00046 
00047 static const WCHAR aquaW[] = {'a','q','u','a',0};
00048 static const WCHAR blackW[] = {'b','l','a','c','k',0};
00049 static const WCHAR blueW[] = {'b','l','u','e',0};
00050 static const WCHAR fuchsiaW[] = {'f','u','s','h','s','i','a',0};
00051 static const WCHAR grayW[] = {'g','r','a','y',0};
00052 static const WCHAR greenW[] = {'g','r','e','e','n',0};
00053 static const WCHAR limeW[] = {'l','i','m','e',0};
00054 static const WCHAR maroonW[] = {'m','a','r','o','o','n',0};
00055 static const WCHAR navyW[] = {'n','a','v','y',0};
00056 static const WCHAR oliveW[] = {'o','l','i','v','e',0};
00057 static const WCHAR purpleW[] = {'p','u','r','p','l','e',0};
00058 static const WCHAR redW[] = {'r','e','d',0};
00059 static const WCHAR silverW[] = {'s','i','l','v','e','r',0};
00060 static const WCHAR tealW[] = {'t','e','a','l',0};
00061 static const WCHAR whiteW[] = {'w','h','i','t','e',0};
00062 static const WCHAR yellowW[] = {'y','e','l','l','o','w',0};
00063 
00064 static const struct {
00065     LPCWSTR keyword;
00066     DWORD rgb;
00067 } keyword_table[] = {
00068     {aquaW,     0x00ffff},
00069     {blackW,    0x000000},
00070     {blueW,     0x0000ff},
00071     {fuchsiaW,  0xff00ff},
00072     {grayW,     0x808080},
00073     {greenW,    0x008000},
00074     {limeW,     0x00ff00},
00075     {maroonW,   0x800000},
00076     {navyW,     0x000080},
00077     {oliveW,    0x808000},
00078     {purpleW,   0x800080},
00079     {redW,      0xff0000},
00080     {silverW,   0xc0c0c0},
00081     {tealW,     0x008080},
00082     {whiteW,    0xffffff},
00083     {yellowW,   0xffff00}
00084 };
00085 
00086 static int comp_value(const WCHAR *ptr, int dpc)
00087 {
00088     int ret = 0;
00089     WCHAR ch;
00090 
00091     if(dpc > 2)
00092         dpc = 2;
00093 
00094     while(dpc--) {
00095         if(!*ptr)
00096             ret *= 16;
00097         else if(isdigitW(ch = *ptr++))
00098             ret = ret*16 + (ch-'0');
00099         else if('a' <= ch && ch <= 'f')
00100             ret = ret*16 + (ch-'a') + 10;
00101         else if('A' <= ch && ch <= 'F')
00102             ret = ret*16 + (ch-'A') + 10;
00103         else
00104             ret *= 16;
00105     }
00106 
00107     return ret;
00108 }
00109 
00110 /* Based on Gecko NS_LooseHexToRGB */
00111 static int loose_hex_to_rgb(const WCHAR *hex)
00112 {
00113     int len, dpc;
00114 
00115     len = strlenW(hex);
00116     if(*hex == '#') {
00117         hex++;
00118         len--;
00119     }
00120     if(len <= 3)
00121         return 0;
00122 
00123     dpc = min(len/3 + (len%3 ? 1 : 0), 4);
00124     return (comp_value(hex, dpc) << 16)
00125         | (comp_value(hex+dpc, dpc) << 8)
00126         | comp_value(hex+2*dpc, dpc);
00127 }
00128 
00129 static HRESULT nscolor_to_str(LPCWSTR color, BSTR *ret)
00130 {
00131     int i, rgb = -1;
00132 
00133     static const WCHAR formatW[] = {'#','%','0','2','x','%','0','2','x','%','0','2','x',0};
00134 
00135     if(!color || !*color) {
00136         *ret = NULL;
00137         return S_OK;
00138     }
00139 
00140     if(*color != '#') {
00141         for(i=0; i < sizeof(keyword_table)/sizeof(keyword_table[0]); i++) {
00142             if(!strcmpiW(color, keyword_table[i].keyword))
00143                 rgb = keyword_table[i].rgb;
00144         }
00145     }
00146     if(rgb == -1)
00147         rgb = loose_hex_to_rgb(color);
00148 
00149     *ret = SysAllocStringLen(NULL, 7);
00150     if(!*ret)
00151         return E_OUTOFMEMORY;
00152 
00153     sprintfW(*ret, formatW, rgb>>16, (rgb>>8)&0xff, rgb&0xff);
00154 
00155     TRACE("%s -> %s\n", debugstr_w(color), debugstr_w(*ret));
00156     return S_OK;
00157 }
00158 
00159 static BOOL variant_to_nscolor(const VARIANT *v, nsAString *nsstr)
00160 {
00161     switch(V_VT(v)) {
00162     case VT_BSTR:
00163         nsAString_Init(nsstr, V_BSTR(v));
00164         return TRUE;
00165 
00166     case VT_I4: {
00167         PRUnichar buf[10];
00168         static const WCHAR formatW[] = {'#','%','x',0};
00169 
00170         wsprintfW(buf, formatW, V_I4(v));
00171         nsAString_Init(nsstr, buf);
00172         return TRUE;
00173     }
00174 
00175     default:
00176         FIXME("invalid vt=%d\n", V_VT(v));
00177     }
00178 
00179     return FALSE;
00180 
00181 }
00182 
00183 static void nscolor_to_variant(const nsAString *nsstr, VARIANT *p)
00184 {
00185     const PRUnichar *color;
00186 
00187     nsAString_GetData(nsstr, &color);
00188 
00189     if(*color == '#') {
00190         V_VT(p) = VT_I4;
00191         V_I4(p) = strtolW(color+1, NULL, 16);
00192     }else {
00193         V_VT(p) = VT_BSTR;
00194         V_BSTR(p) = SysAllocString(color);
00195     }
00196 }
00197 
00198 #define HTMLBODY_THIS(iface) DEFINE_THIS(HTMLBodyElement, HTMLBodyElement, iface)
00199 
00200 static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
00201                                                      REFIID riid, void **ppv)
00202 {
00203     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00204 
00205     return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->textcont.element.node), riid, ppv);
00206 }
00207 
00208 static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface)
00209 {
00210     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00211 
00212     return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->textcont.element.node));
00213 }
00214 
00215 static ULONG WINAPI HTMLBodyElement_Release(IHTMLBodyElement *iface)
00216 {
00217     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00218 
00219     return IHTMLDOMNode_Release(HTMLDOMNODE(&This->textcont.element.node));
00220 }
00221 
00222 static HRESULT WINAPI HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement *iface, UINT *pctinfo)
00223 {
00224     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00225     return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->textcont.element.node.dispex), pctinfo);
00226 }
00227 
00228 static HRESULT WINAPI HTMLBodyElement_GetTypeInfo(IHTMLBodyElement *iface, UINT iTInfo,
00229                                               LCID lcid, ITypeInfo **ppTInfo)
00230 {
00231     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00232     return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->textcont.element.node.dispex), iTInfo, lcid, ppTInfo);
00233 }
00234 
00235 static HRESULT WINAPI HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement *iface, REFIID riid,
00236                                                 LPOLESTR *rgszNames, UINT cNames,
00237                                                 LCID lcid, DISPID *rgDispId)
00238 {
00239     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00240     return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->textcont.element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
00241 }
00242 
00243 static HRESULT WINAPI HTMLBodyElement_Invoke(IHTMLBodyElement *iface, DISPID dispIdMember,
00244                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
00245                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
00246 {
00247     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00248     return IDispatchEx_Invoke(DISPATCHEX(&This->textcont.element.node.dispex), dispIdMember, riid, lcid,
00249             wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
00250 }
00251 
00252 static HRESULT WINAPI HTMLBodyElement_put_background(IHTMLBodyElement *iface, BSTR v)
00253 {
00254     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00255     nsAString nsstr;
00256     nsresult nsres;
00257 
00258     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
00259 
00260     nsAString_InitDepend(&nsstr, v);
00261     nsres = nsIDOMHTMLBodyElement_SetBackground(This->nsbody, &nsstr);
00262     nsAString_Finish(&nsstr);
00263     if(NS_FAILED(nsres))
00264         return E_FAIL;
00265 
00266     return S_OK;
00267 }
00268 
00269 static HRESULT WINAPI HTMLBodyElement_get_background(IHTMLBodyElement *iface, BSTR *p)
00270 {
00271     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00272     nsAString background_str;
00273     nsresult nsres;
00274 
00275     TRACE("(%p)->(%p)\n", This, p);
00276 
00277     nsAString_Init(&background_str, NULL);
00278 
00279     nsres = nsIDOMHTMLBodyElement_GetBackground(This->nsbody, &background_str);
00280     if(NS_SUCCEEDED(nsres)) {
00281         const PRUnichar *background;
00282         nsAString_GetData(&background_str, &background);
00283         *p = *background ? SysAllocString(background) : NULL;
00284     }else {
00285         ERR("GetBackground failed: %08x\n", nsres);
00286         *p = NULL;
00287     }
00288 
00289     nsAString_Finish(&background_str);
00290 
00291     TRACE("*p = %s\n", debugstr_w(*p));
00292     return S_OK;
00293 }
00294 
00295 static HRESULT WINAPI HTMLBodyElement_put_bgProperties(IHTMLBodyElement *iface, BSTR v)
00296 {
00297     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00298     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
00299     return E_NOTIMPL;
00300 }
00301 
00302 static HRESULT WINAPI HTMLBodyElement_get_bgProperties(IHTMLBodyElement *iface, BSTR *p)
00303 {
00304     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00305     FIXME("(%p)->(%p)\n", This, p);
00306     return E_NOTIMPL;
00307 }
00308 
00309 static HRESULT WINAPI HTMLBodyElement_put_leftMargin(IHTMLBodyElement *iface, VARIANT v)
00310 {
00311     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00312     FIXME("(%p)->()\n", This);
00313     return E_NOTIMPL;
00314 }
00315 
00316 static HRESULT WINAPI HTMLBodyElement_get_leftMargin(IHTMLBodyElement *iface, VARIANT *p)
00317 {
00318     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00319     FIXME("(%p)->(%p)\n", This, p);
00320     return E_NOTIMPL;
00321 }
00322 
00323 static HRESULT WINAPI HTMLBodyElement_put_topMargin(IHTMLBodyElement *iface, VARIANT v)
00324 {
00325     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00326     FIXME("(%p)->()\n", This);
00327     return E_NOTIMPL;
00328 }
00329 
00330 static HRESULT WINAPI HTMLBodyElement_get_topMargin(IHTMLBodyElement *iface, VARIANT *p)
00331 {
00332     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00333     FIXME("(%p)->(%p)\n", This, p);
00334     return E_NOTIMPL;
00335 }
00336 
00337 static HRESULT WINAPI HTMLBodyElement_put_rightMargin(IHTMLBodyElement *iface, VARIANT v)
00338 {
00339     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00340     FIXME("(%p)->()\n", This);
00341     return E_NOTIMPL;
00342 }
00343 
00344 static HRESULT WINAPI HTMLBodyElement_get_rightMargin(IHTMLBodyElement *iface, VARIANT *p)
00345 {
00346     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00347     FIXME("(%p)->(%p)\n", This, p);
00348     return E_NOTIMPL;
00349 }
00350 
00351 static HRESULT WINAPI HTMLBodyElement_put_bottomMargin(IHTMLBodyElement *iface, VARIANT v)
00352 {
00353     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00354     FIXME("(%p)->()\n", This);
00355     return E_NOTIMPL;
00356 }
00357 
00358 static HRESULT WINAPI HTMLBodyElement_get_bottomMargin(IHTMLBodyElement *iface, VARIANT *p)
00359 {
00360     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00361     FIXME("(%p)->(%p)\n", This, p);
00362     return E_NOTIMPL;
00363 }
00364 
00365 static HRESULT WINAPI HTMLBodyElement_put_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL v)
00366 {
00367     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00368     FIXME("(%p)->(%x)\n", This, v);
00369     return E_NOTIMPL;
00370 }
00371 
00372 static HRESULT WINAPI HTMLBodyElement_get_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL *p)
00373 {
00374     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00375     FIXME("(%p)->(%p)\n", This, p);
00376     return E_NOTIMPL;
00377 }
00378 
00379 static HRESULT WINAPI HTMLBodyElement_put_bgColor(IHTMLBodyElement *iface, VARIANT v)
00380 {
00381     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00382     nsAString strColor;
00383     nsresult nsres;
00384 
00385     TRACE("(%p)->()\n", This);
00386 
00387     if(!variant_to_nscolor(&v, &strColor))
00388         return S_OK;
00389 
00390     nsres = nsIDOMHTMLBodyElement_SetBgColor(This->nsbody, &strColor);
00391     nsAString_Finish(&strColor);
00392     if(NS_FAILED(nsres))
00393         ERR("SetBgColor failed: %08x\n", nsres);
00394 
00395     return S_OK;
00396 }
00397 
00398 static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIANT *p)
00399 {
00400     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00401     nsAString strColor;
00402     nsresult nsres;
00403     HRESULT hres;
00404 
00405     TRACE("(%p)->(%p)\n", This, p);
00406 
00407     nsAString_Init(&strColor, NULL);
00408     nsres = nsIDOMHTMLBodyElement_GetBgColor(This->nsbody, &strColor);
00409     if(NS_SUCCEEDED(nsres)) {
00410         const PRUnichar *color;
00411 
00412         nsAString_GetData(&strColor, &color);
00413         V_VT(p) = VT_BSTR;
00414         hres = nscolor_to_str(color, &V_BSTR(p));
00415     }else {
00416         ERR("SetBgColor failed: %08x\n", nsres);
00417         hres = E_FAIL;
00418     }
00419 
00420     nsAString_Finish(&strColor);
00421     return hres;
00422 }
00423 
00424 static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v)
00425 {
00426     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00427     nsAString text;
00428     nsresult nsres;
00429 
00430     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
00431 
00432     if(!variant_to_nscolor(&v, &text))
00433         return S_OK;
00434 
00435     nsres = nsIDOMHTMLBodyElement_SetText(This->nsbody, &text);
00436     nsAString_Finish(&text);
00437     if(NS_FAILED(nsres)) {
00438         ERR("SetText failed: %08x\n", nsres);
00439         return E_FAIL;
00440     }
00441 
00442     return S_OK;
00443 }
00444 
00445 static HRESULT WINAPI HTMLBodyElement_get_text(IHTMLBodyElement *iface, VARIANT *p)
00446 {
00447     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00448     nsAString text;
00449     nsresult nsres;
00450     HRESULT hres;
00451 
00452     TRACE("(%p)->(%p)\n", This, p);
00453 
00454     nsAString_Init(&text, NULL);
00455     nsres = nsIDOMHTMLBodyElement_GetText(This->nsbody, &text);
00456     if(NS_SUCCEEDED(nsres)) {
00457         const PRUnichar *color;
00458 
00459         nsAString_GetData(&text, &color);
00460         V_VT(p) = VT_BSTR;
00461         hres = nscolor_to_str(color, &V_BSTR(p));
00462     }else {
00463         ERR("GetText failed: %08x\n", nsres);
00464         hres = E_FAIL;
00465     }
00466 
00467     nsAString_Finish(&text);
00468 
00469     return hres;
00470 }
00471 
00472 static HRESULT WINAPI HTMLBodyElement_put_link(IHTMLBodyElement *iface, VARIANT v)
00473 {
00474     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00475     nsAString link_str;
00476     nsresult nsres;
00477 
00478     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
00479 
00480     if(!variant_to_nscolor(&v, &link_str))
00481         return S_OK;
00482 
00483     nsres = nsIDOMHTMLBodyElement_SetLink(This->nsbody, &link_str);
00484     nsAString_Finish(&link_str);
00485     if(NS_FAILED(nsres))
00486         ERR("SetLink failed: %08x\n", nsres);
00487 
00488     return S_OK;
00489 }
00490 
00491 static HRESULT WINAPI HTMLBodyElement_get_link(IHTMLBodyElement *iface, VARIANT *p)
00492 {
00493     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00494     nsAString link_str;
00495     nsresult nsres;
00496 
00497     TRACE("(%p)->(%p)\n", This, p);
00498 
00499     nsAString_Init(&link_str, NULL);
00500     nsres = nsIDOMHTMLBodyElement_GetLink(This->nsbody, &link_str);
00501     if(NS_FAILED(nsres))
00502         ERR("GetLink failed: %08x\n", nsres);
00503 
00504     nscolor_to_variant(&link_str, p);
00505     nsAString_Finish(&link_str);
00506 
00507     return S_OK;
00508 }
00509 
00510 static HRESULT WINAPI HTMLBodyElement_put_vLink(IHTMLBodyElement *iface, VARIANT v)
00511 {
00512     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00513     nsAString vlink_str;
00514     nsresult nsres;
00515 
00516     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
00517 
00518     if(!variant_to_nscolor(&v, &vlink_str))
00519         return S_OK;
00520 
00521     nsres = nsIDOMHTMLBodyElement_SetVLink(This->nsbody, &vlink_str);
00522     nsAString_Finish(&vlink_str);
00523     if(NS_FAILED(nsres))
00524         ERR("SetLink failed: %08x\n", nsres);
00525 
00526     return S_OK;
00527 }
00528 
00529 static HRESULT WINAPI HTMLBodyElement_get_vLink(IHTMLBodyElement *iface, VARIANT *p)
00530 {
00531     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00532     nsAString vlink_str;
00533     nsresult nsres;
00534 
00535     TRACE("(%p)->(%p)\n", This, p);
00536 
00537     nsAString_Init(&vlink_str, NULL);
00538     nsres = nsIDOMHTMLBodyElement_GetVLink(This->nsbody, &vlink_str);
00539     if(NS_FAILED(nsres))
00540         ERR("GetLink failed: %08x\n", nsres);
00541 
00542     nscolor_to_variant(&vlink_str, p);
00543     nsAString_Finish(&vlink_str);
00544 
00545     return S_OK;
00546 }
00547 
00548 static HRESULT WINAPI HTMLBodyElement_put_aLink(IHTMLBodyElement *iface, VARIANT v)
00549 {
00550     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00551     nsAString alink_str;
00552     nsresult nsres;
00553 
00554     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
00555 
00556     if(!variant_to_nscolor(&v, &alink_str))
00557         return S_OK;
00558 
00559     nsres = nsIDOMHTMLBodyElement_SetALink(This->nsbody, &alink_str);
00560     nsAString_Finish(&alink_str);
00561     if(NS_FAILED(nsres))
00562         ERR("SetALink failed: %08x\n", nsres);
00563 
00564     return S_OK;
00565 }
00566 
00567 static HRESULT WINAPI HTMLBodyElement_get_aLink(IHTMLBodyElement *iface, VARIANT *p)
00568 {
00569     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00570     nsAString alink_str;
00571     nsresult nsres;
00572 
00573     TRACE("(%p)->(%p)\n", This, p);
00574 
00575     nsAString_Init(&alink_str, NULL);
00576     nsres = nsIDOMHTMLBodyElement_GetALink(This->nsbody, &alink_str);
00577     if(NS_FAILED(nsres))
00578         ERR("GetALink failed: %08x\n", nsres);
00579 
00580     nscolor_to_variant(&alink_str, p);
00581     nsAString_Finish(&alink_str);
00582 
00583     return S_OK;
00584 }
00585 
00586 static HRESULT WINAPI HTMLBodyElement_put_onload(IHTMLBodyElement *iface, VARIANT v)
00587 {
00588     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00589     FIXME("(%p)->()\n", This);
00590     return E_NOTIMPL;
00591 }
00592 
00593 static HRESULT WINAPI HTMLBodyElement_get_onload(IHTMLBodyElement *iface, VARIANT *p)
00594 {
00595     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00596     FIXME("(%p)->(%p)\n", This, p);
00597     return E_NOTIMPL;
00598 }
00599 
00600 static HRESULT WINAPI HTMLBodyElement_put_onunload(IHTMLBodyElement *iface, VARIANT v)
00601 {
00602     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00603     FIXME("(%p)->()\n", This);
00604     return E_NOTIMPL;
00605 }
00606 
00607 static HRESULT WINAPI HTMLBodyElement_get_onunload(IHTMLBodyElement *iface, VARIANT *p)
00608 {
00609     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00610     FIXME("(%p)->(%p)\n", This, p);
00611     return E_NOTIMPL;
00612 }
00613 
00614 static HRESULT WINAPI HTMLBodyElement_put_scroll(IHTMLBodyElement *iface, BSTR v)
00615 {
00616     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00617     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
00618     return E_NOTIMPL;
00619 }
00620 
00621 static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *p)
00622 {
00623     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00624     FIXME("(%p)->(%p)\n", This, p);
00625     return E_NOTIMPL;
00626 }
00627 
00628 static HRESULT WINAPI HTMLBodyElement_put_onselect(IHTMLBodyElement *iface, VARIANT v)
00629 {
00630     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00631     FIXME("(%p)->()\n", This);
00632     return E_NOTIMPL;
00633 }
00634 
00635 static HRESULT WINAPI HTMLBodyElement_get_onselect(IHTMLBodyElement *iface, VARIANT *p)
00636 {
00637     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00638     FIXME("(%p)->(%p)\n", This, p);
00639     return E_NOTIMPL;
00640 }
00641 
00642 static HRESULT WINAPI HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement *iface, VARIANT v)
00643 {
00644     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00645     FIXME("(%p)->()\n", This);
00646     return E_NOTIMPL;
00647 }
00648 
00649 static HRESULT WINAPI HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement *iface, VARIANT *p)
00650 {
00651     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00652     FIXME("(%p)->(%p)\n", This, p);
00653     return E_NOTIMPL;
00654 }
00655 
00656 static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, IHTMLTxtRange **range)
00657 {
00658     HTMLBodyElement *This = HTMLBODY_THIS(iface);
00659     nsIDOMDocumentRange *nsdocrange;
00660     nsIDOMRange *nsrange = NULL;
00661     nsresult nsres;
00662     HRESULT hres;
00663 
00664     TRACE("(%p)->(%p)\n", This, range);
00665 
00666     if(!This->textcont.element.node.doc->nsdoc) {
00667         WARN("No nsdoc\n");
00668         return E_UNEXPECTED;
00669     }
00670 
00671     nsres = nsIDOMDocument_QueryInterface(This->textcont.element.node.doc->nsdoc, &IID_nsIDOMDocumentRange,
00672             (void**)&nsdocrange);
00673     if(NS_FAILED(nsres)) {
00674         ERR("Could not get nsIDOMDocumentRabge iface: %08x\n", nsres);
00675         return E_FAIL;
00676     }
00677 
00678     nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &nsrange);
00679     if(NS_SUCCEEDED(nsres)) {
00680         nsres = nsIDOMRange_SelectNodeContents(nsrange, This->textcont.element.node.nsnode);
00681         if(NS_FAILED(nsres))
00682             ERR("SelectNodeContents failed: %08x\n", nsres);
00683     }else {
00684         ERR("CreateRange failed: %08x\n", nsres);
00685     }
00686 
00687     nsIDOMDocumentRange_Release(nsdocrange);
00688 
00689     hres = HTMLTxtRange_Create(This->textcont.element.node.doc->basedoc.doc_node, nsrange, range);
00690 
00691     nsIDOMRange_Release(nsrange);
00692     return hres;
00693 }
00694 
00695 #undef HTMLBODY_THIS
00696 
00697 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl = {
00698     HTMLBodyElement_QueryInterface,
00699     HTMLBodyElement_AddRef,
00700     HTMLBodyElement_Release,
00701     HTMLBodyElement_GetTypeInfoCount,
00702     HTMLBodyElement_GetTypeInfo,
00703     HTMLBodyElement_GetIDsOfNames,
00704     HTMLBodyElement_Invoke,
00705     HTMLBodyElement_put_background,
00706     HTMLBodyElement_get_background,
00707     HTMLBodyElement_put_bgProperties,
00708     HTMLBodyElement_get_bgProperties,
00709     HTMLBodyElement_put_leftMargin,
00710     HTMLBodyElement_get_leftMargin,
00711     HTMLBodyElement_put_topMargin,
00712     HTMLBodyElement_get_topMargin,
00713     HTMLBodyElement_put_rightMargin,
00714     HTMLBodyElement_get_rightMargin,
00715     HTMLBodyElement_put_bottomMargin,
00716     HTMLBodyElement_get_bottomMargin,
00717     HTMLBodyElement_put_noWrap,
00718     HTMLBodyElement_get_noWrap,
00719     HTMLBodyElement_put_bgColor,
00720     HTMLBodyElement_get_bgColor,
00721     HTMLBodyElement_put_text,
00722     HTMLBodyElement_get_text,
00723     HTMLBodyElement_put_link,
00724     HTMLBodyElement_get_link,
00725     HTMLBodyElement_put_vLink,
00726     HTMLBodyElement_get_vLink,
00727     HTMLBodyElement_put_aLink,
00728     HTMLBodyElement_get_aLink,
00729     HTMLBodyElement_put_onload,
00730     HTMLBodyElement_get_onload,
00731     HTMLBodyElement_put_onunload,
00732     HTMLBodyElement_get_onunload,
00733     HTMLBodyElement_put_scroll,
00734     HTMLBodyElement_get_scroll,
00735     HTMLBodyElement_put_onselect,
00736     HTMLBodyElement_get_onselect,
00737     HTMLBodyElement_put_onbeforeunload,
00738     HTMLBodyElement_get_onbeforeunload,
00739     HTMLBodyElement_createTextRange
00740 };
00741 
00742 #define HTMLBODY_NODE_THIS(iface) DEFINE_THIS2(HTMLBodyElement, textcont.element.node, iface)
00743 
00744 static HRESULT HTMLBodyElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
00745 {
00746     HTMLBodyElement *This = HTMLBODY_NODE_THIS(iface);
00747 
00748     *ppv = NULL;
00749 
00750     if(IsEqualGUID(&IID_IUnknown, riid)) {
00751         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
00752         *ppv = HTMLBODY(This);
00753     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
00754         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
00755         *ppv = HTMLBODY(This);
00756     }else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) {
00757         TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
00758         *ppv = HTMLBODY(This);
00759     }else if(IsEqualGUID(&IID_IHTMLTextContainer, riid)) {
00760         TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This->textcont, ppv);
00761         *ppv = HTMLTEXTCONT(&This->textcont);
00762     }
00763 
00764     if(*ppv) {
00765         IUnknown_AddRef((IUnknown*)*ppv);
00766         return S_OK;
00767     }
00768 
00769     return HTMLElement_QI(&This->textcont.element.node, riid, ppv);
00770 }
00771 
00772 static void HTMLBodyElement_destructor(HTMLDOMNode *iface)
00773 {
00774     HTMLBodyElement *This = HTMLBODY_NODE_THIS(iface);
00775 
00776     nsIDOMHTMLBodyElement_Release(This->nsbody);
00777 
00778     HTMLElement_destructor(&This->textcont.element.node);
00779 }
00780 
00781 static event_target_t **HTMLBodyElement_get_event_target(HTMLDOMNode *iface)
00782 {
00783     HTMLBodyElement *This = HTMLBODY_NODE_THIS(iface);
00784 
00785     return This->textcont.element.node.doc
00786         ? &This->textcont.element.node.doc->body_event_target
00787         : &This->textcont.element.node.event_target;
00788 }
00789 
00790 #undef HTMLBODY_NODE_THIS
00791 
00792 static const NodeImplVtbl HTMLBodyElementImplVtbl = {
00793     HTMLBodyElement_QI,
00794     HTMLBodyElement_destructor,
00795     HTMLBodyElement_get_event_target
00796 };
00797 
00798 static const tid_t HTMLBodyElement_iface_tids[] = {
00799     IHTMLBodyElement_tid,
00800     IHTMLBodyElement2_tid,
00801     HTMLELEMENT_TIDS,
00802     IHTMLTextContainer_tid,
00803     IHTMLUniqueName_tid,
00804     0
00805 };
00806 
00807 static dispex_static_data_t HTMLBodyElement_dispex = {
00808     NULL,
00809     DispHTMLBody_tid,
00810     NULL,
00811     HTMLBodyElement_iface_tids
00812 };
00813 
00814 HTMLElement *HTMLBodyElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
00815 {
00816     HTMLBodyElement *ret = heap_alloc_zero(sizeof(HTMLBodyElement));
00817     nsresult nsres;
00818 
00819     TRACE("(%p)->(%p)\n", ret, nselem);
00820 
00821     ret->lpHTMLBodyElementVtbl = &HTMLBodyElementVtbl;
00822     ret->textcont.element.node.vtbl = &HTMLBodyElementImplVtbl;
00823 
00824     HTMLTextContainer_Init(&ret->textcont, doc, nselem, &HTMLBodyElement_dispex);
00825 
00826     ConnectionPoint_Init(&ret->cp_propnotif, &ret->textcont.element.cp_container, &IID_IPropertyNotifySink, NULL);
00827 
00828     nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLBodyElement,
00829                                              (void**)&ret->nsbody);
00830     if(NS_FAILED(nsres))
00831         ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres);
00832 
00833     return &ret->textcont.element;
00834 }

Generated on Fri May 25 2012 04:23:01 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.