ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

range.c
Go to the documentation of this file.
00001 /*
00002  *  ITfRange implementation
00003  *
00004  *  Copyright 2009 Aric Stewart, CodeWeavers
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  */
00020 
00021 #include "config.h"
00022 
00023 #include <stdarg.h>
00024 
00025 #define COBJMACROS
00026 
00027 #include "wine/debug.h"
00028 #include "windef.h"
00029 #include "winbase.h"
00030 #include "winreg.h"
00031 #include "winuser.h"
00032 #include "shlwapi.h"
00033 #include "winerror.h"
00034 #include "objbase.h"
00035 
00036 #include "wine/unicode.h"
00037 
00038 #include "msctf.h"
00039 #include "msctf_internal.h"
00040 
00041 WINE_DEFAULT_DEBUG_CHANNEL(msctf);
00042 
00043 typedef struct tagRange {
00044     ITfRange ITfRange_iface;
00045     /* const ITfRangeACPVtb *RangeACPVtbl; */
00046     LONG refCount;
00047 
00048     ITextStoreACP   *pITextStoreACP;
00049     ITfContext      *pITfContext;
00050 
00051     DWORD lockType;
00052     TfGravity gravityStart, gravityEnd;
00053     DWORD anchorStart, anchorEnd;
00054 
00055 } Range;
00056 
00057 static inline Range *impl_from_ITfRange(ITfRange *iface)
00058 {
00059     return CONTAINING_RECORD(iface, Range, ITfRange_iface);
00060 }
00061 
00062 static void Range_Destructor(Range *This)
00063 {
00064     TRACE("destroying %p\n", This);
00065     HeapFree(GetProcessHeap(),0,This);
00066 }
00067 
00068 static HRESULT WINAPI Range_QueryInterface(ITfRange *iface, REFIID iid, LPVOID *ppvOut)
00069 {
00070     Range *This = impl_from_ITfRange(iface);
00071     *ppvOut = NULL;
00072 
00073     if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfRange))
00074     {
00075         *ppvOut = This;
00076     }
00077 
00078     if (*ppvOut)
00079     {
00080         IUnknown_AddRef(iface);
00081         return S_OK;
00082     }
00083 
00084     WARN("unsupported interface: %s\n", debugstr_guid(iid));
00085     return E_NOINTERFACE;
00086 }
00087 
00088 static ULONG WINAPI Range_AddRef(ITfRange *iface)
00089 {
00090     Range *This = impl_from_ITfRange(iface);
00091     return InterlockedIncrement(&This->refCount);
00092 }
00093 
00094 static ULONG WINAPI Range_Release(ITfRange *iface)
00095 {
00096     Range *This = impl_from_ITfRange(iface);
00097     ULONG ret;
00098 
00099     ret = InterlockedDecrement(&This->refCount);
00100     if (ret == 0)
00101         Range_Destructor(This);
00102     return ret;
00103 }
00104 
00105 /*****************************************************
00106  * ITfRange functions
00107  *****************************************************/
00108 
00109 static HRESULT WINAPI Range_GetText(ITfRange *iface, TfEditCookie ec,
00110         DWORD dwFlags, WCHAR *pchText, ULONG cchMax, ULONG *pcch)
00111 {
00112     Range *This = impl_from_ITfRange(iface);
00113     FIXME("STUB:(%p)\n",This);
00114     return E_NOTIMPL;
00115 }
00116 
00117 static HRESULT WINAPI Range_SetText(ITfRange *iface, TfEditCookie ec,
00118          DWORD dwFlags, const WCHAR *pchText, LONG cch)
00119 {
00120     Range *This = impl_from_ITfRange(iface);
00121     FIXME("STUB:(%p)\n",This);
00122     return E_NOTIMPL;
00123 }
00124 
00125 static HRESULT WINAPI Range_GetFormattedText(ITfRange *iface, TfEditCookie ec,
00126         IDataObject **ppDataObject)
00127 {
00128     Range *This = impl_from_ITfRange(iface);
00129     FIXME("STUB:(%p)\n",This);
00130     return E_NOTIMPL;
00131 }
00132 
00133 static HRESULT WINAPI Range_GetEmbedded(ITfRange *iface, TfEditCookie ec,
00134         REFGUID rguidService, REFIID riid, IUnknown **ppunk)
00135 {
00136     Range *This = impl_from_ITfRange(iface);
00137     FIXME("STUB:(%p)\n",This);
00138     return E_NOTIMPL;
00139 }
00140 
00141 static HRESULT WINAPI Range_InsertEmbedded(ITfRange *iface, TfEditCookie ec,
00142         DWORD dwFlags, IDataObject *pDataObject)
00143 {
00144     Range *This = impl_from_ITfRange(iface);
00145     FIXME("STUB:(%p)\n",This);
00146     return E_NOTIMPL;
00147 }
00148 
00149 static HRESULT WINAPI Range_ShiftStart(ITfRange *iface, TfEditCookie ec,
00150         LONG cchReq, LONG *pcch, const TF_HALTCOND *pHalt)
00151 {
00152     Range *This = impl_from_ITfRange(iface);
00153     FIXME("STUB:(%p)\n",This);
00154     return E_NOTIMPL;
00155 }
00156 
00157 static HRESULT WINAPI Range_ShiftEnd(ITfRange *iface, TfEditCookie ec,
00158         LONG cchReq, LONG *pcch, const TF_HALTCOND *pHalt)
00159 {
00160     Range *This = impl_from_ITfRange(iface);
00161     FIXME("STUB:(%p)\n",This);
00162     return E_NOTIMPL;
00163 }
00164 
00165 static HRESULT WINAPI Range_ShiftStartToRange(ITfRange *iface, TfEditCookie ec,
00166         ITfRange *pRange, TfAnchor aPos)
00167 {
00168     Range *This = impl_from_ITfRange(iface);
00169     FIXME("STUB:(%p)\n",This);
00170     return E_NOTIMPL;
00171 }
00172 
00173 static HRESULT WINAPI Range_ShiftEndToRange(ITfRange *iface, TfEditCookie ec,
00174         ITfRange *pRange, TfAnchor aPos)
00175 {
00176     Range *This = impl_from_ITfRange(iface);
00177     FIXME("STUB:(%p)\n",This);
00178     return E_NOTIMPL;
00179 }
00180 
00181 static HRESULT WINAPI Range_ShiftStartRegion(ITfRange *iface, TfEditCookie ec,
00182         TfShiftDir dir, BOOL *pfNoRegion)
00183 {
00184     Range *This = impl_from_ITfRange(iface);
00185     FIXME("STUB:(%p)\n",This);
00186     return E_NOTIMPL;
00187 }
00188 
00189 static HRESULT WINAPI Range_ShiftEndRegion(ITfRange *iface, TfEditCookie ec,
00190         TfShiftDir dir, BOOL *pfNoRegion)
00191 {
00192     Range *This = impl_from_ITfRange(iface);
00193     FIXME("STUB:(%p)\n",This);
00194     return E_NOTIMPL;
00195 }
00196 
00197 static HRESULT WINAPI Range_IsEmpty(ITfRange *iface, TfEditCookie ec,
00198         BOOL *pfEmpty)
00199 {
00200     Range *This = impl_from_ITfRange(iface);
00201     FIXME("STUB:(%p)\n",This);
00202     return E_NOTIMPL;
00203 }
00204 
00205 static HRESULT WINAPI Range_Collapse(ITfRange *iface, TfEditCookie ec,
00206         TfAnchor aPos)
00207 {
00208     Range *This = impl_from_ITfRange(iface);
00209     TRACE("(%p) %i %i\n",This,ec,aPos);
00210 
00211     switch (aPos)
00212     {
00213         case TF_ANCHOR_START:
00214             This->anchorEnd = This->anchorStart;
00215             break;
00216         case TF_ANCHOR_END:
00217             This->anchorStart = This->anchorEnd;
00218             break;
00219         default:
00220             return E_INVALIDARG;
00221     }
00222 
00223     return S_OK;
00224 }
00225 
00226 static HRESULT WINAPI Range_IsEqualStart(ITfRange *iface, TfEditCookie ec,
00227         ITfRange *pWith, TfAnchor aPos, BOOL *pfEqual)
00228 {
00229     Range *This = impl_from_ITfRange(iface);
00230     FIXME("STUB:(%p)\n",This);
00231     return E_NOTIMPL;
00232 }
00233 
00234 static HRESULT WINAPI Range_IsEqualEnd(ITfRange *iface, TfEditCookie ec,
00235         ITfRange *pWith, TfAnchor aPos, BOOL *pfEqual)
00236 {
00237     Range *This = impl_from_ITfRange(iface);
00238     FIXME("STUB:(%p)\n",This);
00239     return E_NOTIMPL;
00240 }
00241 
00242 static HRESULT WINAPI Range_CompareStart(ITfRange *iface, TfEditCookie ec,
00243         ITfRange *pWith, TfAnchor aPos, LONG *plResult)
00244 {
00245     Range *This = impl_from_ITfRange(iface);
00246     FIXME("STUB:(%p)\n",This);
00247     return E_NOTIMPL;
00248 }
00249 
00250 static HRESULT WINAPI Range_CompareEnd(ITfRange *iface, TfEditCookie ec,
00251         ITfRange *pWith, TfAnchor aPos, LONG *plResult)
00252 {
00253     Range *This = impl_from_ITfRange(iface);
00254     FIXME("STUB:(%p)\n",This);
00255     return E_NOTIMPL;
00256 }
00257 
00258 static HRESULT WINAPI Range_AdjustForInsert(ITfRange *iface, TfEditCookie ec,
00259         ULONG cchInsert, BOOL *pfInsertOk)
00260 {
00261     Range *This = impl_from_ITfRange(iface);
00262     FIXME("STUB:(%p)\n",This);
00263     return E_NOTIMPL;
00264 }
00265 
00266 static HRESULT WINAPI Range_GetGravity(ITfRange *iface,
00267         TfGravity *pgStart, TfGravity *pgEnd)
00268 {
00269     Range *This = impl_from_ITfRange(iface);
00270     FIXME("STUB:(%p)\n",This);
00271     return E_NOTIMPL;
00272 }
00273 
00274 static HRESULT WINAPI Range_SetGravity(ITfRange *iface, TfEditCookie ec,
00275          TfGravity gStart, TfGravity gEnd)
00276 {
00277     Range *This = impl_from_ITfRange(iface);
00278     FIXME("STUB:(%p)\n",This);
00279     return E_NOTIMPL;
00280 }
00281 
00282 static HRESULT WINAPI Range_Clone(ITfRange *iface, ITfRange **ppClone)
00283 {
00284     Range *This = impl_from_ITfRange(iface);
00285     FIXME("STUB:(%p)\n",This);
00286     return E_NOTIMPL;
00287 }
00288 
00289 static HRESULT WINAPI Range_GetContext(ITfRange *iface, ITfContext **ppContext)
00290 {
00291     Range *This = impl_from_ITfRange(iface);
00292     TRACE("(%p)\n",This);
00293     if (!ppContext)
00294         return E_INVALIDARG;
00295     *ppContext = This->pITfContext;
00296     return S_OK;
00297 }
00298 
00299 static const ITfRangeVtbl Range_RangeVtbl =
00300 {
00301     Range_QueryInterface,
00302     Range_AddRef,
00303     Range_Release,
00304 
00305     Range_GetText,
00306     Range_SetText,
00307     Range_GetFormattedText,
00308     Range_GetEmbedded,
00309     Range_InsertEmbedded,
00310     Range_ShiftStart,
00311     Range_ShiftEnd,
00312     Range_ShiftStartToRange,
00313     Range_ShiftEndToRange,
00314     Range_ShiftStartRegion,
00315     Range_ShiftEndRegion,
00316     Range_IsEmpty,
00317     Range_Collapse,
00318     Range_IsEqualStart,
00319     Range_IsEqualEnd,
00320     Range_CompareStart,
00321     Range_CompareEnd,
00322     Range_AdjustForInsert,
00323     Range_GetGravity,
00324     Range_SetGravity,
00325     Range_Clone,
00326     Range_GetContext
00327 };
00328 
00329 HRESULT Range_Constructor(ITfContext *context, ITextStoreACP *textstore, DWORD lockType, DWORD anchorStart, DWORD anchorEnd, ITfRange **ppOut)
00330 {
00331     Range *This;
00332 
00333     This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(Range));
00334     if (This == NULL)
00335         return E_OUTOFMEMORY;
00336 
00337     TRACE("(%p) %p %p\n",This, context, textstore);
00338 
00339     This->ITfRange_iface.lpVtbl = &Range_RangeVtbl;
00340     This->refCount = 1;
00341     This->pITfContext = context;
00342     This->pITextStoreACP = textstore;
00343     This->lockType = lockType;
00344     This->anchorStart = anchorStart;
00345     This->anchorEnd = anchorEnd;
00346 
00347     *ppOut = &This->ITfRange_iface;
00348     TRACE("returning %p\n", This);
00349 
00350     return S_OK;
00351 }
00352 
00353 /* Internal conversion functions */
00354 
00355 HRESULT TF_SELECTION_to_TS_SELECTION_ACP(const TF_SELECTION *tf, TS_SELECTION_ACP *tsAcp)
00356 {
00357     Range *This;
00358 
00359     if (!tf || !tsAcp || !tf->range)
00360         return E_INVALIDARG;
00361 
00362     This = (Range *)tf->range;
00363 
00364     tsAcp->acpStart = This->anchorStart;
00365     tsAcp->acpEnd = This->anchorEnd;
00366     tsAcp->style.ase = tf->style.ase;
00367     tsAcp->style.fInterimChar = tf->style.fInterimChar;
00368     return S_OK;
00369 }

Generated on Sat May 26 2012 04:23:23 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.