[Calc] Text highlighting problem

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
eeigor
Posts: 214
Joined: Sun Apr 12, 2020 10:56 pm

[Calc] Text highlighting problem

Post by eeigor »

Repost: https://ask.libreoffice.org/t/text-high ... blem/66965

Please help to solve the problem of resetting attributes and highlighting the entire text when using a formula (UDF) on the same sheet. It looks like a bug.
The attached example is specially designed for the problem being solved and is presented in a simplified form.
Attachments
bug-highlight-substrings.ods
(19.6 KiB) Downloaded 175 times
Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Calc] Text highlighting problem

Post by Villeroy »

IMHO, this is not a bug. It is a misconception about how Calc is supposed to work. Cell functions deal with values and nothing but values*. Your user defined function is supposed to calculate a return value and nothing else. During this calculation process (which may be part of a huge calculation cascade) everything is locked against changes.

* except built-in STYLE and HYPERLINK which have some side effect on the same formula cell.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Text highlighting problem

Post by JohnSUN-Pensioner »

During the execution of the function, the sheet in which it is located, is blocked from any changes. This avoids many potential errors - for example, computational loops or office crashes due to memory overflows. This restriction does not apply to procedures, for example, to the "Selection changed" event handler, with the help of procedures you can do your trick. Basically, there are some dirty hacks that will allow you to change something on the current sheet using ... uh-uh ... probably not worth writing about this. Just don't try to break this part of Calc, the program is already having a hard time.
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
eeigor
Posts: 214
Joined: Sun Apr 12, 2020 10:56 pm

Re: [Calc] Text highlighting problem

Post by eeigor »

Your comments are very valuable to me.

UPD
+ Link
Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
Post Reply