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