diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-22 15:30:58 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-24 16:50:11 +0100 |
commit | 102091b73d824cdda7f88d9a7b79d04eb33fabf7 (patch) | |
tree | e86aec0fcf10e25c79f821a4bdb07508c9875702 /sc | |
parent | ad74c032ce3b9d8b28387a6d74c8dc536c1ff94a (diff) |
remove ScVbaControlObjectBase::ListenerType enum
we only use one value from it
Change-Id: I3d0391e76f07434915940be25025de36a5475bc5
Reviewed-on: https://gerrit.libreoffice.org/63937
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/vba/vbasheetobject.cxx | 42 | ||||
-rw-r--r-- | sc/source/ui/vba/vbasheetobject.hxx | 15 |
2 files changed, 11 insertions, 46 deletions
diff --git a/sc/source/ui/vba/vbasheetobject.cxx b/sc/source/ui/vba/vbasheetobject.cxx index 9e5b7856d6c4..80f9d3249e57 100644 --- a/sc/source/ui/vba/vbasheetobject.cxx +++ b/sc/source/ui/vba/vbasheetobject.cxx @@ -36,6 +36,10 @@ using namespace ::com::sun::star; using namespace ::ooo::vba; +constexpr OUStringLiteral gaListenerType = "XActionListener"; +constexpr OUStringLiteral gaEventMethod = "actionPerformed"; + + ScVbaButtonCharacters::ScVbaButtonCharacters( const uno::Reference< XHelperInterface >& rxParent, const uno::Reference< uno::XComponentContext >& rxContext, @@ -292,37 +296,11 @@ ScVbaControlObjectBase::ScVbaControlObjectBase( const uno::Reference< uno::XComponentContext >& rxContext, const uno::Reference< frame::XModel >& rxModel, const uno::Reference< container::XIndexContainer >& rxFormIC, - const uno::Reference< drawing::XControlShape >& rxControlShape, - ListenerType eListenerType ) : + const uno::Reference< drawing::XControlShape >& rxControlShape ) : ScVbaControlObject_BASE( rxParent, rxContext, rxModel, uno::Reference< drawing::XShape >( rxControlShape, uno::UNO_QUERY_THROW ) ), mxFormIC( rxFormIC, uno::UNO_SET_THROW ), mxControlProps( rxControlShape->getControl(), uno::UNO_QUERY_THROW ) { - // set listener and event name to be used for OnAction attribute - switch( eListenerType ) - { - case LISTENER_ACTION: - maListenerType = "XActionListener"; - maEventMethod = "actionPerformed"; - break; - case LISTENER_MOUSE: - maListenerType = "XMouseListener"; - maEventMethod = "mouseReleased"; - break; - case LISTENER_TEXT: - maListenerType = "XTextListener"; - maEventMethod = "textChanged"; - break; - case LISTENER_VALUE: - maListenerType = "XAdjustmentListener"; - maEventMethod = "adjustmentValueChanged"; - break; - case LISTENER_CHANGE: - maListenerType = "XChangeListener"; - maEventMethod = "changed"; - break; - // no default, to let the compiler complain about missing case - } } // XSheetObject attributes @@ -348,7 +326,7 @@ OUString SAL_CALL ScVbaControlObjectBase::getOnAction() const script::ScriptEventDescriptor* pEventEnd = pEvent + aEvents.getLength(); const OUString aScriptType = "Script"; for( ; pEvent < pEventEnd; ++pEvent ) - if( (pEvent->ListenerType == maListenerType) && (pEvent->EventMethod == maEventMethod) && (pEvent->ScriptType == aScriptType) ) + if( (pEvent->ListenerType == gaListenerType) && (pEvent->EventMethod == gaEventMethod) && (pEvent->ScriptType == aScriptType) ) return extractMacroName( pEvent->ScriptCode ); } return OUString(); @@ -360,7 +338,7 @@ void SAL_CALL ScVbaControlObjectBase::setOnAction( const OUString& rMacroName ) sal_Int32 nIndex = getModelIndexInForm(); // first, remove a registered event (try/catch just in case implementation throws) - try { xEventMgr->revokeScriptEvent( nIndex, maListenerType, maEventMethod, OUString() ); } catch( uno::Exception& ) {} + try { xEventMgr->revokeScriptEvent( nIndex, gaListenerType, gaEventMethod, OUString() ); } catch( uno::Exception& ) {} // if a macro name has been passed, try to attach it to the event if( !rMacroName.isEmpty() ) @@ -369,8 +347,8 @@ void SAL_CALL ScVbaControlObjectBase::setOnAction( const OUString& rMacroName ) if( !aResolvedMacro.mbFound ) throw uno::RuntimeException(); script::ScriptEventDescriptor aDescriptor; - aDescriptor.ListenerType = maListenerType; - aDescriptor.EventMethod = maEventMethod; + aDescriptor.ListenerType = gaListenerType; + aDescriptor.EventMethod = gaEventMethod; aDescriptor.ScriptType = "Script"; aDescriptor.ScriptCode = makeMacroURL( aResolvedMacro.msResolvedMacro ); xEventMgr->registerScriptEvent( nIndex, aDescriptor ); @@ -419,7 +397,7 @@ ScVbaButton::ScVbaButton( const uno::Reference< frame::XModel >& rxModel, const uno::Reference< container::XIndexContainer >& rxFormIC, const uno::Reference< drawing::XControlShape >& rxControlShape ) : - ScVbaButton_BASE( rxParent, rxContext, rxModel, rxFormIC, rxControlShape, LISTENER_ACTION ) + ScVbaButton_BASE( rxParent, rxContext, rxModel, rxFormIC, rxControlShape ) { } diff --git a/sc/source/ui/vba/vbasheetobject.hxx b/sc/source/ui/vba/vbasheetobject.hxx index 357309e1a0f5..e53418ab0481 100644 --- a/sc/source/ui/vba/vbasheetobject.hxx +++ b/sc/source/ui/vba/vbasheetobject.hxx @@ -133,24 +133,13 @@ typedef ::cppu::ImplInheritanceHelper< ScVbaSheetObjectBase, ov::excel::XControl class ScVbaControlObjectBase : public ScVbaControlObject_BASE { public: - /** Specifies the listener used for OnAction events. */ - enum ListenerType - { - LISTENER_ACTION, /// XActionListener.actionPerformed - LISTENER_MOUSE, /// XMouseListener.mouseReleased - LISTENER_TEXT, /// XTextListener.textChanged - LISTENER_VALUE, /// XAdjustmentListener.adjustmentValueChanged - LISTENER_CHANGE /// XChangeListener.changed - }; - /// @throws css::uno::RuntimeException explicit ScVbaControlObjectBase( const css::uno::Reference< ov::XHelperInterface >& rxParent, const css::uno::Reference< css::uno::XComponentContext >& rxContext, const css::uno::Reference< css::frame::XModel >& rxModel, const css::uno::Reference< css::container::XIndexContainer >& rxFormIC, - const css::uno::Reference< css::drawing::XControlShape >& rxControlShape, - ListenerType eListenerType ); + const css::uno::Reference< css::drawing::XControlShape >& rxControlShape ); // XSheetObject attributes virtual OUString SAL_CALL getName() override; @@ -171,8 +160,6 @@ protected: protected: css::uno::Reference< css::container::XIndexContainer > mxFormIC; css::uno::Reference< css::beans::XPropertySet > mxControlProps; - OUString maListenerType; - OUString maEventMethod; }; typedef ::cppu::ImplInheritanceHelper< ScVbaControlObjectBase, ov::excel::XButton > ScVbaButton_BASE; |