diff options
author | matteocam <matteo.campanelli@gmail.com> | 2015-09-07 16:33:39 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2015-09-20 13:05:15 +0200 |
commit | c21780b58f86399332c8ff753d31fb9870baf9ac (patch) | |
tree | eff8e7c1eb0f30bd38a86407ee075098fa7de1b1 | |
parent | 5b04c453cc03c0d2c6067625242f07deb8f78ba0 (diff) |
chained editeng: Add methods and basic setup for editing-mode chaining
Change-Id: I8065bebaf2a54170bc7b3ddbd35740bcca42298d
-rw-r--r-- | include/svx/svdedxv.hxx | 10 | ||||
-rw-r--r-- | sd/source/ui/view/outlview.cxx | 1 | ||||
-rw-r--r-- | sd/source/ui/view/sdview.cxx | 1 | ||||
-rw-r--r-- | svx/source/svdraw/svdedxv.cxx | 130 |
4 files changed, 142 insertions, 0 deletions
diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx index 5dc3514ad659..bec7338688b8 100644 --- a/include/svx/svdedxv.hxx +++ b/include/svx/svdedxv.hxx @@ -34,6 +34,7 @@ class EditFieldInfo; class ImpSdrEditPara; struct PasteOrDropInfos; class SdrUndoManager; +class TextChainCursorManager; namespace com { namespace sun { namespace star { namespace uno { class Any; @@ -101,6 +102,10 @@ protected: // provide their document UndoManager and derive it from SdrUndoManager. virtual SdrUndoManager* getSdrUndoManagerForEnhancedTextEdit() const; + void ImpMoveCursorAfterChainingEvent(TextChainCursorManager *pCursorManager); + TextChainCursorManager *ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt, vcl::Window* pWin, bool *bOutHandled); + + OutlinerView* ImpFindOutlinerView(vcl::Window* pWin) const; // Create a new OutlinerView at the heap and initialize all required parameters. @@ -109,6 +114,11 @@ protected: void ImpPaintOutlinerView(OutlinerView& rOutlView, const Rectangle& rRect, OutputDevice& rTargetDevice) const; void ImpInvalidateOutlinerView(OutlinerView& rOutlView) const; + // Chaining + void ImpChainingEventHdl(); + DECL_LINK(ImpAfterCutOrPasteChainingEventHdl,void*); + + // Check if the whole text is selected. // Still returns sal_True if there is no text present. bool ImpIsTextEditAllSelected() const; diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx index 6bb82ad75571..d1117bd40d0d 100644 --- a/sd/source/ui/view/outlview.cxx +++ b/sd/source/ui/view/outlview.cxx @@ -1370,6 +1370,7 @@ void OutlineView::ResetLinks() const mrOutliner.SetDrawPortionHdl(Link<DrawPortionInfo*,void>()); mrOutliner.SetBeginPasteOrDropHdl(Link<PasteOrDropInfos*,void>()); mrOutliner.SetEndPasteOrDropHdl(Link<PasteOrDropInfos*,void>()); + mrOutliner.SetChainingEventHdl(Link<>()); } sal_Int8 OutlineView::AcceptDrop( const AcceptDropEvent&, DropTargetHelper&, ::sd::Window*, sal_uInt16, sal_uInt16) diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index 18fbf2e7e68b..524fabab766d 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -1204,6 +1204,7 @@ void View::OnBeginPasteOrDrop( PasteOrDropInfos* /*pInfos*/ ) get the correct style sheet. */ void View::OnEndPasteOrDrop( PasteOrDropInfos* pInfos ) { + /* Style Sheet handling */ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( GetTextEditObject() ); SdrOutliner* pOutliner = GetTextEditOutliner(); if( pOutliner && pTextObj && pTextObj->GetPage() ) diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index ea6ae00180fa..9dbf0ab17aaa 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -51,6 +51,8 @@ #include "svx/svdstr.hrc" #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> @@ -486,6 +488,102 @@ IMPL_LINK_TYPED(SdrObjEditView,ImpOutlinerStatusEventHdl, EditStatus&, rEditStat } } +void SdrObjEditView::ImpChainingEventHdl() +{ + if(pTextEditOutliner ) + { + SdrTextObj* pTextObj = dynamic_cast< SdrTextObj * >( mxTextEditObj.get() ); + OutlinerView* pOLV = GetTextEditOutlinerView(); + if( pTextObj && pOLV) + { + TextChain *pTextChain = pTextObj->GetTextChain(); + + // XXX: IsChainable and GetNilChainingEvent are a bit mixed up atm + if (!pTextObj->IsChainable()) { + return; + } + // This is true during an underflow-caused overflow (with pEdtOutl->SetText()) + if (pTextChain->GetNilChainingEvent(pTextObj)) { + return; + } + + // We prevent to trigger further handling of overflow/underflow for pTextObj + pTextChain->SetNilChainingEvent(pTextObj, true); // XXX + + // Save previous selection pos // NOTE: It must be done to have the right CursorEvent in KeyInput + pTextChain->SetPreChainingSel(pTextObj, pOLV->GetSelection()); + //maPreChainingSel = new ESelection(pOLV->GetSelection()); + + // Handling Undo + const int nText = 0; // XXX: hardcoded index (SdrTextObj::getText handles only 0) + + SdrUndoObjSetText *pTxtUndo = dynamic_cast< SdrUndoObjSetText* > + ( GetModel()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, nText ) ); + + // trigger actual chaining + pTextObj->onChainingEvent(); + + if (pTxtUndo!=NULL) + { + pTxtUndo->AfterSetText(); + if (!pTxtUndo->IsDifferent()) + { + delete pTxtUndo; + pTxtUndo=NULL; + } + } + + if (pTxtUndo) + AddUndo(pTxtUndo); + + //maCursorEvent = new CursorChainingEvent(pTextChain->GetCursorEvent(pTextObj)); + //SdrTextObj *pNextLink = pTextObj->GetNextLinkInChain(); + + // NOTE: Must be called. Don't let the function return if you set it to true and not reset it + pTextChain->SetNilChainingEvent(pTextObj, false); + } else { + // XXX + fprintf(stderr, "[OnChaining] No Edit Outliner View\n"); + } + } + +} + +IMPL_LINK_NOARG(SdrObjEditView,ImpAfterCutOrPasteChainingEventHdl) +{ + SdrTextObj* pTextObj = dynamic_cast< SdrTextObj * >( GetTextEditObject()); + if (!pTextObj) + return 0; + ImpChainingEventHdl(); + TextChainCursorManager *pCursorManager = new TextChainCursorManager(this, pTextObj); + ImpMoveCursorAfterChainingEvent(pCursorManager); + return 0; +} + +void SdrObjEditView::ImpMoveCursorAfterChainingEvent(TextChainCursorManager *pCursorManager) +{ + if (!mxTextEditObj.is() || !pCursorManager) + return; + + SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(mxTextEditObj.get()); + + // Check if it has links to move it to + if (!pTextObj->IsChainable()) + return; + + TextChain *pTextChain = pTextObj->GetTextChain(); + ESelection aNewSel = pTextChain->GetPostChainingSel(pTextObj); + + + pCursorManager->HandleCursorEventAfterChaining( + pTextChain->GetCursorEvent(pTextObj), + aNewSel); + + // Reset event + pTextChain->SetCursorEvent(pTextObj, CursorChainingEvent::NULL_EVENT); +} + + IMPL_LINK_TYPED(SdrObjEditView,ImpOutlinerCalcFieldValueHdl,EditFieldInfo*,pFI,void) { bool bOk=false; @@ -724,6 +822,10 @@ bool SdrObjEditView::SdrBeginTextEdit( pTextEditOutlinerView->ShowCursor(); pTextEditOutliner->SetStatusEventHdl(LINK(this,SdrObjEditView,ImpOutlinerStatusEventHdl)); + if (pTextObj->IsChainable()) { + pTextEditOutlinerView->SetEndCutPasteLinkHdl(LINK(this,SdrObjEditView,ImpAfterCutOrPasteChainingEventHdl) ); + } + #ifdef DBG_UTIL if (mpItemBrowser!=nullptr) mpItemBrowser->SetDirty(); #endif @@ -913,6 +1015,8 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally) pTEOutliner->SetBeginPasteOrDropHdl(Link<PasteOrDropInfos*,void>()); pTEOutliner->SetEndPasteOrDropHdl(Link<PasteOrDropInfos*,void>()); + pTEOutliner->SetChainingEventHdl(Link<>()); + const bool bUndo = IsUndoEnabled(); if( bUndo ) { @@ -1176,6 +1280,32 @@ bool SdrObjEditView::IsTextEditFrameHit(const Point& rHit) const return bOk; } +TextChainCursorManager *SdrObjEditView::ImpHandleMotionThroughBoxesKeyInput( + const KeyEvent& rKEvt, + vcl::Window*, + bool *bOutHandled) +{ + *bOutHandled = false; + + SdrTextObj* pTextObj = NULL; + if (mxTextEditObj.is()) + pTextObj= dynamic_cast<SdrTextObj*>(mxTextEditObj.get()); + else + return NULL; + + if (!pTextObj->GetNextLinkInChain() && !pTextObj->GetPrevLinkInChain()) + return NULL; + + TextChainCursorManager *pCursorManager = new TextChainCursorManager(this, pTextObj); + if( pCursorManager->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. + *bOutHandled = true; + } + + return pCursorManager; +} + bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) |