ReactOS 0.4.17-dev-243-g1369312
stringformat.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winnls.h"
#include "objbase.h"
#include "gdiplus.h"
#include "gdiplus_private.h"
#include "wine/debug.h"
Include dependency graph for stringformat.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (gdiplus)
 
void init_generic_string_formats (void)
 
void free_generic_string_formats (void)
 
GpStatus WINGDIPAPI GdipCreateStringFormat (INT attr, LANGID lang, GpStringFormat **format)
 
GpStatus WINGDIPAPI GdipDeleteStringFormat (GpStringFormat *format)
 
GpStatus WINGDIPAPI GdipStringFormatGetGenericDefault (GpStringFormat **format)
 
GpStatus WINGDIPAPI GdipGetStringFormatAlign (GpStringFormat *format, StringAlignment *align)
 
GpStatus WINGDIPAPI GdipGetStringFormatDigitSubstitution (GDIPCONST GpStringFormat *format, LANGID *language, StringDigitSubstitute *substitute)
 
GpStatus WINGDIPAPI GdipGetStringFormatFlags (GDIPCONST GpStringFormat *format, INT *flags)
 
GpStatus WINGDIPAPI GdipGetStringFormatHotkeyPrefix (GDIPCONST GpStringFormat *format, INT *hkpx)
 
GpStatus WINGDIPAPI GdipGetStringFormatLineAlign (GpStringFormat *format, StringAlignment *align)
 
GpStatus WINGDIPAPI GdipGetStringFormatMeasurableCharacterRangeCount (GDIPCONST GpStringFormat *format, INT *count)
 
GpStatus WINGDIPAPI GdipGetStringFormatTabStopCount (GDIPCONST GpStringFormat *format, INT *count)
 
GpStatus WINGDIPAPI GdipGetStringFormatTabStops (GDIPCONST GpStringFormat *format, INT count, REAL *firsttab, REAL *tabs)
 
GpStatus WINGDIPAPI GdipGetStringFormatTrimming (GpStringFormat *format, StringTrimming *trimming)
 
GpStatus WINGDIPAPI GdipSetStringFormatAlign (GpStringFormat *format, StringAlignment align)
 
GpStatus WINGDIPAPI GdipSetStringFormatDigitSubstitution (GpStringFormat *format, LANGID language, StringDigitSubstitute substitute)
 
GpStatus WINGDIPAPI GdipSetStringFormatHotkeyPrefix (GpStringFormat *format, INT hkpx)
 
GpStatus WINGDIPAPI GdipSetStringFormatLineAlign (GpStringFormat *format, StringAlignment align)
 
GpStatus WINGDIPAPI GdipSetStringFormatMeasurableCharacterRanges (GpStringFormat *format, INT rangeCount, GDIPCONST CharacterRange *ranges)
 
GpStatus WINGDIPAPI GdipSetStringFormatTabStops (GpStringFormat *format, REAL firsttab, INT count, GDIPCONST REAL *tabs)
 
GpStatus WINGDIPAPI GdipSetStringFormatTrimming (GpStringFormat *format, StringTrimming trimming)
 
GpStatus WINGDIPAPI GdipSetStringFormatFlags (GpStringFormat *format, INT flags)
 
GpStatus WINGDIPAPI GdipCloneStringFormat (GDIPCONST GpStringFormat *format, GpStringFormat **newFormat)
 
GpStatus WINGDIPAPI GdipStringFormatGetGenericTypographic (GpStringFormat **format)
 

Variables

const GpStringFormat default_drawstring_format
 
static GpStringFormat generic_default_format
 
static GpStringFormat generic_typographic_format
 

Function Documentation

◆ free_generic_string_formats()

void free_generic_string_formats ( void  )

Definition at line 67 of file stringformat.c.

68{
71
74}
#define free
Definition: debug_ros.c:5
static GpStringFormat generic_default_format
Definition: stringformat.c:53
static GpStringFormat generic_typographic_format
Definition: stringformat.c:54
CharacterRange * character_ranges

Referenced by DllMain().

◆ GdipCloneStringFormat()

GpStatus WINGDIPAPI GdipCloneStringFormat ( GDIPCONST GpStringFormat format,
GpStringFormat **  newFormat 
)

Definition at line 362 of file stringformat.c.

