• R/O
  • HTTP
  • SSH
  • HTTPS

svg-dll: コミット

SVG (SSTP-Viewer Ghost) 用プラグイン


コミットメタ情報

リビジョンa2272ebd08ebb23e712905d56f615af6c211a9cf (tree)
日時2003-11-05 12:47:33
作者naru <bottle@mika...>
コミッターnaru

ログメッセージ

Version 2.3, Fully compatible with SVG3 written specification at the official site

変更サマリ

差分

--- a/SVG.dll.txt
+++ b/SVG.dll.txt
@@ -21,8 +21,15 @@ SSTP-Viewer
2121  2.1 同じ画像ファイルを連続で読まないように修正してかなり高速化。
2222  2.2 存在しないゴーストのリクエストへの反応が遅かったのを高速化。
2323   コメントを正しく読み飛ばすようにした。
24+ 2.3 SVG3の仕様に可能な限り対応。コメント、/EOF等に対応。
2425
26+●制限
27+ GIF形式のサーフィス画像ファイルはサポートしていません。
28+ 画像はjpg, png, bmpのいずれかであることが前提です。
2529
2630 TPngImage は Gustavo Huffenbacher Daud 氏の著作物です。
2731 Gustavo Huffenbacher Daud
28-http://pngdelphi.sourceforge.net
\ No newline at end of file
32+http://pngdelphi.sourceforge.net
33+
34+SVGはT.J.氏の策定したシェルサムネール記述フォーマットです。
35+http://seriko.nanika.jp/sstpviewer/
\ No newline at end of file
--- a/SVG.dpr
+++ b/SVG.dpr
@@ -62,7 +62,7 @@ end;
6262 // CanConfigureは、Configureを呼ばれてやることがあるかどうかを返す。
6363 function GetVersion(DLLName: PChar; NameLen: integer;
6464 var Version: integer; var CanConfigure: boolean): integer; cdecl;
65-const ThisDLL = 'SVG Surface Loader Ver. 2.2';
65+const ThisDLL = 'SVG Surface Loader Ver. 2.3';
6666 begin
6767 Version := 1;
6868 CanConfigure := true;
@@ -144,92 +144,129 @@ end;
144144 procedure ParseKeyVal(const Line: String; out Key, Val: String);
145145 var p: integer;
146146 begin
147+ // Key=Value形式の文字列からKeyとValueを取り出す
148+ // Valueは""で囲んでもよい。Keyは小文字にこの段階で統一
147149 p := Pos('=', Line);
148150 if p > 0 then
149151 begin
150- Key := Copy(Line, 1, p-1);
152+ Key := AnsiLowerCase(Copy(Line, 1, p-1));
151153 Val := AnsiDequotedStr(Copy(Line, p+1, High(integer)), '"');
152154 end else begin
153155 Key := '';
154- Val := Line;
156+ Val := AnsiDequotedStr(Line, '"');
157+ end;
158+end;
159+
160+procedure SplitBlocks(Lines, Blocks: TStringList);
161+var
162+ Str, Block: String;
163+ i: integer;
164+ Start: integer; // 現在注目しているブロックの先頭の文字インデックス
165+ InLead: boolean; // DBCSのLeadBytesを見ているかどうかを保持
166+begin
167+ // SVGの各行をブロックに変換
168+ // コメントを取り外し、/EOF以降を適切に無視する
169+ Str := Lines.Text;
170+ i := 0;
171+ Start := 1;
172+ InLead := false;
173+ while (i < Length(Str)) do
174+ begin
175+ Inc(i);
176+ if InLead then
177+ begin
178+ InLead := false;
179+ Continue;
180+ end else if Str[i] in LeadBytes then
181+ begin
182+ InLead := true;
183+ Continue;
184+ end else
185+ begin
186+ if Str[i] in [',', #13, #10] then
187+ begin
188+ if Start < i then
189+ begin
190+ // 切り出し
191+ Block := Copy(Str, Start, i-Start);
192+ if Block = '/EOF' then
193+ Break
194+ else if Block[1] <> '/' then // コメントは無視
195+ Blocks.Add(Block);
196+ end;
197+ Start := i+1;
198+ end;
199+ end;
155200 end;
156201 end;
157202
158203 function LoadDefinitionFileVer3(Ghost: String;
159204 Surface: integer; Lines: TStringList; const FileName: String;
160205 out Pos: integer): String;
161-var i, j, k, smin, smax, oldsur: integer;
206+var i, k, smin, smax, oldsur: integer;
162207 Key, Val, SurStr, PosStr, SakuraName: String;
163- Dat, Sur2Pos: TStringList;
208+ Blocks, Sur2Pos: TStringList;
164209 begin
165210 oldsur := -1;
166211 Sur2Pos := TStringList.Create;
212+ Blocks := TStringList.Create;
167213 try
168- for i := 1 to Lines.Count-1 do // 1行目は"SVG"の文字列
214+ Lines.Delete(0);
215+ SplitBlocks(Lines, Blocks);
216+ for i := 0 to Blocks.Count-1 do
169217 begin
170- if System.Pos('/', Lines[i]) = 1 then // コメント行をとばす
171- Continue;
172- ParseKeyVal(Lines[i], Key, Val);
173- if SameText(Key, 'sakura') then
218+ ParseKeyVal(Blocks[i], Key, Val);
219+ if Key = 'sakura' then
174220 begin
175221 SakuraName := Val;
176222 Ghost2File.Values[SakuraName] := FileName; //次からのショートカット
177223 if SakuraName <> Ghost then //別ゴーストの定義ファイルなのでパス
178224 Exit;
179- end else if SameText(Key, 'surfacefile') then
225+ end else if Key = 'surfacefile' then
180226 begin
181227 Result := Val;
182- end else if SameText(Key, 'surface') or (Length(Key) = 0) then
228+ end else if (Key = 'surface') or (Length(Key) = 0) then
183229 begin
184230 // サーフィス
185- Dat := TStringList.Create;
231+ if System.Pos(':', Blocks[i]) <= 0 then
232+ Continue;
233+ SurStr := Copy(Blocks[i], 1, System.Pos(':', Blocks[i])-1);
234+ PosStr := Copy(Blocks[i], System.Pos(':', Blocks[i])+1, High(integer));
186235 try
187- Dat.CommaText := Val;
188- for j := 0 to Dat.Count-1 do
236+ if System.Pos('-', SurStr) > 0 then
189237 begin
190- if System.Pos(':', Dat[j]) <= 0 then
191- Continue;
192- SurStr := Copy(Dat[j], 1, System.Pos(':', Dat[j])-1);
193- PosStr := Copy(Dat[j], System.Pos(':', Dat[j])+1, High(integer));
194- try
195- if System.Pos('-', SurStr) > 0 then
196- begin
197- smin := StrToInt(Copy(SurStr, 1, System.Pos('-', SurStr)-1));
198- smax := StrToInt(Copy(SurStr, System.Pos('-', SurStr)+1, High(integer)));
199- end else
200- begin
201- smin := StrToInt(SurStr);
202- smax := smin;
203- end;
204- for k := smin to smax do
205- begin
206- if PosStr = '*' then
207- begin
208- Sur2Pos.Values[IntToStr(k)] := IntToStr(k);
209- oldsur := k;
210- end else if PosStr = '-2' then
211- begin
212- Sur2Pos.Values[IntToStr(k)] := '' // 定義解除
213- end else if PosStr = '+' then
214- begin
215- Inc(oldsur);
216- Sur2Pos.Values[IntToStr(k)] := IntToStr(oldsur);
217- end else if StrToInt(PosStr) >= 0 then
218- begin
219- Sur2Pos.Values[IntToStr(k)] := PosStr;
220- oldsur := StrToInt(PosStr);
221- end;
222- end;
223- except
224- Continue;
238+ smin := StrToInt(Copy(SurStr, 1, System.Pos('-', SurStr)-1));
239+ smax := StrToInt(Copy(SurStr, System.Pos('-', SurStr)+1, High(integer)));
240+ end else
241+ begin
242+ smin := StrToInt(SurStr);
243+ smax := smin;
244+ end;
245+ for k := smin to smax do
246+ begin
247+ if PosStr = '*' then
248+ begin
249+ Sur2Pos.Values[IntToStr(k)] := IntToStr(k);
250+ oldsur := k;
251+ end else if PosStr = '-2' then
252+ begin
253+ Sur2Pos.Values[IntToStr(k)] := '' // 定義解除
254+ end else if PosStr = '+' then
255+ begin
256+ Inc(oldsur);
257+ Sur2Pos.Values[IntToStr(k)] := IntToStr(oldsur);
258+ end else if StrToInt(PosStr) >= 0 then
259+ begin
260+ Sur2Pos.Values[IntToStr(k)] := PosStr;
261+ oldsur := StrToInt(PosStr);
225262 end;
226263 end;
227- finally
228- Dat.Free;
264+ except
265+ Continue;
229266 end;
230267 end;
231268 end;
232- // ShowMessage(Sur2Pos.Text);
269+ // ShowMessage(SakuraName + #13#10 + Sur2Pos.Text);
233270 if SakuraName <> Ghost then //sakura=??の指定が抜けている定義ファイルの場合
234271 Result := ''
235272 else
@@ -241,10 +278,10 @@ begin
241278 end;
242279 finally
243280 Sur2Pos.Free;
281+ Blocks.Free;
244282 end;
245283 end;
246284
247-
248285 function LoadDefinitionFile(Ghost: String;
249286 Surface: integer; FileName: String; out Pos: integer): String;
250287 var Lines: TStringList;
旧リポジトリブラウザで表示