bump product version to 4.1.6.2
[LibreOffice.git] / extensions / source / propctrlr / standardcontrol.hxx
blobb7cd14efb3c7970c2a06ca30bc44bcb4f13fd3a0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
21 #define _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
23 #include "commoncontrol.hxx"
24 #include "pcrcommon.hxx"
26 #include <com/sun/star/inspection/XNumericControl.hpp>
27 #include <com/sun/star/inspection/XStringListControl.hpp>
28 #include <com/sun/star/inspection/XHyperlinkControl.hpp>
29 #include <com/sun/star/uno/Sequence.hxx>
30 #include <vcl/field.hxx>
31 #include <vcl/longcurr.hxx>
32 #include <svtools/ctrlbox.hxx>
33 #include <vcl/lstbox.hxx>
34 #include <vcl/combobox.hxx>
35 #include <svtools/calendar.hxx>
36 #include <svtools/fmtfield.hxx>
38 #include <set>
40 class PushButton;
41 class MultiLineEdit;
42 //............................................................................
43 namespace pcr
45 //............................................................................
47 //========================================================================
48 //= ListLikeControlWithModifyHandler
49 //========================================================================
50 /** Very small helper class which adds a SetModifyHdl to a ListBox-derived class,
51 thus giving this class the same API (as far as the CommonBehaviourControl is concerned)
52 as all other windows.
54 template< class LISTBOX_WINDOW >
55 class ListLikeControlWithModifyHandler : public ControlWindow< LISTBOX_WINDOW >
57 protected:
58 typedef ControlWindow< LISTBOX_WINDOW > ListBoxType;
60 public:
61 ListLikeControlWithModifyHandler( Window* _pParent, WinBits _nStyle )
62 :ListBoxType( _pParent, _nStyle )
66 void SetModifyHdl( const Link& _rLink ) { ListBoxType::SetSelectHdl( _rLink ); }
68 protected:
69 long PreNotify( NotifyEvent& _rNEvt );
72 //------------------------------------------------------------------------
73 template< class LISTBOX_WINDOW >
74 long ListLikeControlWithModifyHandler< LISTBOX_WINDOW >::PreNotify( NotifyEvent& _rNEvt )
76 if ( _rNEvt.GetType() == EVENT_KEYINPUT )
78 const ::KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent();
79 if ( ( pKeyEvent->GetKeyCode().GetModifier() == 0 )
80 && ( ( pKeyEvent->GetKeyCode().GetCode() == KEY_PAGEUP )
81 || ( pKeyEvent->GetKeyCode().GetCode() == KEY_PAGEDOWN )
85 if ( !ListBoxType::IsInDropDown() )
87 // don't give the base class a chance to consume the event, in the property browser, it is
88 // intended to scroll the complete property page
89 return ListBoxType::GetParent()->PreNotify( _rNEvt );
93 return ListBoxType::PreNotify( _rNEvt );
96 //========================================================================
97 //= OTimeControl
98 //========================================================================
99 typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< TimeField > > OTimeControl_Base;
100 class OTimeControl : public OTimeControl_Base
102 public:
103 OTimeControl( Window* pParent, WinBits nWinStyle );
105 // XPropertyControl
106 virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
107 virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
108 virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
111 //========================================================================
112 //= ODateControl
113 //========================================================================
114 typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< CalendarField > > ODateControl_Base;
115 class ODateControl : public ODateControl_Base
117 public:
118 ODateControl( Window* pParent, WinBits nWinStyle );
120 // XPropertyControl
121 virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
122 virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
123 virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
126 //========================================================================
127 //= OEditControl
128 //========================================================================
129 typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< Edit > > OEditControl_Base;
130 class OEditControl : public OEditControl_Base
132 protected:
133 sal_Bool m_bIsPassword : 1;
135 public:
136 OEditControl( Window* _pParent, sal_Bool _bPassWord, WinBits nWinStyle );
138 // XPropertyControl
139 virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
140 virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
141 virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
143 protected:
144 virtual void modified();
147 //========================================================================
148 //= ODateTimeControl
149 //========================================================================
150 typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< FormattedField > > ODateTimeControl_Base;
151 class ODateTimeControl : public ODateTimeControl_Base
153 public:
154 ODateTimeControl( Window* pParent,WinBits nWinStyle );
156 // XPropertyControl
157 virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
158 virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
159 virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
162 //========================================================================
163 //= HyperlinkInput
164 //========================================================================
165 class HyperlinkInput : public Edit
167 private:
168 Point m_aMouseButtonDownPos;
169 Link m_aClickHandler;
171 public:
172 HyperlinkInput( Window* _pParent, WinBits _nWinStyle );
174 /** sets the handler which will (asynchronously, with locked SolarMutex) be called
175 when the hyperlink has been clicked by the user
177 void SetClickHdl( const Link& _rHdl ) { m_aClickHandler = _rHdl; }
178 const Link& GetClickHdl( ) const { return m_aClickHandler; }
180 protected:
181 virtual void MouseMove( const MouseEvent& rMEvt );
182 virtual void MouseButtonDown( const MouseEvent& rMEvt );
183 virtual void MouseButtonUp( const MouseEvent& rMEvt );
184 virtual void Tracking( const TrackingEvent& rTEvt );
186 private:
187 void impl_checkEndClick( const MouseEvent rMEvt );
188 bool impl_textHitTest( const Point& _rWindowPos );
191 //========================================================================
192 //= OHyperlinkControl
193 //========================================================================
194 typedef CommonBehaviourControl< ::com::sun::star::inspection::XHyperlinkControl, ControlWindow< HyperlinkInput > > OHyperlinkControl_Base;
195 class OHyperlinkControl : public OHyperlinkControl_Base
197 private:
198 ::cppu::OInterfaceContainerHelper m_aActionListeners;
200 public:
201 OHyperlinkControl( Window* _pParent, WinBits _nWinStyle );
203 // XPropertyControl
204 virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
205 virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
206 virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
208 // XHyperlinkControl
209 virtual void SAL_CALL addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& listener ) throw (::com::sun::star::uno::RuntimeException);
210 virtual void SAL_CALL removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& listener ) throw (::com::sun::star::uno::RuntimeException);
212 protected:
213 // XComponent
214 virtual void SAL_CALL disposing();
216 protected:
217 DECL_LINK( OnHyperlinkClicked, void* );
220 //========================================================================
221 //= CustomConvertibleNumericField
222 //========================================================================
223 class CustomConvertibleNumericField : public ControlWindow< MetricField >
225 typedef ControlWindow< MetricField > BaseClass;
227 public:
228 CustomConvertibleNumericField( Window* _pParent, WinBits _nStyle )
229 :BaseClass( _pParent, _nStyle )
233 sal_Int64 GetLastValue() const { return mnLastValue; }
236 //========================================================================
237 //= ONumericControl
238 //========================================================================
239 typedef CommonBehaviourControl< ::com::sun::star::inspection::XNumericControl, CustomConvertibleNumericField > ONumericControl_Base;
240 class ONumericControl : public ONumericControl_Base
242 private:
243 FieldUnit m_eValueUnit;
244 sal_Int16 m_nFieldToUNOValueFactor;
246 public:
247 ONumericControl( Window* pParent, WinBits nWinStyle );
249 // XPropertyControl
250 virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
251 virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
252 virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
254 // XNumericControl
255 virtual ::sal_Int16 SAL_CALL getDecimalDigits() throw (::com::sun::star::uno::RuntimeException);
256 virtual void SAL_CALL setDecimalDigits( ::sal_Int16 _decimaldigits ) throw (::com::sun::star::uno::RuntimeException);
257 virtual ::com::sun::star::beans::Optional< double > SAL_CALL getMinValue() throw (::com::sun::star::uno::RuntimeException);
258 virtual void SAL_CALL setMinValue( const ::com::sun::star::beans::Optional< double >& _minvalue ) throw (::com::sun::star::uno::RuntimeException);
259 virtual ::com::sun::star::beans::Optional< double > SAL_CALL getMaxValue() throw (::com::sun::star::uno::RuntimeException);
260 virtual void SAL_CALL setMaxValue( const ::com::sun::star::beans::Optional< double >& _maxvalue ) throw (::com::sun::star::uno::RuntimeException);
261 virtual ::sal_Int16 SAL_CALL getDisplayUnit() throw (::com::sun::star::uno::RuntimeException);
262 virtual void SAL_CALL setDisplayUnit( ::sal_Int16 _displayunit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
263 virtual ::sal_Int16 SAL_CALL getValueUnit() throw (::com::sun::star::uno::RuntimeException);
264 virtual void SAL_CALL setValueUnit( ::sal_Int16 _valueunit ) throw (::com::sun::star::uno::RuntimeException);
266 private:
267 /** converts an API value (<code>double</code>, as passed into <code>set[Max|Min|]Value) into
268 a <code>long</code> value which can be passed to our NumericField.
270 The conversion respects our decimal digits as well as our value factor (<member>m_nFieldToUNOValueFactor</member>).
272 long impl_apiValueToFieldValue_nothrow( double _nApiValue ) const;
274 /** converts a control value, as obtained from our Numeric field, into a value which can passed
275 to outer callers via our UNO API.
277 double impl_fieldValueToApiValue_nothrow( sal_Int64 _nFieldValue ) const;
280 //========================================================================
281 //= OColorControl
282 //========================================================================
283 typedef CommonBehaviourControl < ::com::sun::star::inspection::XStringListControl
284 , ListLikeControlWithModifyHandler< ColorListBox >
285 > OColorControl_Base;
286 class OColorControl : public OColorControl_Base
288 private:
289 ::std::set< OUString > m_aNonColorEntries;
291 public:
292 OColorControl( Window* pParent, WinBits nWinStyle );
294 // XPropertyControl
295 virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
296 virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
297 virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
299 // XStringListControl
300 virtual void SAL_CALL clearList( ) throw (::com::sun::star::uno::RuntimeException);
301 virtual void SAL_CALL prependListEntry( const OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
302 virtual void SAL_CALL appendListEntry( const OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
303 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getListEntries( ) throw (::com::sun::star::uno::RuntimeException);
305 protected:
306 virtual void modified();
309 //========================================================================
310 //= OListboxControl
311 //========================================================================
312 typedef CommonBehaviourControl < ::com::sun::star::inspection::XStringListControl
313 , ListLikeControlWithModifyHandler< ListBox >
314 > OListboxControl_Base;
315 class OListboxControl : public OListboxControl_Base
317 public:
318 OListboxControl( Window* pParent, WinBits nWinStyle );
320 // XPropertyControl
321 virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
322 virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
323 virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
325 // XStringListControl
326 virtual void SAL_CALL clearList( ) throw (::com::sun::star::uno::RuntimeException);
327 virtual void SAL_CALL prependListEntry( const OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
328 virtual void SAL_CALL appendListEntry( const OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
329 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getListEntries( ) throw (::com::sun::star::uno::RuntimeException);
331 protected:
332 virtual void modified();
335 //========================================================================
336 //= OComboboxControl
337 //========================================================================
338 typedef CommonBehaviourControl< ::com::sun::star::inspection::XStringListControl, ControlWindow< ComboBox > > OComboboxControl_Base;
339 class OComboboxControl : public OComboboxControl_Base
341 public:
342 OComboboxControl( Window* pParent, WinBits nWinStyle );
344 // XPropertyControl
345 virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
346 virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
347 virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
349 // XStringListControl
350 virtual void SAL_CALL clearList( ) throw (::com::sun::star::uno::RuntimeException);
351 virtual void SAL_CALL prependListEntry( const OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
352 virtual void SAL_CALL appendListEntry( const OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
353 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getListEntries( ) throw (::com::sun::star::uno::RuntimeException);
355 protected:
356 DECL_LINK( OnEntrySelected, void* );
359 //========================================================================
360 //= DropDownEditControl
361 //========================================================================
362 enum MultiLineOperationMode
364 eStringList,
365 eMultiLineText
367 //========================================================================
368 //= DropDownEditControl
369 //========================================================================
370 class OMultilineFloatingEdit;
371 typedef ControlWindow< Edit > DropDownEditControl_Base;
372 /** an Edit field which can be used as ControlWindow, and has a drop-down button
374 class DropDownEditControl : public DropDownEditControl_Base
376 private:
377 OMultilineFloatingEdit* m_pFloatingEdit;
378 MultiLineEdit* m_pImplEdit;
379 PushButton* m_pDropdownButton;
380 MultiLineOperationMode m_nOperationMode;
381 sal_Bool m_bDropdown : 1;
383 public:
384 DropDownEditControl( Window* _pParent, WinBits _nStyle );
385 ~DropDownEditControl();
387 void setOperationMode( MultiLineOperationMode _eMode ) { m_nOperationMode = _eMode; }
388 MultiLineOperationMode getOperationMode() const { return m_nOperationMode; }
390 void SetTextValue( const OUString& _rText );
391 OUString GetTextValue() const;
393 void SetStringListValue( const StlSyntaxSequence< OUString >& _rStrings );
394 StlSyntaxSequence< OUString >
395 GetStringListValue() const;
397 // ControlWindow overridables
398 virtual void setControlHelper( ControlHelper& _rControlHelper );
400 protected:
401 // Window overridables
402 virtual long PreNotify( NotifyEvent& rNEvt );
403 virtual void Resize();
405 protected:
406 long FindPos(long nSinglePos);
408 private:
409 DECL_LINK( ReturnHdl, OMultilineFloatingEdit* );
410 DECL_LINK( DropDownHdl, PushButton* );
412 sal_Bool ShowDropDown( sal_Bool bShow );
415 //========================================================================
416 //= OMultilineEditControl
417 //========================================================================
418 typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, DropDownEditControl > OMultilineEditControl_Base;
419 class OMultilineEditControl : public OMultilineEditControl_Base
421 public:
422 OMultilineEditControl( Window* pParent, MultiLineOperationMode _eMode, WinBits nWinStyle );
424 // XPropertyControl
425 virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
426 virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
427 virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
430 //............................................................................
431 } // namespace pcr
432 //............................................................................
434 #endif // _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
436 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */