delete the next charakter on cursor-position - join paragraphs

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

delete the next charakter on cursor-position - join paragraphs

Christoph Lutz
Hi,

I have got a simple collapsed TextCursor and I would like to delete the next
charakter in a programmatic way without using the dispatch-framework(!). The
function should behave exakt like pressing the "DEL"-Key in a
writer-document. To do that, I tried the following basic code:

REM the cursor is already present
cursor.goRight(1, false)
cursor.goLeft(1, true)
cursor.setString("")

now assume the following text content:

"here is some text<CURSOR_POS><PAR_BREAK>
and this is the next text"

where <CURSOR_POS> is the position of my collapsed TextCursor and
<PAR_BREAK> is a new-paragraph-charakter (shown with view->nonprinting
Charakters).
Now running the above code produces a joined version of both paragraphs
"here is some textand this is the next text", and this is what I want!

But there is one special case in which the above code behaves different from
pressing the DEL-key:

assume the following content:

"here is some text<CURSOR_POS><PAR_BREAK>
<TEXT_TABLE>
<PAR_BREAK>"

where <TEXT_TABLE> is a text-Table inserted directly after the first
paragraph. Pressing the del-key at the <CURSOR_POS> would ignore the
deletion as a texparagraph and a texttable cannot be joined. Wheras running
the above code, deletes the table and thats what I don't want to get.

Any Ideas how to avoid the removal of the texttable (without using the
dispatch-framework!) are welcome

best regards,
Christoph
Reply | Threaded
Open this post in threaded view
|

Re: delete the next charakter on cursor-position - join paragraphs

Stephan Wunderlich - Sun Germany - ham02 - Hamburg
Hi Christoph,

> Any Ideas how to avoid the removal of the texttable (without using the
> dispatch-framework!) are welcome

mmm ... in my OOo 2.0.2 you code works like a charm even with TextTables
... anyway to make a special treatment for them you could do something
like this:

REM the cursor is already present
cursor.goRight(1, false)
cursor.goLeft(1, true)
if (isEmpty(cursor.TextTable) then
        cursor.setString("")
endif

Hope that helps

Regards

Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: delete the next charakter on cursor-position - join paragraphs

Christoph Lutz
Hi Stephan,

On 5/3/06, Stephan Wunderlich <[hidden email]> wrote:

>
> mmm ... in my OOo 2.0.2 you code works like a charm even with TextTables
> ... anyway to make a special treatment for them you could do something
> like this:
>
> REM the cursor is already present
> cursor.goRight(1, false)
> cursor.goLeft(1, true)
> if (isEmpty(cursor.TextTable) then
>         cursor.setString("")
> endif


thanks! this helped. The plot was the used cursor:

if the cursor is a "real" XTextCursor (created with
XText.creatTextCursorByRange(....)) the cursor.goRight(1,false) behaves
different to a XViewCursor (you get using
ThisComponent.CurrentController.getViewCursor):

xTextCursor.goRight(1,false) jumps to the start of the paragraph after the
table, wheras a viewCursor.goRight(1,false) jumps into the first cell of the
textTable. So your Code doesn't work with a xTextCursor and with a
viewCursor the comparison is not needed (as you already mentioned).

I think this is very strange... bug or feature?

Christoph
Reply | Threaded
Open this post in threaded view
|

Re: delete the next charakter on cursor-position - join paragraphs

Stephan Wunderlich - Sun Germany - ham02 - Hamburg
In reply to this post by Christoph Lutz
Hi Christoph,

> I think this is very strange... bug or feature?

I think the two cursors should behave in the same way ... so I'd say it
is worth an issue for further investigation :-)

Regards

Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]