dwrite: Added IDWriteTextLayout stub

Nikolay Sivov nsivov at codeweavers.com
Fri Sep 28 03:35:26 CDT 2012


Added IDWriteTextLayout stub
-------------- next part --------------
>From b0321ab95e2e73148c9e1b61b11c7ece2f648884 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Fri, 28 Sep 2012 12:13:17 +0400
Subject: [PATCH 6/6] Added IDWriteTextLayout stub

---
 dlls/dwrite/Makefile.in       |    1 +
 dlls/dwrite/dwrite_private.h  |    4 +-
 dlls/dwrite/layout.c          |  645 +++++++++++++++++++++++++++++++++++++++++
 dlls/dwrite/main.c            |   10 +-
 dlls/dwrite/tests/Makefile.in |    3 +-
 dlls/dwrite/tests/layout.c    |   90 ++++++
 6 files changed, 748 insertions(+), 5 deletions(-)
 create mode 100644 dlls/dwrite/layout.c
 create mode 100644 dlls/dwrite/tests/layout.c

diff --git a/dlls/dwrite/Makefile.in b/dlls/dwrite/Makefile.in
index 6da8c62..1b68b2b 100644
--- a/dlls/dwrite/Makefile.in
+++ b/dlls/dwrite/Makefile.in
@@ -5,6 +5,7 @@ IMPORTS   = gdi32
 C_SRCS = \
 	font.c \
 	gdiinterop.c \
+	layout.c \
 	main.c
 
 @MAKE_DLL_RULES@
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index c3c7cb1..709277e 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -26,5 +26,7 @@ static inline BOOL heap_free(void *mem)
     return HeapFree(GetProcessHeap(), 0, mem);
 }
 
-extern HRESULT create_gdiinterop(IDWriteGdiInterop**) DECLSPEC_HIDDEN;
 extern HRESULT create_font_from_logfont(const LOGFONTW*, IDWriteFont**) DECLSPEC_HIDDEN;
