summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-10-09 16:22:24 +0200
committerNoel Grandin <noel@peralex.com>2015-10-12 09:13:34 +0200
commit70254f61ea889cde1eb49b417c8cd9819541b4f8 (patch)
tree63822b4528adf02e77e669b65d9e30e9a1c13a7c /extensions
parent42571e3d4e12c03f32197e9275fa203b86356942 (diff)
now we can push the controlwindow down and lose some type-casting
Change-Id: I3bc5963bad29898bd104feddef1bc1d00a1325e1
Diffstat (limited to 'extensions')
-rw-r--r--extensions/source/propctrlr/commoncontrol.cxx29
-rw-r--r--extensions/source/propctrlr/commoncontrol.hxx44
2 files changed, 23 insertions, 50 deletions
diff --git a/extensions/source/propctrlr/commoncontrol.cxx b/extensions/source/propctrlr/commoncontrol.cxx
index 21b9338a0e6f..04030f2649ca 100644
--- a/extensions/source/propctrlr/commoncontrol.cxx
+++ b/extensions/source/propctrlr/commoncontrol.cxx
@@ -36,13 +36,11 @@ namespace pcr
using ::com::sun::star::uno::Exception;
using ::com::sun::star::inspection::XPropertyControl;
- CommonBehaviourControlHelper::CommonBehaviourControlHelper( vcl::Window* _pControlWindow, sal_Int16 _nControlType, XPropertyControl& _rAntiImpl )
- :m_pControlWindow( _pControlWindow )
- ,m_nControlType( _nControlType )
+ CommonBehaviourControlHelper::CommonBehaviourControlHelper( sal_Int16 _nControlType, XPropertyControl& _rAntiImpl )
+ :m_nControlType( _nControlType )
,m_rAntiImpl( _rAntiImpl )
,m_bModified( false )
{
- DBG_ASSERT( m_pControlWindow != nullptr, "CommonBehaviourControlHelper::CommonBehaviourControlHelper: invalid window!" );
}
@@ -55,15 +53,6 @@ namespace pcr
m_xContext = _controlcontext;
}
-
- Reference< XWindow > SAL_CALL CommonBehaviourControlHelper::getControlWindow() throw (RuntimeException)
- {
- return VCLUnoHelper::GetInterface( m_pControlWindow );
- }
-
-
-
-
void SAL_CALL CommonBehaviourControlHelper::notifyModifiedValue( ) throw (RuntimeException)
{
if ( isModified() && m_xContext.is() )
@@ -81,21 +70,11 @@ namespace pcr
}
- void SAL_CALL CommonBehaviourControlHelper::dispose()
- {
- m_pControlWindow.disposeAndClear();
- }
-
-
void CommonBehaviourControlHelper::autoSizeWindow()
{
- OSL_PRECOND( m_pControlWindow, "CommonBehaviourControlHelper::autoSizeWindow: no window!" );
- if ( !m_pControlWindow )
- return;
-
- ScopedVclPtrInstance< ComboBox > aComboBox(m_pControlWindow, WB_DROPDOWN);
+ ScopedVclPtrInstance< ComboBox > aComboBox(getVclWindow(), WB_DROPDOWN);
aComboBox->SetPosSizePixel(Point(0,0), Size(100,100));
- m_pControlWindow->SetSizePixel(aComboBox->GetSizePixel());
+ getVclWindow()->SetSizePixel(aComboBox->GetSizePixel());
// TODO/UNOize: why do the controls this themselves? Shouldn't this be the task
// of the browser listbox/line?
diff --git a/extensions/source/propctrlr/commoncontrol.hxx b/extensions/source/propctrlr/commoncontrol.hxx
index f8062adc52e2..3a3509a484c8 100644
--- a/extensions/source/propctrlr/commoncontrol.hxx
+++ b/extensions/source/propctrlr/commoncontrol.hxx
@@ -26,6 +26,7 @@
#include <comphelper/broadcasthelper.hxx>
#include <tools/link.hxx>
#include <vcl/window.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
class NotifyEvent;
class Control;
@@ -65,7 +66,6 @@ namespace pcr
class CommonBehaviourControlHelper
{
private:
- VclPtr<vcl::Window> m_pControlWindow;
sal_Int16 m_nControlType;
css::uno::Reference< css::inspection::XPropertyControlContext >
m_xContext;
@@ -75,10 +75,6 @@ namespace pcr
public:
/** creates the instance
- @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 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
@@ -87,28 +83,20 @@ namespace pcr
which is why we hold it without acquiring it/
*/
CommonBehaviourControlHelper(
- vcl::Window* _pControlWindow,
sal_Int16 _nControlType,
css::inspection::XPropertyControl& _rAntiImpl);
virtual ~CommonBehaviourControlHelper();
- inline vcl::Window* getVclControlWindow() { return m_pControlWindow; }
- inline const vcl::Window* getVclControlWindow() const { return m_pControlWindow; }
-
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; }
void SAL_CALL setControlContext( const css::uno::Reference< css::inspection::XPropertyControlContext >& _controlcontext ) throw (css::uno::RuntimeException);
- css::uno::Reference< css::awt::XWindow > SAL_CALL getControlWindow() throw (css::uno::RuntimeException);
bool SAL_CALL isModified( ) throw (css::uno::RuntimeException) { return m_bModified; }
void SAL_CALL notifyModifiedValue( ) throw (css::uno::RuntimeException);
- // XComponent
- void SAL_CALL dispose();
-
/** (fail-safe) wrapper around calling our context's activateNextControl
*/
void activateNextControl() const;
@@ -116,6 +104,8 @@ namespace pcr
/// automatically size the window given in the ctor
void autoSizeWindow();
+ virtual vcl::Window* getVclWindow() = 0;
+
/// may be used by derived classes, they forward the event to the PropCtrListener
DECL_LINK( ModifiedHdl, vcl::Window* );
DECL_LINK_TYPED( GetFocusHdl, Control&, void );
@@ -152,7 +142,7 @@ namespace pcr
virtual void SAL_CALL setControlContext( const css::uno::Reference< css::inspection::XPropertyControlContext >& _controlcontext ) throw (css::uno::RuntimeException) SAL_OVERRIDE
{ CommonBehaviourControlHelper::setControlContext( _controlcontext ); }
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL getControlWindow() throw (css::uno::RuntimeException) SAL_OVERRIDE
- { return CommonBehaviourControlHelper::getControlWindow(); }
+ { return VCLUnoHelper::GetInterface( m_pControlWindow ); }
virtual sal_Bool SAL_CALL isModified( ) throw (css::uno::RuntimeException) SAL_OVERRIDE
{ return CommonBehaviourControlHelper::isModified(); }
virtual void SAL_CALL notifyModifiedValue( ) throw (css::uno::RuntimeException) SAL_OVERRIDE
@@ -160,20 +150,24 @@ namespace pcr
// XComponent
virtual void SAL_CALL disposing() SAL_OVERRIDE
- { CommonBehaviourControlHelper::dispose(); }
+ { m_pControlWindow.disposeAndClear(); }
+
+ // CommonBehaviourControlHelper::getVclWindow
+ virtual vcl::Window* getVclWindow() SAL_OVERRIDE
+ { return m_pControlWindow.get(); }
- /// returns a typed pointer to our control window
TControlWindow* getTypedControlWindow()
- { return static_cast< TControlWindow* >( CommonBehaviourControlHelper::getVclControlWindow() ); }
+ { return m_pControlWindow.get(); }
const TControlWindow* getTypedControlWindow() const
- { return static_cast< const TControlWindow* >( CommonBehaviourControlHelper::getVclControlWindow() ); }
+ { return m_pControlWindow.get(); }
- protected:
/** checks whether the instance is already disposed
@throws DisposedException
if the instance is already disposed
*/
inline void impl_checkDisposed_throw();
+ private:
+ VclPtr<TControlWindow> m_pControlWindow;
};
@@ -183,15 +177,15 @@ 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 )
- ,CommonBehaviourControlHelper( new TControlWindow( _pParentWindow, _nWindowStyle ), _nControlType, *this )
+ ,CommonBehaviourControlHelper( _nControlType, *this )
+ ,m_pControlWindow( new TControlWindow( _pParentWindow, _nWindowStyle ) )
{
- TControlWindow* pControlWindow( getTypedControlWindow() );
- pControlWindow->setControlHelper( *this );
+ m_pControlWindow->setControlHelper( *this );
if ( _bDoSetHandlers )
{
- pControlWindow->SetModifyHdl( LINK( this, CommonBehaviourControlHelper, ModifiedHdl ) );
- pControlWindow->SetGetFocusHdl( LINK( this, CommonBehaviourControlHelper, GetFocusHdl ) );
- pControlWindow->SetLoseFocusHdl( LINK( this, CommonBehaviourControlHelper, LoseFocusHdl ) );
+ m_pControlWindow->SetModifyHdl( LINK( this, CommonBehaviourControlHelper, ModifiedHdl ) );
+ m_pControlWindow->SetGetFocusHdl( LINK( this, CommonBehaviourControlHelper, GetFocusHdl ) );
+ m_pControlWindow->SetLoseFocusHdl( LINK( this, CommonBehaviourControlHelper, LoseFocusHdl ) );
}
autoSizeWindow();
}