Date: prev next · Thread: first prev next last
2014 Archives by date, by thread · List index


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

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.