include/svx/textchaincursor.hxx | 15 +++++++++- svx/source/svdraw/svdedxv.cxx | 48 ++++++---------------------------- svx/source/svdraw/textchaincursor.cxx | 44 ++++++++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 42 deletions(-)
New commits: commit cdc0e22b54d8b2c20950a955070488c5603e66c0 Author: matteocam <matteo.campane...@gmail.com> Date: Thu Jul 23 23:46:47 2015 +0200 Move code for right motion into TextChainCursorManager Change-Id: Ifa6aecbd2c55763583f2d48b0883698f876cbc6c diff --git a/include/svx/textchaincursor.hxx b/include/svx/textchaincursor.hxx index 71dbc60..456d3c1 100644 --- a/include/svx/textchaincursor.hxx +++ b/include/svx/textchaincursor.hxx @@ -20,10 +20,21 @@ #ifndef INCLUDED_SVX_TEXTCHAINCURSOR_HXX #define INCLUDED_SVX_TEXTCHAINCURSOR_HXX +class SdrObjEditView; +class SdrTextObj; +class KeyEvent; -class TextChainCursorHandler + +class TextChainCursorManager { - TextChainCursorHandler(); +public: + TextChainCursorManager(SdrObjEditView *pEditView, const SdrTextObj *pTextObj); + + bool HandleKeyEvent( const KeyEvent& rKEvt ) const; + +private: + SdrObjEditView *mpEditView; + const SdrTextObj *mpTextObj; }; diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index 180ae2e..89e4902 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -52,6 +52,7 @@ #include "svdglob.hxx" #include "svx/globl3d.hxx" #include <svx/textchain.hxx> +#include <svx/textchaincursor.hxx> #include <editeng/outliner.hxx> #include <editeng/adjustitem.hxx> #include <svtools/colorcfg.hxx> @@ -1282,49 +1283,20 @@ bool SdrObjEditView::IsTextEditFrameHit(const Point& rHit) const bool SdrObjEditView::ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) { - // XXX: Find a clean way to do this (even cleaner than the code commented below) - // if( pTextEditOutlinerView->IsKeyEventPushingOutOfPage(rKevt, pWin) - // pWin = HandleKeyPushingOutOfBox(rKevt); - KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction(); - sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); - ESelection aCurSel = pTextEditOutlinerView->GetSelection(); - - SdrTextObj* pTextObj = NULL; if (mxTextEditObj.is()) pTextObj= dynamic_cast<SdrTextObj*>(mxTextEditObj.get()); + else + return false; - bool bHandled = false; - - // XXX: Add check for last position in the para - if (pTextObj && pTextObj->IsChainable() && pTextObj->GetNextLinkInChain() && - eFunc == KeyFuncType::DONTKNOW) - { - SdrOutliner *pOutl = GetTextEditOutliner(); - sal_Int32 nLastPara = pOutl->GetParagraphCount()-1; - OUString aLastParaText = pOutl->GetText(pOutl->GetParagraph(nLastPara)); - sal_Int32 nLastParaLen = aLastParaText.getLength(); - - if (nCode == KEY_RIGHT && - aCurSel.nEndPara == nLastPara && - aCurSel.nEndPos == nLastParaLen - ) - { - fprintf(stderr, "[CHAIN - CURSOR] Trying to move to next box\n" ); - - // Move to next box - SdrEndTextEdit(); - SdrTextObj *pNextLink = pTextObj->GetNextLinkInChain(); - SdrBeginTextEdit(pNextLink); - bHandled = true; - } - + TextChainCursorManager aCursorManager(this, pTextObj); + if( aCursorManager.HandleKeyEvent(rKEvt) ) { + // Possibly do other stuff here if necessary... // XXX: Careful with the checks below (in KeyInput) for pWin and co. You should do them here I guess. - + return true; + } else { + return false; } - - return bHandled; - } bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) @@ -1356,8 +1328,6 @@ bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) #endif ImpMakeTextCursorAreaVisible(); - - return true; } } diff --git a/svx/source/svdraw/textchaincursor.cxx b/svx/source/svdraw/textchaincursor.cxx index 45f8533..37b5931 100644 --- a/svx/source/svdraw/textchaincursor.cxx +++ b/svx/source/svdraw/textchaincursor.cxx @@ -17,11 +17,53 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <svx/textchain.hxx> #include <svx/textchaincursor.hxx> +#include <svx/svdedxv.hxx> +#include <svx/svdoutl.hxx> -TextChainCursorHandler::TextChainCursorHandler() +TextChainCursorManager::TextChainCursorManager(SdrObjEditView *pEditView, const SdrTextObj *pTextObj) : + mpEditView(pEditView), + mpTextObj(pTextObj) { } +bool TextChainCursorManager::HandleKeyEvent( const KeyEvent& rKEvt ) const +{ + bool bHandled = false; + + // XXX: Find a clean way to do this (even cleaner than the code commented below) + // if( pTextEditOutlinerView->IsKeyEventPushingOutOfPage(rKevt, pWin) + // pWin = HandleKeyPushingOutOfBox(rKevt); + KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction(); + sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); + ESelection aCurSel = mpEditView->GetTextEditOutlinerView()->GetSelection(); + + if (mpTextObj && mpTextObj->IsChainable() && mpTextObj->GetNextLinkInChain() && + eFunc == KeyFuncType::DONTKNOW) + { + SdrOutliner *pOutl = mpEditView->GetTextEditOutliner(); + sal_Int32 nLastPara = pOutl->GetParagraphCount()-1; + OUString aLastParaText = pOutl->GetText(pOutl->GetParagraph(nLastPara)); + sal_Int32 nLastParaLen = aLastParaText.getLength(); + + if (nCode == KEY_RIGHT && + aCurSel.nEndPara == nLastPara && + aCurSel.nEndPos == nLastParaLen + ) + { + fprintf(stderr, "[CHAIN - CURSOR] Trying to move to next box\n" ); + + // Move to next box + mpEditView->SdrEndTextEdit(); + SdrTextObj *pNextLink = mpTextObj->GetNextLinkInChain(); + mpEditView->SdrBeginTextEdit(pNextLink); + bHandled = true; + } + + } + return bHandled; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits