diff --git a/extensions/source/propctrlr/standardcontrol.hxx b/extensions/source/propctrlr/standardcontrol.hxx index ffdb51dfcddb..60494c6da8ab 100644 --- a/extensions/source/propctrlr/standardcontrol.hxx +++ b/extensions/source/propctrlr/standardcontrol.hxx @@ -4,9 +4,9 @@ * * $RCSfile: standardcontrol.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: rt $ $Date: 2005-09-08 20:28:33 $ + * last change: $Author: vg $ $Date: 2006-03-14 11:33:05 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -39,6 +39,25 @@ #ifndef _EXTENSIONS_PROPCTRLR_COMMONCONTROL_HXX_ #include "commoncontrol.hxx" #endif +#ifndef _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_ +#include "pcrcommon.hxx" +#endif + +/** === begin UNO includes === **/ +#ifndef _COM_SUN_STAR_INSPECTION_XNUMERICCONTROL_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_INSPECTION_XSTRINGLISTCONTROL_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_INSPECTION_XHYPERLINKCONTROL_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include +#endif +/** === end UNO includes === **/ + #ifndef _SV_FIELD_HXX #include #endif @@ -61,7 +80,7 @@ #include #endif -#include +#include class PushButton; class MultiLineEdit; @@ -70,234 +89,354 @@ namespace pcr { //............................................................................ - class StringRepresentation; + //======================================================================== + //= ListLikeControlWithModifyHandler + //======================================================================== + /** Very small helper class which adds a SetModifyHdl to a ListBox-derived class, + thus giving this class the same API (as far as the CommonBehaviourControl is concerned) + as all other windows. + */ + template< class LISTBOX_WINDOW > + class ListLikeControlWithModifyHandler : public ControlWindow< LISTBOX_WINDOW > + { + protected: + typedef ControlWindow< LISTBOX_WINDOW > ListBoxType; + public: + ListLikeControlWithModifyHandler( Window* _pParent, WinBits _nStyle ) + :ListBoxType( _pParent, _nStyle ) + { + } + + void SetModifyHdl( const Link& _rLink ) { ListBoxType::SetSelectHdl( _rLink ); } + }; //======================================================================== //= OTimeControl //======================================================================== - class OTimeControl : public OCommonBehaviourControl, TimeField + typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< TimeField > > OTimeControl_Base; + class OTimeControl : public OTimeControl_Base { - protected: - virtual long PreNotify( NotifyEvent& rNEvt ); - public: - OTimeControl( Window* pParent, WinBits nWinStyle = WB_TABSTOP); + OTimeControl( Window* pParent, WinBits nWinStyle ); - virtual void SetProperty(const ::rtl::OUString &rString,sal_Bool bIsUnknown=sal_False); - virtual ::rtl::OUString GetProperty()const; + // XPropertyControl + virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException); }; //======================================================================== //= ODateControl //======================================================================== - class ODateControl : public OCommonBehaviourControl, CalendarField + typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< CalendarField > > ODateControl_Base; + class ODateControl : public ODateControl_Base { - protected: - virtual long PreNotify( NotifyEvent& rNEvt ); - public: - ODateControl( Window* pParent, WinBits nWinStyle = WB_TABSTOP); + ODateControl( Window* pParent, WinBits nWinStyle ); - virtual void SetProperty(const ::rtl::OUString &rString,sal_Bool bIsUnknown=sal_False); - virtual ::rtl::OUString GetProperty()const; + // XPropertyControl + virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException); }; //======================================================================== //= OEditControl //======================================================================== - class OEditControl : public OCommonBehaviourControl, Edit + typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< Edit > > OEditControl_Base; + class OEditControl : public OEditControl_Base { protected: - sal_Bool m_bIsPassword : 1; - - protected: - virtual long PreNotify( NotifyEvent& rNEvt ); + sal_Bool m_bIsPassword : 1; public: - OEditControl(Window* _pParent, sal_Bool _bPassWord, WinBits nWinStyle = WB_TABSTOP); + OEditControl( Window* _pParent, sal_Bool _bPassWord, WinBits nWinStyle ); - virtual void SetProperty(const ::rtl::OUString &rString,sal_Bool bIsUnknown=sal_False); - virtual ::rtl::OUString GetProperty()const; + // XPropertyControl + virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException); protected: - virtual void modified(Window* _pSource); - }; - - //======================================================================== - //= OCurrencyControl - //======================================================================== - class OCurrencyControl : public OCommonBehaviourControl, LongCurrencyField - { - protected: - virtual long PreNotify( NotifyEvent& rNEvt ); - - public: - OCurrencyControl( Window* pParent,sal_uInt16 nDigits, - WinBits nWinStyle = WB_TABSTOP); - - virtual void SetProperty(const ::rtl::OUString &rString,sal_Bool bIsUnknown=sal_False); - virtual ::rtl::OUString GetProperty()const; + virtual void modified(); }; //======================================================================== //= ODateTimeControl //======================================================================== - class ODateTimeControl : public OCommonBehaviourControl, FormattedField + typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< FormattedField > > ODateTimeControl_Base; + class ODateTimeControl : public ODateTimeControl_Base + { + public: + ODateTimeControl( Window* pParent,WinBits nWinStyle ); + + // XPropertyControl + virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException); + }; + + //======================================================================== + //= HyperlinkInput + //======================================================================== + class HyperlinkInput : public Edit { private: - ::std::auto_ptr< StringRepresentation > m_pConverter; + Point m_aMouseButtonDownPos; + Link m_aClickHandler; public: - ODateTimeControl( Window* pParent,sal_uInt16 nDigits, WinBits nWinStyle = WB_TABSTOP ); + HyperlinkInput( Window* _pParent, WinBits _nWinStyle ); - virtual void SetProperty( const ::rtl::OUString& _rString,sal_Bool _bIsUnknown = sal_False ); - virtual ::rtl::OUString GetProperty() const; + /** sets the handler which will (asynchronously, with locked SolarMutex) be called + when the hyperlink has been clicked by the user + */ + void SetClickHdl( const Link& _rHdl ) { m_aClickHandler = _rHdl; } + const Link& GetClickHdl( ) const { return m_aClickHandler; } + + protected: + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void Tracking( const TrackingEvent& rTEvt ); + + private: + void impl_checkEndClick( const MouseEvent rMEvt ); + bool impl_textHitTest( const Point& _rWindowPos ); + }; + + //======================================================================== + //= OHyperlinkControl + //======================================================================== + typedef CommonBehaviourControl< ::com::sun::star::inspection::XHyperlinkControl, ControlWindow< HyperlinkInput > > OHyperlinkControl_Base; + class OHyperlinkControl : public OHyperlinkControl_Base + { + private: + ::cppu::OInterfaceContainerHelper m_aActionListeners; + + public: + OHyperlinkControl( Window* _pParent, WinBits _nWinStyle ); + + // XPropertyControl + virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException); + + // XHyperlinkControl + virtual void SAL_CALL addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& listener ) throw (::com::sun::star::uno::RuntimeException); + + protected: + // XComponent + virtual void SAL_CALL disposing(); + + protected: + DECL_LINK( OnHyperlinkClicked, void* ); + }; + + //======================================================================== + //= CustomConvertibleNumericField + //======================================================================== + class CustomConvertibleNumericField : public ControlWindow< MetricField > + { + typedef ControlWindow< MetricField > BaseClass; + + public: + CustomConvertibleNumericField( Window* _pParent, WinBits _nStyle ) + :BaseClass( _pParent, _nStyle ) + { + } + + long GetLastValue() const { return mnLastValue; } }; //======================================================================== //= ONumericControl //======================================================================== - class ONumericControl : public OCommonBehaviourControl, MetricField + typedef CommonBehaviourControl< ::com::sun::star::inspection::XNumericControl, CustomConvertibleNumericField > ONumericControl_Base; + class ONumericControl : public ONumericControl_Base { private: FieldUnit m_eValueUnit; - - protected: - virtual long PreNotify( NotifyEvent& rNEvt ); + sal_Int16 m_nFieldToUNOValueFactor; public: - ONumericControl( Window* pParent, sal_uInt16 nDigits, WinBits nWinStyle = WB_TABSTOP ); + ONumericControl( Window* pParent, WinBits nWinStyle ); - virtual void SetProperty(const ::rtl::OUString &rString,sal_Bool bIsUnknown=sal_False); - virtual ::rtl::OUString GetProperty()const; + // XPropertyControl + virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException); - void SetMin(sal_Int32 _nMin) { MetricField::SetMin(_nMin); } - void SetMax(sal_Int32 _nMax) { MetricField::SetMax(_nMax); } - void SetFieldUnit( FieldUnit _eUnit ) { MetricField::SetUnit( _eUnit ); } - void SetValueUnit( FieldUnit _eUnit ) { m_eValueUnit = _eUnit; } + // XNumericControl + virtual ::sal_Int16 SAL_CALL getDecimalDigits() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDecimalDigits( ::sal_Int16 _decimaldigits ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::beans::Optional< double > SAL_CALL getMinValue() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setMinValue( const ::com::sun::star::beans::Optional< double >& _minvalue ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::beans::Optional< double > SAL_CALL getMaxValue() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setMaxValue( const ::com::sun::star::beans::Optional< double >& _maxvalue ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getDisplayUnit() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDisplayUnit( ::sal_Int16 _displayunit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getValueUnit() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setValueUnit( ::sal_Int16 _valueunit ) throw (::com::sun::star::uno::RuntimeException); - protected: - MetricField::SetUnit; - MetricField::SetCustomUnitText; - MetricField::GetCurUnitText; - MetricField::SetValue; - protected: - inline long GetLastValue() const { return mnLastValue; } + private: + /** converts an API value (double, as passed into set[Max|Min|]Value) into + a long value which can be passed to our NumericField. + + The conversion respects our decimal digits as well as our value factor (m_nFieldToUNOValueFactor). + */ + long impl_apiValueToFieldValue_nothrow( double _nApiValue ) const; + + /** converts a control value, as obtained from our Numeric field, into a value which can passed + to outer callers via our UNO API. + */ + double impl_fieldValueToApiValue_nothrow( long _nFieldValue ) const; }; //======================================================================== //= OColorControl //======================================================================== - class OColorControl : public OCommonBehaviourControl, ColorListBox + typedef CommonBehaviourControl < ::com::sun::star::inspection::XStringListControl + , ListLikeControlWithModifyHandler< ColorListBox > + > OColorControl_Base; + class OColorControl : public OColorControl_Base { - protected: - virtual long PreNotify( NotifyEvent& rNEvt ); + private: + ::std::set< ::rtl::OUString > m_aNonColorEntries; public: - OColorControl( Window* pParent, WinBits nWinStyle = WB_TABSTOP |WB_DROPDOWN|WB_AUTOSIZE); + OColorControl( Window* pParent, WinBits nWinStyle ); - // property value handling - virtual void SetProperty(const ::rtl::OUString &rString,sal_Bool bIsUnknown=sal_False); - virtual ::rtl::OUString GetProperty()const; + // XPropertyControl + virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException); - // list handling - virtual sal_Bool HasList(); - virtual void ClearList(); - virtual void InsertCtrEntry( const ::rtl::OUString& rString, sal_uInt16 nPos = LISTBOX_APPEND ); - - virtual void SetCtrSize(const Size& rSize); + // XStringListControl + virtual void SAL_CALL clearList( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL prependListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL appendListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException); protected: - virtual void modified(Window* _pSource); + virtual void modified(); }; //======================================================================== //= OListboxControl //======================================================================== - class OListboxControl : public OCommonBehaviourControl, ListBox + typedef CommonBehaviourControl < ::com::sun::star::inspection::XStringListControl + , ListLikeControlWithModifyHandler< ListBox > + > OListboxControl_Base; + class OListboxControl : public OListboxControl_Base { - protected: - virtual long PreNotify( NotifyEvent& rNEvt ); - public: - OListboxControl( Window* pParent, WinBits nWinStyle = WB_TABSTOP|WB_SORT|WB_DROPDOWN|WB_AUTOSIZE); + OListboxControl( Window* pParent, WinBits nWinStyle ); - // property value handling - virtual void SetProperty(const ::rtl::OUString &rString,sal_Bool bIsUnknown=sal_False); - virtual ::rtl::OUString GetProperty()const; + // XPropertyControl + virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException); - // list handling - virtual sal_Bool HasList(); - virtual void ClearList(); - virtual void InsertCtrEntry( const ::rtl::OUString& rString, sal_uInt16 nPos = LISTBOX_APPEND ); - - virtual void SetCtrSize(const Size& rSize); + // XStringListControl + virtual void SAL_CALL clearList( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL prependListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL appendListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException); protected: - virtual void modified(Window* _pSource); + virtual void modified(); }; //======================================================================== //= OComboboxControl //======================================================================== - class OComboboxControl : public OCommonBehaviourControl, ComboBox + typedef CommonBehaviourControl< ::com::sun::star::inspection::XStringListControl, ControlWindow< ComboBox > > OComboboxControl_Base; + class OComboboxControl : public OComboboxControl_Base { - protected: - virtual long PreNotify( NotifyEvent& rNEvt ); + public: + OComboboxControl( Window* pParent, WinBits nWinStyle ); + // XPropertyControl + virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException); + + // XStringListControl + virtual void SAL_CALL clearList( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL prependListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL appendListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException); + + }; + + //======================================================================== + //= DropDownEditControl + //======================================================================== + enum MultiLineOperationMode + { + eStringList, + eMultiLineText + }; + //======================================================================== + //= DropDownEditControl + //======================================================================== + class OMultilineFloatingEdit; + typedef ControlWindow< Edit > DropDownEditControl_Base; + /** an Edit field which can be used as ControlWindow, and has a drop-down button + */ + class DropDownEditControl : public DropDownEditControl_Base + { + private: + OMultilineFloatingEdit* m_pFloatingEdit; + MultiLineEdit* m_pImplEdit; + PushButton* m_pDropdownButton; + MultiLineOperationMode m_nOperationMode; + sal_Bool m_bDropdown : 1; public: - OComboboxControl( Window* pParent, - WinBits nWinStyle = WB_TABSTOP | WB_SORT | WB_DROPDOWN | WB_AUTOSIZE); + DropDownEditControl( Window* _pParent, WinBits _nStyle ); + ~DropDownEditControl(); - // property value handling - virtual void SetProperty(const ::rtl::OUString &rString,sal_Bool bIsUnknown=sal_False); - virtual ::rtl::OUString GetProperty()const; + void setOperationMode( MultiLineOperationMode _eMode ) { m_nOperationMode = _eMode; } + MultiLineOperationMode getOperationMode() const { return m_nOperationMode; } - // list handling - virtual sal_Bool HasList(); - virtual void ClearList(); - virtual void InsertCtrEntry( const ::rtl::OUString& rString, sal_uInt16 nPos = LISTBOX_APPEND ); + void SetTextValue( const ::rtl::OUString& _rText ); + ::rtl::OUString GetTextValue() const; - virtual void SetCtrSize(const Size& rSize); + void SetStringListValue( const StlSyntaxSequence< ::rtl::OUString >& _rStrings ); + StlSyntaxSequence< ::rtl::OUString > + GetStringListValue() const; + // ControlWindow overridables + virtual void setControlHelper( ControlHelper& _rControlHelper ); + + protected: + // Window overridables + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual void Resize(); + + protected: + long FindPos(long nSinglePos); + + private: + DECL_LINK( ReturnHdl, OMultilineFloatingEdit* ); + DECL_LINK( DropDownHdl, PushButton* ); + + sal_Bool ShowDropDown( sal_Bool bShow ); }; //======================================================================== //= OMultilineEditControl //======================================================================== - class OMultilineFloatingEdit; - class OMultilineEditControl : public OCommonBehaviourControl, Edit + typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, DropDownEditControl > OMultilineEditControl_Base; + class OMultilineEditControl : public OMultilineEditControl_Base { - OMultilineFloatingEdit* m_pFloatingEdit; - MultiLineEdit* m_pImplEdit; - PushButton* m_pDropdownButton; - sal_Bool m_bDropdown :1; - sal_Bool m_bEdit :1; - - DECL_LINK(ReturnHdl,OMultilineFloatingEdit*); - DECL_LINK(DropDownHdl, PushButton*); - - protected: - - virtual long PreNotify( NotifyEvent& rNEvt ); - void Resize(); - - long FindPos(long nSinglePos); - public: - OMultilineEditControl( Window* pParent,sal_Bool bEdit, - WinBits nWinStyle = WB_TABSTOP | WB_DROPDOWN); + OMultilineEditControl( Window* pParent, MultiLineOperationMode _eMode, WinBits nWinStyle ); - ~OMultilineEditControl(); - - virtual sal_Bool ShowDropDown( sal_Bool bShow ); - - virtual void SetProperty(const ::rtl::OUString &rString,sal_Bool bIsUnknown=sal_False); - virtual ::rtl::OUString GetProperty()const; - - protected: - virtual void modified(Window* _pSource); + // XPropertyControl + virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException); }; //............................................................................