Skip to content

Commit 347567c

Browse files
ver. 2.3.3
- Fixed loading remote svg files - Fixed "autocreate" missing file
1 parent 64b6fa8 commit 347567c

12 files changed

+109
-42
lines changed

Ext/SVGIconImageList/Image32/source/Img32.SVG.Reader.pas

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ TSvgReader = class
179179
property BackgndImage : TImage32 read fBackgndImage;
180180
property TempImage : TImage32 read GetTempImage;
181181
public
182+
procedure CalcViewBoxOfRootElement;
182183
constructor Create;
183184
destructor Destroy; override;
184185
procedure Clear;
@@ -5545,6 +5546,12 @@ procedure TSvgReader.Clear;
55455546
end;
55465547
//------------------------------------------------------------------------------
55475548

5549+
procedure TSvgReader.CalcViewBoxOfRootElement;
5550+
begin
5551+
fRootElement.viewboxWH.Width := fRootElement.elRectWH.width.GetValue(defaultSvgWidth, 0);
5552+
fRootElement.viewboxWH.height := fRootElement.elRectWH.height.GetValue(defaultSvgHeight, 0);
5553+
end;
5554+
55485555
procedure TSvgReader.DrawImage(img: TImage32; scaleToImage: Boolean);
55495556
var
55505557
scale, scaleH: double;
@@ -5556,8 +5563,7 @@ procedure TSvgReader.DrawImage(img: TImage32; scaleToImage: Boolean);
55565563
begin
55575564
if viewboxWH.IsEmpty then
55585565
begin
5559-
viewboxWH.Width := elRectWH.width.GetValue(defaultSvgWidth, 0);
5560-
viewboxWH.height := elRectWH.height.GetValue(defaultSvgHeight, 0);
5566+
CalcViewBoxOfRootElement;
55615567
if viewboxWH.IsEmpty then Exit; // this should never happen
55625568
end;
55635569

Ext/SVGIconImageList/Source/Image32SVGFactory.pas

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ TImage32SVG = class(TInterfacedObject, ISVG)
6969
procedure PaintTo(DC: HDC; R: TRectF; KeepAspectRatio: Boolean = True);
7070
procedure LoadFromSource;
7171
procedure SourceFromStream(Stream: TStream);
72-
procedure UpdateSizeInfo(defaultWidth, defaultHeight: integer);
72+
procedure UpdateSizeInfo;
7373
{$IFDEF CheckForUnsupportedSvg}
7474
procedure CheckForUnsupportedSvg;
7575
{$ENDIF}
@@ -159,16 +159,15 @@ function TImage32SVG.IsEmpty: Boolean;
159159
Result := fSvgReader.IsEmpty;
160160
end;
161161

162-
procedure TImage32SVG.UpdateSizeInfo(defaultWidth, defaultHeight: integer);
163-
var
164-
vbox: TRectWH;
162+
procedure TImage32SVG.UpdateSizeInfo;
165163
begin
166164
//nb: default widths should be the target image's dimensions
167165
//since these values will be used for SVG images that simply
168166
//specify their widths and heights as percentages
169-
vbox := fSvgReader.RootElement.viewboxWH;
170-
FWidth := vbox.Width;
171-
FHeight := vbox.Height;
167+
if fSvgReader.RootElement.viewboxWH.IsEmpty then
168+
fSvgReader.CalcViewBoxOfRootElement;
169+
FWidth := fSvgReader.RootElement.viewboxWH.Width;
170+
FHeight := fSvgReader.RootElement.viewboxWH.Height;
172171
end;
173172

174173
procedure TImage32SVG.LoadFromSource;
@@ -177,7 +176,7 @@ procedure TImage32SVG.LoadFromSource;
177176
begin
178177
if not fSvgReader.LoadFromString(FSource) then
179178
raise ESVGException.Create(IMAGE32_ERROR_PARSING_SVG_TEXT);
180-
UpdateSizeInfo(100, 100);
179+
UpdateSizeInfo;
181180
end;
182181
end;
183182

