~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/infosoft/wordbreaker.c

Version: ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  *    Word splitter Implementation
  3  *
  4  * Copyright 2006 Mike McCormack
  5  *
  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.
 10  *
 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.
 15  *
 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
 19  */
 20 
 21 #define COBJMACROS
 22 
 23 #include "config.h"
 24 
 25 #include <stdarg.h>
 26 
 27 #include "windef.h"
 28 #include "winbase.h"
 29 #include "winuser.h"
 30 #include "ole2.h"
 31 #include "indexsrv.h"
 32 #include "wine/unicode.h"
 33 #include "wine/debug.h"
 34 
 35 WINE_DEFAULT_DEBUG_CHANNEL(infosoft);
 36 
 37 typedef struct tag_wordbreaker_impl
 38 {
 39     IWordBreaker IWordBreaker_iface;
 40     LONG ref;
 41 } wordbreaker_impl;
 42 
 43 static inline wordbreaker_impl *impl_from_IWordBreaker(IWordBreaker *iface)
 44 {
 45     return CONTAINING_RECORD(iface, wordbreaker_impl, IWordBreaker_iface);
 46 }
 47 
 48 static HRESULT WINAPI wb_QueryInterface( IWordBreaker *iface,
 49         REFIID riid, LPVOID *ppvObj)
 50 {
 51     wordbreaker_impl *This = impl_from_IWordBreaker(iface);
 52 
 53     TRACE("(%p)->(%s)\n",This,debugstr_guid(riid));
 54 
 55     *ppvObj = NULL;
 56 
 57     if (IsEqualIID(riid, &IID_IUnknown) ||
 58         IsEqualIID(riid, &IID_IWordBreaker))
 59     {
 60         *ppvObj = This;
 61         return S_OK;
 62     }
 63 
 64     TRACE("-- E_NOINTERFACE\n");
 65     return E_NOINTERFACE;
 66 }
 67 
 68 static ULONG WINAPI wb_AddRef( IWordBreaker *iface )
 69 {
 70     wordbreaker_impl *This = impl_from_IWordBreaker(iface);
 71     return InterlockedIncrement(&This->ref);
 72 }
 73 
 74 static ULONG WINAPI wb_Release(IWordBreaker *iface)
 75 {
 76     wordbreaker_impl *This = impl_from_IWordBreaker(iface);
 77     LONG refcount;
 78 
 79     refcount = InterlockedDecrement(&This->ref);
 80     if (!refcount)
 81         HeapFree(GetProcessHeap(), 0, This);
 82 
 83     return refcount;
 84 }
 85 
 86 static HRESULT WINAPI wb_Init( IWordBreaker *iface,
 87         BOOL fQuery, ULONG ulMaxTokenSize, BOOL *pfLicense )
 88 {
 89     TRACE("%d %u\n", fQuery, ulMaxTokenSize);
 90     *pfLicense = FALSE;
 91     return S_OK;
 92 }
 93 
 94 static HRESULT call_sink( IWordSink *pWordSink, TEXT_SOURCE *ts, UINT len )
 95 {
 96     HRESULT r;
 97 
 98     if (!len)
 99         return S_OK;
100 
101     TRACE("%d %s\n", len, debugstr_w(&ts->awcBuffer[ts->iCur]));
102 
103     r = IWordSink_PutWord( pWordSink, len, &ts->awcBuffer[ts->iCur], len, ts->iCur );
104     ts->iCur += len;
105 
106     return r;
107 }
108 
109 static HRESULT WINAPI wb_BreakText( IWordBreaker *iface,
110          TEXT_SOURCE *ts, IWordSink *pWordSink, IPhraseSink *pPhraseSink)
111 {
112     UINT len, state = 0;
113     WCHAR ch;
114 
115     TRACE("%p %p %p\n", ts, pWordSink, pPhraseSink);
116 
117     if (pPhraseSink)
118         FIXME("IPhraseSink won't be called\n");
119 
120     do
121     {
122         len = 0;
123         while ((ts->iCur + len) < ts->iEnd)
124         {
125             ch = ts->awcBuffer[ts->iCur + len];
126 
127             switch (state)
128             {
129             case 0: /* skip spaces and punctuation */
130 
131                 if (!ch || ispunctW(ch) || isspaceW(ch))
132                     ts->iCur ++;
133                 else
134                     state = 1;
135                 break;
136 
137             case 1: /* find the end of the word */
138 
139                 if (ch && !ispunctW(ch) && !isspaceW(ch))
140                     len++;
141                 else
142                 {
143                     call_sink( pWordSink, ts, len );
144                     len = 0;
145                     state = 0;
146                 }
147                 break;
148 
149             }
150         }
151         call_sink( pWordSink, ts, len );
152 
153     } while (S_OK == ts->pfnFillTextBuffer( ts ));
154 
155     return S_OK;
156 }
157 
158 static HRESULT WINAPI wb_ComposePhrase( IWordBreaker *iface,
159          const WCHAR *pwcNoun, ULONG cwcNoun,
160          const WCHAR *pwcModifier, ULONG cwcModifier,
161          ULONG ulAttachmentType, WCHAR *pwcPhrase, ULONG *pcwcPhrase)
162 {
163     FIXME("%p %u %p %u %u %p %p\n", pwcNoun, cwcNoun,
164           pwcModifier, cwcModifier, ulAttachmentType, pwcPhrase, pcwcPhrase);
165     return S_OK;
166 }
167 
168 static HRESULT WINAPI wb_GetLicenseToUse( IWordBreaker *iface, const WCHAR **ppwcsLicense )
169 {
170     FIXME("%p\n", ppwcsLicense);
171     *ppwcsLicense = NULL;
172     return S_OK;
173 }
174 
175 static const IWordBreakerVtbl wordbreaker_vtbl =
176 {
177     wb_QueryInterface,
178     wb_AddRef,
179     wb_Release,
180     wb_Init,
181     wb_BreakText,
182     wb_ComposePhrase,
183     wb_GetLicenseToUse,
184 };
185 
186 DECLSPEC_HIDDEN HRESULT WINAPI wb_Constructor(IUnknown* pUnkOuter, REFIID riid, LPVOID *ppvObject)
187 {
188     wordbreaker_impl *This;
189     IWordBreaker *wb;
190 
191     TRACE("%p %s %p\n", pUnkOuter, debugstr_guid(riid), ppvObject);
192 
193     This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
194     if (!This)
195         return E_OUTOFMEMORY;
196 
197     This->ref = 1;
198     This->IWordBreaker_iface.lpVtbl = &wordbreaker_vtbl;
199 
200     wb = &This->IWordBreaker_iface;
201 
202     return IWordBreaker_QueryInterface(wb, riid, ppvObject);
203 }
204 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.