gdiplus: GdipGetStringFormatTabStopCount implementation with tests.
This commit is contained in:
parent
e6bce797d3
commit
4a08c13ba9
|
@ -392,7 +392,7 @@
|
||||||
@ stdcall GdipGetStringFormatHotkeyPrefix(ptr ptr)
|
@ stdcall GdipGetStringFormatHotkeyPrefix(ptr ptr)
|
||||||
@ stdcall GdipGetStringFormatLineAlign(ptr ptr)
|
@ stdcall GdipGetStringFormatLineAlign(ptr ptr)
|
||||||
@ stdcall GdipGetStringFormatMeasurableCharacterRangeCount(ptr ptr)
|
@ stdcall GdipGetStringFormatMeasurableCharacterRangeCount(ptr ptr)
|
||||||
@ stub GdipGetStringFormatTabStopCount
|
@ stdcall GdipGetStringFormatTabStopCount(ptr ptr)
|
||||||
@ stub GdipGetStringFormatTabStops
|
@ stub GdipGetStringFormatTabStops
|
||||||
@ stdcall GdipGetStringFormatTrimming(ptr ptr)
|
@ stdcall GdipGetStringFormatTrimming(ptr ptr)
|
||||||
@ stub GdipGetTextContrast
|
@ stub GdipGetTextContrast
|
||||||
|
|
|
@ -194,6 +194,9 @@ struct GpStringFormat{
|
||||||
HotkeyPrefix hkprefix;
|
HotkeyPrefix hkprefix;
|
||||||
StringAlignment vertalign;
|
StringAlignment vertalign;
|
||||||
StringDigitSubstitute digitsub;
|
StringDigitSubstitute digitsub;
|
||||||
|
INT tabcount;
|
||||||
|
REAL firsttab;
|
||||||
|
REAL *tabs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GpFontCollection{
|
struct GpFontCollection{
|
||||||
|
|
|
@ -46,6 +46,10 @@ GpStatus WINGDIPAPI GdipCreateStringFormat(INT attr, LANGID lang,
|
||||||
(*format)->digitlang = LANG_NEUTRAL;
|
(*format)->digitlang = LANG_NEUTRAL;
|
||||||
(*format)->trimming = StringTrimmingCharacter;
|
(*format)->trimming = StringTrimmingCharacter;
|
||||||
(*format)->digitsub = StringDigitSubstituteUser;
|
(*format)->digitsub = StringDigitSubstituteUser;
|
||||||
|
/* tabstops */
|
||||||
|
(*format)->tabcount = 0;
|
||||||
|
(*format)->firsttab = 0.0;
|
||||||
|
(*format)->tabs = NULL;
|
||||||
|
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
@ -55,6 +59,7 @@ GpStatus WINGDIPAPI GdipDeleteStringFormat(GpStringFormat *format)
|
||||||
if(!format)
|
if(!format)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
|
GdipFree(format->tabs);
|
||||||
GdipFree(format);
|
GdipFree(format);
|
||||||
|
|
||||||
return Ok;
|
return Ok;
|
||||||
|
@ -137,6 +142,17 @@ GpStatus WINGDIPAPI GdipGetStringFormatMeasurableCharacterRangeCount(
|
||||||
return NotImplemented;
|
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,
|
GpStatus WINGDIPAPI GdipGetStringFormatTrimming(GpStringFormat *format,
|
||||||
StringTrimming *trimming)
|
StringTrimming *trimming)
|
||||||
{
|
{
|
||||||
|
@ -233,12 +249,22 @@ GpStatus WINGDIPAPI GdipCloneStringFormat(GDIPCONST GpStringFormat *format, GpSt
|
||||||
|
|
||||||
**newFormat = *format;
|
**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);
|
TRACE("%p %p\n",format,newFormat);
|
||||||
|
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*FIXME: add zero tab stops number */
|
|
||||||
GpStatus WINGDIPAPI GdipStringFormatGetGenericTypographic(GpStringFormat **format)
|
GpStatus WINGDIPAPI GdipStringFormatGetGenericTypographic(GpStringFormat **format)
|
||||||
{
|
{
|
||||||
GpStatus stat;
|
GpStatus stat;
|
||||||
|
|
|
@ -140,6 +140,7 @@ static void test_getgenerictypographic(void)
|
||||||
StringTrimming trimming;
|
StringTrimming trimming;
|
||||||
StringDigitSubstitute digitsub;
|
StringDigitSubstitute digitsub;
|
||||||
LANGID digitlang;
|
LANGID digitlang;
|
||||||
|
INT tabcount;
|
||||||
|
|
||||||
/* NULL arg */
|
/* NULL arg */
|
||||||
stat = GdipStringFormatGetGenericTypographic(NULL);
|
stat = GdipStringFormatGetGenericTypographic(NULL);
|
||||||
|
@ -154,6 +155,7 @@ static void test_getgenerictypographic(void)
|
||||||
GdipGetStringFormatHotkeyPrefix(format, &n);
|
GdipGetStringFormatHotkeyPrefix(format, &n);
|
||||||
GdipGetStringFormatTrimming(format, &trimming);
|
GdipGetStringFormatTrimming(format, &trimming);
|
||||||
GdipGetStringFormatDigitSubstitution(format, &digitlang, &digitsub);
|
GdipGetStringFormatDigitSubstitution(format, &digitlang, &digitsub);
|
||||||
|
GdipGetStringFormatTabStopCount(format, &tabcount);
|
||||||
|
|
||||||
expect((StringFormatFlagsNoFitBlackBox |StringFormatFlagsLineLimit | StringFormatFlagsNoClip),
|
expect((StringFormatFlagsNoFitBlackBox |StringFormatFlagsLineLimit | StringFormatFlagsNoClip),
|
||||||
flags);
|
flags);
|
||||||
|
@ -163,6 +165,33 @@ static void test_getgenerictypographic(void)
|
||||||
expect(StringTrimmingNone, trimming);
|
expect(StringTrimmingNone, trimming);
|
||||||
expect(StringDigitSubstituteUser, digitsub);
|
expect(StringDigitSubstituteUser, digitsub);
|
||||||
expect(LANG_NEUTRAL, digitlang);
|
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);
|
stat = GdipDeleteStringFormat(format);
|
||||||
expect(Ok, stat);
|
expect(Ok, stat);
|
||||||
|
@ -184,6 +213,7 @@ START_TEST(stringformat)
|
||||||
test_characterrange();
|
test_characterrange();
|
||||||
test_digitsubstitution();
|
test_digitsubstitution();
|
||||||
test_getgenerictypographic();
|
test_getgenerictypographic();
|
||||||
|
test_tabstops();
|
||||||
|
|
||||||
GdiplusShutdown(gdiplusToken);
|
GdiplusShutdown(gdiplusToken);
|
||||||
}
|
}
|
||||||
|
|
|
@ -444,6 +444,7 @@ GpStatus WINGDIPAPI GdipGetStringFormatHotkeyPrefix(GDIPCONST GpStringFormat*,IN
|
||||||
GpStatus WINGDIPAPI GdipGetStringFormatLineAlign(GpStringFormat*,StringAlignment*);
|
GpStatus WINGDIPAPI GdipGetStringFormatLineAlign(GpStringFormat*,StringAlignment*);
|
||||||
GpStatus WINGDIPAPI GdipGetStringFormatMeasurableCharacterRangeCount(
|
GpStatus WINGDIPAPI GdipGetStringFormatMeasurableCharacterRangeCount(
|
||||||
GDIPCONST GpStringFormat*, INT*);
|
GDIPCONST GpStringFormat*, INT*);
|
||||||
|
GpStatus WINGDIPAPI GdipGetStringFormatTabStopCount(GDIPCONST GpStringFormat*,INT*);
|
||||||
GpStatus WINGDIPAPI GdipGetStringFormatTrimming(GpStringFormat*,StringTrimming*);
|
GpStatus WINGDIPAPI GdipGetStringFormatTrimming(GpStringFormat*,StringTrimming*);
|
||||||
GpStatus WINGDIPAPI GdipSetStringFormatAlign(GpStringFormat*,StringAlignment);
|
GpStatus WINGDIPAPI GdipSetStringFormatAlign(GpStringFormat*,StringAlignment);
|
||||||
GpStatus WINGDIPAPI GdipSetStringFormatDigitSubstitution(GpStringFormat*,LANGID,StringDigitSubstitute);
|
GpStatus WINGDIPAPI GdipSetStringFormatDigitSubstitution(GpStringFormat*,LANGID,StringDigitSubstitute);
|
||||||
|
|
Loading…
Reference in New Issue