1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
29 #define _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
31 #include "commoncontrol.hxx"
32 #include "pcrcommon.hxx"
34 /** === begin UNO includes === **/
35 #include <com/sun/star/inspection/XNumericControl.hpp>
36 #include <com/sun/star/inspection/XStringListControl.hpp>
37 #include <com/sun/star/inspection/XHyperlinkControl.hpp>
38 #include <com/sun/star/uno/Sequence.hxx>
39 /** === end UNO includes === **/
40 #include <vcl/field.hxx>
41 #include <vcl/longcurr.hxx>
42 #include <svtools/ctrlbox.hxx>
43 #include <vcl/lstbox.hxx>
44 #include <vcl/combobox.hxx>
45 #include <svtools/calendar.hxx>
46 #include <svtools/fmtfield.hxx>
52 //............................................................................
55 //............................................................................
57 //========================================================================
58 //= ListLikeControlWithModifyHandler
59 //========================================================================
60 /** Very small helper class which adds a SetModifyHdl to a ListBox-derived class,
61 thus giving this class the same API (as far as the CommonBehaviourControl is concerned)
64 template< class LISTBOX_WINDOW
>
65 class ListLikeControlWithModifyHandler
: public ControlWindow
< LISTBOX_WINDOW
>
68 typedef ControlWindow
< LISTBOX_WINDOW
> ListBoxType
;
71 ListLikeControlWithModifyHandler( Window
* _pParent
, WinBits _nStyle
)
72 :ListBoxType( _pParent
, _nStyle
)
76 void SetModifyHdl( const Link
& _rLink
) { ListBoxType::SetSelectHdl( _rLink
); }
79 long PreNotify( NotifyEvent
& _rNEvt
);
82 //------------------------------------------------------------------------
83 template< class LISTBOX_WINDOW
>
84 long ListLikeControlWithModifyHandler
< LISTBOX_WINDOW
>::PreNotify( NotifyEvent
& _rNEvt
)
86 if ( _rNEvt
.GetType() == EVENT_KEYINPUT
)
88 const ::KeyEvent
* pKeyEvent
= _rNEvt
.GetKeyEvent();
89 if ( ( pKeyEvent
->GetKeyCode().GetModifier() == 0 )
90 && ( ( pKeyEvent
->GetKeyCode().GetCode() == KEY_PAGEUP
)
91 || ( pKeyEvent
->GetKeyCode().GetCode() == KEY_PAGEDOWN
)
95 if ( !ListBoxType::IsInDropDown() )
97 // don't give the base class a chance to consume the event, in the property browser, it is
98 // intended to scroll the complete property page
99 return ListBoxType::GetParent()->PreNotify( _rNEvt
);
103 return ListBoxType::PreNotify( _rNEvt
);
106 //========================================================================
108 //========================================================================
109 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, ControlWindow
< TimeField
> > OTimeControl_Base
;
110 class OTimeControl
: public OTimeControl_Base
113 OTimeControl( Window
* pParent
, WinBits nWinStyle
);
116 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
117 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
118 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
121 //========================================================================
123 //========================================================================
124 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, ControlWindow
< CalendarField
> > ODateControl_Base
;
125 class ODateControl
: public ODateControl_Base
128 ODateControl( Window
* pParent
, WinBits nWinStyle
);
131 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
132 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
133 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
136 //========================================================================
138 //========================================================================
139 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, ControlWindow
< Edit
> > OEditControl_Base
;
140 class OEditControl
: public OEditControl_Base
143 sal_Bool m_bIsPassword
: 1;
146 OEditControl( Window
* _pParent
, sal_Bool _bPassWord
, WinBits nWinStyle
);
149 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
150 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
151 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
154 virtual void modified();
157 //========================================================================
159 //========================================================================
160 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, ControlWindow
< FormattedField
> > ODateTimeControl_Base
;
161 class ODateTimeControl
: public ODateTimeControl_Base
164 ODateTimeControl( Window
* pParent
,WinBits nWinStyle
);
167 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
168 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
169 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
172 //========================================================================
174 //========================================================================
175 class HyperlinkInput
: public Edit
178 Point m_aMouseButtonDownPos
;
179 Link m_aClickHandler
;
182 HyperlinkInput( Window
* _pParent
, WinBits _nWinStyle
);
184 /** sets the handler which will (asynchronously, with locked SolarMutex) be called
185 when the hyperlink has been clicked by the user
187 void SetClickHdl( const Link
& _rHdl
) { m_aClickHandler
= _rHdl
; }
188 const Link
& GetClickHdl( ) const { return m_aClickHandler
; }
191 virtual void MouseMove( const MouseEvent
& rMEvt
);
192 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
193 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
194 virtual void Tracking( const TrackingEvent
& rTEvt
);
197 void impl_checkEndClick( const MouseEvent rMEvt
);
198 bool impl_textHitTest( const Point
& _rWindowPos
);
201 //========================================================================
202 //= OHyperlinkControl
203 //========================================================================
204 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XHyperlinkControl
, ControlWindow
< HyperlinkInput
> > OHyperlinkControl_Base
;
205 class OHyperlinkControl
: public OHyperlinkControl_Base
208 ::cppu::OInterfaceContainerHelper m_aActionListeners
;
211 OHyperlinkControl( Window
* _pParent
, WinBits _nWinStyle
);
214 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
215 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
216 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
219 virtual void SAL_CALL
addActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
>& listener
) throw (::com::sun::star::uno::RuntimeException
);
220 virtual void SAL_CALL
removeActionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
>& listener
) throw (::com::sun::star::uno::RuntimeException
);
224 virtual void SAL_CALL
disposing();
227 DECL_LINK( OnHyperlinkClicked
, void* );
230 //========================================================================
231 //= CustomConvertibleNumericField
232 //========================================================================
233 class CustomConvertibleNumericField
: public ControlWindow
< MetricField
>
235 typedef ControlWindow
< MetricField
> BaseClass
;
238 CustomConvertibleNumericField( Window
* _pParent
, WinBits _nStyle
)
239 :BaseClass( _pParent
, _nStyle
)
243 sal_Int64
GetLastValue() const { return mnLastValue
; }
246 //========================================================================
248 //========================================================================
249 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XNumericControl
, CustomConvertibleNumericField
> ONumericControl_Base
;
250 class ONumericControl
: public ONumericControl_Base
253 FieldUnit m_eValueUnit
;
254 sal_Int16 m_nFieldToUNOValueFactor
;
257 ONumericControl( Window
* pParent
, WinBits nWinStyle
);
260 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
261 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
262 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
265 virtual ::sal_Int16 SAL_CALL
getDecimalDigits() throw (::com::sun::star::uno::RuntimeException
);
266 virtual void SAL_CALL
setDecimalDigits( ::sal_Int16 _decimaldigits
) throw (::com::sun::star::uno::RuntimeException
);
267 virtual ::com::sun::star::beans::Optional
< double > SAL_CALL
getMinValue() throw (::com::sun::star::uno::RuntimeException
);
268 virtual void SAL_CALL
setMinValue( const ::com::sun::star::beans::Optional
< double >& _minvalue
) throw (::com::sun::star::uno::RuntimeException
);
269 virtual ::com::sun::star::beans::Optional
< double > SAL_CALL
getMaxValue() throw (::com::sun::star::uno::RuntimeException
);
270 virtual void SAL_CALL
setMaxValue( const ::com::sun::star::beans::Optional
< double >& _maxvalue
) throw (::com::sun::star::uno::RuntimeException
);
271 virtual ::sal_Int16 SAL_CALL
getDisplayUnit() throw (::com::sun::star::uno::RuntimeException
);
272 virtual void SAL_CALL
setDisplayUnit( ::sal_Int16 _displayunit
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
273 virtual ::sal_Int16 SAL_CALL
getValueUnit() throw (::com::sun::star::uno::RuntimeException
);
274 virtual void SAL_CALL
setValueUnit( ::sal_Int16 _valueunit
) throw (::com::sun::star::uno::RuntimeException
);
277 /** converts an API value (<code>double</code>, as passed into <code>set[Max|Min|]Value) into
278 a <code>long</code> value which can be passed to our NumericField.
280 The conversion respects our decimal digits as well as our value factor (<member>m_nFieldToUNOValueFactor</member>).
282 long impl_apiValueToFieldValue_nothrow( double _nApiValue
) const;
284 /** converts a control value, as obtained from our Numeric field, into a value which can passed
285 to outer callers via our UNO API.
287 double impl_fieldValueToApiValue_nothrow( sal_Int64 _nFieldValue
) const;
290 //========================================================================
292 //========================================================================
293 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XStringListControl
294 , ListLikeControlWithModifyHandler
< ColorListBox
>
295 > OColorControl_Base
;
296 class OColorControl
: public OColorControl_Base
299 ::std::set
< ::rtl::OUString
> m_aNonColorEntries
;
302 OColorControl( Window
* pParent
, WinBits nWinStyle
);
305 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
306 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
307 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
309 // XStringListControl
310 virtual void SAL_CALL
clearList( ) throw (::com::sun::star::uno::RuntimeException
);
311 virtual void SAL_CALL
prependListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
312 virtual void SAL_CALL
appendListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
313 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getListEntries( ) throw (::com::sun::star::uno::RuntimeException
);
316 virtual void modified();
319 //========================================================================
321 //========================================================================
322 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XStringListControl
323 , ListLikeControlWithModifyHandler
< ListBox
>
324 > OListboxControl_Base
;
325 class OListboxControl
: public OListboxControl_Base
328 OListboxControl( Window
* pParent
, WinBits nWinStyle
);
331 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
332 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
333 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
335 // XStringListControl
336 virtual void SAL_CALL
clearList( ) throw (::com::sun::star::uno::RuntimeException
);
337 virtual void SAL_CALL
prependListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
338 virtual void SAL_CALL
appendListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
339 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getListEntries( ) throw (::com::sun::star::uno::RuntimeException
);
342 virtual void modified();
345 //========================================================================
347 //========================================================================
348 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XStringListControl
, ControlWindow
< ComboBox
> > OComboboxControl_Base
;
349 class OComboboxControl
: public OComboboxControl_Base
352 OComboboxControl( Window
* pParent
, WinBits nWinStyle
);
355 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
356 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
357 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
359 // XStringListControl
360 virtual void SAL_CALL
clearList( ) throw (::com::sun::star::uno::RuntimeException
);
361 virtual void SAL_CALL
prependListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
362 virtual void SAL_CALL
appendListEntry( const ::rtl::OUString
& NewEntry
) throw (::com::sun::star::uno::RuntimeException
);
363 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getListEntries( ) throw (::com::sun::star::uno::RuntimeException
);
366 DECL_LINK( OnEntrySelected
, void* );
369 //========================================================================
370 //= DropDownEditControl
371 //========================================================================
372 enum MultiLineOperationMode
377 //========================================================================
378 //= DropDownEditControl
379 //========================================================================
380 class OMultilineFloatingEdit
;
381 typedef ControlWindow
< Edit
> DropDownEditControl_Base
;
382 /** an Edit field which can be used as ControlWindow, and has a drop-down button
384 class DropDownEditControl
: public DropDownEditControl_Base
387 OMultilineFloatingEdit
* m_pFloatingEdit
;
388 MultiLineEdit
* m_pImplEdit
;
389 PushButton
* m_pDropdownButton
;
390 MultiLineOperationMode m_nOperationMode
;
391 sal_Bool m_bDropdown
: 1;
394 DropDownEditControl( Window
* _pParent
, WinBits _nStyle
);
395 ~DropDownEditControl();
397 void setOperationMode( MultiLineOperationMode _eMode
) { m_nOperationMode
= _eMode
; }
398 MultiLineOperationMode
getOperationMode() const { return m_nOperationMode
; }
400 void SetTextValue( const ::rtl::OUString
& _rText
);
401 ::rtl::OUString
GetTextValue() const;
403 void SetStringListValue( const StlSyntaxSequence
< ::rtl::OUString
>& _rStrings
);
404 StlSyntaxSequence
< ::rtl::OUString
>
405 GetStringListValue() const;
407 // ControlWindow overridables
408 virtual void setControlHelper( ControlHelper
& _rControlHelper
);
411 // Window overridables
412 virtual long PreNotify( NotifyEvent
& rNEvt
);
413 virtual void Resize();
416 long FindPos(long nSinglePos
);
419 DECL_LINK( ReturnHdl
, OMultilineFloatingEdit
* );
420 DECL_LINK( DropDownHdl
, PushButton
* );
422 sal_Bool
ShowDropDown( sal_Bool bShow
);
425 //========================================================================
426 //= OMultilineEditControl
427 //========================================================================
428 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, DropDownEditControl
> OMultilineEditControl_Base
;
429 class OMultilineEditControl
: public OMultilineEditControl_Base
432 OMultilineEditControl( Window
* pParent
, MultiLineOperationMode _eMode
, WinBits nWinStyle
);
435 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
436 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
437 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
440 //............................................................................
442 //............................................................................
444 #endif // _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_