Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <string>
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 [ + - ]: 278 : SFX_IMPL_TOOLBOX_CONTROL( SvxFillToolBoxControl, XFillStyleItem );
58 : :
59 : : /*************************************************************************
60 : : |*
61 : : |* SvxFillToolBoxControl
62 : : |*
63 : : \************************************************************************/
64 : :
65 : 129 : 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 : 129 : eLastXFS ( XFILL_NONE )
79 : : {
80 [ + - ][ + - ]: 129 : addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillColor" )));
81 [ + - ][ + - ]: 129 : addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillGradient" )));
82 [ + - ][ + - ]: 129 : addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillHatch" )));
83 [ + - ][ + - ]: 129 : addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillBitmap" )));
84 [ + - ][ + - ]: 129 : addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" )));
85 [ + - ][ + - ]: 129 : addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GradientListState" )));
86 [ + - ][ + - ]: 129 : addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:HatchListState" )));
87 [ + - ][ + - ]: 129 : addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BitmapListState" )));
88 : 129 : }
89 : :
90 : : //========================================================================
91 : :
92 : 129 : SvxFillToolBoxControl::~SvxFillToolBoxControl()
93 : : {
94 [ + + ][ + - ]: 129 : delete pStyleItem;
95 [ + + ][ + - ]: 129 : delete pColorItem;
96 [ + + ][ + - ]: 129 : delete pGradientItem;
97 [ + + ][ + - ]: 129 : delete pHatchItem;
98 [ + + ][ + - ]: 129 : delete pBitmapItem;
99 [ - + ]: 258 : }
100 : :
101 : : //========================================================================
102 : :
103 : 1468 : void SvxFillToolBoxControl::StateChanged(
104 : :
105 : : sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
106 : :
107 : : {
108 : 1468 : bool bEnableControls = false;
109 : :
110 [ - + ]: 1468 : if ( bIgnoreStatusUpdate )
111 : 1468 : return;
112 : :
113 [ - + ]: 1468 : if( eState == SFX_ITEM_DISABLED )
114 : : {
115 [ # # ]: 0 : if( nSID == SID_ATTR_FILL_STYLE )
116 : : {
117 : 0 : pFillTypeLB->Disable();
118 : 0 : pFillTypeLB->SetNoSelection();
119 : : }
120 : 0 : pFillAttrLB->Disable();
121 : 0 : pFillAttrLB->SetNoSelection();
122 : : }
123 : : else
124 : : {
125 [ + + ]: 1468 : if ( SFX_ITEM_AVAILABLE == eState )
126 : : {
127 [ + + ]: 868 : if( nSID == SID_ATTR_FILL_STYLE )
128 : : {
129 [ + + ]: 268 : delete pStyleItem;
130 : 268 : pStyleItem = (XFillStyleItem*) pState->Clone();
131 : 268 : pFillTypeLB->Enable();
132 : :
133 : 268 : eLastXFS = pFillTypeLB->GetSelectEntryPos();
134 : 268 : bUpdate = sal_True;
135 : :
136 : 268 : XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue();
137 : : pFillTypeLB->SelectEntryPos(
138 : 268 : sal::static_int_cast< sal_uInt16 >( eXFS ) );
139 : 268 : pFillAttrLB->Enable();
140 : : }
141 [ + - ]: 600 : else if( pStyleItem )
142 : : {
143 : 600 : XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue();
144 : :
145 [ + + ]: 600 : if( nSID == SID_ATTR_FILL_COLOR )
146 : : {
147 [ + + ]: 150 : delete pColorItem;
148 : 150 : pColorItem = (XFillColorItem*) pState->Clone();
149 : :
150 [ + - ]: 150 : if( eXFS == XFILL_SOLID )
151 : 150 : bEnableControls = true;
152 : : }
153 [ + + ]: 450 : else if( nSID == SID_ATTR_FILL_GRADIENT )
154 : : {
155 [ + + ]: 150 : delete pGradientItem;
156 : 150 : pGradientItem = (XFillGradientItem*) pState->Clone();
157 : :
158 [ - + ]: 150 : if( eXFS == XFILL_GRADIENT )
159 : 0 : bEnableControls = true;
160 : : }
161 [ + + ]: 300 : else if( nSID == SID_ATTR_FILL_HATCH )
162 : : {
163 [ + + ]: 150 : delete pHatchItem;
164 : 150 : pHatchItem = (XFillHatchItem*) pState->Clone();
165 : :
166 [ - + ]: 150 : if( eXFS == XFILL_HATCH )
167 : 0 : bEnableControls = true;
168 : : }
169 [ + - ]: 150 : else if( nSID == SID_ATTR_FILL_BITMAP )
170 : : {
171 [ + + ]: 150 : delete pBitmapItem;
172 : 150 : pBitmapItem = (XFillBitmapItem*) pState->Clone();
173 : :
174 [ - + ]: 150 : if( eXFS == XFILL_BITMAP )
175 : 0 : bEnableControls = true;
176 : : }
177 : : }
178 [ + + ]: 868 : if( bEnableControls )
179 : : {
180 : : //pFillTypeLB->Enable();
181 : 150 : pFillAttrLB->Enable();
182 : :
183 : 150 : bUpdate = sal_True;
184 : : }
185 : :
186 : 868 : Update( pState );
187 : : }
188 : : else
189 : : {
190 : : // leerer oder uneindeutiger Status
191 [ - + ]: 600 : if( nSID == SID_ATTR_FILL_STYLE )
192 : : {
193 : 0 : pFillTypeLB->SetNoSelection();
194 : 0 : pFillAttrLB->Disable();
195 : 0 : pFillAttrLB->SetNoSelection();
196 : 0 : bUpdate = sal_False;
197 : : }
198 : : else
199 : : {
200 : 600 : XFillStyle eXFS = XFILL_NONE;
201 [ + - ]: 600 : if( pStyleItem )
202 : 600 : eXFS = (XFillStyle)pStyleItem->GetValue();
203 [ + - ][ - + ]: 600 : 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 : 0 : pFillAttrLB->SetNoSelection();
210 : : //bUpdate = sal_False;
211 : : }
212 : : }
213 : : }
214 : : }
215 : : }
216 : :
217 : : //========================================================================
218 : :
219 : 0 : void SvxFillToolBoxControl::IgnoreStatusUpdate( sal_Bool bSet )
220 : : {
221 : 0 : bIgnoreStatusUpdate = bSet;
222 : 0 : }
223 : :
224 : : //========================================================================
225 : :
226 : 868 : void SvxFillToolBoxControl::Update( const SfxPoolItem* pState )
227 : : {
228 [ + - ][ + - ]: 868 : if ( pStyleItem && pState && bUpdate )
[ + + ]
229 : : {
230 : 418 : bUpdate = sal_False;
231 : :
232 : 418 : XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue();
233 : :
234 : : // Pruefen, ob Fuellstil schon vorher aktiv war
235 : : //if( eTmpXFS != eXFS )
236 [ - + ]: 418 : if( (XFillStyle) eLastXFS != eXFS )
237 : 0 : pFillControl->SelectFillTypeHdl( NULL );
238 : : //eLastXFS = eXFS;
239 : :
240 [ - + - - : 418 : switch( eXFS )
- - ]
241 : : {
242 : : case XFILL_NONE:
243 : 0 : break;
244 : :
245 : : case XFILL_SOLID:
246 : : {
247 [ + + ]: 418 : if ( pColorItem )
248 : : {
249 [ + - ]: 203 : String aString( pColorItem->GetName() );
250 [ + - ]: 203 : ::Color aColor = pColorItem->GetColorValue();
251 : :
252 [ + - ]: 203 : pFillAttrLB->SelectEntry( aString );
253 : :
254 [ + - ]: 499 : if ( pFillAttrLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND ||
[ + + - + ]
[ + + ]
255 [ + - ][ + + ]: 296 : pFillAttrLB->GetSelectEntryColor() != aColor )
[ # # ]
256 [ + - ]: 110 : pFillAttrLB->SelectEntry( aColor );
257 : :
258 : : // NEU
259 : : // Pruefen, ob Eintrag nicht in der Liste ist
260 [ + - ]: 601 : if( pFillAttrLB->GetSelectEntryPos() ==
[ + + - + ]
[ + + ]
261 : : LISTBOX_ENTRY_NOTFOUND ||
262 [ + - ][ + + ]: 398 : pFillAttrLB->GetSelectEntryColor() != aColor )
[ # # ]
263 : : {
264 [ + - ]: 8 : sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
265 [ + - ]: 8 : String aTmpStr;
266 [ - + ]: 8 : if( nCount > 0 )
267 : : {
268 : : //Letzter Eintrag wird auf temporaere Farbe geprueft
269 [ # # ][ # # ]: 0 : aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
[ # # ]
270 [ # # # # ]: 0 : if( aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
[ # # ]
271 : 0 : aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
272 : : {
273 [ # # ]: 0 : pFillAttrLB->RemoveEntry( nCount - 1 );
274 : : }
275 : : }
276 [ + - ]: 8 : aTmpStr = TMP_STR_BEGIN;
277 [ + - ]: 8 : aTmpStr += aString;
278 [ + - ]: 8 : aTmpStr += TMP_STR_END;
279 : :
280 : : //pFillAttrLB->SetUpdateMode( sal_False );
281 [ + - ]: 8 : sal_uInt16 nPos = pFillAttrLB->InsertEntry( aColor, aTmpStr );
282 : : //pFillAttrLB->SetUpdateMode( sal_True );
283 [ + - ][ + - ]: 8 : pFillAttrLB->SelectEntryPos( nPos );
284 [ + - ]: 203 : }
285 : : // NEU
286 : : }
287 : : else
288 : 215 : pFillAttrLB->SetNoSelection();
289 : : }
290 : 418 : break;
291 : :
292 : : case XFILL_GRADIENT:
293 : : {
294 [ # # ]: 0 : if ( pGradientItem )
295 : : {
296 [ # # ]: 0 : String aString( pGradientItem->GetName() );
297 [ # # ]: 0 : pFillAttrLB->SelectEntry( aString );
298 : : // NEU
299 : : // Pruefen, ob Eintrag nicht in der Liste ist
300 [ # # ][ # # ]: 0 : if( pFillAttrLB->GetSelectEntry() != aString )
[ # # ][ # # ]
301 : : {
302 [ # # ]: 0 : sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
303 [ # # ]: 0 : String aTmpStr;
304 [ # # ]: 0 : if( nCount > 0 )
305 : : {
306 : : //Letzter Eintrag wird auf temporaeren Eintrag geprueft
307 [ # # ][ # # ]: 0 : aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
[ # # ]
308 [ # # # # ]: 0 : if( aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
[ # # ]
309 : 0 : aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
310 : : {
311 [ # # ]: 0 : pFillAttrLB->RemoveEntry( nCount - 1 );
312 : : }
313 : : }
314 [ # # ]: 0 : aTmpStr = TMP_STR_BEGIN;
315 [ # # ]: 0 : aTmpStr += aString;
316 [ # # ]: 0 : aTmpStr += TMP_STR_END;
317 : :
318 [ # # ][ # # ]: 0 : XGradientEntry* pEntry = new XGradientEntry( pGradientItem->GetGradientValue(), aTmpStr );
[ # # ]
319 [ # # ]: 0 : String aEmptyString = String();
320 [ # # ]: 0 : XGradientList aGradientList( aEmptyString );
321 [ # # ]: 0 : aGradientList.Insert( pEntry );
322 : 0 : aGradientList.SetDirty( sal_False );
323 [ # # ]: 0 : Bitmap* pBmp = aGradientList.CreateBitmapForUI( 0 );
324 : :
325 [ # # ]: 0 : if( pBmp )
326 : : {
327 [ # # ][ # # ]: 0 : ( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), *pBmp );
[ # # ]
328 [ # # ][ # # ]: 0 : pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 );
329 [ # # ][ # # ]: 0 : delete pBmp;
330 : : }
331 : :
332 [ # # ]: 0 : aGradientList.Remove( 0 );
333 [ # # ][ # # ]: 0 : delete pEntry;
[ # # ][ # # ]
[ # # ]
334 [ # # ]: 0 : }
335 : : // NEU
336 : : }
337 : : else
338 : 0 : pFillAttrLB->SetNoSelection();
339 : : }
340 : 0 : break;
341 : :
342 : : case XFILL_HATCH:
343 : : {
344 [ # # ]: 0 : if ( pHatchItem )
345 : : {
346 [ # # ]: 0 : String aString( pHatchItem->GetName() );
347 [ # # ]: 0 : pFillAttrLB->SelectEntry( aString );
348 : : // NEU
349 : : // Pruefen, ob Eintrag nicht in der Liste ist
350 [ # # ][ # # ]: 0 : if( pFillAttrLB->GetSelectEntry() != aString )
[ # # ][ # # ]
351 : : {
352 [ # # ]: 0 : sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
353 [ # # ]: 0 : String aTmpStr;
354 [ # # ]: 0 : if( nCount > 0 )
355 : : {
356 : : //Letzter Eintrag wird auf temporaeren Eintrag geprueft
357 [ # # ][ # # ]: 0 : aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
[ # # ]
358 [ # # # # ]: 0 : if( aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
[ # # ]
359 : 0 : aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
360 : : {
361 [ # # ]: 0 : pFillAttrLB->RemoveEntry( nCount - 1 );
362 : : }
363 : : }
364 [ # # ]: 0 : aTmpStr = TMP_STR_BEGIN;
365 [ # # ]: 0 : aTmpStr += aString;
366 [ # # ]: 0 : aTmpStr += TMP_STR_END;
367 : :
368 [ # # ][ # # ]: 0 : XHatchEntry* pEntry = new XHatchEntry( pHatchItem->GetHatchValue(), aTmpStr );
[ # # ]
369 [ # # ]: 0 : String aEmptyString = String();
370 [ # # ]: 0 : XHatchList aHatchList( aEmptyString );
371 [ # # ]: 0 : aHatchList.Insert( pEntry );
372 : 0 : aHatchList.SetDirty( sal_False );
373 [ # # ]: 0 : Bitmap* pBmp = aHatchList.CreateBitmapForUI( 0 );
374 : :
375 [ # # ]: 0 : if( pBmp )
376 : : {
377 [ # # ][ # # ]: 0 : ( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), *pBmp );
[ # # ]
378 [ # # ][ # # ]: 0 : pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 );
379 [ # # ][ # # ]: 0 : delete pBmp;
380 : : }
381 : :
382 [ # # ]: 0 : aHatchList.Remove( 0 );
383 [ # # ][ # # ]: 0 : delete pEntry;
[ # # ][ # # ]
[ # # ]
384 [ # # ]: 0 : }
385 : : // NEU
386 : : }
387 : : else
388 : 0 : pFillAttrLB->SetNoSelection();
389 : : }
390 : 0 : break;
391 : :
392 : : case XFILL_BITMAP:
393 : : {
394 [ # # ]: 0 : if ( pBitmapItem )
395 : : // &&
396 : : // SfxObjectShell::Current() &&
397 : : // SfxObjectShell::Current()->GetItem( SID_BITMAP_LIST ) )
398 : : {
399 [ # # ]: 0 : String aString( pBitmapItem->GetName() );
400 : : // Bitmap aBitmap( pBitmapItem->GetValue() );
401 : :
402 : : // SvxBitmapListItem aItem( *(const SvxBitmapListItem*)(
403 : : // SfxObjectShell::Current()->GetItem( SID_BITMAP_LIST ) ) );
404 [ # # ]: 0 : pFillAttrLB->SelectEntry( aString );
405 : : // NEU
406 : : // Pruefen, ob Eintrag nicht in der Liste ist
407 [ # # ][ # # ]: 0 : if( pFillAttrLB->GetSelectEntry() != aString )
[ # # ][ # # ]
408 : : {
409 [ # # ]: 0 : sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
410 [ # # ]: 0 : String aTmpStr;
411 [ # # ]: 0 : if( nCount > 0 )
412 : : {
413 : : //Letzter Eintrag wird auf temporaeren Eintrag geprueft
414 [ # # ][ # # ]: 0 : aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
[ # # ]
415 [ # # # # ]: 0 : if( aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
[ # # ]
416 : 0 : aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
417 : : {
418 [ # # ]: 0 : pFillAttrLB->RemoveEntry( nCount - 1 );
419 : : }
420 : : }
421 [ # # ]: 0 : aTmpStr = TMP_STR_BEGIN;
422 [ # # ]: 0 : aTmpStr += aString;
423 [ # # ]: 0 : aTmpStr += TMP_STR_END;
424 : :
425 [ # # ][ # # ]: 0 : XBitmapEntry* pEntry = new XBitmapEntry( pBitmapItem->GetBitmapValue(), aTmpStr );
[ # # ]
426 : : XBitmapListRef xBitmapList =
427 : : XPropertyList::CreatePropertyList(XBITMAP_LIST,
428 [ # # ][ # # ]: 0 : rtl::OUString("TmpList"))->AsBitmapList();
[ # # ][ # # ]
429 [ # # ]: 0 : xBitmapList->Insert( pEntry );
430 : 0 : xBitmapList->SetDirty( sal_False );
431 [ # # ]: 0 : pFillAttrLB->Fill( xBitmapList );
432 [ # # ][ # # ]: 0 : pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 );
433 [ # # ]: 0 : xBitmapList->Remove( 0 );
434 [ # # ][ # # ]: 0 : delete pEntry;
[ # # ]
435 [ # # ]: 0 : }
436 : : // NEU
437 : : }
438 : : else
439 : 0 : pFillAttrLB->SetNoSelection();
440 : : }
441 : 0 : break;
442 : :
443 : : default:
444 : : OSL_FAIL( "Nicht unterstuetzter Flaechentyp" );
445 : 418 : break;
446 : : }
447 : : }
448 : :
449 [ + - ][ + - ]: 868 : if( pState && pStyleItem )
450 : : {
451 : 868 : XFillStyle eXFS = (XFillStyle) pStyleItem->GetValue();
452 : :
453 : : // Die Listen haben sich geaendert ?
454 [ # # ][ - + ]: 868 : if( pState->ISA( SvxColorListItem ) &&
[ - + ]
455 : : eXFS == XFILL_SOLID )
456 : : {
457 [ # # ]: 0 : ::Color aTmpColor( pFillAttrLB->GetSelectEntryColor() );
458 [ # # ]: 0 : pFillAttrLB->Clear();
459 [ # # ][ # # ]: 0 : pFillAttrLB->Fill( ( (SvxColorListItem*)pState )->GetColorList() );
460 [ # # ]: 0 : pFillAttrLB->SelectEntry( aTmpColor );
461 : : }
462 [ - + ][ # # ]: 868 : if( pState->ISA( SvxGradientListItem ) &&
[ - + ]
463 : : eXFS == XFILL_GRADIENT )
464 : : {
465 [ # # ]: 0 : String aString( pFillAttrLB->GetSelectEntry() );
466 [ # # ]: 0 : pFillAttrLB->Clear();
467 [ # # ][ # # ]: 0 : pFillAttrLB->Fill( ( (SvxGradientListItem*)pState )->GetGradientList() );
468 [ # # ][ # # ]: 0 : pFillAttrLB->SelectEntry( aString );
469 : : }
470 [ - + ][ # # ]: 868 : if( pState->ISA( SvxHatchListItem ) &&
[ - + ]
471 : : eXFS == XFILL_HATCH )
472 : : {
473 [ # # ]: 0 : String aString( pFillAttrLB->GetSelectEntry() );
474 [ # # ]: 0 : pFillAttrLB->Clear();
475 [ # # ][ # # ]: 0 : pFillAttrLB->Fill( ( (SvxHatchListItem*)pState )->GetHatchList() );
476 [ # # ][ # # ]: 0 : pFillAttrLB->SelectEntry( aString );
477 : : }
478 [ - + ][ # # ]: 868 : if( pState->ISA( SvxBitmapListItem ) &&
[ - + ]
479 : : eXFS == XFILL_BITMAP )
480 : : {
481 [ # # ]: 0 : String aString( pFillAttrLB->GetSelectEntry() );
482 [ # # ]: 0 : pFillAttrLB->Clear();
483 [ # # ][ # # ]: 0 : pFillAttrLB->Fill( ( (SvxBitmapListItem*)pState )->GetBitmapList() );
484 [ # # ][ # # ]: 0 : pFillAttrLB->SelectEntry( aString );
485 : : }
486 : : }
487 : 868 : }
488 : :
489 : : //========================================================================
490 : :
491 : 129 : Window* SvxFillToolBoxControl::CreateItemWindow( Window *pParent )
492 : : {
493 [ + - ]: 129 : if ( GetSlotId() == SID_ATTR_FILL_STYLE )
494 : : {
495 [ + - ]: 129 : pFillControl = new FillControl( pParent );
496 : : // Damit dem FillControl das SvxFillToolBoxControl bekannt ist
497 : : // (und um kompatibel zu bleiben)
498 : 129 : pFillControl->SetData( this );
499 : :
500 : 129 : pFillAttrLB = (SvxFillAttrBox*)pFillControl->pLbFillAttr;
501 : 129 : pFillTypeLB = (SvxFillTypeBox*)pFillControl->pLbFillType;
502 : :
503 [ + - ]: 129 : pFillAttrLB->SetUniqueId( HID_FILL_ATTR_LISTBOX );
504 [ + - ]: 129 : pFillTypeLB->SetUniqueId( HID_FILL_TYPE_LISTBOX );
505 : :
506 : 129 : return pFillControl;
507 : : }
508 : 129 : return NULL;
509 : : }
510 : :
511 : : /*************************************************************************
512 : : |*
513 : : |* FillControl
514 : : |*
515 : : \************************************************************************/
516 : :
517 : 129 : FillControl::FillControl( Window* pParent, WinBits nStyle ) :
518 : : Window( pParent, nStyle | WB_DIALOGCONTROL ),
519 [ + - ]: 129 : pLbFillType(new SvxFillTypeBox( this )),
520 : : aLogicalFillSize(40,80),
521 [ + - ][ + - ]: 258 : aLogicalAttrSize(50,80)
522 : : {
523 [ + - ][ + - ]: 129 : pLbFillAttr = new SvxFillAttrBox( this );
524 [ + - ][ + - ]: 129 : Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT));
[ + - ]
525 [ + - ][ + - ]: 129 : Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT));
[ + - ]
526 [ + - ]: 129 : pLbFillType->SetSizePixel(aTypeSize);
527 [ + - ]: 129 : pLbFillAttr->SetSizePixel(aAttrSize);
528 : : //to get the base height
529 [ + - ]: 129 : aTypeSize = pLbFillType->GetSizePixel();
530 [ + - ]: 129 : aAttrSize = pLbFillAttr->GetSizePixel();
531 [ + - ]: 129 : Point aAttrPnt = pLbFillAttr->GetPosPixel();
532 : : SetSizePixel(
533 : 129 : Size( aAttrPnt.X() + aAttrSize.Width(),
534 [ + - ]: 258 : Max( aAttrSize.Height(), aTypeSize.Height() ) ) );
535 : :
536 [ + - ]: 129 : pLbFillType->SetSelectHdl( LINK( this, FillControl, SelectFillTypeHdl ) );
537 [ + - ]: 129 : pLbFillAttr->SetSelectHdl( LINK( this, FillControl, SelectFillAttrHdl ) );
538 : :
539 [ + - ]: 129 : aDelayTimer.SetTimeout( DELAY_TIMEOUT );
540 [ + - ]: 129 : aDelayTimer.SetTimeoutHdl( LINK( this, FillControl, DelayHdl ) );
541 [ + - ]: 129 : aDelayTimer.Start();
542 : 129 : }
543 : :
544 : : //------------------------------------------------------------------------
545 : :
546 [ + - ]: 129 : FillControl::~FillControl()
547 : : {
548 [ + - ][ + - ]: 129 : delete pLbFillType;
549 [ + - ][ + - ]: 129 : delete pLbFillAttr;
550 [ - + ]: 258 : }
551 : :
552 : : //------------------------------------------------------------------------
553 : :
554 : 119 : IMPL_LINK_NOARG_INLINE_START(FillControl, DelayHdl)
555 : : {
556 : 119 : SelectFillTypeHdl( NULL );
557 [ + - ][ + - ]: 119 : ( (SvxFillToolBoxControl*)GetData() )->updateStatus( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillStyle" )));
558 : : // ( (SvxFillToolBoxControl*)GetData() )->GetBindings().Invalidate( SID_ATTR_FILL_STYLE );
559 : 119 : return 0;
560 : : }
561 : 119 : IMPL_LINK_INLINE_END( FillControl, DelayHdl, Timer *, pTimer )
562 : :
563 : : //------------------------------------------------------------------------
564 : :
565 : 0 : IMPL_LINK( FillControl, SelectFillTypeHdl, ListBox *, pBox )
566 : : {
567 : 119 : 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 [ # # ][ + - ]: 119 : 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 : 119 : pLbFillAttr->Clear();
584 : 119 : SfxObjectShell* pSh = SfxObjectShell::Current();
585 : :
586 [ - + - - : 119 : switch( eXFS )
- - ]
587 : : {
588 : : case XFILL_NONE:
589 : : {
590 : 0 : pLbFillType->Selected();
591 : 0 : SelectFillAttrHdl( pBox );
592 : 0 : pLbFillAttr->Disable();
593 : : }
594 : 0 : break;
595 : :
596 : : case XFILL_SOLID:
597 : : {
598 [ + - ][ + - ]: 119 : if ( pSh && pSh->GetItem( SID_COLOR_TABLE ) )
[ + - ]
599 : : {
600 : : SvxColorListItem aItem( *(const SvxColorListItem*)(
601 [ + - ][ + - ]: 119 : pSh->GetItem( SID_COLOR_TABLE ) ) );
602 [ + - ]: 119 : pLbFillAttr->Enable();
603 [ + - ][ + - ]: 119 : pLbFillAttr->Fill( aItem.GetColorList() );
[ + - ]
604 : : }
605 : : else
606 : 0 : pLbFillAttr->Disable();
607 : : }
608 : 119 : break;
609 : :
610 : : case XFILL_GRADIENT:
611 : : {
612 [ # # ][ # # ]: 0 : if ( pSh && pSh->GetItem( SID_GRADIENT_LIST ) )
[ # # ]
613 : : {
614 : : SvxGradientListItem aItem( *(const SvxGradientListItem*)(
615 [ # # ][ # # ]: 0 : pSh->GetItem( SID_GRADIENT_LIST ) ) );
616 [ # # ]: 0 : pLbFillAttr->Enable();
617 [ # # ][ # # ]: 0 : pLbFillAttr->Fill( aItem.GetGradientList() );
[ # # ]
618 : : }
619 : : else
620 : 0 : pLbFillAttr->Disable();
621 : : }
622 : 0 : break;
623 : :
624 : : case XFILL_HATCH:
625 : : {
626 [ # # ][ # # ]: 0 : if ( pSh && pSh->GetItem( SID_HATCH_LIST ) )
[ # # ]
627 : : {
628 : : SvxHatchListItem aItem( *(const SvxHatchListItem*)(
629 [ # # ][ # # ]: 0 : pSh->GetItem( SID_HATCH_LIST ) ) );
630 [ # # ]: 0 : pLbFillAttr->Enable();
631 [ # # ][ # # ]: 0 : pLbFillAttr->Fill( aItem.GetHatchList() );
[ # # ]
632 : : }
633 : : else
634 : 0 : pLbFillAttr->Disable();
635 : : }
636 : 0 : break;
637 : :
638 : : case XFILL_BITMAP:
639 : : {
640 [ # # ][ # # ]: 0 : if ( pSh && pSh->GetItem( SID_BITMAP_LIST ) )
[ # # ]
641 : : {
642 : : SvxBitmapListItem aItem( *(const SvxBitmapListItem*)(
643 [ # # ][ # # ]: 0 : pSh->GetItem( SID_BITMAP_LIST ) ) );
644 [ # # ]: 0 : pLbFillAttr->Enable();
645 [ # # ][ # # ]: 0 : pLbFillAttr->Fill( aItem.GetBitmapList() );
[ # # ]
646 : : }
647 : : else
648 : 0 : pLbFillAttr->Disable();
649 : : }
650 : 0 : break;
651 : : }
652 : :
653 [ + - ]: 119 : if( eXFS != XFILL_NONE ) // Wurde schon erledigt
654 : : {
655 [ - + ]: 119 : if ( pBox )
656 : 0 : pLbFillType->Selected();
657 : :
658 : : // release focus
659 [ - + ][ # # ]: 119 : if ( pBox && pLbFillType->IsRelease() )
[ - + ]
660 : : {
661 : 0 : SfxViewShell* pViewShell = SfxViewShell::Current();
662 [ # # ][ # # ]: 0 : if( pViewShell && pViewShell->GetWindow() )
[ # # ]
663 : 0 : pViewShell->GetWindow()->GrabFocus();
664 : : }
665 : : }
666 : : }
667 : 119 : return 0;
668 : : }
669 : :
670 : : //------------------------------------------------------------------------
671 : :
672 : 0 : IMPL_LINK( FillControl, SelectFillAttrHdl, ListBox *, pBox )
673 : : {
674 [ # # ]: 0 : XFillStyle eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos();
675 [ # # ]: 0 : XFillStyleItem aXFillStyleItem( eXFS );
676 [ # # ][ # # ]: 0 : sal_Bool bAction = pBox && !pLbFillAttr->IsTravelSelect();
[ # # ]
677 : :
678 [ # # ]: 0 : SfxObjectShell* pSh = SfxObjectShell::Current();
679 [ # # ]: 0 : if ( bAction )
680 : : {
681 : 0 : Any a;
682 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
683 : :
684 : : // First set the style
685 [ # # ][ # # ]: 0 : aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ));
686 [ # # ]: 0 : aXFillStyleItem.QueryValue( a );
687 [ # # ]: 0 : aArgs[0].Value = a;
688 [ # # ][ # # ]: 0 : ( (SvxFillToolBoxControl*)GetData() )->IgnoreStatusUpdate( sal_True );
689 [ # # ]: 0 : ((SvxFillToolBoxControl*)GetData())->Dispatch(
690 [ # # ][ # # ]: 0 : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillStyle" )), aArgs );
691 [ # # ][ # # ]: 0 : ( (SvxFillToolBoxControl*)GetData() )->IgnoreStatusUpdate( sal_False );
692 : :
693 [ # # # # : 0 : switch( eXFS )
# # ]
694 : : {
695 : : case XFILL_NONE:
696 : : {
697 : : }
698 : 0 : break;
699 : :
700 : : case XFILL_SOLID:
701 : : {
702 : : // NEU
703 : : //Eintrag wird auf temporaere Farbe geprueft
704 [ # # ]: 0 : String aTmpStr = pLbFillAttr->GetSelectEntry();
705 [ # # ][ # # ]: 0 : if( aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
[ # # ]
706 : : {
707 [ # # ]: 0 : aTmpStr.Erase( aTmpStr.Len()-1, 1 );
708 [ # # ]: 0 : aTmpStr.Erase( 0, 1 );
709 : : }
710 : :
711 [ # # ][ # # ]: 0 : XFillColorItem aXFillColorItem( aTmpStr, pLbFillAttr->GetSelectEntryColor() );
712 : :
713 [ # # ][ # # ]: 0 : aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ));
714 [ # # ]: 0 : aXFillColorItem.QueryValue( a );
715 [ # # ]: 0 : aArgs[0].Value = a;
716 [ # # ]: 0 : ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillColor" )),
717 [ # # ][ # # ]: 0 : aArgs );
[ # # ][ # # ]
718 : : }
719 : 0 : break;
720 : : case XFILL_GRADIENT:
721 : : {
722 [ # # ]: 0 : sal_uInt16 nPos = pLbFillAttr->GetSelectEntryPos();
723 : :
724 [ # # ][ # # ]: 0 : if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_GRADIENT_LIST ) )
[ # # ][ # # ]
[ # # ]
725 : : {
726 : : SvxGradientListItem aItem(
727 [ # # ][ # # ]: 0 : *(const SvxGradientListItem*)( pSh->GetItem( SID_GRADIENT_LIST ) ) );
728 : :
729 [ # # ][ # # ]: 0 : if ( nPos < aItem.GetGradientList()->Count() ) // kein temp. Eintrag ?
[ # # ]
730 : : {
731 [ # # ][ # # ]: 0 : XGradient aGradient = aItem.GetGradientList()->GetGradient( nPos )->GetGradient();
732 [ # # ][ # # ]: 0 : XFillGradientItem aXFillGradientItem( pLbFillAttr->GetSelectEntry(), aGradient );
[ # # ]
733 : :
734 [ # # ][ # # ]: 0 : aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" ));
735 [ # # ]: 0 : aXFillGradientItem.QueryValue( a );
736 [ # # ]: 0 : aArgs[0].Value = a;
737 [ # # ]: 0 : ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillGradient" )),
738 [ # # ][ # # ]: 0 : aArgs );
[ # # ]
739 [ # # ]: 0 : }
740 : : }
741 : : }
742 : 0 : break;
743 : :
744 : : case XFILL_HATCH:
745 : : {
746 [ # # ]: 0 : sal_uInt16 nPos = pLbFillAttr->GetSelectEntryPos();
747 : :
748 [ # # ][ # # ]: 0 : if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_HATCH_LIST ) )
[ # # ][ # # ]
[ # # ]
749 : : {
750 [ # # ][ # # ]: 0 : SvxHatchListItem aItem( *(const SvxHatchListItem*)( pSh->GetItem( SID_HATCH_LIST ) ) );
751 : :
752 [ # # ][ # # ]: 0 : if ( nPos < aItem.GetHatchList()->Count() ) // kein temp. Eintrag ?
[ # # ]
753 : : {
754 [ # # ][ # # ]: 0 : XHatch aHatch = aItem.GetHatchList()->GetHatch( nPos )->GetHatch();
755 [ # # ][ # # ]: 0 : XFillHatchItem aXFillHatchItem( pLbFillAttr->GetSelectEntry(), aHatch );
[ # # ]
756 : :
757 [ # # ][ # # ]: 0 : aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillHatch" ));
758 [ # # ]: 0 : aXFillHatchItem.QueryValue( a );
759 [ # # ]: 0 : aArgs[0].Value = a;
760 [ # # ]: 0 : ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillHatch" )),
761 [ # # ][ # # ]: 0 : aArgs );
[ # # ]
762 [ # # ]: 0 : }
763 : : }
764 : : }
765 : 0 : break;
766 : :
767 : : case XFILL_BITMAP:
768 : : {
769 [ # # ]: 0 : sal_uInt16 nPos = pLbFillAttr->GetSelectEntryPos();
770 : :
771 [ # # ][ # # ]: 0 : if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_BITMAP_LIST ) )
[ # # ][ # # ]
[ # # ]
772 : : {
773 : : SvxBitmapListItem aItem(
774 [ # # ][ # # ]: 0 : *(const SvxBitmapListItem*)( pSh->GetItem( SID_BITMAP_LIST ) ) );
775 : :
776 [ # # ][ # # ]: 0 : if ( nPos < aItem.GetBitmapList()->Count() ) // kein temp. Eintrag ?
[ # # ]
777 : : {
778 [ # # ][ # # ]: 0 : XOBitmap aXOBitmap = aItem.GetBitmapList()->GetBitmap( nPos )->GetXBitmap();
[ # # ]
779 [ # # ][ # # ]: 0 : XFillBitmapItem aXFillBitmapItem( pLbFillAttr->GetSelectEntry(), aXOBitmap );
[ # # ]
780 : :
781 [ # # ][ # # ]: 0 : aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillBitmap" ));
782 [ # # ]: 0 : aXFillBitmapItem.QueryValue( a );
783 [ # # ]: 0 : aArgs[0].Value = a;
784 [ # # ]: 0 : ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillBitmap" )),
785 [ # # ][ # # ]: 0 : aArgs );
[ # # ][ # # ]
786 [ # # ]: 0 : }
787 : : }
788 : : }
789 : 0 : break;
790 : : }
791 : :
792 : : // release focus
793 [ # # ][ # # ]: 0 : if ( pLbFillAttr->IsRelease() && pBox )
[ # # ]
794 : : {
795 [ # # ]: 0 : SfxViewShell* pViewShell = SfxViewShell::Current();
796 [ # # ][ # # ]: 0 : if( pViewShell && pViewShell->GetWindow() )
[ # # ]
797 : : {
798 [ # # ]: 0 : pViewShell->GetWindow()->GrabFocus();
799 : : }
800 [ # # ]: 0 : }
801 : : }
802 : :
803 [ # # ]: 0 : return 0;
804 : : }
805 : :
806 : : //------------------------------------------------------------------------
807 : :
808 : 129 : void FillControl::Resize()
809 : : {
810 : : // Breite der beiden ListBoxen nicht 1/2 : 1/2, sondern 2/5 : 3/5
811 : 129 : long nW = GetOutputSizePixel().Width() / 5;
812 : 129 : long nH = 180;
813 : 129 : long nSep = 0; // war vorher 4
814 : :
815 [ + - ]: 129 : pLbFillType->SetSizePixel( Size( nW * 2 - nSep, nH ) );
816 [ + - ]: 129 : pLbFillAttr->SetPosSizePixel( Point( nW * 2 + nSep, 0 ), Size( nW * 3 - nSep, nH ) );
817 : 129 : }
818 : :
819 : 0 : void FillControl::DataChanged( const DataChangedEvent& rDCEvt )
820 : : {
821 [ # # # # ]: 0 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
[ # # ]
822 : 0 : (rDCEvt.GetFlags() & SETTINGS_STYLE) )
823 : : {
824 [ # # ][ # # ]: 0 : Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT));
[ # # ]
825 [ # # ][ # # ]: 0 : Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT));
[ # # ]
826 [ # # ]: 0 : pLbFillType->SetSizePixel(aTypeSize);
827 [ # # ]: 0 : pLbFillAttr->SetSizePixel(aAttrSize);
828 : : //to get the base height
829 [ # # ]: 0 : aTypeSize = pLbFillType->GetSizePixel();
830 [ # # ]: 0 : aAttrSize = pLbFillAttr->GetSizePixel();
831 [ # # ]: 0 : Point aAttrPnt = pLbFillAttr->GetPosPixel();
832 : :
833 : : SetSizePixel(
834 : 0 : Size( aAttrPnt.X() + aAttrSize.Width(),
835 [ # # ]: 0 : Max( aAttrSize.Height(), aTypeSize.Height() ) ) );
836 : : }
837 : 0 : Window::DataChanged( rDCEvt );
838 : 0 : }
839 : :
840 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|