xref: /aoo41x/main/svx/source/tbxctrls/itemwin.cxx (revision f6e50924)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 // include ---------------------------------------------------------------
28 #include <tools/shl.hxx>
29 #include <sfx2/dispatch.hxx>
30 #include <sfx2/objsh.hxx>
31 #include <sfx2/viewsh.hxx>
32 #include <sfx2/module.hxx>
33 #include <tools/urlobj.hxx>
34 
35 #define _SVX_ITEMWIN_CXX
36 
37 #include <vcl/svapp.hxx>
38 
39 #include <svx/dialogs.hrc>
40 
41 #define DELAY_TIMEOUT			100
42 
43 #include <svx/xlnclit.hxx>
44 #include <svx/xlnwtit.hxx>
45 #include <svx/xlineit0.hxx>
46 #include <svx/xlndsit.hxx>
47 #include <svx/xtable.hxx>
48 #include "svx/drawitem.hxx"
49 #include <svx/dialmgr.hxx>
50 #include "svx/dlgutil.hxx"
51 #include <svx/itemwin.hxx>
52 #include "svx/linectrl.hxx"
53 #include <svtools/colorcfg.hxx>
54 
55 #include "linectrl.hrc"
56 
57 using namespace ::com::sun::star::uno;
58 using namespace ::com::sun::star::frame;
59 using namespace ::com::sun::star::util;
60 using namespace ::com::sun::star::lang;
61 using namespace ::com::sun::star::beans;
62 
63 #define LOGICAL_EDIT_HEIGHT         12
64 //========================================================================
65 // SvxLineBox
66 //========================================================================
67 
68 SvxLineBox::SvxLineBox( Window* pParent, const Reference< XFrame >& rFrame, WinBits nBits ) :
69 	LineLB( pParent, nBits ),
70 	meBmpMode	( GetSettings().GetStyleSettings().GetHighContrastMode() ? BMP_COLOR_HIGHCONTRAST : BMP_COLOR_NORMAL ),
71 	nCurPos		( 0 ),
72     aLogicalSize(40,140),
73     bRelease    ( sal_True ),
74 	mpSh		( NULL ),
75     mxFrame     ( rFrame )
76 {
77     SetSizePixel( LogicToPixel( aLogicalSize, MAP_APPFONT ));
78     Show();
79 
80 	aDelayTimer.SetTimeout( DELAY_TIMEOUT );
81 	aDelayTimer.SetTimeoutHdl( LINK( this, SvxLineBox, DelayHdl_Impl ) );
82 	aDelayTimer.Start();
83 }
84 
85 // -----------------------------------------------------------------------
86 
87 SvxLineBox::~SvxLineBox()
88 {
89 }
90 
91 // -----------------------------------------------------------------------
92 
93 IMPL_LINK( SvxLineBox, DelayHdl_Impl, Timer *, EMPTYARG )
94 {
95 	if ( GetEntryCount() == 0 )
96 	{
97 		mpSh = SfxObjectShell::Current();
98 		FillControl();
99 	}
100 	return 0;
101 }
102 
103 // -----------------------------------------------------------------------
104 
105 void SvxLineBox::Select()
106 {
107     // Call the parent's Select() member to trigger accessibility events.
108     LineLB::Select();
109 
110 	if ( !IsTravelSelect() )
111 	{
112 		XLineStyle eXLS;
113 		sal_uInt16 nPos = GetSelectEntryPos();
114 //		SfxDispatcher* pDisp = rBindings.GetDispatcher();
115 		//DBG_ASSERT( pDisp, "invalid Dispatcher" );
116 
117 		switch ( nPos )
118 		{
119 			case 0:
120 				eXLS = XLINE_NONE;
121 				break;
122 
123 			case 1:
124 				eXLS = XLINE_SOLID;
125 				break;
126 
127 			default:
128 			{
129 				eXLS = XLINE_DASH;
130 
131 				if ( nPos != LISTBOX_ENTRY_NOTFOUND &&
132 					 SfxObjectShell::Current()	&&
133 					 SfxObjectShell::Current()->GetItem( SID_DASH_LIST ) )
134 				{
135 					// LineDashItem wird nur geschickt, wenn es auch einen Dash besitzt.
136 					// Notify k"ummert sich darum!
137 					SvxDashListItem aItem( *(const SvxDashListItem*)(
138 						SfxObjectShell::Current()->GetItem( SID_DASH_LIST ) ) );
139 					XLineDashItem aLineDashItem( GetSelectEntry(),
140 						aItem.GetDashList()->GetDash( nPos - 2 )->GetDash() );
141 
142                     Any a;
143                     Sequence< PropertyValue > aArgs( 1 );
144                     aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineDash" ));
145                     aLineDashItem.QueryValue ( a );
146                     aArgs[0].Value = a;
147                     SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
148                                                  ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineDash" )),
149                                                  aArgs );
150 //                    pDisp->Execute( SID_ATTR_LINE_DASH, SFX_CALLMODE_RECORD, &aLineDashItem, 0L );
151 				}
152 			}
153 			break;
154 		}
155 
156 		XLineStyleItem aLineStyleItem( eXLS );
157         Any a;
158         Sequence< PropertyValue > aArgs( 1 );
159         aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XLineStyle" ));
160         aLineStyleItem.QueryValue ( a );
161         aArgs[0].Value = a;
162         SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
163                                      ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:XLineStyle" )),
164                                      aArgs );
165 //		pDisp->Execute( SID_ATTR_LINE_STYLE, SFX_CALLMODE_RECORD, &aLineStyleItem, 0L );
166 
167         nCurPos = GetSelectEntryPos();
168 		ReleaseFocus_Impl();
169 	}
170 }
171 
172 // -----------------------------------------------------------------------
173 
174 long SvxLineBox::PreNotify( NotifyEvent& rNEvt )
175 {
176 	sal_uInt16 nType = rNEvt.GetType();
177 
178     switch(nType)
179     {
180         case EVENT_MOUSEBUTTONDOWN:
181         case EVENT_GETFOCUS:
182             nCurPos = GetSelectEntryPos();
183         break;
184         case EVENT_LOSEFOCUS:
185             SelectEntryPos(nCurPos);
186         break;
187         case EVENT_KEYINPUT:
188         {
189             const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
190             if( pKEvt->GetKeyCode().GetCode() == KEY_TAB)
191             {
192                 bRelease = sal_False;
193                 Select();
194             }
195         }
196         break;
197     }
198 	return LineLB::PreNotify( rNEvt );
199 }
200 
201 // -----------------------------------------------------------------------
202 
203 long SvxLineBox::Notify( NotifyEvent& rNEvt )
204 {
205 	long nHandled = LineLB::Notify( rNEvt );
206 
207 	if ( rNEvt.GetType() == EVENT_KEYINPUT )
208 	{
209 		const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
210 
211 		switch ( pKEvt->GetKeyCode().GetCode() )
212 		{
213 			case KEY_RETURN:
214 				Select();
215 				nHandled = 1;
216 				break;
217 
218 			case KEY_ESCAPE:
219 				SelectEntryPos( nCurPos );
220 				ReleaseFocus_Impl();
221 				nHandled = 1;
222 				break;
223         }
224 	}
225 	return nHandled;
226 }
227 
228 // -----------------------------------------------------------------------
229 
230 void SvxLineBox::ReleaseFocus_Impl()
231 {
232     if(!bRelease)
233     {
234         bRelease = sal_True;
235         return;
236     }
237 
238 	if( SfxViewShell::Current() )
239 	{
240 		Window* pShellWnd = SfxViewShell::Current()->GetWindow();
241 
242 		if ( pShellWnd )
243 			pShellWnd->GrabFocus();
244 	}
245 }
246 /* -----------------------------08.03.2002 15:39------------------------------
247 
248  ---------------------------------------------------------------------------*/
249 void SvxLineBox::DataChanged( const DataChangedEvent& rDCEvt )
250 {
251 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
252          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
253     {
254         SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
255         Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
256         SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
257    }
258 
259     LineLB::DataChanged( rDCEvt );
260 
261 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
262          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
263     {
264 		BmpColorMode eMode = GetSettings().GetStyleSettings().GetHighContrastMode() ? BMP_COLOR_HIGHCONTRAST : BMP_COLOR_NORMAL;
265 		if( eMode != meBmpMode )
266 		{
267 			meBmpMode = eMode;
268 			FillControl();
269 		}
270  	}
271 }
272 
273 void SvxLineBox::FillControl()
274 {
275 	FillStyles();
276     if ( !mpSh )
277         mpSh = SfxObjectShell::Current();
278 
279     if( mpSh )
280 	{
281 		const SvxDashListItem* pItem = (const SvxDashListItem*)( mpSh->GetItem( SID_DASH_LIST ) );
282 		if ( pItem )
283 			Fill( pItem->GetDashList() );
284 	}
285 
286 
287 //	rBindings.Invalidate( SID_ATTR_LINE_DASH );
288 }
289 //========================================================================
290 // SvxColorBox
291 //========================================================================
292 
293 SvxColorBox::SvxColorBox(
294     Window* pParent,
295     const ::rtl::OUString& rCommand,
296     const Reference< XFrame >& rFrame,
297     WinBits nBits ) :
298 	ColorLB( pParent, nBits ),
299 	nCurPos		( 0 ),
300     aLogicalSize(45,80),
301     bRelease    ( sal_True ),
302     maCommand   ( rCommand ),
303     mxFrame     ( rFrame )
304 {
305     SetSizePixel( LogicToPixel( aLogicalSize , MAP_APPFONT));
306     Show();
307 
308     SfxObjectShell* pSh = SfxObjectShell::Current();
309 
310 	if ( pSh )
311 	{
312 		const SvxColorTableItem* pItem =
313 			(const SvxColorTableItem*)(	pSh->GetItem( SID_COLOR_TABLE ) );
314 		if(pItem)
315 			Fill( pItem->GetColorTable() );
316 	}
317 }
318 
319 // -----------------------------------------------------------------------
320 
321 IMPL_LINK( SvxColorBox, DelayHdl_Impl, Timer *, EMPTYARG )
322 {
323 	SfxObjectShell* pSh = SfxObjectShell::Current();
324 
325 	if ( pSh )
326 	{
327 		const SvxColorTableItem* pItem = (const SvxColorTableItem*)( pSh->GetItem( SID_COLOR_TABLE ) );
328 		if ( pItem )
329 			Fill( pItem->GetColorTable() );
330 //		rBindings.Invalidate( nId );
331 	}
332 	return 0;
333 }
334 
335 // -----------------------------------------------------------------------
336 
337 SvxColorBox::~SvxColorBox()
338 {
339 }
340 
341 // -----------------------------------------------------------------------
342 
343 void SvxColorBox::Update( const XLineColorItem* pItem )
344 {
345 	if ( pItem )
346 		SelectEntry( pItem->GetColorValue() );
347 	else
348 		SetNoSelection();
349 }
350 
351 // -----------------------------------------------------------------------
352 
353 void SvxColorBox::Select()
354 {
355 	// OJ: base class call needed here because otherwise no event is send for accessibility
356 	ColorLB::Select();
357 	if ( !IsTravelSelect() )
358 	{
359 		XLineColorItem aLineColorItem( GetSelectEntry(), GetSelectEntryColor() );
360 
361         INetURLObject aObj( maCommand );
362 
363         Any a;
364         Sequence< PropertyValue > aArgs( 1 );
365         aArgs[0].Name = aObj.GetURLPath();
366         aLineColorItem.QueryValue( a );
367         aArgs[0].Value = a;
368         SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
369                                      maCommand,
370                                      aArgs );
371 //        rBindings.GetDispatcher()->Execute( nId, SFX_CALLMODE_RECORD, &aLineColorItem, 0L );
372 
373         nCurPos = GetSelectEntryPos();
374 		ReleaseFocus_Impl();
375 	}
376 }
377 
378 // -----------------------------------------------------------------------
379 
380 long SvxColorBox::PreNotify( NotifyEvent& rNEvt )
381 {
382 	sal_uInt16 nType = rNEvt.GetType();
383 
384     switch(nType)
385     {
386         case  EVENT_MOUSEBUTTONDOWN:
387         case EVENT_GETFOCUS:
388             nCurPos = GetSelectEntryPos();
389         break;
390         case EVENT_LOSEFOCUS:
391             SelectEntryPos(nCurPos);
392         break;
393         case EVENT_KEYINPUT:
394         {
395             const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
396 
397             if( pKEvt->GetKeyCode().GetCode() == KEY_TAB)
398             {
399                 bRelease = sal_False;
400                 Select();
401             }
402         }
403     }
404 
405 	return ColorLB::PreNotify( rNEvt );
406 }
407 
408 // -----------------------------------------------------------------------
409 
410 long SvxColorBox::Notify( NotifyEvent& rNEvt )
411 {
412 	long nHandled = ColorLB::Notify( rNEvt );
413 
414 	if ( rNEvt.GetType() == EVENT_KEYINPUT )
415 	{
416 		const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
417 
418 		switch ( pKEvt->GetKeyCode().GetCode() )
419 		{
420 			case KEY_RETURN:
421 				Select();
422 				nHandled = 1;
423 				break;
424 
425 			case KEY_ESCAPE:
426 				SelectEntryPos( nCurPos );
427 				ReleaseFocus_Impl();
428 				nHandled = 1;
429 				break;
430         }
431 	}
432 	return nHandled;
433 }
434 /* -----------------------------08.03.2002 15:35------------------------------
435 
436  ---------------------------------------------------------------------------*/
437 void SvxColorBox::DataChanged( const DataChangedEvent& rDCEvt )
438 {
439 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
440          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
441     {
442         SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
443         Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
444         SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
445     }
446 
447     ColorLB::DataChanged( rDCEvt );
448 }
449 // -----------------------------------------------------------------------
450 
451 void SvxColorBox::ReleaseFocus_Impl()
452 {
453     if(!bRelease)
454     {
455         bRelease = sal_True;
456         return;
457     }
458 
459 	if( SfxViewShell::Current() )
460 	{
461 		Window* pShellWnd = SfxViewShell::Current()->GetWindow();
462 
463 		if ( pShellWnd )
464 			pShellWnd->GrabFocus();
465 	}
466 }
467 
468 //========================================================================
469 // SvxMetricField
470 //========================================================================
471 
472 SvxMetricField::SvxMetricField(
473     Window* pParent, const Reference< XFrame >& rFrame, WinBits nBits ) :
474 	MetricField( pParent, nBits ),
475 	aCurTxt( String() ),
476     mxFrame( rFrame )
477 {
478 	Size aSize = Size(GetTextWidth( String::CreateFromAscii("99,99mm") ),GetTextHeight());
479 	aSize.Width() += 20;
480 	aSize.Height() += 6;
481 	SetSizePixel( aSize );
482     aLogicalSize = PixelToLogic(aSize, MAP_APPFONT);
483 	SetUnit( FUNIT_MM );
484 	SetDecimalDigits( 2 );
485 	SetMax( 5000 );
486 	SetMin( 0 );
487 	SetLast( 5000 );
488 	SetFirst( 0 );
489 
490 	eDlgUnit = SfxModule::GetModuleFieldUnit( mxFrame );
491 	SetFieldUnit( *this, eDlgUnit, sal_False );
492 	Show();
493 }
494 
495 // -----------------------------------------------------------------------
496 
497 SvxMetricField::~SvxMetricField()
498 {
499 }
500 
501 // -----------------------------------------------------------------------
502 
503 void SvxMetricField::Update( const XLineWidthItem* pItem )
504 {
505 	if ( pItem )
506 	{
507 		if ( pItem->GetValue() != GetCoreValue( *this, ePoolUnit ) )
508 			SetMetricValue( *this, pItem->GetValue(), ePoolUnit );
509 	}
510 	else
511 		SetText( String() );
512 }
513 
514 // -----------------------------------------------------------------------
515 
516 void SvxMetricField::Modify()
517 {
518 	MetricField::Modify();
519 	long nTmp = GetCoreValue( *this, ePoolUnit );
520 	XLineWidthItem aLineWidthItem( nTmp );
521 
522     Any a;
523     Sequence< PropertyValue > aArgs( 1 );
524     aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineWidth" ));
525     aLineWidthItem.QueryValue( a );
526     aArgs[0].Value = a;
527     SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
528                                  ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineWidth" )),
529                                  aArgs );
530 //	rBindings.GetDispatcher()->Execute( SID_ATTR_LINE_WIDTH, SFX_CALLMODE_RECORD, &aLineWidthItem, 0L );
531 }
532 
533 // -----------------------------------------------------------------------
534 
535 void SvxMetricField::ReleaseFocus_Impl()
536 {
537 	if( SfxViewShell::Current() )
538 	{
539 		Window* pShellWnd = SfxViewShell::Current()->GetWindow();
540 		if ( pShellWnd )
541 			pShellWnd->GrabFocus();
542 	}
543 }
544 
545 // -----------------------------------------------------------------------
546 
547 void SvxMetricField::Down()
548 {
549 	sal_Int64 nValue = GetValue();
550 	nValue -= GetSpinSize();
551 
552 	// Um unter OS/2 einen Sprung auf Max zu verhindern
553 	if ( nValue >= GetMin() )
554 		MetricField::Down();
555 }
556 
557 // -----------------------------------------------------------------------
558 
559 void SvxMetricField::Up()
560 {
561 	MetricField::Up();
562 }
563 
564 // -----------------------------------------------------------------------
565 
566 void SvxMetricField::SetCoreUnit( SfxMapUnit eUnit )
567 {
568 	ePoolUnit = eUnit;
569 }
570 
571 // -----------------------------------------------------------------------
572 
573 void SvxMetricField::RefreshDlgUnit()
574 {
575 	FieldUnit eTmpUnit = SfxModule::GetModuleFieldUnit( mxFrame );
576 	if ( eDlgUnit != eTmpUnit )
577 	{
578 		eDlgUnit = eTmpUnit;
579 		SetFieldUnit( *this, eDlgUnit, sal_False );
580 	}
581 }
582 
583 // -----------------------------------------------------------------------
584 
585 long SvxMetricField::PreNotify( NotifyEvent& rNEvt )
586 {
587 	sal_uInt16 nType = rNEvt.GetType();
588 
589 	if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
590 		aCurTxt = GetText();
591 
592 	return MetricField::PreNotify( rNEvt );
593 }
594 
595 // -----------------------------------------------------------------------
596 
597 long SvxMetricField::Notify( NotifyEvent& rNEvt )
598 {
599 	long nHandled = MetricField::Notify( rNEvt );
600 
601 	if ( rNEvt.GetType() == EVENT_KEYINPUT )
602 	{
603 		const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
604 		const KeyCode& rKey = pKEvt->GetKeyCode();
605 		SfxViewShell* pSh = SfxViewShell::Current();
606 
607 		if ( rKey.GetModifier() && rKey.GetGroup() != KEYGROUP_CURSOR && pSh )
608 			pSh->KeyInput( *pKEvt );
609 		else
610 		{
611 			bool bHandled = sal_False;
612 
613 			switch ( rKey.GetCode() )
614 			{
615 				case KEY_RETURN:
616 					Reformat();
617 					bHandled = sal_True;
618 					break;
619 
620 				case KEY_ESCAPE:
621 					SetText( aCurTxt );
622 					bHandled = sal_True;
623 					break;
624 			}
625 
626 			if ( bHandled )
627 			{
628 				nHandled = 1;
629 				Modify();
630 				ReleaseFocus_Impl();
631 			}
632 		}
633 	}
634 	return nHandled;
635 }
636 /* -----------------------------08.03.2002 15:32------------------------------
637 
638  ---------------------------------------------------------------------------*/
639 void SvxMetricField::DataChanged( const DataChangedEvent& rDCEvt )
640 {
641 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
642          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
643     {
644         SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
645     }
646 
647     MetricField::DataChanged( rDCEvt );
648 }
649 
650 //========================================================================
651 // SvxFillTypeBox
652 //========================================================================
653 
654 SvxFillTypeBox::SvxFillTypeBox( Window* pParent, WinBits nBits ) :
655 	FillTypeLB( pParent, nBits | WB_TABSTOP ),
656 	nCurPos	( 0 ),
657     bSelect ( sal_False ),
658     bRelease(sal_True)
659 {
660     SetSizePixel( LogicToPixel( Size(40, 40 ),MAP_APPFONT ));
661     Fill();
662 	SelectEntryPos( XFILL_SOLID );
663 	Show();
664 }
665 
666 // -----------------------------------------------------------------------
667 
668 SvxFillTypeBox::~SvxFillTypeBox()
669 {
670 }
671 
672 // -----------------------------------------------------------------------
673 
674 long SvxFillTypeBox::PreNotify( NotifyEvent& rNEvt )
675 {
676 	sal_uInt16 nType = rNEvt.GetType();
677 
678 	if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
679 		nCurPos = GetSelectEntryPos();
680 	else if ( EVENT_LOSEFOCUS == nType
681 		&& Application::GetFocusWindow()
682 		&& !IsWindowOrChild( Application::GetFocusWindow(), sal_True ) )
683 	{
684 		if ( !bSelect )
685 			SelectEntryPos( nCurPos );
686 		else
687 			bSelect = sal_False;
688 	}
689 
690 	return FillTypeLB::PreNotify( rNEvt );
691 }
692 
693 // -----------------------------------------------------------------------
694 
695 long SvxFillTypeBox::Notify( NotifyEvent& rNEvt )
696 {
697 	long nHandled = FillTypeLB::Notify( rNEvt );
698 
699 	if ( rNEvt.GetType() == EVENT_KEYINPUT )
700 	{
701 		const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
702 		switch ( pKEvt->GetKeyCode().GetCode() )
703 		{
704             case KEY_RETURN:
705                 nHandled = 1;
706                 ( (Link&)GetSelectHdl() ).Call( this );
707             break;
708             case KEY_TAB:
709                 bRelease = sal_False;
710                 ( (Link&)GetSelectHdl() ).Call( this );
711                 bRelease = sal_True;
712                 break;
713 
714 			case KEY_ESCAPE:
715 				SelectEntryPos( nCurPos );
716 				ReleaseFocus_Impl();
717 				nHandled = 1;
718 				break;
719 		}
720 	}
721 	return nHandled;
722 }
723 
724 // -----------------------------------------------------------------------
725 
726 void SvxFillTypeBox::ReleaseFocus_Impl()
727 {
728 	if( SfxViewShell::Current() )
729 	{
730 		Window* pShellWnd = SfxViewShell::Current()->GetWindow();
731 
732 		if ( pShellWnd )
733 			pShellWnd->GrabFocus();
734 	}
735 }
736 
737 //========================================================================
738 // SvxFillAttrBox
739 //========================================================================
740 
741 SvxFillAttrBox::SvxFillAttrBox( Window* pParent, WinBits nBits ) :
742 
743 	FillAttrLB( pParent, nBits | WB_TABSTOP ),
744 
745     nCurPos( 0 ),
746     bRelease( sal_True )
747 
748 {
749 	SetPosPixel( Point( 90, 0 ) );
750     SetSizePixel( LogicToPixel( Size(50, 80 ), MAP_APPFONT ));
751 	Show();
752 }
753 
754 // -----------------------------------------------------------------------
755 
756 SvxFillAttrBox::~SvxFillAttrBox()
757 {
758 }
759 
760 // -----------------------------------------------------------------------
761 
762 long SvxFillAttrBox::PreNotify( NotifyEvent& rNEvt )
763 {
764 	sal_uInt16 nType = rNEvt.GetType();
765 
766 	if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
767 		nCurPos = GetSelectEntryPos();
768 
769 	return FillAttrLB::PreNotify( rNEvt );
770 }
771 
772 // -----------------------------------------------------------------------
773 
774 long SvxFillAttrBox::Notify( NotifyEvent& rNEvt )
775 {
776 	long nHandled = FillAttrLB::Notify( rNEvt );
777 
778 	if ( rNEvt.GetType() == EVENT_KEYINPUT )
779 	{
780 		const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
781 
782 		switch ( pKEvt->GetKeyCode().GetCode() )
783 		{
784 			case KEY_RETURN:
785 				( (Link&)GetSelectHdl() ).Call( this );
786 				nHandled = 1;
787             break;
788             case KEY_TAB:
789                 bRelease = sal_False;
790                 GetSelectHdl().Call( this );
791                 bRelease = sal_True;
792             break;
793 			case KEY_ESCAPE:
794 				SelectEntryPos( nCurPos );
795 				ReleaseFocus_Impl();
796 				nHandled = 1;
797 				break;
798 		}
799 	}
800 	return nHandled;
801 }
802 
803 // -----------------------------------------------------------------------
804 
805 void SvxFillAttrBox::Select()
806 {
807 	FillAttrLB::Select();
808 }
809 
810 // -----------------------------------------------------------------------
811 
812 void SvxFillAttrBox::ReleaseFocus_Impl()
813 {
814 	if( SfxViewShell::Current() )
815 	{
816 		Window* pShellWnd = SfxViewShell::Current()->GetWindow();
817 
818 		if ( pShellWnd )
819 			pShellWnd->GrabFocus();
820 	}
821 }
822