summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-11-06 11:47:50 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-11-06 16:42:05 +0100
commit427d1355fd909b12c71d82e504cc200db6e55aa5 (patch)
tree65b1d13f8d7018155f85c582b407b4b95aa7ed49
parentUpdate git submodules (diff)
downloadcore-427d1355fd909b12c71d82e504cc200db6e55aa5.tar.gz
core-427d1355fd909b12c71d82e504cc200db6e55aa5.zip
disentangle writer's SID_FM_CONTROL_IDENTIFIER handling
a) make m_nFormSfxId simply follow the slotid, like its sibling m_nDrawSfxId b) move the previously selected form object into a variable of its own as m_eFormObjKind instead of ~abusing m_nFormSfxId to do that c) pass which form object a ConstFormControl creates as an explicit ctor arg instead of providing that information by overwriting the slotid that its ::Activate gets passed making it follow the equivalent calc pattern and separating these very different slot ids and object identifiers In testing, with the form controls toolbar, clicking on a toolbaritem toggles it on, and drawing in writer gives the expected control via ConstFormControl ctor, and clicking the same toolbaritem toggles it off hitting the expected SID_FM_LEAVE_CREATE case. Change-Id: I514f6adc38f706c82f0268abf5c5e73cef5b902c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105405 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sc/source/ui/view/tabvwsh2.cxx9
-rw-r--r--sw/inc/view.hxx3
-rw-r--r--sw/source/uibase/inc/conform.hxx5
-rw-r--r--sw/source/uibase/ribbar/conform.cxx9
-rw-r--r--sw/source/uibase/uiview/view.cxx1
-rw-r--r--sw/source/uibase/uiview/viewdraw.cxx25
6 files changed, 29 insertions, 23 deletions
diff --git a/sc/source/ui/view/tabvwsh2.cxx b/sc/source/ui/view/tabvwsh2.cxx
index 0883ea333e2a..9e0a81600e8f 100644
--- a/sc/source/ui/view/tabvwsh2.cxx
+++ b/sc/source/ui/view/tabvwsh2.cxx
@@ -95,12 +95,11 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
nNewId = SID_OBJECT_SELECT;
sal_uInt16 nNewFormId = 0;
- if ( nNewId == SID_FM_CREATE_CONTROL && pArgs )
+ if (nNewId == SID_FM_CREATE_CONTROL)
{
- const SfxPoolItem* pItem;
- if ( pArgs->GetItemState( SID_FM_CONTROL_IDENTIFIER, true, &pItem ) == SfxItemState::SET &&
- dynamic_cast<const SfxUInt16Item*>( pItem) != nullptr )
- nNewFormId = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+ const SfxUInt16Item* pIdentifierItem = rReq.GetArg<SfxUInt16Item>(SID_FM_CONTROL_IDENTIFIER);
+ if (pIdentifierItem)
+ nNewFormId = pIdentifierItem->GetValue();
}
OUString sStringItemValue;
diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index 8513b6c7e171..4130142662e4 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -214,6 +214,7 @@ class SW_DLLPUBLIC SwView: public SfxViewShell
sal_uInt16 m_nDrawSfxId;
OUString m_sDrawCustom; //some drawing types are marked with strings!
sal_uInt16 m_nFormSfxId;
+ sal_uInt16 m_eFormObjKind;
SotExchangeDest m_nLastPasteDestination;
// save the border distance status from SwView::StateTabWin to re-use it in SwView::ExecTabWin()
@@ -520,7 +521,7 @@ public:
bool EnterDrawTextMode(const Point& aDocPos);
/// Same as EnterDrawTextMode(), but takes an SdrObject instead of guessing it by document position.
bool EnterShapeDrawTextMode(SdrObject* pObject);
- void LeaveDrawCreate() { m_nDrawSfxId = m_nFormSfxId = USHRT_MAX; m_sDrawCustom.clear();}
+ void LeaveDrawCreate() { m_nDrawSfxId = m_nFormSfxId = USHRT_MAX; m_sDrawCustom.clear(); m_eFormObjKind = 0; }
bool IsDrawMode() const { return (m_nDrawSfxId != USHRT_MAX || m_nFormSfxId != USHRT_MAX); }
bool IsFormMode() const;
bool IsBezierEditMode() const;
diff --git a/sw/source/uibase/inc/conform.hxx b/sw/source/uibase/inc/conform.hxx
index 65e01caf98ce..3459347ddb3f 100644
--- a/sw/source/uibase/inc/conform.hxx
+++ b/sw/source/uibase/inc/conform.hxx
@@ -23,8 +23,11 @@
class ConstFormControl : public SwDrawBase
{
+private:
+ sal_uInt16 m_eObjKind;
+
public:
- ConstFormControl(SwWrtShell* pSh, SwEditWin* pWin, SwView* pView);
+ ConstFormControl(SwWrtShell* pSh, SwEditWin* pWin, SwView* pView, sal_uInt16 eObjKind);
// Mouse- & Key-Events
virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
diff --git a/sw/source/uibase/ribbar/conform.cxx b/sw/source/uibase/ribbar/conform.cxx
index a61a0d725312..c016e1240619 100644
--- a/sw/source/uibase/ribbar/conform.cxx
+++ b/sw/source/uibase/ribbar/conform.cxx
@@ -27,8 +27,9 @@
#include <drawbase.hxx>
#include <conform.hxx>
-ConstFormControl::ConstFormControl(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView) :
- SwDrawBase(pWrtShell, pEditWin, pSwView)
+ConstFormControl::ConstFormControl(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView, sal_uInt16 eObjKind)
+ : SwDrawBase(pWrtShell, pEditWin, pSwView)
+ , m_eObjKind(eObjKind)
{
m_bInsForm = true;
}
@@ -79,9 +80,9 @@ bool ConstFormControl::MouseButtonDown(const MouseEvent& rMEvt)
void ConstFormControl::Activate(const sal_uInt16 nSlotId)
{
- m_pWin->SetSdrDrawMode( static_cast<SdrObjKind>(nSlotId) );
+ m_pWin->SetSdrDrawMode(static_cast<SdrObjKind>(m_eObjKind));
SwDrawBase::Activate(nSlotId);
- m_pSh->GetDrawView()->SetCurrentObj(nSlotId);
+ m_pSh->GetDrawView()->SetCurrentObj(m_eObjKind);
m_pWin->SetPointer(PointerStyle::DrawRect);
}
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 0a9fde5beb18..a031b6fab422 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -720,6 +720,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
m_nPageCnt(0),
m_nDrawSfxId( USHRT_MAX ),
m_nFormSfxId( USHRT_MAX ),
+ m_eFormObjKind(0),
m_nLastPasteDestination( static_cast<SotExchangeDest>(0xFFFF) ),
m_nLeftBorderDistance( 0 ),
m_nRightBorderDistance( 0 ),
diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx
index 85f9082b977f..7a8cacfaad41 100644
--- a/sw/source/uibase/uiview/viewdraw.cxx
+++ b/sw/source/uibase/uiview/viewdraw.cxx
@@ -81,21 +81,24 @@ void SwView::ExecDraw(SfxRequest& rReq)
if(pArgs && SfxItemState::SET == pArgs->GetItemState(GetPool().GetWhich(nSlotId), false, &pItem))
pStringItem = dynamic_cast< const SfxStringItem*>(pItem);
+ sal_uInt16 eNewFormObjKind = 0;
+ if (nSlotId == SID_FM_CREATE_CONTROL)
+ {
+ const SfxUInt16Item* pIdentifierItem = rReq.GetArg<SfxUInt16Item>(SID_FM_CONTROL_IDENTIFIER);
+ if (pIdentifierItem)
+ eNewFormObjKind = pIdentifierItem->GetValue();
+ }
+
if (nSlotId == SID_OBJECT_SELECT && m_nFormSfxId == nSlotId)
{
bDeselect = true;
}
else if (nSlotId == SID_FM_CREATE_CONTROL)
{
- const SfxUInt16Item* pIdentifierItem = rReq.GetArg<SfxUInt16Item>(SID_FM_CONTROL_IDENTIFIER);
- if( pIdentifierItem )
+ if (eNewFormObjKind == m_eFormObjKind || eNewFormObjKind == 0)
{
- sal_uInt16 nNewId = pIdentifierItem->GetValue();
- if (nNewId == m_nFormSfxId)
- {
- bDeselect = true;
- GetViewFrame()->GetDispatcher()->Execute(SID_FM_LEAVE_CREATE); // Button should popping out
- }
+ bDeselect = true;
+ GetViewFrame()->GetDispatcher()->Execute(SID_FM_LEAVE_CREATE); // Button should popping out
}
}
else if (nSlotId == SID_FM_CREATE_FIELDCONTROL)
@@ -279,11 +282,9 @@ void SwView::ExecDraw(SfxRequest& rReq)
case SID_FM_CREATE_CONTROL:
{
- const SfxUInt16Item* pIdentifierItem = rReq.GetArg<SfxUInt16Item>(SID_FM_CONTROL_IDENTIFIER);
- if( pIdentifierItem )
- nSlotId = pIdentifierItem->GetValue();
- pFuncPtr.reset( new ConstFormControl(m_pWrtShell.get(), m_pEditWin, this) );
+ pFuncPtr.reset(new ConstFormControl(m_pWrtShell.get(), m_pEditWin, this, eNewFormObjKind));
m_nFormSfxId = nSlotId;
+ m_eFormObjKind = eNewFormObjKind;
}
break;