gdiplus: Implemented Gdip[Get/Set]StringFormatTabStops with tests.
This commit is contained in:
parent
4a08c13ba9
commit
f44034a7d4
|
@ -393,7 +393,7 @@
|
|||
@ stdcall GdipGetStringFormatLineAlign(ptr ptr)
|
||||
@ stdcall GdipGetStringFormatMeasurableCharacterRangeCount(ptr ptr)
|
||||
@ stdcall GdipGetStringFormatTabStopCount(ptr ptr)
|
||||
@ stub GdipGetStringFormatTabStops
|
||||
@ stdcall GdipGetStringFormatTabStops(ptr long ptr ptr)
|
||||
@ stdcall GdipGetStringFormatTrimming(ptr ptr)
|
||||
@ stub GdipGetTextContrast
|
||||
@ stdcall GdipGetTextRenderingHint(ptr ptr)
|
||||
|
@ -591,7 +591,7 @@
|
|||
@ stdcall GdipSetStringFormatHotkeyPrefix(ptr long)
|
||||
@ stdcall GdipSetStringFormatLineAlign(ptr long)
|
||||
@ stdcall GdipSetStringFormatMeasurableCharacterRanges(ptr long ptr)
|
||||
@ stub GdipSetStringFormatTabStops
|
||||
@ stdcall GdipSetStringFormatTabStops(ptr long long ptr)
|
||||
@ stdcall GdipSetStringFormatTrimming(ptr long)
|
||||
@ stub GdipSetTextContrast
|
||||
@ stdcall GdipSetTextRenderingHint(ptr long)
|
||||
|
|
|
@ -153,6 +153,21 @@ GpStatus WINGDIPAPI GdipGetStringFormatTabStopCount(GDIPCONST GpStringFormat *fo
|
|||
return Ok;
|
||||
}
|
||||
|
||||
GpStatus WINGDIPAPI GdipGetStringFormatTabStops(GDIPCONST GpStringFormat *format, INT count,
|
||||
REAL *firsttab, REAL *tabs)
|
||||
{
|
||||
if(!format || !firsttab || !tabs)
|
||||
return InvalidParameter;
|
||||
|
||||
/* native simply crashes on count < 0 */
|
||||
if(count != 0)
|
||||
memcpy(tabs, format->tabs, sizeof(REAL)*count);
|
||||
|
||||
*firsttab = format->firsttab;
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
GpStatus WINGDIPAPI GdipGetStringFormatTrimming(GpStringFormat *format,
|
||||
StringTrimming *trimming)
|
||||
{
|
||||
|
@ -221,6 +236,36 @@ GpStatus WINGDIPAPI GdipSetStringFormatMeasurableCharacterRanges(GpStringFormat*
|
|||
return NotImplemented;
|
||||
}
|
||||
|
||||
GpStatus WINGDIPAPI GdipSetStringFormatTabStops(GpStringFormat *format, REAL firsttab,
|
||||
INT count, GDIPCONST REAL *tabs)
|
||||
{
|
||||
if(!format || !tabs)
|
||||
return InvalidParameter;
|
||||
|
||||
if(count > 0){
|
||||
if(firsttab < 0.0) return NotImplemented;
|
||||
/* first time allocation */
|
||||
if(format->tabcount == 0){
|
||||
format->tabs = GdipAlloc(sizeof(REAL)*count);
|
||||
if(!format->tabs)
|
||||
return OutOfMemory;
|
||||
}
|
||||
/* reallocation */
|
||||
if((format->tabcount < count) && (format->tabcount > 0)){
|
||||
REAL *ptr;
|
||||
ptr = HeapReAlloc(GetProcessHeap(), 0, format->tabs, sizeof(REAL)*count);
|
||||
if(!ptr)
|
||||
return OutOfMemory;
|
||||
format->tabs = ptr;
|
||||
}
|
||||
format->firsttab = firsttab;
|
||||
format->tabcount = count;
|
||||
memcpy(format->tabs, tabs, sizeof(REAL)*count);
|
||||
}
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
GpStatus WINGDIPAPI GdipSetStringFormatTrimming(GpStringFormat *format,
|
||||
StringTrimming trimming)
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "wine/test.h"
|
||||
|
||||
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
|
||||
#define expectf(expected, got) ok(got == expected, "Expected %.2f, got %.2f\n", expected, got)
|
||||
|
||||
static void test_constructor(void)
|
||||
{
|
||||
|
@ -171,11 +172,14 @@ static void test_getgenerictypographic(void)
|
|||
expect(Ok, stat);
|
||||
}
|
||||
|
||||
static REAL tabstops[] = {0.0, 10.0, 2.0};
|
||||
static void test_tabstops(void)
|
||||
{
|
||||
GpStringFormat *format;
|
||||
GpStatus stat;
|
||||
INT count;
|
||||
REAL tabs[3];
|
||||
REAL firsttab;
|
||||
|
||||
stat = GdipCreateStringFormat(0, LANG_NEUTRAL, &format);
|
||||
expect(Ok, stat);
|
||||
|
@ -188,10 +192,86 @@ static void test_tabstops(void)
|
|||
stat = GdipGetStringFormatTabStopCount(format, NULL);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipSetStringFormatTabStops(NULL, 0.0, 0, NULL);
|
||||
expect(InvalidParameter, stat);
|
||||
stat = GdipSetStringFormatTabStops(format, 0.0, 0, NULL);
|
||||
expect(InvalidParameter, stat);
|
||||
stat = GdipSetStringFormatTabStops(NULL, 0.0, 0, tabstops);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipGetStringFormatTabStops(NULL, 0, NULL, NULL);
|
||||
expect(InvalidParameter, stat);
|
||||
stat = GdipGetStringFormatTabStops(format, 0, NULL, NULL);
|
||||
expect(InvalidParameter, stat);
|
||||
stat = GdipGetStringFormatTabStops(NULL, 0, &firsttab, NULL);
|
||||
expect(InvalidParameter, stat);
|
||||
stat = GdipGetStringFormatTabStops(NULL, 0, NULL, tabs);
|
||||
expect(InvalidParameter, stat);
|
||||
stat = GdipGetStringFormatTabStops(format, 0, &firsttab, NULL);
|
||||
expect(InvalidParameter, stat);
|
||||
stat = GdipGetStringFormatTabStops(format, 0, NULL, tabs);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
/* not NULL */
|
||||
stat = GdipGetStringFormatTabStopCount(format, &count);
|
||||
expect(Ok, stat);
|
||||
expect(0, count);
|
||||
/* negative tabcount */
|
||||
stat = GdipSetStringFormatTabStops(format, 0.0, -1, tabstops);
|
||||
expect(Ok, stat);
|
||||
count = -1;
|
||||
stat = GdipGetStringFormatTabStopCount(format, &count);
|
||||
expect(Ok, stat);
|
||||
expect(0, count);
|
||||
|
||||
stat = GdipSetStringFormatTabStops(format, -10.0, 0, tabstops);
|
||||
expect(Ok, stat);
|
||||
stat = GdipSetStringFormatTabStops(format, -10.0, 1, tabstops);
|
||||
expect(NotImplemented, stat);
|
||||
|
||||
firsttab = -1.0;
|
||||
tabs[0] = tabs[1] = tabs[2] = -1.0;
|
||||
stat = GdipGetStringFormatTabStops(format, 0, &firsttab, tabs);
|
||||
expect(Ok, stat);
|
||||
expectf(-1.0, tabs[0]);
|
||||
expectf(-1.0, tabs[1]);
|
||||
expectf(-1.0, tabs[2]);
|
||||
expectf(0.0, firsttab);
|
||||
|
||||
stat = GdipSetStringFormatTabStops(format, +0.0, 3, tabstops);
|
||||
expect(Ok, stat);
|
||||
count = 0;
|
||||
stat = GdipGetStringFormatTabStopCount(format, &count);
|
||||
expect(Ok, stat);
|
||||
expect(3, count);
|
||||
|
||||
firsttab = -1.0;
|
||||
tabs[0] = tabs[1] = tabs[2] = -1.0;
|
||||
stat = GdipGetStringFormatTabStops(format, 3, &firsttab, tabs);
|
||||
expect(Ok, stat);
|
||||
expectf(0.0, tabs[0]);
|
||||
expectf(10.0, tabs[1]);
|
||||
expectf(2.0, tabs[2]);
|
||||
expectf(0.0, firsttab);
|
||||
|
||||
stat = GdipSetStringFormatTabStops(format, 10.0, 3, tabstops);
|
||||
expect(Ok, stat);
|
||||
firsttab = -1.0;
|
||||
tabs[0] = tabs[1] = tabs[2] = -1.0;
|
||||
stat = GdipGetStringFormatTabStops(format, 0, &firsttab, tabs);
|
||||
expect(Ok, stat);
|
||||
expectf(-1.0, tabs[0]);
|
||||
expectf(-1.0, tabs[1]);
|
||||
expectf(-1.0, tabs[2]);
|
||||
expectf(10.0, firsttab);
|
||||
|
||||
/* zero tabcount, after valid setting to 3 */
|
||||
stat = GdipSetStringFormatTabStops(format, 0.0, 0, tabstops);
|
||||
expect(Ok, stat);
|
||||
count = 0;
|
||||
stat = GdipGetStringFormatTabStopCount(format, &count);
|
||||
expect(Ok, stat);
|
||||
expect(3, count);
|
||||
|
||||
stat = GdipDeleteStringFormat(format);
|
||||
expect(Ok, stat);
|
||||
|
|
|
@ -445,6 +445,7 @@ GpStatus WINGDIPAPI GdipGetStringFormatLineAlign(GpStringFormat*,StringAlignment
|
|||
GpStatus WINGDIPAPI GdipGetStringFormatMeasurableCharacterRangeCount(
|
||||
GDIPCONST GpStringFormat*, INT*);
|
||||
GpStatus WINGDIPAPI GdipGetStringFormatTabStopCount(GDIPCONST GpStringFormat*,INT*);
|
||||
GpStatus WINGDIPAPI GdipGetStringFormatTabStops(GDIPCONST GpStringFormat*,INT,REAL*,REAL*);
|
||||
GpStatus WINGDIPAPI GdipGetStringFormatTrimming(GpStringFormat*,StringTrimming*);
|
||||
GpStatus WINGDIPAPI GdipSetStringFormatAlign(GpStringFormat*,StringAlignment);
|
||||
GpStatus WINGDIPAPI GdipSetStringFormatDigitSubstitution(GpStringFormat*,LANGID,StringDigitSubstitute);
|
||||
|
@ -452,6 +453,7 @@ GpStatus WINGDIPAPI GdipSetStringFormatHotkeyPrefix(GpStringFormat*,INT);
|
|||
GpStatus WINGDIPAPI GdipSetStringFormatLineAlign(GpStringFormat*,StringAlignment);
|
||||
GpStatus WINGDIPAPI GdipSetStringFormatMeasurableCharacterRanges(
|
||||
GpStringFormat*, INT, GDIPCONST CharacterRange*);
|
||||
GpStatus WINGDIPAPI GdipSetStringFormatTabStops(GpStringFormat*,REAL,INT,GDIPCONST REAL*);
|
||||
GpStatus WINGDIPAPI GdipSetStringFormatTrimming(GpStringFormat*,StringTrimming);
|
||||
GpStatus WINGDIPAPI GdipCloneStringFormat(GDIPCONST GpStringFormat*,GpStringFormat**);
|
||||
|
||||
|
|
Loading…
Reference in New Issue