Piotr Caban : jscript: Added String_fontcolor implementation.
Alexandre Julliard
julliard at winehq.org
Fri Jul 10 08:52:05 CDT 2009
Module: wine
Branch: master
Commit: 1133bc7ce846478ec04c97aa54ae585684bc3c6c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1133bc7ce846478ec04c97aa54ae585684bc3c6c
Author: Piotr Caban <piotr.caban at gmail.com>
Date: Thu Jul 9 22:41:27 2009 +0200
jscript: Added String_fontcolor implementation.
---
dlls/jscript/string.c | 54 +++++++++++++++++++++++++++++++++++++++++++-
dlls/jscript/tests/api.js | 13 ++++++++++
2 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c
index 9f2ab9b..927d95a 100644
--- a/dlls/jscript/string.c
+++ b/dlls/jscript/string.c
@@ -150,6 +150,54 @@ static HRESULT do_attributeless_tag_format(DispatchEx *dispex, LCID lcid, WORD f
return S_OK;
}
+static HRESULT do_attribute_tag_format(DispatchEx *dispex, LCID lcid, WORD flags,
+ DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp,
+ const WCHAR *tagname, const WCHAR *attr)
+{
+ static const WCHAR tagfmtW[]
+ = {'<','%','s',' ','%','s','=','\"','%','s','\"','>','%','s','<','/','%','s','>',0};
+ static const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0};
+
+ StringInstance *string;
+ BSTR ret, attr_value;
+ HRESULT hres;
+
+ if(!is_class(dispex, JSCLASS_STRING)) {
+ WARN("this is not a string object\n");
+ return E_NOTIMPL;
+ }
+
+ string = (StringInstance*) dispex;
+
+ if(arg_cnt(dp)) {
+ hres = to_string(dispex->ctx, get_arg(dp, 0), ei, &attr_value);
+ if(FAILED(hres))
+ return hres;
+ }
+ else {
+ attr_value = SysAllocString(undefinedW);
+ if(!attr_value)
+ return E_OUTOFMEMORY;
+ }
+
+ if(retv) {
+ ret = SysAllocStringLen(NULL, string->length + 2*strlenW(tagname)
+ + strlenW(attr) + SysStringLen(attr_value) + 9);
+ if(!ret) {
+ SysFreeString(attr_value);
+ return E_OUTOFMEMORY;
+ }
+
+ sprintfW(ret, tagfmtW, tagname, attr, attr_value, string->str, tagname);
+
+ V_VT(retv) = VT_BSTR;
+ V_BSTR(retv) = ret;
+ }
+
+ SysFreeString(attr_value);
+ return S_OK;
+}
+
static HRESULT String_anchor(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
@@ -336,8 +384,10 @@ static HRESULT String_fixed(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
static HRESULT String_fontcolor(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ static const WCHAR fontW[] = {'F','O','N','T',0};
+ static const WCHAR colorW[] = {'C','O','L','O','R',0};
+
+ return do_attribute_tag_format(dispex, lcid, flags, dp, retv, ei, sp, fontW, colorW);
}
static HRESULT String_fontsize(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 79b255b..2368a4b 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -305,6 +305,19 @@ ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
tmp = "test".fixed(3);
ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
+tmp = "".fontcolor();
+ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
+tmp = "".fontcolor(3);
+ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
+tmp = "".fontcolor("red");
+ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
+tmp = "test".fontcolor();
+ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
+tmp = "test".fontcolor(3);
+ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
+tmp = "test".fontcolor("green");
+ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
+
tmp = "".italics();
ok(tmp === "<I></I>", "''.italics() = " + tmp);
tmp = "".italics(3);
More information about the wine-cvs
mailing list