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
32 #include "wine/unicode.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(infosoft
);
37 typedef struct tag_wordbreaker_impl
39 const IWordBreakerVtbl
*lpVtbl
;
43 static HRESULT WINAPI
wb_QueryInterface( IWordBreaker
*iface
,
44 REFIID riid
, LPVOID
*ppvObj
)
46 wordbreaker_impl
*This
= (wordbreaker_impl
*)iface
;
48 TRACE("(%p)->(%s)\n",This
,debugstr_guid(riid
));
52 if (IsEqualIID(riid
, &IID_IUnknown
) ||
53 IsEqualIID(riid
, &IID_IWordBreaker
))
59 TRACE("-- E_NOINTERFACE\n");
63 static ULONG WINAPI
wb_AddRef( IWordBreaker
*iface
)
65 wordbreaker_impl
*This
= (wordbreaker_impl
*)iface
;
66 return InterlockedIncrement(&This
->ref
);
69 static ULONG WINAPI
wb_Release(IWordBreaker
*iface
)
71 wordbreaker_impl
*This
= (wordbreaker_impl
*)iface
;
74 refcount
= InterlockedDecrement(&This
->ref
);
76 HeapFree(GetProcessHeap(), 0, This
);
81 static HRESULT WINAPI
wb_Init( IWordBreaker
*iface
,
82 BOOL fQuery
, ULONG ulMaxTokenSize
, BOOL
*pfLicense
)
84 TRACE("%d %u\n", fQuery
, ulMaxTokenSize
);
89 static HRESULT
call_sink( IWordSink
*pWordSink
, TEXT_SOURCE
*ts
, UINT len
)
96 TRACE("%d %s\n", len
, debugstr_w(&ts
->awcBuffer
[ts
->iCur
]));
98 r
= IWordSink_PutWord( pWordSink
, len
, &ts
->awcBuffer
[ts
->iCur
], len
, ts
->iCur
);
104 static HRESULT WINAPI
wb_BreakText( IWordBreaker
*iface
,
105 TEXT_SOURCE
*ts
, IWordSink
*pWordSink
, IPhraseSink
*pPhraseSink
)
110 TRACE("%p %p %p\n", ts
, pWordSink
, pPhraseSink
);
113 FIXME("IPhraseSink won't be called\n");
118 while ((ts
->iCur
+ len
) < ts
->iEnd
)
120 ch
= ts
->awcBuffer
[ts
->iCur
+ len
];
124 case 0: /* skip spaces and punctuation */
126 if (!ch
|| ispunctW(ch
) || isspaceW(ch
))
132 case 1: /* find the end of the word */
134 if (ch
&& !ispunctW(ch
) && !isspaceW(ch
))
138 call_sink( pWordSink
, ts
, len
);
146 call_sink( pWordSink
, ts
, len
);
148 } while (S_OK
== ts
->pfnFillTextBuffer( ts
));
153 static HRESULT WINAPI
wb_ComposePhrase( IWordBreaker
*iface
,
154 const WCHAR
*pwcNoun
, ULONG cwcNoun
,
155 const WCHAR
*pwcModifier
, ULONG cwcModifier
,
156 ULONG ulAttachmentType
, WCHAR
*pwcPhrase
, ULONG
*pcwcPhrase
)
158 FIXME("%p %u %p %u %u %p %p\n", pwcNoun
, cwcNoun
,
159 pwcModifier
, cwcModifier
, ulAttachmentType
, pwcPhrase
, pcwcPhrase
);
163 static HRESULT WINAPI
wb_GetLicenseToUse( IWordBreaker
*iface
, const WCHAR
**ppwcsLicense
)
165 FIXME("%p\n", ppwcsLicense
);
166 *ppwcsLicense
= NULL
;
170 static const IWordBreakerVtbl wordbreaker_vtbl
=
181 HRESULT WINAPI
wb_Constructor(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
*ppvObject
)
183 wordbreaker_impl
*This
;
186 TRACE("%p %s %p\n", pUnkOuter
, debugstr_guid(riid
), ppvObject
);
188 This
= HeapAlloc(GetProcessHeap(), 0, sizeof *This
);
190 return E_OUTOFMEMORY
;
193 This
->lpVtbl
= &wordbreaker_vtbl
;
195 wb
= (IWordBreaker
*) This
;
197 return IWordBreaker_QueryInterface(wb
, riid
, ppvObject
);