diff options
author | matteocam <matteo.campanelli@gmail.com> | 2015-07-24 01:03:58 +0200 |
---|---|---|
committer | matteocam <matteo.campanelli@gmail.com> | 2015-07-31 12:16:13 +0200 |
commit | 0f29998d8bf8e719fbc534a5e0880acbe3a6be27 (patch) | |
tree | 1a061bb735ed89ecc65b6b3a2f7bc2b4b10e1f4d /svx | |
parent | 1780d2ce92b8b15551e9a199615885bd20bf5fa7 (diff) |
Add specific method for cursor event handling
Change-Id: I664e1ac9ac52d7d54e2f3ca35cbb429dc2e131cb
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdedxv.cxx | 31 | ||||
-rw-r--r-- | svx/source/svdraw/textchaincursor.cxx | 43 |
2 files changed, 47 insertions, 27 deletions
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index afbf3cf5c8f4..27db21de41e7 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -543,39 +543,16 @@ void SdrObjEditView::ImpMoveCursorAfterChainingEvent() if (!pTextObj->IsChainable() || !pTextObj->GetNextLinkInChain()) return; - - SdrTextObj *pNextLink = pTextObj->GetNextLinkInChain(); - OutlinerView* pOLV = GetTextEditOutlinerView(); - TextChain *pTextChain = pTextObj->GetTextChain(); ESelection aNewSel = pTextChain->GetPostChainingSel(pTextObj); - switch ( pTextChain->GetCursorEvent(pTextObj) ) { - - case CursorChainingEvent::UNCHANGED: - // Set same selection as before the chaining (which is saved as PostChainingSel) - // We need an explicit set because the Outliner is messed up - // after text transfer and otherwise it brings us at arbitrary positions. - pOLV->SetSelection(aNewSel); - break; - case CursorChainingEvent::TO_NEXT_LINK: - SdrEndTextEdit(); - SdrBeginTextEdit(pNextLink); - // OutlinerView has changed, so we update the pointer - pOLV = GetTextEditOutlinerView(); - pOLV->SetSelection(aNewSel); // XXX - break; - case CursorChainingEvent::TO_PREV_LINK: - // XXX: To be handled - break; - case CursorChainingEvent::NULL_EVENT: - // Do nothing here - break; - } + TextChainCursorManager aCursorManager(this, pTextObj); + aCursorManager.HandleCursorEvent( + pTextChain->GetCursorEvent(pTextObj), + aNewSel); // Reset event pTextChain->SetCursorEvent(pTextObj, CursorChainingEvent::NULL_EVENT); - } IMPL_LINK_TYPED(SdrObjEditView,ImpOutlinerCalcFieldValueHdl,EditFieldInfo*,pFI,void) diff --git a/svx/source/svdraw/textchaincursor.cxx b/svx/source/svdraw/textchaincursor.cxx index 37b5931ac437..a0def0741a65 100644 --- a/svx/source/svdraw/textchaincursor.cxx +++ b/svx/source/svdraw/textchaincursor.cxx @@ -22,6 +22,10 @@ #include <svx/svdedxv.hxx> #include <svx/svdoutl.hxx> +// XXX: Possible duplication of code in behavior with stuff in ImpEditView (or ImpEditEngine) and OutlinerView + +// XXX: We violate Demeter's Law several times here, I'm afraid + TextChainCursorManager::TextChainCursorManager(SdrObjEditView *pEditView, const SdrTextObj *pTextObj) : mpEditView(pEditView), mpTextObj(pTextObj) @@ -66,4 +70,43 @@ bool TextChainCursorManager::HandleKeyEvent( const KeyEvent& rKEvt ) const return bHandled; } +void TextChainCursorManager::HandleCursorEvent(const CursorChainingEvent aCurEvt, + const ESelection aNewSel) const +{ + OutlinerView* pOLV = mpEditView->GetTextEditOutlinerView(); + SdrTextObj *pNextLink = mpTextObj->GetNextLinkInChain(); + SdrTextObj *pPrevLink = mpTextObj->GetPrevLinkInChain(); + + switch ( aCurEvt ) { + case CursorChainingEvent::UNCHANGED: + // Set same selection as before the chaining (which is saved as PostChainingSel) + // We need an explicit set because the Outliner is messed up + // after text transfer and otherwise it brings us at arbitrary positions. + pOLV->SetSelection(aNewSel); + break; + case CursorChainingEvent::TO_NEXT_LINK: + impChangeEditingTextObj(pNextLink, aNewSel); + break; + case CursorChainingEvent::TO_PREV_LINK: + impChangeEditingTextObj(pPrevLink, aNewSel); + break; + case CursorChainingEvent::NULL_EVENT: + // Do nothing here + break; + } + +} + +void TextChainCursorManager::impChangeEditingTextObj(SdrTextObj *pTargetTextObj, ESelection aNewSel) const +{ + if (!pTargetTextObj) + return; + + mpEditView->SdrEndTextEdit(); + mpEditView->SdrBeginTextEdit(pTargetTextObj); + // OutlinerView has changed, so we update the pointer + OutlinerView *pOLV = mpEditView->GetTextEditOutlinerView(); + pOLV->SetSelection(aNewSel); // XXX +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |