102 lines
3.0 KiB
QBasic
102 lines
3.0 KiB
QBasic
![]() |
Attribute VB_Name = "DataAccess"
|
||
|
Option Private Module
|
||
|
Option Explicit
|
||
|
|
||
|
Public Function Globals() As InfoGlobals
|
||
|
Static s_Globals As InfoGlobals
|
||
|
If s_Globals Is Nothing Then _
|
||
|
Set s_Globals = New InfoGlobals
|
||
|
Set Globals = s_Globals
|
||
|
End Function
|
||
|
|
||
|
Public Function AccessArtifact(sPath$, bReadOnly As Boolean) As Object
|
||
|
Dim fso As New Scripting.FileSystemObject
|
||
|
Dim tAppl As TApplication: tAppl = ApplicationFromExtension(fso.GetExtensionName(sPath))
|
||
|
If tAppl = T_APP_UNDEF Then
|
||
|
Debug.Print "Unsupported file extenstion: " & sPath
|
||
|
Exit Function
|
||
|
End If
|
||
|
|
||
|
Dim appWrap As Object: Set appWrap = GetWrapper(tAppl, sPath, bReadOnly)
|
||
|
If appWrap.Document Is Nothing Then _
|
||
|
Exit Function
|
||
|
Set AccessArtifact = appWrap
|
||
|
End Function
|
||
|
|
||
|
Public Function AccessProducts() As DB_Products
|
||
|
Static s_Products As DB_Products
|
||
|
|
||
|
If s_Products Is Nothing Then
|
||
|
Set s_Products = New DB_Products
|
||
|
Call s_Products.Init(ThisWorkbook.Worksheets(SHEET_PRODUCTS), AccessComponents)
|
||
|
End If
|
||
|
|
||
|
Set AccessProducts = s_Products
|
||
|
End Function
|
||
|
|
||
|
Public Function AccessComponents() As DB_Components
|
||
|
Static s_Components As DB_Components
|
||
|
|
||
|
If s_Components Is Nothing Then
|
||
|
Set s_Components = New DB_Components
|
||
|
Call s_Components.Init(ThisWorkbook.Worksheets(SHEET_COMPONENTS))
|
||
|
End If
|
||
|
|
||
|
Set AccessComponents = s_Components
|
||
|
End Function
|
||
|
|
||
|
Public Function AccessTests() As DB_Tests
|
||
|
Static s_Tests As DB_Tests
|
||
|
|
||
|
If s_Tests Is Nothing Then
|
||
|
Set s_Tests = New DB_Tests
|
||
|
Call s_Tests.Init(ThisWorkbook.Worksheets(SHEET_TESTS))
|
||
|
End If
|
||
|
|
||
|
Set AccessTests = s_Tests
|
||
|
End Function
|
||
|
|
||
|
Public Function AccessShared() As DB_SharedModules
|
||
|
Static s_Shared As DB_SharedModules
|
||
|
|
||
|
If s_Shared Is Nothing Then
|
||
|
Set s_Shared = New DB_SharedModules
|
||
|
Call s_Shared.Init(ThisWorkbook.Worksheets(SHEET_SHARED))
|
||
|
End If
|
||
|
|
||
|
Set AccessShared = s_Shared
|
||
|
End Function
|
||
|
|
||
|
Public Function AccessProduct(target$) As IteratorProduct
|
||
|
Dim projects As DB_Products: Set projects = AccessProducts
|
||
|
If Not projects.Contains(target) Then _
|
||
|
Exit Function
|
||
|
Set AccessProduct = projects.Access(target)
|
||
|
End Function
|
||
|
|
||
|
' =======
|
||
|
Private Function GetWrapper(tAppl As TApplication, sPath$, bReadOnly As Boolean) As Object
|
||
|
Select Case tAppl
|
||
|
Case T_APP_WORD
|
||
|
Set GetWrapper = New API_WordWrapper
|
||
|
Call GetWrapper.SetReporter(Globals.Logger)
|
||
|
Call GetWrapper.CreateApplication
|
||
|
Call GetWrapper.OpenDocument(sPath, bReadOnly:=bReadOnly)
|
||
|
|
||
|
Case T_APP_EXCEL
|
||
|
Set GetWrapper = New API_XLWrapper
|
||
|
Call GetWrapper.SetReporter(Globals.Logger)
|
||
|
Call GetWrapper.CreateApplication
|
||
|
Call GetWrapper.OpenDocument(sPath, bReadOnly:=bReadOnly)
|
||
|
|
||
|
Case T_APP_VISIO
|
||
|
Set GetWrapper = New API_VsoWrapper
|
||
|
Call GetWrapper.SetReporter(Globals.Logger)
|
||
|
Call GetWrapper.CreateApplication
|
||
|
Dim nFlags As Integer: nFlags = visOpenDontList + visOpenDeclineAutoRefresh
|
||
|
If bReadOnly Then _
|
||
|
nFlags = nFlags + visOpenRO
|
||
|
Call GetWrapper.OpenDocument(sPath, nFlags)
|
||
|
End Select
|
||
|
End Function
|