2006-07-11 04:13:18 +02:00
|
|
|
/*
|
|
|
|
* Word splitter Implementation
|
|
|
|
*
|
|
|
|
* Copyright 2006 Mike McCormack
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "ole2.h"
|
2006-08-11 13:21:46 +02:00
|
|
|
#include "indexsrv.h"
|
2006-07-11 04:13:18 +02:00
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(infosoft);
|
|
|
|
|
|
|
|
typedef struct tag_wordbreaker_impl
|
|
|
|
{
|
|
|
|
const IWordBreakerVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
|
|
|
} wordbreaker_impl;
|
|
|
|
|
|
|
|
static HRESULT WINAPI wb_QueryInterface( IWordBreaker *iface,
|
|
|
|
REFIID riid, LPVOID *ppvObj)
|
|
|
|
{
|
|
|
|
wordbreaker_impl *This = (wordbreaker_impl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n",This,debugstr_guid(riid));
|
|
|
|
|
|
|
|
*ppvObj = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IWordBreaker))
|
|
|
|
{
|
|
|
|
*ppvObj = This;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("-- E_NOINTERFACE\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI wb_AddRef( IWordBreaker *iface )
|
|
|
|
{
|
|
|
|
wordbreaker_impl *This = (wordbreaker_impl *)iface;
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI wb_Release(IWordBreaker *iface)
|
|
|
|
{
|
|
|
|
wordbreaker_impl *This = (wordbreaker_impl *)iface;
|
|
|
|
LONG refcount;
|
|
|
|
|
|
|
|
refcount = InterlockedDecrement(&This->ref);
|
|
|
|
if (!refcount)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI wb_Init( IWordBreaker *iface,
|
|
|
|
BOOL fQuery, ULONG ulMaxTokenSize, BOOL *pfLicense )
|
|
|
|
{
|
2006-10-04 11:50:42 +02:00
|
|
|
TRACE("%d %u\n", fQuery, ulMaxTokenSize);
|
2006-07-11 04:13:18 +02:00
|
|
|
*pfLicense = FALSE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2006-08-11 13:08:25 +02:00
|
|
|
static HRESULT call_sink( IWordSink *pWordSink, TEXT_SOURCE *ts, UINT len )
|
2006-07-11 04:13:18 +02:00
|
|
|
{
|
2006-08-11 13:08:25 +02:00
|
|
|
HRESULT r;
|
2006-07-11 04:13:18 +02:00
|
|
|
|
2006-08-11 13:08:25 +02:00
|
|
|
if (!len)
|
|
|
|
return S_OK;
|
2006-07-11 04:13:18 +02:00
|
|
|
|
2006-08-11 13:08:25 +02:00
|
|
|
TRACE("%d %s\n", len, debugstr_w(&ts->awcBuffer[ts->iCur]));
|
2006-07-11 04:13:18 +02:00
|
|
|
|
2006-08-11 13:08:25 +02:00
|
|
|
r = IWordSink_PutWord( pWordSink, len, &ts->awcBuffer[ts->iCur], len, ts->iCur );
|
|
|
|
ts->iCur += len;
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
2006-07-11 04:13:18 +02:00
|
|
|
|
2006-08-11 13:08:25 +02:00
|
|
|
static HRESULT WINAPI wb_BreakText( IWordBreaker *iface,
|
|
|
|
TEXT_SOURCE *ts, IWordSink *pWordSink, IPhraseSink *pPhraseSink)
|
|
|
|
{
|
|
|
|
UINT len, state = 0;
|
|
|
|
WCHAR ch;
|
2006-07-11 04:13:18 +02:00
|
|
|
|
2006-08-11 13:08:25 +02:00
|
|
|
TRACE("%p %p %p\n", ts, pWordSink, pPhraseSink);
|
2006-07-11 04:13:18 +02:00
|
|
|
|
2006-08-11 13:08:25 +02:00
|
|
|
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 ));
|
2006-07-11 04:13:18 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI wb_ComposePhrase( IWordBreaker *iface,
|
|
|
|
const WCHAR *pwcNoun, ULONG cwcNoun,
|
|
|
|
const WCHAR *pwcModifier, ULONG cwcModifier,
|
|
|
|
ULONG ulAttachmentType, WCHAR *pwcPhrase, ULONG *pcwcPhrase)
|
|
|
|
{
|
2006-10-04 11:50:42 +02:00
|
|
|
FIXME("%p %u %p %u %u %p %p\n", pwcNoun, cwcNoun,
|
2006-07-11 04:13:18 +02:00
|
|
|
pwcModifier, cwcModifier, ulAttachmentType, pwcPhrase, pcwcPhrase);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI wb_GetLicenseToUse( IWordBreaker *iface, const WCHAR **ppwcsLicense )
|
|
|
|
{
|
|
|
|
FIXME("%p\n", ppwcsLicense);
|
|
|
|
*ppwcsLicense = NULL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IWordBreakerVtbl wordbreaker_vtbl =
|
|
|
|
{
|
|
|
|
wb_QueryInterface,
|
|
|
|
wb_AddRef,
|
|
|
|
wb_Release,
|
|
|
|
wb_Init,
|
|
|
|
wb_BreakText,
|
|
|
|
wb_ComposePhrase,
|
|
|
|
wb_GetLicenseToUse,
|
|
|
|
};
|
|
|
|
|
2006-08-10 15:40:39 +02:00
|
|
|
HRESULT WINAPI wb_Constructor(IUnknown* pUnkOuter, REFIID riid, LPVOID *ppvObject)
|
2006-07-11 04:13:18 +02:00
|
|
|
{
|
|
|
|
wordbreaker_impl *This;
|
|
|
|
IWordBreaker *wb;
|
|
|
|
|
2006-08-11 13:08:25 +02:00
|
|
|
TRACE("%p %s %p\n", pUnkOuter, debugstr_guid(riid), ppvObject);
|
2006-07-11 04:13:18 +02:00
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
|
|
|
|
if (!This)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->ref = 1;
|
|
|
|
This->lpVtbl = &wordbreaker_vtbl;
|
|
|
|
|
|
|
|
wb = (IWordBreaker*) This;
|
|
|
|
|
|
|
|
return IWordBreaker_QueryInterface(wb, riid, ppvObject);
|
|
|
|
}
|