363{
364 if(!format || !newFormat)
365 return InvalidParameter;
366
367 *newFormat = malloc(sizeof(GpStringFormat));
368 if(!*newFormat) return OutOfMemory;
369
370 **newFormat = *format;
371
372 if(format->tabcount > 0){
373 (*newFormat)->tabs = malloc(sizeof(REAL) * format->tabcount);
374 if(!(*newFormat)->tabs){
375 free(*newFormat);
376 return OutOfMemory;
377 }
378 memcpy((*newFormat)->tabs, format->tabs, sizeof(REAL) * format->tabcount);
379 }
380 else
381 (*newFormat)->tabs = NULL;
382
383 if(format->range_count > 0){
384 (*newFormat)->character_ranges = malloc(sizeof(CharacterRange) * format->range_count);
385 if(!(*newFormat)->character_ranges){
386 free((*newFormat)->tabs);
387 free(*newFormat);
388 return OutOfMemory;
389 }
390 memcpy((*newFormat)->character_ranges, format->character_ranges,
391 sizeof(CharacterRange) * format->range_count);
392 }
393 else
394 (*newFormat)->character_ranges = NULL;
395
396 TRACE("%p %p\n",format,newFormat);
397
398 return Ok;
399}
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
float REAL
Definition: types.h:41
@ Ok
Definition: gdiplustypes.h:25
@ InvalidParameter
Definition: gdiplustypes.h:27
@ OutOfMemory
Definition: gdiplustypes.h:28
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define TRACE(s)
Definition: solgame.cpp:4
Definition: format.c:58

◆ GdipCreateStringFormat()

GpStatus WINGDIPAPI GdipCreateStringFormat ( INT  attr,
LANGID  lang,
GpStringFormat **  format 
)

Definition at line 76 of file stringformat.c.

78{
79 TRACE("(%i, %x, %p)\n", attr, lang, format);
80
81 if(!format)
82 return InvalidParameter;
83
84 *format = calloc(1, sizeof(GpStringFormat));
85 if(!*format) return OutOfMemory;
86
87 (*format)->attr = attr;
88 (*format)->lang = lang;
89 (*format)->digitlang = LANG_NEUTRAL;
90 (*format)->trimming = StringTrimmingCharacter;
91 (*format)->digitsub = StringDigitSubstituteUser;
92 (*format)->character_ranges = NULL;
93 (*format)->range_count = 0;
94 (*format)->generic_typographic = FALSE;
95 /* tabstops */
96 (*format)->tabcount = 0;
97 (*format)->firsttab = 0.0;
98 (*format)->tabs = NULL;
99
100 TRACE("<-- %p\n", *format);
101
102 return Ok;
103}
#define FALSE
Definition: types.h:117
@ StringTrimmingCharacter
Definition: gdiplusenums.h:292
@ StringDigitSubstituteUser
Definition: gdiplusenums.h:270
#define calloc
Definition: rosglue.h:14
#define LANG_NEUTRAL
Definition: nls.h:22
Definition: cookie.c:202
static const WCHAR lang[]
Definition: wbemdisp.c:287

Referenced by test_characterrange(), test_constructor(), test_digitsubstitution(), test_font_height_scaling(), test_font_transform(), test_GdipDrawString(), test_GdipMeasureString(), test_measure_string(), test_measured_extra_space(), test_string_functions(), test_stringformatflags(), and test_tabstops().

◆ GdipDeleteStringFormat()

◆ GdipGetStringFormatAlign()

GpStatus WINGDIPAPI GdipGetStringFormatAlign ( GpStringFormat format,
StringAlignment align 
)

Definition at line 130 of file stringformat.c.

132{
133 if(!format || !align)
134 return InvalidParameter;
135
136 *align = format->align;
137
138 return Ok;
139}
int align(int length, int align)
Definition: dsound8.c:36

Referenced by test_constructor(), test_getgenericdefault(), and test_getgenerictypographic().

◆ GdipGetStringFormatDigitSubstitution()

GpStatus WINGDIPAPI GdipGetStringFormatDigitSubstitution ( GDIPCONST GpStringFormat format,
LANGID language,
StringDigitSubstitute substitute 
)

Definition at line 141 of file stringformat.c.

143{
144 if(!format)
145 return InvalidParameter;
146
147 if(language) *language = format->digitlang;
148 if(substitute) *substitute = format->digitsub;
149
150 return Ok;
151}

Referenced by test_constructor(), test_digitsubstitution(), test_getgenericdefault(), and test_getgenerictypographic().

◆ GdipGetStringFormatFlags()

GpStatus WINGDIPAPI GdipGetStringFormatFlags ( GDIPCONST GpStringFormat format,
INT flags 
)

Definition at line 153 of file stringformat.c.

155{
156 if (!(format && flags))
157 return InvalidParameter;
158
159 *flags = format->attr;
160
161 return Ok;
162}
GLbitfield flags
Definition: glext.h:7161

Referenced by test_getgenericdefault(), test_getgenerictypographic(), and test_stringformatflags().