+extern HRESULT create_textlayout(IDWriteTextLayout**) DECLSPEC_HIDDEN;
+extern HRESULT create_gdiinterop(IDWriteGdiInterop**) DECLSPEC_HIDDEN;
+
diff --git a/dlls/dwrite/layout.c b/dlls/dwrite/layout.c
new file mode 100644
index 0000000..31fe99e
--- /dev/null
+++ b/dlls/dwrite/layout.c
@@ -0,0 +1,645 @@
+/*
+ *    Text format and layout
+ *
+ * Copyright 2012 Nikolay Sivov for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "dwrite.h"
+#include "dwrite_private.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
+
+struct dwrite_textlayout {
+    IDWriteTextLayout IDWriteTextLayout_iface;
+    LONG ref;
+};
+
+static inline struct dwrite_textlayout *impl_from_IDWriteTextLayout(IDWriteTextLayout *iface)
+{
+    return CONTAINING_RECORD(iface, struct dwrite_textlayout, IDWriteTextLayout_iface);
+}
+
+static HRESULT WINAPI dwritetextlayout_QueryInterface(IDWriteTextLayout *iface, REFIID riid, void **obj)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+
+    TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
+
+    if (IsEqualIID(riid, &IID_IUnknown) ||
+        IsEqualIID(riid, &IID_IDWriteTextFormat) ||
+        IsEqualIID(riid, &IID_IDWriteTextLayout))
+    {
+        *obj = iface;
+        IDWriteTextLayout_AddRef(iface);
+        return S_OK;
+    }
+
+    *obj = NULL;
+
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI dwritetextlayout_AddRef(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    ULONG ref = InterlockedIncrement(&This->ref);
+    TRACE("(%p)->(%d)\n", This, ref);
+    return ref;
+}
+
+static ULONG WINAPI dwritetextlayout_Release(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    ULONG ref = InterlockedDecrement(&This->ref);
+
+    TRACE("(%p)->(%d)\n", This, ref);
+
+    if (!ref)
+        heap_free(This);
+
+    return S_OK;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetTextAlignment(IDWriteTextLayout *iface, DWRITE_TEXT_ALIGNMENT alignment)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%d): stub\n", This, alignment);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetParagraphAlignment(IDWriteTextLayout *iface, DWRITE_PARAGRAPH_ALIGNMENT alignment)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%d): stub\n", This, alignment);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetWordWrapping(IDWriteTextLayout *iface, DWRITE_WORD_WRAPPING wrapping)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%d): stub\n", This, wrapping);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetReadingDirection(IDWriteTextLayout *iface, DWRITE_READING_DIRECTION direction)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%d): stub\n", This, direction);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetFlowDirection(IDWriteTextLayout *iface, DWRITE_FLOW_DIRECTION direction)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%d): stub\n", This, direction);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetIncrementalTabStop(IDWriteTextLayout *iface, FLOAT tabstop)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%f): stub\n", This, tabstop);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetTrimming(IDWriteTextLayout *iface, DWRITE_TRIMMING const *trimming,
+    IDWriteInlineObject *trimming_sign)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p %p): stub\n", This, trimming, trimming_sign);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetLineSpacing(IDWriteTextLayout *iface, DWRITE_LINE_SPACING_METHOD spacing,
+    FLOAT line_spacing, FLOAT baseline)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%d %f %f): stub\n", This, spacing, line_spacing, baseline);
+    return E_NOTIMPL;
+}
+
+static DWRITE_TEXT_ALIGNMENT WINAPI dwritetextlayout_GetTextAlignment(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p): stub\n", This);
+    return DWRITE_TEXT_ALIGNMENT_LEADING;
+}
+
+static DWRITE_PARAGRAPH_ALIGNMENT WINAPI dwritetextlayout_GetParagraphAlignment(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p): stub\n", This);
+    return DWRITE_PARAGRAPH_ALIGNMENT_NEAR;
+}
+
+static DWRITE_WORD_WRAPPING WINAPI dwritetextlayout_GetWordWrapping(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p): stub\n", This);
+    return DWRITE_WORD_WRAPPING_NO_WRAP;
+}
+
+static DWRITE_READING_DIRECTION WINAPI dwritetextlayout_GetReadingDirection(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p): stub\n", This);
+    return DWRITE_READING_DIRECTION_LEFT_TO_RIGHT;
+}
+
+static DWRITE_FLOW_DIRECTION WINAPI dwritetextlayout_GetFlowDirection(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p): stub\n", This);
+    return DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM;
+}
+
+static FLOAT WINAPI dwritetextlayout_GetIncrementalTabStop(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p): stub\n", This);
+    return 0.0;
+}
+
+static HRESULT WINAPI dwritetextlayout_GetTrimming(IDWriteTextLayout *iface, DWRITE_TRIMMING *options,
+    IDWriteInlineObject **trimming_sign)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p %p): stub\n", This, options, trimming_sign);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_GetLineSpacing(IDWriteTextLayout *iface, DWRITE_LINE_SPACING_METHOD *method,
+    FLOAT *spacing, FLOAT *baseline)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p %p %p): stub\n", This, method, spacing, baseline);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_GetFontCollection(IDWriteTextLayout *iface, IDWriteFontCollection **collection)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p): stub\n", This, collection);
+    return E_NOTIMPL;
+}
+
+static UINT32 WINAPI dwritetextlayout_GetFontFamilyNameLength(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p): stub\n", This);
+    return 0;
+}
+
+static HRESULT WINAPI dwritetextlayout_GetFontFamilyName(IDWriteTextLayout *iface, WCHAR *name, UINT32 size)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p %u): stub\n", This, name, size);
+    return E_NOTIMPL;
+}
+
+static DWRITE_FONT_WEIGHT WINAPI dwritetextlayout_GetFontWeight(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p): stub\n", This);
+    return DWRITE_FONT_WEIGHT_NORMAL;
+}
+
+static DWRITE_FONT_STYLE WINAPI dwritetextlayout_GetFontStyle(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p): stub\n", This);
+    return DWRITE_FONT_STYLE_NORMAL;
+}
+
+static DWRITE_FONT_STRETCH WINAPI dwritetextlayout_GetFontStretch(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p): stub\n", This);
+    return DWRITE_FONT_STRETCH_NORMAL;
+}
+
+static FLOAT WINAPI dwritetextlayout_GetFontSize(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p): stub\n", This);
+    return 0.0;
+}
+
+static UINT32 WINAPI dwritetextlayout_GetLocaleNameLength(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p): stub\n", This);
+    return 0;
+}
+
+static HRESULT WINAPI dwritetextlayout_GetLocaleName(IDWriteTextLayout *iface, WCHAR *name, UINT32 size)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p %u): stub\n", This, name, size);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetMaxWidth(IDWriteTextLayout *iface, FLOAT maxWidth)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%f): stub\n", This, maxWidth);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetMaxHeight(IDWriteTextLayout *iface, FLOAT maxHeight)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%f): stub\n", This, maxHeight);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetFontCollection(IDWriteTextLayout *iface, IDWriteFontCollection* collection, DWRITE_TEXT_RANGE range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p %u:%u): stub\n", This, collection, range.startPosition, range.length);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetFontFamilyName(IDWriteTextLayout *iface, WCHAR const *name, DWRITE_TEXT_RANGE range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%s %u:%u): stub\n", This, debugstr_w(name), range.startPosition, range.length);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetFontWeight(IDWriteTextLayout *iface, DWRITE_FONT_WEIGHT weight, DWRITE_TEXT_RANGE range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%d %u:%u): stub\n", This, weight, range.startPosition, range.length);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetFontStyle(IDWriteTextLayout *iface, DWRITE_FONT_STYLE style, DWRITE_TEXT_RANGE range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%d %u:%u): stub\n", This, style, range.startPosition, range.length);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetFontStretch(IDWriteTextLayout *iface, DWRITE_FONT_STRETCH stretch, DWRITE_TEXT_RANGE range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%d %u:%u): stub\n", This, stretch, range.startPosition, range.length);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetFontSize(IDWriteTextLayout *iface, FLOAT size, DWRITE_TEXT_RANGE range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%f %u:%u): stub\n", This, size, range.startPosition, range.length);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetUnderline(IDWriteTextLayout *iface, BOOL underline, DWRITE_TEXT_RANGE range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%d %u:%u): stub\n", This, underline, range.startPosition, range.length);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetStrikethrough(IDWriteTextLayout *iface, BOOL strikethrough, DWRITE_TEXT_RANGE range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%d %u:%u): stub\n", This, strikethrough, range.startPosition, range.length);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetDrawingEffect(IDWriteTextLayout *iface, IUnknown* effect, DWRITE_TEXT_RANGE range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p %u:%u): stub\n", This, effect, range.startPosition, range.length);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetInlineObject(IDWriteTextLayout *iface, IDWriteInlineObject *object, DWRITE_TEXT_RANGE range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p %u:%u): stub\n", This, object, range.startPosition, range.length);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetTypography(IDWriteTextLayout *iface, IDWriteTypography* typography, DWRITE_TEXT_RANGE range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p %u:%u): stub\n", This, typography, range.startPosition, range.length);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_SetLocaleName(IDWriteTextLayout *iface, WCHAR const* locale, DWRITE_TEXT_RANGE range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%s %u:%u): stub\n", This, debugstr_w(locale), range.startPosition, range.length);
+    return E_NOTIMPL;
+}
+
+static FLOAT WINAPI dwritetextlayout_GetMaxWidth(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p): stub\n", This);
+    return 0.0;
+}
+
+static FLOAT WINAPI dwritetextlayout_GetMaxHeight(IDWriteTextLayout *iface)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p): stub\n", This);
+    return 0.0;
+}
+
+static HRESULT WINAPI dwritetextlayout_layout_GetFontCollection(IDWriteTextLayout *iface, UINT32 pos,
+    IDWriteFontCollection** collection, DWRITE_TEXT_RANGE *range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p %p): stub\n", This, collection, range);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_layout_GetFontFamilyNameLength(IDWriteTextLayout *iface,
+    UINT32 pos, UINT32* len, DWRITE_TEXT_RANGE *range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%d %p %p): stub\n", This, pos, len, range);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_layout_GetFontFamilyName(IDWriteTextLayout *iface,
+    UINT32 position, WCHAR* name, UINT32 name_size, DWRITE_TEXT_RANGE *range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%u %p %u %p): stub\n", This, position, name, name_size, range);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_layout_GetFontWeight(IDWriteTextLayout *iface,
+    UINT32 position, DWRITE_FONT_WEIGHT *weight, DWRITE_TEXT_RANGE *range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%u %p %p): stub\n", This, position, weight, range);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_layout_GetFontStyle(IDWriteTextLayout *iface,
+    UINT32 currentPosition, DWRITE_FONT_STYLE *style, DWRITE_TEXT_RANGE *range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%u %p %p): stub\n", This, currentPosition, style, range);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_layout_GetFontStretch(IDWriteTextLayout *iface,
+    UINT32 position, DWRITE_FONT_STRETCH *stretch, DWRITE_TEXT_RANGE *range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%u %p %p): stub\n", This, position, stretch, range);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_layout_GetFontSize(IDWriteTextLayout *iface,
+    UINT32 position, FLOAT *size, DWRITE_TEXT_RANGE *range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%u %p %p): stub\n", This, position, size, range);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_GetUnderline(IDWriteTextLayout *iface,
+    UINT32 position, BOOL *has_underline, DWRITE_TEXT_RANGE *range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%u %p %p): stub\n", This, position, has_underline, range);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_GetStrikethrough(IDWriteTextLayout *iface,
+    UINT32 position, BOOL *has_strikethrough, DWRITE_TEXT_RANGE *range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%u %p %p): stub\n", This, position, has_strikethrough, range);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_GetDrawingEffect(IDWriteTextLayout *iface,
+    UINT32 position, IUnknown **effect, DWRITE_TEXT_RANGE *range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%u %p %p): stub\n", This, position, effect, range);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_GetInlineObject(IDWriteTextLayout *iface,
+    UINT32 position, IDWriteInlineObject **object, DWRITE_TEXT_RANGE *range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%u %p %p): stub\n", This, position, object, range);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_GetTypography(IDWriteTextLayout *iface,
+    UINT32 position, IDWriteTypography** typography, DWRITE_TEXT_RANGE *range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%u %p %p): stub\n", This, position, typography, range);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_layout_GetLocaleNameLength(IDWriteTextLayout *iface,
+    UINT32 position, UINT32* length, DWRITE_TEXT_RANGE *range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%u %p %p): stub\n", This, position, length, range);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_layout_GetLocaleName(IDWriteTextLayout *iface,
+    UINT32 position, WCHAR* name, UINT32 name_size, DWRITE_TEXT_RANGE *range)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%u %p %u %p): stub\n", This, position, name, name_size, range);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_Draw(IDWriteTextLayout *iface,
+    void *context, IDWriteTextRenderer* renderer, FLOAT originX, FLOAT originY)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p %p %f %f): stub\n", This, context, renderer, originX, originY);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_GetLineMetrics(IDWriteTextLayout *iface,
+    DWRITE_LINE_METRICS *metrics, UINT32 max_count, UINT32 *actual_count)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p %u %p): stub\n", This, metrics, max_count, actual_count);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_GetMetrics(IDWriteTextLayout *iface, DWRITE_TEXT_METRICS *metrics)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p): stub\n", This, metrics);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_GetOverhangMetrics(IDWriteTextLayout *iface, DWRITE_OVERHANG_METRICS *overhangs)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p): stub\n", This, overhangs);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_GetClusterMetrics(IDWriteTextLayout *iface,
+    DWRITE_CLUSTER_METRICS *metrics, UINT32 max_count, UINT32* act_count)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p %u %p): stub\n", This, metrics, max_count, act_count);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_DetermineMinWidth(IDWriteTextLayout *iface, FLOAT* min_width)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%p): stub\n", This, min_width);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_HitTestPoint(IDWriteTextLayout *iface,
+    FLOAT pointX, FLOAT pointY, BOOL* is_trailinghit, BOOL* is_inside, DWRITE_HIT_TEST_METRICS *metrics)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%f %f %p %p %p): stub\n", This, pointX, pointY, is_trailinghit, is_inside, metrics);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_HitTestTextPosition(IDWriteTextLayout *iface,
+    UINT32 textPosition, BOOL is_trailinghit, FLOAT* pointX, FLOAT* pointY, DWRITE_HIT_TEST_METRICS *metrics)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%u %d %p %p %p): stub\n", This, textPosition, is_trailinghit, pointX, pointY, metrics);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dwritetextlayout_HitTestTextRange(IDWriteTextLayout *iface,
+    UINT32 textPosition, UINT32 textLength, FLOAT originX, FLOAT originY,
+    DWRITE_HIT_TEST_METRICS *metrics, UINT32 max_metricscount, UINT32* actual_metricscount)
+{
+    struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
+    FIXME("(%p)->(%u %u %f %f %p %u %p): stub\n", This, textPosition, textLength, originX, originY, metrics,
+        max_metricscount, actual_metricscount);
+    return E_NOTIMPL;
+}
+
+static const IDWriteTextLayoutVtbl dwritetextlayoutvtbl = {
+    dwritetextlayout_QueryInterface,
+    dwritetextlayout_AddRef,
+    dwritetextlayout_Release,
+    dwritetextlayout_SetTextAlignment,
+    dwritetextlayout_SetParagraphAlignment,
+    dwritetextlayout_SetWordWrapping,
+    dwritetextlayout_SetReadingDirection,
+    dwritetextlayout_SetFlowDirection,
+    dwritetextlayout_SetIncrementalTabStop,
+    dwritetextlayout_SetTrimming,
+    dwritetextlayout_SetLineSpacing,
+    dwritetextlayout_GetTextAlignment,
+    dwritetextlayout_GetParagraphAlignment,
+    dwritetextlayout_GetWordWrapping,
+    dwritetextlayout_GetReadingDirection,
+    dwritetextlayout_GetFlowDirection,
+    dwritetextlayout_GetIncrementalTabStop,
+    dwritetextlayout_GetTrimming,
+    dwritetextlayout_GetLineSpacing,
+    dwritetextlayout_GetFontCollection,
+    dwritetextlayout_GetFontFamilyNameLength,
+    dwritetextlayout_GetFontFamilyName,
+    dwritetextlayout_GetFontWeight,
+    dwritetextlayout_GetFontStyle,
+    dwritetextlayout_GetFontStretch,
+    dwritetextlayout_GetFontSize,
+    dwritetextlayout_GetLocaleNameLength,
+    dwritetextlayout_GetLocaleName,
+    dwritetextlayout_SetMaxWidth,
+    dwritetextlayout_SetMaxHeight,
+    dwritetextlayout_SetFontCollection,
+    dwritetextlayout_SetFontFamilyName,
+    dwritetextlayout_SetFontWeight,
+    dwritetextlayout_SetFontStyle,
+    dwritetextlayout_SetFontStretch,
+    dwritetextlayout_SetFontSize,
+    dwritetextlayout_SetUnderline,
+    dwritetextlayout_SetStrikethrough,
+    dwritetextlayout_SetDrawingEffect,
+    dwritetextlayout_SetInlineObject,
+    dwritetextlayout_SetTypography,
+    dwritetextlayout_SetLocaleName,
+    dwritetextlayout_GetMaxWidth,
+    dwritetextlayout_GetMaxHeight,
+    dwritetextlayout_layout_GetFontCollection,
+    dwritetextlayout_layout_GetFontFamilyNameLength,
+    dwritetextlayout_layout_GetFontFamilyName,
+    dwritetextlayout_layout_GetFontWeight,
+    dwritetextlayout_layout_GetFontStyle,
+    dwritetextlayout_layout_GetFontStretch,
+    dwritetextlayout_layout_GetFontSize,
+    dwritetextlayout_GetUnderline,
+    dwritetextlayout_GetStrikethrough,
+    dwritetextlayout_GetDrawingEffect,
+    dwritetextlayout_GetInlineObject,
+    dwritetextlayout_GetTypography,
+    dwritetextlayout_layout_GetLocaleNameLength,
+    dwritetextlayout_layout_GetLocaleName,
+    dwritetextlayout_Draw,
+    dwritetextlayout_GetLineMetrics,
+    dwritetextlayout_GetMetrics,
+    dwritetextlayout_GetOverhangMetrics,
+    dwritetextlayout_GetClusterMetrics,
+    dwritetextlayout_DetermineMinWidth,
+    dwritetextlayout_HitTestPoint,
+    dwritetextlayout_HitTestTextPosition,
+    dwritetextlayout_HitTestTextRange
+};
+
+HRESULT create_textlayout(IDWriteTextLayout **layout)
+{
+    struct dwrite_textlayout *This;
+
+    *layout = NULL;
+
+    This = heap_alloc(sizeof(struct dwrite_textlayout));
+    if (!This) return E_OUTOFMEMORY;
+
+    This->IDWriteTextLayout_iface.lpVtbl = &dwritetextlayoutvtbl;
+    This->ref = 1;
+
+    *layout = &This->IDWriteTextLayout_iface;
+
+    return S_OK;
+}
diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c
index ca7de8e..114fab9 100644
--- a/dlls/dwrite/main.c
+++ b/dlls/dwrite/main.c
@@ -177,16 +177,20 @@ static HRESULT WINAPI dwritefactory_CreateTextLayout(IDWriteFactory *iface, WCHA
     UINT32 len, IDWriteTextFormat *format, FLOAT max_width, FLOAT max_height, IDWriteTextLayout **layout)
 {
     FIXME("(%s %u %p %f %f %p): stub\n", debugstr_w(string), len, format, max_width, max_height, layout);
-    return E_NOTIMPL;
+
+    if (!format) return E_INVALIDARG;
+    return create_textlayout(layout);
 }
 
 static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory *iface, WCHAR const* string,
     UINT32 len, IDWriteTextFormat *format, FLOAT layout_width, FLOAT layout_height, FLOAT pixels_per_dip,
     DWRITE_MATRIX const* transform, BOOL use_gdi_natural, IDWriteTextLayout **layout)
 {
-    FIXME("(%s:%u %p %f %f %f %p %d %p): stub\n", debugstr_wn(string, len), len, format, layout_width, layout_height,
+    FIXME("(%s:%u %p %f %f %f %p %d %p): semi-stub\n", debugstr_wn(string, len), len, format, layout_width, layout_height,
         pixels_per_dip, transform, use_gdi_natural, layout);
-    return E_NOTIMPL;
+
+    if (!format) return E_INVALIDARG;
+    return create_textlayout(layout);
 }
 
 static HRESULT WINAPI dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory *iface, IDWriteTextFormat *format,
diff --git a/dlls/dwrite/tests/Makefile.in b/dlls/dwrite/tests/Makefile.in
index 98843cf..9009a8f 100644
--- a/dlls/dwrite/tests/Makefile.in
+++ b/dlls/dwrite/tests/Makefile.in
@@ -2,6 +2,7 @@ TESTDLL = dwrite.dll
 IMPORTS = dwrite gdi32
 
 C_SRCS = \
-	font.c
+	font.c \
+	layout.c
 
 @MAKE_TEST_RULES@
diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c
new file mode 100644
index 0000000..6e2c718
--- /dev/null
+++ b/dlls/dwrite/tests/layout.c
@@ -0,0 +1,90 @@
+/*
+ *    Text layout/format tests
+ *
+ * Copyright 2012 Nikolay Sivov for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+
+#include "windows.h"
+#include "dwrite.h"
+
+#include "wine/test.h"
+
+static IDWriteFactory *factory;
+
+static void test_CreateTextLayout(void)
+{
+    static const WCHAR strW[] = {'s','t','r','i','n','g',0};
+    IDWriteTextLayout *layout;
+    HRESULT hr;
+
+    hr = IDWriteFactory_CreateTextLayout(factory, NULL, 0, NULL, 0.0, 0.0, &layout);
+    ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+    hr = IDWriteFactory_CreateTextLayout(factory, strW, 6, NULL, 0.0, 0.0, &layout);
+    ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+    hr = IDWriteFactory_CreateTextLayout(factory, strW, 6, NULL, 1.0, 0.0, &layout);
+    ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+    hr = IDWriteFactory_CreateTextLayout(factory, strW, 6, NULL, 0.0, 1.0, &layout);
+    ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+    hr = IDWriteFactory_CreateTextLayout(factory, strW, 6, NULL, 1000.0, 1000.0, &layout);
+    ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+}
+
+static void test_CreateGdiCompatibleTextLayout(void)
+{
+    static const WCHAR strW[] = {'s','t','r','i','n','g',0};
+    IDWriteTextLayout *layout;
+    HRESULT hr;
+
+    hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, NULL, 0, NULL, 0.0, 0.0, 0.0, NULL, FALSE, &layout);
+    ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+    hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, strW, 6, NULL, 0.0, 0.0, 0.0, NULL, FALSE, &layout);
+    ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+    hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, strW, 6, NULL, 1.0, 0.0, 0.0, NULL, FALSE, &layout);
+    ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+    hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, strW, 6, NULL, 1.0, 0.0, 1.0, NULL, FALSE, &layout);
+    ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+    hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, strW, 6, NULL, 1000.0, 1000.0, 1.0, NULL, FALSE, &layout);
+    ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+}
+
+START_TEST(layout)
+{
+    HRESULT hr;
+
+    hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, &IID_IDWriteFactory, (IUnknown**)&factory);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+    if (hr != S_OK)
+    {
+        win_skip("failed to create factory\n");
+        return;
+    }
+
+    test_CreateTextLayout();
+    test_CreateGdiCompatibleTextLayout();
+
+    IDWriteFactory_Release(factory);
+}
-- 
1.5.6.5




More information about the wine-patches mailing list