[Libreoffice-commits] core.git: Branch 'feature/chained-text-boxes' - 4 commits - editeng/source include/svx sd/source svx/source
matteocam
matteo.campanelli at gmail.com
Mon Sep 7 11:02:25 PDT 2015
editeng/source/outliner/outlvw.cxx | 11 ++
include/svx/svdedxv.hxx | 10 ++
sd/source/ui/view/drviewse.cxx | 5 +
sd/source/ui/view/outlview.cxx | 1
sd/source/ui/view/sdview.cxx | 1
svx/source/svdraw/svdedxv.cxx | 145 +++++++++++++++++++++++++++++++++++++
6 files changed, 171 insertions(+), 2 deletions(-)
New commits:
commit 54b576c3b3bf3d67c5ffd4ae391f6c03e3647dc1
Author: matteocam <matteo.campanelli at gmail.com>
Date: Mon Sep 7 20:01:35 2015 +0200
Handle chaining for cutting and pasting
Change-Id: Iec08e339a7f06c5fa56e67b42206b31c766f845b
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index 4a0d96e..edf617f 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -675,8 +675,12 @@ void OutlinerView::InsertText( const OutlinerParaObject& rParaObj )
void OutlinerView::Cut()
{
- if ( !ImpCalcSelectedPages( false ) || pOwner->ImpCanDeleteSelectedPages( this ) )
+ if ( !ImpCalcSelectedPages( false ) || pOwner->ImpCanDeleteSelectedPages( this ) ) {
pEditView->Cut();
+ // Chaining handling
+ if (aEndCutPasteLink.IsSet())
+ aEndCutPasteLink.Call(NULL);
+ }
}
void OutlinerView::Paste()
@@ -705,6 +709,11 @@ void OutlinerView::PasteSpecial()
pEditView->SetEditEngineUpdateMode( true );
pOwner->UndoActionEnd( OLUNDO_INSERT );
pEditView->ShowCursor( true );
+
+ // Chaining handling
+ // NOTE: We need to do this last because it pEditView may be deleted if a switch of box occurs
+ if (aEndCutPasteLink.IsSet())
+ aEndCutPasteLink.Call(NULL);
}
}
commit 731000696b282f457a7e003297d4f158849825d4
Author: matteocam <matteo.campanelli at gmail.com>
Date: Mon Sep 7 19:58:16 2015 +0200
Handle DEL key for chaining
Change-Id: I124b1adf6df3c42a58d45eaeb0e1e053c0eea4c9
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index da65984..d9e0a99 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -950,7 +950,10 @@ void DrawViewShell::FuSupport(SfxRequest& rReq)
{
vcl::KeyCode aKCode(KEY_DELETE);
KeyEvent aKEvt( 0, aKCode);
- pOLV->PostKeyEvent(aKEvt);
+ //pOLV->PostKeyEvent(aKEvt);
+ // We use SdrObjEditView to handle DEL for underflow handling
+ mpDrawView->KeyInput(aKEvt, NULL);
+
}
}
else
commit 1a86da45320faf5f644c1a82c07bd9b522a2a351
Author: matteocam <matteo.campanelli at gmail.com>
Date: Mon Sep 7 16:37:56 2015 +0200
Enable chaining after a key is pressed
Change-Id: I64351619dd0886f3bb0c080557864c46a17d737d
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 86a69e4..c263a62 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -1326,6 +1326,15 @@ bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin)
if(pTextEditOutlinerView)
{
+ /* Start special handling of keys within a chain */
+ // We possibly move to another box before any handling
+ bool bHandled = false;
+ TextChainCursorManager *pCursorManager =
+ ImpHandleMotionThroughBoxesKeyInput(rKEvt, pWin, &bHandled);
+ if (bHandled)
+ return true;
+ /* End special handling of keys within a chain */
+
if (pTextEditOutlinerView->PostKeyEvent(rKEvt, pWin))
{
if( mpModel )
@@ -1334,6 +1343,11 @@ bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin)
mpModel->SetChanged();
}
+ /* Start chaining processing */
+ ImpChainingEventHdl();
+ ImpMoveCursorAfterChainingEvent(pCursorManager);
+ /* End chaining processing */
+
if (pWin!=NULL && pWin!=pTextEditWin) SetTextEditWin(pWin);
#ifdef DBG_UTIL
if (mpItemBrowser!=nullptr) mpItemBrowser->SetDirty();
commit 8ecbccf07bfcf82cb755f8abbe84f00576d76cc4
Author: matteocam <matteo.campanelli at gmail.com>
Date: Mon Sep 7 16:33:39 2015 +0200
Add methods and basic setup for editing-mode chaining
Change-Id: I8065bebaf2a54170bc7b3ddbd35740bcca42298d
diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx
index 2aa9f89..c388941 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 17fe875..c2687f6 100644
--- a/sd/source/ui/view/outlview.cxx
+++ b/sd/source/ui/view/outlview.cxx
@@ -1375,6 +1375,7 @@ void OutlineView::ResetLinks() const
mrOutliner.SetDrawPortionHdl(Link<DrawPortionInfo*,void>());
mrOutliner.SetBeginPasteOrDropHdl(Link<PasteOrDropInfos*,void>());
mrOutliner.SetEndPasteOrDropHdl(Link<PasteOrDropInfos*,void>());
+ mrOutliner.SetChainingEventHdl(aEmptyLink);
}
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 18fbf2e..524faba 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 f38d33f..86a69e4 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>
@@ -489,6 +491,102 @@ IMPL_LINK(SdrObjEditView,ImpOutlinerStatusEventHdl,EditStatus*,pEditStat)
return 0;
}
+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;
@@ -728,6 +826,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
@@ -917,6 +1019,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 )
{
@@ -1189,10 +1293,37 @@ 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)
{
+
if(pTextEditOutlinerView)
{
if (pTextEditOutlinerView->PostKeyEvent(rKEvt, pWin))
More information about the Libreoffice-commits
mailing list