◆ GdipGetStringFormatHotkeyPrefix()

GpStatus WINGDIPAPI GdipGetStringFormatHotkeyPrefix ( GDIPCONST GpStringFormat format,
INT hkpx 
)

Definition at line 164 of file stringformat.c.

166{
167 if(!format || !hkpx)
168 return InvalidParameter;
169
170 *hkpx = (INT)format->hkprefix;
171
172 return Ok;
173}
#define INT
Definition: polytest.cpp:20

Referenced by test_constructor(), test_getgenericdefault(), and test_getgenerictypographic().

◆ GdipGetStringFormatLineAlign()

GpStatus WINGDIPAPI GdipGetStringFormatLineAlign ( GpStringFormat format,
StringAlignment align 
)

Definition at line 175 of file stringformat.c.

177{
178 if(!format || !align)
179 return InvalidParameter;
180
181 *align = format->line_align;
182
183 return Ok;
184}

Referenced by test_constructor(), test_getgenericdefault(), and test_getgenerictypographic().

◆ GdipGetStringFormatMeasurableCharacterRangeCount()

GpStatus WINGDIPAPI GdipGetStringFormatMeasurableCharacterRangeCount ( GDIPCONST GpStringFormat format,
INT count 
)

Definition at line 186 of file stringformat.c.

188{
189 if (!(format && count))
190 return InvalidParameter;
191
192 TRACE("%p %p\n", format, count);
193
194 *count = format->range_count;
195
196 return Ok;
197}
GLuint GLuint GLsizei count
Definition: gl.h:1545

Referenced by test_characterrange(), and test_constructor().

◆ GdipGetStringFormatTabStopCount()

GpStatus WINGDIPAPI GdipGetStringFormatTabStopCount ( GDIPCONST GpStringFormat format,
INT count 
)

Definition at line 199 of file stringformat.c.

201{
202 if(!format || !count)
203 return InvalidParameter;
204
205 *count = format->tabcount;
206
207 return Ok;
208}

Referenced by test_getgenericdefault(), test_getgenerictypographic(), and test_tabstops().

◆ GdipGetStringFormatTabStops()

GpStatus WINGDIPAPI GdipGetStringFormatTabStops ( GDIPCONST GpStringFormat format,
INT  count,
REAL firsttab,
REAL tabs 
)

Definition at line 210 of file stringformat.c.

212{
213 if(!format || !firsttab || !tabs)
214 return InvalidParameter;
215
216 /* native simply crashes on count < 0 */
217 if(count != 0)
218 memcpy(tabs, format->tabs, sizeof(REAL)*count);
219
220 *firsttab = format->firsttab;
221
222 return Ok;
223}

Referenced by test_tabstops().

◆ GdipGetStringFormatTrimming()

GpStatus WINGDIPAPI GdipGetStringFormatTrimming ( GpStringFormat format,
StringTrimming trimming 
)

Definition at line 225 of file stringformat.c.

227{
228 if(!format || !trimming)
229 return InvalidParameter;
230
231 *trimming = format->trimming;
232
233 return Ok;
234}

Referenced by test_constructor(), test_getgenericdefault(), and test_getgenerictypographic().

◆ GdipSetStringFormatAlign()

GpStatus WINGDIPAPI GdipSetStringFormatAlign ( GpStringFormat format,
StringAlignment  align 
)

Definition at line 236 of file stringformat.c.

238{
239 TRACE("(%p, %i)\n", format, align);
240
241 if(!format)
242 return InvalidParameter;
243
244 format->align = align;
245
246 return Ok;
247}

Referenced by test_measure_string().

◆ GdipSetStringFormatDigitSubstitution()

GpStatus WINGDIPAPI GdipSetStringFormatDigitSubstitution ( GpStringFormat format,
LANGID  language,
StringDigitSubstitute  substitute 
)

Definition at line 250 of file stringformat.c.

252{
253 TRACE("(%p, %x, %i)\n", format, language, substitute);
254
255 if(!format)
256 return InvalidParameter;
257
258 format->digitlang = language;
259 format->digitsub = substitute;
260
261 return Ok;
262}

Referenced by test_digitsubstitution().

◆ GdipSetStringFormatFlags()

GpStatus WINGDIPAPI GdipSetStringFormatFlags ( GpStringFormat format,
INT  flags 
)

Definition at line 350 of file stringformat.c.

351{
352 TRACE("(%p, %x)\n", format, flags);
353
354 if(!format)
355 return InvalidParameter;
356
357 format->attr = flags;
358
359 return Ok;
360}

