xref: /aoo42x/main/svx/source/tbxctrls/fillctrl.cxx (revision 70d3707a)
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 
29 #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
30 #include <sfx2/app.hxx>
31 #include <sfx2/dispatch.hxx>
32 #include <sfx2/objsh.hxx>
33 #include <sfx2/viewsh.hxx>
34 #include <rtl/ustring.hxx>
35 
36 #include <svx/dialogs.hrc>
37 
38 #define DELAY_TIMEOUT			300
39 
40 #define TMP_STR_BEGIN	'['
41 #define TMP_STR_END		']'
42 
43 #include "svx/drawitem.hxx"
44 #include "svx/xattr.hxx"
45 #include <svx/xtable.hxx>
46 #include <svx/fillctrl.hxx>
47 #include <svx/itemwin.hxx>
48 #include <svx/dialmgr.hxx>
49 #include "helpid.hrc"
50 
51 using namespace ::com::sun::star::uno;
52 using namespace ::com::sun::star::util;
53 using namespace ::com::sun::star::beans;
54 using namespace ::com::sun::star::frame;
55 using namespace ::com::sun::star::lang;
56 
57 SFX_IMPL_TOOLBOX_CONTROL( SvxFillToolBoxControl, XFillStyleItem );
58 
59 /*************************************************************************
60 |*
61 |* SvxFillToolBoxControl
62 |*
63 \************************************************************************/
64 
65 SvxFillToolBoxControl::SvxFillToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
66 	SfxToolBoxControl( nSlotId, nId, rTbx ),
67 
68 	pStyleItem		( NULL ),
69 	pColorItem		( NULL ),
70 	pGradientItem	( NULL ),
71 	pHatchItem		( NULL ),
72 	pBitmapItem		( NULL ),
73 	pFillControl	( NULL ),
74 	pFillTypeLB		( NULL ),
75 	pFillAttrLB		( NULL ),
76 	bUpdate			( sal_False ),
77     bIgnoreStatusUpdate( sal_False ),
78     eLastXFS        ( XFILL_NONE )
79 {
80     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillColor" )));
81     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillGradient" )));
82     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillHatch" )));
83     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillBitmap" )));
84     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" )));
85     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GradientListState" )));
86     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:HatchListState" )));
87     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BitmapListState" )));
88 }
89 
90 //========================================================================
91 
92 SvxFillToolBoxControl::~SvxFillToolBoxControl()
93 {
94 	delete pStyleItem;
95 	delete pColorItem;
96 	delete pGradientItem;
97 	delete pHatchItem;
98 	delete pBitmapItem;
99 }
100 
101 //========================================================================
102 
103 void SvxFillToolBoxControl::StateChanged(
104 
105 	sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
106 
107 {
108 	bool bEnableControls = sal_False;
109 
110     if ( bIgnoreStatusUpdate )
111         return;
112 
113 	if( eState == SFX_ITEM_DISABLED )
114 	{
115 		if( nSID == SID_ATTR_FILL_STYLE )
116 		{
117 			pFillTypeLB->Disable();
118 			pFillTypeLB->SetNoSelection();
119 		}
120 		pFillAttrLB->Disable();
121 		pFillAttrLB->SetNoSelection();
122 	}
123 	else
124 	{
125 		if ( SFX_ITEM_AVAILABLE == eState )
126 		{
127 			if( nSID == SID_ATTR_FILL_STYLE )
128 			{
129 				delete pStyleItem;
130 				pStyleItem = (XFillStyleItem*) pState->Clone();
131 				pFillTypeLB->Enable();
132 
133 				eLastXFS = pFillTypeLB->GetSelectEntryPos();
134 				bUpdate = sal_True;
135 
136 				XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue();
137 				pFillTypeLB->SelectEntryPos(
138                     sal::static_int_cast< sal_uInt16 >( eXFS ) );
139 				pFillAttrLB->Enable();
140 			}
141 			else if( pStyleItem )
142 			{
143 				XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue();
144 
145 				if( nSID == SID_ATTR_FILL_COLOR )
146 				{
147 					delete pColorItem;
148 					pColorItem = (XFillColorItem*) pState->Clone();
149 
150 					if( eXFS == XFILL_SOLID )
151 						bEnableControls = sal_True;
152 				}
153 				else if( nSID == SID_ATTR_FILL_GRADIENT )
154 				{
155 					delete pGradientItem;
156 					pGradientItem = (XFillGradientItem*) pState->Clone();
157 
158 					if( eXFS == XFILL_GRADIENT )
159 						bEnableControls = sal_True;
160 				}
161 				else if( nSID == SID_ATTR_FILL_HATCH )
162 				{
163 					delete pHatchItem;
164 					pHatchItem = (XFillHatchItem*) pState->Clone();
165 
166 					if( eXFS == XFILL_HATCH )
167 						bEnableControls = sal_True;
168 				}
169 				else if( nSID == SID_ATTR_FILL_BITMAP )
170 				{
171 					delete pBitmapItem;
172 					pBitmapItem = (XFillBitmapItem*) pState->Clone();
173 
174 					if( eXFS == XFILL_BITMAP )
175 						bEnableControls = sal_True;
176 				}
177 			}
178 			if( bEnableControls )
179 			{
180 				//pFillTypeLB->Enable();
181 				pFillAttrLB->Enable();
182 
183 				bUpdate = sal_True;
184 			}
185 
186             Update( pState );
187         }
188 		else
189 		{
190 			// leerer oder uneindeutiger Status
191 			if( nSID == SID_ATTR_FILL_STYLE )
192 			{
193 				pFillTypeLB->SetNoSelection();
194 				pFillAttrLB->Disable();
195 				pFillAttrLB->SetNoSelection();
196 				bUpdate = sal_False;
197 			}
198 			else
199 			{
200 				XFillStyle eXFS = XFILL_NONE;
201 				if( pStyleItem )
202 					eXFS = (XFillStyle)pStyleItem->GetValue();
203 				if( !pStyleItem ||
204 					( nSID == SID_ATTR_FILL_COLOR	 && eXFS == XFILL_SOLID ) ||
205 					( nSID == SID_ATTR_FILL_GRADIENT && eXFS == XFILL_GRADIENT ) ||
206 					( nSID == SID_ATTR_FILL_HATCH 	 && eXFS == XFILL_HATCH ) ||
207 					( nSID == SID_ATTR_FILL_BITMAP 	 && eXFS == XFILL_BITMAP ) )
208 				{
209 					pFillAttrLB->SetNoSelection();
210 					//bUpdate = sal_False;
211 				}
212 			}
213 		}
214 	}
215 }
216 
217 //========================================================================
218 
219 void SvxFillToolBoxControl::IgnoreStatusUpdate( sal_Bool bSet )
220 {
221     bIgnoreStatusUpdate = bSet;
222 }
223 
224 //========================================================================
225 
226 void SvxFillToolBoxControl::Update( const SfxPoolItem* pState )
227 {
228 	if ( pStyleItem && pState && bUpdate )
229 	{
230 		bUpdate = sal_False;
231 
232 		XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue();
233 
234 		// Pruefen, ob Fuellstil schon vorher aktiv war
235 		//if( eTmpXFS != eXFS )
236 		if( (XFillStyle) eLastXFS != eXFS )
237 			pFillControl->SelectFillTypeHdl( NULL );
238 			//eLastXFS = eXFS;
239 
240 		switch( eXFS )
241 		{
242 			case XFILL_NONE:
243 			break;
244 
245 			case XFILL_SOLID:
246 			{
247 				if ( pColorItem )
248 				{
249 					String aString( pColorItem->GetName() );
250                     ::Color aColor = pColorItem->GetColorValue();
251 
252 					pFillAttrLB->SelectEntry( aString );
253 
254 					if ( pFillAttrLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND ||
255 						 pFillAttrLB->GetSelectEntryColor() != aColor )
256 						pFillAttrLB->SelectEntry( aColor );
257 
258 					// NEU
259 					// Pruefen, ob Eintrag nicht in der Liste ist
260 					if( pFillAttrLB->GetSelectEntryPos() ==
261 						LISTBOX_ENTRY_NOTFOUND ||
262 						pFillAttrLB->GetSelectEntryColor() != aColor )
263 					{
264 						sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
265 						String aTmpStr;
266 						if( nCount > 0 )
267 						{
268 							//Letzter Eintrag wird auf temporaere Farbe geprueft
269 							aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
270 							if(  aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
271 								 aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
272 							{
273 								pFillAttrLB->RemoveEntry( nCount - 1 );
274 							}
275 						}
276 						aTmpStr = TMP_STR_BEGIN;
277 						aTmpStr += aString;
278 						aTmpStr += TMP_STR_END;
279 
280 						//pFillAttrLB->SetUpdateMode( sal_False );
281 						sal_uInt16 nPos = pFillAttrLB->InsertEntry( aColor, aTmpStr );
282 						//pFillAttrLB->SetUpdateMode( sal_True );
283 						pFillAttrLB->SelectEntryPos( nPos );
284 					}
285 					// NEU
286 				}
287 				else
288 					pFillAttrLB->SetNoSelection();
289 			}
290 			break;
291 
292 			case XFILL_GRADIENT:
293 			{
294 				if ( pGradientItem )
295 				{
296 					String aString( pGradientItem->GetName() );
297 					pFillAttrLB->SelectEntry( aString );
298 					// NEU
299 					// Pruefen, ob Eintrag nicht in der Liste ist
300 					if( pFillAttrLB->GetSelectEntry() != aString )
301 					{
302 						sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
303 						String aTmpStr;
304 						if( nCount > 0 )
305 						{
306 							//Letzter Eintrag wird auf temporaeren Eintrag geprueft
307 							aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
308 							if(  aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
309 								 aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
310 							{
311 								pFillAttrLB->RemoveEntry( nCount - 1 );
312 							}
313 						}
314 						aTmpStr = TMP_STR_BEGIN;
315 						aTmpStr += aString;
316 						aTmpStr += TMP_STR_END;
317 
318 						XGradientEntry* pEntry = new XGradientEntry( pGradientItem->GetGradientValue(), aTmpStr );
319 						String aEmptyString = String();
320  						XGradientList aGradientList( aEmptyString );
321 						aGradientList.Insert( pEntry );
322 						aGradientList.SetDirty( sal_False );
323 						Bitmap* pBmp = aGradientList.CreateBitmapForUI( 0 );
324 
325 						if( pBmp )
326 						{
327 							( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), *pBmp );
328 							pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 );
329 							delete pBmp;
330 						}
331 
332 						aGradientList.Remove( 0 );
333 						delete pEntry;
334 					}
335 					// NEU
336 				}
337 				else
338 					pFillAttrLB->SetNoSelection();
339 			}
340 			break;
341 
342 			case XFILL_HATCH:
343 			{
344 				if ( pHatchItem )
345 				{
346 					String aString( pHatchItem->GetName() );
347 					pFillAttrLB->SelectEntry( aString );
348 					// NEU
349 					// Pruefen, ob Eintrag nicht in der Liste ist
350 					if( pFillAttrLB->GetSelectEntry() != aString )
351 					{
352 						sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
353 						String aTmpStr;
354 						if( nCount > 0 )
355 						{
356 							//Letzter Eintrag wird auf temporaeren Eintrag geprueft
357 							aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
358 							if(  aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
359 								 aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
360 							{
361 								pFillAttrLB->RemoveEntry( nCount - 1 );
362 							}
363 						}
364 						aTmpStr = TMP_STR_BEGIN;
365 						aTmpStr += aString;
366 						aTmpStr += TMP_STR_END;
367 
368 						XHatchEntry* pEntry = new XHatchEntry( pHatchItem->GetHatchValue(), aTmpStr );
369 						String aEmptyString = String();
370 						XHatchList aHatchList( aEmptyString );
371 						aHatchList.Insert( pEntry );
372 						aHatchList.SetDirty( sal_False );
373 						Bitmap* pBmp = aHatchList.CreateBitmapForUI( 0 );
374 
375 						if( pBmp )
376 						{
377 							( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), *pBmp );
378 							pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 );
379 							delete pBmp;
380 						}
381 
382 						aHatchList.Remove( 0 );
383 						delete pEntry;
384 					}
385 					// NEU
386 				}
387 				else
388 					pFillAttrLB->SetNoSelection();
389 			}
390 			break;
391 
392 			case XFILL_BITMAP:
393 			{
394 				if ( pBitmapItem )
395 					// &&
396 					// SfxObjectShell::Current() 	&&
397 					// SfxObjectShell::Current()->GetItem( SID_BITMAP_LIST ) )
398 				{
399 					String aString( pBitmapItem->GetName() );
400 					// Bitmap aBitmap( pBitmapItem->GetValue() );
401 
402 					// SvxBitmapListItem aItem( *(const SvxBitmapListItem*)(
403 					// 	SfxObjectShell::Current()->GetItem( SID_BITMAP_LIST ) ) );
404 					pFillAttrLB->SelectEntry( aString );
405 					// NEU
406 					// Pruefen, ob Eintrag nicht in der Liste ist
407 					if( pFillAttrLB->GetSelectEntry() != aString )
408 					{
409 						sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
410 						String aTmpStr;
411 						if( nCount > 0 )
412 						{
413 							//Letzter Eintrag wird auf temporaeren Eintrag geprueft
414 							aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
415 							if(  aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
416 								 aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
417 							{
418 								pFillAttrLB->RemoveEntry( nCount - 1 );
419 							}
420 						}
421 						aTmpStr = TMP_STR_BEGIN;
422 						aTmpStr += aString;
423 						aTmpStr += TMP_STR_END;
424 
425 						XBitmapEntry* pEntry = new XBitmapEntry(pBitmapItem->GetGraphicObject(), aTmpStr);
426 						XBitmapList aBitmapList( String::CreateFromAscii("TmpList") );
427 						aBitmapList.Insert( pEntry );
428 						aBitmapList.SetDirty( sal_False );
429 						pFillAttrLB->Fill( &aBitmapList );
430 						pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 );
431 						aBitmapList.Remove( 0 );
432 						delete pEntry;
433 					}
434 					// NEU
435 				}
436 				else
437 					pFillAttrLB->SetNoSelection();
438 			}
439 			break;
440 
441 			default:
442 				DBG_ERROR( "Nicht unterstuetzter Flaechentyp" );
443 			break;
444 		}
445 	}
446 
447 	if( pState && pStyleItem )
448 	{
449 		XFillStyle eXFS = (XFillStyle) pStyleItem->GetValue();
450 
451 		// Die Listen haben sich geaendert ?
452 		if( pState->ISA( SvxColorTableItem ) &&
453 			eXFS == XFILL_SOLID )
454 		{
455 			::Color aTmpColor( pFillAttrLB->GetSelectEntryColor() );
456 			pFillAttrLB->Clear();
457 			pFillAttrLB->Fill( ( (SvxColorTableItem*)pState )->GetColorTable() );
458 			pFillAttrLB->SelectEntry( aTmpColor );
459 		}
460 		if( pState->ISA( SvxGradientListItem ) &&
461 			eXFS == XFILL_GRADIENT )
462 		{
463 			String aString( pFillAttrLB->GetSelectEntry() );
464 			pFillAttrLB->Clear();
465 			pFillAttrLB->Fill( ( (SvxGradientListItem*)pState )->GetGradientList() );
466 			pFillAttrLB->SelectEntry( aString );
467 		}
468 		if( pState->ISA( SvxHatchListItem ) &&
469 			eXFS == XFILL_HATCH )
470 		{
471 			String aString( pFillAttrLB->GetSelectEntry() );
472 			pFillAttrLB->Clear();
473 			pFillAttrLB->Fill( ( (SvxHatchListItem*)pState )->GetHatchList() );
474 			pFillAttrLB->SelectEntry( aString );
475 		}
476 		if( pState->ISA( SvxBitmapListItem ) &&
477 			eXFS == XFILL_BITMAP )
478 		{
479 			String aString( pFillAttrLB->GetSelectEntry() );
480 			pFillAttrLB->Clear();
481 			pFillAttrLB->Fill( ( (SvxBitmapListItem*)pState )->GetBitmapList() );
482 			pFillAttrLB->SelectEntry( aString );
483 		}
484 	}
485 }
486 
487 //========================================================================
488 
489 Window* SvxFillToolBoxControl::CreateItemWindow( Window *pParent )
490 {
491 	if ( GetSlotId() == SID_ATTR_FILL_STYLE )
492 	{
493 		pFillControl = new FillControl( pParent );
494 		// Damit dem FillControl das SvxFillToolBoxControl bekannt ist
495 		// (und um kompatibel zu bleiben)
496 		pFillControl->SetData( this );
497 
498 		pFillAttrLB = (SvxFillAttrBox*)pFillControl->pLbFillAttr;
499 		pFillTypeLB = (SvxFillTypeBox*)pFillControl->pLbFillType;
500 
501 		pFillAttrLB->SetUniqueId( HID_FILL_ATTR_LISTBOX );
502 		pFillTypeLB->SetUniqueId( HID_FILL_TYPE_LISTBOX );
503 
504 		return pFillControl;
505 	}
506 	return NULL;
507 }
508 
509 /*************************************************************************
510 |*
511 |* FillControl
512 |*
513 \************************************************************************/
514 
515 FillControl::FillControl( Window* pParent, WinBits nStyle ) :
516     Window( pParent, nStyle | WB_DIALOGCONTROL ),
517     pLbFillType(new SvxFillTypeBox( this )),
518     aLogicalFillSize(40,80),
519     aLogicalAttrSize(50,80)
520 {
521     pLbFillAttr = new SvxFillAttrBox( this );
522     Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT));
523     Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT));
524     pLbFillType->SetSizePixel(aTypeSize);
525     pLbFillAttr->SetSizePixel(aAttrSize);
526     //to get the base height
527     aTypeSize = pLbFillType->GetSizePixel();
528     aAttrSize = pLbFillAttr->GetSizePixel();
529     Point aAttrPnt = pLbFillAttr->GetPosPixel();
530 	SetSizePixel(
531 		Size( aAttrPnt.X() + aAttrSize.Width(),
532 			  Max( aAttrSize.Height(), aTypeSize.Height() ) ) );
533 
534 	pLbFillType->SetSelectHdl( LINK( this, FillControl, SelectFillTypeHdl ) );
535 	pLbFillAttr->SetSelectHdl( LINK( this, FillControl, SelectFillAttrHdl ) );
536 
537 	aDelayTimer.SetTimeout( DELAY_TIMEOUT );
538 	aDelayTimer.SetTimeoutHdl( LINK( this, FillControl, DelayHdl ) );
539 	aDelayTimer.Start();
540 }
541 
542 //------------------------------------------------------------------------
543 
544 FillControl::~FillControl()
545 {
546 	delete pLbFillType;
547 	delete pLbFillAttr;
548 }
549 
550 //------------------------------------------------------------------------
551 
552 IMPL_LINK_INLINE_START( FillControl, DelayHdl, Timer *, EMPTYARG )
553 {
554 	SelectFillTypeHdl( NULL );
555     ( (SvxFillToolBoxControl*)GetData() )->updateStatus( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillStyle" )));
556 //	( (SvxFillToolBoxControl*)GetData() )->GetBindings().Invalidate( SID_ATTR_FILL_STYLE );
557 	return 0;
558 }
559 IMPL_LINK_INLINE_END( FillControl, DelayHdl, Timer *, pTimer )
560 
561 //------------------------------------------------------------------------
562 
563 IMPL_LINK( FillControl, SelectFillTypeHdl, ListBox *, pBox )
564 {
565 	XFillStyle  eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos();
566 
567 	// Spaeter sollte eine Optimierung derart erfolgen, dass die
568 	// Listen, bzw. Tables nur dann geloescht und wieder aufgebaut
569 	// werden, wenn sich die Listen, bzw. Tables tatsaechlich geaendert
570 	// haben (in den LBs natuerlich).
571 
572 	if ( ( pBox && !pBox->IsTravelSelect() ) || !pBox )
573 	{
574 		// Damit wir in folgendem Fall einen Status anzeigen koennen:
575 		// Ein Typ wurde ausgewaehlt aber kein Attribut.
576 		// Die Selektion hat genau die gleichen Attribute wie die vorherige.
577 //		SvxFillToolBoxControl* pControlerItem = (SvxFillToolBoxControl*)GetData();
578 //		if( pControlerItem )
579 //			pControlerItem->ClearCache();
580 
581 		pLbFillAttr->Clear();
582 		SfxObjectShell* pSh = SfxObjectShell::Current();
583 
584 		switch( eXFS )
585 		{
586 			case XFILL_NONE:
587 			{
588 				pLbFillType->Selected();
589 				SelectFillAttrHdl( pBox );
590 				pLbFillAttr->Disable();
591 			}
592 			break;
593 
594 			case XFILL_SOLID:
595 			{
596 				if ( pSh && pSh->GetItem( SID_COLOR_TABLE ) )
597 				{
598 					SvxColorTableItem aItem( *(const SvxColorTableItem*)(
599 						pSh->GetItem( SID_COLOR_TABLE ) ) );
600 					pLbFillAttr->Enable();
601 					pLbFillAttr->Fill( aItem.GetColorTable() );
602 				}
603 				else
604 					pLbFillAttr->Disable();
605 			}
606 			break;
607 
608 			case XFILL_GRADIENT:
609 			{
610 				if ( pSh && pSh->GetItem( SID_GRADIENT_LIST ) )
611 				{
612 					SvxGradientListItem aItem( *(const SvxGradientListItem*)(
613 						pSh->GetItem( SID_GRADIENT_LIST ) ) );
614 					pLbFillAttr->Enable();
615 					pLbFillAttr->Fill( aItem.GetGradientList() );
616 				}
617 				else
618 					pLbFillAttr->Disable();
619 			}
620 			break;
621 
622 			case XFILL_HATCH:
623 			{
624 				if ( pSh && pSh->GetItem( SID_HATCH_LIST ) )
625 				{
626 					SvxHatchListItem aItem( *(const SvxHatchListItem*)(
627 						pSh->GetItem( SID_HATCH_LIST ) ) );
628 					pLbFillAttr->Enable();
629 					pLbFillAttr->Fill( aItem.GetHatchList() );
630 				}
631 				else
632 					pLbFillAttr->Disable();
633 			}
634 			break;
635 
636 			case XFILL_BITMAP:
637 			{
638 				if ( pSh && pSh->GetItem( SID_BITMAP_LIST ) )
639 				{
640 					SvxBitmapListItem aItem( *(const SvxBitmapListItem*)(
641 						pSh->GetItem( SID_BITMAP_LIST ) ) );
642 					pLbFillAttr->Enable();
643 					pLbFillAttr->Fill( aItem.GetBitmapList() );
644 				}
645 				else
646 					pLbFillAttr->Disable();
647 			}
648 			break;
649 		}
650 
651 		if( eXFS != XFILL_NONE ) // Wurde schon erledigt
652 		{
653 			if ( pBox )
654 				pLbFillType->Selected();
655 
656 			// release focus
657             if ( pBox && pLbFillType->IsRelease() )
658 			{
659 				SfxViewShell* pViewShell = SfxViewShell::Current();
660 				if( pViewShell && pViewShell->GetWindow() )
661 					pViewShell->GetWindow()->GrabFocus();
662 			}
663 		}
664     }
665 	return 0;
666 }
667 
668 //------------------------------------------------------------------------
669 
670 IMPL_LINK( FillControl, SelectFillAttrHdl, ListBox *, pBox )
671 {
672 	XFillStyle eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos();
673 	XFillStyleItem aXFillStyleItem( eXFS );
674 	sal_Bool bAction = pBox && !pLbFillAttr->IsTravelSelect();
675 
676 	SfxObjectShell* pSh = SfxObjectShell::Current();
677     if ( bAction )
678     {
679         Any a;
680         Sequence< PropertyValue > aArgs( 1 );
681 
682         // First set the style
683         aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ));
684         aXFillStyleItem.QueryValue(  a );
685         aArgs[0].Value = a;
686         ( (SvxFillToolBoxControl*)GetData() )->IgnoreStatusUpdate( sal_True );
687         ((SvxFillToolBoxControl*)GetData())->Dispatch(
688             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillStyle" )), aArgs );
689         ( (SvxFillToolBoxControl*)GetData() )->IgnoreStatusUpdate( sal_False );
690 
691         switch( eXFS )
692         {
693             case XFILL_NONE:
694             {
695             }
696             break;
697 
698             case XFILL_SOLID:
699             {
700                 // NEU
701                 //Eintrag wird auf temporaere Farbe geprueft
702                 String aTmpStr = pLbFillAttr->GetSelectEntry();
703                 if( aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
704                 {
705                     aTmpStr.Erase( aTmpStr.Len()-1, 1 );
706                     aTmpStr.Erase( 0, 1 );
707                 }
708 
709                 XFillColorItem aXFillColorItem( aTmpStr, pLbFillAttr->GetSelectEntryColor() );
710 
711                 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ));
712                 aXFillColorItem.QueryValue( a );
713                 aArgs[0].Value = a;
714                 ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillColor" )),
715                                                                aArgs );
716             }
717             break;
718             case XFILL_GRADIENT:
719             {
720                 sal_uInt16 nPos = pLbFillAttr->GetSelectEntryPos();
721 
722                 if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_GRADIENT_LIST ) )
723                 {
724                     SvxGradientListItem aItem(
725                         *(const SvxGradientListItem*)( pSh->GetItem( SID_GRADIENT_LIST ) ) );
726 
727                     if ( nPos < aItem.GetGradientList()->Count() )  // kein temp. Eintrag ?
728                     {
729                         XGradient aGradient = aItem.GetGradientList()->GetGradient( nPos )->GetGradient();
730                         XFillGradientItem aXFillGradientItem( pLbFillAttr->GetSelectEntry(), aGradient );
731 
732                         aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" ));
733                         aXFillGradientItem.QueryValue( a );
734                         aArgs[0].Value = a;
735                         ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillGradient" )),
736                                                                        aArgs );
737                     }
738                 }
739             }
740             break;
741 
742             case XFILL_HATCH:
743             {
744                 sal_uInt16 nPos = pLbFillAttr->GetSelectEntryPos();
745 
746                 if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_HATCH_LIST ) )
747                 {
748                     SvxHatchListItem aItem( *(const SvxHatchListItem*)( pSh->GetItem( SID_HATCH_LIST ) ) );
749 
750                     if ( nPos < aItem.GetHatchList()->Count() )  // kein temp. Eintrag ?
751                     {
752                         XHatch aHatch = aItem.GetHatchList()->GetHatch( nPos )->GetHatch();
753                         XFillHatchItem aXFillHatchItem( pLbFillAttr->GetSelectEntry(), aHatch );
754 
755                         aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillHatch" ));
756                         aXFillHatchItem.QueryValue( a );
757                         aArgs[0].Value = a;
758                         ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillHatch" )),
759                                                                        aArgs );
760                     }
761                 }
762             }
763             break;
764 
765             case XFILL_BITMAP:
766             {
767                 sal_uInt16 nPos = pLbFillAttr->GetSelectEntryPos();
768 
769                 if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_BITMAP_LIST ) )
770                 {
771                     SvxBitmapListItem aItem(
772                         *(const SvxBitmapListItem*)( pSh->GetItem( SID_BITMAP_LIST ) ) );
773 
774                     if ( nPos < aItem.GetBitmapList()->Count() )  // kein temp. Eintrag ?
775                     {
776                         const XBitmapEntry* pXBitmapEntry = aItem.GetBitmapList()->GetBitmap(nPos);
777                         const XFillBitmapItem aXFillBitmapItem(pLbFillAttr->GetSelectEntry(), pXBitmapEntry->GetGraphicObject());
778 
779                         aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillBitmap" ));
780                         aXFillBitmapItem.QueryValue( a );
781                         aArgs[0].Value = a;
782                         ((SvxFillToolBoxControl*)GetData())->Dispatch(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FillBitmap")), aArgs);
783                     }
784                 }
785             }
786             break;
787         }
788 
789         // release focus
790         if ( pLbFillAttr->IsRelease()  && pBox )
791 		{
792 			SfxViewShell* pViewShell = SfxViewShell::Current();
793 			if( pViewShell && pViewShell->GetWindow() )
794 			{
795 	            pViewShell->GetWindow()->GrabFocus();
796 			}
797 		}
798     }
799 
800     return 0;
801 }
802 
803 //------------------------------------------------------------------------
804 
805 void FillControl::Resize()
806 {
807 	// Breite der beiden ListBoxen nicht 1/2 : 1/2, sondern 2/5 : 3/5
808 	long nW = GetOutputSizePixel().Width() / 5;
809 	long nH = 180;
810 	long nSep = 0; // war vorher 4
811 
812 	pLbFillType->SetSizePixel( Size( nW * 2 - nSep, nH ) );
813 	pLbFillAttr->SetPosSizePixel( Point( nW * 2 + nSep, 0 ), Size( nW * 3 - nSep, nH ) );
814 }
815 /* -----------------------------08.03.2002 15:04------------------------------
816 
817  ---------------------------------------------------------------------------*/
818 
819 void FillControl::DataChanged( const DataChangedEvent& rDCEvt )
820 {
821 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
822          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
823     {
824         Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT));
825         Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT));
826         pLbFillType->SetSizePixel(aTypeSize);
827         pLbFillAttr->SetSizePixel(aAttrSize);
828         //to get the base height
829         aTypeSize = pLbFillType->GetSizePixel();
830         aAttrSize = pLbFillAttr->GetSizePixel();
831         Point aAttrPnt = pLbFillAttr->GetPosPixel();
832 
833         SetSizePixel(
834             Size( aAttrPnt.X() + aAttrSize.Width(),
835                 Max( aAttrSize.Height(), aTypeSize.Height() ) ) );
836     }
837     Window::DataChanged( rDCEvt );
838 }
839 
840