xref: /AOO41X/main/svx/source/tbxctrls/fillctrl.cxx (revision 8809db7a87f97847b57a57f4cd2b0104b2b83182)
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->GetBitmapValue(), aTmpStr );
426                         XBitmapList aBitmapList( String::CreateFromAscii("TmpList") );
427                         aBitmapList.Insert( pEntry );
428                         aBitmapList.SetDirty( sal_False );
429                         //Bitmap* pBmp = aBitmapList.GetBitmap( 0 );
430                         //( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), *pBmp );
431                         pFillAttrLB->Fill( &aBitmapList );
432                         pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 );
433                         aBitmapList.Remove( 0 );
434                         delete pEntry;
435                     }
436                     // NEU
437                 }
438                 else
439                     pFillAttrLB->SetNoSelection();
440             }
441             break;
442 
443             default:
444                 DBG_ERROR( "Nicht unterstuetzter Flaechentyp" );
445             break;
446         }
447     }
448 
449     if( pState && pStyleItem )
450     {
451         XFillStyle eXFS = (XFillStyle) pStyleItem->GetValue();
452 
453         // Die Listen haben sich geaendert ?
454         if( pState->ISA( SvxColorTableItem ) &&
455             eXFS == XFILL_SOLID )
456         {
457             ::Color aTmpColor( pFillAttrLB->GetSelectEntryColor() );
458             pFillAttrLB->Clear();
459             pFillAttrLB->Fill( ( (SvxColorTableItem*)pState )->GetColorTable() );
460             pFillAttrLB->SelectEntry( aTmpColor );
461         }
462         if( pState->ISA( SvxGradientListItem ) &&
463             eXFS == XFILL_GRADIENT )
464         {
465             String aString( pFillAttrLB->GetSelectEntry() );
466             pFillAttrLB->Clear();
467             pFillAttrLB->Fill( ( (SvxGradientListItem*)pState )->GetGradientList() );
468             pFillAttrLB->SelectEntry( aString );
469         }
470         if( pState->ISA( SvxHatchListItem ) &&
471             eXFS == XFILL_HATCH )
472         {
473             String aString( pFillAttrLB->GetSelectEntry() );
474             pFillAttrLB->Clear();
475             pFillAttrLB->Fill( ( (SvxHatchListItem*)pState )->GetHatchList() );
476             pFillAttrLB->SelectEntry( aString );
477         }
478         if( pState->ISA( SvxBitmapListItem ) &&
479             eXFS == XFILL_BITMAP )
480         {
481             String aString( pFillAttrLB->GetSelectEntry() );
482             pFillAttrLB->Clear();
483             pFillAttrLB->Fill( ( (SvxBitmapListItem*)pState )->GetBitmapList() );
484             pFillAttrLB->SelectEntry( aString );
485         }
486     }
487 }
488 
489 //========================================================================
490 
491 Window* SvxFillToolBoxControl::CreateItemWindow( Window *pParent )
492 {
493     if ( GetSlotId() == SID_ATTR_FILL_STYLE )
494     {
495         pFillControl = new FillControl( pParent );
496         // Damit dem FillControl das SvxFillToolBoxControl bekannt ist
497         // (und um kompatibel zu bleiben)
498         pFillControl->SetData( this );
499 
500         pFillAttrLB = (SvxFillAttrBox*)pFillControl->pLbFillAttr;
501         pFillTypeLB = (SvxFillTypeBox*)pFillControl->pLbFillType;
502 
503         pFillAttrLB->SetUniqueId( HID_FILL_ATTR_LISTBOX );
504         pFillTypeLB->SetUniqueId( HID_FILL_TYPE_LISTBOX );
505 
506         return pFillControl;
507     }
508     return NULL;
509 }
510 
511 /*************************************************************************
512 |*
513 |* FillControl
514 |*
515 \************************************************************************/
516 
517 FillControl::FillControl( Window* pParent, WinBits nStyle ) :
518     Window( pParent, nStyle | WB_DIALOGCONTROL ),
519     pLbFillType(new SvxFillTypeBox( this )),
520     aLogicalFillSize(40,80),
521     aLogicalAttrSize(50,80)
522 {
523     pLbFillAttr = new SvxFillAttrBox( this );
524     Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT));
525     Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT));
526     pLbFillType->SetSizePixel(aTypeSize);
527     pLbFillAttr->SetSizePixel(aAttrSize);
528     //to get the base height
529     aTypeSize = pLbFillType->GetSizePixel();
530     aAttrSize = pLbFillAttr->GetSizePixel();
531     Point aAttrPnt = pLbFillAttr->GetPosPixel();
532     SetSizePixel(
533         Size( aAttrPnt.X() + aAttrSize.Width(),
534               Max( aAttrSize.Height(), aTypeSize.Height() ) ) );
535 
536     pLbFillType->SetSelectHdl( LINK( this, FillControl, SelectFillTypeHdl ) );
537     pLbFillAttr->SetSelectHdl( LINK( this, FillControl, SelectFillAttrHdl ) );
538 
539     aDelayTimer.SetTimeout( DELAY_TIMEOUT );
540     aDelayTimer.SetTimeoutHdl( LINK( this, FillControl, DelayHdl ) );
541     aDelayTimer.Start();
542 }
543 
544 //------------------------------------------------------------------------
545 
546 FillControl::~FillControl()
547 {
548     delete pLbFillType;
549     delete pLbFillAttr;
550 }
551 
552 //------------------------------------------------------------------------
553 
554 IMPL_LINK_INLINE_START( FillControl, DelayHdl, Timer *, EMPTYARG )
555 {
556     SelectFillTypeHdl( NULL );
557     ( (SvxFillToolBoxControl*)GetData() )->updateStatus( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillStyle" )));
558 //  ( (SvxFillToolBoxControl*)GetData() )->GetBindings().Invalidate( SID_ATTR_FILL_STYLE );
559     return 0;
560 }
561 IMPL_LINK_INLINE_END( FillControl, DelayHdl, Timer *, pTimer )
562 
563 //------------------------------------------------------------------------
564 
565 IMPL_LINK( FillControl, SelectFillTypeHdl, ListBox *, pBox )
566 {
567     XFillStyle  eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos();
568 
569     // Spaeter sollte eine Optimierung derart erfolgen, dass die
570     // Listen, bzw. Tables nur dann geloescht und wieder aufgebaut
571     // werden, wenn sich die Listen, bzw. Tables tatsaechlich geaendert
572     // haben (in den LBs natuerlich).
573 
574     if ( ( pBox && !pBox->IsTravelSelect() ) || !pBox )
575     {
576         // Damit wir in folgendem Fall einen Status anzeigen koennen:
577         // Ein Typ wurde ausgewaehlt aber kein Attribut.
578         // Die Selektion hat genau die gleichen Attribute wie die vorherige.
579 //      SvxFillToolBoxControl* pControlerItem = (SvxFillToolBoxControl*)GetData();
580 //      if( pControlerItem )
581 //          pControlerItem->ClearCache();
582 
583         pLbFillAttr->Clear();
584         SfxObjectShell* pSh = SfxObjectShell::Current();
585 
586         switch( eXFS )
587         {
588             case XFILL_NONE:
589             {
590                 pLbFillType->Selected();
591                 SelectFillAttrHdl( pBox );
592                 pLbFillAttr->Disable();
593             }
594             break;
595 
596             case XFILL_SOLID:
597             {
598                 if ( pSh && pSh->GetItem( SID_COLOR_TABLE ) )
599                 {
600                     SvxColorTableItem aItem( *(const SvxColorTableItem*)(
601                         pSh->GetItem( SID_COLOR_TABLE ) ) );
602                     pLbFillAttr->Enable();
603                     pLbFillAttr->Fill( aItem.GetColorTable() );
604                 }
605                 else
606                     pLbFillAttr->Disable();
607             }
608             break;
609 
610             case XFILL_GRADIENT:
611             {
612                 if ( pSh && pSh->GetItem( SID_GRADIENT_LIST ) )
613                 {
614                     SvxGradientListItem aItem( *(const SvxGradientListItem*)(
615                         pSh->GetItem( SID_GRADIENT_LIST ) ) );
616                     pLbFillAttr->Enable();
617                     pLbFillAttr->Fill( aItem.GetGradientList() );
618                 }
619                 else
620                     pLbFillAttr->Disable();
621             }
622             break;
623 
624             case XFILL_HATCH:
625             {
626                 if ( pSh && pSh->GetItem( SID_HATCH_LIST ) )
627                 {
628                     SvxHatchListItem aItem( *(const SvxHatchListItem*)(
629                         pSh->GetItem( SID_HATCH_LIST ) ) );
630                     pLbFillAttr->Enable();
631                     pLbFillAttr->Fill( aItem.GetHatchList() );
632                 }
633                 else
634                     pLbFillAttr->Disable();
635             }
636             break;
637 
638             case XFILL_BITMAP:
639             {
640                 if ( pSh && pSh->GetItem( SID_BITMAP_LIST ) )
641                 {
642                     SvxBitmapListItem aItem( *(const SvxBitmapListItem*)(
643                         pSh->GetItem( SID_BITMAP_LIST ) ) );
644                     pLbFillAttr->Enable();
645                     pLbFillAttr->Fill( aItem.GetBitmapList() );
646                 }
647                 else
648                     pLbFillAttr->Disable();
649             }
650             break;
651         }
652 
653         if( eXFS != XFILL_NONE ) // Wurde schon erledigt
654         {
655             if ( pBox )
656                 pLbFillType->Selected();
657 
658             // release focus
659             if ( pBox && pLbFillType->IsRelease() )
660             {
661                 SfxViewShell* pViewShell = SfxViewShell::Current();
662                 if( pViewShell && pViewShell->GetWindow() )
663                     pViewShell->GetWindow()->GrabFocus();
664             }
665         }
666     }
667     return 0;
668 }
669 
670 //------------------------------------------------------------------------
671 
672 IMPL_LINK( FillControl, SelectFillAttrHdl, ListBox *, pBox )
673 {
674     XFillStyle eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos();
675     XFillStyleItem aXFillStyleItem( eXFS );
676     sal_Bool bAction = pBox && !pLbFillAttr->IsTravelSelect();
677 
678     SfxObjectShell* pSh = SfxObjectShell::Current();
679     if ( bAction )
680     {
681         Any a;
682         Sequence< PropertyValue > aArgs( 1 );
683 
684         // First set the style
685         aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ));
686         aXFillStyleItem.QueryValue(  a );
687         aArgs[0].Value = a;
688         ( (SvxFillToolBoxControl*)GetData() )->IgnoreStatusUpdate( sal_True );
689         ((SvxFillToolBoxControl*)GetData())->Dispatch(
690             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillStyle" )), aArgs );
691         ( (SvxFillToolBoxControl*)GetData() )->IgnoreStatusUpdate( sal_False );
692 
693         switch( eXFS )
694         {
695             case XFILL_NONE:
696             {
697             }
698             break;
699 
700             case XFILL_SOLID:
701             {
702                 // NEU
703                 //Eintrag wird auf temporaere Farbe geprueft
704                 String aTmpStr = pLbFillAttr->GetSelectEntry();
705                 if( aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
706                 {
707                     aTmpStr.Erase( aTmpStr.Len()-1, 1 );
708                     aTmpStr.Erase( 0, 1 );
709                 }
710 
711                 XFillColorItem aXFillColorItem( aTmpStr, pLbFillAttr->GetSelectEntryColor() );
712 
713                 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ));
714                 aXFillColorItem.QueryValue( a );
715                 aArgs[0].Value = a;
716                 ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillColor" )),
717                                                                aArgs );
718             }
719             break;
720             case XFILL_GRADIENT:
721             {
722                 sal_uInt16 nPos = pLbFillAttr->GetSelectEntryPos();
723 
724                 if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_GRADIENT_LIST ) )
725                 {
726                     SvxGradientListItem aItem(
727                         *(const SvxGradientListItem*)( pSh->GetItem( SID_GRADIENT_LIST ) ) );
728 
729                     if ( nPos < aItem.GetGradientList()->Count() )  // kein temp. Eintrag ?
730                     {
731                         XGradient aGradient = aItem.GetGradientList()->GetGradient( nPos )->GetGradient();
732                         XFillGradientItem aXFillGradientItem( pLbFillAttr->GetSelectEntry(), aGradient );
733 
734                         aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" ));
735                         aXFillGradientItem.QueryValue( a );
736                         aArgs[0].Value = a;
737                         ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillGradient" )),
738                                                                        aArgs );
739                     }
740                 }
741             }
742             break;
743 
744             case XFILL_HATCH:
745             {
746                 sal_uInt16 nPos = pLbFillAttr->GetSelectEntryPos();
747 
748                 if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_HATCH_LIST ) )
749                 {
750                     SvxHatchListItem aItem( *(const SvxHatchListItem*)( pSh->GetItem( SID_HATCH_LIST ) ) );
751 
752                     if ( nPos < aItem.GetHatchList()->Count() )  // kein temp. Eintrag ?
753                     {
754                         XHatch aHatch = aItem.GetHatchList()->GetHatch( nPos )->GetHatch();
755                         XFillHatchItem aXFillHatchItem( pLbFillAttr->GetSelectEntry(), aHatch );
756 
757                         aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillHatch" ));
758                         aXFillHatchItem.QueryValue( a );
759                         aArgs[0].Value = a;
760                         ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillHatch" )),
761                                                                        aArgs );
762                     }
763                 }
764             }
765             break;
766 
767             case XFILL_BITMAP:
768             {
769                 sal_uInt16 nPos = pLbFillAttr->GetSelectEntryPos();
770 
771                 if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_BITMAP_LIST ) )
772                 {
773                     SvxBitmapListItem aItem(
774                         *(const SvxBitmapListItem*)( pSh->GetItem( SID_BITMAP_LIST ) ) );
775 
776                     if ( nPos < aItem.GetBitmapList()->Count() )  // kein temp. Eintrag ?
777                     {
778                         XOBitmap aXOBitmap = aItem.GetBitmapList()->GetBitmap( nPos )->GetXBitmap();
779                         XFillBitmapItem aXFillBitmapItem( pLbFillAttr->GetSelectEntry(), aXOBitmap );
780 
781                         aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillBitmap" ));
782                         aXFillBitmapItem.QueryValue( a );
783                         aArgs[0].Value = a;
784                         ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillBitmap" )),
785                                                                        aArgs );
786                     }
787                 }
788             }
789             break;
790         }
791 
792         // release focus
793         if ( pLbFillAttr->IsRelease()  && pBox )
794         {
795             SfxViewShell* pViewShell = SfxViewShell::Current();
796             if( pViewShell && pViewShell->GetWindow() )
797             {
798                 pViewShell->GetWindow()->GrabFocus();
799             }
800         }
801     }
802 
803     return 0;
804 }
805 
806 //------------------------------------------------------------------------
807 
808 void FillControl::Resize()
809 {
810     // Breite der beiden ListBoxen nicht 1/2 : 1/2, sondern 2/5 : 3/5
811     long nW = GetOutputSizePixel().Width() / 5;
812     long nH = 180;
813     long nSep = 0; // war vorher 4
814 
815     pLbFillType->SetSizePixel( Size( nW * 2 - nSep, nH ) );
816     pLbFillAttr->SetPosSizePixel( Point( nW * 2 + nSep, 0 ), Size( nW * 3 - nSep, nH ) );
817 }
818 /* -----------------------------08.03.2002 15:04------------------------------
819 
820  ---------------------------------------------------------------------------*/
821 
822 void FillControl::DataChanged( const DataChangedEvent& rDCEvt )
823 {
824     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
825          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
826     {
827         Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT));
828         Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT));
829         pLbFillType->SetSizePixel(aTypeSize);
830         pLbFillAttr->SetSizePixel(aAttrSize);
831         //to get the base height
832         aTypeSize = pLbFillType->GetSizePixel();
833         aAttrSize = pLbFillAttr->GetSizePixel();
834         Point aAttrPnt = pLbFillAttr->GetPosPixel();
835 
836         SetSizePixel(
837             Size( aAttrPnt.X() + aAttrSize.Width(),
838                 Max( aAttrSize.Height(), aTypeSize.Height() ) ) );
839     }
840     Window::DataChanged( rDCEvt );
841 }
842 
843