2 * Word splitter Implementation
4 * Copyright 2006 Mike McCormack
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include "wine/unicode.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(infosoft);
38 typedef struct tag_wordbreaker_impl
40 const IWordBreakerVtbl *lpVtbl;
44 static HRESULT WINAPI wb_QueryInterface( IWordBreaker *iface,
45 REFIID riid, LPVOID *ppvObj)
47 wordbreaker_impl *This = (wordbreaker_impl *)iface;
49 TRACE("(%p)->(%s)\n",This,debugstr_guid(riid));
53 if (IsEqualIID(riid, &IID_IUnknown) ||
54 IsEqualIID(riid, &IID_IWordBreaker))
60 TRACE("-- E_NOINTERFACE\n");
64 static ULONG WINAPI wb_AddRef( IWordBreaker *iface )
66 wordbreaker_impl *This = (wordbreaker_impl *)iface;
67 return InterlockedIncrement(&This->ref);
70 static ULONG WINAPI wb_Release(IWordBreaker *iface)
72 wordbreaker_impl *This = (wordbreaker_impl *)iface;
75 refcount = InterlockedDecrement(&This->ref);
77 HeapFree(GetProcessHeap(), 0, This);
82 static HRESULT WINAPI wb_Init( IWordBreaker *iface,
83 BOOL fQuery, ULONG ulMaxTokenSize, BOOL *pfLicense )
85 TRACE("%d %u\n", fQuery, ulMaxTokenSize);
90 static HRESULT call_sink( IWordSink *pWordSink, TEXT_SOURCE *ts, UINT len )
97 TRACE("%d %s\n", len, debugstr_w(&ts->awcBuffer[ts->iCur]));
99 r = IWordSink_PutWord( pWordSink, len, &ts->awcBuffer[ts->iCur], len, ts->iCur );
105 static HRESULT WINAPI wb_BreakText( IWordBreaker *iface,
106 TEXT_SOURCE *ts, IWordSink *pWordSink, IPhraseSink *pPhraseSink)
111 TRACE("%p %p %p\n", ts, pWordSink, pPhraseSink);
114 FIXME("IPhraseSink won't be called\n");
119 while ((ts->iCur + len) < ts->iEnd)
121 ch = ts->awcBuffer[ts->iCur + len];
125 case 0: /* skip spaces and punctuation */
127 if (!ch || ispunctW(ch) || isspaceW(ch))
133 case 1: /* find the end of the word */
135 if (ch && !ispunctW(ch) && !isspaceW(ch))
139 call_sink( pWordSink, ts, len );
147 call_sink( pWordSink, ts, len );
149 } while (S_OK == ts->pfnFillTextBuffer( ts ));
154 static HRESULT WINAPI wb_ComposePhrase( IWordBreaker *iface,
155 const WCHAR *pwcNoun, ULONG cwcNoun,
156 const WCHAR *pwcModifier, ULONG cwcModifier,
157 ULONG ulAttachmentType, WCHAR *pwcPhrase, ULONG *pcwcPhrase)
159 FIXME("%p %u %p %u %u %p %p\n", pwcNoun, cwcNoun,
160 pwcModifier, cwcModifier, ulAttachmentType, pwcPhrase, pcwcPhrase);
164 static HRESULT WINAPI wb_GetLicenseToUse( IWordBreaker *iface, const WCHAR **ppwcsLicense )
166 FIXME("%p\n", ppwcsLicense);
167 *ppwcsLicense = NULL;
171 static const IWordBreakerVtbl wordbreaker_vtbl =
182 HRESULT WINAPI wb_Constructor(IUnknown* pUnkOuter, REFIID riid, LPVOID *ppvObject)
184 wordbreaker_impl *This;
187 TRACE("%p %s %p\n", pUnkOuter, debugstr_guid(riid), ppvObject);
189 This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
191 return E_OUTOFMEMORY;
194 This->lpVtbl = &wordbreaker_vtbl;
196 wb = (IWordBreaker*) This;
198 return IWordBreaker_QueryInterface(wb, riid, ppvObject);