Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions source/forms/InstallAddInForm.cls
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Attribute VB_Exposed = False
' <license>_codelib/license.bas</license>
' <use>_codelib/addins/shared/AddInConfiguration.cls</use>
' <use>_codelib/addins/shared/AddInInstaller.cls</use>
' <use>base/modApplication.bas</use>
' <use>base/modErrorHandler.bas</use>
'</codelib>
'---------------------------------------------------------------------------------------
'
Expand Down
66 changes: 58 additions & 8 deletions source/modules/ACLibFileManager.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,7 @@ Private Sub ImportVbComponent(ByRef CodeLibInf As CodeLibInfo, ByRef ImportFile
End If

If CodeModuleExists Then ' Change content via CodeModule so that MS add-in for source code management does not cause trouble
' TODO: check if invisible properties changed
Set cm = vbc.CodeModule
cm.DeleteLines 1, cm.CountOfLines
cm.AddFromFile ImportFile.Path
Expand All @@ -1117,7 +1118,7 @@ Private Sub ImportVbComponent(ByRef CodeLibInf As CodeLibInfo, ByRef ImportFile
Loop

Else
VbcCol.import ImportFile.Path
VbcCol.Import ImportFile.Path
End If

End Sub
Expand Down Expand Up @@ -1372,15 +1373,9 @@ Private Sub GetCodeLibInfoFromFile(ByRef CodeLibInf As CodeLibInfo, ByVal InputF
Dim CheckString As String
Dim TempString As String
Dim i As Long
Dim FileNumber As Long
Dim StringCutPos As Long

FileNumber = FreeFile

Open InputFile.Path For Binary Access Read As FileNumber
CheckString = String$(LOF(FileNumber), 0)
Get FileNumber, , CheckString
Close FileNumber
CheckString = ReadSourceFile(InputFile)

'Determine names
CodeLibInf.Name = FindSubString(CheckString, SEARCHSTRING_ATTRIBUTNAME_BEGIN, SEARCHSTRING_ATTRIBUTNAME_END, Pos)
Expand Down Expand Up @@ -1462,6 +1457,61 @@ Private Sub GetCodeLibInfoFromFile(ByRef CodeLibInf As CodeLibInfo, ByVal InputF

End Sub

Private Function ReadSourceFile(ByVal InputFile As Object) As String

Dim FileNumber As Long
Dim StringCutPos As Long
Dim CheckString As String

Dim CheckBytes(1 To 3) As Byte
Dim FileCharset As String

FileNumber = FreeFile

Open InputFile.Path For Binary Access Read As FileNumber

If LOF(FileNumber) >= 3 Then

Get #FileNumber, , CheckBytes

If CheckBytes(1) = &HEF And CheckBytes(2) = &HBB And CheckBytes(3) = &HBF Then
FileCharset = "utf-8"
ElseIf (CheckBytes(1) = &HFF And CheckBytes(2) = &HFE) Or (CheckBytes(1) = &HFE And CheckBytes(2) = &HFF) Then
FileCharset = "utf-16"
Else
Seek #FileNumber, 1
CheckString = String$(LOF(FileNumber), 0)
Get #FileNumber, , CheckString
End If

End If

Close FileNumber

If Len(FileCharset) > 0 Then
CheckString = ReadUtfFileToString(InputFile, FileCharset)
End If

ReadSourceFile = CheckString

End Function

Function ReadUtfFileToString(ByVal InputFile As Object, ByVal FileCharset As String) As String

Dim Stream As Object ' Late Binding für ADODB.Stream
Set Stream = CreateObject("ADODB.Stream")

With Stream
.Type = 2 ' Text
.Charset = FileCharset
.Open
.LoadFromFile InputFile.Path
ReadUtfFileToString = .ReadText
.Close
End With

End Function

Private Sub GetCodeLibInfoPackage(ByRef CodeLibInf As CodeLibInfo, ByRef SourceString As String)
Dim PackageName As String
PackageName = Trim(FindSubString(SourceString, SEARCHSTRING_PACKAGE_BEGIN, SEARCHSTRING_PACKAGE_END))
Expand Down
54 changes: 53 additions & 1 deletion source/modules/ACLibGitHubImporter.cls
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Private m_BranchName As String

#If VBA7 Then
Private Declare PtrSafe Function DeleteUrlCacheEntry Lib "wininet.dll" Alias "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As LongPtr, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As LongPtr) As Long
#Else
Private Declare Function DeleteUrlCacheEntry Lib "wininet.dll" Alias "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Expand Down Expand Up @@ -298,7 +298,59 @@ On Error GoTo 0
End Sub

Private Sub DownloadFileFromWeb(ByVal Url As String, ByVal TargetPath As String)

If FileExists(TargetPath) Then Kill TargetPath
DeleteUrlCacheEntry Url
URLDownloadToFile 0, Url, TargetPath, 0, 0

If IsUTF16(TargetPath) Then 'Forms/Reports
Exit Sub
End If

NormalizeDownloadFile TargetPath ' fix issues with import as module instead of Class

End Sub

Function IsUTF16(ByVal InputFile As String) As Boolean

Dim FileNumber As Integer
Dim CheckByte(1 To 2) As Byte
FileNumber = FreeFile
Open InputFile For Binary Access Read As #FileNumber
If LOF(FileNumber) >= 2 Then
Get #FileNumber, , CheckByte
If (CheckByte(1) = &HFF And CheckByte(2) = &HFE) Or (CheckByte(1) = &HFE And CheckByte(2) = &HFF) Then
IsUTF16 = True
End If
End If
Close #FileNumber

End Function

Sub NormalizeDownloadFile(ByVal InputFile As String)

Dim TextStreamIn As Scripting.TextStream, TextStreamOut As Scripting.TextStream
Dim TempFile As String
Dim TextLine As String

TempFile = InputFile & ".temp"

With New Scripting.FileSystemObject

Set TextStreamIn = .OpenTextFile(InputFile, ForReading, False)
Set TextStreamOut = .OpenTextFile(TempFile, ForWriting, True, TristateUseDefault)

Do While Not TextStreamIn.AtEndOfStream
TextLine = TextStreamIn.ReadLine
TextStreamOut.Write TextLine & vbCrLf
Loop

TextStreamIn.Close
TextStreamOut.Close

.DeleteFile InputFile
.MoveFile TempFile, InputFile

End With

End Sub
1 change: 1 addition & 0 deletions source/modules/AddInInstaller.cls
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Attribute VB_Exposed = False
' <file>_codelib/addins/shared/AddInInstaller.cls</file>
' <license>_codelib/license.bas</license>
' <use>_codelib/addins/shared/AddInConfiguration.cls</use>
' <use>file/FileTools.bas</use>
' <ref><name>DAO</name><major>5</major><minor>0</minor><guid>{00025E01-0000-0000-C000-000000000046}</guid></ref>
'</codelib>
'---------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion source/nav-pane-groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
"Name": "Benutzerdefiniert",
"Flags": 0,
"Position": 3,
"Position": 2,
"Groups": [
{
"Name": "Benutzerdefinierte Gruppe 1",
Expand Down