summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-10-09 15:17:24 +0200
committerNoel Grandin <noel@peralex.com>2015-10-12 09:13:34 +0200
commit42571e3d4e12c03f32197e9275fa203b86356942 (patch)
tree7b6df7bcdd58f7fa41fdf7780ed180d96764219e /extensions
parenta517b945e7e71cc928645431e1f28cc82f32844b (diff)
reduce the web of class relationships here a little
make CommonBehaviourControlHelper a base-class of the CommonBehaviourControl template, which allows us to dispense with the IModifyListener callback interface Change-Id: I3c02b864fa08fc50515c11af859477e0fdc035e3
Diffstat (limited to 'extensions')
-rw-r--r--extensions/source/propctrlr/commoncontrol.cxx30
-rw-r--r--extensions/source/propctrlr/commoncontrol.hxx108
-rw-r--r--extensions/source/propctrlr/standardcontrol.cxx18
-rw-r--r--extensions/source/propctrlr/standardcontrol.hxx5
4 files changed, 62 insertions, 99 deletions
diff --git a/extensions/source/propctrlr/commoncontrol.cxx b/extensions/source/propctrlr/commoncontrol.cxx
index d7f24693d8a7..21b9338a0e6f 100644
--- a/extensions/source/propctrlr/commoncontrol.cxx
+++ b/extensions/source/propctrlr/commoncontrol.cxx
@@ -36,28 +36,27 @@ namespace pcr
using ::com::sun::star::uno::Exception;
using ::com::sun::star::inspection::XPropertyControl;
- ControlHelper::ControlHelper( vcl::Window* _pControlWindow, sal_Int16 _nControlType, XPropertyControl& _rAntiImpl, IModifyListener* _pModifyListener )
+ CommonBehaviourControlHelper::CommonBehaviourControlHelper( vcl::Window* _pControlWindow, sal_Int16 _nControlType, XPropertyControl& _rAntiImpl )
:m_pControlWindow( _pControlWindow )
,m_nControlType( _nControlType )
,m_rAntiImpl( _rAntiImpl )
- ,m_pModifyListener( _pModifyListener )
,m_bModified( false )
{
- DBG_ASSERT( m_pControlWindow != nullptr, "ControlHelper::ControlHelper: invalid window!" );
+ DBG_ASSERT( m_pControlWindow != nullptr, "CommonBehaviourControlHelper::CommonBehaviourControlHelper: invalid window!" );
}
- ControlHelper::~ControlHelper()
+ CommonBehaviourControlHelper::~CommonBehaviourControlHelper()
{
}
- void SAL_CALL ControlHelper::setControlContext( const Reference< XPropertyControlContext >& _controlcontext ) throw (RuntimeException)
+ void SAL_CALL CommonBehaviourControlHelper::setControlContext( const Reference< XPropertyControlContext >& _controlcontext ) throw (RuntimeException)
{
m_xContext = _controlcontext;
}
- Reference< XWindow > SAL_CALL ControlHelper::getControlWindow() throw (RuntimeException)
+ Reference< XWindow > SAL_CALL CommonBehaviourControlHelper::getControlWindow() throw (RuntimeException)
{
return VCLUnoHelper::GetInterface( m_pControlWindow );
}
@@ -65,7 +64,7 @@ namespace pcr
- void SAL_CALL ControlHelper::notifyModifiedValue( ) throw (RuntimeException)
+ void SAL_CALL CommonBehaviourControlHelper::notifyModifiedValue( ) throw (RuntimeException)
{
if ( isModified() && m_xContext.is() )
{
@@ -82,15 +81,15 @@ namespace pcr
}
- void SAL_CALL ControlHelper::dispose()
+ void SAL_CALL CommonBehaviourControlHelper::dispose()
{
m_pControlWindow.disposeAndClear();
}
- void ControlHelper::autoSizeWindow()
+ void CommonBehaviourControlHelper::autoSizeWindow()
{
- OSL_PRECOND( m_pControlWindow, "ControlHelper::autoSizeWindow: no window!" );
+ OSL_PRECOND( m_pControlWindow, "CommonBehaviourControlHelper::autoSizeWindow: no window!" );
if ( !m_pControlWindow )
return;
@@ -103,7 +102,7 @@ namespace pcr
}
- void ControlHelper::impl_activateNextControl_nothrow() const
+ void CommonBehaviourControlHelper::activateNextControl() const
{
try
{
@@ -117,15 +116,14 @@ namespace pcr
}
- IMPL_LINK( ControlHelper, ModifiedHdl, vcl::Window*, /*_pWin*/ )
+ IMPL_LINK( CommonBehaviourControlHelper, ModifiedHdl, vcl::Window*, /*_pWin*/ )
{
- if ( m_pModifyListener )
- m_pModifyListener->modified();
+ modified();
return 0;
}
- IMPL_LINK_NOARG_TYPED( ControlHelper, GetFocusHdl, Control&, void )
+ IMPL_LINK_NOARG_TYPED( CommonBehaviourControlHelper, GetFocusHdl, Control&, void )
{
try
{
@@ -139,7 +137,7 @@ namespace pcr
}
- IMPL_LINK_NOARG_TYPED( ControlHelper, LoseFocusHdl, Control&, void )
+ IMPL_LINK_NOARG_TYPED( CommonBehaviourControlHelper, LoseFocusHdl, Control&, void )
{
// TODO/UNOize: should this be outside the default control's implementations? If somebody
// has an own control implementation, which does *not* do this - would this be allowed?
diff --git a/extensions/source/propctrlr/commoncontrol.hxx b/extensions/source/propctrlr/commoncontrol.hxx
index 607d54d261ae..f8062adc52e2 100644
--- a/extensions/source/propctrlr/commoncontrol.hxx
+++ b/extensions/source/propctrlr/commoncontrol.hxx
@@ -34,13 +34,13 @@ namespace pcr
{
- class ControlHelper;
+ class CommonBehaviourControlHelper;
template< class TControlWindow >
class ControlWindow : public TControlWindow
{
protected:
- ControlHelper* m_pHelper;
+ CommonBehaviourControlHelper* m_pHelper;
public:
ControlWindow( vcl::Window* _pParent, WinBits _nStyle )
@@ -49,34 +49,20 @@ namespace pcr
{
}
- /// sets a ControlHelper instance which some functionality is delegated to
- virtual void setControlHelper( ControlHelper& _rControlHelper )
+ /// sets a CommonBehaviourControlHelper instance which some functionality is delegated to
+ virtual void setControlHelper( CommonBehaviourControlHelper& _rControlHelper )
{ m_pHelper = &_rControlHelper; }
};
- //= IModifyListener
-
- class SAL_NO_VTABLE IModifyListener
- {
- public:
- virtual void modified() = 0;
-
- protected:
- ~IModifyListener() {}
- };
-
-
- //= ControlHelper
+ //= CommonBehaviourControlHelper
/** A helper class for implementing the <type scope="css::inspection">XPropertyControl</type>
or one of its derived interfaces.
- This class is intended to be held as member of another class which implements the
- <type scope="css::inspection">XPropertyControl</type> interface. The pointer
- to this interface is to be passed to the ctor.
+ This class is used as a base class the CommonBehaviourControl template.
*/
- class ControlHelper
+ class CommonBehaviourControlHelper
{
private:
VclPtr<vcl::Window> m_pControlWindow;
@@ -85,7 +71,6 @@ namespace pcr
m_xContext;
css::inspection::XPropertyControl&
m_rAntiImpl;
- IModifyListener* m_pModifyListener;
bool m_bModified;
public:
@@ -93,36 +78,26 @@ namespace pcr
@param _rControlWindow
the window which is associated with the <type scope="css::inspection">XPropertyControl</type>.
Must not be <NULL/>.<br/>
- Ownership for this window is taken by the ControlHelper - it will be deleted in <member>disposing</member>.
+ Ownership for this window is taken by the CommonBehaviourControlHelper - it will be deleted in <member>disposing</member>.
@param _nControlType
the type of the control - one of the <type scope="css::inspection">PropertyControlType</type>
constants
@param _pAntiImpl
- Reference to the instance as whose "impl-class" we act. This reference is held during lifetime
- of the <type>ControlHelper</type> class, within acquiring it. Thus, the owner of the
- <type>ControlHelper</type> is responsible for assuring the lifetime of the instance
- pointed to by <arg>_pAntiImpl</arg>.
- @param _pModifyListener
- a listener to be modfied when the user modified the control's value. the
- <member>IModifyListener::modified</member> of this listener is called from within our
- ModifiedHdl. A default implementation of <member>IModifyListener::modified</member>
- would just call our <member>setModified</member>.
+ Reference to the instance as whose "impl-class" we act i.e. the CommonBehaviourControl<> template,
+ which is why we hold it without acquiring it/
*/
- ControlHelper(
+ CommonBehaviourControlHelper(
vcl::Window* _pControlWindow,
sal_Int16 _nControlType,
- css::inspection::XPropertyControl& _rAntiImpl,
- IModifyListener* _pModifyListener );
+ css::inspection::XPropertyControl& _rAntiImpl);
- virtual ~ControlHelper();
+ virtual ~CommonBehaviourControlHelper();
- /** sets our "modified" flag to <TRUE/>
- */
- inline void setModified() { m_bModified = true; }
inline vcl::Window* getVclControlWindow() { return m_pControlWindow; }
inline const vcl::Window* getVclControlWindow() const { return m_pControlWindow; }
- public:
+ virtual void modified() { m_bModified = true; }
+
// XPropertyControl
::sal_Int16 SAL_CALL getControlType() throw (css::uno::RuntimeException) { return m_nControlType; }
css::uno::Reference< css::inspection::XPropertyControlContext > SAL_CALL getControlContext() throw (css::uno::RuntimeException) { return m_xContext; }
@@ -136,9 +111,8 @@ namespace pcr
/** (fail-safe) wrapper around calling our context's activateNextControl
*/
- inline void activateNextControl() const { impl_activateNextControl_nothrow(); }
+ void activateNextControl() const;
- public:
/// automatically size the window given in the ctor
void autoSizeWindow();
@@ -146,19 +120,13 @@ namespace pcr
DECL_LINK( ModifiedHdl, vcl::Window* );
DECL_LINK_TYPED( GetFocusHdl, Control&, void );
DECL_LINK_TYPED( LoseFocusHdl, Control&, void );
-
- private:
- /** fail-safe wrapper around calling our context's activateNextControl
- */
- void impl_activateNextControl_nothrow() const;
};
//= CommonBehaviourControl
/** implements a base class for <type scope="css::inspection">XPropertyControl</type>
- implementations, which delegates the generic functionality of this interface to a
- <type>ControlHelper</type> member.
+ implementations
@param TControlInterface
an interface class which is derived from (or identical to) <type scope="css::inspection">XPropertyControl</type>
@@ -168,43 +136,37 @@ namespace pcr
template < class TControlInterface, class TControlWindow >
class CommonBehaviourControl :public ::comphelper::OBaseMutex
,public ::cppu::WeakComponentImplHelper< TControlInterface >
- ,public IModifyListener
+ ,public CommonBehaviourControlHelper
{
protected:
typedef ::comphelper::OBaseMutex MutexBaseClass;
typedef ::cppu::WeakComponentImplHelper< TControlInterface > ComponentBaseClass;
- protected:
- ControlHelper m_aImplControl;
-
- protected:
inline CommonBehaviourControl( sal_Int16 _nControlType, vcl::Window* _pParentWindow, WinBits _nWindowStyle, bool _bDoSetHandlers = true );
// XPropertyControl - delegated to ->m_aImplControl
virtual ::sal_Int16 SAL_CALL getControlType() throw (css::uno::RuntimeException) SAL_OVERRIDE
- { return m_aImplControl.getControlType(); }
+ { return CommonBehaviourControlHelper::getControlType(); }
virtual css::uno::Reference< css::inspection::XPropertyControlContext > SAL_CALL getControlContext() throw (css::uno::RuntimeException) SAL_OVERRIDE
- { return m_aImplControl.getControlContext(); }
+ { return CommonBehaviourControlHelper::getControlContext(); }
virtual void SAL_CALL setControlContext( const css::uno::Reference< css::inspection::XPropertyControlContext >& _controlcontext ) throw (css::uno::RuntimeException) SAL_OVERRIDE
- { m_aImplControl.setControlContext( _controlcontext ); }
+ { CommonBehaviourControlHelper::setControlContext( _controlcontext ); }
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL getControlWindow() throw (css::uno::RuntimeException) SAL_OVERRIDE
- { return m_aImplControl.getControlWindow(); }
+ { return CommonBehaviourControlHelper::getControlWindow(); }
virtual sal_Bool SAL_CALL isModified( ) throw (css::uno::RuntimeException) SAL_OVERRIDE
- { return m_aImplControl.isModified(); }
+ { return CommonBehaviourControlHelper::isModified(); }
virtual void SAL_CALL notifyModifiedValue( ) throw (css::uno::RuntimeException) SAL_OVERRIDE
- { m_aImplControl.notifyModifiedValue(); }
+ { CommonBehaviourControlHelper::notifyModifiedValue(); }
// XComponent
virtual void SAL_CALL disposing() SAL_OVERRIDE
- { m_aImplControl.dispose(); }
-
- // IModifyListener
- virtual void modified() SAL_OVERRIDE
- { m_aImplControl.setModified(); }
+ { CommonBehaviourControlHelper::dispose(); }
/// returns a typed pointer to our control window
- TControlWindow* getTypedControlWindow() { return static_cast< TControlWindow* > ( m_aImplControl.getVclControlWindow() ); }
- const TControlWindow* getTypedControlWindow() const { return static_cast< const TControlWindow* >( m_aImplControl.getVclControlWindow() ); }
+ TControlWindow* getTypedControlWindow()
+ { return static_cast< TControlWindow* >( CommonBehaviourControlHelper::getVclControlWindow() ); }
+ const TControlWindow* getTypedControlWindow() const
+ { return static_cast< const TControlWindow* >( CommonBehaviourControlHelper::getVclControlWindow() ); }
protected:
/** checks whether the instance is already disposed
@@ -221,17 +183,17 @@ namespace pcr
template< class TControlInterface, class TControlWindow >
inline CommonBehaviourControl< TControlInterface, TControlWindow >::CommonBehaviourControl ( sal_Int16 _nControlType, vcl::Window* _pParentWindow, WinBits _nWindowStyle, bool _bDoSetHandlers )
:ComponentBaseClass( m_aMutex )
- ,m_aImplControl( new TControlWindow( _pParentWindow, _nWindowStyle ), _nControlType, *this, this )
+ ,CommonBehaviourControlHelper( new TControlWindow( _pParentWindow, _nWindowStyle ), _nControlType, *this )
{
TControlWindow* pControlWindow( getTypedControlWindow() );
- pControlWindow->setControlHelper( m_aImplControl );
+ pControlWindow->setControlHelper( *this );
if ( _bDoSetHandlers )
{
- pControlWindow->SetModifyHdl( LINK( &m_aImplControl, ControlHelper, ModifiedHdl ) );
- pControlWindow->SetGetFocusHdl( LINK( &m_aImplControl, ControlHelper, GetFocusHdl ) );
- pControlWindow->SetLoseFocusHdl( LINK( &m_aImplControl, ControlHelper, LoseFocusHdl ) );
+ pControlWindow->SetModifyHdl( LINK( this, CommonBehaviourControlHelper, ModifiedHdl ) );
+ pControlWindow->SetGetFocusHdl( LINK( this, CommonBehaviourControlHelper, GetFocusHdl ) );
+ pControlWindow->SetLoseFocusHdl( LINK( this, CommonBehaviourControlHelper, LoseFocusHdl ) );
}
- m_aImplControl.autoSizeWindow();
+ autoSizeWindow();
}
diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx
index 88d63ff2a2aa..3620e383dd08 100644
--- a/extensions/source/propctrlr/standardcontrol.cxx
+++ b/extensions/source/propctrlr/standardcontrol.cxx
@@ -223,7 +223,7 @@ namespace pcr
// for password controls, we fire a commit for every single change
if ( m_bIsPassword )
- m_aImplControl.notifyModifiedValue();
+ notifyModifiedValue();
}
@@ -787,7 +787,7 @@ namespace pcr
if ( !getTypedControlWindow()->IsTravelSelect() )
// fire a commit
- m_aImplControl.notifyModifiedValue();
+ notifyModifiedValue();
}
@@ -879,7 +879,7 @@ namespace pcr
if ( !getTypedControlWindow()->IsTravelSelect() )
// fire a commit
- m_aImplControl.notifyModifiedValue();
+ notifyModifiedValue();
}
@@ -947,7 +947,7 @@ namespace pcr
{
if ( !getTypedControlWindow()->IsTravelSelect() )
// fire a commit
- m_aImplControl.notifyModifiedValue();
+ notifyModifiedValue();
return 0L;
}
@@ -1058,13 +1058,13 @@ namespace pcr
}
- void DropDownEditControl::setControlHelper( ControlHelper& _rControlHelper )
+ void DropDownEditControl::setControlHelper( CommonBehaviourControlHelper& _rControlHelper )
{
DropDownEditControl_Base::setControlHelper( _rControlHelper );
- m_pFloatingEdit->getEdit().SetModifyHdl( LINK( &_rControlHelper, ControlHelper, ModifiedHdl ) );
- m_pImplEdit->SetGetFocusHdl( LINK( &_rControlHelper, ControlHelper, GetFocusHdl ) );
- m_pImplEdit->SetModifyHdl( LINK( &_rControlHelper, ControlHelper, ModifiedHdl ) );
- m_pImplEdit->SetLoseFocusHdl( LINK( &_rControlHelper, ControlHelper, LoseFocusHdl ) );
+ m_pFloatingEdit->getEdit().SetModifyHdl( LINK( &_rControlHelper, CommonBehaviourControlHelper, ModifiedHdl ) );
+ m_pImplEdit->SetGetFocusHdl( LINK( &_rControlHelper, CommonBehaviourControlHelper, GetFocusHdl ) );
+ m_pImplEdit->SetModifyHdl( LINK( &_rControlHelper, CommonBehaviourControlHelper, ModifiedHdl ) );
+ m_pImplEdit->SetLoseFocusHdl( LINK( &_rControlHelper, CommonBehaviourControlHelper, LoseFocusHdl ) );
}
diff --git a/extensions/source/propctrlr/standardcontrol.hxx b/extensions/source/propctrlr/standardcontrol.hxx
index 594c306eb313..8c2220c7bf47 100644
--- a/extensions/source/propctrlr/standardcontrol.hxx
+++ b/extensions/source/propctrlr/standardcontrol.hxx
@@ -114,6 +114,7 @@ namespace pcr
virtual css::uno::Type SAL_CALL getValueType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
protected:
+ // CommonBehaviourControlHelper::modified
virtual void modified() SAL_OVERRIDE;
};
@@ -275,6 +276,7 @@ namespace pcr
virtual css::uno::Sequence< OUString > SAL_CALL getListEntries( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
protected:
+ // CommonBehaviourControlHelper::modified
virtual void modified() SAL_OVERRIDE;
};
@@ -301,6 +303,7 @@ namespace pcr
virtual css::uno::Sequence< OUString > SAL_CALL getListEntries( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
protected:
+ // CommonBehaviourControlHelper::modified
virtual void modified() SAL_OVERRIDE;
};
@@ -368,7 +371,7 @@ namespace pcr
GetStringListValue() const;
// ControlWindow overridables
- virtual void setControlHelper( ControlHelper& _rControlHelper ) SAL_OVERRIDE;
+ virtual void setControlHelper( CommonBehaviourControlHelper& _rControlHelper ) SAL_OVERRIDE;
protected:
// Window overridables