Kaydet (Commit) 4f42beed authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: fdo#33599 cursor in notes is reset to start on focus out/focus in

SidebarTxtControl::LoseFocus calls mrSidebarWin.UpdateData which takes the text
from the postit if the postit has been modified and updates the field from it.
That updates all listeners of that field which includes the postit itself,
which in response updates its content from the field, which causes the cursor
to be disabled, i.e the original contents have been removed and replaced with
identical content, but the selection has been invalidated.

Change-Id: Idcde25a85a3a657a6057e70a59e2219e224e009e
üst 9a99c835
...@@ -86,23 +86,38 @@ SwAnnotationWin::~SwAnnotationWin() ...@@ -86,23 +86,38 @@ SwAnnotationWin::~SwAnnotationWin()
void SwAnnotationWin::SetPostItText() void SwAnnotationWin::SetPostItText()
{ {
//If the cursor was visible, then make it visible again after
//changing text, e.g. fdo#33599
Cursor *pCursor = GetOutlinerView()->GetEditView().GetCursor();
bool bCursorVisible = pCursor ? pCursor->IsVisible() : false;
//If the new text is the same as the old text, keep the same insertion
//point .e.g. fdo#33599
mpFld = static_cast<SwPostItField*>(mpFmtFld->GetFld());
rtl::OUString sNewText = mpFld->GetPar2();
bool bTextUnchanged = sNewText.equals(Engine()->GetEditEngine().GetText());
ESelection aOrigSelection(GetOutlinerView()->GetEditView().GetSelection());
// get text from SwPostItField and insert into our textview // get text from SwPostItField and insert into our textview
Engine()->SetModifyHdl( Link() ); Engine()->SetModifyHdl( Link() );
Engine()->EnableUndo( sal_False ); Engine()->EnableUndo( sal_False );
mpFld = static_cast<SwPostItField*>(mpFmtFld->GetFld());
if( mpFld->GetTextObject() ) if( mpFld->GetTextObject() )
Engine()->SetText( *mpFld->GetTextObject() ); Engine()->SetText( *mpFld->GetTextObject() );
else else
{ {
Engine()->Clear(); Engine()->Clear();
GetOutlinerView()->SetAttribs(DefaultItem()); GetOutlinerView()->SetAttribs(DefaultItem());
GetOutlinerView()->InsertText(mpFld->GetPar2(),false); GetOutlinerView()->InsertText(sNewText,false);
} }
Engine()->ClearModifyFlag(); Engine()->ClearModifyFlag();
Engine()->GetUndoManager().Clear(); Engine()->GetUndoManager().Clear();
Engine()->EnableUndo( sal_True ); Engine()->EnableUndo( sal_True );
Engine()->SetModifyHdl( LINK( this, SwAnnotationWin, ModifyHdl ) ); Engine()->SetModifyHdl( LINK( this, SwAnnotationWin, ModifyHdl ) );
if (bTextUnchanged)
GetOutlinerView()->GetEditView().SetSelection(aOrigSelection);
if (bCursorVisible)
GetOutlinerView()->ShowCursor();
Invalidate(); Invalidate();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment