Hi,
Maximilian Odendahl wrote:
Hi there,
I want to insert a field and then jump back, so my cursor is
positioned just in front of the inserted field:
aFldMgr.InsertFld(aData);
rSh.Push();
rSh.SwCrsrShell::Left(1, CRSR_SKIP_CHARS, FALSE);
pPostIt = (SwPostItField*)aFldMgr.GetCurFld();
rSh.Pop(FALSE);
This works fine, but not if there is a selection. I changed the code
so the selection is not deleted, so the field is inserted at the
beginning.
But I am not able to position the cursor now in front of the field,
this should work no matter if the actual cursor is at the start or end
of the selection.
So I need sth. like
aFldMgr.InsertFld(aData);
This call replaces the selection with the field.
rSh.Push();
if (rSh.HasSelection())
??????????
You will probably never get here.
else
rSh.SwCrsrShell::Left(1, CRSR_SKIP_CHARS, FALSE);
pPostIt = (SwPostItField*)aFldMgr.GetCurFld();
rSh.Pop(FALSE);
Can anyone help out?
Something like this should do what you want (I didn't try) :
rSh.Push();
if( rSh.HasSelection() )
{
rSh.NormalizePam( - true/false depending on insert before or after
the selection - )
rSh.ClearMark();
}
aFldMgr.InsertFld(aData);
rSh.SwCrsrShell::Left(1, CRSR_SKIP_CHARS, FALSE);
pPostIt = (SwPostItField*)aFldMgr.GetCurFld();
rSh.Pop(FALSE);
Multiple selection and table selections need additional handling.
Regards,
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]