2009-05-18 21:48:18 +02:00
|
|
|
/*
|
|
|
|
* ITfRange implementation
|
|
|
|
*
|
|
|
|
* Copyright 2009 Aric Stewart, CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
|
|
|
#include "msctf.h"
|
|
|
|
#include "msctf_internal.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msctf);
|
|
|
|
|
|
|
|
typedef struct tagRange {
|
2010-12-08 22:59:40 +01:00
|
|
|
ITfRange ITfRange_iface;
|
2009-05-18 21:48:18 +02:00
|
|
|
/* const ITfRangeACPVtb *RangeACPVtbl; */
|
|
|
|
LONG refCount;
|
|
|
|
|
|
|
|
ITextStoreACP *pITextStoreACP;
|
|
|
|
ITfContext *pITfContext;
|
|
|
|
|
|
|
|
DWORD lockType;
|
|
|
|
TfGravity gravityStart, gravityEnd;
|
|
|
|
DWORD anchorStart, anchorEnd;
|
|
|
|
|
|
|
|
} Range;
|
|
|
|
|
2010-12-08 22:59:40 +01:00
|
|
|
static inline Range *impl_from_ITfRange(ITfRange *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, Range, ITfRange_iface);
|
|
|
|
}
|
|
|
|
|
2009-05-18 21:48:18 +02:00
|
|
|
static void Range_Destructor(Range *This)
|
|
|
|
{
|
|
|
|
TRACE("destroying %p\n", This);
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_QueryInterface(ITfRange *iface, REFIID iid, LPVOID *ppvOut)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
*ppvOut = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfRange))
|
|
|
|
{
|
|
|
|
*ppvOut = This;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*ppvOut)
|
|
|
|
{
|
2012-08-19 20:01:36 +02:00
|
|
|
ITfRange_AddRef(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("unsupported interface: %s\n", debugstr_guid(iid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Range_AddRef(ITfRange *iface)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
return InterlockedIncrement(&This->refCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Range_Release(ITfRange *iface)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
ULONG ret;
|
|
|
|
|
|
|
|
ret = InterlockedDecrement(&This->refCount);
|
|
|
|
if (ret == 0)
|
|
|
|
Range_Destructor(This);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* ITfRange functions
|
|
|
|
*****************************************************/
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_GetText(ITfRange *iface, TfEditCookie ec,
|
|
|
|
DWORD dwFlags, WCHAR *pchText, ULONG cchMax, ULONG *pcch)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_SetText(ITfRange *iface, TfEditCookie ec,
|
|
|
|
DWORD dwFlags, const WCHAR *pchText, LONG cch)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_GetFormattedText(ITfRange *iface, TfEditCookie ec,
|
|
|
|
IDataObject **ppDataObject)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_GetEmbedded(ITfRange *iface, TfEditCookie ec,
|
|
|
|
REFGUID rguidService, REFIID riid, IUnknown **ppunk)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_InsertEmbedded(ITfRange *iface, TfEditCookie ec,
|
|
|
|
DWORD dwFlags, IDataObject *pDataObject)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_ShiftStart(ITfRange *iface, TfEditCookie ec,
|
|
|
|
LONG cchReq, LONG *pcch, const TF_HALTCOND *pHalt)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_ShiftEnd(ITfRange *iface, TfEditCookie ec,
|
|
|
|
LONG cchReq, LONG *pcch, const TF_HALTCOND *pHalt)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_ShiftStartToRange(ITfRange *iface, TfEditCookie ec,
|
|
|
|
ITfRange *pRange, TfAnchor aPos)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_ShiftEndToRange(ITfRange *iface, TfEditCookie ec,
|
|
|
|
ITfRange *pRange, TfAnchor aPos)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_ShiftStartRegion(ITfRange *iface, TfEditCookie ec,
|
|
|
|
TfShiftDir dir, BOOL *pfNoRegion)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_ShiftEndRegion(ITfRange *iface, TfEditCookie ec,
|
|
|
|
TfShiftDir dir, BOOL *pfNoRegion)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_IsEmpty(ITfRange *iface, TfEditCookie ec,
|
|
|
|
BOOL *pfEmpty)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_Collapse(ITfRange *iface, TfEditCookie ec,
|
|
|
|
TfAnchor aPos)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-26 20:30:08 +02:00
|
|
|
TRACE("(%p) %i %i\n",This,ec,aPos);
|
|
|
|
|
|
|
|
switch (aPos)
|
|
|
|
{
|
|
|
|
case TF_ANCHOR_START:
|
|
|
|
This->anchorEnd = This->anchorStart;
|
|
|
|
break;
|
|
|
|
case TF_ANCHOR_END:
|
|
|
|
This->anchorStart = This->anchorEnd;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2009-05-18 21:48:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_IsEqualStart(ITfRange *iface, TfEditCookie ec,
|
|
|
|
ITfRange *pWith, TfAnchor aPos, BOOL *pfEqual)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_IsEqualEnd(ITfRange *iface, TfEditCookie ec,
|
|
|
|
ITfRange *pWith, TfAnchor aPos, BOOL *pfEqual)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_CompareStart(ITfRange *iface, TfEditCookie ec,
|
|
|
|
ITfRange *pWith, TfAnchor aPos, LONG *plResult)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_CompareEnd(ITfRange *iface, TfEditCookie ec,
|
|
|
|
ITfRange *pWith, TfAnchor aPos, LONG *plResult)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_AdjustForInsert(ITfRange *iface, TfEditCookie ec,
|
|
|
|
ULONG cchInsert, BOOL *pfInsertOk)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_GetGravity(ITfRange *iface,
|
|
|
|
TfGravity *pgStart, TfGravity *pgEnd)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_SetGravity(ITfRange *iface, TfEditCookie ec,
|
|
|
|
TfGravity gStart, TfGravity gEnd)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_Clone(ITfRange *iface, ITfRange **ppClone)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:18 +02:00
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Range_GetContext(ITfRange *iface, ITfContext **ppContext)
|
|
|
|
{
|
2010-12-08 22:59:40 +01:00
|
|
|
Range *This = impl_from_ITfRange(iface);
|
2009-05-18 21:48:26 +02:00
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
if (!ppContext)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
*ppContext = This->pITfContext;
|
|
|
|
return S_OK;
|
2009-05-18 21:48:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const ITfRangeVtbl Range_RangeVtbl =
|
|
|
|
{
|
|
|
|
Range_QueryInterface,
|
|
|
|
Range_AddRef,
|
|
|
|
Range_Release,
|
|
|
|
|
|
|
|
Range_GetText,
|
|
|
|
Range_SetText,
|
|
|
|
Range_GetFormattedText,
|
|
|
|
Range_GetEmbedded,
|
|
|
|
Range_InsertEmbedded,
|
|
|
|
Range_ShiftStart,
|
|
|
|
Range_ShiftEnd,
|
|
|
|
Range_ShiftStartToRange,
|
|
|
|
Range_ShiftEndToRange,
|
|
|
|
Range_ShiftStartRegion,
|
|
|
|
Range_ShiftEndRegion,
|
|
|
|
Range_IsEmpty,
|
|
|
|
Range_Collapse,
|
|
|
|
Range_IsEqualStart,
|
|
|
|
Range_IsEqualEnd,
|
|
|
|
Range_CompareStart,
|
|
|
|
Range_CompareEnd,
|
|
|
|
Range_AdjustForInsert,
|
|
|
|
Range_GetGravity,
|
|
|
|
Range_SetGravity,
|
|
|
|
Range_Clone,
|
|
|
|
Range_GetContext
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT Range_Constructor(ITfContext *context, ITextStoreACP *textstore, DWORD lockType, DWORD anchorStart, DWORD anchorEnd, ITfRange **ppOut)
|
|
|
|
{
|
|
|
|
Range *This;
|
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(Range));
|
|
|
|
if (This == NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
TRACE("(%p) %p %p\n",This, context, textstore);
|
|
|
|
|
2010-12-08 22:59:40 +01:00
|
|
|
This->ITfRange_iface.lpVtbl = &Range_RangeVtbl;
|
2009-05-18 21:48:18 +02:00
|
|
|
This->refCount = 1;
|
|
|
|
This->pITfContext = context;
|
|
|
|
This->pITextStoreACP = textstore;
|
|
|
|
This->lockType = lockType;
|
|
|
|
This->anchorStart = anchorStart;
|
|
|
|
This->anchorEnd = anchorEnd;
|
|
|
|
|
2010-12-08 22:59:40 +01:00
|
|
|
*ppOut = &This->ITfRange_iface;
|
2009-05-18 21:48:18 +02:00
|
|
|
TRACE("returning %p\n", This);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2009-06-03 18:27:31 +02:00
|
|
|
|
|
|
|
/* Internal conversion functions */
|
|
|
|
|
|
|
|
HRESULT TF_SELECTION_to_TS_SELECTION_ACP(const TF_SELECTION *tf, TS_SELECTION_ACP *tsAcp)
|
|
|
|
{
|
2009-06-05 09:20:27 +02:00
|
|
|
Range *This;
|
2009-06-03 18:27:31 +02:00
|
|
|
|
|
|
|
if (!tf || !tsAcp || !tf->range)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2009-06-05 09:20:27 +02:00
|
|
|
This = (Range *)tf->range;
|
|
|
|
|
2009-06-03 18:27:31 +02:00
|
|
|
tsAcp->acpStart = This->anchorStart;
|
|
|
|
tsAcp->acpEnd = This->anchorEnd;
|
|
|
|
tsAcp->style.ase = tf->style.ase;
|
|
|
|
tsAcp->style.fInterimChar = tf->style.fInterimChar;
|
|
|
|
return S_OK;
|
|
|
|
}
|