Develop and Download Open Source Software

Browse CVS Repository

Contents of /gikonavigoeson/gikonavi/AbonUnit.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.17.2.3 - (show annotations) (download) (as text)
Fri Oct 8 05:44:48 2004 UTC (19 years, 6 months ago) by yoffy
Branch: stable
Changes since 1.17.2.2: +46 -42 lines
File MIME type: text/x-pascal
b49 、ヒ・゙。シ・ク。」

1 unit AbonUnit;
2
3 interface
4 uses
5 Windows,Messages, ShellAPI, SysUtils, Classes,StdCtrls,StrUtils;
6
7 type
8 TIndiviAbon = record
9 Res: Integer;
10 option: Integer; // 0:騾乗? 1:騾壼クク縺ゅ⊂繝シ繧?/span>
11 end;
12
13 TAbon = class(TObject)
14 private
15 { Private 螳」險? }
16 Froot : String;
17 Flistpath : String;
18 FNGwordpath : String;
19 Ftokens : array of array of string;
20 FAbonRes : array of TIndiviAbon;
21 FAbonString : String;
22 // FCutoffNum : Integer; //縺薙?謨ー莉・荳企?」邯壹☆繧句酔縺倩恭蟄励rNG繝ッ繝シ繝峨→縺吶k
23 FDeleterlo : Boolean; //&rlo;繧貞炎繧九° //霑ス蜉?&lro;繧ょ炎繧?/span>
24 FReplaceul :Boolean ; //<ul>繧ソ繧ー繧?lt;br>繧ソ繧ー縺ォ鄂ョ謠帙☆繧九°
25 FReverse : Boolean ; //NG繝ッ繝シ繝峨〒縺ョ縺ゅ⊂縲懊s縺ョ邨先棡繧貞渚霆「縺輔○繧九°
26 FAbonPopupRes : Boolean; //繝ャ繧ケ繝昴ャ繝励い繝??縺ョ譎ゅ↓縺ゅ⊂繝シ繧薙☆繧九°
27 FCreateNGwordFile : Boolean; //謖?ョ壹&繧後◆path縺ォNG繝ッ繝シ繝液xt縺檎┌縺九▲縺溘→縺阪↓閾ェ蜍慕噪縺ォ逕滓?縺吶k縺?/span>
28 FNGwordFileIndex : Integer; //迴セ蝨ィ隱ュ縺ソ霎シ繧薙〒繧起G繝ッ繝シ繝峨′list縺ョ菴戊。檎岼縺?/span>
29 FNGwordname : String; //迴セ蝨ィ隱ュ縺ソ霎シ繧薙〒繧起G繝ッ繝シ繝峨?陦ィ遉コ蜷?/span>
30 FIndividualFileName : String; //蛟句挨縺ゅ⊂縲懊s縺ョ繝輔ぃ繧、繝ォ蜷?/span>
31 FReturnNGwordLineNum : Boolean; //NG繝ッ繝シ繝峨?陦梧焚繧定ソ斐☆縲?/span>
32 FSetNGResAnchor : Boolean; //NG縺ォ隧イ蠖薙@縺溘→縺阪↓譛ャ譁?↓縺昴?繝ャ繧ケ縺ク縺ョ繝ャ繧ケ繧「繝ウ繧ォ繝シ繧偵▽縺代k縺九←縺?°
33 FDeleteSyria: Boolean; //繧キ繝ェ繧「隱槭ヶ繝ゥ繧ッ繝ゥ蟇セ遲厄シ?amp;#1792~&#1871??/span>
34 procedure SetTokens(index: integer ; argline:String);
35 function Getlistpath() : String;
36 procedure Setlistpath(const Value : String);
37 function LoadListFile(path :String;listStringList : TStringList) : Boolean;
38 function ReadNGwordslist(line : Integer) : Boolean;
39 function LoadFromSetResNumFile(SetResNumFile : String) : Boolean;
40 public
41 { Public 螳」險? }
42 constructor Create; // 繧ウ繝ウ繧ケ繝医Λ繧ッ繧ソ
43 destructor Destroy; override; // 繝?せ繝医Λ繧ッ繧ソ
44 property Deleterlo: Boolean read FDeleterlo write FDeleterlo default false;
45 property Replaceul: Boolean read FReplaceul write FReplaceul default false;
46 property Reverse: Boolean read FReverse write FReverse default false;
47 property CreateNGwordFile: Boolean read FCreateNGwordFile write FCreateNGwordFile;
48 property AbonString : String read FAbonString write FAbonString;
49 property AbonPopupRes : Boolean read FAbonPopupRes write FAbonPopupRes default false;
50 property listpath : String read Getlistpath write Setlistpath;
51 property NGwordFileIndex : Integer read FNGwordFileIndex write FNGwordFileIndex default 0;
52 property NGwordname : String read FNGwordname write FNGwordname;
53 property ReturnNGwordLineNum : Boolean read FReturnNGwordLineNum write FReturnNGwordLineNum default false;
54 property SetNGResAnchor : Boolean read FSetNGResAnchor write FSetNGResAnchor default false;
55 property DeleteSyria : Boolean read FDeleteSyria write FDeleteSyria default false;
56 procedure Setroot(root :String);
57 function Getroot() : String;
58
59 function Getfullpath(argpath : String) : String;
60 procedure SetNGwordpath(path :String);
61 function GetNGwordpath() : String;
62 function LoadFromNGwordFile(path :String) : Boolean;
63 function ReLoadFromNGwordFile() : Boolean;
64 procedure LoadFromStringList( bufstl : TStringList );
65 function CheckAbonPopupRes(line : String) :Boolean;
66 function FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean;//1繝ゥ繧、繝ウ縺壹▽逕ィ縲?/span>
67 function FindNGwordsEx(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean;//1繝ゥ繧、繝ウ縺壹▽逕ィ縲?/span>
68 //縺ゅ⊂縲懊s蜃ヲ逅?NG繝ッ繝シ繝峨〒縺ョ繝輔ぅ繝ォ繧ソ繝ェ繝ウ繧ー)
69 procedure Execute(var ThreadStrings : TStringList); overload;
70 procedure Execute(var ThreadStrings : TStringList; NGwords : TStringList); overload;
71 procedure Execute(var ThreadStrings : TStringList; NGwords : TStrings); overload;
72 procedure Execute(var ResString : String; ResNumber : Integer); overload; //荳サ縺ォplugin縺九i縺ョDat To HTML 逕ィ
73 procedure ExecuteEx(var ThreadStrings : TStringList); overload;
74 procedure ExecuteEx(var ThreadStrings : TStringList; NGwords : TStringList); overload;
75 procedure ExecuteEx(var ThreadStrings : TStringList; NGwords : TStrings); overload;
76 procedure ExecuteEx(var ResString : String; ResNumber : Integer); overload; //荳サ縺ォplugin縺九i縺ョDat To HTML 逕ィ
77
78 //蛟句挨縺ゅ⊂縲懊s縺励g繧?/span>
79 procedure IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String); overload;
80 procedure IndividualAbon(var ResString : String; SetResNumFile : String; ResNumber : Integer); overload;
81 procedure AddIndividualAbon( ResNum : Integer ; option : Integer);
82 procedure DeleteIndividualAbon( ResNum : Integer);
83 function GetAbonResCount() : Integer;
84 function GetAbonResString(Num : Integer) : String;
85 function CheckIndividualAbonList(ResNum : Integer) : Boolean;
86
87 procedure EditNGwords(); //NGword.txt繧帝幕縺上??/span>
88 function ShowAllTokens() : String; //繝?ヰ繝?げ逕ィ
89 //--
90 procedure GoHome();//List縺ョ?題。檎岼繧定ェュ繧?
91 function GoForward() : Boolean; //List縺ョ荳?縺、谺。縺ョNG繝ッ繝シ繝峨ヵ繧。繧、繝ォ繧定ェュ縺ソ霎シ繧?
92 function GoBack() : Boolean; //List縺ョ荳?縺、蜑阪?NG繝ッ繝シ繝峨ヵ繧。繧、繝ォ繧定ェュ縺ソ霎シ繧?
93 //--
94 function TreatSyria(AString: string): string;
95 end;
96 var
97 Abon1 :TAbon;
98 const
99 NGwordListFileName : String = 'NGwords.list';
100
101 implementation
102
103 uses MojuUtils;
104
105 constructor TAbon.Create;
106 begin
107 // 蛻晄悄蛹?/span>
108 FAbonString := '&nbsp;<>&nbsp;<>&nbsp;<>&nbsp;&nbsp;<><>';
109 FCreateNGwordFile := true;
110 SetLength(FAbonRes,1);
111 FAbonRes[0].Res := 0;
112 FAbonRes[0].option := -1;
113
114 end;
115
116 destructor TAbon.Destroy;
117 begin
118 inherited;
119 end;
120 //root縺ッExe\config\NGwords繝輔か繝ォ繝?
121 procedure TAbon.Setroot(root :String);
122 var
123 bufStringList : TStringList;
124 begin
125 bufStringList := TStringList.Create;
126 try
127 if not DirectoryExists(root) then begin
128 CreateDir(root);
129 end;
130 if root[Length(root)] <> '\' then begin
131 root := root + '\';
132 end;
133 Flistpath := root + NGwordListFileName;
134 LoadListFile(Flistpath, bufStringList);
135 finally
136 bufStringList.Free;
137 end;
138 Froot := root;
139 end;
140 function TAbon.Getroot() : String;
141 begin
142 Result := Froot;
143 end;
144 //NGwordpath縺ッNGword.txt縺ョ繝輔Ν繝代せ
145 procedure TAbon.SetNGwordpath(path :String);
146 begin
147 FNGwordpath := Getfullpath(path);
148 LoadFromNGwordFile(FNGwordpath);
149 end;
150 function TAbon.GetNGwordpath() : String;
151 begin
152 Result := FNGwordpath;
153 end;
154 //繝輔Ν繝代せ縺ァ縺ェ縺代l縺ー繝輔Ν繝代せ縺ォ縺励※霑斐☆縲?/span>
155 function TAbon.Getfullpath(argpath : String) : String;
156 begin
157 if AnsiPos(':\',argpath) <> 2 then begin //繝峨Λ繧、繝悶°繧峨?繝輔Ν繝代せ縺檎┌縺代l縺ー
158 if Getroot() = '' then begin
159 Result := ''; //root繝代せ縺瑚ィュ螳壹&繧後※縺ェ縺?°遨コ縺ォ縺吶k
160 end else begin
161 if (Froot[Length(Froot)] = '\') and (argpath[1] = '\') then begin //蜈磯?ュ縺ョ\繧貞炎髯、
162 Delete(argpath,1,1);
163 end;
164 Insert( Getroot(), argpath , 1);//root繝代せ繧呈諺蜈・
165 Result := argpath;
166 end;
167 end else begin
168 Result := argpath;
169 end;
170
171 end;
172 //NGword繝輔ぃ繧、繝ォ縺ョ隱ュ縺ソ霎シ縺ソ
173 function TAbon.LoadFromNGwordFile(path :String) : boolean;
174 var
175 bufstl : TStringList;
176 begin
177 path := Getfullpath(path);
178 if path = '' then begin
179 Result := false;
180 end else begin
181 bufstl := TStringList.Create;
182 try
183 try
184 bufstl.LoadFromFile(path);
185 LoadFromStringList( bufstl );
186 Result := true;
187 except
188 if CreateNGwordFile = true then begin
189 bufstl.SaveToFile(path);
190 end;
191 Result := false;
192 end;
193 finally
194 bufstl.Free;
195 end;
196 end;
197
198 end;
199 //NGword繝ェ繧ケ繝郁ェュ縺ソ霎シ縺ソ
200 procedure TAbon.LoadFromStringList( bufstl : TStringList );
201 var
202 i : integer;
203 begin
204 try
205 for i := bufstl.Count -1 downto 0 do begin
206 if bufstl.Strings[i] = '' then begin
207 bufstl.Delete(i);
208 end;
209 end;
210 SetLength(Ftokens,bufstl.Count);
211 for i := 0 to bufstl.Count -1 do begin
212 SetTokens(i , bufstl.Strings[i]);
213 end;
214
215 except
216 Exit;
217 end;
218 end;
219 //NGwordpath縺梧里縺ォ險ュ螳壹&繧後※縺?k縺ィ縺阪?繝ェ繝ュ繝シ繝臥畑髢「謨ー
220 function TAbon.ReLoadFromNGwordFile() : boolean;
221 begin
222 if GetNGwordpath() ='' then begin
223 Result := false;
224 end else begin
225 Result := LoadFromNGwordFile( GetNGwordpath() );
226 end;
227 end;
228 function TAbon.Getlistpath() : String;
229 begin
230 Result := Flistpath;
231 end;
232 procedure TAbon.Setlistpath(const Value : String);
233 begin
234 Flistpath := Getfullpath(Value);
235 end;
236 //荳?陦後?荳ュ縺ョ繝医?繧ッ繝ウ繧貞?繧雁?縺代※繧サ繝?ヨ
237 procedure TAbon.SetTokens(index: integer ; argline : String);
238 var
239 ret : Integer;
240 bufstl : TStringList;
241 i : Integer;
242 pos : Integer;
243 buftoken : String;
244 begin
245 pos := 0;
246 bufstl := TStringList.Create;
247 try
248 if Length(argline) > 0 then begin
249 pos := AnsiPos(#9,argline);
250 while pos <> 0 DO begin
251 buftoken := Copy(argline,1,pos-1);
252 Delete(argline,1,pos);
253 if Length(buftoken) > 0 then begin
254 bufstl.Append(buftoken);
255 end else if ( bufstl.Count = 0 ) then begin
256 bufstl.Append('');
257 end;
258 pos := AnsiPos(#9,argline);
259 end;
260 if Length(argline) > 0 then begin
261 bufstl.Append(argline);
262 end;
263 ret := bufstl.Count;
264 SetLength(Ftokens[index],ret);
265 for i := 0 to bufstl.Count - 1 do begin
266 Ftokens[index][i] := bufstl.Strings[i];
267 end;
268 end;
269 finally
270 bufstl.Free;
271 end;
272
273 end;
274 //Debug逕ィ縺。繧?s縺ィNG繝ッ繝シ繝峨r諡セ縺医※縺?k縺?/span>
275 function TAbon.ShowAllTokens() : String;
276 var
277 i : Integer;
278 j : Integer;
279 ret : String;
280 begin
281 for i := 0 to High(Ftokens) do begin
282 for j := 0 to High(Ftokens[i]) do begin
283 ret := ret + Ftokens[i][j];
284 end;
285 end;
286 Result := ret;
287
288
289
290 end;
291 //NG繝ッ繝シ繝峨′蜷ォ縺セ繧後※縺?◆繧液rue繧定ソ斐@縲√◎縺ョNG繝ッ繝シ繝峨?陦梧焚繧誰GwordsLineNum縺ォ蜈・繧後※霑斐☆縲?/span>
292 //繧ゅ@繧る?乗?縺ゅ⊂縲懊s縺ォ縺吶k縺ェ繧迂nbisible繧稚rue縺ォ縺励※霑斐☆
293 function TAbon.FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean; //1繝ゥ繧、繝ウ縺壹▽逕ィ縲?/span>
294 var
295 lines : Integer;
296 cells : Integer;
297 hit : Boolean;
298 bufline : String;
299 start : Integer;
300 begin
301 hit := false;
302 if AnsiPos(FAbonString,line) <> 1 then begin
303 for lines := 0 to High(Ftokens) do begin
304 hit := true;
305 bufline := line;
306 if Ftokens[lines][0] <> '' then begin
307 Invisible := false;
308 start := 0;
309 end else begin
310 Invisible := true;
311 start := 1;
312 end;
313
314 for cells := start to High(Ftokens[lines]) do begin
315 if AnsiPos(Ftokens[lines][cells],bufline) = 0 then begin
316 hit := false;
317 break;
318 end else begin
319 Delete(bufline,AnsiPos(Ftokens[lines][cells],bufline),Length(Ftokens[lines][cells]));
320 end;
321 end;
322 if hit = true then begin
323 NGwordsLineNum := lines + 1;
324 break;
325 end;
326 end;
327 end;
328 Result := hit;
329 end;
330 //NG繝ッ繝シ繝峨′蜷ォ縺セ繧後※縺?◆繧液rue繧定ソ斐@縲√◎縺ョNG繝ッ繝シ繝峨?陦梧焚繧誰GwordsLineNum縺ォ蜈・繧後※霑斐☆縲?/span>
331 //繧ゅ@繧る?乗?縺ゅ⊂縲懊s縺ォ縺吶k縺ェ繧迂nbisible繧稚rue縺ォ縺励※霑斐☆
332 //蜊願ァ貞?隗堤┌隕?/span>
333 function TAbon.FindNGwordsEx(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean;//1繝ゥ繧、繝ウ縺壹▽逕ィ縲?/span>
334 var
335 lines : Integer;
336 cells : Integer;
337 hit : Boolean;
338 bufline : String;
339 start : Integer;
340 begin
341 hit := false;
342 if AnsiPos(FAbonString,line) <> 1 then begin
343 for lines := 0 to High(Ftokens) do begin
344 hit := true;
345 bufline := line;
346 if Ftokens[lines][0] <> '' then begin
347 Invisible := false;
348 start := 0;
349 end else begin
350 Invisible := true;
351 start := 1;
352 end;
353
354 for cells := start to High(Ftokens[lines]) do begin
355 if AnsiPos(Ftokens[lines][cells],bufline) = 0 then begin
356 hit := false;
357 break;
358 end else begin
359 Delete(bufline, AnsiPos(Ftokens[lines][cells],bufline),Length(Ftokens[lines][cells]));
360 end;
361 end;
362 if hit = true then begin
363 NGwordsLineNum := lines + 1;
364 break;
365 end;
366 end;
367 end;
368 Result := hit;
369 end;
370 //譛ォ蟆セ縺ョ繝悶?繝ォ蛟、縺ッtrue縺?縺ィ縲¨G繝ッ繝シ繝峨r蜷ォ繧?繧ゅ?縺?縺代r霑斐☆縲?/span>
371 procedure TAbon.Execute(var ThreadStrings : TStringList);
372 var
373 i : Integer;
374 NGwordsLine : Integer;
375 bufline : String;
376 invisi : Boolean;
377 begin
378 for i:=0 to ThreadStrings.Count - 1 do begin
379 NGwordsLine := 0;
380 if FindNGwords(ThreadStrings.Strings[i], NGwordsLine ,invisi) <> Reverse then begin
381 if invisi = true then begin
382 ThreadStrings.Strings[i] := '';
383 end else begin
384 if not ReturnNGwordLineNum and not SetNGResAnchor then begin
385 ThreadStrings.Strings[i] := FAbonString;
386 end else if not ReturnNGwordLineNum then begin
387 ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<>&gt;%d<><>',[(i+1)]);
388 end else if not SetNGResAnchor then begin
389 ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 陦檎岼縺ョNG繝ッ繝シ繝峨′蜷ォ縺セ繧後※縺?∪縺吶??lt;/B><><>',[NGwordsLine]);
390 end else begin
391 ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 陦檎岼縺ョNG繝ッ繝シ繝峨′蜷ォ縺セ繧後※縺?∪縺吶??lt;/B>&gt;%d <><>',[NGwordsLine,(i+1)]);
392 end;
393 end;
394 end else begin
395 bufline := ThreadStrings.Strings[i];
396 if Deleterlo = true then begin
397 bufline := CustomStringReplace(bufline,'&rlo;','');
398 bufline := CustomStringReplace(bufline,'&lro;','');
399 end;
400 if Replaceul = true then begin
401 bufline := CustomStringReplace( bufline,'<ul>','<br>' );
402 bufline := CustomStringReplace( bufline,'</ul>','<br>' );
403 end;
404 if DeleteSyria = true then
405 bufline := TreatSyria(bufline);
406 ThreadStrings.Strings[i] := bufline;
407 end;
408 end;
409 end;
410 procedure TAbon.Execute(var ResString : String; ResNumber : Integer);
411 var
412 NGwordsLine : Integer;
413 bufline : String;
414 invisi : Boolean;
415 begin
416 NGwordsLine := 0;
417 if FindNGwords(ResString, NGwordsLine ,invisi) <> Reverse then begin
418 if invisi = true then begin
419 ResString := '';
420 end else begin
421 if not ReturnNGwordLineNum and not SetNGResAnchor then begin
422 ResString := FAbonString;
423 end else if not ReturnNGwordLineNum then begin
424 ResString := Format('&nbsp;<>&nbsp;<>&nbsp;<>&gt;%d<><>',[(ResNumber)]);
425 end else if not SetNGResAnchor then begin
426 ResString := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 陦檎岼縺ョNG繝ッ繝シ繝峨′蜷ォ縺セ繧後※縺?∪縺吶??lt;/B><><>',[NGwordsLine]);
427 end else begin
428 ResString := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 陦檎岼縺ョNG繝ッ繝シ繝峨′蜷ォ縺セ繧後※縺?∪縺吶??lt;/B>&gt;%d <><>',[NGwordsLine,(ResNumber)]);
429 end;
430 end;
431 end else begin
432 bufline := ResString;
433 if Deleterlo = true then begin
434 bufline := CustomStringReplace( bufline,'&rlo;','' );
435 bufline := CustomStringReplace( bufline,'&lro;','' );
436 end;
437 if Replaceul = true then begin
438 bufline := CustomStringReplace( bufline,'<ul>','<br>' );
439 bufline := CustomStringReplace( bufline,'</ul>','<br>' );
440 end;
441 if DeleteSyria = true then
442 bufline := TreatSyria(bufline);
443 ResString := bufline;
444 end;
445 end;
446
447 procedure TAbon.Execute(var ThreadStrings : TStringList; NGwords : TStringList);
448 var
449 i : Integer;
450 begin
451 SetLength(Ftokens,NGwords.Count);
452 for i := 0 to NGwords.Count -1 do begin
453 SetTokens(i , NGwords.Strings[i]);
454 end;
455 Execute(ThreadStrings);
456
457 end;
458 procedure TAbon.Execute(var ThreadStrings : TStringList; NGwords : TStrings);
459 var
460 i : Integer;
461 buf : TStringList;
462 begin
463 buf := TStringList.Create;
464 buf.AddStrings(NGwords);
465 SetLength(Ftokens,buf.Count);
466 for i := 0 to buf.Count -1 do begin
467 SetTokens(i , buf.Strings[i]);
468 end;
469 Execute(ThreadStrings);
470 buf.Free;
471 end;
472
473 //譛ォ蟆セ縺ョ繝悶?繝ォ蛟、縺ッtrue縺?縺ィ縲¨G繝ッ繝シ繝峨r蜷ォ繧?繧ゅ?縺?縺代r霑斐☆縲?/span>
474 procedure TAbon.ExecuteEx(var ThreadStrings : TStringList);
475 var
476 i : Integer;
477 NGwordsLine : Integer;
478 bufline : String;
479 invisi : Boolean;
480 begin
481 for i:=0 to ThreadStrings.Count - 1 do begin
482 NGwordsLine := 0;
483 if FindNGwordsEx(ThreadStrings.Strings[i], NGwordsLine ,invisi) <> Reverse then begin
484 if invisi = true then begin
485 ThreadStrings.Strings[i] := '';
486 end else begin
487 if not ReturnNGwordLineNum and not SetNGResAnchor then begin
488 ThreadStrings.Strings[i] := FAbonString;
489 end else if not ReturnNGwordLineNum then begin
490 ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<>&gt;%d<><>',[(i+1)]);
491 end else if not SetNGResAnchor then begin
492 ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 陦檎岼縺ョNG繝ッ繝シ繝峨′蜷ォ縺セ繧後※縺?∪縺吶??lt;/B><><>',[NGwordsLine]);
493 end else begin
494 ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 陦檎岼縺ョNG繝ッ繝シ繝峨′蜷ォ縺セ繧後※縺?∪縺吶??lt;/B>&gt;%d <><>',[NGwordsLine,(i+1)]);
495 end;
496 end;
497 end else begin
498 bufline := ThreadStrings.Strings[i];
499 if Deleterlo = true then begin
500 bufline := CustomStringReplace(bufline,'&rlo;','');
501 bufline := CustomStringReplace(bufline,'&lro;','');
502 end;
503 if Replaceul = true then begin
504 bufline := CustomStringReplace( bufline,'<ul>','<br>' );
505 bufline := CustomStringReplace( bufline,'</ul>','<br>' );
506 end;
507 if DeleteSyria = true then
508 bufline := TreatSyria(bufline);
509 ThreadStrings.Strings[i] := bufline;
510 end;
511 end;
512 end;
513 procedure TAbon.ExecuteEx(var ResString : String; ResNumber : Integer);
514 var
515 NGwordsLine : Integer;
516 bufline : String;
517 invisi : Boolean;
518 begin
519 NGwordsLine := 0;
520 if FindNGwordsEx(ResString, NGwordsLine ,invisi) <> Reverse then begin
521 if invisi = true then begin
522 ResString := '';
523 end else begin
524 if not ReturnNGwordLineNum and not SetNGResAnchor then begin
525 ResString := FAbonString;
526 end else if not ReturnNGwordLineNum then begin
527 ResString := Format('&nbsp;<>&nbsp;<>&nbsp;<>&gt;%d<><>',[(ResNumber)]);
528 end else if not SetNGResAnchor then begin
529 ResString := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 陦檎岼縺ョNG繝ッ繝シ繝峨′蜷ォ縺セ繧後※縺?∪縺吶??lt;/B><><>',[NGwordsLine]);
530 end else begin
531 ResString := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 陦檎岼縺ョNG繝ッ繝シ繝峨′蜷ォ縺セ繧後※縺?∪縺吶??lt;/B>&gt;%d <><>',[NGwordsLine,(ResNumber)]);
532 end;
533 end;
534 end else begin
535 bufline := ResString;
536 if Deleterlo = true then begin
537 bufline := CustomStringReplace( bufline,'&rlo;','' );
538 bufline := CustomStringReplace( bufline,'&lro;','' );
539 end;
540 if Replaceul = true then begin
541 bufline := CustomStringReplace( bufline,'<ul>','<br>' );
542 bufline := CustomStringReplace( bufline,'</ul>','<br>' );
543 end;
544 if DeleteSyria = true then
545 bufline := TreatSyria(bufline);
546 ResString := bufline;
547 end;
548 end;
549
550 procedure TAbon.ExecuteEx(var ThreadStrings : TStringList; NGwords : TStringList);
551 var
552 i : Integer;
553 begin
554 SetLength(Ftokens,NGwords.Count);
555 for i := 0 to NGwords.Count -1 do begin
556 SetTokens(i , NGwords.Strings[i]);
557 end;
558 ExecuteEx(ThreadStrings);
559
560 end;
561 procedure TAbon.ExecuteEx(var ThreadStrings : TStringList; NGwords : TStrings);
562 var
563 i : Integer;
564 buf : TStringList;
565 begin
566 buf := TStringList.Create;
567 buf.AddStrings(NGwords);
568 SetLength(Ftokens,buf.Count);
569 for i := 0 to buf.Count -1 do begin
570 SetTokens(i , buf.Strings[i]);
571 end;
572 ExecuteEx(ThreadStrings);
573 buf.Free;
574 end;
575
576 //****************************************************************************//
577 //迴セ蝨ィ繧サ繝?ヨ縺輔l縺ヲ縺?kNGword.txt繧帝幕縺?/span>
578 procedure TAbon.EditNGwords();
579 begin
580 ShellExecute(0 ,nil,PChar(FNGwordpath),nil,nil,SW_SHOW);
581 end;
582 //繝昴ャ繝励い繝??逕ィ蛻、螳夐未謨ー
583 function TAbon.CheckAbonPopupRes(line : String) :Boolean;
584 var
585 i: Integer;
586 v: boolean;
587 begin
588 if AbonPopupRes = true then begin
589 Result := FindNGwords(line, i ,v);
590 end else begin
591 Result := false;
592 end;
593 end;
594 //隍?焚縺ョNG繝ッ繝シ繝峨ユ繧ュ繧ケ繝医r隱ュ縺ソ霎シ繧?==============================================
595 //List繝輔ぃ繧、繝ォ繧定ェュ縺ソ霎シ繧?
596 function TAbon.LoadListFile(path :String; listStringList : TStringList) : Boolean;
597 begin
598 try
599 listStringList.LoadFromFile(path);
600 Result := true;
601 except
602 listStringList.Append('荳?闊ャ=NGword.txt');
603 listStringList.SaveToFile(path);
604 Result := false;
605 end;
606 end;
607 //List縺ョ荳?縺、谺。縺ョNG繝ッ繝シ繝峨ヵ繧。繧、繝ォ繧定ェュ縺ソ霎シ繧?
608 function TAbon.GoForward() : Boolean;
609 begin
610 FNGwordFileIndex := FNGwordFileIndex + 1;
611 Result := ReadNGwordslist(FNGwordFileIndex);
612 end;
613 //List縺ョ荳?縺、蜑阪?NG繝ッ繝シ繝峨ヵ繧。繧、繝ォ繧定ェュ縺ソ霎シ繧?
614 function TAbon.GoBack() : Boolean;
615 begin
616 FNGwordFileIndex := FNGwordFileIndex -1;
617 Result := ReadNGwordslist(FNGwordFileIndex);
618 end;
619 //List縺ョ?題。檎岼繧定ェュ繧?
620 procedure TAbon.GoHome();
621 begin
622 FNGwordFileIndex := 0;
623 ReadNGwordslist(FNGwordFileIndex);
624 end;
625 //List縺ョline陦檎岼繧定ェュ繧?
626 function TAbon.ReadNGwordslist(line : Integer) : Boolean;
627 var
628 liststl : TStringList;
629 linebuf : String;
630 begin
631 liststl := TStringList.Create;
632 try
633 if LoadListFile(Flistpath,liststl) = true then begin
634 if line < 0 then begin
635 line := liststl.Count - 1;
636 FNGwordFileIndex := liststl.Count - 1;
637 end else if line > liststl.Count - 1 then begin
638 line := 0;
639 FNGwordFileIndex := 0;
640 end;
641 linebuf := liststl.Strings[line];
642 FNGwordname := Copy(linebuf,1,AnsiPos('=',linebuf)-1);
643 Delete(linebuf,1,AnsiPos('=',linebuf));
644 SetNGwordpath(linebuf);
645 Result := true;
646 end else begin
647 Result := false;
648 end
649 finally
650 liststl.Free;
651 end;
652
653 end;
654 //隍?焚縺ョNG繝ッ繝シ繝峨ユ繧ュ繧ケ繝医r隱ュ縺ソ霎シ繧?=====縺薙%縺セ縺ァ=================================
655 //蛟句挨縺ゅ⊂縲懊s螳溯。碁未謨ー
656 procedure TAbon.IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String);
657 var
658 i : Integer;
659 begin
660 if FileExists(SetResNumFile) = true then begin
661 if LoadFromSetResNumFile(SetResNumFile) = true then begin
662 for i := 0 to High(FAbonRes) do begin
663 if (FAbonRes[i].Res <= ThreadStrings.Count) and (FAbonRes[i].Res > 0) then begin
664 if FAbonRes[i].option = 0 then begin
665 ThreadStrings.Strings[FAbonRes[i].Res-1] := '';
666 end else begin
667 ThreadStrings.Strings[FAbonRes[i].Res-1] := '縺ゅ⊂縲懊s<>縺ゅ⊂縲懊s<>縺ゅ⊂縲懊s<>縺ゅ⊂縲懊s<>';
668 end;
669 end;
670
671 end;
672 end;
673 end else begin
674 FIndividualFileName := SetResNumFile;
675 SetLength(FAbonRes,1);
676 FAbonRes[0].Res := 0;
677 FAbonRes[0].option := -1;
678 end;
679 end;
680 procedure TAbon.IndividualAbon(var ResString : String; SetResNumFile : String; ResNumber : Integer);
681 var
682 i : Integer;
683 begin
684 if FileExists(SetResNumFile) = true then begin
685 if LoadFromSetResNumFile(SetResNumFile) = true then begin
686 for i := 0 to High(FAbonRes) do begin
687 if FAbonRes[i].Res = ResNumber then begin
688 if FAbonRes[i].option = 0 then begin
689 ResString := '';
690 end else begin
691 ResString := '縺ゅ⊂縲懊s<>縺ゅ⊂縲懊s<>縺ゅ⊂縲懊s<>縺ゅ⊂縲懊s<>';
692 end;
693 Exit;
694 end;
695 end;
696 end;
697 end else begin
698 FIndividualFileName := SetResNumFile;
699 SetLength(FAbonRes,1);
700 FAbonRes[0].Res := 0;
701 FAbonRes[0].option := -1;
702 end;
703 end;
704
705 //蛟句挨縺ゅ⊂縲懊s繝輔ぃ繧、繝ォ隱ュ縺ソ霎シ縺ソ髢「謨ー
706 function TAbon.LoadFromSetResNumFile(SetResNumFile : String) : Boolean;
707 var
708 bufStringList : TStringList;
709 bufLine : String;
710 i : Integer;
711 begin
712 bufStringList := TStringList.Create;
713 try
714 try
715 bufStringList.LoadFromFile(SetResNumFile);
716 FIndividualFileName := SetResNumFile;
717 //遨コ陦悟炎髯、
718 for i := bufStringList.Count-1 downto 0 do begin
719 if bufStringList.Strings[i] = '' then begin
720 bufStringList.Delete(i);
721 end;
722 end;
723
724 //繝。繝「繝ェ遒コ菫?/span>
725 SetLength(FAbonRes,bufStringList.Count);
726 //莉」蜈・
727 for i :=0 to bufStringList.Count - 1 do begin
728 bufLine := Trim(bufStringList.Strings[i]);
729 FAbonRes[i].Res := StrToInt(Copy(bufLine,1,AnsiPos('-',bufLine)-1));
730 FAbonRes[i].option := StrToInt(Copy(bufLine,AnsiPos('-',bufLine)+1,1));
731 end;
732 except
733 Result := false;
734 Exit;
735 end;
736 finally
737 bufStringList.Free;
738 end;
739 Result := true;
740 end;
741 //蛟句挨縺ゅ⊂縲懊s繝輔ぃ繧、繝ォ縺ォ霑ス蜉?
742 procedure TAbon.AddIndividualAbon( ResNum : Integer ; option : Integer);
743 var
744 IndividualFile : TStringList;
745 linebuf : String;
746 i : Integer;
747 begin
748 IndividualFile := TStringList.Create;
749 if FAbonRes[0].Res <> 0 then begin
750 for i := 0 to High(FAbonRes) do begin
751 if FAbonRes[i].Res <> ResNum then begin
752 linebuf := IntToStr(FAbonRes[i].Res) + '-' + IntToStr(FabonRes[i].option);
753 IndividualFile.Append(linebuf);
754 end;
755 end;
756 end;
757 linebuf := IntToStr(ResNum) + '-' + IntToStr(option);
758 IndividualFile.Append(linebuf);
759 try
760 IndividualFile.SaveToFile(FIndividualFileName);
761 finally
762 IndividualFile.Free;
763 end;
764 end;
765 //蛟句挨縺ゅ⊂縲懊s繝輔ぃ繧、繝ォ縺九i蜑企勁
766 procedure TAbon.DeleteIndividualAbon( ResNum : Integer);
767 var
768 IndividualFile : TStringList;
769 linebuf : String;
770 i : Integer;
771 begin
772 IndividualFile := TStringList.Create;
773 if FAbonRes[0].Res <> 0 then begin
774 for i := 0 to High(FAbonRes) do begin
775 if FAbonRes[i].Res <> ResNum then begin
776 linebuf := IntToStr(FAbonRes[i].Res) + '-' + IntToStr(FabonRes[i].option);
777 IndividualFile.Append(linebuf);
778 end;
779 end;
780 end;
781 if IndividualFile.Count <> 0 then begin
782 try
783 IndividualFile.SaveToFile(FIndividualFileName);
784 finally
785 IndividualFile.Free;
786 end;
787 end else begin
788 if FileExists(FIndividualFileName) = true then begin
789 DeleteFile(FIndividualFileName);
790 end;
791 end;
792 end;
793 //蛟句挨縺ゅ⊂縲懊s縺ョ繝ェ繧ケ繝医?蛟区焚繧定ソ斐☆
794 function TAbon.GetAbonResCount() : Integer;
795 var
796 i : Integer;
797 begin
798 if FAbonRes[0].Res = 0 then begin
799 Result := 0
800 end else begin
801 i := High(FAbonRes);
802 Result := i+1;
803 end;
804 end;
805 //蛟句挨縺ゅ⊂縲懊s縺ョ繝ェ繧ケ繝医??手。檎岼縺ョ繝ャ繧ケ繧呈枚蟄怜?縺ァ霑斐☆
806 function TAbon.GetAbonResString(Num : Integer) : String;
807 begin
808 if (Num <= High(FAbonRes)) and (Num >= 0) then begin
809 Result := IntToStr(FAbonRes[Num].Res);
810 end else begin
811 Result := '';
812 end;
813 end;
814 //繝昴ャ繝励い繝??縺ョ蛻、螳夂畑
815 function TAbon.CheckIndividualAbonList(ResNum : Integer) : Boolean;
816 var
817 i : Integer;
818 begin
819 if FAbonRes[0].Res <> 0 then begin
820 for i := 0 to High(FAbonRes) do begin
821 if FAbonRes[i].Res = ResNum then begin
822 Result := true;
823 Exit;
824 end;
825 end;
826 end;
827 Result := false;
828
829 end;
830 //繧キ繝ェ繧「隱槭ヶ繝ゥ繧ッ繝ゥ蟇セ遲?/span>
831 function TAbon.TreatSyria(AString: string): string;
832 var
833 //count: Integer; //(&#1792~&#1871)
834 pos: Integer;
835 tmp: string;
836 begin
837 pos := AnsiPos('&#18', AString);
838 while pos <> 0 do begin
839 if StrToIntDef(Copy(AString, pos+4, 2), -1) > 0 then begin
840 if (AString[pos+6] = ';' ) or (AString[pos+6] = ' ') then begin
841 tmp := tmp + Copy(AString, 1, pos - 1);
842 Delete(AString, 1, pos+6);
843 end else if StrToIntDef(AString[pos+6], -1) = -1 then begin
844 tmp := tmp + Copy(AString, 1, pos - 1);
845 Delete(AString, 1, pos+5);
846 end else begin
847 tmp := tmp + Copy(AString, 1, pos + 5);
848 Delete(AString, 1, pos+5);
849 end;
850 end else begin
851 tmp := tmp + Copy(AString, 1, pos + 5);
852 Delete(AString, 1, pos+5);
853 end;
854 pos := AnsiPos('&#18', AString);
855 end;
856 if Length(AString) > 0 then
857 tmp := tmp + AString;
858 AString := tmp;
859 tmp := '';
860
861 pos := AnsiPos('&#179', AString);
862 while pos <> 0 do begin
863 if StrToIntDef(Copy(AString, pos+5, 1), 0) > 2 then begin
864 if (AString[pos+6] = ';') or (AString[pos+6] = ' ') then begin
865 tmp := tmp + Copy(AString, 1, pos - 1);
866 Delete(AString, 1, pos+6);
867 end else if StrToIntDef(AString[pos+6], -1) = -1 then begin
868 tmp := tmp + Copy(AString, 1, pos - 1);
869 Delete(AString, 1, pos+5);
870 end else begin
871 tmp := tmp + Copy(AString, 1, pos + 5);
872 Delete(AString, 1, pos+5);
873 end;
874 end else begin
875 tmp := tmp + Copy(AString, 1, pos + 5);
876 Delete(AString, 1, pos+5);
877 end;
878 pos := AnsiPos('&#179', AString);
879 end;
880 if Length(AString) > 0 then
881 tmp := tmp + AString;
882 Result := tmp;
883 end;
884 end.
885

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26