dwrite: Store last line wrapping property.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2015-12-25 15:57:59 +03:00 committed by Alexandre Julliard
parent 7a83be7bd2
commit 3905ed8c47
2 changed files with 68 additions and 12 deletions

View File

@ -45,6 +45,7 @@ struct dwrite_textformat_data {
DWRITE_PARAGRAPH_ALIGNMENT paralign;
DWRITE_READING_DIRECTION readingdir;
DWRITE_WORD_WRAPPING wrapping;
BOOL last_line_wrapping;
DWRITE_TEXT_ALIGNMENT textalignment;
DWRITE_FLOW_DIRECTION flow;
DWRITE_LINE_SPACING_METHOD spacingmethod;
@ -3202,15 +3203,15 @@ static DWRITE_VERTICAL_GLYPH_ORIENTATION WINAPI dwritetextlayout2_GetVerticalGly
static HRESULT WINAPI dwritetextlayout2_SetLastLineWrapping(IDWriteTextLayout2 *iface, BOOL lastline_wrapping_enabled)
{
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
FIXME("(%p)->(%d): stub\n", This, lastline_wrapping_enabled);
return E_NOTIMPL;
TRACE("(%p)->(%d)\n", This, lastline_wrapping_enabled);
return IDWriteTextFormat1_SetLastLineWrapping(&This->IDWriteTextFormat1_iface, lastline_wrapping_enabled);
}
static BOOL WINAPI dwritetextlayout2_GetLastLineWrapping(IDWriteTextLayout2 *iface)
{
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
FIXME("(%p): stub\n", This);
return FALSE;
TRACE("(%p)\n", This);
return IDWriteTextFormat1_GetLastLineWrapping(&This->IDWriteTextFormat1_iface);
}
static HRESULT WINAPI dwritetextlayout2_SetOpticalAlignment(IDWriteTextLayout2 *iface, DWRITE_OPTICAL_ALIGNMENT alignment)
@ -3609,15 +3610,18 @@ static DWRITE_VERTICAL_GLYPH_ORIENTATION WINAPI dwritetextformat1_layout_GetVert
static HRESULT WINAPI dwritetextformat1_layout_SetLastLineWrapping(IDWriteTextFormat1 *iface, BOOL lastline_wrapping_enabled)
{
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
FIXME("(%p)->(%d): stub\n", This, lastline_wrapping_enabled);
return E_NOTIMPL;
TRACE("(%p)->(%d)\n", This, lastline_wrapping_enabled);
This->format.last_line_wrapping = !!lastline_wrapping_enabled;
return S_OK;
}
static BOOL WINAPI dwritetextformat1_layout_GetLastLineWrapping(IDWriteTextFormat1 *iface)
{
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
FIXME("(%p): stub\n", This);
return FALSE;
TRACE("(%p)\n", This);
return This->format.last_line_wrapping;
}
static HRESULT WINAPI dwritetextformat1_layout_SetOpticalAlignment(IDWriteTextFormat1 *iface, DWRITE_OPTICAL_ALIGNMENT alignment)
@ -4542,15 +4546,18 @@ static DWRITE_VERTICAL_GLYPH_ORIENTATION WINAPI dwritetextformat1_GetVerticalGly
static HRESULT WINAPI dwritetextformat1_SetLastLineWrapping(IDWriteTextFormat1 *iface, BOOL lastline_wrapping_enabled)
{
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
FIXME("(%p)->(%d): stub\n", This, lastline_wrapping_enabled);
return E_NOTIMPL;
TRACE("(%p)->(%d)\n", This, lastline_wrapping_enabled);
This->format.last_line_wrapping = !!lastline_wrapping_enabled;
return S_OK;
}
static BOOL WINAPI dwritetextformat1_GetLastLineWrapping(IDWriteTextFormat1 *iface)
{
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
FIXME("(%p): stub\n", This);
return FALSE;
TRACE("(%p)\n", This);
return This->format.last_line_wrapping;
}
static HRESULT WINAPI dwritetextformat1_SetOpticalAlignment(IDWriteTextFormat1 *iface, DWRITE_OPTICAL_ALIGNMENT alignment)
@ -4649,6 +4656,7 @@ HRESULT create_textformat(const WCHAR *family_name, IDWriteFontCollection *colle
This->format.textalignment = DWRITE_TEXT_ALIGNMENT_LEADING;
This->format.paralign = DWRITE_PARAGRAPH_ALIGNMENT_NEAR;
This->format.wrapping = DWRITE_WORD_WRAPPING_WRAP;
This->format.last_line_wrapping = TRUE;
This->format.readingdir = DWRITE_READING_DIRECTION_LEFT_TO_RIGHT;
This->format.flow = DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM;
This->format.spacingmethod = DWRITE_LINE_SPACING_METHOD_DEFAULT;

View File

@ -4130,6 +4130,53 @@ static void test_SetTypography(void)
IDWriteFactory_Release(factory);
}
static void test_SetLastLineWrapping(void)
{
static const WCHAR strW[] = {'a',0};
IDWriteTextLayout2 *layout2;
IDWriteTextFormat1 *format1;
IDWriteTextLayout *layout;
IDWriteTextFormat *format;
IDWriteFactory *factory;
HRESULT hr;
BOOL ret;
factory = create_factory();
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);
hr = IDWriteTextFormat_QueryInterface(format, &IID_IDWriteTextFormat1, (void**)&format1);
IDWriteTextFormat_Release(format);
if (hr != S_OK) {
win_skip("SetLastLineWrapping() is not supported\n");
IDWriteFactory_Release(factory);
return;
}
ret = IDWriteTextFormat1_GetLastLineWrapping(format1);
ok(ret, "got %d\n", ret);
hr = IDWriteTextFormat1_SetLastLineWrapping(format1, FALSE);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteFactory_CreateTextLayout(factory, strW, 1, (IDWriteTextFormat*)format1, 1000.0, 1000.0, &layout);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteTextLayout_QueryInterface(layout, &IID_IDWriteTextLayout2, (void**)&layout2);
ok(hr == S_OK, "got 0x%08x\n", hr);
IDWriteTextLayout_Release(layout);
ret = IDWriteTextLayout2_GetLastLineWrapping(layout2);
ok(!ret, "got %d\n", ret);
hr = IDWriteTextLayout2_SetLastLineWrapping(layout2, TRUE);
ok(hr == S_OK, "got 0x%08x\n", hr);
IDWriteFactory_Release(factory);
}
START_TEST(layout)
{
static const WCHAR ctrlstrW[] = {0x202a,0};
@ -4178,6 +4225,7 @@ START_TEST(layout)
test_MapCharacters();
test_FontFallbackBuilder();
test_SetTypography();
test_SetLastLineWrapping();
IDWriteFactory_Release(factory);
}