1999-02-20 17:48:53 +01:00
|
|
|
/*
|
|
|
|
* OLE Font encapsulation implementation
|
|
|
|
*
|
|
|
|
* This file contains an implementation of the IFont
|
|
|
|
* interface and the OleCreateFontIndirect API call.
|
|
|
|
*
|
|
|
|
* Copyright 1999 Francis Beaudet
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-02-20 17:48:53 +01:00
|
|
|
*/
|
|
|
|
#include <assert.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1999-02-28 13:27:56 +01:00
|
|
|
#include <string.h>
|
2003-01-07 21:36:20 +01:00
|
|
|
|
2004-08-11 21:43:45 +02:00
|
|
|
#define COBJMACROS
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2004-08-11 21:43:45 +02:00
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
#include "winerror.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2000-09-26 02:00:55 +02:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
2000-11-30 02:31:28 +01:00
|
|
|
#include "winuser.h"
|
2000-08-14 16:41:19 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-12-05 21:33:07 +01:00
|
|
|
#include "objbase.h"
|
2004-08-22 23:38:46 +02:00
|
|
|
#include "oleauto.h" /* for SysAllocString(....) */
|
2000-11-30 02:31:28 +01:00
|
|
|
#include "ole2.h"
|
1999-02-20 17:48:53 +01:00
|
|
|
#include "olectl.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-07-28 22:17:21 +02:00
|
|
|
#include "connpt.h" /* for CreateConnectionPoint */
|
2006-02-10 14:50:26 +01:00
|
|
|
#include "oaidl.h"
|
1999-02-20 17:48:53 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
/***********************************************************************
|
1999-03-13 18:59:07 +01:00
|
|
|
* Declaration of constants used when serializing the font object.
|
|
|
|
*/
|
|
|
|
#define FONTPERSIST_ITALIC 0x02
|
|
|
|
#define FONTPERSIST_UNDERLINE 0x04
|
|
|
|
#define FONTPERSIST_STRIKETHROUGH 0x08
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* Declaration of the implementation class for the IFont interface
|
1999-02-20 17:48:53 +01:00
|
|
|
*/
|
|
|
|
typedef struct OLEFontImpl OLEFontImpl;
|
|
|
|
|
|
|
|
struct OLEFontImpl
|
|
|
|
{
|
|
|
|
/*
|
2002-06-01 01:06:46 +02:00
|
|
|
* This class supports many interfaces. IUnknown, IFont,
|
2000-07-28 22:17:21 +02:00
|
|
|
* IDispatch, IDispFont IPersistStream and IConnectionPointContainer.
|
|
|
|
* The first two are supported by the first vtable, the next two are
|
|
|
|
* supported by the second table and the last two have their own.
|
1999-02-20 17:48:53 +01:00
|
|
|
*/
|
2005-07-27 17:14:18 +02:00
|
|
|
const IFontVtbl* lpVtbl;
|
|
|
|
const IDispatchVtbl* lpvtblIDispatch;
|
|
|
|
const IPersistStreamVtbl* lpvtblIPersistStream;
|
|
|
|
const IConnectionPointContainerVtbl* lpvtblIConnectionPointContainer;
|
|
|
|
const IPersistPropertyBagVtbl* lpvtblIPersistPropertyBag;
|
|
|
|
const IPersistStreamInitVtbl* lpvtblIPersistStreamInit;
|
1999-02-20 17:48:53 +01:00
|
|
|
/*
|
|
|
|
* Reference count for that instance of the class.
|
|
|
|
*/
|
2005-07-11 12:25:19 +02:00
|
|
|
LONG ref;
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This structure contains the description of the class.
|
|
|
|
*/
|
|
|
|
FONTDESC description;
|
1999-03-13 18:59:07 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Contain the font associated with this object.
|
|
|
|
*/
|
|
|
|
HFONT gdiFont;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Font lock count.
|
|
|
|
*/
|
|
|
|
DWORD fontLock;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Size ratio
|
|
|
|
*/
|
|
|
|
long cyLogical;
|
|
|
|
long cyHimetric;
|
2000-07-28 22:17:21 +02:00
|
|
|
|
2006-02-10 14:50:26 +01:00
|
|
|
IConnectionPoint *pPropertyNotifyCP;
|
|
|
|
IConnectionPoint *pFontEventsCP;
|
1999-02-20 17:48:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Here, I define utility macros to help with the casting of the
|
1999-02-20 17:48:53 +01:00
|
|
|
* "this" parameter.
|
2004-10-05 20:15:29 +02:00
|
|
|
* There is a version to accommodate all of the VTables implemented
|
1999-03-13 18:59:07 +01:00
|
|
|
* by this object.
|
1999-02-20 17:48:53 +01:00
|
|
|
*/
|
2005-07-27 17:14:18 +02:00
|
|
|
|
|
|
|
static inline OLEFontImpl *impl_from_IDispatch( IDispatch *iface )
|
|
|
|
{
|
|
|
|
return (OLEFontImpl *)((char*)iface - FIELD_OFFSET(OLEFontImpl, lpvtblIDispatch));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline OLEFontImpl *impl_from_IPersistStream( IPersistStream *iface )
|
|
|
|
{
|
|
|
|
return (OLEFontImpl *)((char*)iface - FIELD_OFFSET(OLEFontImpl, lpvtblIPersistStream));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline OLEFontImpl *impl_from_IConnectionPointContainer( IConnectionPointContainer *iface )
|
|
|
|
{
|
|
|
|
return (OLEFontImpl *)((char*)iface - FIELD_OFFSET(OLEFontImpl, lpvtblIConnectionPointContainer));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline OLEFontImpl *impl_from_IPersistPropertyBag( IPersistPropertyBag *iface )
|
|
|
|
{
|
|
|
|
return (OLEFontImpl *)((char*)iface - FIELD_OFFSET(OLEFontImpl, lpvtblIPersistPropertyBag));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline OLEFontImpl *impl_from_IPersistStreamInit( IPersistStreamInit *iface )
|
|
|
|
{
|
|
|
|
return (OLEFontImpl *)((char*)iface - FIELD_OFFSET(OLEFontImpl, lpvtblIPersistStreamInit));
|
|
|
|
}
|
2000-07-28 22:17:21 +02:00
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* Prototypes for the implementation functions for the IFont
|
|
|
|
* interface
|
|
|
|
*/
|
|
|
|
static OLEFontImpl* OLEFontImpl_Construct(LPFONTDESC fontDesc);
|
|
|
|
static void OLEFontImpl_Destroy(OLEFontImpl* fontDesc);
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_QueryInterface(IFont* iface, REFIID riid, VOID** ppvoid);
|
|
|
|
static ULONG WINAPI OLEFontImpl_AddRef(IFont* iface);
|
|
|
|
static ULONG WINAPI OLEFontImpl_Release(IFont* iface);
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Name(IFont* iface, BSTR* pname);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Name(IFont* iface, BSTR name);
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Size(IFont* iface, CY* psize);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Size(IFont* iface, CY size);
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Bold(IFont* iface, BOOL* pbold);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Bold(IFont* iface, BOOL bold);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Italic(IFont* iface, BOOL* pitalic);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Italic(IFont* iface, BOOL italic);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Underline(IFont* iface, BOOL* punderline);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Underline(IFont* iface, BOOL underline);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Strikethrough(IFont* iface, BOOL* pstrikethrough);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Strikethrough(IFont* iface, BOOL strikethrough);
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Weight(IFont* iface, short* pweight);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Weight(IFont* iface, short weight);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Charset(IFont* iface, short* pcharset);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Charset(IFont* iface, short charset);
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_get_hFont(IFont* iface, HFONT* phfont);
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_Clone(IFont* iface, IFont** ppfont);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IsEqual(IFont* iface, IFont* pFontOther);
|
2004-10-19 00:39:21 +02:00
|
|
|
static HRESULT WINAPI OLEFontImpl_SetRatio(IFont* iface, LONG cyLogical, LONG cyHimetric);
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_QueryTextMetrics(IFont* iface, TEXTMETRICOLE* ptm);
|
1999-02-26 12:11:13 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_AddRefHfont(IFont* iface, HFONT hfont);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_ReleaseHfont(IFont* iface, HFONT hfont);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_SetHdc(IFont* iface, HDC hdc);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* Prototypes for the implementation functions for the IDispatch
|
|
|
|
* interface
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface,
|
|
|
|
REFIID riid,
|
1999-02-20 17:48:53 +01:00
|
|
|
VOID** ppvoid);
|
1999-02-21 19:16:08 +01:00
|
|
|
static ULONG WINAPI OLEFontImpl_IDispatch_AddRef(IDispatch* iface);
|
|
|
|
static ULONG WINAPI OLEFontImpl_IDispatch_Release(IDispatch* iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch* iface,
|
1999-02-21 19:16:08 +01:00
|
|
|
unsigned int* pctinfo);
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
UINT iTInfo,
|
2002-06-01 01:06:46 +02:00
|
|
|
LCID lcid,
|
1999-02-21 19:16:08 +01:00
|
|
|
ITypeInfo** ppTInfo);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(IDispatch* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
1999-02-21 19:16:08 +01:00
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_Invoke(IDispatch* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
1999-02-21 19:16:08 +01:00
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
2002-06-01 01:06:46 +02:00
|
|
|
VARIANT* pVarResult,
|
1999-02-21 19:16:08 +01:00
|
|
|
EXCEPINFO* pExepInfo,
|
2002-06-01 01:06:46 +02:00
|
|
|
UINT* puArgErr);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
1999-03-13 18:59:07 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* Prototypes for the implementation functions for the IPersistStream
|
|
|
|
* interface
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface,
|
|
|
|
REFIID riid,
|
1999-03-13 18:59:07 +01:00
|
|
|
VOID** ppvoid);
|
|
|
|
static ULONG WINAPI OLEFontImpl_IPersistStream_AddRef(IPersistStream* iface);
|
|
|
|
static ULONG WINAPI OLEFontImpl_IPersistStream_Release(IPersistStream* iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface,
|
1999-03-13 18:59:07 +01:00
|
|
|
CLSID* pClassID);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IsDirty(IPersistStream* iface);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_Load(IPersistStream* iface,
|
|
|
|
IStream* pLoadStream);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_Save(IPersistStream* iface,
|
|
|
|
IStream* pOutStream,
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL fClearDirty);
|
1999-03-13 18:59:07 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_GetSizeMax(IPersistStream* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
ULARGE_INTEGER* pcbSize);
|
1999-03-13 18:59:07 +01:00
|
|
|
|
2000-07-28 22:17:21 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* Prototypes for the implementation functions for the
|
|
|
|
* IConnectionPointContainer interface
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IConnectionPointContainer_QueryInterface(
|
2002-06-01 01:06:46 +02:00
|
|
|
IConnectionPointContainer* iface,
|
|
|
|
REFIID riid,
|
2000-07-28 22:17:21 +02:00
|
|
|
VOID** ppvoid);
|
|
|
|
static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_AddRef(
|
|
|
|
IConnectionPointContainer* iface);
|
|
|
|
static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_Release(
|
|
|
|
IConnectionPointContainer* iface);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_EnumConnectionPoints(
|
|
|
|
IConnectionPointContainer* iface,
|
|
|
|
IEnumConnectionPoints **ppEnum);
|
|
|
|
static HRESULT WINAPI OLEFontImpl_FindConnectionPoint(
|
|
|
|
IConnectionPointContainer* iface,
|
|
|
|
REFIID riid,
|
|
|
|
IConnectionPoint **ppCp);
|
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
/*
|
|
|
|
* Virtual function tables for the OLEFontImpl class.
|
|
|
|
*/
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IFontVtbl OLEFontImpl_VTable =
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
|
|
|
OLEFontImpl_QueryInterface,
|
|
|
|
OLEFontImpl_AddRef,
|
|
|
|
OLEFontImpl_Release,
|
|
|
|
OLEFontImpl_get_Name,
|
|
|
|
OLEFontImpl_put_Name,
|
|
|
|
OLEFontImpl_get_Size,
|
|
|
|
OLEFontImpl_put_Size,
|
|
|
|
OLEFontImpl_get_Bold,
|
|
|
|
OLEFontImpl_put_Bold,
|
|
|
|
OLEFontImpl_get_Italic,
|
|
|
|
OLEFontImpl_put_Italic,
|
|
|
|
OLEFontImpl_get_Underline,
|
|
|
|
OLEFontImpl_put_Underline,
|
|
|
|
OLEFontImpl_get_Strikethrough,
|
|
|
|
OLEFontImpl_put_Strikethrough,
|
|
|
|
OLEFontImpl_get_Weight,
|
|
|
|
OLEFontImpl_put_Weight,
|
|
|
|
OLEFontImpl_get_Charset,
|
|
|
|
OLEFontImpl_put_Charset,
|
|
|
|
OLEFontImpl_get_hFont,
|
2002-06-01 01:06:46 +02:00
|
|
|
OLEFontImpl_Clone,
|
1999-02-20 17:48:53 +01:00
|
|
|
OLEFontImpl_IsEqual,
|
|
|
|
OLEFontImpl_SetRatio,
|
|
|
|
OLEFontImpl_QueryTextMetrics,
|
|
|
|
OLEFontImpl_AddRefHfont,
|
|
|
|
OLEFontImpl_ReleaseHfont,
|
|
|
|
OLEFontImpl_SetHdc
|
|
|
|
};
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IDispatchVtbl OLEFontImpl_IDispatch_VTable =
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
|
|
|
OLEFontImpl_IDispatch_QueryInterface,
|
|
|
|
OLEFontImpl_IDispatch_AddRef,
|
|
|
|
OLEFontImpl_IDispatch_Release,
|
|
|
|
OLEFontImpl_GetTypeInfoCount,
|
|
|
|
OLEFontImpl_GetTypeInfo,
|
|
|
|
OLEFontImpl_GetIDsOfNames,
|
|
|
|
OLEFontImpl_Invoke
|
|
|
|
};
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IPersistStreamVtbl OLEFontImpl_IPersistStream_VTable =
|
1999-03-13 18:59:07 +01:00
|
|
|
{
|
|
|
|
OLEFontImpl_IPersistStream_QueryInterface,
|
|
|
|
OLEFontImpl_IPersistStream_AddRef,
|
|
|
|
OLEFontImpl_IPersistStream_Release,
|
|
|
|
OLEFontImpl_GetClassID,
|
|
|
|
OLEFontImpl_IsDirty,
|
|
|
|
OLEFontImpl_Load,
|
|
|
|
OLEFontImpl_Save,
|
|
|
|
OLEFontImpl_GetSizeMax
|
|
|
|
};
|
1999-02-20 17:48:53 +01:00
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IConnectionPointContainerVtbl
|
2000-07-28 22:17:21 +02:00
|
|
|
OLEFontImpl_IConnectionPointContainer_VTable =
|
|
|
|
{
|
|
|
|
OLEFontImpl_IConnectionPointContainer_QueryInterface,
|
|
|
|
OLEFontImpl_IConnectionPointContainer_AddRef,
|
|
|
|
OLEFontImpl_IConnectionPointContainer_Release,
|
|
|
|
OLEFontImpl_EnumConnectionPoints,
|
|
|
|
OLEFontImpl_FindConnectionPoint
|
|
|
|
};
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IPersistPropertyBagVtbl OLEFontImpl_IPersistPropertyBag_VTable;
|
|
|
|
static const IPersistStreamInitVtbl OLEFontImpl_IPersistStreamInit_VTable;
|
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* OleCreateFontIndirect [OLEAUT32.420]
|
|
|
|
*/
|
2000-02-07 17:27:33 +01:00
|
|
|
HRESULT WINAPI OleCreateFontIndirect(
|
1999-02-20 17:48:53 +01:00
|
|
|
LPFONTDESC lpFontDesc,
|
|
|
|
REFIID riid,
|
2000-02-07 17:27:33 +01:00
|
|
|
LPVOID* ppvObj)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
|
|
|
OLEFontImpl* newFont = 0;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p, %s, %p)\n", lpFontDesc, debugstr_guid(riid), ppvObj);
|
1999-02-20 17:48:53 +01:00
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if (ppvObj==0)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*ppvObj = 0;
|
|
|
|
|
2003-06-24 21:21:20 +02:00
|
|
|
if (!lpFontDesc) {
|
|
|
|
FONTDESC fd;
|
|
|
|
|
2004-04-20 04:14:00 +02:00
|
|
|
static const WCHAR fname[] = { 'S','y','s','t','e','m',0 };
|
2003-06-24 21:21:20 +02:00
|
|
|
|
|
|
|
fd.cbSizeofstruct = sizeof(fd);
|
2004-04-20 04:14:00 +02:00
|
|
|
fd.lpstrName = (WCHAR*)fname;
|
2003-06-24 21:21:20 +02:00
|
|
|
fd.cySize.s.Lo = 80000;
|
|
|
|
fd.cySize.s.Hi = 0;
|
|
|
|
fd.sWeight = 0;
|
|
|
|
fd.sCharset = 0;
|
|
|
|
fd.fItalic = 0;
|
|
|
|
fd.fUnderline = 0;
|
|
|
|
fd.fStrikethrough = 0;
|
|
|
|
lpFontDesc = &fd;
|
|
|
|
}
|
2002-01-15 21:23:57 +01:00
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
/*
|
|
|
|
* Try to construct a new instance of the class.
|
|
|
|
*/
|
|
|
|
newFont = OLEFontImpl_Construct(lpFontDesc);
|
|
|
|
|
|
|
|
if (newFont == 0)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure it supports the interface required by the caller.
|
|
|
|
*/
|
|
|
|
hr = IFont_QueryInterface((IFont*)newFont, riid, ppvObj);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release the reference obtained in the constructor. If
|
|
|
|
* the QueryInterface was unsuccessful, it will free the class.
|
|
|
|
*/
|
|
|
|
IFont_Release((IFont*)newFont);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* Implementation of the OLEFontImpl class.
|
|
|
|
*/
|
|
|
|
|
2000-07-28 22:17:21 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* OLEFont_SendNotify (internal)
|
|
|
|
*
|
|
|
|
* Sends notification messages of changed properties to any interested
|
|
|
|
* connections.
|
|
|
|
*/
|
|
|
|
static void OLEFont_SendNotify(OLEFontImpl* this, DISPID dispID)
|
|
|
|
{
|
2006-02-10 14:50:26 +01:00
|
|
|
static const WCHAR wszName[] = {'N','a','m','e',0};
|
|
|
|
static const WCHAR wszSize[] = {'S','i','z','e',0};
|
|
|
|
static const WCHAR wszBold[] = {'B','o','l','d',0};
|
|
|
|
static const WCHAR wszItalic[] = {'I','t','a','l','i','c',0};
|
|
|
|
static const WCHAR wszUnder[] = {'U','n','d','e','r','l','i','n','e',0};
|
|
|
|
static const WCHAR wszStrike[] = {'S','t','r','i','k','e','t','h','r','o','u','g','h',0};
|
|
|
|
static const WCHAR wszWeight[] = {'W','e','i','g','h','t',0};
|
|
|
|
static const WCHAR wszCharset[] = {'C','h','a','r','s','s','e','t',0};
|
|
|
|
static const LPCWSTR dispid_mapping[] =
|
|
|
|
{
|
|
|
|
wszName,
|
|
|
|
NULL,
|
|
|
|
wszSize,
|
|
|
|
wszBold,
|
|
|
|
wszItalic,
|
|
|
|
wszUnder,
|
|
|
|
wszStrike,
|
|
|
|
wszWeight,
|
|
|
|
wszCharset
|
|
|
|
};
|
|
|
|
|
2000-07-28 22:17:21 +02:00
|
|
|
IEnumConnections *pEnum;
|
|
|
|
CONNECTDATA CD;
|
2003-01-23 02:23:59 +01:00
|
|
|
HRESULT hres;
|
2000-07-28 22:17:21 +02:00
|
|
|
|
2006-02-10 14:50:26 +01:00
|
|
|
hres = IConnectionPoint_EnumConnections(this->pPropertyNotifyCP, &pEnum);
|
|
|
|
if (SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) {
|
|
|
|
IPropertyNotifySink *sink;
|
|
|
|
|
|
|
|
IUnknown_QueryInterface(CD.pUnk, &IID_IPropertyNotifySink, (LPVOID)&sink);
|
|
|
|
IPropertyNotifySink_OnChanged(sink, dispID);
|
|
|
|
IPropertyNotifySink_Release(sink);
|
|
|
|
IUnknown_Release(CD.pUnk);
|
|
|
|
}
|
|
|
|
IEnumConnections_Release(pEnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IConnectionPoint_EnumConnections(this->pFontEventsCP, &pEnum);
|
|
|
|
if (SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
DISPPARAMS dispparams;
|
|
|
|
VARIANTARG vararg;
|
|
|
|
|
|
|
|
VariantInit(&vararg);
|
|
|
|
V_VT(&vararg) = VT_BSTR;
|
|
|
|
V_BSTR(&vararg) = SysAllocString(dispid_mapping[dispID]);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-02-10 14:50:26 +01:00
|
|
|
dispparams.cArgs = 1;
|
|
|
|
dispparams.cNamedArgs = 0;
|
|
|
|
dispparams.rgdispidNamedArgs = NULL;
|
|
|
|
dispparams.rgvarg = &vararg;
|
2000-07-28 22:17:21 +02:00
|
|
|
|
2006-02-10 14:50:26 +01:00
|
|
|
while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) {
|
|
|
|
IFontEventsDisp *disp;
|
|
|
|
|
|
|
|
IUnknown_QueryInterface(CD.pUnk, &IID_IFontEventsDisp, (LPVOID)&disp);
|
|
|
|
IDispatch_Invoke(disp, DISPID_FONT_CHANGED, &IID_NULL,
|
|
|
|
LOCALE_NEUTRAL, INVOKE_FUNC, &dispparams, NULL,
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
IDispatch_Release(disp);
|
|
|
|
IUnknown_Release(CD.pUnk);
|
|
|
|
}
|
|
|
|
VariantClear(&vararg);
|
|
|
|
IEnumConnections_Release(pEnum);
|
2000-07-28 22:17:21 +02:00
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_Construct
|
|
|
|
*
|
|
|
|
* This method will construct a new instance of the OLEFontImpl
|
|
|
|
* class.
|
|
|
|
*
|
|
|
|
* The caller of this method must release the object when it's
|
|
|
|
* done with it.
|
|
|
|
*/
|
|
|
|
static OLEFontImpl* OLEFontImpl_Construct(LPFONTDESC fontDesc)
|
|
|
|
{
|
|
|
|
OLEFontImpl* newObject = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate space for the object.
|
|
|
|
*/
|
|
|
|
newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl));
|
|
|
|
|
|
|
|
if (newObject==0)
|
|
|
|
return newObject;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
/*
|
|
|
|
* Initialize the virtual function table.
|
|
|
|
*/
|
2005-07-27 17:14:18 +02:00
|
|
|
newObject->lpVtbl = &OLEFontImpl_VTable;
|
|
|
|
newObject->lpvtblIDispatch = &OLEFontImpl_IDispatch_VTable;
|
|
|
|
newObject->lpvtblIPersistStream = &OLEFontImpl_IPersistStream_VTable;
|
|
|
|
newObject->lpvtblIConnectionPointContainer = &OLEFontImpl_IConnectionPointContainer_VTable;
|
|
|
|
newObject->lpvtblIPersistPropertyBag = &OLEFontImpl_IPersistPropertyBag_VTable;
|
|
|
|
newObject->lpvtblIPersistStreamInit = &OLEFontImpl_IPersistStreamInit_VTable;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
/*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Start with one reference count. The caller of this function
|
1999-02-20 17:48:53 +01:00
|
|
|
* must release the interface pointer when it is done.
|
|
|
|
*/
|
|
|
|
newObject->ref = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy the description of the font in the object.
|
|
|
|
*/
|
|
|
|
assert(fontDesc->cbSizeofstruct >= sizeof(FONTDESC));
|
|
|
|
|
|
|
|
newObject->description.cbSizeofstruct = sizeof(FONTDESC);
|
|
|
|
newObject->description.lpstrName = HeapAlloc(GetProcessHeap(),
|
2002-06-01 01:06:46 +02:00
|
|
|
0,
|
1999-02-26 12:11:13 +01:00
|
|
|
(lstrlenW(fontDesc->lpstrName)+1) * sizeof(WCHAR));
|
2000-08-14 16:41:19 +02:00
|
|
|
strcpyW(newObject->description.lpstrName, fontDesc->lpstrName);
|
1999-02-20 17:48:53 +01:00
|
|
|
newObject->description.cySize = fontDesc->cySize;
|
|
|
|
newObject->description.sWeight = fontDesc->sWeight;
|
|
|
|
newObject->description.sCharset = fontDesc->sCharset;
|
|
|
|
newObject->description.fItalic = fontDesc->fItalic;
|
|
|
|
newObject->description.fUnderline = fontDesc->fUnderline;
|
1999-03-14 14:47:00 +01:00
|
|
|
newObject->description.fStrikethrough = fontDesc->fStrikethrough;
|
1999-02-20 17:48:53 +01:00
|
|
|
|
1999-03-13 18:59:07 +01:00
|
|
|
/*
|
|
|
|
* Initializing all the other members.
|
|
|
|
*/
|
1999-03-18 18:39:57 +01:00
|
|
|
newObject->gdiFont = 0;
|
1999-03-13 18:59:07 +01:00
|
|
|
newObject->fontLock = 0;
|
2003-01-23 02:23:59 +01:00
|
|
|
newObject->cyLogical = 72L;
|
|
|
|
newObject->cyHimetric = 2540L;
|
2006-02-14 11:33:18 +01:00
|
|
|
newObject->pPropertyNotifyCP = NULL;
|
|
|
|
newObject->pFontEventsCP = NULL;
|
|
|
|
|
2006-02-10 14:50:26 +01:00
|
|
|
CreateConnectionPoint((IUnknown*)newObject, &IID_IPropertyNotifySink, &newObject->pPropertyNotifyCP);
|
|
|
|
CreateConnectionPoint((IUnknown*)newObject, &IID_IFontEventsDisp, &newObject->pFontEventsCP);
|
2006-02-14 11:33:18 +01:00
|
|
|
|
|
|
|
if (!newObject->pPropertyNotifyCP || !newObject->pFontEventsCP)
|
|
|
|
{
|
|
|
|
OLEFontImpl_Destroy(newObject);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("returning %p\n", newObject);
|
1999-02-20 17:48:53 +01:00
|
|
|
return newObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
2000-07-28 22:17:21 +02:00
|
|
|
* OLEFontImpl_Destroy
|
1999-02-20 17:48:53 +01:00
|
|
|
*
|
|
|
|
* This method is called by the Release method when the reference
|
2000-07-16 17:44:22 +02:00
|
|
|
* count goes down to 0. It will free all resources used by
|
1999-02-20 17:48:53 +01:00
|
|
|
* this object.
|
|
|
|
*/
|
|
|
|
static void OLEFontImpl_Destroy(OLEFontImpl* fontDesc)
|
|
|
|
{
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)\n", fontDesc);
|
|
|
|
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, fontDesc->description.lpstrName);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
1999-03-18 18:39:57 +01:00
|
|
|
if (fontDesc->gdiFont!=0)
|
1999-03-13 18:59:07 +01:00
|
|
|
DeleteObject(fontDesc->gdiFont);
|
|
|
|
|
2006-02-14 11:33:18 +01:00
|
|
|
if (fontDesc->pPropertyNotifyCP)
|
|
|
|
IConnectionPoint_Release(fontDesc->pPropertyNotifyCP);
|
|
|
|
if (fontDesc->pFontEventsCP)
|
|
|
|
IConnectionPoint_Release(fontDesc->pFontEventsCP);
|
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, fontDesc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_QueryInterface (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI OLEFontImpl_QueryInterface(
|
|
|
|
IFont* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%s, %p)\n", this, debugstr_guid(riid), ppvObject);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform a sanity check on the parameters.
|
|
|
|
*/
|
|
|
|
if ( (this==0) || (ppvObject==0) )
|
|
|
|
return E_INVALIDARG;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
/*
|
|
|
|
* Initialize the return parameter.
|
|
|
|
*/
|
|
|
|
*ppvObject = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
/*
|
|
|
|
* Compare the riid with the interface IDs implemented by this object.
|
|
|
|
*/
|
2003-01-23 02:23:59 +01:00
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid))
|
1999-02-20 17:48:53 +01:00
|
|
|
*ppvObject = (IFont*)this;
|
2003-01-23 02:23:59 +01:00
|
|
|
if (IsEqualGUID(&IID_IFont, riid))
|
1999-02-20 17:48:53 +01:00
|
|
|
*ppvObject = (IFont*)this;
|
2003-01-23 02:23:59 +01:00
|
|
|
if (IsEqualGUID(&IID_IDispatch, riid))
|
2005-07-27 17:14:18 +02:00
|
|
|
*ppvObject = (IDispatch*)&(this->lpvtblIDispatch);
|
2003-01-23 02:23:59 +01:00
|
|
|
if (IsEqualGUID(&IID_IFontDisp, riid))
|
2005-07-27 17:14:18 +02:00
|
|
|
*ppvObject = (IDispatch*)&(this->lpvtblIDispatch);
|
2003-01-23 02:23:59 +01:00
|
|
|
if (IsEqualGUID(&IID_IPersistStream, riid))
|
2005-07-27 17:14:18 +02:00
|
|
|
*ppvObject = (IPersistStream*)&(this->lpvtblIPersistStream);
|
2003-01-23 02:23:59 +01:00
|
|
|
if (IsEqualGUID(&IID_IConnectionPointContainer, riid))
|
2005-07-27 17:14:18 +02:00
|
|
|
*ppvObject = (IConnectionPointContainer*)&(this->lpvtblIConnectionPointContainer);
|
2003-01-23 02:23:59 +01:00
|
|
|
if (IsEqualGUID(&IID_IPersistPropertyBag, riid))
|
2005-07-27 17:14:18 +02:00
|
|
|
*ppvObject = (IPersistPropertyBag*)&(this->lpvtblIPersistPropertyBag);
|
2003-01-23 02:23:59 +01:00
|
|
|
if (IsEqualGUID(&IID_IPersistStreamInit, riid))
|
2005-07-27 17:14:18 +02:00
|
|
|
*ppvObject = (IPersistStreamInit*)&(this->lpvtblIPersistStreamInit);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
/*
|
|
|
|
* Check that we obtained an interface.
|
|
|
|
*/
|
|
|
|
if ((*ppvObject)==0)
|
1999-03-13 18:59:07 +01:00
|
|
|
{
|
2003-01-23 02:23:59 +01:00
|
|
|
FIXME("() : asking for unsupported interface %s\n",debugstr_guid(riid));
|
1999-02-20 17:48:53 +01:00
|
|
|
return E_NOINTERFACE;
|
1999-03-13 18:59:07 +01:00
|
|
|
}
|
1999-02-20 17:48:53 +01:00
|
|
|
OLEFontImpl_AddRef((IFont*)this);
|
2002-06-01 01:06:46 +02:00
|
|
|
return S_OK;
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_AddRef (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
ULONG WINAPI OLEFontImpl_AddRef(
|
1999-02-20 17:48:53 +01:00
|
|
|
IFont* iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(ref=%ld)\n", this, this->ref);
|
2004-09-21 02:25:03 +02:00
|
|
|
return InterlockedIncrement(&this->ref);
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_Release (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
ULONG WINAPI OLEFontImpl_Release(
|
1999-02-20 17:48:53 +01:00
|
|
|
IFont* iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2004-09-21 02:25:03 +02:00
|
|
|
ULONG ret;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(ref=%ld)\n", this, this->ref);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Decrease the reference count on this object.
|
|
|
|
*/
|
2004-09-21 02:25:03 +02:00
|
|
|
ret = InterlockedDecrement(&this->ref);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the reference count goes down to 0, perform suicide.
|
|
|
|
*/
|
2004-09-21 02:25:03 +02:00
|
|
|
if (ret==0) OLEFontImpl_Destroy(this);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-09-21 02:25:03 +02:00
|
|
|
return ret;
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-20 17:48:53 +01:00
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_get_Name (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Name(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
BSTR* pname)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%p)\n", this, pname);
|
1999-02-20 17:48:53 +01:00
|
|
|
/*
|
|
|
|
* Sanity check.
|
|
|
|
*/
|
|
|
|
if (pname==0)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if (this->description.lpstrName!=0)
|
1999-02-26 12:11:13 +01:00
|
|
|
*pname = SysAllocString(this->description.lpstrName);
|
1999-02-20 17:48:53 +01:00
|
|
|
else
|
|
|
|
*pname = 0;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_put_Name (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Name(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
BSTR name)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%p)\n", this, name);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
if (this->description.lpstrName==0)
|
|
|
|
{
|
|
|
|
this->description.lpstrName = HeapAlloc(GetProcessHeap(),
|
2002-06-01 01:06:46 +02:00
|
|
|
0,
|
1999-02-26 12:11:13 +01:00
|
|
|
(lstrlenW(name)+1) * sizeof(WCHAR));
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->description.lpstrName = HeapReAlloc(GetProcessHeap(),
|
2002-06-01 01:06:46 +02:00
|
|
|
0,
|
1999-02-20 17:48:53 +01:00
|
|
|
this->description.lpstrName,
|
1999-02-26 12:11:13 +01:00
|
|
|
(lstrlenW(name)+1) * sizeof(WCHAR));
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this->description.lpstrName==0)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2000-08-14 16:41:19 +02:00
|
|
|
strcpyW(this->description.lpstrName, name);
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("new name %s\n", debugstr_w(this->description.lpstrName));
|
|
|
|
OLEFont_SendNotify(this, DISPID_FONT_NAME);
|
1999-02-20 17:48:53 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_get_Size (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Size(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-20 17:48:53 +01:00
|
|
|
CY* psize)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%p)\n", this, psize);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if (psize==0)
|
|
|
|
return E_POINTER;
|
|
|
|
|
1999-09-19 16:20:33 +02:00
|
|
|
psize->s.Hi = 0;
|
|
|
|
psize->s.Lo = this->description.cySize.s.Lo;
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_put_Size (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Size(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-20 17:48:53 +01:00
|
|
|
CY size)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%ld)\n", this, size.s.Lo);
|
1999-09-19 16:20:33 +02:00
|
|
|
this->description.cySize.s.Hi = 0;
|
2000-07-28 22:17:21 +02:00
|
|
|
this->description.cySize.s.Lo = size.s.Lo;
|
|
|
|
OLEFont_SendNotify(this, DISPID_FONT_SIZE);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_get_Bold (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Bold(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL* pbold)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%p)\n", this, pbold);
|
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if (pbold==0)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*pbold = this->description.sWeight > 550;
|
|
|
|
|
|
|
|
return S_OK;
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_put_Bold (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Bold(
|
1999-02-20 17:48:53 +01:00
|
|
|
IFont* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL bold)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%d)\n", this, bold);
|
|
|
|
this->description.sWeight = bold ? FW_BOLD : FW_NORMAL;
|
|
|
|
OLEFont_SendNotify(this, DISPID_FONT_BOLD);
|
|
|
|
|
|
|
|
return S_OK;
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_get_Italic (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Italic(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL* pitalic)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%p)\n", this, pitalic);
|
1999-02-20 17:48:53 +01:00
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if (pitalic==0)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*pitalic = this->description.fItalic;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_put_Italic (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Italic(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL italic)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%d)\n", this, italic);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
this->description.fItalic = italic;
|
|
|
|
|
2000-07-28 22:17:21 +02:00
|
|
|
OLEFont_SendNotify(this, DISPID_FONT_ITALIC);
|
1999-02-20 17:48:53 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_get_Underline (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Underline(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL* punderline)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%p)\n", this, punderline);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if (punderline==0)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*punderline = this->description.fUnderline;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_put_Underline (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Underline(
|
1999-02-20 17:48:53 +01:00
|
|
|
IFont* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL underline)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%d)\n", this, underline);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
this->description.fUnderline = underline;
|
|
|
|
|
2000-07-28 22:17:21 +02:00
|
|
|
OLEFont_SendNotify(this, DISPID_FONT_UNDER);
|
1999-02-20 17:48:53 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_get_Strikethrough (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Strikethrough(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL* pstrikethrough)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%p)\n", this, pstrikethrough);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if (pstrikethrough==0)
|
|
|
|
return E_POINTER;
|
|
|
|
|
1999-03-14 14:47:00 +01:00
|
|
|
*pstrikethrough = this->description.fStrikethrough;
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_put_Strikethrough (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Strikethrough(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL strikethrough)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%d)\n", this, strikethrough);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
1999-03-14 14:47:00 +01:00
|
|
|
this->description.fStrikethrough = strikethrough;
|
2000-07-28 22:17:21 +02:00
|
|
|
OLEFont_SendNotify(this, DISPID_FONT_STRIKE);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_get_Weight (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Weight(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-20 17:48:53 +01:00
|
|
|
short* pweight)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%p)\n", this, pweight);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if (pweight==0)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*pweight = this->description.sWeight;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_put_Weight (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Weight(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-20 17:48:53 +01:00
|
|
|
short weight)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%d)\n", this, weight);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
this->description.sWeight = weight;
|
|
|
|
|
2000-07-28 22:17:21 +02:00
|
|
|
OLEFont_SendNotify(this, DISPID_FONT_WEIGHT);
|
1999-02-20 17:48:53 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_get_Charset (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_get_Charset(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-20 17:48:53 +01:00
|
|
|
short* pcharset)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%p)\n", this, pcharset);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if (pcharset==0)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*pcharset = this->description.sCharset;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_put_Charset (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_put_Charset(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-20 17:48:53 +01:00
|
|
|
short charset)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%d)\n", this, charset);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
this->description.sCharset = charset;
|
2000-07-28 22:17:21 +02:00
|
|
|
OLEFont_SendNotify(this, DISPID_FONT_CHARSET);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_get_hFont (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_get_hFont(
|
1999-02-20 17:48:53 +01:00
|
|
|
IFont* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
HFONT* phfont)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%p)\n", this, phfont);
|
1999-03-13 18:59:07 +01:00
|
|
|
if (phfont==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Realize the font if necessary
|
1999-02-20 17:48:53 +01:00
|
|
|
*/
|
1999-03-13 18:59:07 +01:00
|
|
|
if (this->gdiFont==0)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
1999-03-13 18:59:07 +01:00
|
|
|
LOGFONTW logFont;
|
|
|
|
INT fontHeight;
|
|
|
|
CY cySize;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-13 18:59:07 +01:00
|
|
|
/*
|
|
|
|
* The height of the font returned by the get_Size property is the
|
|
|
|
* height of the font in points multiplied by 10000... Using some
|
|
|
|
* simple conversions and the ratio given by the application, it can
|
|
|
|
* be converted to a height in pixels.
|
|
|
|
*/
|
|
|
|
IFont_get_Size(iface, &cySize);
|
|
|
|
|
2005-08-22 11:22:43 +02:00
|
|
|
/* Standard ratio is 72 / 2540, or 18 / 635 in lowest terms. */
|
|
|
|
/* Ratio is applied here relative to the standard. */
|
|
|
|
fontHeight = MulDiv( cySize.s.Lo, this->cyLogical*635, this->cyHimetric*18 );
|
1999-03-13 18:59:07 +01:00
|
|
|
|
|
|
|
memset(&logFont, 0, sizeof(LOGFONTW));
|
|
|
|
|
2003-01-23 02:23:59 +01:00
|
|
|
logFont.lfHeight = ((fontHeight%10000L)>5000L) ? (-fontHeight/10000L)-1 :
|
|
|
|
(-fontHeight/10000L);
|
1999-03-13 18:59:07 +01:00
|
|
|
logFont.lfItalic = this->description.fItalic;
|
|
|
|
logFont.lfUnderline = this->description.fUnderline;
|
1999-03-14 14:47:00 +01:00
|
|
|
logFont.lfStrikeOut = this->description.fStrikethrough;
|
1999-03-13 18:59:07 +01:00
|
|
|
logFont.lfWeight = this->description.sWeight;
|
|
|
|
logFont.lfCharSet = this->description.sCharset;
|
|
|
|
logFont.lfOutPrecision = OUT_CHARACTER_PRECIS;
|
|
|
|
logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
|
|
|
logFont.lfQuality = DEFAULT_QUALITY;
|
|
|
|
logFont.lfPitchAndFamily = DEFAULT_PITCH;
|
2000-08-14 16:41:19 +02:00
|
|
|
strcpyW(logFont.lfFaceName,this->description.lpstrName);
|
1999-03-13 18:59:07 +01:00
|
|
|
|
|
|
|
this->gdiFont = CreateFontIndirectW(&logFont);
|
|
|
|
}
|
|
|
|
|
|
|
|
*phfont = this->gdiFont;
|
2002-10-25 05:12:50 +02:00
|
|
|
TRACE("Returning %p\n", *phfont);
|
1999-03-13 18:59:07 +01:00
|
|
|
return S_OK;
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_Clone (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_Clone(
|
1999-02-20 17:48:53 +01:00
|
|
|
IFont* iface,
|
|
|
|
IFont** ppfont)
|
|
|
|
{
|
1999-03-13 18:59:07 +01:00
|
|
|
OLEFontImpl* newObject = 0;
|
2001-08-20 19:59:10 +02:00
|
|
|
LOGFONTW logFont;
|
|
|
|
INT fontHeight;
|
|
|
|
CY cySize;
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%p)\n", this, ppfont);
|
1999-03-13 18:59:07 +01:00
|
|
|
|
|
|
|
if (ppfont == NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*ppfont = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate space for the object.
|
|
|
|
*/
|
|
|
|
newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl));
|
|
|
|
|
|
|
|
if (newObject==NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
*newObject = *this;
|
|
|
|
|
2001-08-20 19:59:10 +02:00
|
|
|
/* We need to alloc new memory for the string, otherwise
|
|
|
|
* we free memory twice.
|
1999-03-13 18:59:07 +01:00
|
|
|
*/
|
2001-08-20 19:59:10 +02:00
|
|
|
newObject->description.lpstrName = HeapAlloc(
|
|
|
|
GetProcessHeap(),0,
|
|
|
|
(1+strlenW(this->description.lpstrName))*2
|
|
|
|
);
|
2002-06-25 04:54:06 +02:00
|
|
|
strcpyW(newObject->description.lpstrName, this->description.lpstrName);
|
2001-08-20 19:59:10 +02:00
|
|
|
/* We need to clone the HFONT too. This is just cut & paste from above */
|
|
|
|
IFont_get_Size(iface, &cySize);
|
|
|
|
|
2005-08-22 11:22:43 +02:00
|
|
|
fontHeight = MulDiv(cySize.s.Lo, this->cyLogical*635,this->cyHimetric*18);
|
2001-08-20 19:59:10 +02:00
|
|
|
|
|
|
|
memset(&logFont, 0, sizeof(LOGFONTW));
|
|
|
|
|
|
|
|
logFont.lfHeight = ((fontHeight%10000L)>5000L) ? (-fontHeight/10000L)-1 :
|
|
|
|
(-fontHeight/10000L);
|
|
|
|
logFont.lfItalic = this->description.fItalic;
|
|
|
|
logFont.lfUnderline = this->description.fUnderline;
|
|
|
|
logFont.lfStrikeOut = this->description.fStrikethrough;
|
|
|
|
logFont.lfWeight = this->description.sWeight;
|
|
|
|
logFont.lfCharSet = this->description.sCharset;
|
|
|
|
logFont.lfOutPrecision = OUT_CHARACTER_PRECIS;
|
|
|
|
logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
|
|
|
logFont.lfQuality = DEFAULT_QUALITY;
|
|
|
|
logFont.lfPitchAndFamily = DEFAULT_PITCH;
|
|
|
|
strcpyW(logFont.lfFaceName,this->description.lpstrName);
|
|
|
|
|
|
|
|
newObject->gdiFont = CreateFontIndirectW(&logFont);
|
|
|
|
|
|
|
|
|
|
|
|
/* The cloned object starts with a reference count of 1 */
|
1999-03-13 18:59:07 +01:00
|
|
|
newObject->ref = 1;
|
|
|
|
|
|
|
|
*ppfont = (IFont*)newObject;
|
|
|
|
|
|
|
|
return S_OK;
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_IsEqual (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_IsEqual(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-20 17:48:53 +01:00
|
|
|
IFont* pFontOther)
|
|
|
|
{
|
2003-01-23 02:23:59 +01:00
|
|
|
FIXME("(%p, %p), stub!\n",iface,pFontOther);
|
1999-02-20 17:48:53 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_SetRatio (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_SetRatio(
|
1999-02-20 17:48:53 +01:00
|
|
|
IFont* iface,
|
2004-10-19 00:39:21 +02:00
|
|
|
LONG cyLogical,
|
|
|
|
LONG cyHimetric)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%ld, %ld)\n", this, cyLogical, cyHimetric);
|
1999-03-13 18:59:07 +01:00
|
|
|
|
|
|
|
this->cyLogical = cyLogical;
|
|
|
|
this->cyHimetric = cyHimetric;
|
|
|
|
|
|
|
|
return S_OK;
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_QueryTextMetrics (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_QueryTextMetrics(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-20 17:48:53 +01:00
|
|
|
TEXTMETRICOLE* ptm)
|
|
|
|
{
|
2005-02-18 13:51:23 +01:00
|
|
|
HDC hdcRef;
|
|
|
|
HFONT hOldFont, hNewFont;
|
|
|
|
|
|
|
|
hdcRef = GetDC(0);
|
|
|
|
OLEFontImpl_get_hFont(iface, &hNewFont);
|
|
|
|
hOldFont = SelectObject(hdcRef, hNewFont);
|
|
|
|
GetTextMetricsW(hdcRef, ptm);
|
|
|
|
SelectObject(hdcRef, hOldFont);
|
|
|
|
ReleaseDC(0, hdcRef);
|
|
|
|
return S_OK;
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_AddRefHfont (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_AddRefHfont(
|
2002-06-01 01:06:46 +02:00
|
|
|
IFont* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
HFONT hfont)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2002-10-25 05:12:50 +02:00
|
|
|
TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock);
|
1999-03-13 18:59:07 +01:00
|
|
|
|
1999-03-18 18:39:57 +01:00
|
|
|
if ( (hfont == 0) ||
|
1999-03-13 18:59:07 +01:00
|
|
|
(hfont != this->gdiFont) )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
this->fontLock++;
|
|
|
|
|
|
|
|
return S_OK;
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_ReleaseHfont (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_ReleaseHfont(
|
1999-02-20 17:48:53 +01:00
|
|
|
IFont* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
HFONT hfont)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2002-10-25 05:12:50 +02:00
|
|
|
TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock);
|
1999-03-13 18:59:07 +01:00
|
|
|
|
1999-03-18 18:39:57 +01:00
|
|
|
if ( (hfont == 0) ||
|
1999-03-13 18:59:07 +01:00
|
|
|
(hfont != this->gdiFont) )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
this->fontLock--;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we just released our last font reference, destroy it.
|
|
|
|
*/
|
|
|
|
if (this->fontLock==0)
|
|
|
|
{
|
|
|
|
DeleteObject(this->gdiFont);
|
2002-06-01 01:06:46 +02:00
|
|
|
this->gdiFont = 0;
|
2000-07-28 22:17:21 +02:00
|
|
|
}
|
1999-03-13 18:59:07 +01:00
|
|
|
|
|
|
|
return S_OK;
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_SetHdc (IFont)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IFont methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_SetHdc(
|
1999-02-20 17:48:53 +01:00
|
|
|
IFont* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
HDC hdc)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
OLEFontImpl *this = (OLEFontImpl *)iface;
|
2002-10-25 05:12:50 +02:00
|
|
|
FIXME("(%p)->(%p): Stub\n", this, hdc);
|
1999-02-20 17:48:53 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_IDispatch_QueryInterface (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(
|
1999-02-20 17:48:53 +01:00
|
|
|
IDispatch* iface,
|
|
|
|
REFIID riid,
|
|
|
|
VOID** ppvoid)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IDispatch(iface);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
2005-07-27 17:14:18 +02:00
|
|
|
return IFont_QueryInterface((IFont *)this, riid, ppvoid);
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_IDispatch_Release (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static ULONG WINAPI OLEFontImpl_IDispatch_Release(
|
1999-02-20 17:48:53 +01:00
|
|
|
IDispatch* iface)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IDispatch(iface);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
2005-07-27 17:14:18 +02:00
|
|
|
return IFont_Release((IFont *)this);
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_IDispatch_AddRef (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static ULONG WINAPI OLEFontImpl_IDispatch_AddRef(
|
1999-02-20 17:48:53 +01:00
|
|
|
IDispatch* iface)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IDispatch(iface);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
2005-07-27 17:14:18 +02:00
|
|
|
return IFont_AddRef((IFont *)this);
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_GetTypeInfoCount (IDispatch)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IDispatch methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(
|
2002-06-01 01:06:46 +02:00
|
|
|
IDispatch* iface,
|
1999-02-20 17:48:53 +01:00
|
|
|
unsigned int* pctinfo)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IDispatch(iface);
|
2000-07-28 22:17:21 +02:00
|
|
|
FIXME("(%p)->(%p): Stub\n", this, pctinfo);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_GetTypeInfo (IDispatch)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IDispatch methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_GetTypeInfo(
|
2002-06-01 01:06:46 +02:00
|
|
|
IDispatch* iface,
|
1999-02-26 12:11:13 +01:00
|
|
|
UINT iTInfo,
|
2002-06-01 01:06:46 +02:00
|
|
|
LCID lcid,
|
1999-02-20 17:48:53 +01:00
|
|
|
ITypeInfo** ppTInfo)
|
|
|
|
{
|
2005-09-13 12:36:54 +02:00
|
|
|
static const WCHAR stdole2tlb[] = {'s','t','d','o','l','e','2','.','t','l','b',0};
|
2003-01-23 02:23:59 +01:00
|
|
|
ITypeLib *tl;
|
|
|
|
HRESULT hres;
|
1999-02-20 17:48:53 +01:00
|
|
|
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IDispatch(iface);
|
2004-11-06 04:49:18 +01:00
|
|
|
TRACE("(%p, iTInfo=%d, lcid=%04x, %p)\n", this, iTInfo, (int)lcid, ppTInfo);
|
2003-01-23 02:23:59 +01:00
|
|
|
if (iTInfo != 0)
|
|
|
|
return E_FAIL;
|
2005-09-13 12:36:54 +02:00
|
|
|
hres = LoadTypeLib(stdole2tlb, &tl);
|
2003-01-23 02:23:59 +01:00
|
|
|
if (FAILED(hres)) {
|
2005-09-13 12:36:54 +02:00
|
|
|
ERR("Could not load the stdole2.tlb?\n");
|
2003-01-23 02:23:59 +01:00
|
|
|
return hres;
|
|
|
|
}
|
2005-09-13 12:36:54 +02:00
|
|
|
hres = ITypeLib_GetTypeInfoOfGuid(tl, &IID_IFontDisp, ppTInfo);
|
2003-01-23 02:23:59 +01:00
|
|
|
if (FAILED(hres)) {
|
|
|
|
FIXME("Did not IDispatch typeinfo from typelib, hres %lx\n",hres);
|
|
|
|
}
|
|
|
|
return hres;
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_GetIDsOfNames (IDispatch)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IDispatch methods.
|
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(
|
1999-02-20 17:48:53 +01:00
|
|
|
IDispatch* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
1999-02-20 17:48:53 +01:00
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IDispatch(iface);
|
2003-01-23 02:23:59 +01:00
|
|
|
FIXME("(%p,%s,%p,%d,%04x,%p), stub!\n", this, debugstr_guid(riid), rgszNames,
|
|
|
|
cNames, (int)lcid, rgDispId
|
|
|
|
);
|
1999-02-20 17:48:53 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_Invoke (IDispatch)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IDispatch methods.
|
2003-01-23 02:23:59 +01:00
|
|
|
*
|
|
|
|
* Note: Do not call _put_Xxx methods, since setting things here
|
|
|
|
* should not call notify functions as I found out debugging the generic
|
|
|
|
* MS VB5 installer.
|
1999-02-20 17:48:53 +01:00
|
|
|
*/
|
1999-02-21 19:16:08 +01:00
|
|
|
static HRESULT WINAPI OLEFontImpl_Invoke(
|
1999-02-20 17:48:53 +01:00
|
|
|
IDispatch* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
1999-02-20 17:48:53 +01:00
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
2002-06-01 01:06:46 +02:00
|
|
|
VARIANT* pVarResult,
|
1999-02-20 17:48:53 +01:00
|
|
|
EXCEPINFO* pExepInfo,
|
1999-02-26 12:11:13 +01:00
|
|
|
UINT* puArgErr)
|
1999-02-20 17:48:53 +01:00
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IDispatch(iface);
|
2003-01-23 02:23:59 +01:00
|
|
|
OLEFontImpl *xthis = (OLEFontImpl*)this;
|
|
|
|
|
|
|
|
switch (dispIdMember) {
|
|
|
|
case DISPID_FONT_NAME:
|
|
|
|
switch (wFlags) {
|
|
|
|
case DISPATCH_PROPERTYGET:
|
|
|
|
case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
|
|
|
|
V_VT(pVarResult) = VT_BSTR;
|
2005-07-27 17:14:18 +02:00
|
|
|
return OLEFontImpl_get_Name((IFont *)this, &V_BSTR(pVarResult));
|
2003-01-23 02:23:59 +01:00
|
|
|
case DISPATCH_PROPERTYPUT: {
|
2004-11-06 04:49:18 +01:00
|
|
|
BSTR name;
|
|
|
|
BOOL freename;
|
|
|
|
|
|
|
|
if (V_VT(&pDispParams->rgvarg[0]) == VT_DISPATCH) {
|
|
|
|
IFont *font;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(V_DISPATCH(&pDispParams->rgvarg[0]), &IID_IFont, (void **) &font);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
FIXME("dispatch value for name property is not an OleFont, returning hr=0x%lx\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IFont_get_Name(font, &name); /* this allocates a new BSTR so free it later */
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
IUnknown_Release(font);
|
|
|
|
|
|
|
|
freename = TRUE;
|
|
|
|
} else if (V_VT(&pDispParams->rgvarg[0]) == VT_BSTR) {
|
|
|
|
name = V_BSTR(&pDispParams->rgvarg[0]);
|
|
|
|
freename = FALSE;
|
|
|
|
} else {
|
|
|
|
FIXME("app is trying to set name property with a non BSTR, non dispatch value. returning E_FAIL\n");
|
|
|
|
return E_FAIL;
|
2003-01-23 02:23:59 +01:00
|
|
|
}
|
2004-11-06 04:49:18 +01:00
|
|
|
|
|
|
|
TRACE("name is %s\n", debugstr_w(name));
|
|
|
|
|
2003-01-23 02:23:59 +01:00
|
|
|
if (!xthis->description.lpstrName)
|
|
|
|
xthis->description.lpstrName = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(name)+1) * sizeof(WCHAR));
|
|
|
|
else
|
|
|
|
xthis->description.lpstrName = HeapReAlloc(GetProcessHeap(), 0, xthis->description.lpstrName, (lstrlenW(name)+1) * sizeof(WCHAR));
|
|
|
|
|
|
|
|
if (xthis->description.lpstrName==0)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
strcpyW(xthis->description.lpstrName, name);
|
2004-11-06 04:49:18 +01:00
|
|
|
|
|
|
|
if (freename) SysFreeString(name);
|
|
|
|
|
2003-01-23 02:23:59 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DISPID_FONT_BOLD:
|
|
|
|
switch (wFlags) {
|
|
|
|
case DISPATCH_PROPERTYGET:
|
|
|
|
case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
|
|
|
|
V_VT(pVarResult) = VT_BOOL;
|
2005-07-27 17:14:18 +02:00
|
|
|
return OLEFontImpl_get_Bold((IFont *)this, (BOOL*)&V_BOOL(pVarResult));
|
2003-01-23 02:23:59 +01:00
|
|
|
case DISPATCH_PROPERTYPUT:
|
|
|
|
if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
|
|
|
|
FIXME("DISPID_FONT_BOLD/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
|
|
|
|
return E_FAIL;
|
|
|
|
} else {
|
|
|
|
xthis->description.sWeight = V_BOOL(&pDispParams->rgvarg[0]) ? FW_BOLD : FW_NORMAL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DISPID_FONT_ITALIC:
|
|
|
|
switch (wFlags) {
|
|
|
|
case DISPATCH_PROPERTYGET:
|
|
|
|
case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
|
|
|
|
V_VT(pVarResult) = VT_BOOL;
|
2005-07-27 17:14:18 +02:00
|
|
|
return OLEFontImpl_get_Italic((IFont *)this, (BOOL*)&V_BOOL(pVarResult));
|
2003-01-23 02:23:59 +01:00
|
|
|
case DISPATCH_PROPERTYPUT:
|
|
|
|
if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
|
|
|
|
FIXME("DISPID_FONT_ITALIC/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
|
|
|
|
return E_FAIL;
|
|
|
|
} else {
|
|
|
|
xthis->description.fItalic = V_BOOL(&pDispParams->rgvarg[0]);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DISPID_FONT_UNDER:
|
|
|
|
switch (wFlags) {
|
|
|
|
case DISPATCH_PROPERTYGET:
|
|
|
|
case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
|
|
|
|
V_VT(pVarResult) = VT_BOOL;
|
2005-07-27 17:14:18 +02:00
|
|
|
return OLEFontImpl_get_Underline((IFont *)this, (BOOL*)&V_BOOL(pVarResult));
|
2003-01-23 02:23:59 +01:00
|
|
|
case DISPATCH_PROPERTYPUT:
|
|
|
|
if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
|
|
|
|
FIXME("DISPID_FONT_UNDER/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
|
|
|
|
return E_FAIL;
|
|
|
|
} else {
|
|
|
|
xthis->description.fUnderline = V_BOOL(&pDispParams->rgvarg[0]);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DISPID_FONT_STRIKE:
|
|
|
|
switch (wFlags) {
|
|
|
|
case DISPATCH_PROPERTYGET:
|
|
|
|
case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
|
|
|
|
V_VT(pVarResult) = VT_BOOL;
|
2005-07-27 17:14:18 +02:00
|
|
|
return OLEFontImpl_get_Strikethrough((IFont *)this, (BOOL*)&V_BOOL(pVarResult));
|
2003-01-23 02:23:59 +01:00
|
|
|
case DISPATCH_PROPERTYPUT:
|
|
|
|
if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
|
|
|
|
FIXME("DISPID_FONT_STRIKE/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
|
|
|
|
return E_FAIL;
|
|
|
|
} else {
|
|
|
|
xthis->description.fStrikethrough = V_BOOL(&pDispParams->rgvarg[0]);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DISPID_FONT_SIZE:
|
|
|
|
switch (wFlags) {
|
|
|
|
case DISPATCH_PROPERTYPUT: {
|
|
|
|
assert (pDispParams->cArgs == 1);
|
|
|
|
xthis->description.cySize.s.Hi = 0;
|
|
|
|
if (V_VT(&pDispParams->rgvarg[0]) != VT_CY) {
|
|
|
|
if (V_VT(&pDispParams->rgvarg[0]) == VT_I2) {
|
|
|
|
xthis->description.cySize.s.Lo = V_I2(&pDispParams->rgvarg[0]) * 10000;
|
|
|
|
} else {
|
|
|
|
FIXME("property put for Size with vt %d unsupported!\n",V_VT(&pDispParams->rgvarg[0]));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
xthis->description.cySize.s.Lo = V_CY(&pDispParams->rgvarg[0]).s.Lo;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
case DISPATCH_PROPERTYGET:
|
|
|
|
case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
|
|
|
|
V_VT(pVarResult) = VT_CY;
|
2005-07-27 17:14:18 +02:00
|
|
|
return OLEFontImpl_get_Size((IFont *)this, &V_CY(pVarResult));
|
2003-01-23 02:23:59 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DISPID_FONT_CHARSET:
|
|
|
|
switch (wFlags) {
|
|
|
|
case DISPATCH_PROPERTYPUT:
|
|
|
|
assert (pDispParams->cArgs == 1);
|
|
|
|
if (V_VT(&pDispParams->rgvarg[0]) != VT_I2)
|
|
|
|
FIXME("varg of first disparg is not VT_I2, but %d\n",V_VT(&pDispParams->rgvarg[0]));
|
|
|
|
xthis->description.sCharset = V_I2(&pDispParams->rgvarg[0]);
|
|
|
|
return S_OK;
|
|
|
|
case DISPATCH_PROPERTYGET:
|
|
|
|
case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
|
|
|
|
V_VT(pVarResult) = VT_I2;
|
2005-07-27 17:14:18 +02:00
|
|
|
return OLEFontImpl_get_Charset((IFont *)this, &V_I2(pVarResult));
|
2003-01-23 02:23:59 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
FIXME("%p->(%ld,%s,%lx,%x,%p,%p,%p,%p), unhandled dispid/flag!\n",
|
|
|
|
this,dispIdMember,debugstr_guid(riid),lcid,
|
|
|
|
wFlags,pDispParams,pVarResult,pExepInfo,puArgErr
|
2001-07-14 02:47:52 +02:00
|
|
|
);
|
2001-07-23 01:03:55 +02:00
|
|
|
return S_OK;
|
1999-02-20 17:48:53 +01:00
|
|
|
}
|
|
|
|
|
1999-03-13 18:59:07 +01:00
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_IPersistStream_QueryInterface (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(
|
|
|
|
IPersistStream* iface,
|
|
|
|
REFIID riid,
|
|
|
|
VOID** ppvoid)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IPersistStream(iface);
|
1999-03-13 18:59:07 +01:00
|
|
|
|
2005-07-27 17:14:18 +02:00
|
|
|
return IFont_QueryInterface((IFont *)this, riid, ppvoid);
|
1999-03-13 18:59:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_IPersistStream_Release (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI OLEFontImpl_IPersistStream_Release(
|
|
|
|
IPersistStream* iface)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IPersistStream(iface);
|
1999-02-20 17:48:53 +01:00
|
|
|
|
2005-07-27 17:14:18 +02:00
|
|
|
return IFont_Release((IFont *)this);
|
1999-03-13 18:59:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_IPersistStream_AddRef (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI OLEFontImpl_IPersistStream_AddRef(
|
|
|
|
IPersistStream* iface)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IPersistStream(iface);
|
1999-03-13 18:59:07 +01:00
|
|
|
|
2005-07-27 17:14:18 +02:00
|
|
|
return IFont_AddRef((IFont *)this);
|
1999-03-13 18:59:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_GetClassID (IPersistStream)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IPersistStream methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI OLEFontImpl_GetClassID(
|
2002-06-01 01:06:46 +02:00
|
|
|
IPersistStream* iface,
|
1999-03-13 18:59:07 +01:00
|
|
|
CLSID* pClassID)
|
|
|
|
{
|
2003-01-23 02:23:59 +01:00
|
|
|
TRACE("(%p,%p)\n",iface,pClassID);
|
1999-03-13 18:59:07 +01:00
|
|
|
if (pClassID==0)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
memcpy(pClassID, &CLSID_StdFont, sizeof(CLSID_StdFont));
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_IsDirty (IPersistStream)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IPersistStream methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IsDirty(
|
|
|
|
IPersistStream* iface)
|
|
|
|
{
|
2003-01-23 02:23:59 +01:00
|
|
|
TRACE("(%p)\n",iface);
|
1999-03-13 18:59:07 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_Load (IPersistStream)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IPersistStream methods.
|
|
|
|
*
|
|
|
|
* This is the format of the standard font serialization as far as I
|
|
|
|
* know
|
|
|
|
*
|
|
|
|
* Offset Type Value Comment
|
|
|
|
* 0x0000 Byte Unknown Probably a version number, contains 0x01
|
|
|
|
* 0x0001 Short Charset Charset value from the FONTDESC structure
|
|
|
|
* 0x0003 Byte Attributes Flags defined as follows:
|
|
|
|
* 00000010 - Italic
|
|
|
|
* 00000100 - Underline
|
|
|
|
* 00001000 - Strikethrough
|
|
|
|
* 0x0004 Short Weight Weight value from FONTDESC structure
|
|
|
|
* 0x0006 DWORD size "Low" portion of the cySize member of the FONTDESC
|
|
|
|
* structure/
|
|
|
|
* 0x000A Byte name length Length of the font name string (no null character)
|
|
|
|
* 0x000B String name Name of the font (ASCII, no nul character)
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI OLEFontImpl_Load(
|
|
|
|
IPersistStream* iface,
|
|
|
|
IStream* pLoadStream)
|
|
|
|
{
|
|
|
|
char readBuffer[0x100];
|
|
|
|
ULONG cbRead;
|
|
|
|
BYTE bVersion;
|
|
|
|
BYTE bAttributes;
|
|
|
|
BYTE bStringSize;
|
2002-01-01 01:24:30 +01:00
|
|
|
INT len;
|
1999-03-13 18:59:07 +01:00
|
|
|
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IPersistStream(iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-13 18:59:07 +01:00
|
|
|
/*
|
|
|
|
* Read the version byte
|
|
|
|
*/
|
|
|
|
IStream_Read(pLoadStream, &bVersion, 1, &cbRead);
|
|
|
|
|
|
|
|
if ( (cbRead!=1) ||
|
|
|
|
(bVersion!=0x01) )
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Charset
|
|
|
|
*/
|
|
|
|
IStream_Read(pLoadStream, &this->description.sCharset, 2, &cbRead);
|
|
|
|
|
|
|
|
if (cbRead!=2)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attributes
|
|
|
|
*/
|
|
|
|
IStream_Read(pLoadStream, &bAttributes, 1, &cbRead);
|
|
|
|
|
|
|
|
if (cbRead!=1)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
this->description.fItalic = (bAttributes & FONTPERSIST_ITALIC) != 0;
|
1999-03-14 14:47:00 +01:00
|
|
|
this->description.fStrikethrough = (bAttributes & FONTPERSIST_STRIKETHROUGH) != 0;
|
1999-03-13 18:59:07 +01:00
|
|
|
this->description.fUnderline = (bAttributes & FONTPERSIST_UNDERLINE) != 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-13 18:59:07 +01:00
|
|
|
/*
|
|
|
|
* Weight
|
|
|
|
*/
|
|
|
|
IStream_Read(pLoadStream, &this->description.sWeight, 2, &cbRead);
|
|
|
|
|
|
|
|
if (cbRead!=2)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Size
|
|
|
|
*/
|
1999-09-19 16:20:33 +02:00
|
|
|
IStream_Read(pLoadStream, &this->description.cySize.s.Lo, 4, &cbRead);
|
1999-03-13 18:59:07 +01:00
|
|
|
|
|
|
|
if (cbRead!=4)
|
|
|
|
return E_FAIL;
|
|
|
|
|
1999-09-19 16:20:33 +02:00
|
|
|
this->description.cySize.s.Hi = 0;
|
1999-03-13 18:59:07 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* FontName
|
|
|
|
*/
|
|
|
|
IStream_Read(pLoadStream, &bStringSize, 1, &cbRead);
|
|
|
|
|
|
|
|
if (cbRead!=1)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
IStream_Read(pLoadStream, readBuffer, bStringSize, &cbRead);
|
|
|
|
|
|
|
|
if (cbRead!=bStringSize)
|
|
|
|
return E_FAIL;
|
|
|
|
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, this->description.lpstrName);
|
1999-03-13 18:59:07 +01:00
|
|
|
|
2002-01-01 01:24:30 +01:00
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, NULL, 0 );
|
|
|
|
this->description.lpstrName = HeapAlloc( GetProcessHeap(), 0, (len+1) * sizeof(WCHAR) );
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, this->description.lpstrName, len );
|
|
|
|
this->description.lpstrName[len] = 0;
|
1999-03-13 18:59:07 +01:00
|
|
|
|
2002-06-25 04:54:06 +02:00
|
|
|
/* Ensure use of this font causes a new one to be created @@@@ */
|
|
|
|
DeleteObject(this->gdiFont);
|
|
|
|
this->gdiFont = 0;
|
|
|
|
|
1999-03-13 18:59:07 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_Save (IPersistStream)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IPersistStream methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI OLEFontImpl_Save(
|
|
|
|
IPersistStream* iface,
|
|
|
|
IStream* pOutStream,
|
|
|
|
BOOL fClearDirty)
|
|
|
|
{
|
|
|
|
char* writeBuffer = NULL;
|
|
|
|
ULONG cbWritten;
|
|
|
|
BYTE bVersion = 0x01;
|
|
|
|
BYTE bAttributes;
|
|
|
|
BYTE bStringSize;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IPersistStream(iface);
|
1999-03-13 18:59:07 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the version byte
|
|
|
|
*/
|
|
|
|
IStream_Write(pOutStream, &bVersion, 1, &cbWritten);
|
|
|
|
|
|
|
|
if (cbWritten!=1)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Charset
|
|
|
|
*/
|
|
|
|
IStream_Write(pOutStream, &this->description.sCharset, 2, &cbWritten);
|
|
|
|
|
|
|
|
if (cbWritten!=2)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attributes
|
|
|
|
*/
|
|
|
|
bAttributes = 0;
|
|
|
|
|
|
|
|
if (this->description.fItalic)
|
|
|
|
bAttributes |= FONTPERSIST_ITALIC;
|
|
|
|
|
1999-03-14 14:47:00 +01:00
|
|
|
if (this->description.fStrikethrough)
|
1999-03-13 18:59:07 +01:00
|
|
|
bAttributes |= FONTPERSIST_STRIKETHROUGH;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-13 18:59:07 +01:00
|
|
|
if (this->description.fUnderline)
|
|
|
|
bAttributes |= FONTPERSIST_UNDERLINE;
|
|
|
|
|
|
|
|
IStream_Write(pOutStream, &bAttributes, 1, &cbWritten);
|
|
|
|
|
|
|
|
if (cbWritten!=1)
|
|
|
|
return E_FAIL;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-13 18:59:07 +01:00
|
|
|
/*
|
|
|
|
* Weight
|
|
|
|
*/
|
|
|
|
IStream_Write(pOutStream, &this->description.sWeight, 2, &cbWritten);
|
|
|
|
|
|
|
|
if (cbWritten!=2)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Size
|
|
|
|
*/
|
1999-09-19 16:20:33 +02:00
|
|
|
IStream_Write(pOutStream, &this->description.cySize.s.Lo, 4, &cbWritten);
|
1999-03-13 18:59:07 +01:00
|
|
|
|
|
|
|
if (cbWritten!=4)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FontName
|
|
|
|
*/
|
|
|
|
if (this->description.lpstrName!=0)
|
2002-01-01 01:24:30 +01:00
|
|
|
bStringSize = WideCharToMultiByte( CP_ACP, 0, this->description.lpstrName,
|
|
|
|
strlenW(this->description.lpstrName), NULL, 0, NULL, NULL );
|
1999-03-13 18:59:07 +01:00
|
|
|
else
|
|
|
|
bStringSize = 0;
|
|
|
|
|
|
|
|
IStream_Write(pOutStream, &bStringSize, 1, &cbWritten);
|
|
|
|
|
|
|
|
if (cbWritten!=1)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
if (bStringSize!=0)
|
|
|
|
{
|
2002-01-01 01:24:30 +01:00
|
|
|
if (!(writeBuffer = HeapAlloc( GetProcessHeap(), 0, bStringSize ))) return E_OUTOFMEMORY;
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, this->description.lpstrName,
|
|
|
|
strlenW(this->description.lpstrName),
|
|
|
|
writeBuffer, bStringSize, NULL, NULL );
|
1999-03-13 18:59:07 +01:00
|
|
|
|
|
|
|
IStream_Write(pOutStream, writeBuffer, bStringSize, &cbWritten);
|
|
|
|
HeapFree(GetProcessHeap(), 0, writeBuffer);
|
|
|
|
|
|
|
|
if (cbWritten!=bStringSize)
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_GetSizeMax (IPersistStream)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IPersistStream methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI OLEFontImpl_GetSizeMax(
|
|
|
|
IPersistStream* iface,
|
|
|
|
ULARGE_INTEGER* pcbSize)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IPersistStream(iface);
|
1999-03-13 18:59:07 +01:00
|
|
|
|
|
|
|
if (pcbSize==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
pcbSize->u.HighPart = 0;
|
|
|
|
pcbSize->u.LowPart = 0;
|
1999-03-13 18:59:07 +01:00
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
pcbSize->u.LowPart += sizeof(BYTE); /* Version */
|
|
|
|
pcbSize->u.LowPart += sizeof(WORD); /* Lang code */
|
|
|
|
pcbSize->u.LowPart += sizeof(BYTE); /* Flags */
|
|
|
|
pcbSize->u.LowPart += sizeof(WORD); /* Weight */
|
|
|
|
pcbSize->u.LowPart += sizeof(DWORD); /* Size */
|
|
|
|
pcbSize->u.LowPart += sizeof(BYTE); /* StrLength */
|
1999-03-13 18:59:07 +01:00
|
|
|
|
|
|
|
if (this->description.lpstrName!=0)
|
2004-01-23 02:51:33 +01:00
|
|
|
pcbSize->u.LowPart += lstrlenW(this->description.lpstrName);
|
1999-03-13 18:59:07 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2000-07-28 22:17:21 +02:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_IConnectionPointContainer_QueryInterface (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IConnectionPointContainer_QueryInterface(
|
|
|
|
IConnectionPointContainer* iface,
|
|
|
|
REFIID riid,
|
|
|
|
VOID** ppvoid)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IConnectionPointContainer(iface);
|
2000-07-28 22:17:21 +02:00
|
|
|
|
|
|
|
return IFont_QueryInterface((IFont*)this, riid, ppvoid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_IConnectionPointContainer_Release (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_Release(
|
|
|
|
IConnectionPointContainer* iface)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IConnectionPointContainer(iface);
|
2000-07-28 22:17:21 +02:00
|
|
|
|
|
|
|
return IFont_Release((IFont*)this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_IConnectionPointContainer_AddRef (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_AddRef(
|
|
|
|
IConnectionPointContainer* iface)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IConnectionPointContainer(iface);
|
2000-07-28 22:17:21 +02:00
|
|
|
|
|
|
|
return IFont_AddRef((IFont*)this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_EnumConnectionPoints (IConnectionPointContainer)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IConnectionPointContainer
|
|
|
|
* methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI OLEFontImpl_EnumConnectionPoints(
|
|
|
|
IConnectionPointContainer* iface,
|
|
|
|
IEnumConnectionPoints **ppEnum)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IConnectionPointContainer(iface);
|
2000-07-28 22:17:21 +02:00
|
|
|
|
|
|
|
FIXME("(%p)->(%p): stub\n", this, ppEnum);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl_FindConnectionPoint (IConnectionPointContainer)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IConnectionPointContainer
|
|
|
|
* methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI OLEFontImpl_FindConnectionPoint(
|
|
|
|
IConnectionPointContainer* iface,
|
|
|
|
REFIID riid,
|
|
|
|
IConnectionPoint **ppCp)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IConnectionPointContainer(iface);
|
2000-07-28 22:17:21 +02:00
|
|
|
TRACE("(%p)->(%s, %p): stub\n", this, debugstr_guid(riid), ppCp);
|
|
|
|
|
2006-02-10 14:50:26 +01:00
|
|
|
if(IsEqualIID(riid, &IID_IPropertyNotifySink)) {
|
|
|
|
return IConnectionPoint_QueryInterface(this->pPropertyNotifyCP,
|
|
|
|
&IID_IConnectionPoint,
|
|
|
|
(LPVOID)ppCp);
|
|
|
|
} else if(IsEqualIID(riid, &IID_IFontEventsDisp)) {
|
|
|
|
return IConnectionPoint_QueryInterface(this->pFontEventsCP,
|
|
|
|
&IID_IConnectionPoint,
|
|
|
|
(LPVOID)ppCp);
|
2000-07-28 22:17:21 +02:00
|
|
|
} else {
|
2006-02-10 14:51:30 +01:00
|
|
|
FIXME("no connection point for %s\n", debugstr_guid(riid));
|
|
|
|
return CONNECT_E_NOCONNECTION;
|
2000-07-28 22:17:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-23 02:23:59 +01:00
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl implementation of IPersistPropertyBag.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_QueryInterface(
|
|
|
|
IPersistPropertyBag *iface, REFIID riid, LPVOID *ppvObj
|
|
|
|
) {
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IPersistPropertyBag(iface);
|
|
|
|
return IFont_QueryInterface((IFont *)this,riid,ppvObj);
|
2003-01-23 02:23:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI OLEFontImpl_IPersistPropertyBag_AddRef(
|
|
|
|
IPersistPropertyBag *iface
|
|
|
|
) {
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IPersistPropertyBag(iface);
|
|
|
|
return IFont_AddRef((IFont *)this);
|
2003-01-23 02:23:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI OLEFontImpl_IPersistPropertyBag_Release(
|
|
|
|
IPersistPropertyBag *iface
|
|
|
|
) {
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IPersistPropertyBag(iface);
|
|
|
|
return IFont_Release((IFont *)this);
|
2003-01-23 02:23:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_GetClassID(
|
|
|
|
IPersistPropertyBag *iface, CLSID *classid
|
|
|
|
) {
|
|
|
|
FIXME("(%p,%p), stub!\n", iface, classid);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_InitNew(
|
|
|
|
IPersistPropertyBag *iface
|
|
|
|
) {
|
|
|
|
FIXME("(%p), stub!\n", iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_Load(
|
|
|
|
IPersistPropertyBag *iface, IPropertyBag* pPropBag, IErrorLog* pErrorLog
|
|
|
|
) {
|
2004-08-20 21:58:46 +02:00
|
|
|
/* (from Visual Basic 6 property bag)
|
|
|
|
Name = "MS Sans Serif"
|
|
|
|
Size = 13.8
|
|
|
|
Charset = 0
|
|
|
|
Weight = 400
|
|
|
|
Underline = 0 'False
|
|
|
|
Italic = 0 'False
|
|
|
|
Strikethrough = 0 'False
|
|
|
|
*/
|
|
|
|
static const WCHAR sAttrName[] = {'N','a','m','e',0};
|
|
|
|
static const WCHAR sAttrSize[] = {'S','i','z','e',0};
|
|
|
|
static const WCHAR sAttrCharset[] = {'C','h','a','r','s','e','t',0};
|
|
|
|
static const WCHAR sAttrWeight[] = {'W','e','i','g','h','t',0};
|
|
|
|
static const WCHAR sAttrUnderline[] = {'U','n','d','e','r','l','i','n','e',0};
|
|
|
|
static const WCHAR sAttrItalic[] = {'I','t','a','l','i','c',0};
|
|
|
|
static const WCHAR sAttrStrikethrough[] = {'S','t','r','i','k','e','t','h','r','o','u','g','h',0};
|
|
|
|
VARIANT rawAttr;
|
|
|
|
VARIANT valueAttr;
|
|
|
|
HRESULT iRes = S_OK;
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IPersistPropertyBag(iface);
|
2004-08-20 21:58:46 +02:00
|
|
|
|
|
|
|
VariantInit(&rawAttr);
|
|
|
|
VariantInit(&valueAttr);
|
|
|
|
|
|
|
|
if (iRes == S_OK) {
|
|
|
|
iRes = IPropertyBag_Read(pPropBag, sAttrName, &rawAttr, pErrorLog);
|
|
|
|
if (iRes == S_OK)
|
|
|
|
{
|
|
|
|
iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BSTR);
|
|
|
|
if (iRes == S_OK)
|
2005-07-27 17:14:18 +02:00
|
|
|
iRes = IFont_put_Name((IFont *)this, V_BSTR(&valueAttr));
|
2004-08-20 21:58:46 +02:00
|
|
|
}
|
|
|
|
else if (iRes == E_INVALIDARG)
|
|
|
|
iRes = S_OK;
|
|
|
|
VariantClear(&rawAttr);
|
|
|
|
VariantClear(&valueAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iRes == S_OK) {
|
|
|
|
iRes = IPropertyBag_Read(pPropBag, sAttrSize, &rawAttr, pErrorLog);
|
|
|
|
if (iRes == S_OK)
|
|
|
|
{
|
|
|
|
iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_CY);
|
|
|
|
if (iRes == S_OK)
|
2005-07-27 17:14:18 +02:00
|
|
|
iRes = IFont_put_Size((IFont *)this, V_CY(&valueAttr));
|
2004-08-20 21:58:46 +02:00
|
|
|
}
|
|
|
|
else if (iRes == E_INVALIDARG)
|
|
|
|
iRes = S_OK;
|
|
|
|
VariantClear(&rawAttr);
|
|
|
|
VariantClear(&valueAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iRes == S_OK) {
|
|
|
|
iRes = IPropertyBag_Read(pPropBag, sAttrCharset, &rawAttr, pErrorLog);
|
|
|
|
if (iRes == S_OK)
|
|
|
|
{
|
|
|
|
iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_I2);
|
|
|
|
if (iRes == S_OK)
|
2005-07-27 17:14:18 +02:00
|
|
|
iRes = IFont_put_Charset((IFont *)this, V_I2(&valueAttr));
|
2004-08-20 21:58:46 +02:00
|
|
|
}
|
|
|
|
else if (iRes == E_INVALIDARG)
|
|
|
|
iRes = S_OK;
|
|
|
|
VariantClear(&rawAttr);
|
|
|
|
VariantClear(&valueAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iRes == S_OK) {
|
|
|
|
iRes = IPropertyBag_Read(pPropBag, sAttrWeight, &rawAttr, pErrorLog);
|
|
|
|
if (iRes == S_OK)
|
|
|
|
{
|
|
|
|
iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_I2);
|
|
|
|
if (iRes == S_OK)
|
2005-07-27 17:14:18 +02:00
|
|
|
iRes = IFont_put_Weight((IFont *)this, V_I2(&valueAttr));
|
2004-08-20 21:58:46 +02:00
|
|
|
}
|
|
|
|
else if (iRes == E_INVALIDARG)
|
|
|
|
iRes = S_OK;
|
|
|
|
VariantClear(&rawAttr);
|
|
|
|
VariantClear(&valueAttr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iRes == S_OK) {
|
|
|
|
iRes = IPropertyBag_Read(pPropBag, sAttrUnderline, &rawAttr, pErrorLog);
|
|
|
|
if (iRes == S_OK)
|
|
|
|
{
|
|
|
|
iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BOOL);
|
|
|
|
if (iRes == S_OK)
|
2005-07-27 17:14:18 +02:00
|
|
|
iRes = IFont_put_Underline((IFont *)this, V_BOOL(&valueAttr));
|
2004-08-20 21:58:46 +02:00
|
|
|
}
|
|
|
|
else if (iRes == E_INVALIDARG)
|
|
|
|
iRes = S_OK;
|
|
|
|
VariantClear(&rawAttr);
|
|
|
|
VariantClear(&valueAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iRes == S_OK) {
|
|
|
|
iRes = IPropertyBag_Read(pPropBag, sAttrItalic, &rawAttr, pErrorLog);
|
|
|
|
if (iRes == S_OK)
|
|
|
|
{
|
|
|
|
iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BOOL);
|
|
|
|
if (iRes == S_OK)
|
2005-07-27 17:14:18 +02:00
|
|
|
iRes = IFont_put_Italic((IFont *)this, V_BOOL(&valueAttr));
|
2004-08-20 21:58:46 +02:00
|
|
|
}
|
|
|
|
else if (iRes == E_INVALIDARG)
|
|
|
|
iRes = S_OK;
|
|
|
|
VariantClear(&rawAttr);
|
|
|
|
VariantClear(&valueAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iRes == S_OK) {
|
|
|
|
iRes = IPropertyBag_Read(pPropBag, sAttrStrikethrough, &rawAttr, pErrorLog);
|
|
|
|
if (iRes == S_OK)
|
|
|
|
{
|
|
|
|
iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BOOL);
|
|
|
|
if (iRes == S_OK)
|
2005-07-27 17:14:18 +02:00
|
|
|
IFont_put_Strikethrough((IFont *)this, V_BOOL(&valueAttr));
|
2004-08-20 21:58:46 +02:00
|
|
|
}
|
|
|
|
else if (iRes == E_INVALIDARG)
|
|
|
|
iRes = S_OK;
|
|
|
|
VariantClear(&rawAttr);
|
|
|
|
VariantClear(&valueAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(iRes))
|
|
|
|
WARN("-- 0x%08lx\n", iRes);
|
|
|
|
return iRes;
|
2003-01-23 02:23:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_Save(
|
|
|
|
IPersistPropertyBag *iface, IPropertyBag* pPropBag, BOOL fClearDirty,
|
|
|
|
BOOL fSaveAllProperties
|
|
|
|
) {
|
|
|
|
FIXME("(%p,%p,%d,%d), stub!\n", iface, pPropBag, fClearDirty, fSaveAllProperties);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IPersistPropertyBagVtbl OLEFontImpl_IPersistPropertyBag_VTable =
|
2003-01-23 02:23:59 +01:00
|
|
|
{
|
|
|
|
OLEFontImpl_IPersistPropertyBag_QueryInterface,
|
|
|
|
OLEFontImpl_IPersistPropertyBag_AddRef,
|
|
|
|
OLEFontImpl_IPersistPropertyBag_Release,
|
|
|
|
|
|
|
|
OLEFontImpl_IPersistPropertyBag_GetClassID,
|
|
|
|
OLEFontImpl_IPersistPropertyBag_InitNew,
|
|
|
|
OLEFontImpl_IPersistPropertyBag_Load,
|
|
|
|
OLEFontImpl_IPersistPropertyBag_Save
|
|
|
|
};
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* OLEFontImpl implementation of IPersistStreamInit.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_QueryInterface(
|
|
|
|
IPersistStreamInit *iface, REFIID riid, LPVOID *ppvObj
|
|
|
|
) {
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IPersistStreamInit(iface);
|
|
|
|
return IFont_QueryInterface((IFont *)this,riid,ppvObj);
|
2003-01-23 02:23:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI OLEFontImpl_IPersistStreamInit_AddRef(
|
|
|
|
IPersistStreamInit *iface
|
|
|
|
) {
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IPersistStreamInit(iface);
|
|
|
|
return IFont_AddRef((IFont *)this);
|
2003-01-23 02:23:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI OLEFontImpl_IPersistStreamInit_Release(
|
|
|
|
IPersistStreamInit *iface
|
|
|
|
) {
|
2005-07-27 17:14:18 +02:00
|
|
|
OLEFontImpl *this = impl_from_IPersistStreamInit(iface);
|
|
|
|
return IFont_Release((IFont *)this);
|
2003-01-23 02:23:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_GetClassID(
|
|
|
|
IPersistStreamInit *iface, CLSID *classid
|
|
|
|
) {
|
|
|
|
FIXME("(%p,%p), stub!\n", iface, classid);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_IsDirty(
|
|
|
|
IPersistStreamInit *iface
|
|
|
|
) {
|
|
|
|
FIXME("(%p), stub!\n", iface);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_Load(
|
|
|
|
IPersistStreamInit *iface, LPSTREAM pStm
|
|
|
|
) {
|
|
|
|
FIXME("(%p,%p), stub!\n", iface, pStm);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_Save(
|
|
|
|
IPersistStreamInit *iface, LPSTREAM pStm, BOOL fClearDirty
|
|
|
|
) {
|
|
|
|
FIXME("(%p,%p,%d), stub!\n", iface, pStm, fClearDirty);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_GetSizeMax(
|
|
|
|
IPersistStreamInit *iface, ULARGE_INTEGER *pcbSize
|
|
|
|
) {
|
|
|
|
FIXME("(%p,%p), stub!\n", iface, pcbSize);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_InitNew(
|
|
|
|
IPersistStreamInit *iface
|
|
|
|
) {
|
|
|
|
FIXME("(%p), stub!\n", iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IPersistStreamInitVtbl OLEFontImpl_IPersistStreamInit_VTable =
|
2003-01-23 02:23:59 +01:00
|
|
|
{
|
|
|
|
OLEFontImpl_IPersistStreamInit_QueryInterface,
|
|
|
|
OLEFontImpl_IPersistStreamInit_AddRef,
|
|
|
|
OLEFontImpl_IPersistStreamInit_Release,
|
|
|
|
|
|
|
|
OLEFontImpl_IPersistStreamInit_GetClassID,
|
|
|
|
OLEFontImpl_IPersistStreamInit_IsDirty,
|
|
|
|
OLEFontImpl_IPersistStreamInit_Load,
|
|
|
|
OLEFontImpl_IPersistStreamInit_Save,
|
|
|
|
OLEFontImpl_IPersistStreamInit_GetSizeMax,
|
|
|
|
OLEFontImpl_IPersistStreamInit_InitNew
|
|
|
|
};
|
|
|
|
|
2001-07-24 02:59:28 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* StdFont ClassFactory
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/* IUnknown fields */
|
2005-06-06 21:50:35 +02:00
|
|
|
const IClassFactoryVtbl *lpVtbl;
|
2005-07-11 12:25:19 +02:00
|
|
|
LONG ref;
|
2001-07-24 02:59:28 +02:00
|
|
|
} IClassFactoryImpl;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI
|
2001-07-24 02:59:28 +02:00
|
|
|
SFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
|
2004-09-09 23:03:58 +02:00
|
|
|
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
2001-07-24 02:59:28 +02:00
|
|
|
|
|
|
|
FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
SFCF_AddRef(LPCLASSFACTORY iface) {
|
2004-09-09 23:03:58 +02:00
|
|
|
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
2004-09-21 02:25:03 +02:00
|
|
|
return InterlockedIncrement(&This->ref);
|
2001-07-24 02:59:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI SFCF_Release(LPCLASSFACTORY iface) {
|
2004-09-09 23:03:58 +02:00
|
|
|
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
2001-07-24 02:59:28 +02:00
|
|
|
/* static class, won't be freed */
|
2004-09-21 02:25:03 +02:00
|
|
|
return InterlockedDecrement(&This->ref);
|
2001-07-24 02:59:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SFCF_CreateInstance(
|
|
|
|
LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
|
|
|
|
) {
|
2003-06-24 21:21:20 +02:00
|
|
|
return OleCreateFontIndirect(NULL,riid,ppobj);
|
2001-07-24 02:59:28 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SFCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
|
2004-09-09 23:03:58 +02:00
|
|
|
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
2001-07-24 02:59:28 +02:00
|
|
|
FIXME("(%p)->(%d),stub!\n",This,dolock);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IClassFactoryVtbl SFCF_Vtbl = {
|
2001-07-24 02:59:28 +02:00
|
|
|
SFCF_QueryInterface,
|
|
|
|
SFCF_AddRef,
|
|
|
|
SFCF_Release,
|
|
|
|
SFCF_CreateInstance,
|
|
|
|
SFCF_LockServer
|
|
|
|
};
|
|
|
|
static IClassFactoryImpl STDFONT_CF = {&SFCF_Vtbl, 1 };
|
|
|
|
|
|
|
|
void _get_STDFONT_CF(LPVOID *ppv) { *ppv = (LPVOID)&STDFONT_CF; }
|