gdiplus: GdipGetStringFormatTabStopCount implementation with tests.

This commit is contained in:
Nikolay Sivov 2008-07-30 15:06:39 +04:00 committed by Alexandre Julliard
parent e6bce797d3
commit 4a08c13ba9
5 changed files with 62 additions and 2 deletions

View File

@ -392,7 +392,7 @@
@ stdcall GdipGetStringFormatHotkeyPrefix(ptr ptr)
@ stdcall GdipGetStringFormatLineAlign(ptr ptr)
@ stdcall GdipGetStringFormatMeasurableCharacterRangeCount(ptr ptr)
@ stub GdipGetStringFormatTabStopCount
@ stdcall GdipGetStringFormatTabStopCount(ptr ptr)
@ stub GdipGetStringFormatTabStops
@ stdcall GdipGetStringFormatTrimming(ptr ptr)
@ stub GdipGetTextContrast

View File

@ -194,6 +194,9 @@ struct GpStringFormat{
HotkeyPrefix hkprefix;
StringAlignment vertalign;
StringDigitSubstitute digitsub;
INT tabcount;
REAL firsttab;
REAL *tabs;
};
struct GpFontCollection{

View File

@ -46,6 +46,10 @@ GpStatus WINGDIPAPI GdipCreateStringFormat(INT attr, LANGID lang,
(*format)->digitlang = LANG_NEUTRAL;
(*format)->trimming = StringTrimmingCharacter;
(*format)->digitsub = StringDigitSubstituteUser;
/* tabstops */
(*format)->tabcount = 0;
(*format)->firsttab = 0.0;
(*format)->tabs = NULL;
return Ok;
}
@ -55,6 +59,7 @@ GpStatus WINGDIPAPI GdipDeleteStringFormat(GpStringFormat *format)
if(!format)
return InvalidParameter;
GdipFree(format->tabs);
GdipFree(format);
return Ok;
@ -137,6 +142,17 @@ GpStatus WINGDIPAPI GdipGetStringFormatMeasurableCharacterRangeCount(
return NotImplemented;
}
GpStatus WINGDIPAPI GdipGetStringFormatTabStopCount(GDIPCONST GpStringFormat *format,
INT *count)
{
if(!format || !count)
return InvalidParameter;
*count = format->tabcount;
return Ok;
}
GpStatus WINGDIPAPI GdipGetStringFormatTrimming(GpStringFormat *format,
StringTrimming *trimming)
{
@ -233,12 +249,22 @@ GpStatus WINGDIPAPI GdipCloneStringFormat(GDIPCONST GpStringFormat *format, GpSt
**newFormat = *format;
if(format->tabcount > 0){
(*newFormat)->tabs = GdipAlloc(sizeof(REAL) * format->tabcount);
if(!(*newFormat)->tabs){
GdipFree(*newFormat);
return OutOfMemory;
}
memcpy((*newFormat)->tabs, format->tabs, sizeof(REAL) * format->tabcount);
}
else
(*newFormat)->tabs = NULL;
TRACE("%p %p\n",format,newFormat);
return Ok;
}
/*FIXME: add zero tab stops number */
GpStatus WINGDIPAPI GdipStringFormatGetGenericTypographic(GpStringFormat **format)
{
GpStatus stat;

View File

@ -140,6 +140,7 @@ static void test_getgenerictypographic(void)
StringTrimming trimming;
StringDigitSubstitute digitsub;
LANGID digitlang;
INT tabcount;
/* NULL arg */
stat = GdipStringFormatGetGenericTypographic(NULL);
@ -154,6 +155,7 @@ static void test_getgenerictypographic(void)
GdipGetStringFormatHotkeyPrefix(format, &n);
GdipGetStringFormatTrimming(format, &trimming);
GdipGetStringFormatDigitSubstitution(format, &digitlang, &digitsub);
GdipGetStringFormatTabStopCount(format, &tabcount);
expect((StringFormatFlagsNoFitBlackBox |StringFormatFlagsLineLimit | StringFormatFlagsNoClip),
flags);
@ -163,6 +165,33 @@ static void test_getgenerictypographic(void)
expect(StringTrimmingNone, trimming);
expect(StringDigitSubstituteUser, digitsub);
expect(LANG_NEUTRAL, digitlang);
expect(0, tabcount);
stat = GdipDeleteStringFormat(format);
expect(Ok, stat);
}
static void test_tabstops(void)
{
GpStringFormat *format;
GpStatus stat;
INT count;
stat = GdipCreateStringFormat(0, LANG_NEUTRAL, &format);
expect(Ok, stat);
/* NULL */
stat = GdipGetStringFormatTabStopCount(NULL, NULL);
expect(InvalidParameter, stat);
stat = GdipGetStringFormatTabStopCount(NULL, &count);
expect(InvalidParameter, stat);
stat = GdipGetStringFormatTabStopCount(format, NULL);
expect(InvalidParameter, stat);
/* not NULL */
stat = GdipGetStringFormatTabStopCount(format, &count);
expect(Ok, stat);
expect(0, count);
stat = GdipDeleteStringFormat(format);
expect(Ok, stat);
@ -184,6 +213,7 @@ START_TEST(stringformat)
test_characterrange();
test_digitsubstitution();
test_getgenerictypographic();
test_tabstops();
GdiplusShutdown(gdiplusToken);
}

View File

@ -444,6 +444,7 @@ GpStatus WINGDIPAPI GdipGetStringFormatHotkeyPrefix(GDIPCONST GpStringFormat*,IN
GpStatus WINGDIPAPI GdipGetStringFormatLineAlign(GpStringFormat*,StringAlignment*);
GpStatus WINGDIPAPI GdipGetStringFormatMeasurableCharacterRangeCount(
GDIPCONST GpStringFormat*, INT*);
GpStatus WINGDIPAPI GdipGetStringFormatTabStopCount(GDIPCONST GpStringFormat*,INT*);
GpStatus WINGDIPAPI GdipGetStringFormatTrimming(GpStringFormat*,StringTrimming*);
GpStatus WINGDIPAPI GdipSetStringFormatAlign(GpStringFormat*,StringAlignment);
GpStatus WINGDIPAPI GdipSetStringFormatDigitSubstitution(GpStringFormat*,LANGID,StringDigitSubstitute);