Module: wine Branch: master Commit: 578260745a25ecbcbd8c40ce5a27796881ab3743 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=578260745a25ecbcbd8c40ce...
Author: Hans Leidekker hans@it.vu.nl Date: Thu Sep 28 17:00:19 2006 +0200
usp10: Add a stub implementation and a test for ScriptLayout.
---
dlls/usp10/tests/usp10.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ dlls/usp10/usp10.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ dlls/usp10/usp10.spec | 2 +- 3 files changed, 95 insertions(+), 1 deletions(-)
diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c index 45a65f2..3fef69a 100644 --- a/dlls/usp10/tests/usp10.c +++ b/dlls/usp10/tests/usp10.c @@ -727,6 +727,52 @@ void test_ScriptGetGlyphABCWidth(HDC hdc ok(hr == S_OK, "expected S_OK, got 0x%08lx\n", hr); }
+void test_ScriptLayout(void) +{ + HRESULT hr; + static const BYTE levels[][5] = + { + { 0, 0, 0, 0, 0 }, + { 1, 1, 1, 1, 1 }, + { 2, 2, 2, 2, 2 }, + { 3, 3, 3, 3, 3 }, + }; + static const int expect[][5] = + { + { 0, 1, 2, 3, 4 }, + { 4, 3, 2, 1, 0 }, + { 0, 1, 2, 3, 4 }, + { 4, 3, 2, 1, 0 } + }; + int i, j, vistolog[sizeof(levels[0])], logtovis[sizeof(levels[0])]; + + hr = ScriptLayout(sizeof(levels[0]), NULL, vistolog, logtovis); + ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08lx\n", hr); + + hr = ScriptLayout(sizeof(levels[0]), levels[0], NULL, NULL); + ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08lx\n", hr); + + for (i = 0; i < sizeof(levels)/sizeof(levels[0]); i++) + { + hr = ScriptLayout(sizeof(levels[0]), levels[i], vistolog, logtovis); + ok(hr == S_OK, "expected S_OK, got 0x%08lx\n", hr); + + for (j = 0; j < sizeof(levels[i]); j++) + { + ok(expect[i][j] == vistolog[j], + "failure: levels[%d][%d] = %d, vistolog[%d] = %d\n", + i, j, levels[i][j], j, vistolog[j] ); + } + + for (j = 0; j < sizeof(levels[i]); j++) + { + ok(expect[i][j] == logtovis[j], + "failure: levels[%d][%d] = %d, logtovis[%d] = %d\n", + i, j, levels[i][j], j, logtovis[j] ); + } + } +} + static const struct { LGRPID group; @@ -1010,6 +1056,7 @@ START_TEST(usp10) test_ScriptTextOut(); test_ScriptXtoX(); test_ScriptString(); + test_ScriptLayout();
test_digit_substitution(); } diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c index e258345..7fca547 100644 --- a/dlls/usp10/usp10.c +++ b/dlls/usp10/usp10.c @@ -1124,3 +1124,50 @@ HRESULT WINAPI ScriptGetGlyphABCWidth(HD
return S_OK; } + +/*********************************************************************** + * ScriptLayout (USP10.@) + * + * Map embedding levels to visual and/or logical order. + * + * PARAMS + * runs [I] Size of level array. + * level [I] Array of embedding levels. + * vistolog [O] Map of embedding levels from visual to logical order. + * logtovis [O] Map of embedding levels from logical to visual order. + * + * RETURNS + * Success: S_OK + * Failure: Non-zero HRESULT value. + * + * BUGS + * This stub works correctly for any sequence of a single + * embedding level but not for sequences of different + * embedding levels, i.e. mixtures of RTL and LTR scripts. + */ +HRESULT WINAPI ScriptLayout(int runs, const BYTE *level, int *vistolog, int *logtovis) +{ + int i, j = runs - 1, k = 0; + + FIXME("(%d, %p, %p, %p): stub\n", runs, level, vistolog, logtovis); + + if (!level || (!vistolog && !logtovis)) + return E_INVALIDARG; + + for (i = 0; i < runs; i++) + { + if (level[i] % 2) + { + if (vistolog) *vistolog++ = j; + if (logtovis) *logtovis++ = j; + j--; + } + else + { + if (vistolog) *vistolog++ = k; + if (logtovis) *logtovis++ = k; + k++; + } + } + return S_OK; +} diff --git a/dlls/usp10/usp10.spec b/dlls/usp10/usp10.spec index 0c9ab51..95a6c77 100644 --- a/dlls/usp10/usp10.spec +++ b/dlls/usp10/usp10.spec @@ -13,7 +13,7 @@ @ stdcall ScriptIsComplex(wstr long long) @ stdcall ScriptItemize(wstr long long ptr ptr ptr ptr) @ stub ScriptJustify -@ stub ScriptLayout +@ stdcall ScriptLayout(long ptr ptr ptr) @ stdcall ScriptPlace(ptr ptr ptr long ptr ptr ptr ptr ptr) @ stdcall ScriptRecordDigitSubstitution(ptr ptr) @ stdcall ScriptShape(ptr ptr ptr long long ptr ptr ptr ptr ptr)