diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-04-28 20:51:37 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-04-28 21:15:31 +0100 |
commit | 4f42beedc34837da5d1f4cc26405e5f998b005d1 (patch) | |
tree | 7d1473f2c6ab5403e1e1a539ac23220951095107 | |
parent | 9a99c835bf35c754d5214b35e65c5eaf80707ab4 (diff) |
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
-rw-r--r-- | sw/source/ui/docvw/AnnotationWin.cxx | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sw/source/ui/docvw/AnnotationWin.cxx b/sw/source/ui/docvw/AnnotationWin.cxx index a4cee7ecee2c..898b73e66bd8 100644 --- a/sw/source/ui/docvw/AnnotationWin.cxx +++ b/sw/source/ui/docvw/AnnotationWin.cxx @@ -86,23 +86,38 @@ SwAnnotationWin::~SwAnnotationWin() 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 Engine()->SetModifyHdl( Link() ); Engine()->EnableUndo( sal_False ); - mpFld = static_cast<SwPostItField*>(mpFmtFld->GetFld()); if( mpFld->GetTextObject() ) Engine()->SetText( *mpFld->GetTextObject() ); else { Engine()->Clear(); GetOutlinerView()->SetAttribs(DefaultItem()); - GetOutlinerView()->InsertText(mpFld->GetPar2(),false); + GetOutlinerView()->InsertText(sNewText,false); } Engine()->ClearModifyFlag(); Engine()->GetUndoManager().Clear(); Engine()->EnableUndo( sal_True ); Engine()->SetModifyHdl( LINK( this, SwAnnotationWin, ModifyHdl ) ); + if (bTextUnchanged) + GetOutlinerView()->GetEditView().SetSelection(aOrigSelection); + if (bCursorVisible) + GetOutlinerView()->ShowCursor(); Invalidate(); } |