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