Develop and Download Open Source Software

Browse CVS Repository

Diff of /gikonavigoeson/gikonavi/AbonUnit.pas

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

revision 1.23 by h677, Tue Apr 20 14:53:57 2004 UTC revision 1.24 by h677, Thu May 6 15:13:52 2004 UTC
# Line 64  type Line 64  type
64      procedure LoadFromStringList( bufstl : TStringList );      procedure LoadFromStringList( bufstl : TStringList );
65      function CheckAbonPopupRes(line : String) :Boolean;      function CheckAbonPopupRes(line : String) :Boolean;
66          function FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean;//1ラインずつ用。          function FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean;//1ラインずつ用。
67          function Cutoff(line : String) : Boolean; //CutOff値以上個の同じ英数が並んでいたらtrue          function FindNGwordsEx(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean;//1ラインずつ用。
68      //あぼ〜ん処理(NGワードでのフィルタリング)          //あぼ〜ん処理(NGワードでのフィルタリング)
69      procedure Execute(var ThreadStrings : TStringList); overload;          procedure Execute(var ThreadStrings : TStringList); overload;
70      procedure Execute(var ThreadStrings : TStringList; NGwords : TStringList); overload;          procedure Execute(var ThreadStrings : TStringList; NGwords : TStringList); overload;
71      procedure Execute(var ThreadStrings : TStringList; NGwords : TStrings); overload;          procedure Execute(var ThreadStrings : TStringList; NGwords : TStrings); overload;
72      procedure Execute(var ResString : String; ResNumber : Integer); overload;   //主にpluginからのDat To HTML 用          procedure Execute(var ResString : String; ResNumber : Integer); overload;       //主にpluginからのDat To HTML 用
73      //個別あぼ〜んしょり          procedure ExecuteEx(var ThreadStrings : TStringList); overload;
74      procedure IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String); overload;          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からのDat To HTML 用
77    
78            //個別あぼ〜んしょり
79            procedure IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String); overload;
80          procedure IndividualAbon(var ResString : String; SetResNumFile : String; ResNumber : Integer); overload;          procedure IndividualAbon(var ResString : String; SetResNumFile : String; ResNumber : Integer); overload;
81      procedure AddIndividualAbon( ResNum : Integer ; option : Integer);          procedure AddIndividualAbon( ResNum : Integer ; option : Integer);
82      procedure DeleteIndividualAbon( ResNum : Integer);          procedure DeleteIndividualAbon( ResNum : Integer);
83      function GetAbonResCount() : Integer;          function GetAbonResCount() : Integer;
84      function GetAbonResString(Num : Integer) : String;          function GetAbonResString(Num : Integer) : String;
85      function CheckIndividualAbonList(ResNum : Integer) : Boolean;          function CheckIndividualAbonList(ResNum : Integer) : Boolean;
86    
87          procedure EditNGwords();  //NGword.txtを開く。          procedure EditNGwords();  //NGword.txtを開く。
88      function ShowAllTokens() : String;  //デバッグ用          function ShowAllTokens() : String;  //デバッグ用
89      //--          //--
90      procedure GoHome();//Listの1行目を読む          procedure GoHome();//Listの1行目を読む
91      function GoForward() : Boolean; //Listの一つ次のNGワードファイルを読み込む          function GoForward() : Boolean; //Listの一つ次のNGワードファイルを読み込む
92      function GoBack() : Boolean; //Listの一つ前のNGワードファイルを読み込む          function GoBack() : Boolean; //Listの一つ前のNGワードファイルを読み込む
93      //--          //--
94      function TreatSyria(AString: string): string;          function TreatSyria(AString: string): string;
95    end;    end;
96  var  var
97      Abon1 :TAbon;          Abon1 :TAbon;
98  const  const
99      NGwordListFileName : String = 'NGwords.list';          NGwordListFileName : String = 'NGwords.list';
100    
101  implementation  implementation
102    
# Line 99  uses MojuUtils; Line 104  uses MojuUtils;
104    
105  constructor TAbon.Create;  constructor TAbon.Create;
106  begin  begin
107      // 初期化          // 初期化
108      FAbonString := '&nbsp;<>&nbsp;<>&nbsp;<>&nbsp;&nbsp;<><>';          FAbonString := '&nbsp;<>&nbsp;<>&nbsp;<>&nbsp;&nbsp;<><>';
109      FCreateNGwordFile := true;          FCreateNGwordFile := true;
110      SetLength(FAbonRes,1);          SetLength(FAbonRes,1);
111      FAbonRes[0].Res := 0;          FAbonRes[0].Res := 0;
112      FAbonRes[0].option := -1;          FAbonRes[0].option := -1;
113    
114  end;  end;
115    
116  destructor TAbon.Destroy;  destructor TAbon.Destroy;
117  begin  begin
118      inherited;          inherited;
119  end;  end;
120  //rootはExe\config\NGwordsフォルダ  //rootはExe\config\NGwordsフォルダ
121  procedure TAbon.Setroot(root :String);  procedure TAbon.Setroot(root :String);
122  var  var
123      bufStringList : TStringList;          bufStringList : TStringList;
124  begin  begin
125      bufStringList := TStringList.Create;          bufStringList := TStringList.Create;
126      try          try
127          if not DirectoryExists(root) then begin                  if not DirectoryExists(root) then begin
128              CreateDir(root);                          CreateDir(root);
129          end;                  end;
130          if root[Length(root)] <> '\' then begin                  if root[Length(root)] <> '\' then begin
131              root := root + '\';                          root := root + '\';
132          end;                  end;
133          Flistpath := root + NGwordListFileName;                  Flistpath := root + NGwordListFileName;
134          LoadListFile(Flistpath, bufStringList);                  LoadListFile(Flistpath, bufStringList);
135      finally          finally
136          bufStringList.Free;                  bufStringList.Free;
137      end;          end;
138      Froot := root;          Froot := root;
139  end;  end;
140  function TAbon.Getroot() : String;  function TAbon.Getroot() : String;
141  begin  begin
142      Result := Froot;          Result := Froot;
143  end;  end;
144  //NGwordpathはNGword.txtのフルパス  //NGwordpathはNGword.txtのフルパス
145  procedure TAbon.SetNGwordpath(path :String);  procedure TAbon.SetNGwordpath(path :String);
146  begin  begin
147      FNGwordpath := Getfullpath(path);          FNGwordpath := Getfullpath(path);
148      LoadFromNGwordFile(FNGwordpath);          LoadFromNGwordFile(FNGwordpath);
149  end;  end;
150  function TAbon.GetNGwordpath() : String;  function TAbon.GetNGwordpath() : String;
151  begin  begin
152      Result :=  FNGwordpath;          Result :=  FNGwordpath;
153  end;  end;
154  //フルパスでなければフルパスにして返す。  //フルパスでなければフルパスにして返す。
155  function TAbon.Getfullpath(argpath : String) : String;  function TAbon.Getfullpath(argpath : String) : String;
156  begin  begin
157      if AnsiPos(':\',argpath) <> 2 then begin  //ドライブからのフルパスが無ければ          if AnsiPos(':\',argpath) <> 2 then begin  //ドライブからのフルパスが無ければ
158          if Getroot() = '' then begin                  if Getroot() = '' then begin
159              Result := '';    //rootパスが設定されてないか空にする                          Result := '';    //rootパスが設定されてないか空にする
160          end else begin                  end else begin
161              if (Froot[Length(Froot)] = '\') and (argpath[1] = '\') then begin  //先頭の\を削除                          if (Froot[Length(Froot)] = '\') and (argpath[1] = '\') then begin  //先頭の\を削除
162                  Delete(argpath,1,1);                                  Delete(argpath,1,1);
163              end;                          end;
164              Insert( Getroot(), argpath , 1);//rootパスを挿入                          Insert( Getroot(), argpath , 1);//rootパスを挿入
165              Result := argpath;                          Result := argpath;
166          end;                  end;
167      end else begin          end else begin
168          Result := argpath;                  Result := argpath;
169      end;          end;
170    
171  end;  end;
172  //NGwordファイルの読み込み  //NGwordファイルの読み込み
173  function TAbon.LoadFromNGwordFile(path :String) : boolean;  function TAbon.LoadFromNGwordFile(path :String) : boolean;
174  var  var
175      bufstl : TStringList;          bufstl : TStringList;
176  begin  begin
177      path := Getfullpath(path);          path := Getfullpath(path);
178      if path = '' then begin          if path = '' then begin
179          Result := false;                  Result := false;
180      end else begin          end else begin
181          bufstl := TStringList.Create;                  bufstl := TStringList.Create;
182          try                  try
183              try                          try
184                  bufstl.LoadFromFile(path);                                  bufstl.LoadFromFile(path);
185                  LoadFromStringList( bufstl );                                  LoadFromStringList( bufstl );
186                  Result := true;                                  Result := true;
187              except                          except
188                  if CreateNGwordFile = true then begin                                  if CreateNGwordFile = true then begin
189                      bufstl.SaveToFile(path);                                          bufstl.SaveToFile(path);
190                  end;                                  end;
191                  Result := false;                                  Result := false;
192              end;                          end;
193          finally                  finally
194              bufstl.Free;                          bufstl.Free;
195          end;                  end;
196      end;          end;
197    
198  end;  end;
199  //NGwordリスト読み込み  //NGwordリスト読み込み
200  procedure TAbon.LoadFromStringList( bufstl : TStringList );  procedure TAbon.LoadFromStringList( bufstl : TStringList );
201  var  var
202      i : integer;          i : integer;
203  begin  begin
204      try          try
205          for i := bufstl.Count -1  downto 0 do begin                  for i := bufstl.Count -1  downto 0 do begin
206              if bufstl.Strings[i] = '' then begin                          if bufstl.Strings[i] = '' then begin
207                  bufstl.Delete(i);                                  bufstl.Delete(i);
208              end;                          end;
209          end;                  end;
210          SetLength(Ftokens,bufstl.Count);                  SetLength(Ftokens,bufstl.Count);
211          for i := 0  to bufstl.Count -1 do begin                  for i := 0  to bufstl.Count -1 do begin
212              SetTokens(i , bufstl.Strings[i]);                          SetTokens(i , bufstl.Strings[i]);
213          end;                  end;
214    
215      except          except
216          Exit;                  Exit;
217      end;          end;
218  end;  end;
219  //NGwordpathが既に設定されているときのリロード用関数  //NGwordpathが既に設定されているときのリロード用関数
220  function TAbon.ReLoadFromNGwordFile() : boolean;  function TAbon.ReLoadFromNGwordFile() : boolean;
221  begin  begin
222      if GetNGwordpath() ='' then begin          if GetNGwordpath() ='' then begin
223          Result := false;                  Result := false;
224      end else begin          end else begin
225          Result := LoadFromNGwordFile( GetNGwordpath() );                  Result := LoadFromNGwordFile( GetNGwordpath() );
226      end;          end;
227  end;  end;
228  function TAbon.Getlistpath() : String;  function TAbon.Getlistpath() : String;
229  begin  begin
230      Result := Flistpath;          Result := Flistpath;
231  end;  end;
232  procedure TAbon.Setlistpath(const Value : String);  procedure TAbon.Setlistpath(const Value : String);
233  begin  begin
234      Flistpath := Getfullpath(Value);          Flistpath := Getfullpath(Value);
235  end;  end;
236  //一行の中のトークンを切り分けてセット  //一行の中のトークンを切り分けてセット
237  procedure TAbon.SetTokens(index: integer ; argline : String);  procedure TAbon.SetTokens(index: integer ; argline : String);
238  var  var
239      ret : Integer;          ret : Integer;
240      bufstl : TStringList;          bufstl : TStringList;
241      i : Integer;          i : Integer;
242      pos : Integer;          pos : Integer;
243      buftoken : String;          buftoken : String;
244  begin  begin
245          pos := 0;          pos := 0;
246      bufstl := TStringList.Create;          bufstl := TStringList.Create;
247      try          try
248          if Length(argline) > 0 then begin                  if Length(argline) > 0 then begin
249                  pos := AnsiPos(#9,argline);                          pos := AnsiPos(#9,argline);
250              while pos <> 0 DO begin                          while pos <> 0 DO begin
251                  buftoken := Copy(argline,1,pos-1);                                  buftoken := Copy(argline,1,pos-1);
252                  Delete(argline,1,pos);                                  Delete(argline,1,pos);
253                  if Length(buftoken) > 0 then begin                                  if Length(buftoken) > 0 then begin
254                                  bufstl.Append(buftoken);                                          bufstl.Append(buftoken);
255                  end else if ( bufstl.Count = 0 ) then begin                                  end else if ( bufstl.Count = 0 ) then begin
256                      bufstl.Append('');                                          bufstl.Append('');
257                  end;                                  end;
258                      pos := AnsiPos(#9,argline);                                  pos := AnsiPos(#9,argline);
259              end;                          end;
260                  if Length(argline) > 0 then begin                          if Length(argline) > 0 then begin
261                          bufstl.Append(argline);                                  bufstl.Append(argline);
262              end;                          end;
263                  ret := bufstl.Count;                          ret := bufstl.Count;
264                  SetLength(Ftokens[index],ret);                          SetLength(Ftokens[index],ret);
265                  for i := 0 to bufstl.Count - 1  do begin                          for i := 0 to bufstl.Count - 1  do begin
266                          Ftokens[index][i] := bufstl.Strings[i];                                  Ftokens[index][i] := bufstl.Strings[i];
267                  end;                          end;
268          end;                  end;
269      finally          finally
270          bufstl.Free;                  bufstl.Free;
271      end;          end;
272    
273  end;  end;
274  //Debug用ちゃんとNGワードを拾えているか  //Debug用ちゃんとNGワードを拾えているか
275  function TAbon.ShowAllTokens() : String;  function TAbon.ShowAllTokens() : String;
276  var  var
277      i : Integer;          i : Integer;
278      j : Integer;          j : Integer;
279      ret : String;          ret : String;
280  begin  begin
281      for i := 0 to High(Ftokens) do begin          for i := 0 to High(Ftokens) do begin
282          for j := 0 to High(Ftokens[i]) do begin                  for j := 0 to High(Ftokens[i]) do begin
283              ret := ret + Ftokens[i][j];                          ret := ret + Ftokens[i][j];
284          end;                  end;
285      end;          end;
286      Result := ret;          Result := ret;
287    
288    
289    
290  end;  end;
291    //NGワードが含まれていたらtrueを返し、そのNGワードの行数をNGwordsLineNumに入れて返す。
292  //****************************************************************************//  //もしも透明あぼ〜んにするならInbisibleをtrueにして返す
293  //NGワードが含まれてたらtrueを返す。  function TAbon.FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean; //1ラインずつ用。
 {function TAbon.FindNGwords(const line : String) : Boolean;  
294  var  var
295          lines : Integer;          lines : Integer;
296          cells : Integer;          cells : Integer;
297          hit : Boolean;          hit : Boolean;
   
298          bufline : String;          bufline : String;
299            start : Integer;
300  begin  begin
301          hit := false;          hit := false;
302          if AnsiPos(FAbonString,line) <> 1 then begin          if AnsiPos(FAbonString,line) <> 1 then begin
303                  for lines := 0 to High(Ftokens) do begin                  for lines := 0 to High(Ftokens) do begin
304                          hit := true;                          hit := true;
305                          bufline := line;                          bufline := line;
306                          for cells := 0 to High(Ftokens[lines]) do begin                          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                                  if AnsiPos(Ftokens[lines][cells],bufline) = 0 then begin
316                                          hit := false;                                          hit := false;
317                                          break;                                          break;
# Line 308  begin Line 320  begin
320                                  end;                                  end;
321                          end;                          end;
322                          if hit = true then begin                          if hit = true then begin
323                                    NGwordsLineNum := lines + 1;
324                                  break;                                  break;
325                          end;                          end;
326                  end;                  end;
327          end;          end;
328          Result := hit;          Result := hit;
329  end;  end;
330  //NGワードが含まれていたらtrueを返し、そのNGワードの行数をNGwordsLineNumに入れて返す  //NGワードが含まれていたらtrueを返し、そのNGワードの行数をNGwordsLineNumに入れて返す。
331  function TAbon.FindNGwords(const line : String; var NGwordsLineNum : Integer) : Boolean;  //もしも透明あぼ〜んにするならInbisibleをtrueにして返す
332    //半角全角無視
333    function TAbon.FindNGwordsEx(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean;//1ラインずつ用。
334  var  var
335          lines : Integer;          lines : Integer;
336          cells : Integer;          cells : Integer;
337          hit : Boolean;          hit : Boolean;
338          bufline : String;          bufline : String;
339            start : Integer;
340  begin  begin
341          hit := false;          hit := false;
342          if AnsiPos(FAbonString,line) <> 1 then begin          if AnsiPos(FAbonString,line) <> 1 then begin
343                  for lines := 0 to High(Ftokens) do begin                  for lines := 0 to High(Ftokens) do begin
344                          hit := true;                          hit := true;
345                          bufline := line;                          bufline := line;
346                          for cells := 0 to High(Ftokens[lines]) do begin                          if Ftokens[lines][0] <> ''  then begin
347                                  if AnsiPos(Ftokens[lines][cells],bufline) = 0 then begin                                  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 VaguePos(Ftokens[lines][cells],bufline) = 0 then begin
356                                          hit := false;                                          hit := false;
357                                          break;                                          break;
358                                  end else begin                                  end else begin
359                                          Delete(bufline,AnsiPos(Ftokens[lines][cells],bufline),Length(Ftokens[lines][cells]));                                          Delete(bufline, VaguePos(Ftokens[lines][cells],bufline),Length(Ftokens[lines][cells]));
360                                  end;                                  end;
361                          end;                          end;
362                          if hit = true then begin                          if hit = true then begin
# Line 343  begin Line 367  begin
367          end;          end;
368          Result := hit;          Result := hit;
369  end;  end;
 }  
 //NGワードが含まれていたらtrueを返し、そのNGワードの行数をNGwordsLineNumに入れて返す。  
 //もしも透明あぼ〜んにするならInbisibleをtrueにして返す  
 function TAbon.FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean; //1ラインずつ用。  
 var  
         lines : Integer;  
         cells : Integer;  
         hit : Boolean;  
         bufline : String;  
         start : Integer;  
 begin  
         hit := false;  
         if AnsiPos(FAbonString,line) <> 1 then begin  
                 for lines := 0 to High(Ftokens) do begin  
                         hit := true;  
             bufline := line;  
             if Ftokens[lines][0] <> ''  then begin  
                 Invisible := false;  
                 start := 0;  
             end else begin  
                 Invisible := true;  
                 start := 1;  
             end;  
   
             for cells := start to High(Ftokens[lines]) do begin  
                 if AnsiPos(Ftokens[lines][cells],bufline) = 0 then begin  
                     hit := false;  
                     break;  
                 end else begin  
                     Delete(bufline,AnsiPos(Ftokens[lines][cells],bufline),Length(Ftokens[lines][cells]));  
                 end;  
             end;  
             if hit = true then begin  
                 NGwordsLineNum := lines + 1;  
                 break;  
             end;  
         end;  
     end;  
     Result := hit;  
 end;  
   
 //CutOff値以上個の同じ英数が並んでいたらtrue  
 function TAbon.Cutoff(line : String) : Boolean;  
 var  
     i : Integer;  
     sheed : AnsiChar;  
     buf : String;  
     ret : Bool;  
 begin  
     ret := false;  
     if FCutoffNum <> 0 then begin  
         for i := 65 to 90 do begin  
             sheed := Chr(i);  
             buf := DupeString(sheed, FCutoffNum);  
             if AnsiContainsText(line, buf) = true then begin  
                 ret := true;  
                 break;  
             end;  
         end;  
     end;  
     Result := ret;  
 end;  
370  //末尾のブール値はtrueだと、NGワードを含むものだけを返す。  //末尾のブール値はtrueだと、NGワードを含むものだけを返す。
371  procedure TAbon.Execute(var ThreadStrings : TStringList);  procedure TAbon.Execute(var ThreadStrings : TStringList);
372  var  var
373      i : Integer;          i : Integer;
374      NGwordsLine : Integer;          NGwordsLine : Integer;
375      bufline : String;          bufline : String;
376      invisi : Boolean;          invisi : Boolean;
377  begin  begin
378      for i:=0 to ThreadStrings.Count - 1 do begin          for i:=0 to ThreadStrings.Count - 1 do begin
379          NGwordsLine := 0;                  NGwordsLine := 0;
380                  if FindNGwords(ThreadStrings.Strings[i], NGwordsLine ,invisi) <> Reverse  then begin                  if FindNGwords(ThreadStrings.Strings[i], NGwordsLine ,invisi) <> Reverse  then begin
381              if invisi = true then begin                          if invisi = true then begin
382                  ThreadStrings.Strings[i] := '';                                  ThreadStrings.Strings[i] := '';
383              end else begin                          end else begin
384                  if not ReturnNGwordLineNum and not SetNGResAnchor then begin                                  if not ReturnNGwordLineNum and not SetNGResAnchor then begin
385                      ThreadStrings.Strings[i] := FAbonString;                                          ThreadStrings.Strings[i] := FAbonString;
386                  end else if not ReturnNGwordLineNum then begin                                  end else if not ReturnNGwordLineNum then begin
387                      ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<>&gt;%d<><>',[(i+1)]);                                          ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<>&gt;%d<><>',[(i+1)]);
388                  end else if not SetNGResAnchor then begin                                  end else if not SetNGResAnchor then begin
389                      ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 行目のNGワードが含まれています。</B><><>',[NGwordsLine]);                                          ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 行目のNGワードが含まれています。</B><><>',[NGwordsLine]);
390                  end else begin                                  end else begin
391                      ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 行目のNGワードが含まれています。</B>&gt;%d <><>',[NGwordsLine,(i+1)]);                                          ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 行目のNGワードが含まれています。</B>&gt;%d <><>',[NGwordsLine,(i+1)]);
392                  end;                                  end;
393              end;                          end;
394          end else begin                  end else begin
395              bufline := ThreadStrings.Strings[i];                          bufline := ThreadStrings.Strings[i];
396              if Deleterlo = true then begin                          if Deleterlo = true then begin
397                  bufline := CustomStringReplace(bufline,'&rlo;','');                                  bufline := CustomStringReplace(bufline,'&rlo;','');
398                  bufline := CustomStringReplace(bufline,'&lro;','');                                  bufline := CustomStringReplace(bufline,'&lro;','');
399              end;                          end;
400              if Replaceul = true then begin                          if Replaceul = true then begin
401                  bufline := CustomStringReplace( bufline,'<ul>','<br>' );                                  bufline := CustomStringReplace( bufline,'<ul>','<br>' );
402                  bufline := CustomStringReplace( bufline,'</ul>','<br>' );                                  bufline := CustomStringReplace( bufline,'</ul>','<br>' );
403              end;                          end;
404                  if DeleteSyria = true then                          if DeleteSyria = true then
405                  bufline := TreatSyria(bufline);                                  bufline := TreatSyria(bufline);
406              ThreadStrings.Strings[i] := bufline;                          ThreadStrings.Strings[i] := bufline;
407          end;                  end;
408      end;          end;
409  end;  end;
410  procedure TAbon.Execute(var ResString : String; ResNumber : Integer);  procedure TAbon.Execute(var ResString : String; ResNumber : Integer);
411  var  var
412      NGwordsLine : Integer;          NGwordsLine : Integer;
413      bufline : String;          bufline : String;
414      invisi : Boolean;          invisi : Boolean;
415  begin  begin
416      NGwordsLine := 0;          NGwordsLine := 0;
417      if FindNGwords(ResString, NGwordsLine ,invisi) <> Reverse  then begin          if FindNGwords(ResString, NGwordsLine ,invisi) <> Reverse  then begin
418          if invisi = true then begin                  if invisi = true then begin
419              ResString := '';                          ResString := '';
420          end else begin                  end else begin
421              if not ReturnNGwordLineNum and not SetNGResAnchor then begin                          if not ReturnNGwordLineNum and not SetNGResAnchor then begin
422                  ResString := FAbonString;                                  ResString := FAbonString;
423              end else if not ReturnNGwordLineNum then begin                          end else if not ReturnNGwordLineNum then begin
424                  ResString := Format('&nbsp;<>&nbsp;<>&nbsp;<>&gt;%d<><>',[(ResNumber)]);                                  ResString := Format('&nbsp;<>&nbsp;<>&nbsp;<>&gt;%d<><>',[(ResNumber)]);
425              end else if not SetNGResAnchor then begin                          end else if not SetNGResAnchor then begin
426                  ResString := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 行目のNGワードが含まれています。</B><><>',[NGwordsLine]);                                  ResString := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 行目のNGワードが含まれています。</B><><>',[NGwordsLine]);
427              end else begin                          end else begin
428                  ResString := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 行目のNGワードが含まれています。</B>&gt;%d <><>',[NGwordsLine,(ResNumber)]);                                  ResString := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 行目のNGワードが含まれています。</B>&gt;%d <><>',[NGwordsLine,(ResNumber)]);
429              end;                          end;
430          end;                  end;
431      end else begin          end else begin
432          bufline := ResString;                  bufline := ResString;
433          if Deleterlo = true then begin                  if Deleterlo = true then begin
434              bufline := CustomStringReplace( bufline,'&rlo;','' );                          bufline := CustomStringReplace( bufline,'&rlo;','' );
435              bufline := CustomStringReplace( bufline,'&lro;','' );                          bufline := CustomStringReplace( bufline,'&lro;','' );
436          end;                  end;
437          if Replaceul = true then begin                  if Replaceul = true then begin
438              bufline := CustomStringReplace( bufline,'<ul>','<br>' );                          bufline := CustomStringReplace( bufline,'<ul>','<br>' );
439              bufline := CustomStringReplace( bufline,'</ul>','<br>' );                          bufline := CustomStringReplace( bufline,'</ul>','<br>' );
440          end;                  end;
441          if DeleteSyria = true then                  if DeleteSyria = true then
442                  bufline := TreatSyria(bufline);                          bufline := TreatSyria(bufline);
443          ResString := bufline;                  ResString := bufline;
444      end;          end;
445  end;  end;
446    
447  procedure TAbon.Execute(var ThreadStrings : TStringList; NGwords : TStringList);  procedure TAbon.Execute(var ThreadStrings : TStringList; NGwords : TStringList);
448  var  var
449      i : Integer;          i : Integer;
450  begin  begin
451      SetLength(Ftokens,NGwords.Count);          SetLength(Ftokens,NGwords.Count);
452      for i := 0  to NGwords.Count -1 do begin          for i := 0  to NGwords.Count -1 do begin
453          SetTokens(i , NGwords.Strings[i]);                  SetTokens(i , NGwords.Strings[i]);
454      end;          end;
455      Execute(ThreadStrings);          Execute(ThreadStrings);
456    
457  end;  end;
458  procedure TAbon.Execute(var ThreadStrings : TStringList; NGwords : TStrings);  procedure TAbon.Execute(var ThreadStrings : TStringList; NGwords : TStrings);
459  var  var
460      i : Integer;          i : Integer;
461      buf : TStringList;          buf : TStringList;
462  begin  begin
463      buf := TStringList.Create;          buf := TStringList.Create;
464      buf.AddStrings(NGwords);          buf.AddStrings(NGwords);
465      SetLength(Ftokens,buf.Count);          SetLength(Ftokens,buf.Count);
466      for i := 0  to buf.Count -1 do begin          for i := 0  to buf.Count -1 do begin
467          SetTokens(i , buf.Strings[i]);                  SetTokens(i , buf.Strings[i]);
468      end;          end;
469      Execute(ThreadStrings);          Execute(ThreadStrings);
470          buf.Free;          buf.Free;
471  end;  end;
472    
473    //末尾のブール値はtrueだと、NGワードを含むものだけを返す。
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ワードが含まれています。</B><><>',[NGwordsLine]);
493                                    end else begin
494                                            ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 行目のNGワードが含まれています。</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ワードが含まれています。</B><><>',[NGwordsLine]);
530                            end else begin
531                                    ResString := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 行目のNGワードが含まれています。</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  //現在セットされているNGword.txtを開く  //現在セットされているNGword.txtを開く
578  procedure TAbon.EditNGwords();  procedure TAbon.EditNGwords();
579  begin  begin
580      ShellExecute(0 ,nil,PChar(FNGwordpath),nil,nil,SW_SHOW);          ShellExecute(0 ,nil,PChar(FNGwordpath),nil,nil,SW_SHOW);
581  end;  end;
582  //ポップアップ用判定関数  //ポップアップ用判定関数
583  function TAbon.CheckAbonPopupRes(line : String) :Boolean;  function TAbon.CheckAbonPopupRes(line : String) :Boolean;
# Line 523  var Line 587  var
587  begin  begin
588          if AbonPopupRes = true then begin          if AbonPopupRes = true then begin
589                  Result := FindNGwords(line, i ,v);                  Result := FindNGwords(line, i ,v);
590      end else begin          end else begin
591          Result := false;                  Result := false;
592      end;          end;
593  end;  end;
594  //複数のNGワードテキストを読み込む==============================================  //複数のNGワードテキストを読み込む==============================================
595  //Listファイルを読み込む  //Listファイルを読み込む

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

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