@@ -1100,6 +1100,7 @@ Private Sub ImportVbComponent(ByRef CodeLibInf As CodeLibInfo, ByRef ImportFile
11001100 End If
11011101
11021102 If CodeModuleExists Then ' Change content via CodeModule so that MS add-in for source code management does not cause trouble
1103+ ' TODO: check if invisible properties changed
11031104 Set cm = vbc.CodeModule
11041105 cm.DeleteLines 1 , cm.CountOfLines
11051106 cm.AddFromFile ImportFile.Path
@@ -1117,7 +1118,7 @@ Private Sub ImportVbComponent(ByRef CodeLibInf As CodeLibInfo, ByRef ImportFile
11171118 Loop
11181119
11191120 Else
1120- VbcCol.import ImportFile.Path
1121+ VbcCol.Import ImportFile.Path
11211122 End If
11221123
11231124End Sub
@@ -1372,15 +1373,9 @@ Private Sub GetCodeLibInfoFromFile(ByRef CodeLibInf As CodeLibInfo, ByVal InputF
13721373 Dim CheckString As String
13731374 Dim TempString As String
13741375 Dim i As Long
1375- Dim FileNumber As Long
13761376 Dim StringCutPos As Long
13771377
1378- FileNumber = FreeFile
1379-
1380- Open InputFile.Path For Binary Access Read As FileNumber
1381- CheckString = String $(LOF(FileNumber), 0 )
1382- Get FileNumber, , CheckString
1383- Close FileNumber
1378+ CheckString = ReadSourceFile(InputFile)
13841379
13851380 'Determine names
13861381 CodeLibInf.Name = FindSubString(CheckString, SEARCHSTRING_ATTRIBUTNAME_BEGIN, SEARCHSTRING_ATTRIBUTNAME_END, Pos)
@@ -1462,6 +1457,61 @@ Private Sub GetCodeLibInfoFromFile(ByRef CodeLibInf As CodeLibInfo, ByVal InputF
14621457
14631458End Sub
14641459
1460+ Private Function ReadSourceFile (ByVal InputFile As Object ) As String
1461+
1462+ Dim FileNumber As Long
1463+ Dim StringCutPos As Long
1464+ Dim CheckString As String
1465+
1466+ Dim CheckBytes(1 To 3 ) As Byte
1467+ Dim FileCharset As String
1468+
1469+ FileNumber = FreeFile
1470+
1471+ Open InputFile.Path For Binary Access Read As FileNumber
1472+
1473+ If LOF(FileNumber) >= 3 Then
1474+
1475+ Get #FileNumber, , CheckBytes
1476+
1477+ If CheckBytes(1 ) = &HEF And CheckBytes(2 ) = &HBB And CheckBytes(3 ) = &HBF Then
1478+ FileCharset = "utf-8"
1479+ ElseIf (CheckBytes(1 ) = &HFF And CheckBytes(2 ) = &HFE ) Or (CheckBytes(1 ) = &HFE And CheckBytes(2 ) = &HFF ) Then
1480+ FileCharset = "utf-16"
1481+ Else
1482+ Seek #FileNumber, 1
1483+ CheckString = String $(LOF(FileNumber), 0 )
1484+ Get #FileNumber, , CheckString
1485+ End If
1486+
1487+ End If
1488+
1489+ Close FileNumber
1490+
1491+ If Len(FileCharset) > 0 Then
1492+ CheckString = ReadUtfFileToString(InputFile, FileCharset)
1493+ End If
1494+
1495+ ReadSourceFile = CheckString
1496+
1497+ End Function
1498+
1499+ Function ReadUtfFileToString (ByVal InputFile As Object , ByVal FileCharset As String ) As String
1500+
1501+ Dim Stream As Object ' Late Binding für ADODB.Stream
1502+ Set Stream = CreateObject("ADODB.Stream" )
1503+
1504+ With Stream
1505+ .Type = 2 ' Text
1506+ .Charset = FileCharset
1507+ .Open
1508+ .LoadFromFile InputFile.Path
1509+ ReadUtfFileToString = .ReadText
1510+ .Close
1511+ End With
1512+
1513+ End Function
1514+
14651515Private Sub GetCodeLibInfoPackage (ByRef CodeLibInf As CodeLibInfo , ByRef SourceString As String )
14661516 Dim PackageName As String
14671517 PackageName = Trim(FindSubString(SourceString, SEARCHSTRING_PACKAGE_BEGIN, SEARCHSTRING_PACKAGE_END))
0 commit comments