Commit c4c35d33 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

infosoft: Use the pfnFillTextBuffer function to refresh the buffer.

parent 510fc118
......@@ -87,35 +87,67 @@ static HRESULT WINAPI wb_Init( IWordBreaker *iface,
return S_OK;
}
static HRESULT WINAPI wb_BreakText( IWordBreaker *iface,
TEXT_SOURCE *pTextSource, IWordSink *pWordSink, IPhraseSink *pPhraseSink)
static HRESULT call_sink( IWordSink *pWordSink, TEXT_SOURCE *ts, UINT len )
{
LPCWSTR p, q;
DWORD len;
HRESULT r;
FIXME("%p %p %p\n", pTextSource, pWordSink, pPhraseSink);
if (!len)
return S_OK;
p = pTextSource->awcBuffer;
TRACE("%d %s\n", len, debugstr_w(&ts->awcBuffer[ts->iCur]));
while (*p)
{
/* skip spaces and punctuation */
while(ispunctW(*p) || isspaceW(*p))
p++;
r = IWordSink_PutWord( pWordSink, len, &ts->awcBuffer[ts->iCur], len, ts->iCur );
ts->iCur += len;
return r;
}
/* find the end of the word */
q = p;
while(*q && !ispunctW(*q) && !isspaceW(*q))
q++;
static HRESULT WINAPI wb_BreakText( IWordBreaker *iface,
TEXT_SOURCE *ts, IWordSink *pWordSink, IPhraseSink *pPhraseSink)
{
UINT len, state = 0;
WCHAR ch;
len = q - p;
if (!len)
break;
TRACE("%p %p %p\n", ts, pWordSink, pPhraseSink);
IWordSink_PutWord( pWordSink, len, p, len, p - pTextSource->awcBuffer );
if (pPhraseSink)
FIXME("IPhraseSink won't be called\n");
do
{
len = 0;
while ((ts->iCur + len) < ts->iEnd)
{
ch = ts->awcBuffer[ts->iCur + len];
switch (state)
{
case 0: /* skip spaces and punctuation */
if (!ch || ispunctW(ch) || isspaceW(ch))
ts->iCur ++;
else
state = 1;
break;
case 1: /* find the end of the word */
if (ch && !ispunctW(ch) && !isspaceW(ch))
len++;
else
{
call_sink( pWordSink, ts, len );
len = 0;
state = 0;
}
break;
}
}
call_sink( pWordSink, ts, len );
} while (S_OK == ts->pfnFillTextBuffer( ts ));
p = q;
}
return S_OK;
}
......@@ -152,7 +184,7 @@ HRESULT WINAPI wb_Constructor(IUnknown* pUnkOuter, REFIID riid, LPVOID *ppvObjec
wordbreaker_impl *This;
IWordBreaker *wb;
FIXME("%p %s %p\n", pUnkOuter, debugstr_guid(riid), ppvObject);
TRACE("%p %s %p\n", pUnkOuter, debugstr_guid(riid), ppvObject);
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
if (!This)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment