odbc32: Implement SQLDataSourcesA() forward.
[wine] / dlls / dwrite / layout.c
1 /*
2  *    Text format and layout
3  *
4  * Copyright 2012 Nikolay Sivov for CodeWeavers
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #define COBJMACROS
22
23 #include <stdarg.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "dwrite.h"
29 #include "dwrite_private.h"
30
31 #include "wine/debug.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
34
35 struct dwrite_textformat_data {
36     WCHAR *family_name;
37     WCHAR *locale;
38     UINT32 locale_len;
39
40     DWRITE_FONT_WEIGHT weight;
41     DWRITE_FONT_STYLE style;
42     DWRITE_FONT_STRETCH stretch;
43
44     FLOAT size;
45
46     IDWriteFontCollection *collection;
47 };
48
49 struct dwrite_textlayout {
50     IDWriteTextLayout IDWriteTextLayout_iface;
51     LONG ref;
52
53     WCHAR *str;
54     UINT32 len;
55     struct dwrite_textformat_data format;
56 };
57
58 struct dwrite_textformat {
59     IDWriteTextFormat IDWriteTextFormat_iface;
60     LONG ref;
61     struct dwrite_textformat_data format;
62 };
63
64 static void release_format_data(struct dwrite_textformat_data *data)
65 {
66     if (data->collection) IDWriteFontCollection_Release(data->collection);
67     heap_free(data->family_name);
68     heap_free(data->locale);
69 }
70
71 static inline struct dwrite_textlayout *impl_from_IDWriteTextLayout(IDWriteTextLayout *iface)
72 {
73     return CONTAINING_RECORD(iface, struct dwrite_textlayout, IDWriteTextLayout_iface);
74 }
75
76 static inline struct dwrite_textformat *impl_from_IDWriteTextFormat(IDWriteTextFormat *iface)
77 {
78     return CONTAINING_RECORD(iface, struct dwrite_textformat, IDWriteTextFormat_iface);
79 }
80
81 static HRESULT WINAPI dwritetextlayout_QueryInterface(IDWriteTextLayout *iface, REFIID riid, void **obj)
82 {
83     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
84
85     TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
86
87     if (IsEqualIID(riid, &IID_IUnknown) ||
88         IsEqualIID(riid, &IID_IDWriteTextFormat) ||
89         IsEqualIID(riid, &IID_IDWriteTextLayout))
90     {
91         *obj = iface;
92         IDWriteTextLayout_AddRef(iface);
93         return S_OK;
94     }
95
96     *obj = NULL;
97
98     return E_NOINTERFACE;
99 }
100
101 static ULONG WINAPI dwritetextlayout_AddRef(IDWriteTextLayout *iface)
102 {
103     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
104     ULONG ref = InterlockedIncrement(&This->ref);
105     TRACE("(%p)->(%d)\n", This, ref);
106     return ref;
107 }
108
109 static ULONG WINAPI dwritetextlayout_Release(IDWriteTextLayout *iface)
110 {
111     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
112     ULONG ref = InterlockedDecrement(&This->ref);
113
114     TRACE("(%p)->(%d)\n", This, ref);
115
116     if (!ref)
117     {
118         release_format_data(&This->format);
119         heap_free(This->str);
120         heap_free(This);
121     }
122
123     return ref;
124 }
125
126 static HRESULT WINAPI dwritetextlayout_SetTextAlignment(IDWriteTextLayout *iface, DWRITE_TEXT_ALIGNMENT alignment)
127 {
128     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
129     FIXME("(%p)->(%d): stub\n", This, alignment);
130     return E_NOTIMPL;
131 }
132
133 static HRESULT WINAPI dwritetextlayout_SetParagraphAlignment(IDWriteTextLayout *iface, DWRITE_PARAGRAPH_ALIGNMENT alignment)
134 {
135     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
136     FIXME("(%p)->(%d): stub\n", This, alignment);
137     return E_NOTIMPL;
138 }
139
140 static HRESULT WINAPI dwritetextlayout_SetWordWrapping(IDWriteTextLayout *iface, DWRITE_WORD_WRAPPING wrapping)
141 {
142     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
143     FIXME("(%p)->(%d): stub\n", This, wrapping);
144     return E_NOTIMPL;
145 }
146
147 static HRESULT WINAPI dwritetextlayout_SetReadingDirection(IDWriteTextLayout *iface, DWRITE_READING_DIRECTION direction)
148 {
149     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
150     FIXME("(%p)->(%d): stub\n", This, direction);
151     return E_NOTIMPL;
152 }
153
154 static HRESULT WINAPI dwritetextlayout_SetFlowDirection(IDWriteTextLayout *iface, DWRITE_FLOW_DIRECTION direction)
155 {
156     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
157     FIXME("(%p)->(%d): stub\n", This, direction);
158     return E_NOTIMPL;
159 }
160
161 static HRESULT WINAPI dwritetextlayout_SetIncrementalTabStop(IDWriteTextLayout *iface, FLOAT tabstop)
162 {
163     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
164     FIXME("(%p)->(%f): stub\n", This, tabstop);
165     return E_NOTIMPL;
166 }
167
168 static HRESULT WINAPI dwritetextlayout_SetTrimming(IDWriteTextLayout *iface, DWRITE_TRIMMING const *trimming,
169     IDWriteInlineObject *trimming_sign)
170 {
171     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
172     FIXME("(%p)->(%p %p): stub\n", This, trimming, trimming_sign);
173     return E_NOTIMPL;
174 }
175
176 static HRESULT WINAPI dwritetextlayout_SetLineSpacing(IDWriteTextLayout *iface, DWRITE_LINE_SPACING_METHOD spacing,
177     FLOAT line_spacing, FLOAT baseline)
178 {
179     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
180     FIXME("(%p)->(%d %f %f): stub\n", This, spacing, line_spacing, baseline);
181     return E_NOTIMPL;
182 }
183
184 static DWRITE_TEXT_ALIGNMENT WINAPI dwritetextlayout_GetTextAlignment(IDWriteTextLayout *iface)
185 {
186     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
187     FIXME("(%p): stub\n", This);
188     return DWRITE_TEXT_ALIGNMENT_LEADING;
189 }
190
191 static DWRITE_PARAGRAPH_ALIGNMENT WINAPI dwritetextlayout_GetParagraphAlignment(IDWriteTextLayout *iface)
192 {
193     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
194     FIXME("(%p): stub\n", This);
195     return DWRITE_PARAGRAPH_ALIGNMENT_NEAR;
196 }
197
198 static DWRITE_WORD_WRAPPING WINAPI dwritetextlayout_GetWordWrapping(IDWriteTextLayout *iface)
199 {
200     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
201     FIXME("(%p): stub\n", This);
202     return DWRITE_WORD_WRAPPING_NO_WRAP;
203 }
204
205 static DWRITE_READING_DIRECTION WINAPI dwritetextlayout_GetReadingDirection(IDWriteTextLayout *iface)
206 {
207     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
208     FIXME("(%p): stub\n", This);
209     return DWRITE_READING_DIRECTION_LEFT_TO_RIGHT;
210 }
211
212 static DWRITE_FLOW_DIRECTION WINAPI dwritetextlayout_GetFlowDirection(IDWriteTextLayout *iface)
213 {
214     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
215     FIXME("(%p): stub\n", This);
216     return DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM;
217 }
218
219 static FLOAT WINAPI dwritetextlayout_GetIncrementalTabStop(IDWriteTextLayout *iface)
220 {
221     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
222     FIXME("(%p): stub\n", This);
223     return 0.0;
224 }
225
226 static HRESULT WINAPI dwritetextlayout_GetTrimming(IDWriteTextLayout *iface, DWRITE_TRIMMING *options,
227     IDWriteInlineObject **trimming_sign)
228 {
229     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
230     FIXME("(%p)->(%p %p): stub\n", This, options, trimming_sign);
231     return E_NOTIMPL;
232 }
233
234 static HRESULT WINAPI dwritetextlayout_GetLineSpacing(IDWriteTextLayout *iface, DWRITE_LINE_SPACING_METHOD *method,
235     FLOAT *spacing, FLOAT *baseline)
236 {
237     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
238     FIXME("(%p)->(%p %p %p): stub\n", This, method, spacing, baseline);
239     return E_NOTIMPL;
240 }
241
242 static HRESULT WINAPI dwritetextlayout_GetFontCollection(IDWriteTextLayout *iface, IDWriteFontCollection **collection)
243 {
244     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
245     FIXME("(%p)->(%p): stub\n", This, collection);
246     return E_NOTIMPL;
247 }
248
249 static UINT32 WINAPI dwritetextlayout_GetFontFamilyNameLength(IDWriteTextLayout *iface)
250 {
251     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
252     FIXME("(%p): stub\n", This);
253     return 0;
254 }
255
256 static HRESULT WINAPI dwritetextlayout_GetFontFamilyName(IDWriteTextLayout *iface, WCHAR *name, UINT32 size)
257 {
258     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
259     FIXME("(%p)->(%p %u): stub\n", This, name, size);
260     return E_NOTIMPL;
261 }
262
263 static DWRITE_FONT_WEIGHT WINAPI dwritetextlayout_GetFontWeight(IDWriteTextLayout *iface)
264 {
265     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
266     FIXME("(%p): stub\n", This);
267     return DWRITE_FONT_WEIGHT_NORMAL;
268 }
269
270 static DWRITE_FONT_STYLE WINAPI dwritetextlayout_GetFontStyle(IDWriteTextLayout *iface)
271 {
272     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
273     FIXME("(%p): stub\n", This);
274     return DWRITE_FONT_STYLE_NORMAL;
275 }
276
277 static DWRITE_FONT_STRETCH WINAPI dwritetextlayout_GetFontStretch(IDWriteTextLayout *iface)
278 {
279     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
280     FIXME("(%p): stub\n", This);
281     return DWRITE_FONT_STRETCH_NORMAL;
282 }
283
284 static FLOAT WINAPI dwritetextlayout_GetFontSize(IDWriteTextLayout *iface)
285 {
286     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
287     FIXME("(%p): stub\n", This);
288     return 0.0;
289 }
290
291 static UINT32 WINAPI dwritetextlayout_GetLocaleNameLength(IDWriteTextLayout *iface)
292 {
293     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
294     TRACE("(%p)\n", This);
295     return This->format.locale_len;
296 }
297
298 static HRESULT WINAPI dwritetextlayout_GetLocaleName(IDWriteTextLayout *iface, WCHAR *name, UINT32 size)
299 {
300     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
301
302     TRACE("(%p)->(%p %u)\n", This, name, size);
303
304     if (size <= This->format.locale_len) return E_NOT_SUFFICIENT_BUFFER;
305     strcpyW(name, This->format.locale);
306     return S_OK;
307 }
308
309 static HRESULT WINAPI dwritetextlayout_SetMaxWidth(IDWriteTextLayout *iface, FLOAT maxWidth)
310 {
311     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
312     FIXME("(%p)->(%f): stub\n", This, maxWidth);
313     return E_NOTIMPL;
314 }
315
316 static HRESULT WINAPI dwritetextlayout_SetMaxHeight(IDWriteTextLayout *iface, FLOAT maxHeight)
317 {
318     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
319     FIXME("(%p)->(%f): stub\n", This, maxHeight);
320     return E_NOTIMPL;
321 }
322
323 static HRESULT WINAPI dwritetextlayout_SetFontCollection(IDWriteTextLayout *iface, IDWriteFontCollection* collection, DWRITE_TEXT_RANGE range)
324 {
325     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
326     FIXME("(%p)->(%p %u:%u): stub\n", This, collection, range.startPosition, range.length);
327     return E_NOTIMPL;
328 }
329
330 static HRESULT WINAPI dwritetextlayout_SetFontFamilyName(IDWriteTextLayout *iface, WCHAR const *name, DWRITE_TEXT_RANGE range)
331 {
332     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
333     FIXME("(%p)->(%s %u:%u): stub\n", This, debugstr_w(name), range.startPosition, range.length);
334     return E_NOTIMPL;
335 }
336
337 static HRESULT WINAPI dwritetextlayout_SetFontWeight(IDWriteTextLayout *iface, DWRITE_FONT_WEIGHT weight, DWRITE_TEXT_RANGE range)
338 {
339     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
340     FIXME("(%p)->(%d %u:%u): stub\n", This, weight, range.startPosition, range.length);
341     return E_NOTIMPL;
342 }
343
344 static HRESULT WINAPI dwritetextlayout_SetFontStyle(IDWriteTextLayout *iface, DWRITE_FONT_STYLE style, DWRITE_TEXT_RANGE range)
345 {
346     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
347     FIXME("(%p)->(%d %u:%u): stub\n", This, style, range.startPosition, range.length);
348     return E_NOTIMPL;
349 }
350
351 static HRESULT WINAPI dwritetextlayout_SetFontStretch(IDWriteTextLayout *iface, DWRITE_FONT_STRETCH stretch, DWRITE_TEXT_RANGE range)
352 {
353     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
354     FIXME("(%p)->(%d %u:%u): stub\n", This, stretch, range.startPosition, range.length);
355     return E_NOTIMPL;
356 }
357
358 static HRESULT WINAPI dwritetextlayout_SetFontSize(IDWriteTextLayout *iface, FLOAT size, DWRITE_TEXT_RANGE range)
359 {
360     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
361     FIXME("(%p)->(%f %u:%u): stub\n", This, size, range.startPosition, range.length);
362     return E_NOTIMPL;
363 }
364
365 static HRESULT WINAPI dwritetextlayout_SetUnderline(IDWriteTextLayout *iface, BOOL underline, DWRITE_TEXT_RANGE range)
366 {
367     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
368     FIXME("(%p)->(%d %u:%u): stub\n", This, underline, range.startPosition, range.length);
369     return E_NOTIMPL;
370 }
371
372 static HRESULT WINAPI dwritetextlayout_SetStrikethrough(IDWriteTextLayout *iface, BOOL strikethrough, DWRITE_TEXT_RANGE range)
373 {
374     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
375     FIXME("(%p)->(%d %u:%u): stub\n", This, strikethrough, range.startPosition, range.length);
376     return E_NOTIMPL;
377 }
378
379 static HRESULT WINAPI dwritetextlayout_SetDrawingEffect(IDWriteTextLayout *iface, IUnknown* effect, DWRITE_TEXT_RANGE range)
380 {
381     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
382     FIXME("(%p)->(%p %u:%u): stub\n", This, effect, range.startPosition, range.length);
383     return E_NOTIMPL;
384 }
385
386 static HRESULT WINAPI dwritetextlayout_SetInlineObject(IDWriteTextLayout *iface, IDWriteInlineObject *object, DWRITE_TEXT_RANGE range)
387 {
388     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
389     FIXME("(%p)->(%p %u:%u): stub\n", This, object, range.startPosition, range.length);
390     return E_NOTIMPL;
391 }
392
393 static HRESULT WINAPI dwritetextlayout_SetTypography(IDWriteTextLayout *iface, IDWriteTypography* typography, DWRITE_TEXT_RANGE range)
394 {
395     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
396     FIXME("(%p)->(%p %u:%u): stub\n", This, typography, range.startPosition, range.length);
397     return E_NOTIMPL;
398 }
399
400 static HRESULT WINAPI dwritetextlayout_SetLocaleName(IDWriteTextLayout *iface, WCHAR const* locale, DWRITE_TEXT_RANGE range)
401 {
402     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
403     FIXME("(%p)->(%s %u:%u): stub\n", This, debugstr_w(locale), range.startPosition, range.length);
404     return E_NOTIMPL;
405 }
406
407 static FLOAT WINAPI dwritetextlayout_GetMaxWidth(IDWriteTextLayout *iface)
408 {
409     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
410     FIXME("(%p): stub\n", This);
411     return 0.0;
412 }
413
414 static FLOAT WINAPI dwritetextlayout_GetMaxHeight(IDWriteTextLayout *iface)
415 {
416     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
417     FIXME("(%p): stub\n", This);
418     return 0.0;
419 }
420
421 static HRESULT WINAPI dwritetextlayout_layout_GetFontCollection(IDWriteTextLayout *iface, UINT32 pos,
422     IDWriteFontCollection** collection, DWRITE_TEXT_RANGE *range)
423 {
424     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
425     FIXME("(%p)->(%p %p): stub\n", This, collection, range);
426     return E_NOTIMPL;
427 }
428
429 static HRESULT WINAPI dwritetextlayout_layout_GetFontFamilyNameLength(IDWriteTextLayout *iface,
430     UINT32 pos, UINT32* len, DWRITE_TEXT_RANGE *range)
431 {
432     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
433     FIXME("(%p)->(%d %p %p): stub\n", This, pos, len, range);
434     return E_NOTIMPL;
435 }
436
437 static HRESULT WINAPI dwritetextlayout_layout_GetFontFamilyName(IDWriteTextLayout *iface,
438     UINT32 position, WCHAR* name, UINT32 name_size, DWRITE_TEXT_RANGE *range)
439 {
440     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
441     FIXME("(%p)->(%u %p %u %p): stub\n", This, position, name, name_size, range);
442     return E_NOTIMPL;
443 }
444
445 static HRESULT WINAPI dwritetextlayout_layout_GetFontWeight(IDWriteTextLayout *iface,
446     UINT32 position, DWRITE_FONT_WEIGHT *weight, DWRITE_TEXT_RANGE *range)
447 {
448     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
449     FIXME("(%p)->(%u %p %p): stub\n", This, position, weight, range);
450     return E_NOTIMPL;
451 }
452
453 static HRESULT WINAPI dwritetextlayout_layout_GetFontStyle(IDWriteTextLayout *iface,
454     UINT32 currentPosition, DWRITE_FONT_STYLE *style, DWRITE_TEXT_RANGE *range)
455 {
456     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
457     FIXME("(%p)->(%u %p %p): stub\n", This, currentPosition, style, range);
458     return E_NOTIMPL;
459 }
460
461 static HRESULT WINAPI dwritetextlayout_layout_GetFontStretch(IDWriteTextLayout *iface,
462     UINT32 position, DWRITE_FONT_STRETCH *stretch, DWRITE_TEXT_RANGE *range)
463 {
464     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
465     FIXME("(%p)->(%u %p %p): stub\n", This, position, stretch, range);
466     return E_NOTIMPL;
467 }
468
469 static HRESULT WINAPI dwritetextlayout_layout_GetFontSize(IDWriteTextLayout *iface,
470     UINT32 position, FLOAT *size, DWRITE_TEXT_RANGE *range)
471 {
472     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
473     FIXME("(%p)->(%u %p %p): stub\n", This, position, size, range);
474     return E_NOTIMPL;
475 }
476
477 static HRESULT WINAPI dwritetextlayout_GetUnderline(IDWriteTextLayout *iface,
478     UINT32 position, BOOL *has_underline, DWRITE_TEXT_RANGE *range)
479 {
480     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
481     FIXME("(%p)->(%u %p %p): stub\n", This, position, has_underline, range);
482     return E_NOTIMPL;
483 }
484
485 static HRESULT WINAPI dwritetextlayout_GetStrikethrough(IDWriteTextLayout *iface,
486     UINT32 position, BOOL *has_strikethrough, DWRITE_TEXT_RANGE *range)
487 {
488     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
489     FIXME("(%p)->(%u %p %p): stub\n", This, position, has_strikethrough, range);
490     return E_NOTIMPL;
491 }
492
493 static HRESULT WINAPI dwritetextlayout_GetDrawingEffect(IDWriteTextLayout *iface,
494     UINT32 position, IUnknown **effect, DWRITE_TEXT_RANGE *range)
495 {
496     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
497     FIXME("(%p)->(%u %p %p): stub\n", This, position, effect, range);
498     return E_NOTIMPL;
499 }
500
501 static HRESULT WINAPI dwritetextlayout_GetInlineObject(IDWriteTextLayout *iface,
502     UINT32 position, IDWriteInlineObject **object, DWRITE_TEXT_RANGE *range)
503 {
504     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
505     FIXME("(%p)->(%u %p %p): stub\n", This, position, object, range);
506     return E_NOTIMPL;
507 }
508
509 static HRESULT WINAPI dwritetextlayout_GetTypography(IDWriteTextLayout *iface,
510     UINT32 position, IDWriteTypography** typography, DWRITE_TEXT_RANGE *range)
511 {
512     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
513     FIXME("(%p)->(%u %p %p): stub\n", This, position, typography, range);
514     return E_NOTIMPL;
515 }
516
517 static HRESULT WINAPI dwritetextlayout_layout_GetLocaleNameLength(IDWriteTextLayout *iface,
518     UINT32 position, UINT32* length, DWRITE_TEXT_RANGE *range)
519 {
520     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
521     FIXME("(%p)->(%u %p %p): stub\n", This, position, length, range);
522     return E_NOTIMPL;
523 }
524
525 static HRESULT WINAPI dwritetextlayout_layout_GetLocaleName(IDWriteTextLayout *iface,
526     UINT32 position, WCHAR* name, UINT32 name_size, DWRITE_TEXT_RANGE *range)
527 {
528     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
529     FIXME("(%p)->(%u %p %u %p): stub\n", This, position, name, name_size, range);
530     return E_NOTIMPL;
531 }
532
533 static HRESULT WINAPI dwritetextlayout_Draw(IDWriteTextLayout *iface,
534     void *context, IDWriteTextRenderer* renderer, FLOAT originX, FLOAT originY)
535 {
536     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
537     FIXME("(%p)->(%p %p %f %f): stub\n", This, context, renderer, originX, originY);
538     return E_NOTIMPL;
539 }
540
541 static HRESULT WINAPI dwritetextlayout_GetLineMetrics(IDWriteTextLayout *iface,
542     DWRITE_LINE_METRICS *metrics, UINT32 max_count, UINT32 *actual_count)
543 {
544     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
545     FIXME("(%p)->(%p %u %p): stub\n", This, metrics, max_count, actual_count);
546     return E_NOTIMPL;
547 }
548
549 static HRESULT WINAPI dwritetextlayout_GetMetrics(IDWriteTextLayout *iface, DWRITE_TEXT_METRICS *metrics)
550 {
551     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
552     FIXME("(%p)->(%p): stub\n", This, metrics);
553     return E_NOTIMPL;
554 }
555
556 static HRESULT WINAPI dwritetextlayout_GetOverhangMetrics(IDWriteTextLayout *iface, DWRITE_OVERHANG_METRICS *overhangs)
557 {
558     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
559     FIXME("(%p)->(%p): stub\n", This, overhangs);
560     return E_NOTIMPL;
561 }
562
563 static HRESULT WINAPI dwritetextlayout_GetClusterMetrics(IDWriteTextLayout *iface,
564     DWRITE_CLUSTER_METRICS *metrics, UINT32 max_count, UINT32* act_count)
565 {
566     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
567     FIXME("(%p)->(%p %u %p): stub\n", This, metrics, max_count, act_count);
568     return E_NOTIMPL;
569 }
570
571 static HRESULT WINAPI dwritetextlayout_DetermineMinWidth(IDWriteTextLayout *iface, FLOAT* min_width)
572 {
573     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
574     FIXME("(%p)->(%p): stub\n", This, min_width);
575     return E_NOTIMPL;
576 }
577
578 static HRESULT WINAPI dwritetextlayout_HitTestPoint(IDWriteTextLayout *iface,
579     FLOAT pointX, FLOAT pointY, BOOL* is_trailinghit, BOOL* is_inside, DWRITE_HIT_TEST_METRICS *metrics)
580 {
581     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
582     FIXME("(%p)->(%f %f %p %p %p): stub\n", This, pointX, pointY, is_trailinghit, is_inside, metrics);
583     return E_NOTIMPL;
584 }
585
586 static HRESULT WINAPI dwritetextlayout_HitTestTextPosition(IDWriteTextLayout *iface,
587     UINT32 textPosition, BOOL is_trailinghit, FLOAT* pointX, FLOAT* pointY, DWRITE_HIT_TEST_METRICS *metrics)
588 {
589     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
590     FIXME("(%p)->(%u %d %p %p %p): stub\n", This, textPosition, is_trailinghit, pointX, pointY, metrics);
591     return E_NOTIMPL;
592 }
593
594 static HRESULT WINAPI dwritetextlayout_HitTestTextRange(IDWriteTextLayout *iface,
595     UINT32 textPosition, UINT32 textLength, FLOAT originX, FLOAT originY,
596     DWRITE_HIT_TEST_METRICS *metrics, UINT32 max_metricscount, UINT32* actual_metricscount)
597 {
598     struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
599     FIXME("(%p)->(%u %u %f %f %p %u %p): stub\n", This, textPosition, textLength, originX, originY, metrics,
600         max_metricscount, actual_metricscount);
601     return E_NOTIMPL;
602 }
603
604 static const IDWriteTextLayoutVtbl dwritetextlayoutvtbl = {
605     dwritetextlayout_QueryInterface,
606     dwritetextlayout_AddRef,
607     dwritetextlayout_Release,
608     dwritetextlayout_SetTextAlignment,
609     dwritetextlayout_SetParagraphAlignment,
610     dwritetextlayout_SetWordWrapping,
611     dwritetextlayout_SetReadingDirection,
612     dwritetextlayout_SetFlowDirection,
613     dwritetextlayout_SetIncrementalTabStop,
614     dwritetextlayout_SetTrimming,
615     dwritetextlayout_SetLineSpacing,
616     dwritetextlayout_GetTextAlignment,
617     dwritetextlayout_GetParagraphAlignment,
618     dwritetextlayout_GetWordWrapping,
619     dwritetextlayout_GetReadingDirection,
620     dwritetextlayout_GetFlowDirection,
621     dwritetextlayout_GetIncrementalTabStop,
622     dwritetextlayout_GetTrimming,
623     dwritetextlayout_GetLineSpacing,
624     dwritetextlayout_GetFontCollection,
625     dwritetextlayout_GetFontFamilyNameLength,
626     dwritetextlayout_GetFontFamilyName,
627     dwritetextlayout_GetFontWeight,
628     dwritetextlayout_GetFontStyle,
629     dwritetextlayout_GetFontStretch,
630     dwritetextlayout_GetFontSize,
631     dwritetextlayout_GetLocaleNameLength,
632     dwritetextlayout_GetLocaleName,
633     dwritetextlayout_SetMaxWidth,
634     dwritetextlayout_SetMaxHeight,
635     dwritetextlayout_SetFontCollection,
636     dwritetextlayout_SetFontFamilyName,
637     dwritetextlayout_SetFontWeight,
638     dwritetextlayout_SetFontStyle,
639     dwritetextlayout_SetFontStretch,
640     dwritetextlayout_SetFontSize,
641     dwritetextlayout_SetUnderline,
642     dwritetextlayout_SetStrikethrough,
643     dwritetextlayout_SetDrawingEffect,
644     dwritetextlayout_SetInlineObject,
645     dwritetextlayout_SetTypography,
646     dwritetextlayout_SetLocaleName,
647     dwritetextlayout_GetMaxWidth,
648     dwritetextlayout_GetMaxHeight,
649     dwritetextlayout_layout_GetFontCollection,
650     dwritetextlayout_layout_GetFontFamilyNameLength,
651     dwritetextlayout_layout_GetFontFamilyName,
652     dwritetextlayout_layout_GetFontWeight,
653     dwritetextlayout_layout_GetFontStyle,
654     dwritetextlayout_layout_GetFontStretch,
655     dwritetextlayout_layout_GetFontSize,
656     dwritetextlayout_GetUnderline,
657     dwritetextlayout_GetStrikethrough,
658     dwritetextlayout_GetDrawingEffect,
659     dwritetextlayout_GetInlineObject,
660     dwritetextlayout_GetTypography,
661     dwritetextlayout_layout_GetLocaleNameLength,
662     dwritetextlayout_layout_GetLocaleName,
663     dwritetextlayout_Draw,
664     dwritetextlayout_GetLineMetrics,
665     dwritetextlayout_GetMetrics,
666     dwritetextlayout_GetOverhangMetrics,
667     dwritetextlayout_GetClusterMetrics,
668     dwritetextlayout_DetermineMinWidth,
669     dwritetextlayout_HitTestPoint,
670     dwritetextlayout_HitTestTextPosition,
671     dwritetextlayout_HitTestTextRange
672 };
673
674 HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *format, IDWriteTextLayout **layout)
675 {
676     struct dwrite_textlayout *This;
677     UINT32 locale_len;
678
679     *layout = NULL;
680
681     This = heap_alloc(sizeof(struct dwrite_textlayout));
682     if (!This) return E_OUTOFMEMORY;
683
684     This->IDWriteTextLayout_iface.lpVtbl = &dwritetextlayoutvtbl;
685     This->ref = 1;
686     This->str = heap_strdupnW(str, len);
687     This->len = len;
688     memset(&This->format, 0, sizeof(This->format));
689
690     /* reference is not kept here, instead copy all underlying data */
691     IDWriteTextFormat_GetFontCollection(format, &This->format.collection);
692
693     /* locale name and length */
694     locale_len = IDWriteTextFormat_GetLocaleNameLength(format);
695     This->format.locale  = heap_alloc((locale_len+1)*sizeof(WCHAR));
696     IDWriteTextFormat_GetLocaleName(format, This->format.locale, locale_len+1);
697     This->format.locale_len = locale_len;
698
699     This->format.weight  = IDWriteTextFormat_GetFontWeight(format);
700     This->format.style   = IDWriteTextFormat_GetFontStyle(format);
701     This->format.stretch = IDWriteTextFormat_GetFontStretch(format);
702     This->format.size    = IDWriteTextFormat_GetFontSize(format);
703
704     *layout = &This->IDWriteTextLayout_iface;
705
706     return S_OK;
707 }
708
709 static HRESULT WINAPI dwritetextformat_QueryInterface(IDWriteTextFormat *iface, REFIID riid, void **obj)
710 {
711     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
712
713     TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
714
715     if (IsEqualIID(riid, &IID_IUnknown) ||
716         IsEqualIID(riid, &IID_IDWriteTextFormat))
717     {
718         *obj = iface;
719         IDWriteTextFormat_AddRef(iface);
720         return S_OK;
721     }
722
723     *obj = NULL;
724
725     return E_NOINTERFACE;
726 }
727
728 static ULONG WINAPI dwritetextformat_AddRef(IDWriteTextFormat *iface)
729 {
730     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
731     ULONG ref = InterlockedIncrement(&This->ref);
732     TRACE("(%p)->(%d)\n", This, ref);
733     return ref;
734 }
735
736 static ULONG WINAPI dwritetextformat_Release(IDWriteTextFormat *iface)
737 {
738     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
739     ULONG ref = InterlockedDecrement(&This->ref);
740
741     TRACE("(%p)->(%d)\n", This, ref);
742
743     if (!ref)
744     {
745         release_format_data(&This->format);
746         heap_free(This);
747     }
748
749     return ref;
750 }
751
752 static HRESULT WINAPI dwritetextformat_SetTextAlignment(IDWriteTextFormat *iface, DWRITE_TEXT_ALIGNMENT alignment)
753 {
754     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
755     FIXME("(%p)->(%d): stub\n", This, alignment);
756     return E_NOTIMPL;
757 }
758
759 static HRESULT WINAPI dwritetextformat_SetParagraphAlignment(IDWriteTextFormat *iface, DWRITE_PARAGRAPH_ALIGNMENT alignment)
760 {
761     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
762     FIXME("(%p)->(%d): stub\n", This, alignment);
763     return E_NOTIMPL;
764 }
765
766 static HRESULT WINAPI dwritetextformat_SetWordWrapping(IDWriteTextFormat *iface, DWRITE_WORD_WRAPPING wrapping)
767 {
768     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
769     FIXME("(%p)->(%d): stub\n", This, wrapping);
770     return E_NOTIMPL;
771 }
772
773 static HRESULT WINAPI dwritetextformat_SetReadingDirection(IDWriteTextFormat *iface, DWRITE_READING_DIRECTION direction)
774 {
775     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
776     FIXME("(%p)->(%d): stub\n", This, direction);
777     return E_NOTIMPL;
778 }
779
780 static HRESULT WINAPI dwritetextformat_SetFlowDirection(IDWriteTextFormat *iface, DWRITE_FLOW_DIRECTION direction)
781 {
782     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
783     FIXME("(%p)->(%d): stub\n", This, direction);
784     return E_NOTIMPL;
785 }
786
787 static HRESULT WINAPI dwritetextformat_SetIncrementalTabStop(IDWriteTextFormat *iface, FLOAT tabstop)
788 {
789     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
790     FIXME("(%p)->(%f): stub\n", This, tabstop);
791     return E_NOTIMPL;
792 }
793
794 static HRESULT WINAPI dwritetextformat_SetTrimming(IDWriteTextFormat *iface, DWRITE_TRIMMING const *trimming,
795     IDWriteInlineObject *trimming_sign)
796 {
797     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
798     FIXME("(%p)->(%p %p): stub\n", This, trimming, trimming_sign);
799     return E_NOTIMPL;
800 }
801
802 static HRESULT WINAPI dwritetextformat_SetLineSpacing(IDWriteTextFormat *iface, DWRITE_LINE_SPACING_METHOD spacing,
803     FLOAT line_spacing, FLOAT baseline)
804 {
805     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
806     FIXME("(%p)->(%d %f %f): stub\n", This, spacing, line_spacing, baseline);
807     return E_NOTIMPL;
808 }
809
810 static DWRITE_TEXT_ALIGNMENT WINAPI dwritetextformat_GetTextAlignment(IDWriteTextFormat *iface)
811 {
812     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
813     FIXME("(%p): stub\n", This);
814     return DWRITE_TEXT_ALIGNMENT_LEADING;
815 }
816
817 static DWRITE_PARAGRAPH_ALIGNMENT WINAPI dwritetextformat_GetParagraphAlignment(IDWriteTextFormat *iface)
818 {
819     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
820     FIXME("(%p): stub\n", This);
821     return DWRITE_PARAGRAPH_ALIGNMENT_NEAR;
822 }
823
824 static DWRITE_WORD_WRAPPING WINAPI dwritetextformat_GetWordWrapping(IDWriteTextFormat *iface)
825 {
826     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
827     FIXME("(%p): stub\n", This);
828     return DWRITE_WORD_WRAPPING_NO_WRAP;
829 }
830
831 static DWRITE_READING_DIRECTION WINAPI dwritetextformat_GetReadingDirection(IDWriteTextFormat *iface)
832 {
833     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
834     FIXME("(%p): stub\n", This);
835     return DWRITE_READING_DIRECTION_LEFT_TO_RIGHT;
836 }
837
838 static DWRITE_FLOW_DIRECTION WINAPI dwritetextformat_GetFlowDirection(IDWriteTextFormat *iface)
839 {
840     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
841     FIXME("(%p): stub\n", This);
842     return DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM;
843 }
844
845 static FLOAT WINAPI dwritetextformat_GetIncrementalTabStop(IDWriteTextFormat *iface)
846 {
847     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
848     FIXME("(%p): stub\n", This);
849     return 0.0;
850 }
851
852 static HRESULT WINAPI dwritetextformat_GetTrimming(IDWriteTextFormat *iface, DWRITE_TRIMMING *options,
853     IDWriteInlineObject **trimming_sign)
854 {
855     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
856     FIXME("(%p)->(%p %p): stub\n", This, options, trimming_sign);
857     return E_NOTIMPL;
858 }
859
860 static HRESULT WINAPI dwritetextformat_GetLineSpacing(IDWriteTextFormat *iface, DWRITE_LINE_SPACING_METHOD *method,
861     FLOAT *spacing, FLOAT *baseline)
862 {
863     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
864     FIXME("(%p)->(%p %p %p): stub\n", This, method, spacing, baseline);
865     return E_NOTIMPL;
866 }
867
868 static HRESULT WINAPI dwritetextformat_GetFontCollection(IDWriteTextFormat *iface, IDWriteFontCollection **collection)
869 {
870     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
871
872     TRACE("(%p)->(%p)\n", This, collection);
873
874     *collection = This->format.collection;
875     IDWriteFontCollection_AddRef(*collection);
876
877     return S_OK;
878 }
879
880 static UINT32 WINAPI dwritetextformat_GetFontFamilyNameLength(IDWriteTextFormat *iface)
881 {
882     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
883     FIXME("(%p): stub\n", This);
884     return 0;
885 }
886
887 static HRESULT WINAPI dwritetextformat_GetFontFamilyName(IDWriteTextFormat *iface, WCHAR *name, UINT32 size)
888 {
889     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
890     FIXME("(%p)->(%p %u): stub\n", This, name, size);
891     return E_NOTIMPL;
892 }
893
894 static DWRITE_FONT_WEIGHT WINAPI dwritetextformat_GetFontWeight(IDWriteTextFormat *iface)
895 {
896     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
897     TRACE("(%p)\n", This);
898     return This->format.weight;
899 }
900
901 static DWRITE_FONT_STYLE WINAPI dwritetextformat_GetFontStyle(IDWriteTextFormat *iface)
902 {
903     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
904     TRACE("(%p)\n", This);
905     return This->format.style;
906 }
907
908 static DWRITE_FONT_STRETCH WINAPI dwritetextformat_GetFontStretch(IDWriteTextFormat *iface)
909 {
910     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
911     TRACE("(%p)\n", This);
912     return This->format.stretch;
913 }
914
915 static FLOAT WINAPI dwritetextformat_GetFontSize(IDWriteTextFormat *iface)
916 {
917     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
918     TRACE("(%p)\n", This);
919     return This->format.size;
920 }
921
922 static UINT32 WINAPI dwritetextformat_GetLocaleNameLength(IDWriteTextFormat *iface)
923 {
924     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
925     TRACE("(%p)\n", This);
926     return This->format.locale_len;
927 }
928
929 static HRESULT WINAPI dwritetextformat_GetLocaleName(IDWriteTextFormat *iface, WCHAR *name, UINT32 size)
930 {
931     struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
932
933     TRACE("(%p)->(%p %u)\n", This, name, size);
934
935     if (size <= This->format.locale_len) return E_NOT_SUFFICIENT_BUFFER;
936     strcpyW(name, This->format.locale);
937     return S_OK;
938 }
939
940 static const IDWriteTextFormatVtbl dwritetextformatvtbl = {
941     dwritetextformat_QueryInterface,
942     dwritetextformat_AddRef,
943     dwritetextformat_Release,
944     dwritetextformat_SetTextAlignment,
945     dwritetextformat_SetParagraphAlignment,
946     dwritetextformat_SetWordWrapping,
947     dwritetextformat_SetReadingDirection,
948     dwritetextformat_SetFlowDirection,
949     dwritetextformat_SetIncrementalTabStop,
950     dwritetextformat_SetTrimming,
951     dwritetextformat_SetLineSpacing,
952     dwritetextformat_GetTextAlignment,
953     dwritetextformat_GetParagraphAlignment,
954     dwritetextformat_GetWordWrapping,
955     dwritetextformat_GetReadingDirection,
956     dwritetextformat_GetFlowDirection,
957     dwritetextformat_GetIncrementalTabStop,
958     dwritetextformat_GetTrimming,
959     dwritetextformat_GetLineSpacing,
960     dwritetextformat_GetFontCollection,
961     dwritetextformat_GetFontFamilyNameLength,
962     dwritetextformat_GetFontFamilyName,
963     dwritetextformat_GetFontWeight,
964     dwritetextformat_GetFontStyle,
965     dwritetextformat_GetFontStretch,
966     dwritetextformat_GetFontSize,
967     dwritetextformat_GetLocaleNameLength,
968     dwritetextformat_GetLocaleName
969 };
970
971 HRESULT create_textformat(const WCHAR *family_name, IDWriteFontCollection *collection, DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style,
972     DWRITE_FONT_STRETCH stretch, FLOAT size, const WCHAR *locale, IDWriteTextFormat **format)
973 {
974     struct dwrite_textformat *This;
975
976     *format = NULL;
977
978     This = heap_alloc(sizeof(struct dwrite_textformat));
979     if (!This) return E_OUTOFMEMORY;
980
981     This->IDWriteTextFormat_iface.lpVtbl = &dwritetextformatvtbl;
982     This->ref = 1;
983     This->format.family_name = heap_strdupW(family_name);
984     This->format.locale = heap_strdupW(locale);
985     This->format.locale_len = strlenW(locale);
986     This->format.weight = weight;
987     This->format.style = style;
988     This->format.size = size;
989
990     if (collection)
991     {
992         This->format.collection = collection;
993         IDWriteFontCollection_AddRef(collection);
994     }
995     else
996     {
997         HRESULT hr = get_system_fontcollection(&This->format.collection);
998         if (hr != S_OK)
999         {
1000             IDWriteTextFormat_Release(&This->IDWriteTextFormat_iface);
1001             return hr;
1002         }
1003     }
1004
1005     *format = &This->IDWriteTextFormat_iface;
1006
1007     return S_OK;
1008 }