Help: Get and setting document level user variables doesn’t working before LibreOffice version 4.2.1.1.
Nikunj Banker
Nikunj.Banker at decos.com
Fri May 2 05:15:38 PDT 2014
Dear Libreoffice developer community,
I have just started maintaining one libreoffice plug-in, it has following code which were working before LibreOffice version 4.2.1.1. This code is used to store and retrieve document level information:
'----------------------------------------------------------------------------------------
' FUNCTION: SetUserVariable
' Set Info to the current Document
' Returns: Status;Success or Failure
' Arguments: oDocument Document Object to which info will be stored
' iIndex Index of the Variable where info will get stored
' sVarName Varaible Name to be stored
' aValue Value to be stored
'----------------------------------------------------------------------------------------
Function SetUserVariable(ByVal oDocument As Object, ByVal iIndex As Integer, ByVal sVarName As String, ByVal aValue As Variant) As Boolean
Dim oDocumentInfo As Object
Dim iCnt As Integer
On Error GoTo ErrHandler
If Not IsNull(oDocument) Then
SetUserVariable = False
oDocumentInfo = oDocument.getDocumentInfo()
iCnt = oDocumentInfo.getUserFieldCount()
If iIndex < iCnt Then
oDocumentInfo.setUserFieldName(iIndex, sVarName)
oDocumentInfo.setUserFieldValue(iIndex, aValue)
SetUserVariable = True 'Success Exit Function
End If
End If
Exit Function
ErrHandler:
LogError("DECOSDIRECT.SetUserVariable", Error$, Erl)
SetUserVariable = False
End Function
'----------------------------------------------------------------------------------------
' FUNCTION: GetUserVariable
' Get Info of the current Document
' Returns: Status;Success or Failure and Document Info
' Arguments: oDocument Document Object to which info will be stored
' iIndex Index of the Variable where info will get stored
' sVarName Varaible Name to be stored
' aValue Value which will be returened
'----------------------------------------------------------------------------------------
Function GetUserVariable(ByVal oDocument As Object, ByVal iIndex As Integer, ByVal sVariable As String, ByRef sValue As Variant) As Boolean
Dim vCount As Integer
Dim oDocumentInfo As Object
Dim iCnt As Integer
On Error GoTo ErrHandler
If Not IsNull(oDocument) Then
oDocumentInfo = oDocument.getDocumentInfo()
iCnt = oDocumentInfo.getUserFieldCount()
If iIndex < iCnt Then
If sVariable = oDocumentInfo.getUserFieldName(iIndex) Then
sValue = oDocumentInfo.getUserFieldValue(iIndex)
GetUserVariable = True
Else
GetUserVariable = False
End If
End If
End If
Exit Function
ErrHandler:
LogError("DECOSDIRECT.GetUserVariable", Error$, Erl)
GetUserVariable = False
End Function
Here, oDocument is ‘thisComponent’. In above code red marked methods doesn’t working before LibreOffice version 4.2.1.1. Can you please help us to provide updated API or alternative solution.
The following API not working with latest version of LibreOffice:
oDocumentInfo = oDocument.getDocumentInfo()
iCnt = oDocumentInfo.getUserFieldCount()
oDocumentInfo.getUserFieldName(iIndex)
and
oDocumentInfo.getUserFieldValue(iIndex)
It’s found that these methods/API are depreciated, can you provide new API calls that are necessary to add user properties to a file/document?
Thanks & Regards,
Nikunj Banker
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20140502/f72ffe2d/attachment.html>
More information about the LibreOffice
mailing list