[Libreoffice-commits] core.git: Branch 'feature/gsoc14-draw-chained-text-boxes' - include/svx svx/source
matteocam
matteo.campanelli at gmail.com
Thu Jul 23 16:04:34 PDT 2015
include/svx/textchaincursor.hxx | 4 +++
svx/source/svdraw/svdedxv.cxx | 31 +++---------------------
svx/source/svdraw/textchaincursor.cxx | 43 ++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+), 27 deletions(-)
New commits:
commit 70ce299e1a6c4a1d7375ddb089acfb8b60a9e8c8
Author: matteocam <matteo.campanelli at gmail.com>
Date: Fri Jul 24 01:03:58 2015 +0200
Add specific method for cursor event handling
Change-Id: I664e1ac9ac52d7d54e2f3ca35cbb429dc2e131cb
diff --git a/include/svx/textchaincursor.hxx b/include/svx/textchaincursor.hxx
index 456d3c1..ce5200f 100644
--- a/include/svx/textchaincursor.hxx
+++ b/include/svx/textchaincursor.hxx
@@ -31,10 +31,14 @@ public:
TextChainCursorManager(SdrObjEditView *pEditView, const SdrTextObj *pTextObj);
bool HandleKeyEvent( const KeyEvent& rKEvt ) const;
+ void HandleCursorEvent(const CursorChainingEvent aCurEvt,
+ const ESelection aNewSel) const;
private:
SdrObjEditView *mpEditView;
const SdrTextObj *mpTextObj;
+
+ void impChangeEditingTextObj(SdrTextObj *pTargetTextObj, ESelection aNewSel) const;
};
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index fe7f6c4..15e2228 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -536,39 +536,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(SdrObjEditView,ImpOutlinerCalcFieldValueHdl,EditFieldInfo*,pFI)
diff --git a/svx/source/svdraw/textchaincursor.cxx b/svx/source/svdraw/textchaincursor.cxx
index 37b5931..a0def07 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: */
More information about the Libreoffice-commits
mailing list