@@ -192,7 +191,7 @@ procedure TImage32SVG.LoadFromStream(Stream: TStream);
192191
Stream.Position := OldPos;
193192
// Now create the SVG
194193
fSvgReader.LoadFromStream(Stream);
195-
UpdateSizeInfo(100, 100);
194+
UpdateSizeInfo;
196195
end;
197196

198197
procedure TImage32SVG.PaintTo(DC: HDC; R: TRectF; KeepAspectRatio: Boolean);

Ext/SVGIconImageList/Source/SVGIconUtils.pas

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,13 @@ function PNG4TransparentBitMap(aBitmap: TBitmap): TPNGImage;
9595
BmpRGBA: ^TRGBAArray;
9696
PngRGB: ^TRGB;
9797
begin
98+
if (aBitmap.Height = 0) or (aBitmap.Width = 0) then
99+
begin
100+
Result := TPNGImage.CreateBlank(COLOR_RGBALPHA, 8, 1 , 1);
101+
Exit;
102+
end;
98103
//201011 Thomas Wassermann
99-
Result := TPNGImage.CreateBlank(COLOR_RGBALPHA, 8, aBitmap.Width , aBitmap.Height);
104+
Result := TPNGImage.CreateBlank(COLOR_RGBALPHA, 8, aBitmap.Width, aBitmap.Height);
100105

101106
Result.CreateAlpha;
102107
Result.Canvas.CopyMode:= cmSrcCopy;

README.htm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
}
3131
</style>
3232
<h1>Markdown Editor and Shell Extensions <a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-yellowgreen.svg" alt="License"/></a></h1>
33-
<p><strong>Latest Version 2.3.2 - 22 Jan 2025</strong></p>
33+
<p><strong>Latest Version 2.3.3 - 26 Jan 2025</strong></p>
3434
<p><strong>A collection of tools for markdown files, to edit and view content:</strong></p>
3535
<ul>
3636
<li><p>A <strong>Markdown Text Editor</strong> to manually edit a markdown file, with instant preview of the output in a HTML Viewer.</p>
@@ -81,6 +81,11 @@ <h3>Manual Build and Installation (only for Delphi developers)</h3>
8181
</li>
8282
</ol>
8383
<h2>Release Notes</h2>
84+
<p>26 Jan 2025: ver. 2.3.3</p>
85+
<ul>
86+
<li>Fixed loading remote svg files</li>
87+
<li>Fixed &ldquo;autocreate&rdquo; missing file</li>
88+
</ul>
8489
<p>22 Jan 2025: ver. 2.3.2</p>
8590
<ul>
8691
<li>Added auto-create file linked, if not exists</li>

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Markdown Editor and Shell Extensions [![License](https://img.shields.io/badge/License-Apache%202.0-yellowgreen.svg)](https://opensource.org/licenses/Apache-2.0)
22

3-
**Latest Version 2.3.2 - 22 Jan 2025**
3+
**Latest Version 2.3.3 - 26 Jan 2025**
44

55
**A collection of tools for markdown files, to edit and view content:**
66

@@ -67,6 +67,10 @@ To manually install the SVGShellExtensions.dll follow these steps:
6767

6868
## Release Notes ##
6969

70+
26 Jan 2025: ver. 2.3.3
71+
- Fixed loading remote svg files
72+
- Fixed "autocreate" missing file
73+
7074
22 Jan 2025: ver. 2.3.2
7175
- Added auto-create file linked, if not exists
7276
- Fixed Splitter View Opening a File

Source/MDShellEx.Resources.pas

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -302,24 +302,24 @@ procedure TdmResources.StopLoadingImages(const AStop: Boolean);
302302
function TdmResources.getStreamData(const AFileName : String;
303303
const AMaxWidth: Integer; const ABackgroundColor: TColor): TStream;
304304
var
305-
sl : TStringList;
305+
LFileStream: TStringStream;
306306
bFail : Boolean;
307307
bTryAgain : Boolean;
308308
LIdHTTP : TIdHTTP;
309309
LIdSSLIOHandler: TIdSSLIOHandlerSocketOpenSSL;
310-
LFileName: string;
310+
LFileName: TFileName;
311+
LFileContent: string;
311312
Begin
312313
Result := nil;
313314
FStream.Clear;
314315
LIdHTTP := nil;
315-
sl := nil;
316+
LFileStream := nil;
316317
LFileName := AFileName;
317318
LIdSSLIOHandler := nil;
318319
try
319320
LIdHTTP := TIdHTTP.Create;
320321
LIdHTTP.AllowCookies := True;
321322
LIdHTTP.HandleRedirects := True;
322-
sl := TStringList.Create;
323323
LIdSSLIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(LIdHTTP);
324324
LIdSSLIOHandler.DefaultPort := 0;
325325
LIdSSLIOHandler.SSLOptions.SSLVersions := [sslvTLSv1_2];
@@ -336,28 +336,38 @@ function TdmResources.getStreamData(const AFileName : String;
336336
else
337337
raise;
338338
end;
339-
// Need To check For Failed Retrieval...
340-
FStream.Position:= 0;
341-
sl.LoadFromStream(FStream);
342-
bTryAgain := False;
343-
bFail := False;
344-
if Length(sl.Text) = 0 then
345-
bFail:= True;
339+
346340
if FStream.Size = 0 then
341+
begin
347342
bFail:= True;
348-
349-
if FStream.Size < 1024 then
350-
Begin
351-
if Pos('Not Found', sl.Text) > 0 then bFail:= True;
352-
if (Pos(LowerCase('<title>301 Moved Permanently</title>'), LowerCase(sl.Text)) > 0) or
353-
(Pos(LowerCase('<html><body>'), LowerCase(sl.Text)) > 0) then
343+
bTryAgain := False;
344+
end
345+
else
346+
begin
347+
// Need To check For Failed Retrieval...
348+
FStream.Position:= 0;
349+
LFileStream := TStringStream.Create('', TEncoding.UTF8);
350+
LFileStream.LoadFromStream(FStream);
351+
LFileContent := LFileStream.DataString;
352+
// Save string to local File
353+
LFileName := ChangeFileExt(TPath.GetTempFileName,'.svg');
354+
LFileStream.SaveToFile(LFileName);
355+
bTryAgain := False;
356+
bFail := False;
357+
358+
if FStream.Size < 1024 then
354359
Begin
355-
if Pos(LowerCase('<a href="'), LowerCase(sl.Text)) > 0 then
360+
if Pos('Not Found', LFileContent) > 0 then bFail:= True;
361+
if (Pos(LowerCase('<title>301 Moved Permanently</title>'), LowerCase(LFileContent)) > 0) or
362+
(Pos(LowerCase('<html><body>'), LowerCase(LFileContent)) > 0) then
356363
Begin
357-
LFileName := Copy(sl.Text, Pos('<a href="', sl.Text) + 9, Length(sl.Text));
358-
LFileName := Copy(LFileName, 1, Pos('"', LFileName) -1);
359-
bTryAgain:= True;
360-
End;
364+
if Pos(LowerCase('<a href="'), LowerCase(LFileContent)) > 0 then
365+
Begin
366+
LFileName := Copy(LFileContent, Pos('<a href="', LFileContent) + 9, Length(LFileContent));
367+
LFileName := Copy(LFileName, 1, Pos('"', LFileName) -1);
368+
bTryAgain:= True;
369+
End;
370+
end;
361371
end;
362372
end;
363373

@@ -373,7 +383,7 @@ function TdmResources.getStreamData(const AFileName : String;
373383
finally
374384
LIdSSLIOHandler.Free;
375385
LIdHttp.Free;
376-
sl.Free;
386+
LFileStream.Free;
377387
end;
378388
end;
379389

Source/MDShellExtensions.dproj

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
<Cfg_2>true</Cfg_2>
5454
<Base>true</Base>
5555
</PropertyGroup>
56+
<PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win64)'!=''">
57+
<Cfg_2_Win64>true</Cfg_2_Win64>
58+
<CfgParent>Cfg_2</CfgParent>
59+
<Cfg_2>true</Cfg_2>
60+
<Base>true</Base>
61+
</PropertyGroup>
5662
<PropertyGroup Condition="'$(Base)'!=''">
5763
<SanitizedProjectName>MDShellExtensions</SanitizedProjectName>
5864
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;System.Win;Winapi;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace)</DCC_Namespace>
@@ -109,6 +115,10 @@
109115
<DCC_MapFile>3</DCC_MapFile>
110116
<DCC_LocalDebugSymbols>true</DCC_LocalDebugSymbols>
111117
</PropertyGroup>
118+
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
119+
<VerInfo_Release>3</VerInfo_Release>
120+
<VerInfo_Keys>CompanyName=Ethea S.r.l.;FileDescription=MarkDown Shell Extensions 64bit;FileVersion=2.3.3.0;InternalName=;LegalCopyright=Copyright © 2021-2025 Ethea S.r.l.;LegalTrademarks=;OriginalFilename=;ProductName=MarkDown Shell Extensions 64bit;ProductVersion=2.3;Comments=</VerInfo_Keys>
121+
</PropertyGroup>
112122
<ItemGroup>
113123
<DelphiCompile Include="$(MainSource)">
114124
<MainSource>MainSource</MainSource>
@@ -201,12 +211,25 @@
201211
</Parameters>
202212
<Excluded_Packages>
203213
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\wPDF3_D12.bpl">wPDF V3 - (C) WPCubed GmbH</Excluded_Packages>
214+
<Excluded_Packages Name="$(BDSBIN)\dclofficexp290.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
215+
<Excluded_Packages Name="D:\ETHEA\FGX Native\Libs\290\Win32\Release\FGXNative.Designer.290.bpl">File D:\ETHEA\FGX Native\Libs\290\Win32\Release\FGXNative.Designer.290.bpl not found</Excluded_Packages>
216+
<Excluded_Packages Name="D:\ETHEA\FGX Native\Libs\290\Win32\Release\FGXNative.Registration.290.bpl">FGX Native - Designtime Registration</Excluded_Packages>
204217
<Excluded_Packages Name="$(BDSBIN)\bcbie290.bpl">Embarcadero C++Builder Internet Explorer Components Package</Excluded_Packages>
205218
<Excluded_Packages Name="$(BDSBIN)\bcboffice2k290.bpl">Embarcadero C++Builder Office 2000 Servers Package</Excluded_Packages>
206219
<Excluded_Packages Name="$(BDSBIN)\bcbofficexp290.bpl">Embarcadero C++Builder Office XP Servers Package</Excluded_Packages>
207220
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k290.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
208-
<Excluded_Packages Name="$(BDSBIN)\dclofficexp290.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
221+
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\QR506DesignDXE12.bpl">QuickReport 5.06 Components</Excluded_Packages>
222+
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\dclshlctrls290.bpl">Shell Control Property and Component Editors</Excluded_Packages>
223+
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\dfcstudiowin290.bpl">Woll2Woll FirstClass 4K Sydney</Excluded_Packages>
224+
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\dipstudiowin290.bpl">Woll2Woll InfoPower Studio 4K</Excluded_Packages>
225+
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\kbmMemDesD120Std.bpl">kbmMemTable Standard Edition - High performance memory table - RAD Studio 12 for Win32 - Designtime - www.Components4Developers.com</Excluded_Packages>
226+
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\DCLPsRBD12.bpl">Pragnaan ReportBuilder Export Devices</Excluded_Packages>
227+
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\QImport2DTD12.bpl">EMS Advanced Import Component Suite</Excluded_Packages>
228+
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\QExport3DTD12.bpl">EMS Advanced Export Component Suite</Excluded_Packages>
229+
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\tmsdedXE17.bpl">TMS Component Pack design time support</Excluded_Packages>
230+
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\dGXOutD7.bpl">GExperts Outlookbar design time package</Excluded_Packages>
209231
<Excluded_Packages Name="D:\ETHEA\FGX Native\Libs\290\Win32\Release\FGXNative.Extension.Zint.290.bpl">FGX Native Extension - Zint Barcode</Excluded_Packages>
232+
<Excluded_Packages Name="D:\ETHEA\DevExpressVCL\Library\RS29\cxBDEAdaptersRS29.bpl">BDE Adapters for ExpressDataController by Developer Express Inc.</Excluded_Packages>
210233
</Excluded_Packages>
211234
</Delphi.Personality>
212235
<Platforms>

Source/MDShellExtensions.res

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)