Localized the error message.

This commit is contained in:
依瑪貓 2016-12-07 16:37:48 +08:00
parent 8caef506b4
commit cd7954c32f
5 changed files with 40 additions and 11 deletions

View File

@ -70,7 +70,8 @@ Sub subMain
End If End If
maIVs = fnFindIV (aQuery) maIVs = fnFindIV (aQuery)
If UBound (maIVs) = -1 Then If UBound (maIVs) = -1 Then
MsgBox "Found no matching IV." 'MsgBox "Found no matching IV."
MsgBox fnGetResString ("msg1000")
Else Else
subSaveIV (aQuery, maIVs) subSaveIV (aQuery, maIVs)
End If End If

View File

@ -8,11 +8,19 @@ Const BASE_KEY As String = "/org.openoffice.Office.Addons.PokemonGoIV.AddonConfi
' fnGetImageUrl: Returns the image URL for the UNO image controls. ' fnGetImageUrl: Returns the image URL for the UNO image controls.
Function fnGetImageUrl (sName As String) As String Function fnGetImageUrl (sName As String) As String
Dim oRegKey As Object Dim oRegKey As Object
oRegKey = fnGetRegistryKeyContent (BASE_KEY & "FileResources/" & sName) oRegKey = fnGetRegistryKeyContent (BASE_KEY & "FileResources/" & sName)
fnGetImageUrl = fnExpandMacroFieldExpression (oRegKey.Url) fnGetImageUrl = fnExpandMacroFieldExpression (oRegKey.Url)
End Function End Function
' fnGetResString: Returns the localized text string.
Function fnGetResString (sID As String) As String
Dim oRegKey As Object
oRegKey = fnGetRegistryKeyContent (BASE_KEY & "Messages/" & sID)
fnGetResString = oRegKey.Text
End Function
' fnGetRegistryKeyContent: Returns the registry key content ' fnGetRegistryKeyContent: Returns the registry key content
Function fnGetRegistryKeyContent (sKeyName as string, Optional bforUpdate as Boolean) Function fnGetRegistryKeyContent (sKeyName as string, Optional bforUpdate as Boolean)
Dim oConfigProvider As Object Dim oConfigProvider As Object
@ -23,12 +31,18 @@ Function fnGetRegistryKeyContent (sKeyName as string, Optional bforUpdate as Boo
aNodePath(0).Name = "nodepath" aNodePath(0).Name = "nodepath"
aNodePath(0).Value = sKeyName aNodePath(0).Value = sKeyName
If IsMissing (bForUpdate) Then If IsMissing (bForUpdate) Then
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationAccess", aNodePath()) fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _
"com.sun.star.configuration.ConfigurationAccess", _
aNodePath())
Else Else
If bForUpdate Then If bForUpdate Then
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationUpdateAccess", aNodePath()) fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _
"com.sun.star.configuration.ConfigurationUpdateAccess", _
aNodePath())
Else Else
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationAccess", aNodePath()) fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _
"com.sun.star.configuration.ConfigurationAccess", _
aNodePath())
End If End If
End If End If
End Function End Function

1
TODO
View File

@ -1,5 +1,4 @@
PokemonGoIV TODO PokemonGoIV TODO
* Error messages.
* Show images of teams, team leaders and Pokémons. * Show images of teams, team leaders and Pokémons.
* Center the dialog. * Center the dialog.

View File

@ -72,7 +72,8 @@ Sub subMain
End If End If
maIVs = fnFindIV (aQuery) maIVs = fnFindIV (aQuery)
If UBound (maIVs) = -1 Then If UBound (maIVs) = -1 Then
MsgBox "Found no matching IV." 'MsgBox "Found no matching IV."
MsgBox fnGetResString ("msg1000")
Else Else
subSaveIV (aQuery, maIVs) subSaveIV (aQuery, maIVs)
End If End If

View File

@ -10,11 +10,19 @@ Const BASE_KEY As String = "/org.openoffice.Office.Addons.PokemonGoIV.Addon
' fnGetImageUrl: Returns the image URL for the UNO image controls. ' fnGetImageUrl: Returns the image URL for the UNO image controls.
Function fnGetImageUrl (sName As String) As String Function fnGetImageUrl (sName As String) As String
Dim oRegKey As Object Dim oRegKey As Object
oRegKey = fnGetRegistryKeyContent (BASE_KEY & "FileResources/" & sName) oRegKey = fnGetRegistryKeyContent (BASE_KEY & "FileResources/" & sName)
fnGetImageUrl = fnExpandMacroFieldExpression (oRegKey.Url) fnGetImageUrl = fnExpandMacroFieldExpression (oRegKey.Url)
End Function End Function
' fnGetResString: Returns the localized text string.
Function fnGetResString (sID As String) As String
Dim oRegKey As Object
oRegKey = fnGetRegistryKeyContent (BASE_KEY & "Messages/" & sID)
fnGetResString = oRegKey.Text
End Function
' fnGetRegistryKeyContent: Returns the registry key content ' fnGetRegistryKeyContent: Returns the registry key content
Function fnGetRegistryKeyContent (sKeyName as string, Optional bforUpdate as Boolean) Function fnGetRegistryKeyContent (sKeyName as string, Optional bforUpdate as Boolean)
Dim oConfigProvider As Object Dim oConfigProvider As Object
@ -25,12 +33,18 @@ Function fnGetRegistryKeyContent (sKeyName as string, Optional bforUpdate as Boo
aNodePath(0).Name = "nodepath" aNodePath(0).Name = "nodepath"
aNodePath(0).Value = sKeyName aNodePath(0).Value = sKeyName
If IsMissing (bForUpdate) Then If IsMissing (bForUpdate) Then
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationAccess", aNodePath()) fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _
"com.sun.star.configuration.ConfigurationAccess", _
aNodePath())
Else Else
If bForUpdate Then If bForUpdate Then
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationUpdateAccess", aNodePath()) fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _
"com.sun.star.configuration.ConfigurationUpdateAccess", _
aNodePath())
Else Else
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationAccess", aNodePath()) fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _
"com.sun.star.configuration.ConfigurationAccess", _
aNodePath())
End If End If
End If End If
End Function End Function