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