[Libreoffice-commits] core.git: Branch 'feature/gsoc14-draw-chained-text-boxes' - 2 commits - include/svx sd/source svx/source
matteocam
matteo.campanelli at gmail.com
Fri Jul 24 07:33:02 PDT 2015
include/svx/svdedxv.hxx | 5 ++-
include/svx/textchaincursor.hxx | 17 ++++++++---
sd/source/ui/view/drviewse.cxx | 3 +-
svx/source/svdraw/svdedxv.cxx | 36 ++++++++++++++----------
svx/source/svdraw/textchaincursor.cxx | 50 +++++++++++++++++++++++++++++-----
5 files changed, 84 insertions(+), 27 deletions(-)
New commits:
commit 8c4db4fe0f5bd10c06fb2a35b2e5cdaedad34bc3
Author: matteocam <matteo.campanelli at gmail.com>
Date: Fri Jul 24 16:29:47 2015 +0200
Handle DEL calling Sdr*View::KeyInput instead of OutlinerView::PostKeyEvent
Change-Id: I7f4483e5165d30786288462fe5397ee93e477673
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index 516f487..a8bb8c1 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -939,7 +939,8 @@ void DrawViewShell::FuSupport(SfxRequest& rReq)
{
vcl::KeyCode aKCode(KEY_DELETE);
KeyEvent aKEvt( 0, aKCode);
- pOLV->PostKeyEvent(aKEvt);
+ //pOLV->PostKeyEvent(aKEvt);
+ mpDrawView->KeyInput(aKEvt, NULL);
}
}
else
commit ebe372b42c1e9667a60fb06e798e01dc11e2155b
Author: matteocam <matteo.campanelli at gmail.com>
Date: Fri Jul 24 12:04:31 2015 +0200
Handle Delete
Change-Id: I17a1886689785420fb881bea8f1d609ab3f35c4e
diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx
index d45a12f..c7e9c99 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;
enum class CursorChainingEvent;
class ESelection;
@@ -110,8 +111,8 @@ protected:
OutlinerView* ImpFindOutlinerView(vcl::Window* pWin) const;
- void ImpMoveCursorAfterChainingEvent();
- bool ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt, vcl::Window* pWin);
+ void ImpMoveCursorAfterChainingEvent(TextChainCursorManager *pCursorManager);
+ TextChainCursorManager *ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt, vcl::Window* pWin, bool *bOutHandled);
// Create a new OutlinerView at the heap and initialize all required parameters.
// pTextEditObj, pTextEditPV and pTextEditOutliner have to be initialized
diff --git a/include/svx/textchaincursor.hxx b/include/svx/textchaincursor.hxx
index 1d9c4de..7668773 100644
--- a/include/svx/textchaincursor.hxx
+++ b/include/svx/textchaincursor.hxx
@@ -31,19 +31,28 @@ class TextChainCursorManager
public:
TextChainCursorManager(SdrObjEditView *pEditView, const SdrTextObj *pTextObj);
- bool HandleKeyEvent( const KeyEvent& rKEvt ) const;
+ bool HandleKeyEvent( const KeyEvent& rKEvt );
+
+ // Used by HandledKeyEvent and basic building block for handling cursor event
void HandleCursorEvent(const CursorChainingEvent aCurEvt,
- const ESelection aNewSel) const;
+ const ESelection aNewSel);
+
+ // To be used after chaining event to deal with some nuisances
+ void HandleCursorEventAfterChaining(const CursorChainingEvent aCurEvt,
+ const ESelection aNewSel);
private:
SdrObjEditView *mpEditView;
const SdrTextObj *mpTextObj;
- void impChangeEditingTextObj(SdrTextObj *pTargetTextObj, ESelection aNewSel) const;
+ // flag for handling of CANC which is kind of an exceptional case
+ bool mbHandlingDel;
+
+ void impChangeEditingTextObj(SdrTextObj *pTargetTextObj, ESelection aNewSel);
void impDetectEvent(const KeyEvent& rKEvt,
CursorChainingEvent *pOutCursorEvt,
ESelection *pOutSel,
- bool *bOutHandled) const;
+ bool *bOutHandled);
};
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index ad35d29..cfc5d33 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -526,9 +526,9 @@ IMPL_LINK_NOARG(SdrObjEditView,ImpChainingEventHdl)
}
-void SdrObjEditView::ImpMoveCursorAfterChainingEvent()
+void SdrObjEditView::ImpMoveCursorAfterChainingEvent(TextChainCursorManager *pCursorManager)
{
- if (!mxTextEditObj.is())
+ if (!mxTextEditObj.is() || !pCursorManager)
return;
SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(mxTextEditObj.get());
@@ -539,8 +539,8 @@ void SdrObjEditView::ImpMoveCursorAfterChainingEvent()
TextChain *pTextChain = pTextObj->GetTextChain();
ESelection aNewSel = pTextChain->GetPostChainingSel(pTextObj);
- TextChainCursorManager aCursorManager(this, pTextObj);
- aCursorManager.HandleCursorEvent(
+
+ pCursorManager->HandleCursorEventAfterChaining(
pTextChain->GetCursorEvent(pTextObj),
aNewSel);
@@ -1258,25 +1258,30 @@ bool SdrObjEditView::IsTextEditFrameHit(const Point& rHit) const
return bOk;
}
-bool SdrObjEditView::ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt, vcl::Window* pWin)
+TextChainCursorManager *SdrObjEditView::ImpHandleMotionThroughBoxesKeyInput(
+ const KeyEvent& rKEvt,
+ vcl::Window* pWin,
+ bool *bOutHandled)
{
+ *bOutHandled = false;
+
SdrTextObj* pTextObj = NULL;
if (mxTextEditObj.is())
pTextObj= dynamic_cast<SdrTextObj*>(mxTextEditObj.get());
else
- return false;
+ return NULL;
if (!pTextObj->IsChainable())
- return false;
+ return NULL;
- TextChainCursorManager aCursorManager(this, pTextObj);
- if( aCursorManager.HandleKeyEvent(rKEvt) ) {
+ 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.
- return true;
- } else {
- return false;
+ *bOutHandled = true;
}
+
+ return pCursorManager;
}
bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin)
@@ -1284,7 +1289,10 @@ bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin)
if(pTextEditOutlinerView)
{
// We possibly move to another box before any handling
- if (ImpHandleMotionThroughBoxesKeyInput(rKEvt, pWin))
+ bool bHandled = false;
+ TextChainCursorManager *pCursorManager =
+ ImpHandleMotionThroughBoxesKeyInput(rKEvt, pWin, &bHandled);
+ if (bHandled)
return true;
// FIXME(matteocam): Old code from here
@@ -1299,7 +1307,7 @@ bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin)
// FIXME(matteocam)
// Start chaining processing
ImpChainingEventHdl(NULL);
- ImpMoveCursorAfterChainingEvent();
+ ImpMoveCursorAfterChainingEvent(pCursorManager);
// End chaining processing
if (pWin!=NULL && pWin!=pTextEditWin) SetTextEditWin(pWin);
diff --git a/svx/source/svdraw/textchaincursor.cxx b/svx/source/svdraw/textchaincursor.cxx
index af2af7c..35a339e 100644
--- a/svx/source/svdraw/textchaincursor.cxx
+++ b/svx/source/svdraw/textchaincursor.cxx
@@ -28,14 +28,15 @@
TextChainCursorManager::TextChainCursorManager(SdrObjEditView *pEditView, const SdrTextObj *pTextObj) :
mpEditView(pEditView),
- mpTextObj(pTextObj)
+ mpTextObj(pTextObj),
+ mbHandlingDel(false)
{
assert(mpEditView);
assert(mpTextObj);
}
-bool TextChainCursorManager::HandleKeyEvent( const KeyEvent& rKEvt ) const
+bool TextChainCursorManager::HandleKeyEvent( const KeyEvent& rKEvt )
{
ESelection aNewSel;
CursorChainingEvent aCursorEvent;
@@ -56,7 +57,7 @@ bool TextChainCursorManager::HandleKeyEvent( const KeyEvent& rKEvt ) const
void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
CursorChainingEvent *pOutCursorEvt,
ESelection *pOutSel,
- bool *bOutHandled) const
+ bool *bOutHandled)
{
SdrOutliner *pOutl = mpEditView->GetTextEditOutliner();
OutlinerView *pOLV = mpEditView->GetTextEditOutlinerView();
@@ -92,6 +93,16 @@ void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
return;
}
+ // Possibility: Are we "pushing" at the end of the object?
+ if (nCode == KEY_DELETE && bAtEndOfTextContent && pNextLink)
+ {
+ *pOutCursorEvt = CursorChainingEvent::TO_NEXT_LINK;
+ // Selection unchanged: we are at the beginning of the box
+ *bOutHandled = false; // We still need to delete the characters
+ mbHandlingDel = true;
+ return;
+ }
+
ESelection aStartSel = ESelection(0, 0);
bool bAtStartOfTextContent = aCurSel.IsEqual(aStartSel);
@@ -118,16 +129,40 @@ void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
}
+void TextChainCursorManager::HandleCursorEventAfterChaining(
+ const CursorChainingEvent aCurEvt,
+ const ESelection aNewSel)
+
+{
+ // Special case for DELETE handling: we need to get back at the end of the prev box
+ if (mbHandlingDel) {
+ // reset flag
+ mbHandlingDel = false;
+
+ // Move to end of prev box
+ SdrTextObj *pPrevLink = mpTextObj->GetPrevLinkInChain();
+ ESelection aEndSel(100000, 100000);
+ impChangeEditingTextObj(pPrevLink, aEndSel);
+ return;
+ }
+
+ // Standard handling
+ HandleCursorEvent(aCurEvt, aNewSel);
+}
+
+
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)
@@ -148,7 +183,7 @@ void TextChainCursorManager::HandleCursorEvent(
}
-void TextChainCursorManager::impChangeEditingTextObj(SdrTextObj *pTargetTextObj, ESelection aNewSel) const
+void TextChainCursorManager::impChangeEditingTextObj(SdrTextObj *pTargetTextObj, ESelection aNewSel)
{
assert(pTargetTextObj);
@@ -156,7 +191,10 @@ void TextChainCursorManager::impChangeEditingTextObj(SdrTextObj *pTargetTextObj,
mpEditView->SdrBeginTextEdit(pTargetTextObj);
// OutlinerView has changed, so we update the pointer
OutlinerView *pOLV = mpEditView->GetTextEditOutlinerView();
- pOLV->SetSelection(aNewSel); // XXX
+ pOLV->SetSelection(aNewSel);
+
+ // Update reference text obj
+ mpTextObj = pTargetTextObj;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list