Hans Leidekker : usp10:
Implement and test ScriptStringGetOrder and ScriptString_pcOutChars.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Jan 4 04:45:01 CST 2007
Module: wine
Branch: master
Commit: f152153f15de09acbee08d890f8b8ebab04f5dfe
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f152153f15de09acbee08d890f8b8ebab04f5dfe
Author: Hans Leidekker <hans at it.vu.nl>
Date: Wed Jan 3 12:12:29 2007 +0100
usp10: Implement and test ScriptStringGetOrder and ScriptString_pcOutChars.
---
dlls/usp10/tests/usp10.c | 42 ++++++++++++-----------
dlls/usp10/usp10.c | 80 ++++++++++++++++++++++++++++++++++++++-------
dlls/usp10/usp10.spec | 4 +-
3 files changed, 91 insertions(+), 35 deletions(-)
diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c
index a4d6e6e..42a4da7 100644
--- a/dlls/usp10/tests/usp10.c
+++ b/dlls/usp10/tests/usp10.c
@@ -617,8 +617,8 @@ static void test_ScriptString(HDC hdc)
HRESULT hr;
WCHAR teststr[] = {'T','e','s','t','1',' ','a','2','b','3', '\0'};
- int String = (sizeof(teststr)/sizeof(WCHAR))-1;
- int Glyphs = String * 2 + 16;
+ int len = (sizeof(teststr) / sizeof(WCHAR)) - 1;
+ int Glyphs = len * 2 + 16;
int Charset;
DWORD Flags = SSA_GLYPHS;
int ReqWidth = 100;
@@ -633,49 +633,51 @@ static void test_ScriptString(HDC hdc)
int Y = 100;
UINT Options = 0;
const RECT rc = {0, 50, 100, 100};
- int MinSel = 0;
+ int MinSel = 0;
int MaxSel = 0;
BOOL Disabled = FALSE;
+ const int *clip_len;
+ UINT *order, i;
- LOGFONTA lf;
-
- lstrcpyA(lf.lfFaceName, "Symbol");
- lf.lfHeight = 10;
- lf.lfItalic = 0;
- lf.lfEscapement = 0;
- lf.lfOrientation = 0;
- lf.lfUnderline = 0;
- lf.lfStrikeOut = 0;
- lf.lfWeight = 300;
- lf.lfWidth = 10;
Charset = -1; /* this flag indicates unicode input */
/* Test without hdc to get E_PENDING */
- hr = ScriptStringAnalyse( NULL, teststr, String, Glyphs, Charset, Flags,
+ hr = ScriptStringAnalyse( NULL, teststr, len, Glyphs, Charset, Flags,
ReqWidth, &Control, &State, Dx, &Tabdef,
&InClass, &ssa);
ok(hr == E_PENDING, "ScriptStringAnalyse Stub should return E_PENDING not %08x\n", hr);
/* test with hdc, this should be a valid test */
- hr = ScriptStringAnalyse( hdc, teststr, String, Glyphs, Charset, Flags,
+ hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
ReqWidth, &Control, &State, Dx, &Tabdef,
&InClass, &ssa);
ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
/* test makes sure that a call with a valid pssa still works */
- hr = ScriptStringAnalyse( hdc, teststr, String, Glyphs, Charset, Flags,
+ hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
ReqWidth, &Control, &State, Dx, &Tabdef,
&InClass, &ssa);
ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
ok(ssa != NULL, "ScriptStringAnalyse pssa should not be NULL\n");
- if (hr == 0)
+ if (hr == S_OK)
{
hr = ScriptStringOut(ssa, X, Y, Options, &rc, MinSel, MaxSel, Disabled);
ok(hr == S_OK, "ScriptStringOut should return S_OK not %08x\n", hr);
- hr = ScriptStringFree(&ssa);
- ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
}
+
+ clip_len = ScriptString_pcOutChars(ssa);
+ ok(*clip_len == len, "ScriptString_pcOutChars failed, got %d, expected %d\n", *clip_len, len);
+
+ order = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *clip_len * sizeof(UINT));
+ hr = ScriptStringGetOrder(ssa, order);
+ ok(hr == S_OK, "ScriptStringGetOrder failed, got %08x, expected S_OK\n", hr);
+
+ for (i = 0; i < *clip_len; i++) ok(order[i] == i, "%d: got %d expected %d\n", i, order[i], i);
+ HeapFree(GetProcessHeap(), 0, order);
+
+ hr = ScriptStringFree(&ssa);
+ ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
}
static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c
index ca713bd..3afaadd 100644
--- a/dlls/usp10/usp10.c
+++ b/dlls/usp10/usp10.c
@@ -159,6 +159,7 @@ typedef struct {
typedef struct {
BOOL invalid;
+ int clip_len;
ScriptCache *sc;
int cItems;
int cMaxGlyphs;
@@ -520,19 +521,12 @@ HRESULT WINAPI ScriptItemize(const WCHAR
* ScriptStringAnalyse (USP10.@)
*
*/
-HRESULT WINAPI ScriptStringAnalyse(HDC hdc,
- const void *pString,
- int cString,
- int cGlyphs,
- int iCharset,
- DWORD dwFlags,
- int iReqWidth,
- SCRIPT_CONTROL *psControl,
- SCRIPT_STATE *psState,
- const int *piDx,
- SCRIPT_TABDEF *pTabdef,
- const BYTE *pbInClass,
- SCRIPT_STRING_ANALYSIS *pssa)
+HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString,
+ int cGlyphs, int iCharset, DWORD dwFlags,
+ int iReqWidth, SCRIPT_CONTROL *psControl,
+ SCRIPT_STATE *psState, const int *piDx,
+ SCRIPT_TABDEF *pTabdef, const BYTE *pbInClass,
+ SCRIPT_STRING_ANALYSIS *pssa)
{
HRESULT hr = E_OUTOFMEMORY;
StringAnalysis *analysis = NULL;
@@ -542,12 +536,20 @@ HRESULT WINAPI ScriptStringAnalyse(HDC h
hdc, pString, cString, cGlyphs, iCharset, dwFlags, iReqWidth,
psControl, psState, piDx, pTabdef, pbInClass, pssa);
+ if (iCharset != -1)
+ {
+ FIXME("Only Unicode strings are supported\n");
+ return E_INVALIDARG;
+ }
if (cString < 1 || !pString) return E_INVALIDARG;
if ((dwFlags & SSA_GLYPHS) && !hdc) return E_PENDING;
if (!(analysis = usp_zero_alloc(sizeof(StringAnalysis)))) return E_OUTOFMEMORY;
if (!(analysis->pItem = usp_zero_alloc(num_items * sizeof(SCRIPT_ITEM) + 1))) goto error;
+ /* FIXME: handle clipping */
+ analysis->clip_len = cString;
+
hr = ScriptItemize(pString, cString, num_items, psControl, psState, analysis->pItem,
&analysis->numItems);
@@ -1567,3 +1569,55 @@ const SCRIPT_LOGATTR * WINAPI ScriptStri
if (!analysis) return NULL;
return analysis->logattrs;
}
+
+/***********************************************************************
+ * ScriptString_pcOutChars (USP10.@)
+ *
+ * Retrieve the length of a string after clipping.
+ *
+ * PARAMS
+ * ssa [I] String analysis.
+ *
+ * RETURNS
+ * Success: Pointer to the length.
+ * Failure: NULL
+ */
+const int * WINAPI ScriptString_pcOutChars(SCRIPT_STRING_ANALYSIS ssa)
+{
+ StringAnalysis *analysis = ssa;
+
+ TRACE("(%p)\n", ssa);
+
+ if (!analysis) return NULL;
+ return &analysis->clip_len;
+}
+
+/***********************************************************************
+ * ScriptStringGetOrder (USP10.@)
+ *
+ * Retrieve a glyph order map.
+ *
+ * PARAMS
+ * ssa [I] String analysis.
+ * order [I/O] Array of glyph positions.
+ *
+ * RETURNS
+ * Success: S_OK
+ * Failure: a non-zero HRESULT.
+ */
+HRESULT WINAPI ScriptStringGetOrder(SCRIPT_STRING_ANALYSIS ssa, UINT *order)
+{
+ unsigned int i, j, k;
+ StringAnalysis *analysis = ssa;
+
+ TRACE("(%p)\n", ssa);
+
+ if (!analysis) return S_FALSE;
+
+ /* FIXME: handle RTL scripts */
+ for (i = 0, k = 0; i < analysis->numItems; i++)
+ for (j = 0; j < analysis->glyphs[i].numGlyphs; j++, k++)
+ order[k] = k;
+
+ return S_OK;
+}
diff --git a/dlls/usp10/usp10.spec b/dlls/usp10/usp10.spec
index 8051da2..df07f43 100644
--- a/dlls/usp10/usp10.spec
+++ b/dlls/usp10/usp10.spec
@@ -21,13 +21,13 @@
@ stdcall ScriptStringCPtoX(ptr long long ptr)
@ stdcall ScriptStringFree(ptr)
@ stdcall ScriptStringGetLogicalWidths(ptr ptr)
-@ stub ScriptStringGetOrder
+@ stdcall ScriptStringGetOrder(ptr ptr)
@ stdcall ScriptStringOut(ptr long long long ptr long long long)
@ stdcall ScriptStringValidate(ptr)
@ stdcall ScriptStringXtoCP(ptr long ptr ptr)
@ stdcall ScriptString_pLogAttr(ptr)
@ stdcall ScriptString_pSize(ptr)
-@ stub ScriptString_pcOutChars
+@ stdcall ScriptString_pcOutChars(ptr)
@ stdcall ScriptTextOut(ptr ptr long long long ptr ptr ptr long ptr long ptr ptr ptr)
@ stdcall ScriptXtoCP(long long long ptr ptr ptr ptr ptr ptr)
@ stub UspAllocCache
More information about the wine-cvs
mailing list