リビジョン | 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
@@ -21,8 +21,15 @@ SSTP-Viewer | ||
21 | 21 | 2.1 同じ画像ファイルを連続で読まないように修正してかなり高速化。 |
22 | 22 | 2.2 存在しないゴーストのリクエストへの反応が遅かったのを高速化。 |
23 | 23 | コメントを正しく読み飛ばすようにした。 |
24 | + 2.3 SVG3の仕様に可能な限り対応。コメント、/EOF等に対応。 | |
24 | 25 | |
26 | +●制限 | |
27 | + GIF形式のサーフィス画像ファイルはサポートしていません。 | |
28 | + 画像はjpg, png, bmpのいずれかであることが前提です。 | |
25 | 29 | |
26 | 30 | TPngImage は Gustavo Huffenbacher Daud 氏の著作物です。 |
27 | 31 | 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 |
@@ -62,7 +62,7 @@ end; | ||
62 | 62 | // CanConfigureは、Configureを呼ばれてやることがあるかどうかを返す。 |
63 | 63 | function GetVersion(DLLName: PChar; NameLen: integer; |
64 | 64 | 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'; | |
66 | 66 | begin |
67 | 67 | Version := 1; |
68 | 68 | CanConfigure := true; |
@@ -144,92 +144,129 @@ end; | ||
144 | 144 | procedure ParseKeyVal(const Line: String; out Key, Val: String); |
145 | 145 | var p: integer; |
146 | 146 | begin |
147 | + // Key=Value形式の文字列からKeyとValueを取り出す | |
148 | + // Valueは""で囲んでもよい。Keyは小文字にこの段階で統一 | |
147 | 149 | p := Pos('=', Line); |
148 | 150 | if p > 0 then |
149 | 151 | begin |
150 | - Key := Copy(Line, 1, p-1); | |
152 | + Key := AnsiLowerCase(Copy(Line, 1, p-1)); | |
151 | 153 | Val := AnsiDequotedStr(Copy(Line, p+1, High(integer)), '"'); |
152 | 154 | end else begin |
153 | 155 | 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; | |
155 | 200 | end; |
156 | 201 | end; |
157 | 202 | |
158 | 203 | function LoadDefinitionFileVer3(Ghost: String; |
159 | 204 | Surface: integer; Lines: TStringList; const FileName: String; |
160 | 205 | out Pos: integer): String; |
161 | -var i, j, k, smin, smax, oldsur: integer; | |
206 | +var i, k, smin, smax, oldsur: integer; | |
162 | 207 | Key, Val, SurStr, PosStr, SakuraName: String; |
163 | - Dat, Sur2Pos: TStringList; | |
208 | + Blocks, Sur2Pos: TStringList; | |
164 | 209 | begin |
165 | 210 | oldsur := -1; |
166 | 211 | Sur2Pos := TStringList.Create; |
212 | + Blocks := TStringList.Create; | |
167 | 213 | 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 | |
169 | 217 | 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 | |
174 | 220 | begin |
175 | 221 | SakuraName := Val; |
176 | 222 | Ghost2File.Values[SakuraName] := FileName; //次からのショートカット |
177 | 223 | if SakuraName <> Ghost then //別ゴーストの定義ファイルなのでパス |
178 | 224 | Exit; |
179 | - end else if SameText(Key, 'surfacefile') then | |
225 | + end else if Key = 'surfacefile' then | |
180 | 226 | begin |
181 | 227 | 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 | |
183 | 229 | begin |
184 | 230 | // サーフィス |
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)); | |
186 | 235 | try |
187 | - Dat.CommaText := Val; | |
188 | - for j := 0 to Dat.Count-1 do | |
236 | + if System.Pos('-', SurStr) > 0 then | |
189 | 237 | 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); | |
225 | 262 | end; |
226 | 263 | end; |
227 | - finally | |
228 | - Dat.Free; | |
264 | + except | |
265 | + Continue; | |
229 | 266 | end; |
230 | 267 | end; |
231 | 268 | end; |
232 | - // ShowMessage(Sur2Pos.Text); | |
269 | + // ShowMessage(SakuraName + #13#10 + Sur2Pos.Text); | |
233 | 270 | if SakuraName <> Ghost then //sakura=??の指定が抜けている定義ファイルの場合 |
234 | 271 | Result := '' |
235 | 272 | else |
@@ -241,10 +278,10 @@ begin | ||
241 | 278 | end; |
242 | 279 | finally |
243 | 280 | Sur2Pos.Free; |
281 | + Blocks.Free; | |
244 | 282 | end; |
245 | 283 | end; |
246 | 284 | |
247 | - | |
248 | 285 | function LoadDefinitionFile(Ghost: String; |
249 | 286 | Surface: integer; FileName: String; out Pos: integer): String; |
250 | 287 | var Lines: TStringList; |