xref: /aoo42x/main/toolkit/source/layout/vcl/wfield.cxx (revision 5e0f18e3)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "wrapper.hxx"
25 
26 #include <comphelper/processfactory.hxx>
27 #include <com/sun/star/awt/XMetricField.hpp>
28 #include <com/sun/star/awt/XNumericField.hpp>
29 #include <com/sun/star/awt/XTextComponent.hpp>
30 #include <com/sun/star/awt/XListBox.hpp>
31 #include <com/sun/star/awt/XComboBox.hpp>
32 #include <cppuhelper/implbase1.hxx>
33 #include <com/sun/star/awt/XActionListener.hpp>
34 #include <com/sun/star/awt/XItemListener.hpp>
35 #include <com/sun/star/awt/XMouseListener.hpp>
36 #include <vcl/combobox.hxx>
37 #include <vcl/lstbox.hxx>
38 
39 #include <toolkit/awt/vclxwindows.hxx>
40 
41 using namespace ::com::sun::star;
42 using rtl::OUString;
43 
44 #define LAYOUT_API_CALLS_HANDLER 0
45 
46 namespace layout
47 {
48 
49 class EditImpl : public ControlImpl
50                , public ::cppu::WeakImplHelper1< awt::XTextListener >
51 {
52 public:
53     Link maModifyHdl;
54 
55     uno::Reference< awt::XTextComponent > mxEdit;
EditImpl(Context * context,const PeerHandle & peer,Window * window)56     EditImpl( Context *context, const PeerHandle &peer, Window *window )
57         : ControlImpl( context, peer, window )
58         , mxEdit( peer, uno::UNO_QUERY )
59     {
60     }
61 
62     ~EditImpl ();
63 
64     virtual void SAL_CALL disposing( lang::EventObject const& e )
65         throw (uno::RuntimeException);
66 
67     virtual void SetModifyHdl( Link const& link );
68 
textChanged(const awt::TextEvent &)69     void SAL_CALL textChanged( const awt::TextEvent& /* rEvent */ )
70         throw (uno::RuntimeException)
71     {
72         maModifyHdl.Call( mpWindow );
73     }
74 };
75 
~EditImpl()76 EditImpl::~EditImpl ()
77 {
78 }
79 
disposing(lang::EventObject const & e)80 void SAL_CALL EditImpl::disposing( lang::EventObject const& e )
81     throw (uno::RuntimeException)
82 {
83     ControlImpl::disposing (e);
84     mxEdit.clear ();
85 }
86 
SetModifyHdl(Link const & link)87 void EditImpl::SetModifyHdl( Link const& link )
88 {
89     if (!link && !!maModifyHdl)
90         mxEdit->removeTextListener( this );
91     else if (!!link && !maModifyHdl)
92         mxEdit->addTextListener( this );
93     maModifyHdl = link;
94 }
95 
~Edit()96 Edit::~Edit ()
97 {
98     SetModifyHdl (Link ());
99 }
100 
SetSelection(Selection const & rSelection)101 void Edit::SetSelection( Selection const& rSelection )
102 {
103 #if LAYOUT_API_CALLS_HANDLER
104     if ( !getImpl()->mxEdit.is() )
105         getImpl()->mxEdit->setSelection( awt::Selection( rSelection.Min(), rSelection.Max() ) );
106 #else /* !LAYOUT_API_CALLS_HANDLER */
107     GetEdit ()->SetSelection (rSelection);
108 #endif /* !LAYOUT_API_CALLS_HANDLER */
109 }
110 
SetText(OUString const & rStr)111 void Edit::SetText( OUString const& rStr )
112 {
113 #if LAYOUT_API_CALLS_HANDLER
114     if ( getImpl()->mxEdit.is() )
115         /// this calls handlers; endless loop in numfmt.cxx
116         getImpl()->mxEdit->setText( rStr );
117 #else /* !LAYOUT_API_CALLS_HANDLER */
118     GetEdit ()->SetText (rStr);
119 #endif /* !LAYOUT_API_CALLS_HANDLER */
120 }
121 
GetText() const122 String Edit::GetText() const
123 {
124     if ( !getImpl()->mxEdit.is() )
125         return getImpl()->mxEdit->getText();
126     return OUString();
127 }
128 
SetModifyHdl(const Link & link)129 void Edit::SetModifyHdl( const Link& link )
130 {
131     if (getImpl() && getImpl()->mxEdit.is ())
132         getImpl()->SetModifyHdl( link );
133 }
134 
135 IMPL_CONSTRUCTORS( Edit, Control, "edit" );
136 IMPL_GET_IMPL( Edit );
137 IMPL_GET_WINDOW (Edit);
138 
139 class MultiLineEditImpl : public EditImpl
140 {
141 public:
MultiLineEditImpl(Context * context,const PeerHandle & peer,Window * window)142     MultiLineEditImpl( Context *context, const PeerHandle &peer, Window *window )
143         : EditImpl( context, peer, window )
144     {
145     }
146 };
147 
148 IMPL_CONSTRUCTORS( MultiLineEdit, Edit, "multilineedit" );
149 IMPL_GET_IMPL( MultiLineEdit );
150 
151 class SpinFieldImpl : public EditImpl
152 {
153   public:
SpinFieldImpl(Context * context,const PeerHandle & peer,Window * window)154     SpinFieldImpl( Context *context, const PeerHandle &peer, Window *window )
155         : EditImpl( context, peer, window )
156     {
157     }
158 };
159 
160 IMPL_CONSTRUCTORS( SpinField, Edit, "spinfield" );
161 
162 class NumericFieldImpl : public SpinFieldImpl
163 {
164   public:
NumericFieldImpl(Context * context,const PeerHandle & peer,Window * window)165     NumericFieldImpl( Context *context, const PeerHandle &peer, Window *window )
166         : SpinFieldImpl( context, peer, window )
167     {
168     }
169 };
170 
171 class MetricFieldImpl : public SpinFieldImpl
172 {
173   public:
MetricFieldImpl(Context * context,const PeerHandle & peer,Window * window)174     MetricFieldImpl( Context *context, const PeerHandle &peer, Window *window )
175         : SpinFieldImpl( context, peer, window )
176     {
177     }
178 };
179 
180 IMPL_GET_IMPL( SpinField );
181 IMPL_GET_IMPL( NumericField );
182 IMPL_GET_IMPL( MetricField );
183 
184 class FormatterBaseImpl
185 {
186   protected:
187     PeerHandle mpeer;
188   public:
FormatterBaseImpl(const PeerHandle & peer)189     explicit FormatterBaseImpl( const PeerHandle &peer )
190         : mpeer( peer )
191     {
192     };
193 };
194 
FormatterBase(FormatterBaseImpl * pFormatImpl)195 FormatterBase::FormatterBase( FormatterBaseImpl *pFormatImpl )
196     : mpFormatImpl( pFormatImpl )
197 {
198 }
199 
200 class NumericFormatterImpl : public FormatterBaseImpl
201 {
202   public:
203     uno::Reference< awt::XNumericField > mxField;
NumericFormatterImpl(const PeerHandle & peer)204     explicit NumericFormatterImpl( const PeerHandle &peer )
205         : FormatterBaseImpl( peer )
206         , mxField( peer, uno::UNO_QUERY )
207     {
208     }
209 
210     // FIXME: burn that CPU ! cut/paste from vclxwindows.cxx
valueToDouble(sal_Int64 nValue)211     double valueToDouble( sal_Int64 nValue )
212     {
213         sal_Int16 nDigits = mxField->getDecimalDigits();
214         double n = (double)nValue;
215         for ( sal_uInt16 d = 0; d < nDigits; d++ )
216             n /= 10;
217         return n;
218     } // FIXME: burn that CPU ! cut/paste from vclxwindows.cxx
doubleToValue(double nValue)219     sal_Int64 doubleToValue( double nValue )
220     {
221         sal_Int16 nDigits = mxField->getDecimalDigits();
222         double n = nValue;
223         for ( sal_uInt16 d = 0; d < nDigits; d++ )
224             n *= 10;
225         return (sal_Int64) n;
226     }
227 };
228 
229 class MetricFormatterImpl : public FormatterBaseImpl
230 {
231   public:
232     uno::Reference< awt::XMetricField > mxField;
MetricFormatterImpl(const PeerHandle & peer)233     explicit MetricFormatterImpl( const PeerHandle &peer )
234         : FormatterBaseImpl( peer )
235         , mxField( peer, uno::UNO_QUERY )
236     {
237     }
238 };
239 
NumericFormatter(FormatterBaseImpl * pImpl)240 NumericFormatter::NumericFormatter( FormatterBaseImpl *pImpl )
241     : FormatterBase( pImpl )
242 {
243 }
244 
getFormatImpl() const245 NumericFormatterImpl& NumericFormatter::getFormatImpl() const
246 {
247     return *( static_cast<NumericFormatterImpl *>( mpFormatImpl ) );
248 }
249 
250 #define SET_IMPL(vclmethod, idlmethod) \
251     void NumericFormatter::vclmethod( sal_Int64 nValue ) \
252     { \
253         if ( !getFormatImpl().mxField.is() ) \
254             return; \
255         getFormatImpl().mxField->idlmethod( getFormatImpl().valueToDouble( nValue ) ); \
256     }
257 
SET_IMPL(SetMin,setMin)258 SET_IMPL( SetMin, setMin )
259 SET_IMPL( SetMax, setMax )
260 SET_IMPL( SetLast, setLast )
261 SET_IMPL( SetFirst, setFirst )
262 SET_IMPL( SetValue, setValue )
263 SET_IMPL( SetSpinSize, setSpinSize )
264 
265 sal_Int64 NumericFormatter::GetValue() const
266 {
267     if ( !getFormatImpl().mxField.is() )
268         return 0;
269     return getFormatImpl().doubleToValue( getFormatImpl().mxField->getValue() );
270 }
271 
272 #undef SET_IMPL
273 
274 IMPL_CONSTRUCTORS_2( NumericField, SpinField, NumericFormatter, "numericfield" );
275 
MetricFormatter(FormatterBaseImpl * pImpl)276 MetricFormatter::MetricFormatter( FormatterBaseImpl *pImpl )
277     : FormatterBase( pImpl )
278 {
279 }
getFormatImpl() const280 MetricFormatterImpl& MetricFormatter::getFormatImpl() const
281 {    return *( static_cast<MetricFormatterImpl *>( mpFormatImpl ) );   }
282 
283 #define MetricUnitVclToUno(a) ((sal_uInt16)(a))
284 
285 #define SET_IMPL(vclmethod, idlmethod) \
286     void MetricFormatter::vclmethod( sal_Int64 nValue, FieldUnit nUnit ) \
287     { \
288         if ( !getFormatImpl().mxField.is() ) \
289             return; \
290         getFormatImpl().mxField->idlmethod( nValue, MetricUnitVclToUno( nUnit ) ); \
291     }
292 
SET_IMPL(SetMin,setMin)293 SET_IMPL( SetMin, setMin )
294 SET_IMPL( SetMax, setMax )
295 SET_IMPL( SetLast, setLast )
296 SET_IMPL( SetFirst, setFirst )
297 SET_IMPL( SetValue, setValue )
298 
299 #undef SET_IMPL
300 
301 void MetricFormatter::SetSpinSize( sal_Int64 nValue )
302 {
303     if ( !getFormatImpl().mxField.is() )
304         return;
305     getFormatImpl().mxField->setSpinSize( nValue );
306 }
307 
GetValue(FieldUnit nUnit) const308 sal_Int64 MetricFormatter::GetValue( FieldUnit nUnit ) const
309 {
310     if ( !getFormatImpl().mxField.is() )
311         return 0;
312     return getFormatImpl().mxField->getValue( MetricUnitVclToUno( nUnit ) );
313 }
314 
315 IMPL_CONSTRUCTORS_2( MetricField, SpinField, MetricFormatter, "metricfield" );
316 
317 class ComboBoxImpl : public EditImpl
318                    , public ::cppu::WeakImplHelper1< awt::XActionListener >
319                    , public ::cppu::WeakImplHelper1< awt::XItemListener >
320 {
321 public:
322     uno::Reference< awt::XComboBox > mxComboBox;
323 
324     Link maClickHdl;
325     Link maSelectHdl;
326 
327     Window *parent;
328 
ComboBoxImpl(Context * context,const PeerHandle & peer,Window * window)329     ComboBoxImpl( Context *context, const PeerHandle &peer, Window *window )
330         : EditImpl( context, peer, window )
331         , mxComboBox( peer, uno::UNO_QUERY )
332     {
333     }
334 
335     ~ComboBoxImpl ();
336 
InsertEntry(OUString const & rStr,sal_uInt16 nPos)337     sal_uInt16 InsertEntry( OUString const& rStr, sal_uInt16 nPos )
338     {
339         if ( nPos == COMBOBOX_APPEND )
340             nPos = GetEntryCount();
341         mxComboBox->addItem( rtl::OUString( rStr ), nPos );
342         return nPos;
343     }
344 
RemoveEntry(sal_uInt16 nPos)345     void RemoveEntry( sal_uInt16 nPos )
346     {
347         mxComboBox->removeItems( nPos, 1 );
348     }
349 
GetEntryPos(String const & rStr) const350     sal_uInt16 GetEntryPos( String const& rStr ) const
351     {
352         uno::Sequence< rtl::OUString> aItems( mxComboBox->getItems() );
353         rtl::OUString rKey( rStr );
354         sal_uInt16 n = sal::static_int_cast< sal_uInt16 >(aItems.getLength());
355         for (sal_uInt16 i = 0; i < n; i++)
356         {
357             if ( aItems[ i ] == rKey )
358                 return i;
359         }
360         return COMBOBOX_ENTRY_NOTFOUND;
361     }
362 
GetEntry(sal_uInt16 nPos) const363     OUString GetEntry( sal_uInt16 nPos ) const
364     {
365         return OUString( mxComboBox->getItem( nPos ) );
366     }
367 
GetEntryCount() const368     sal_uInt16 GetEntryCount() const
369     {
370         return mxComboBox->getItemCount();
371     }
372 
SetClickHdl(Link const & link)373     void SetClickHdl( Link const& link )
374     {
375         if (!link && !!maClickHdl)
376             mxComboBox->removeActionListener( this );
377         else if (!!link && !maClickHdl)
378             mxComboBox->addActionListener( this );
379         maClickHdl = link;
380     }
381 
SetSelectHdl(Link const & link)382     void SetSelectHdl( Link const& link )
383     {
384         if (!link && !!maSelectHdl)
385             mxComboBox->removeItemListener( this );
386         else if (!!link && !maSelectHdl)
387             mxComboBox->addItemListener( this );
388         maSelectHdl = link;
389     }
390 
391     void SAL_CALL disposing( lang::EventObject const& e )
392         throw (uno::RuntimeException);
393 
actionPerformed(const awt::ActionEvent &)394     void SAL_CALL actionPerformed (const awt::ActionEvent&)
395         throw (uno::RuntimeException)
396     {
397         ComboBox* pComboBox = static_cast<ComboBox*>( mpWindow );
398         if ( !pComboBox )
399             return;
400         maClickHdl.Call( pComboBox );
401     }
402 
itemStateChanged(awt::ItemEvent const &)403     void SAL_CALL itemStateChanged( awt::ItemEvent const&)
404         throw (uno::RuntimeException)
405     {
406         ComboBox* pComboBox = static_cast<ComboBox*>( mpWindow );
407         if ( !pComboBox )
408             return;
409         maSelectHdl.Call( pComboBox );
410     }
411 };
412 
~ComboBox()413 ComboBox::~ComboBox ()
414 {
415 #ifndef __SUNPRO_CC
416     OSL_TRACE ("%s: deleting ComboBox for window: %p", __FUNCTION__, GetWindow ());
417 #endif
418 }
419 
~ComboBoxImpl()420 ComboBoxImpl::~ComboBoxImpl ()
421 {
422 #ifndef __SUNPRO_CC
423     OSL_TRACE ("%s: deleting ComboBoxImpl for window: %p", __FUNCTION__, mpWindow ? mpWindow->GetWindow () : 0);
424     OSL_TRACE ("%s: deleting ComboBoxImpl for listener: %p", __FUNCTION__, static_cast<XFocusListener*> (this));
425 #endif
426 }
427 
disposing(lang::EventObject const & e)428 void ComboBoxImpl::disposing( lang::EventObject const& e )
429     throw (uno::RuntimeException)
430 {
431     EditImpl::disposing (e);
432     mxComboBox.clear ();
433 }
434 
InsertEntry(String const & rStr,sal_uInt16 nPos)435 sal_uInt16 ComboBox::InsertEntry( String const& rStr, sal_uInt16 nPos )
436 {
437     return getImpl()->InsertEntry( rStr, nPos );
438 }
439 
RemoveEntry(String const & rStr)440 void ComboBox::RemoveEntry( String const& rStr )
441 {
442     getImpl()->RemoveEntry( GetEntryPos( rStr ) );
443 }
444 
RemoveEntry(sal_uInt16 nPos)445 void ComboBox::RemoveEntry( sal_uInt16 nPos )
446 {
447     getImpl()->RemoveEntry( nPos );
448 }
449 
Clear()450 void ComboBox::Clear()
451 {
452     uno::Sequence< rtl::OUString> aNoItems;
453     if ( getImpl() )
454         getImpl()->setProperty( "StringItemList", uno::Any( aNoItems ) );
455 }
456 
GetEntryPos(String const & rStr) const457 sal_uInt16 ComboBox::GetEntryPos( String const& rStr ) const
458 {
459     return getImpl()->GetEntryPos( rStr );
460 }
461 
GetEntry(sal_uInt16 nPos) const462 String ComboBox::GetEntry( sal_uInt16 nPos ) const
463 {
464     rtl::OUString rItem = getImpl()->mxComboBox->getItem( nPos );
465     return OUString( rItem );
466 }
467 
GetEntryCount() const468 sal_uInt16 ComboBox::GetEntryCount() const
469 {
470     return getImpl()->GetEntryCount();
471 }
472 
SetClickHdl(const Link & link)473 void ComboBox::SetClickHdl( const Link& link )
474 {
475     if (getImpl() && getImpl()->mxComboBox.is ())
476         getImpl()->SetClickHdl( link );
477 }
478 
SetSelectHdl(const Link & link)479 void ComboBox::SetSelectHdl( const Link& link )
480 {
481     if (getImpl() && getImpl()->mxComboBox.is ())
482         getImpl()->SetSelectHdl( link );
483 }
484 
EnableAutocomplete(bool enable,bool matchCase)485 void ComboBox::EnableAutocomplete (bool enable, bool matchCase)
486 {
487     GetComboBox ()->EnableAutocomplete (enable, matchCase);
488 }
489 
490 IMPL_CONSTRUCTORS_BODY( ComboBox, Edit, "combobox", getImpl()->parent = parent; );
491 IMPL_GET_WINDOW (ComboBox);
492 IMPL_GET_IMPL( ComboBox );
493 
494 class ListBoxImpl : public ControlImpl
495                   , public ::cppu::WeakImplHelper1< awt::XActionListener >
496                   , public ::cppu::WeakImplHelper1< awt::XItemListener >
497                   , public ::cppu::WeakImplHelper1< awt::XMouseListener >
498 {
499     Link maClickHdl;
500     Link maSelectHdl;
501     Link maDoubleClickHdl;
502 
503 public:
504     uno::Reference< awt::XListBox > mxListBox;
ListBoxImpl(Context * context,const PeerHandle & peer,Window * window)505     ListBoxImpl( Context *context, const PeerHandle &peer, Window *window )
506         : ControlImpl( context, peer, window )
507         , mxListBox( peer, uno::UNO_QUERY )
508     {
509         SelectEntryPos (0, true);
510     }
511 
InsertEntry(String const & rStr,sal_uInt16 nPos)512     sal_uInt16 InsertEntry (String const& rStr, sal_uInt16 nPos)
513     {
514         if ( nPos == LISTBOX_APPEND )
515             nPos = mxListBox->getItemCount();
516         mxListBox->addItem( rtl::OUString( rStr ), nPos );
517         return nPos;
518     }
519 
RemoveEntry(sal_uInt16 nPos)520     void RemoveEntry( sal_uInt16 nPos )
521     {
522         mxListBox->removeItems( nPos, 1 );
523     }
524 
RemoveEntry(String const & rStr,sal_uInt16 nPos)525     sal_uInt16 RemoveEntry( String const& rStr, sal_uInt16 nPos)
526     {
527         if ( nPos == LISTBOX_APPEND )
528             nPos = mxListBox->getItemCount();
529         mxListBox->addItem( rtl::OUString( rStr ), nPos );
530         return nPos;
531     }
532 
GetEntryPos(String const & rStr) const533     sal_uInt16 GetEntryPos( String const& rStr ) const
534     {
535         uno::Sequence< rtl::OUString> aItems( mxListBox->getItems() );
536         rtl::OUString rKey( rStr );
537         sal_uInt16 n = sal::static_int_cast< sal_uInt16 >(aItems.getLength());
538         for (sal_uInt16 i = 0; i < n; i++)
539         {
540             if ( aItems[ i ] == rKey )
541                 return i;
542         }
543         return LISTBOX_ENTRY_NOTFOUND;
544     }
545 
GetEntry(sal_uInt16 nPos) const546     OUString GetEntry( sal_uInt16 nPos ) const
547     {
548         return mxListBox->getItem( nPos );
549     }
550 
GetEntryCount() const551     sal_uInt16 GetEntryCount() const
552     {
553         return mxListBox->getItemCount();
554     }
555 
SelectEntryPos(sal_uInt16 nPos,bool bSelect)556     void SelectEntryPos( sal_uInt16 nPos, bool bSelect )
557     {
558         mxListBox->selectItemPos( nPos, bSelect );
559     }
560 
GetSelectEntryCount() const561     sal_uInt16 GetSelectEntryCount() const
562     {
563         return sal::static_int_cast< sal_uInt16 >( mxListBox->getSelectedItems().getLength() );
564     }
565 
GetSelectEntryPos(sal_uInt16 nSelIndex) const566     sal_uInt16 GetSelectEntryPos( sal_uInt16 nSelIndex ) const
567     {
568         sal_uInt16 nSelected = 0;
569         if ( mxListBox->isMutipleMode() )
570         {
571             uno::Sequence< short > aItems( mxListBox->getSelectedItemsPos() );
572             if ( nSelIndex < aItems.getLength() )
573                 nSelected = aItems[ nSelIndex ];
574         }
575         else
576             nSelected = mxListBox->getSelectedItemPos();
577         return nSelected;
578     }
579 
disposing(lang::EventObject const & e)580     virtual void SAL_CALL disposing( lang::EventObject const& e )
581         throw (uno::RuntimeException)
582     {
583         ControlImpl::disposing (e);
584         mxListBox.clear ();
585     }
586 
GetClickHdl()587     Link& GetClickHdl ()
588     {
589         return maClickHdl;
590     }
591 
SetClickHdl(Link const & link)592     void SetClickHdl( Link const& link )
593     {
594         if (!link && !!maClickHdl)
595             mxListBox->removeActionListener( this );
596         else if (!!link && !maClickHdl)
597             mxListBox->addActionListener( this );
598         maClickHdl = link;
599     }
600 
actionPerformed(const awt::ActionEvent &)601     void SAL_CALL actionPerformed( const awt::ActionEvent& /* rEvent */ )
602         throw (uno::RuntimeException)
603     {
604         maClickHdl.Call( mpWindow );
605     }
606 
GetSelectHdl()607     Link& GetSelectHdl ()
608     {
609         return maSelectHdl;
610     }
611 
SetSelectHdl(Link const & link)612     void SetSelectHdl( Link const& link )
613     {
614         if (!link && !!maSelectHdl)
615             mxListBox->removeItemListener( this );
616         else if (!!link && !maSelectHdl)
617             mxListBox->addItemListener( this );
618         maSelectHdl = link;
619     }
620 
itemStateChanged(awt::ItemEvent const &)621     void SAL_CALL itemStateChanged (awt::ItemEvent const&)
622         throw (uno::RuntimeException)
623     {
624         maSelectHdl.Call (static_cast <ListBox*> (mpWindow));
625     }
626 
GetDoubleClickHdl()627     Link& GetDoubleClickHdl ()
628     {
629         return maDoubleClickHdl;
630     }
631 
SetDoubleClickHdl(Link const & link)632     void SetDoubleClickHdl (Link const& link)
633     {
634         if (!link && !!maDoubleClickHdl)
635             mxWindow->removeMouseListener (this);
636         else if (!!link && !maSelectHdl)
637             mxWindow->addMouseListener (this);
638         maDoubleClickHdl = link;
639     }
640 
mousePressed(awt::MouseEvent const &)641     void SAL_CALL mousePressed (awt::MouseEvent const&) throw (uno::RuntimeException)
642     {
643     }
mouseReleased(awt::MouseEvent const & e)644     void SAL_CALL mouseReleased (awt::MouseEvent const& e) throw (uno::RuntimeException)
645     {
646         if (e.ClickCount == 2)
647             maDoubleClickHdl.Call (mpWindow);
648     }
mouseEntered(awt::MouseEvent const &)649     void SAL_CALL mouseEntered (awt::MouseEvent const&) throw (uno::RuntimeException)
650     {
651     }
mouseExited(awt::MouseEvent const &)652     void SAL_CALL mouseExited (awt::MouseEvent const&) throw (uno::RuntimeException)
653     {
654     }
655 };
656 
~ListBox()657 ListBox::~ListBox ()
658 {
659 }
660 
InsertEntry(String const & rStr,sal_uInt16 nPos)661 sal_uInt16 ListBox::InsertEntry (String const& rStr, sal_uInt16 nPos)
662 {
663     return getImpl()->InsertEntry(rStr, nPos);
664 }
665 
RemoveEntry(sal_uInt16 nPos)666 void ListBox::RemoveEntry( sal_uInt16 nPos )
667 {
668     return getImpl()->RemoveEntry( nPos );
669 }
670 
RemoveEntry(String const & rStr)671 void ListBox::RemoveEntry( String const& rStr )
672 {
673     return getImpl()->RemoveEntry( GetEntryPos( rStr ) );
674 }
675 
Clear()676 void ListBox::Clear()
677 {
678     uno::Sequence< rtl::OUString> aNoItems;
679     if ( getImpl() )
680         getImpl()->setProperty( "StringItemList", uno::Any( aNoItems ) );
681 }
682 
GetEntryPos(String const & rStr) const683 sal_uInt16 ListBox::GetEntryPos( String const& rStr ) const
684 {
685     return getImpl()->GetEntryPos( rStr );
686 }
687 
GetEntry(sal_uInt16 nPos) const688 String ListBox::GetEntry( sal_uInt16 nPos ) const
689 {
690     return getImpl()->GetEntry( nPos );
691 }
692 
GetEntryCount() const693 sal_uInt16 ListBox::GetEntryCount() const
694 {
695     return getImpl()->GetEntryCount();
696 }
697 
SelectEntryPos(sal_uInt16 nPos,bool bSelect)698 void ListBox::SelectEntryPos( sal_uInt16 nPos, bool bSelect )
699 {
700 #if LAYOUT_API_CALLS_HANDLER
701     getImpl()->SelectEntryPos( nPos, bSelect );
702 #else /* !LAYOUT_API_CALLS_HANDLER */
703     GetListBox ()->SelectEntryPos (nPos, bSelect);
704 #endif /* !LAYOUT_API_CALLS_HANDLER */
705 }
706 
SelectEntry(String const & rStr,bool bSelect)707 void ListBox::SelectEntry( String const& rStr, bool bSelect )
708 {
709     SelectEntryPos( GetEntryPos( rStr ), bSelect );
710 }
711 
GetSelectEntryCount() const712 sal_uInt16 ListBox::GetSelectEntryCount() const
713 {
714     return getImpl()->GetSelectEntryCount();
715 }
716 
GetSelectEntryPos(sal_uInt16 nSelIndex) const717 sal_uInt16 ListBox::GetSelectEntryPos( sal_uInt16 nSelIndex ) const
718 {
719     return getImpl()->GetSelectEntryPos( nSelIndex );
720 }
721 
GetSelectEntry(sal_uInt16 nSelIndex) const722 String ListBox::GetSelectEntry( sal_uInt16 nSelIndex ) const
723 {
724     return GetEntry( GetSelectEntryPos( nSelIndex ) );
725 }
726 
GetSelectHdl()727 Link& ListBox::GetSelectHdl ()
728 {
729     return getImpl()->GetSelectHdl ();
730 }
731 
SetSelectHdl(Link const & link)732 void ListBox::SetSelectHdl( Link const& link )
733 {
734     getImpl()->SetSelectHdl( link );
735 }
736 
GetClickHdl()737 Link& ListBox::GetClickHdl ()
738 {
739     return getImpl()->GetSelectHdl ();
740 }
741 
SetClickHdl(Link const & link)742 void ListBox::SetClickHdl( Link const& link )
743 {
744     if (getImpl() && getImpl()->mxListBox.is ())
745         getImpl()->SetClickHdl( link );
746 }
747 
GetDoubleClickHdl()748 Link& ListBox::GetDoubleClickHdl ()
749 {
750     return getImpl()->GetSelectHdl ();
751 }
752 
SetDoubleClickHdl(Link const & link)753 void ListBox::SetDoubleClickHdl( Link const& link )
754 {
755     getImpl()->SetDoubleClickHdl( link );
756 }
757 
SetEntryData(sal_uInt16 pos,void * data)758 void ListBox::SetEntryData( sal_uInt16 pos, void* data)
759 {
760     GetListBox ()->SetEntryData (pos, data);
761 }
762 
GetEntryData(sal_uInt16 pos) const763 void* ListBox::GetEntryData( sal_uInt16 pos) const
764 {
765     return GetListBox ()->GetEntryData (pos);
766 }
767 
SetNoSelection()768 void ListBox::SetNoSelection ()
769 {
770     GetListBox ()->SetNoSelection ();
771 }
772 
773 IMPL_CONSTRUCTORS (ListBox, Control, "listbox");
774 IMPL_GET_IMPL (ListBox);
775 IMPL_GET_WINDOW (ListBox);
776 
777 IMPL_IMPL (MultiListBox, ListBox)
778 IMPL_CONSTRUCTORS_BODY( MultiListBox, ListBox, "multilistbox", GetMultiListBox()->EnableMultiSelection( true ); );
779 IMPL_GET_IMPL( MultiListBox );
780 IMPL_GET_WINDOW( MultiListBox );
781 } // namespace layout
782