Bug 125485 - inserting ne TextField.URL failed with expection __main__.IllegalArgumentException
Summary: inserting ne TextField.URL failed with expection __main__.IllegalArgumentExce...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.2.3.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Hyperlink Macro-Python
  Show dependency treegraph
 
Reported: 2019-05-25 10:57 UTC by mt1-wiesent
Modified: 2023-08-18 18:47 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mt1-wiesent 2019-05-25 10:57:32 UTC
Description:
Exception is received with following code:

text = model.Text
wtf = model.createInstance("com.sun.star.text.TextField.URL")
wtf.Representation = "testURL"
wtf.URL = "www.google.de"
curs = text.createTextCursor()
text.insertTextContent(curs, wtf, False)

Traceback (most recent call last):
  File "C:/Users/mt1-w/PycharmProjects/untitled1/test.py", line 73, in <module>
    text.insertTextContent(curs, wtf, False)
__main__.IllegalArgumentException

Other TextFields are working fine.

Steps to Reproduce:
see code from description

Actual Results:
can´t set Hyperlinks by Python script

Expected Results:
execption is caused


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 himajin100000 2019-06-13 07:08:41 UTC
Self-Reminder:

In "com.sun.star.text.TextField.URL" case

Exception is thrown at
https://opengrok.libreoffice.org/xref/core/editeng/source/uno/unofield.cxx?r=966f40ee#668

In "com.sun.star.text.TextField.DateTime" case, the program reaches this line

https://opengrok.libreoffice.org/xref/core/sw/source/core/unocore/unofield.cxx?r=9ff648c6#2039

wnen called from the following line

https://opengrok.libreoffice.org/xref/core/sw/source/core/unocore/unotext.cxx?r=2ddc66e6#618
============================
createInstance related code:
https://opengrok.libreoffice.org/xref/core/sw/source/uibase/uno/unotxdoc.cxx?r=0e27158c#1664
Comment 3 himajin100000 2019-06-17 17:40:42 UTC
Just a guess, not sure:

the argument to attach method is SwXTextRange
and is neither SvxUnoTextRange nor SvxUnoTextRangeBase, which seems often used in editeng ?
Comment 4 mt1-wiesent 2020-03-03 07:57:57 UTC
Short update.
I also tried it with the standard LibreOffice macro language BASIC. But in the end the result is the same. Also when using BASIC I get the IllegalArgumentException. It looks like to me that the UNO interface has a problem here or I´m doing it in the wrong way.
Comment 5 mt1-wiesent 2020-03-03 08:01:26 UTC
I also tried to do it the other way arround.
Generated a odt file with some text hyperlinks, datetime and normal text inside. Then I tried to read all text fields of the document. But only the datetime text fields where shown. The text hyperlinks where not shown.

Please see python sample code.

tf = model.TextFields
tfenum = model.TextFields.createEnumeration()
while tfenum.hasMoreElements():
    tf = tfenum.nextElement()
    print(tf)
Comment 6 Stephan Bergmann 2020-03-04 12:42:44 UTC
> mt1-wiesent@web.de changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>            Assignee|libreoffice-bugs@lists.free |sbergman@redhat.com
>                    |desktop.org                 |

Did you mean to add me to the CC list instead?  Please do not randomly assign bugs to other people.
Comment 7 mt1-wiesent 2020-03-04 15:11:02 UTC
Hello,

The user himajin100000 mentioned that the problem is probably caused by the files unofield.cxx and / or unotext.cxx.

I took a look in the history of these files. You where one of the main editors of these files, so I thought that maybe you can have a look to the reported bug or at least can forward the bug to the right person.

Sorry for assigning this bug to you but I thought your where the right person. 

For a developer with good knowledge of the code, debugging of this bug shouldn´t be difficult. Unfortunatelly, I don´t have a developement setup my own and most of the time I´m programming in C I´m not that aware of C++ code. 

So I´m happy to get some information at least if the bug I found is a real bug or only a user fail by myself.

Thanks
Comment 8 mt1-wiesent 2020-03-04 15:12:09 UTC
(In reply to Stephan Bergmann from comment #6)
> > mt1-wiesent@web.de changed:
> > 
> >            What    |Removed                     |Added
> > ----------------------------------------------------------------------------
> >            Assignee|libreoffice-bugs@lists.free |sbergman@redhat.com
> >                    |desktop.org                 |
> 
> Did you mean to add me to the CC list instead?  Please do not randomly
> assign bugs to other people.

please see my new comment
Comment 9 Stephan Bergmann 2020-03-04 15:27:11 UTC
Sorry, I don't have knowledge about the Writer-specific UNO API and how to use it.  (Assuming this even is about manipulating Writer documents.  The original description does not tell, but it very much looks like it.)
Comment 10 QA Administrators 2022-03-05 03:33:23 UTC
Dear mt1-wiesent,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug