Getting a viewcursor in a RichEditControl

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
taurian
Posts: 1
Joined: Thu Jan 25, 2018 2:17 am

Getting a viewcursor in a RichEditControl

Post by taurian »

I have a Python app using a non modal window with several controls in Writer 5.4.3.
I can manipulate all controls , enter text, handle keystrokes,
create text cursors, etc.
There is one thing i cannot do: create a view cursor
for a richtextcontrol (RTC). I need a view cursor to be able to parse text
at the current cursor location.

Pressing f12 opens the non modal window and populates the RTC (txt.c)
I position the cursor in the RTC and hit ctl-F12 (there are KeyListeners for all controls) which runs code similar to:

Code: Select all

'''
zt.c		# non modal window control
zt.frame	# non modal window frame (zt,txt are class objects)
txt.m		# rich text model
txt.c		# rich text control
'''
txt.c.setText('wwww')   # 'wwww' is seen in the richtextcontrol
##  i thought this would work:
ctlr		=   zt.frame.getController()
txt.c.setText(repr(ctlr))  ## returns: None in the richtextcontrol
cv  	=   ctlr.getViewCursor()
The value of 'ctlr' is 'None', which is not what I want. I need the controller value of the
non-modal window, not the controller of the Writer document, to get a ViewCursor here.
I have used MRI and
reviewed API Reference & Developers Guide & Basic Guide & have A. Pitonyak's book
all to no avail.
I would appreciate any assistance at all on this.
Libreoffice 5.4 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Getting a viewcursor in a RichEditControl

Post by Villeroy »

Service com.sun.star.form.component.RichTextControl is restricted to database forms. What you are using is a com.sun.star.awt.UnoControlEdit without binding to a database.
Attachments
RichTextControl_t92134.odt
(13.94 KiB) Downloaded 247 times
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
Post Reply