Good afternoon.
Base is saving entries like (ã) as (%C3%A3). How can I fix this?
Thank you so much!
EDIT:
It happens only when I use Filepicker to fill some fields.
Thank you again.
Good afternoon.
Base is saving entries like (ã) as (%C3%A3). How can I fix this?
Thank you so much!
EDIT:
It happens only when I use Filepicker to fill some fields.
Thank you again.
This looks like a problem with charsets, where you “see” unicode-encoding of umlauts.
.
As you mentioned file-picker: Any URL-encoding involved?
.
How exactly do you fill your fields and what kind of database do you use?
This is the Macro to get the text from the Filepicker, has to change it to local path, instead of URL, and break it to fill three columns.
I’m using HSQLDB 2.5.1 external. It’s called Split, isn’t it?
' Converte URL "file:///" para caminho do Windows
Function URLToPath(sURL As String) As String
If Left(sURL, 8) = "file:///" Then
sURL = Mid(sURL, 9)
End If
sURL = Replace(sURL, "/", "\") ' Windows
URLToPath = sURL
End Function
Sub SelecionarFicheiroPreencherLinhaAtual(oEvent As Object)
Dim oForm As Object
Dim oDialog As Object
Dim sFile As String, sFilePath As String
Dim sNome As String, sCaminho As String, sExt As String
Dim iPos As Long, iExt As Long
Dim iTipoID As Long
Dim oDB As Object, oResult As Object
' Obter o SubForm ligado à tabela ARQUIVO
oForm = ThisComponent.DrawPage.Forms.getByName("Form_Desenho").getByName("Sub_Arquivos")
' Criar FilePicker
oDialog = CreateUnoService("com.sun.star.ui.dialogs.FilePicker")
oDialog.initialize(Array(com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE))
' Filtros básicos
oDialog.appendFilter("Todos os ficheiros", "*.*")
' Executar FilePicker
If oDialog.execute() = com.sun.star.ui.dialogs.ExecutableDialogResults.OK Then
sFile = oDialog.getFiles()(0)
' Converter URL para caminho do sistema
If Left(sFile, 8) = "file:///" Then sFile = Mid(sFile, 9)
sFilePath = Replace(sFile, "/", "\")
' Extrair caminho e nome do ficheiro
iPos = GetLastPos(sFilePath, "\")
sCaminho = Left(sFilePath, iPos - 1)
sNome = Mid(sFilePath, iPos + 1)
' Extrair extensão
iExt = GetLastPos(sNome, ".")
If iExt > 0 Then
sExt = LCase(Mid(sNome, iExt + 1))
Else
sExt = ""
End If
' Obter ID do tipo de ficheiro
oDB = ThisDatabaseDocument.CurrentController.ActiveConnection
oResult = oDB.createStatement().executeQuery("SELECT ID_TIPO_ARQUIVO FROM TIPO_ARQUIVO WHERE EXTENSAO = '" & sExt & "'")
If oResult.next() Then
iTipoID = oResult.getInt(1)
Else
MsgBox "Extensão não encontrada em TIPO_ARQUIVO: " & sExt
Exit Sub
End If
' Atualizar registo atual em vez de criar novo
oForm.getColumns().getByName("CAMINHO").updateString(sCaminho)
oForm.getColumns().getByName("NOME_ARQUIVO").updateString(sNome)
oForm.getColumns().getByName("TIPO_ARQUIVO").updateInt(iTipoID)
' O Base grava as alterações automáticamente ao mudar de linha
'oForm.updateRow() Não é preciso
End If
End Sub
Exactly. And that is not just “cut file:///
and replace slashes to backslashes”. We have a dedicated function for that, which also decodes the percent encoding used in URLs.
Thank you!
Work like a charm!