Referenced by test_getgenericdefault(), test_getgenerictypographic(), test_measure_string(), and test_stringformatflags().

◆ GdipSetStringFormatHotkeyPrefix()

GpStatus WINGDIPAPI GdipSetStringFormatHotkeyPrefix ( GpStringFormat format,
INT  hkpx 
)

Definition at line 264 of file stringformat.c.

266{
267 TRACE("(%p, %i)\n", format, hkpx);
268
269 if(!format || hkpx < 0 || hkpx > 2)
270 return InvalidParameter;
271
272 format->hkprefix = (HotkeyPrefix) hkpx;
273
274 return Ok;
275}
HotkeyPrefix
Definition: gdiplusenums.h:310

◆ GdipSetStringFormatLineAlign()

GpStatus WINGDIPAPI GdipSetStringFormatLineAlign ( GpStringFormat format,
StringAlignment  align 
)

Definition at line 277 of file stringformat.c.

279{
280 TRACE("(%p, %i)\n", format, align);
281
282 if(!format)
283 return InvalidParameter;
284
285 format->line_align = align;
286
287 return Ok;
288}

Referenced by test_measure_string().

◆ GdipSetStringFormatMeasurableCharacterRanges()

GpStatus WINGDIPAPI GdipSetStringFormatMeasurableCharacterRanges ( GpStringFormat format,
INT  rangeCount,
GDIPCONST CharacterRange ranges 
)

Definition at line 290 of file stringformat.c.

292{
293 CharacterRange *new_ranges;
294
295 if (!(format && ranges))
296 return InvalidParameter;
297
298 TRACE("%p, %d, %p\n", format, rangeCount, ranges);
299
300 new_ranges = malloc(rangeCount * sizeof(CharacterRange));
301 if (!new_ranges)
302 return OutOfMemory;
303
304 free(format->character_ranges);
305 format->character_ranges = new_ranges;
306 memcpy(format->character_ranges, ranges, sizeof(CharacterRange) * rangeCount);
307 format->range_count = rangeCount;
308
309 return Ok;
310}

Referenced by test_characterrange(), test_font_height_scaling(), test_measure_string(), and test_string_functions().

◆ GdipSetStringFormatTabStops()

GpStatus WINGDIPAPI GdipSetStringFormatTabStops ( GpStringFormat format,
REAL  firsttab,
INT  count,
GDIPCONST REAL tabs 
)

Definition at line 312 of file stringformat.c.

314{
315 TRACE("(%p, %0.2f, %i, %p)\n", format, firsttab, count, tabs);
316
317 if(!format || !tabs)
318 return InvalidParameter;
319
320 if(count > 0){
321 if(firsttab < 0.0) return NotImplemented;
322 if(format->tabcount < count){
323 REAL *ptr;
324 ptr = realloc(format->tabs, sizeof(REAL) * count);
325 if(!ptr)
326 return OutOfMemory;
327 format->tabs = ptr;
328 }
329 format->firsttab = firsttab;
330 format->tabcount = count;
331 memcpy(format->tabs, tabs, sizeof(REAL)*count);
332 }
333
334 return Ok;
335}
#define realloc
Definition: debug_ros.c:6
@ NotImplemented
Definition: gdiplustypes.h:31
static PVOID ptr
Definition: dispmode.c:27

Referenced by test_tabstops().

◆ GdipSetStringFormatTrimming()

GpStatus WINGDIPAPI GdipSetStringFormatTrimming ( GpStringFormat format,
StringTrimming  trimming 
)

Definition at line 337 of file stringformat.c.

339{
340 TRACE("(%p, %i)\n", format, trimming);
341
342 if(!format)
343 return InvalidParameter;
344
345 format->trimming = trimming;
346
347 return Ok;
348}

◆ GdipStringFormatGetGenericDefault()

GpStatus WINGDIPAPI GdipStringFormatGetGenericDefault ( GpStringFormat **  format)

Definition at line 120 of file stringformat.c.

121{
122 if (!format)
123 return InvalidParameter;
124
126
127 return Ok;
128}

Referenced by test_getgenericdefault().

◆ GdipStringFormatGetGenericTypographic()

GpStatus WINGDIPAPI GdipStringFormatGetGenericTypographic ( GpStringFormat **  format)

Definition at line 401 of file stringformat.c.

402{
403 if(!format)
404 return InvalidParameter;
405
407
408 TRACE("%p => %p\n", format, *format);
409
410 return Ok;
411}

Referenced by test_font_transform(), and test_getgenerictypographic().

◆ init_generic_string_formats()

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( gdiplus  )

Variable Documentation

◆ default_drawstring_format

◆ generic_default_format

◆ generic_typographic_format