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
maIVs = fnFindIV (aQuery)
If UBound (maIVs) = -1 Then
MsgBox "Found no matching IV."
'MsgBox "Found no matching IV."
MsgBox fnGetResString ("msg1000")
Else
subSaveIV (aQuery, maIVs)
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.
Function fnGetImageUrl (sName As String) As String
Dim oRegKey As Object
oRegKey = fnGetRegistryKeyContent (BASE_KEY & "FileResources/" & sName)
fnGetImageUrl = fnExpandMacroFieldExpression (oRegKey.Url)
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
Function fnGetRegistryKeyContent (sKeyName as string, Optional bforUpdate as Boolean)
Dim oConfigProvider As Object
@ -23,12 +31,18 @@ Function fnGetRegistryKeyContent (sKeyName as string, Optional bforUpdate as Boo
aNodePath(0).Name = "nodepath"
aNodePath(0).Value = sKeyName
If IsMissing (bForUpdate) Then
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationAccess", aNodePath())
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _
"com.sun.star.configuration.ConfigurationAccess", _
aNodePath())
Else
If bForUpdate Then
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationUpdateAccess", aNodePath())
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _
"com.sun.star.configuration.ConfigurationUpdateAccess", _
aNodePath())
Else
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationAccess", aNodePath())
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _
"com.sun.star.configuration.ConfigurationAccess", _
aNodePath())
End If
End If
End Function

1
TODO
View File

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

View File

@ -72,7 +72,8 @@ Sub subMain
End If
maIVs = fnFindIV (aQuery)
If UBound (maIVs) = -1 Then
MsgBox "Found no matching IV."
'MsgBox "Found no matching IV."
MsgBox fnGetResString ("msg1000")
Else
subSaveIV (aQuery, maIVs)
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.
Function fnGetImageUrl (sName As String) As String
Dim oRegKey As Object
oRegKey = fnGetRegistryKeyContent (BASE_KEY & "FileResources/" & sName)
fnGetImageUrl = fnExpandMacroFieldExpression (oRegKey.Url)
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
Function fnGetRegistryKeyContent (sKeyName as string, Optional bforUpdate as Boolean)
Dim oConfigProvider As Object
@ -25,12 +33,18 @@ Function fnGetRegistryKeyContent (sKeyName as string, Optional bforUpdate as Boo
aNodePath(0).Name = "nodepath"
aNodePath(0).Value = sKeyName
If IsMissing (bForUpdate) Then
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationAccess", aNodePath())
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _
"com.sun.star.configuration.ConfigurationAccess", _
aNodePath())
Else
If bForUpdate Then
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationUpdateAccess", aNodePath())
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _
"com.sun.star.configuration.ConfigurationUpdateAccess", _
aNodePath())
Else
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationAccess", aNodePath())
fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _
"com.sun.star.configuration.ConfigurationAccess", _
aNodePath())
End If
End If
End Function