Added a sample project. Updated README to include a link to the Pokémon GO IV calculator as an example project.
This commit is contained in:
19
sample-project/SampleProject/MyModule.vb
Normal file
19
sample-project/SampleProject/MyModule.vb
Normal file
@ -0,0 +1,19 @@
|
||||
' MyModule: The main module of the sample project
|
||||
' by imacat <imacat@mail.imacat.idv.tw>, 2017-08-01
|
||||
|
||||
Option Explicit
|
||||
|
||||
' Main: The main program
|
||||
Sub Main
|
||||
Dim oDialog As Object
|
||||
|
||||
DialogLibraries.loadLibrary "SampleProject"
|
||||
oDialog = CreateUnoDialog (DialogLibraries.SampleProject.MyDialog)
|
||||
' Cancelled
|
||||
If oDialog.execute = 0 Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
|
||||
MsgBox GetResString ("DinnerChoice") & oDialog.getControl ("MenuList1").getSelectedItem
|
||||
End Sub
|
46
sample-project/SampleProject/Registry.vb
Normal file
46
sample-project/SampleProject/Registry.vb
Normal file
@ -0,0 +1,46 @@
|
||||
' Registry: Utilities to access to private configuration
|
||||
' Taken from TextToColumns, 2017-08-02
|
||||
|
||||
Option Explicit
|
||||
|
||||
' TODO: Replace SampleProject with your own project name
|
||||
Const BASE_KEY As String = "/org.openoffice.Office.Addons.SampleProject.AddonConfiguration/"
|
||||
|
||||
' GetImageUrl: Returns the image URL for the UNO image controls.
|
||||
Function GetImageUrl (sName As String) As String
|
||||
BasicLibraries.loadLibrary "Tools"
|
||||
Dim oRegKey As Object
|
||||
|
||||
oRegKey = GetRegistryKeyContent (BASE_KEY & "FileResources/" & sName)
|
||||
GetImageUrl = ExpandMacroFieldExpression (oRegKey.Url)
|
||||
End Function
|
||||
|
||||
' GetResString: Returns the localized text string.
|
||||
Function GetResString (sID As String) As String
|
||||
BasicLibraries.loadLibrary "Tools"
|
||||
Dim oRegKey As Object
|
||||
|
||||
oRegKey = GetRegistryKeyContent (BASE_KEY & "Messages/" & sID)
|
||||
GetResString = oRegKey.Text
|
||||
End Function
|
||||
|
||||
' ExpandMacroFieldExpression
|
||||
Function ExpandMacroFieldExpression (sURL As String) As String
|
||||
Dim sTemp As String
|
||||
Dim oSM As Object
|
||||
Dim oMacroExpander As Object
|
||||
|
||||
' Gets the service manager
|
||||
oSM = getProcessServiceManager
|
||||
' Gets the macro expander
|
||||
oMacroExpander = oSM.DefaultContext.getValueByName ( _
|
||||
"/singletons/com.sun.star.util.theMacroExpander")
|
||||
|
||||
'cut the vnd.sun.star.expand: part
|
||||
sTemp = Join (Split (sURL, "vnd.sun.star.expand:"))
|
||||
|
||||
'Expand the macrofield expression
|
||||
sTemp = oMacroExpander.ExpandMacros (sTemp)
|
||||
sTemp = Trim (sTemp)
|
||||
ExpandMacroFieldExpression = sTemp
|
||||
End Function
|
Reference in New Issue
Block a user