Commit 27e86cfc authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Added partial implementation for CreateEllipsisTrimmingSign().

parent 6b560c92
......@@ -76,6 +76,7 @@ extern HRESULT convert_fontface_to_logfont(IDWriteFontFace*, LOGFONTW*) DECLSPEC
extern HRESULT create_textformat(const WCHAR*,IDWriteFontCollection*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH,
FLOAT,const WCHAR*,IDWriteTextFormat**) DECLSPEC_HIDDEN;
extern HRESULT create_textlayout(const WCHAR*,UINT32,IDWriteTextFormat*,IDWriteTextLayout**) DECLSPEC_HIDDEN;
extern HRESULT create_trimmingsign(IDWriteInlineObject**) DECLSPEC_HIDDEN;
extern HRESULT get_gdiinterop(IDWriteGdiInterop**) DECLSPEC_HIDDEN;
extern HRESULT create_localizedstrings(IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
extern HRESULT add_localizedstring(IDWriteLocalizedStrings*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN;
......
......@@ -74,6 +74,11 @@ struct dwrite_textformat {
struct dwrite_textformat_data format;
};
struct dwrite_trimmingsign {
IDWriteInlineObject IDWriteInlineObject_iface;
LONG ref;
};
static const IDWriteTextFormatVtbl dwritetextformatvtbl;
static void release_format_data(struct dwrite_textformat_data *data)
......@@ -99,6 +104,11 @@ static inline struct dwrite_textformat *unsafe_impl_from_IDWriteTextFormat(IDWri
return iface->lpVtbl == &dwritetextformatvtbl ? impl_from_IDWriteTextFormat(iface) : NULL;
}
static inline struct dwrite_trimmingsign *impl_from_IDWriteInlineObject(IDWriteInlineObject *iface)
{
return CONTAINING_RECORD(iface, struct dwrite_trimmingsign, IDWriteInlineObject_iface);
}
static HRESULT WINAPI dwritetextlayout_QueryInterface(IDWriteTextLayout *iface, REFIID riid, void **obj)
{
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
......@@ -762,6 +772,104 @@ HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *forma
return S_OK;
}
static HRESULT WINAPI dwritetrimmingsign_QueryInterface(IDWriteInlineObject *iface, REFIID riid, void **obj)
{
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteInlineObject)) {
*obj = iface;
IDWriteInlineObject_AddRef(iface);
return S_OK;
}
*obj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI dwritetrimmingsign_AddRef(IDWriteInlineObject *iface)
{
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->(%d)\n", This, ref);
return ref;
}
static ULONG WINAPI dwritetrimmingsign_Release(IDWriteInlineObject *iface)
{
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->(%d)\n", This, ref);
if (!ref)
heap_free(This);
return ref;
}
static HRESULT WINAPI dwritetrimmingsign_Draw(IDWriteInlineObject *iface, void *context, IDWriteTextRenderer *renderer,
FLOAT originX, FLOAT originY, BOOL is_sideways, BOOL is_rtl, IUnknown *drawing_effect)
{
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
FIXME("(%p)->(%p %p %f %f %d %d %p): stub\n", This, context, renderer, originX, originY, is_sideways, is_rtl, drawing_effect);
return E_NOTIMPL;
}
static HRESULT WINAPI dwritetrimmingsign_GetMetrics(IDWriteInlineObject *iface, DWRITE_INLINE_OBJECT_METRICS *metrics)
{
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
FIXME("(%p)->(%p): stub\n", This, metrics);
return E_NOTIMPL;
}
static HRESULT WINAPI dwritetrimmingsign_GetOverhangMetrics(IDWriteInlineObject *iface, DWRITE_OVERHANG_METRICS *overhangs)
{
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
FIXME("(%p)->(%p): stub\n", This, overhangs);
return E_NOTIMPL;
}
static HRESULT WINAPI dwritetrimmingsign_GetBreakConditions(IDWriteInlineObject *iface, DWRITE_BREAK_CONDITION *before,
DWRITE_BREAK_CONDITION *after)
{
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
TRACE("(%p)->(%p %p)\n", This, before, after);
*before = *after = DWRITE_BREAK_CONDITION_NEUTRAL;
return S_OK;
}
static const IDWriteInlineObjectVtbl dwritetrimmingsignvtbl = {
dwritetrimmingsign_QueryInterface,
dwritetrimmingsign_AddRef,
dwritetrimmingsign_Release,
dwritetrimmingsign_Draw,
dwritetrimmingsign_GetMetrics,
dwritetrimmingsign_GetOverhangMetrics,
dwritetrimmingsign_GetBreakConditions
};
HRESULT create_trimmingsign(IDWriteInlineObject **sign)
{
struct dwrite_trimmingsign *This;
*sign = NULL;
This = heap_alloc(sizeof(struct dwrite_trimmingsign));
if (!This) return E_OUTOFMEMORY;
This->IDWriteInlineObject_iface.lpVtbl = &dwritetrimmingsignvtbl;
This->ref = 1;
*sign = &This->IDWriteInlineObject_iface;
return S_OK;
}
static HRESULT WINAPI dwritetextformat_QueryInterface(IDWriteTextFormat *iface, REFIID riid, void **obj)
{
struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
......
......@@ -527,8 +527,8 @@ static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory
static HRESULT WINAPI dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory *iface, IDWriteTextFormat *format,
IDWriteInlineObject **trimming_sign)
{
FIXME("(%p %p): stub\n", format, trimming_sign);
return E_NOTIMPL;
FIXME("(%p %p): semi-stub\n", format, trimming_sign);
return create_trimmingsign(trimming_sign);
}
static HRESULT WINAPI dwritefactory_CreateTextAnalyzer(IDWriteFactory *iface, IDWriteTextAnalyzer **analyzer)
......
......@@ -233,6 +233,35 @@ static void test_GetLocaleName(void)
IDWriteTextFormat_Release(format);
}
static void test_CreateEllipsisTrimmingSign(void)
{
DWRITE_BREAK_CONDITION before, after;
IDWriteTextFormat *format;
IDWriteInlineObject *sign;
HRESULT hr;
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format);
ok(hr == S_OK, "got 0x%08x\n", hr);
EXPECT_REF(format, 1);
hr = IDWriteFactory_CreateEllipsisTrimmingSign(factory, format, &sign);
ok(hr == S_OK, "got 0x%08x\n", hr);
EXPECT_REF(format, 1);
if (0) /* crashes on native */
hr = IDWriteInlineObject_GetBreakConditions(sign, NULL, NULL);
before = after = DWRITE_BREAK_CONDITION_CAN_BREAK;
hr = IDWriteInlineObject_GetBreakConditions(sign, &before, &after);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(before == DWRITE_BREAK_CONDITION_NEUTRAL, "got %d\n", before);
ok(after == DWRITE_BREAK_CONDITION_NEUTRAL, "got %d\n", after);
IDWriteInlineObject_Release(sign);
IDWriteTextFormat_Release(format);
}
START_TEST(layout)
{
HRESULT hr;
......@@ -249,6 +278,7 @@ START_TEST(layout)
test_CreateGdiCompatibleTextLayout();
test_CreateTextFormat();
test_GetLocaleName();
test_CreateEllipsisTrimmingSign();
IDWriteFactory_Release(factory);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment