[Libreoffice-bugs] [Bug 139829] New: User defined function malfunction after opening Calc document
bugzilla-daemon at bugs.documentfoundation.org
bugzilla-daemon at bugs.documentfoundation.org
Fri Jan 22 10:09:08 UTC 2021
https://bugs.documentfoundation.org/show_bug.cgi?id=139829
Bug ID: 139829
Summary: User defined function malfunction after opening Calc
document
Product: LibreOffice
Version: 6.4.7.2 release
Hardware: All
OS: Windows (All)
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: BASIC
Assignee: libreoffice-bugs at lists.freedesktop.org
Reporter: yestok at yestok.pl
Description:
I have written a user function to obtain selected information about a document.
Here it is:
Function DokInfo(optional info, Optional styl)
REM The function returns the document information indicated by the parameter.
REM the "info" argument must be the text:
REM "AutorO" - gives the author of the document.
REM "Utworzony" - document creation date.
REM "Zmodyfikowany" - date of last modification.
REM "AutorM" - author of the last modification.
REM "Ile" - Number of sessions with the document.
REM "Czas" - total working time on the document.
REM styl, if present, must be one of the acceptable formats
REM presentation of date and / or time given as text as in the TEXT () function
Dim oData As Object, oDoc As Object
If isMissing(info) Or isArray(info) Then DokInfo="Zły argument" : Stop 'Bad
argument
If IsMissing(styl) Then styl="Standard"
oDoc=ThisComponent
On Local Error GoTo niemodyfikowany
oDoc=oDoc.DocumentProperties
info=UCase(info)
With oDoc
Select Case info
Case "AUTORO" ' - gives the author of the
document.
DokInfo= .Author
Case "UTWORZONY" ' - document creation date.
oData=.CreationDate
GoSub kiedy
Case "ZMODYFIKOWANY" ' - date of last modification.
oData=.ModificationDate
GoSub kiedy
Case "AUTORM" ' - author of the last
modification.
DokInfo=.ModifiedBy
Case "ILE" ' - Number of sessions with the
document.
DokInfo=.EditingCycles
Case "CZAS" ' - total working time on the
document.
DokInfo=Format(.EditingDuration/86400,Iif(styl="Standard","[h]:mm:ss",styl))
Case Else
DokInfo="Zły argument" 'Bad argument
End Select
End With
Exit Function
kiedy:
With oData
DokInfo=Format(DateSerial(.Year,.Month,.Day)+TimeSerial(.hours,.minutes,.seconds),styl)
End With
Return
niemodyfikowany:
DokInfo="Dokument nie był modyfikowany" 'The document was not modified
End Function
If I save the function together with the document in the document container, it
works fine.
If a function is placed in the "My Macros" container, then after loading the
file in which the function was used, it does not determine the correct
information. They will appear only after the file is forced to be reloaded, or
after the cell with the function is forcibly moved to another place or its
contents copied (e.g. to itself).
While looking for a solution to the problem, I wrote another simple function.
Test function (Optional wrs, Optional kol)
If isMissing (wrs) Then wrs = 0
If IsMissing (col) Then col = 0
test = thisComponent.Sheets (0) .GetCellByPosition (kol, wrs) .String
End function
It turns out that after loading the file, it also does not return any result if
it is in the "My Macros" container and document must be reloaded for good
results.
What could be the reason for this action?
Steps to Reproduce:
1. Add the attached function (eg test) to the "Standard" library in the "My
Macros" container.
2. Create a Calc document where you will apply this feature.
3. Save the document and close it.
4. Open the document again.
Actual Results:
The cell containing the function displays no value (function test) or contains
false values (function DokInfo).
Expected Results:
The result of the function should be displayed. It will only appear after
reloading the file.
Reproducible: Always
User Profile Reset: No
Additional Info:
Such an action appears in many colleagues on the LibreOffice forum.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20210122/1a1bf252/attachment.htm>
More information about the Libreoffice-bugs
mailing list