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

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

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

~ [ 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.