fillctrl.cxx (6d78070f) fillctrl.cxx (00467759)
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

--- 5 unchanged lines hidden (view full) ---

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
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

--- 5 unchanged lines hidden (view full) ---

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
22// MARKER(update_precomp.py): autogen include statement, do not remove
23#include "precompiled_svx.hxx"
24
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>
25#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
26#include <sfx2/app.hxx>
27#include <sfx2/dispatch.hxx>
28#include <sfx2/objsh.hxx>
29#include <sfx2/viewsh.hxx>
30#include <rtl/ustring.hxx>
35
36#include <svx/dialogs.hrc>
37
31#include <svx/dialogs.hrc>
32
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>

--- 9 unchanged lines hidden (view full) ---

57SFX_IMPL_TOOLBOX_CONTROL( SvxFillToolBoxControl, XFillStyleItem );
58
59/*************************************************************************
60|*
61|* SvxFillToolBoxControl
62|*
63\************************************************************************/
64
33#define TMP_STR_BEGIN '['
34#define TMP_STR_END ']'
35
36#include "svx/drawitem.hxx"
37#include "svx/xattr.hxx"
38#include <svx/xtable.hxx>
39#include <svx/fillctrl.hxx>
40#include <svx/itemwin.hxx>

--- 9 unchanged lines hidden (view full) ---

50SFX_IMPL_TOOLBOX_CONTROL( SvxFillToolBoxControl, XFillStyleItem );
51
52/*************************************************************************
53|*
54|* SvxFillToolBoxControl
55|*
56\************************************************************************/
57
65SvxFillToolBoxControl::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 eLastXFS ( XFILL_NONE )
58SvxFillToolBoxControl::SvxFillToolBoxControl(
59 sal_uInt16 nSlotId,
60 sal_uInt16 nId,
61 ToolBox& rTbx )
62: SfxToolBoxControl( nSlotId, nId, rTbx ),
63 mpStyleItem(0),
64 mpColorItem(0),
65 mpGradientItem(0),
66 mpHatchItem(0),
67 mpBitmapItem(0),
68 mpFillControl(0),
69 mpFillTypeLB(0),
70 mpFillAttrLB(0),
71 meLastXFS(XFILL_NONE),
72 mbUpdate(false)
78{
79 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillColor" )));
80 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillGradient" )));
81 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillHatch" )));
82 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillBitmap" )));
83 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" )));
84 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GradientListState" )));
85 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:HatchListState" )));
86 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BitmapListState" )));
87}
88
89//========================================================================
90
91SvxFillToolBoxControl::~SvxFillToolBoxControl()
92{
73{
74 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillColor" )));
75 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillGradient" )));
76 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillHatch" )));
77 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillBitmap" )));
78 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" )));
79 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GradientListState" )));
80 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:HatchListState" )));
81 addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BitmapListState" )));
82}
83
84//========================================================================
85
86SvxFillToolBoxControl::~SvxFillToolBoxControl()
87{
93 delete pStyleItem;
94 delete pColorItem;
95 delete pGradientItem;
96 delete pHatchItem;
97 delete pBitmapItem;
88 delete mpStyleItem;
89 delete mpColorItem;
90 delete mpGradientItem;
91 delete mpHatchItem;
92 delete mpBitmapItem;
98}
99
100//========================================================================
101
102void SvxFillToolBoxControl::StateChanged(
93}
94
95//========================================================================
96
97void SvxFillToolBoxControl::StateChanged(
103
104 sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
105
98 sal_uInt16 nSID,
99 SfxItemState eState,
100 const SfxPoolItem* pState)
106{
101{
107 bool bEnableControls = sal_False;
102 bool bEnableControls(false);
108
103
109 if( eState == SFX_ITEM_DISABLED )
110 {
111 if( nSID == SID_ATTR_FILL_STYLE )
112 {
113 pFillTypeLB->Disable();
114 pFillTypeLB->SetNoSelection();
115 }
116 pFillAttrLB->Disable();
117 pFillAttrLB->SetNoSelection();
118 }
119 else
120 {
121 if ( SFX_ITEM_AVAILABLE == eState )
122 {
123 if( nSID == SID_ATTR_FILL_STYLE )
124 {
125 delete pStyleItem;
126 pStyleItem = (XFillStyleItem*) pState->Clone();
127 pFillTypeLB->Enable();
128 }
129 else if( pStyleItem )
130 {
131 XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue();
104 if(eState == SFX_ITEM_DISABLED)
105 {
106 // slot disable state
107 if(nSID == SID_ATTR_FILL_STYLE)
108 {
109 mpFillTypeLB->Disable();
110 mpFillTypeLB->SetNoSelection();
111 }
132
112
133 if( nSID == SID_ATTR_FILL_COLOR )
134 {
135 delete pColorItem;
136 pColorItem = (XFillColorItem*) pState->Clone();
113 mpFillAttrLB->Disable();
114 mpFillAttrLB->SetNoSelection();
115 }
116 else if(SFX_ITEM_AVAILABLE == eState)
117 {
118 // slot available state
119 if(nSID == SID_ATTR_FILL_STYLE)
120 {
121 delete mpStyleItem;
122 mpStyleItem = static_cast< XFillStyleItem* >(pState->Clone());
123 mpFillTypeLB->Enable();
124 }
125 else if(mpStyleItem)
126 {
127 const XFillStyle eXFS(static_cast< XFillStyle >(mpStyleItem->GetValue()));
137
128
138 if( eXFS == XFILL_SOLID )
139 bEnableControls = sal_True;
140 }
141 else if( nSID == SID_ATTR_FILL_GRADIENT )
142 {
143 delete pGradientItem;
144 pGradientItem = (XFillGradientItem*) pState->Clone();
129 if(nSID == SID_ATTR_FILL_COLOR)
130 {
131 delete mpColorItem;
132 mpColorItem = static_cast< XFillColorItem* >(pState->Clone());
145
133
146 if( eXFS == XFILL_GRADIENT )
147 bEnableControls = sal_True;
148 }
149 else if( nSID == SID_ATTR_FILL_HATCH )
150 {
151 delete pHatchItem;
152 pHatchItem = (XFillHatchItem*) pState->Clone();
134 if(eXFS == XFILL_SOLID)
135 {
136 bEnableControls = true;
137 }
138 }
139 else if(nSID == SID_ATTR_FILL_GRADIENT)
140 {
141 delete mpGradientItem;
142 mpGradientItem = static_cast< XFillGradientItem* >(pState->Clone());
153
143
154 if( eXFS == XFILL_HATCH )
155 bEnableControls = sal_True;
156 }
157 else if( nSID == SID_ATTR_FILL_BITMAP )
158 {
159 delete pBitmapItem;
160 pBitmapItem = (XFillBitmapItem*) pState->Clone();
144 if(eXFS == XFILL_GRADIENT)
145 {
146 bEnableControls = true;
147 }
148 }
149 else if(nSID == SID_ATTR_FILL_HATCH)
150 {
151 delete mpHatchItem;
152 mpHatchItem = static_cast< XFillHatchItem* >(pState->Clone());
161
153
162 if( eXFS == XFILL_BITMAP )
163 bEnableControls = sal_True;
164 }
165 }
166
167 if( pStyleItem )
154 if(eXFS == XFILL_HATCH)
155 {
156 bEnableControls = true;
157 }
158 }
159 else if(nSID == SID_ATTR_FILL_BITMAP)
168 {
160 {
169 // ensure that the correct entry is selected in pFillTypeLB. It
170 // might have been changed by nSID == SID_ATTR_FILL_STYLE, but
171 // it might also be in an in-between state when user had started to
172 // change fillstyle, but not yet changed fillvalue for new style
173 // and when nSID == SID_ATTR_FILL_COLOR/SID_ATTR_FILL_GRADIENT/
174 // SID_ATTR_FILL_HATCH/SID_ATTR_FILL_BITMAP value change is triggered
175 eLastXFS = pFillTypeLB->GetSelectEntryPos();
176 XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue();
161 delete mpBitmapItem;
162 mpBitmapItem = static_cast< XFillBitmapItem* >(pState->Clone());
177
163
178 if(eLastXFS != eXFS)
164 if(eXFS == XFILL_BITMAP)
179 {
165 {
180 bUpdate = sal_True;
181 pFillTypeLB->SelectEntryPos( sal::static_int_cast< sal_uInt16 >( eXFS ) );
166 bEnableControls = true;
182 }
167 }
168 }
169 }
183
170
184 pFillAttrLB->Enable();
171 if(mpStyleItem)
172 {
173 // ensure that the correct entry is selected in mpFillTypeLB
174 XFillStyle eXFS(static_cast< XFillStyle >(mpStyleItem->GetValue()));
175 const bool bFillTypeChangedByUser(mpFillControl->mbFillTypeChanged);
176
177 if(bFillTypeChangedByUser)
178 {
179 meLastXFS = static_cast< XFillStyle >(mpFillControl->mnLastFillTypeControlSelectEntryPos);
180 mpFillControl->mbFillTypeChanged = false;
185 }
186
181 }
182
187 if( bEnableControls )
188 {
189 //pFillTypeLB->Enable();
190 pFillAttrLB->Enable();
183 if(meLastXFS != eXFS)
184 {
185 mbUpdate = true;
186 mpFillTypeLB->SelectEntryPos(sal::static_int_cast<sal_uInt16>(eXFS));
187 }
191
188
192 bUpdate = sal_True;
193 }
194
195 Update( pState );
189 mpFillAttrLB->Enable();
196 }
190 }
197 else
198 {
199 // leerer oder uneindeutiger Status
200 if( nSID == SID_ATTR_FILL_STYLE )
201 {
202 pFillTypeLB->SetNoSelection();
203 pFillAttrLB->Disable();
204 pFillAttrLB->SetNoSelection();
205 bUpdate = sal_False;
206 }
207 else
208 {
209 XFillStyle eXFS = XFILL_NONE;
210 if( pStyleItem )
211 eXFS = (XFillStyle)pStyleItem->GetValue();
212 if( !pStyleItem ||
213 ( nSID == SID_ATTR_FILL_COLOR && eXFS == XFILL_SOLID ) ||
214 ( nSID == SID_ATTR_FILL_GRADIENT && eXFS == XFILL_GRADIENT ) ||
215 ( nSID == SID_ATTR_FILL_HATCH && eXFS == XFILL_HATCH ) ||
216 ( nSID == SID_ATTR_FILL_BITMAP && eXFS == XFILL_BITMAP ) )
217 {
218 pFillAttrLB->SetNoSelection();
219 //bUpdate = sal_False;
220 }
221 }
222 }
223 }
191
192 if(bEnableControls)
193 {
194 mpFillAttrLB->Enable();
195 mbUpdate = true;
196 }
197
198 Update(pState);
199 }
200 else
201 {
202 // slot empty or ambigous
203 if(nSID == SID_ATTR_FILL_STYLE)
204 {
205 mpFillTypeLB->SetNoSelection();
206 mpFillAttrLB->Disable();
207 mpFillAttrLB->SetNoSelection();
208 delete mpStyleItem;
209 mpStyleItem = 0;
210 mbUpdate = false;
211 }
212 else
213 {
214 XFillStyle eXFS(XFILL_NONE);
215
216 if(mpStyleItem)
217 {
218 eXFS = static_cast< XFillStyle >(mpStyleItem->GetValue());
219 }
220
221 if(!mpStyleItem ||
222 (nSID == SID_ATTR_FILL_COLOR && eXFS == XFILL_SOLID) ||
223 (nSID == SID_ATTR_FILL_GRADIENT && eXFS == XFILL_GRADIENT) ||
224 (nSID == SID_ATTR_FILL_HATCH && eXFS == XFILL_HATCH) ||
225 (nSID == SID_ATTR_FILL_BITMAP && eXFS == XFILL_BITMAP))
226 {
227 mpFillAttrLB->SetNoSelection();
228 }
229 }
230 }
224}
225
226//========================================================================
227
231}
232
233//========================================================================
234
228void SvxFillToolBoxControl::Update( const SfxPoolItem* pState )
235void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
229{
236{
230 if ( pStyleItem && pState && bUpdate )
231 {
232 bUpdate = sal_False;
237 if(mpStyleItem && pState && mbUpdate)
238 {
239 mbUpdate = false;
240 const XFillStyle eXFS(static_cast< XFillStyle >(mpStyleItem->GetValue()));
233
241
234 XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue();
242 // Pruefen, ob Fuellstil schon vorher aktiv war
243 if(meLastXFS != eXFS)
244 {
245 // update mnLastFillTypeControlSelectEntryPos and fill style list
246 mpFillControl->updateLastFillTypeControlSelectEntryPos();
247 mpFillControl->InitializeFillStyleAccordingToGivenFillType(eXFS);
248 meLastXFS = eXFS;
249 }
235
250
236 // Pruefen, ob Fuellstil schon vorher aktiv war
237 //if( eTmpXFS != eXFS )
238 if( (XFillStyle) eLastXFS != eXFS )
239 pFillControl->SelectFillTypeHdl( NULL );
240 //eLastXFS = eXFS;
251 switch(eXFS)
252 {
253 case XFILL_NONE:
254 {
255 break;
256 }
241
257
242 switch( eXFS )
243 {
244 case XFILL_NONE:
245 break;
258 case XFILL_SOLID:
259 {
260 if(mpColorItem)
261 {
262 String aString(mpColorItem->GetName());
263 ::Color aColor = mpColorItem->GetColorValue();
246
264
247 case XFILL_SOLID:
248 {
249 if ( pColorItem )
250 {
251 String aString( pColorItem->GetName() );
252 ::Color aColor = pColorItem->GetColorValue();
265 mpFillAttrLB->SelectEntry(aString);
253
266
254 pFillAttrLB->SelectEntry( aString );
267 if(mpFillAttrLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND || mpFillAttrLB->GetSelectEntryColor() != aColor)
268 {
269 mpFillAttrLB->SelectEntry(aColor);
270 }
255
271
256 if ( pFillAttrLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND ||
257 pFillAttrLB->GetSelectEntryColor() != aColor )
258 pFillAttrLB->SelectEntry( aColor );
272 // Pruefen, ob Eintrag nicht in der Liste ist
273 if(mpFillAttrLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND || mpFillAttrLB->GetSelectEntryColor() != aColor)
274 {
275 sal_uInt16 nCount = mpFillAttrLB->GetEntryCount();
276 String aTmpStr;
277 if(nCount > 0)
278 {
279 //Letzter Eintrag wird auf temporaere Farbe geprueft
280 aTmpStr = mpFillAttrLB->GetEntry(nCount - 1);
259
281
260 // NEU
261 // Pruefen, ob Eintrag nicht in der Liste ist
262 if( pFillAttrLB->GetSelectEntryPos() ==
263 LISTBOX_ENTRY_NOTFOUND ||
264 pFillAttrLB->GetSelectEntryColor() != aColor )
265 {
266 sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
267 String aTmpStr;
268 if( nCount > 0 )
269 {
270 //Letzter Eintrag wird auf temporaere Farbe geprueft
271 aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
272 if( aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
273 aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
274 {
275 pFillAttrLB->RemoveEntry( nCount - 1 );
276 }
277 }
278 aTmpStr = TMP_STR_BEGIN;
279 aTmpStr += aString;
280 aTmpStr += TMP_STR_END;
282 if(aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len() - 1) == TMP_STR_END)
283 {
284 mpFillAttrLB->RemoveEntry(nCount - 1);
285 }
286 }
281
287
282 //pFillAttrLB->SetUpdateMode( sal_False );
283 sal_uInt16 nPos = pFillAttrLB->InsertEntry( aColor, aTmpStr );
284 //pFillAttrLB->SetUpdateMode( sal_True );
285 pFillAttrLB->SelectEntryPos( nPos );
286 }
287 // NEU
288 }
289 else
290 pFillAttrLB->SetNoSelection();
291 }
292 break;
288 aTmpStr = TMP_STR_BEGIN;
289 aTmpStr += aString;
290 aTmpStr += TMP_STR_END;
293
291
294 case XFILL_GRADIENT:
295 {
296 if ( pGradientItem )
297 {
298 String aString( pGradientItem->GetName() );
299 pFillAttrLB->SelectEntry( aString );
300 // NEU
301 // Pruefen, ob Eintrag nicht in der Liste ist
302 if( pFillAttrLB->GetSelectEntry() != aString )
303 {
304 sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
305 String aTmpStr;
306 if( nCount > 0 )
307 {
308 //Letzter Eintrag wird auf temporaeren Eintrag geprueft
309 aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
310 if( aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
311 aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
312 {
313 pFillAttrLB->RemoveEntry( nCount - 1 );
314 }
315 }
316 aTmpStr = TMP_STR_BEGIN;
317 aTmpStr += aString;
318 aTmpStr += TMP_STR_END;
292 sal_uInt16 nPos = mpFillAttrLB->InsertEntry(aColor,aTmpStr);
293 mpFillAttrLB->SelectEntryPos(nPos);
294 }
295 }
296 else
297 {
298 mpFillAttrLB->SetNoSelection();
299 }
300 break;
301 }
319
302
320 XGradientEntry* pEntry = new XGradientEntry( pGradientItem->GetGradientValue(), aTmpStr );
303 case XFILL_GRADIENT:
304 {
305 if(mpGradientItem)
306 {
307 String aString(mpGradientItem->GetName());
308 mpFillAttrLB->SelectEntry(aString);
309
310 // Pruefen, ob Eintrag nicht in der Liste ist
311 if(mpFillAttrLB->GetSelectEntry() != aString)
312 {
313 sal_uInt16 nCount = mpFillAttrLB->GetEntryCount();
314 String aTmpStr;
315
316 if(nCount > 0)
317 {
318 //Letzter Eintrag wird auf temporaeren Eintrag geprueft
319 aTmpStr = mpFillAttrLB->GetEntry(nCount - 1);
320
321 if(aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len() - 1) == TMP_STR_END)
322 {
323 mpFillAttrLB->RemoveEntry(nCount - 1);
324 }
325 }
326
327 aTmpStr = TMP_STR_BEGIN;
328 aTmpStr += aString;
329 aTmpStr += TMP_STR_END;
330
331 XGradientEntry* pEntry = new XGradientEntry(mpGradientItem->GetGradientValue(),aTmpStr);
321 XGradientListSharedPtr aGradientList(XPropertyListFactory::CreateSharedXGradientList(String::CreateFromAscii("TmpList")));
332 XGradientListSharedPtr aGradientList(XPropertyListFactory::CreateSharedXGradientList(String::CreateFromAscii("TmpList")));
322
333
323 aGradientList->Insert(pEntry);
334 aGradientList->Insert(pEntry);
324 aGradientList->SetDirty(false);
325 const Bitmap aBmp = aGradientList->GetUiBitmap( 0 );
335 aGradientList->SetDirty(false);
336 const Bitmap aBmp = aGradientList->GetUiBitmap(0);
326
337
327 if( !aBmp.IsEmpty() )
328 {
329 ( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), aBmp );
330 pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 );
331 }
332 }
333 // NEU
334 }
335 else
336 pFillAttrLB->SetNoSelection();
337 }
338 break;
338 if(!aBmp.IsEmpty())
339 {
340 ((ListBox*)mpFillAttrLB)->InsertEntry(pEntry->GetName(),aBmp);
341 mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1);
342 }
343 }
344 }
345 else
346 {
347 mpFillAttrLB->SetNoSelection();
348 }
349 break;
350 }
339
351
340 case XFILL_HATCH:
341 {
342 if ( pHatchItem )
343 {
344 String aString( pHatchItem->GetName() );
345 pFillAttrLB->SelectEntry( aString );
346 // NEU
347 // Pruefen, ob Eintrag nicht in der Liste ist
348 if( pFillAttrLB->GetSelectEntry() != aString )
349 {
350 sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
351 String aTmpStr;
352 if( nCount > 0 )
353 {
354 //Letzter Eintrag wird auf temporaeren Eintrag geprueft
355 aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
356 if( aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
357 aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
358 {
359 pFillAttrLB->RemoveEntry( nCount - 1 );
360 }
361 }
362 aTmpStr = TMP_STR_BEGIN;
363 aTmpStr += aString;
364 aTmpStr += TMP_STR_END;
352 case XFILL_HATCH:
353 {
354 if(mpHatchItem)
355 {
356 String aString(mpHatchItem->GetName());
357 mpFillAttrLB->SelectEntry(aString);
365
358
366 XHatchEntry* pEntry = new XHatchEntry( pHatchItem->GetHatchValue(), aTmpStr );
367 XHatchListSharedPtr aHatchList(XPropertyListFactory::CreateSharedXHatchList(String::CreateFromAscii("TmpList")));
359 // Pruefen, ob Eintrag nicht in der Liste ist
360 if(mpFillAttrLB->GetSelectEntry() != aString)
361 {
362 sal_uInt16 nCount = mpFillAttrLB->GetEntryCount();
363 String aTmpStr;
364 if(nCount > 0)
365 {
366 //Letzter Eintrag wird auf temporaeren Eintrag geprueft
367 aTmpStr = mpFillAttrLB->GetEntry(nCount - 1);
368 if(aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
369 aTmpStr.GetChar(aTmpStr.Len() - 1) == TMP_STR_END)
370 {
371 mpFillAttrLB->RemoveEntry(nCount - 1);
372 }
373 }
368
374
369 aHatchList->Insert( pEntry );
370 aHatchList->SetDirty( sal_False );
371 const Bitmap aBmp = aHatchList->GetUiBitmap( 0 );
375 aTmpStr = TMP_STR_BEGIN;
376 aTmpStr += aString;
377 aTmpStr += TMP_STR_END;
372
378
373 if( !aBmp.IsEmpty() )
374 {
375 ( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), aBmp );
376 pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 );
377 }
378 }
379 // NEU
380 }
381 else
382 pFillAttrLB->SetNoSelection();
383 }
384 break;
379 XHatchEntry* pEntry = new XHatchEntry(mpHatchItem->GetHatchValue(),aTmpStr);
380 XHatchListSharedPtr aHatchList(XPropertyListFactory::CreateSharedXHatchList(String::CreateFromAscii("TmpList")));
385
381
386 case XFILL_BITMAP:
387 {
388 if ( pBitmapItem )
389 // &&
390 // SfxObjectShell::Current() &&
391 // SfxObjectShell::Current()->GetItem( SID_BITMAP_LIST ) )
392 {
393 String aString( pBitmapItem->GetName() );
394 // Bitmap aBitmap( pBitmapItem->GetValue() );
382 aHatchList->Insert(pEntry);
383 aHatchList->SetDirty(sal_False);
384 const Bitmap aBmp = aHatchList->GetUiBitmap(0);
395
385
396 // SvxBitmapListItem aItem( *(const SvxBitmapListItem*)(
397 // SfxObjectShell::Current()->GetItem( SID_BITMAP_LIST ) ) );
398 pFillAttrLB->SelectEntry( aString );
399 // NEU
400 // Pruefen, ob Eintrag nicht in der Liste ist
401 if( pFillAttrLB->GetSelectEntry() != aString )
402 {
403 sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
404 String aTmpStr;
405 if( nCount > 0 )
406 {
407 //Letzter Eintrag wird auf temporaeren Eintrag geprueft
408 aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
409 if( aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
410 aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
411 {
412 pFillAttrLB->RemoveEntry( nCount - 1 );
413 }
414 }
415 aTmpStr = TMP_STR_BEGIN;
416 aTmpStr += aString;
417 aTmpStr += TMP_STR_END;
386 if(!aBmp.IsEmpty())
387 {
388 ((ListBox*)mpFillAttrLB)->InsertEntry(pEntry->GetName(),aBmp);
389 mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1);
390 }
391 }
392 }
393 else
394 {
395 mpFillAttrLB->SetNoSelection();
396 }
397 break;
398 }
418
399
400 case XFILL_BITMAP:
401 {
402 if(mpBitmapItem)
403 {
404 String aString(mpBitmapItem->GetName());
405 mpFillAttrLB->SelectEntry(aString);
406
407 // Pruefen, ob Eintrag nicht in der Liste ist
408 if(mpFillAttrLB->GetSelectEntry() != aString)
409 {
410 sal_uInt16 nCount = mpFillAttrLB->GetEntryCount();
411 String aTmpStr;
412
413 if(nCount > 0)
414 {
415 //Letzter Eintrag wird auf temporaeren Eintrag geprueft
416 aTmpStr = mpFillAttrLB->GetEntry(nCount - 1);
417
418 if(aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len() - 1) == TMP_STR_END)
419 {
420 mpFillAttrLB->RemoveEntry(nCount - 1);
421 }
422 }
423
424 aTmpStr = TMP_STR_BEGIN;
425 aTmpStr += aString;
426 aTmpStr += TMP_STR_END;
427
419 XBitmapListSharedPtr aNew(XPropertyListFactory::CreateSharedXBitmapList(String::CreateFromAscii("TmpList")));
428 XBitmapListSharedPtr aNew(XPropertyListFactory::CreateSharedXBitmapList(String::CreateFromAscii("TmpList")));
420 aNew->Insert(new XBitmapEntry(pBitmapItem->GetGraphicObject(), aTmpStr));
429 aNew->Insert(new XBitmapEntry(mpBitmapItem->GetGraphicObject(),aTmpStr));
421 aNew->SetDirty(false);
422
430 aNew->SetDirty(false);
431
423 pFillAttrLB->Fill( aNew );
424 pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 );
425 }
426 // NEU
427 }
428 else
429 pFillAttrLB->SetNoSelection();
430 }
431 break;
432 mpFillAttrLB->Fill(aNew);
433 mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1);
434 }
435 }
436 else
437 {
438 mpFillAttrLB->SetNoSelection();
439 }
440 break;
441 }
432
442
433 default:
434 DBG_ERROR( "Nicht unterstuetzter Flaechentyp" );
435 break;
436 }
437 }
443 default:
444 {
445 DBG_ERROR("Nicht unterstuetzter Flaechentyp");
446 break;
447 }
448 }
438
449
439 if( pState && pStyleItem )
440 {
441 XFillStyle eXFS = (XFillStyle) pStyleItem->GetValue();
450 // update mnLastFillAttrControlSelectEntryPos
451 mpFillControl->updateLastFillAttrControlSelectEntryPos();
452 }
442
453
443 // Die Listen haben sich geaendert ?
444 if( pState->ISA( SvxColorTableItem ) &&
445 eXFS == XFILL_SOLID )
446 {
447 ::Color aTmpColor( pFillAttrLB->GetSelectEntryColor() );
448 pFillAttrLB->Clear();
449 pFillAttrLB->Fill( ( (SvxColorTableItem*)pState )->GetColorTable() );
450 pFillAttrLB->SelectEntry( aTmpColor );
451 }
452 if( pState->ISA( SvxGradientListItem ) &&
453 eXFS == XFILL_GRADIENT )
454 {
455 String aString( pFillAttrLB->GetSelectEntry() );
456 pFillAttrLB->Clear();
457 pFillAttrLB->Fill( ( (SvxGradientListItem*)pState )->GetGradientList() );
458 pFillAttrLB->SelectEntry( aString );
459 }
460 if( pState->ISA( SvxHatchListItem ) &&
461 eXFS == XFILL_HATCH )
462 {
463 String aString( pFillAttrLB->GetSelectEntry() );
464 pFillAttrLB->Clear();
465 pFillAttrLB->Fill( ( (SvxHatchListItem*)pState )->GetHatchList() );
466 pFillAttrLB->SelectEntry( aString );
467 }
468 if( pState->ISA( SvxBitmapListItem ) &&
469 eXFS == XFILL_BITMAP )
470 {
471 String aString( pFillAttrLB->GetSelectEntry() );
472 pFillAttrLB->Clear();
473 pFillAttrLB->Fill( ( (SvxBitmapListItem*)pState )->GetBitmapList() );
474 pFillAttrLB->SelectEntry( aString );
475 }
476 }
454 if(pState && mpStyleItem)
455 {
456 XFillStyle eXFS = static_cast< XFillStyle >(mpStyleItem->GetValue());
457
458 // Die Listen haben sich geaendert ?
459 switch(eXFS)
460 {
461 case XFILL_SOLID:
462 {
463 const SvxColorTableItem* pItem = dynamic_cast< const SvxColorTableItem* >(pState);
464
465 if(pItem)
466 {
467 ::Color aTmpColor(mpFillAttrLB->GetSelectEntryColor());
468 mpFillAttrLB->Clear();
469 mpFillAttrLB->Fill(pItem->GetColorTable());
470 mpFillAttrLB->SelectEntry(aTmpColor);
471 }
472 break;
473 }
474 case XFILL_GRADIENT:
475 {
476 const SvxGradientListItem* pItem = dynamic_cast< const SvxGradientListItem* >(pState);
477
478 if(pItem)
479 {
480 String aString(mpFillAttrLB->GetSelectEntry());
481 mpFillAttrLB->Clear();
482 mpFillAttrLB->Fill(pItem->GetGradientList());
483 mpFillAttrLB->SelectEntry(aString);
484 }
485 break;
486 }
487 case XFILL_HATCH:
488 {
489 const SvxHatchListItem* pItem = dynamic_cast< const SvxHatchListItem* >(pState);
490
491 if(pItem)
492 {
493 String aString(mpFillAttrLB->GetSelectEntry());
494 mpFillAttrLB->Clear();
495 mpFillAttrLB->Fill(pItem->GetHatchList());
496 mpFillAttrLB->SelectEntry(aString);
497 }
498 break;
499 }
500 case XFILL_BITMAP:
501 {
502 const SvxBitmapListItem* pItem = dynamic_cast< const SvxBitmapListItem* >(pState);
503
504 if(pItem)
505 {
506 String aString(mpFillAttrLB->GetSelectEntry());
507 mpFillAttrLB->Clear();
508 mpFillAttrLB->Fill(pItem->GetBitmapList());
509 mpFillAttrLB->SelectEntry(aString);
510 }
511 break;
512 }
513 default: // XFILL_NONE
514 {
515 break;
516 }
517 }
518 }
477}
478
479//========================================================================
480
519}
520
521//========================================================================
522
481Window* SvxFillToolBoxControl::CreateItemWindow( Window *pParent )
523Window* SvxFillToolBoxControl::CreateItemWindow(Window *pParent)
482{
524{
483 if ( GetSlotId() == SID_ATTR_FILL_STYLE )
484 {
485 pFillControl = new FillControl( pParent );
486 // Damit dem FillControl das SvxFillToolBoxControl bekannt ist
487 // (und um kompatibel zu bleiben)
488 pFillControl->SetData( this );
525 if(GetSlotId() == SID_ATTR_FILL_STYLE)
526 {
527 mpFillControl = new FillControl(pParent);
528 // Damit dem FillControl das SvxFillToolBoxControl bekannt ist
529 // (und um kompatibel zu bleiben)
530 mpFillControl->SetData(this);
489
531
490 pFillAttrLB = (SvxFillAttrBox*)pFillControl->pLbFillAttr;
491 pFillTypeLB = (SvxFillTypeBox*)pFillControl->pLbFillType;
532 mpFillAttrLB = (SvxFillAttrBox*)mpFillControl->mpLbFillAttr;
533 mpFillTypeLB = (SvxFillTypeBox*)mpFillControl->mpLbFillType;
492
534
493 pFillAttrLB->SetUniqueId( HID_FILL_ATTR_LISTBOX );
494 pFillTypeLB->SetUniqueId( HID_FILL_TYPE_LISTBOX );
535 mpFillAttrLB->SetUniqueId(HID_FILL_ATTR_LISTBOX);
536 mpFillTypeLB->SetUniqueId(HID_FILL_TYPE_LISTBOX);
495
537
496 return pFillControl;
497 }
498 return NULL;
538 if(!mpStyleItem)
539 {
540 // for Writer and Calc it's not the same instance of
541 // SvxFillToolBoxControl which gets used after deselecting
542 // and selecting a DrawObject, thhus a useful initialization is
543 // needed to get the FillType and the FillStyle List inited
544 // correctly. This in combination with meLastXFS inited to
545 // XFILL_NONE do the trick
546 mpStyleItem = new XFillStyleItem(XFILL_SOLID);
547 }
548
549 return mpFillControl;
550 }
551 return NULL;
499}
500
501/*************************************************************************
502|*
503|* FillControl
504|*
505\************************************************************************/
506
552}
553
554/*************************************************************************
555|*
556|* FillControl
557|*
558\************************************************************************/
559
507FillControl::FillControl( Window* pParent, WinBits nStyle ) :
508 Window( pParent, nStyle | WB_DIALOGCONTROL ),
509 pLbFillType(new SvxFillTypeBox( this )),
510 aLogicalFillSize(40,80),
511 aLogicalAttrSize(50,80)
560FillControl::FillControl(Window* pParent,WinBits nStyle)
561: Window(pParent,nStyle | WB_DIALOGCONTROL),
562 mpLbFillType(new SvxFillTypeBox(this)),
563 mpLbFillAttr(new SvxFillAttrBox(this)),
564 maLogicalFillSize(40,80),
565 maLogicalAttrSize(50,80),
566 mnLastFillTypeControlSelectEntryPos(mpLbFillType->GetSelectEntryPos()),
567 mnLastFillAttrControlSelectEntryPos(mpLbFillAttr->GetSelectEntryPos()),
568 mbFillTypeChanged(false)
512{
569{
513 pLbFillAttr = new SvxFillAttrBox( this );
514 Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT));
515 Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT));
516 pLbFillType->SetSizePixel(aTypeSize);
517 pLbFillAttr->SetSizePixel(aAttrSize);
570 Size aTypeSize(LogicToPixel(maLogicalFillSize,MAP_APPFONT));
571 Size aAttrSize(LogicToPixel(maLogicalAttrSize,MAP_APPFONT));
572 mpLbFillType->SetSizePixel(aTypeSize);
573 mpLbFillAttr->SetSizePixel(aAttrSize);
574
518 //to get the base height
575 //to get the base height
519 aTypeSize = pLbFillType->GetSizePixel();
520 aAttrSize = pLbFillAttr->GetSizePixel();
521 Point aAttrPnt = pLbFillAttr->GetPosPixel();
522 SetSizePixel(
523 Size( aAttrPnt.X() + aAttrSize.Width(),
524 Max( aAttrSize.Height(), aTypeSize.Height() ) ) );
576 aTypeSize = mpLbFillType->GetSizePixel();
577 aAttrSize = mpLbFillAttr->GetSizePixel();
578 Point aAttrPnt = mpLbFillAttr->GetPosPixel();
579 SetSizePixel(
580 Size(aAttrPnt.X() + aAttrSize.Width(),
581 Max(aAttrSize.Height(),aTypeSize.Height())));
525
582
526 pLbFillType->SetSelectHdl( LINK( this, FillControl, SelectFillTypeHdl ) );
527 pLbFillAttr->SetSelectHdl( LINK( this, FillControl, SelectFillAttrHdl ) );
528
529 aDelayTimer.SetTimeout( DELAY_TIMEOUT );
530 aDelayTimer.SetTimeoutHdl( LINK( this, FillControl, DelayHdl ) );
531 aDelayTimer.Start();
583 mpLbFillType->SetSelectHdl(LINK(this,FillControl,SelectFillTypeHdl));
584 mpLbFillAttr->SetSelectHdl(LINK(this,FillControl,SelectFillAttrHdl));
532}
533
534//------------------------------------------------------------------------
535
536FillControl::~FillControl()
537{
585}
586
587//------------------------------------------------------------------------
588
589FillControl::~FillControl()
590{
538 delete pLbFillType;
539 delete pLbFillAttr;
591 delete mpLbFillType;
592 delete mpLbFillAttr;
540}
541
542//------------------------------------------------------------------------
543
593}
594
595//------------------------------------------------------------------------
596
544IMPL_LINK_INLINE_START( FillControl, DelayHdl, Timer *, EMPTYARG )
597void FillControl::InitializeFillStyleAccordingToGivenFillType(XFillStyle aFillStyle)
545{
598{
546 SelectFillTypeHdl( NULL );
547 ( (SvxFillToolBoxControl*)GetData() )->updateStatus( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillStyle" )));
548// ( (SvxFillToolBoxControl*)GetData() )->GetBindings().Invalidate( SID_ATTR_FILL_STYLE );
549 return 0;
599 SfxObjectShell* pSh = SfxObjectShell::Current();
600 bool bDone(false);
601
602 if(pSh)
603 {
604 // clear in all cases, else we would risk a mix of FillStyles in the Style list
605 mpLbFillAttr->Clear();
606
607 switch(aFillStyle)
608 {
609 case XFILL_SOLID:
610 {
611 if(pSh->GetItem(SID_COLOR_TABLE))
612 {
613 const SvxColorTableItem* pItem = static_cast< const SvxColorTableItem* >(pSh->GetItem(SID_COLOR_TABLE));
614 mpLbFillAttr->Enable();
615 mpLbFillAttr->Fill(pItem->GetColorTable());
616 bDone = true;
617 }
618 break;
619 }
620
621 case XFILL_GRADIENT:
622 {
623 if(pSh->GetItem(SID_GRADIENT_LIST))
624 {
625 const SvxGradientListItem* pItem = static_cast< const SvxGradientListItem* >(pSh->GetItem(SID_GRADIENT_LIST));
626 mpLbFillAttr->Enable();
627 mpLbFillAttr->Fill(pItem->GetGradientList());
628 bDone = true;
629 }
630 break;
631 }
632
633 case XFILL_HATCH:
634 {
635 if(pSh->GetItem(SID_HATCH_LIST))
636 {
637 const SvxHatchListItem* pItem = static_cast< const SvxHatchListItem* >(pSh->GetItem(SID_HATCH_LIST));
638 mpLbFillAttr->Enable();
639 mpLbFillAttr->Fill(pItem->GetHatchList());
640 bDone = true;
641 }
642 break;
643 }
644
645 case XFILL_BITMAP:
646 {
647 if(pSh->GetItem(SID_BITMAP_LIST))
648 {
649 const SvxBitmapListItem* pItem = static_cast< const SvxBitmapListItem* >(pSh->GetItem(SID_BITMAP_LIST));
650 mpLbFillAttr->Enable();
651 mpLbFillAttr->Fill(pItem->GetBitmapList());
652 bDone = true;
653 }
654 break;
655 }
656 default: // XFILL_NONE
657 {
658 // accept disable (no styles for XFILL_NONE)
659 break;
660 }
661 }
662 }
663
664 if(!bDone)
665 {
666 mpLbFillAttr->Disable();
667 }
550}
668}
551IMPL_LINK_INLINE_END( FillControl, DelayHdl, Timer *, pTimer )
552
669
553//------------------------------------------------------------------------
670void FillControl::updateLastFillTypeControlSelectEntryPos()
671{
672 mnLastFillTypeControlSelectEntryPos = mpLbFillType->GetSelectEntryPos();
673}
554
674
555IMPL_LINK( FillControl, SelectFillTypeHdl, ListBox *, pBox )
675IMPL_LINK(FillControl,SelectFillTypeHdl,ListBox *,pBox)
556{
676{
557 XFillStyle eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos();
677 if(!pBox) // only work with real calls from ListBox, do not accept direct calls with zeros here
678 {
679 return 0;
680 }
558
681
559 // Spaeter sollte eine Optimierung derart erfolgen, dass die
560 // Listen, bzw. Tables nur dann geloescht und wieder aufgebaut
561 // werden, wenn sich die Listen, bzw. Tables tatsaechlich geaendert
562 // haben (in den LBs natuerlich).
682 const bool bAction(
683 !mpLbFillType->IsTravelSelect() // keep TravelSelect, this means keyboard up/down in the list
684 && mpLbFillType->GetSelectEntryCount()
685 && mpLbFillType->GetSelectEntryPos() != mnLastFillTypeControlSelectEntryPos);
563
686
564 if ( ( pBox && !pBox->IsTravelSelect() ) || !pBox )
565 {
566 // Damit wir in folgendem Fall einen Status anzeigen koennen:
567 // Ein Typ wurde ausgewaehlt aber kein Attribut.
568 // Die Selektion hat genau die gleichen Attribute wie die vorherige.
569// SvxFillToolBoxControl* pControlerItem = (SvxFillToolBoxControl*)GetData();
570// if( pControlerItem )
571// pControlerItem->ClearCache();
687 updateLastFillTypeControlSelectEntryPos();
688 XFillStyle eXFS = static_cast< XFillStyle >(mpLbFillType->GetSelectEntryPos());
572
689
573 pLbFillAttr->Clear();
574 SfxObjectShell* pSh = SfxObjectShell::Current();
690 if(bAction && XFILL_NONE != eXFS)
691 {
692 mbFillTypeChanged = true;
693 }
575
694
576 switch( eXFS )
577 {
578 case XFILL_NONE:
579 {
580 pLbFillType->Selected();
581 SelectFillAttrHdl( pBox );
582 pLbFillAttr->Disable();
583 }
584 break;
695 // update list of FillStyles in any case
696 InitializeFillStyleAccordingToGivenFillType(eXFS);
585
697
586 case XFILL_SOLID:
587 {
588 if ( pSh && pSh->GetItem( SID_COLOR_TABLE ) )
589 {
590 SvxColorTableItem aItem( *(const SvxColorTableItem*)(
591 pSh->GetItem( SID_COLOR_TABLE ) ) );
592 pLbFillAttr->Enable();
593 pLbFillAttr->Fill( aItem.GetColorTable() );
594 }
595 else
596 pLbFillAttr->Disable();
597 }
598 break;
698 // for XFILL_NONE do no longer call SelectFillAttrHdl (as done before),
699 // trigger needed actions directly. This is the only action this handler
700 // can trigger directly as the user action is finished in this case
701 if(XFILL_NONE == eXFS && bAction)
702 {
703 // for XFILL_NONE do no longer call SelectFillAttrHdl,
704 // trigger needed actions directly
705 Any a;
706 Sequence< PropertyValue > aArgsFillStyle(1);
707 XFillStyleItem aXFillStyleItem(eXFS);
599
708
600 case XFILL_GRADIENT:
601 {
602 if ( pSh && pSh->GetItem( SID_GRADIENT_LIST ) )
603 {
604 SvxGradientListItem aItem( *(const SvxGradientListItem*)(
605 pSh->GetItem( SID_GRADIENT_LIST ) ) );
606 pLbFillAttr->Enable();
607 pLbFillAttr->Fill( aItem.GetGradientList() );
608 }
609 else
610 pLbFillAttr->Disable();
611 }
612 break;
709 aArgsFillStyle[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle"));
710 aXFillStyleItem.QueryValue(a);
711 aArgsFillStyle[0].Value = a;
712 ((SvxFillToolBoxControl*)GetData())->Dispatch(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FillStyle")), aArgsFillStyle);
713 }
613
714
614 case XFILL_HATCH:
615 {
616 if ( pSh && pSh->GetItem( SID_HATCH_LIST ) )
617 {
618 SvxHatchListItem aItem( *(const SvxHatchListItem*)(
619 pSh->GetItem( SID_HATCH_LIST ) ) );
620 pLbFillAttr->Enable();
621 pLbFillAttr->Fill( aItem.GetHatchList() );
622 }
623 else
624 pLbFillAttr->Disable();
625 }
626 break;
715 mpLbFillType->Selected();
627
716
628 case XFILL_BITMAP:
629 {
630 if ( pSh && pSh->GetItem( SID_BITMAP_LIST ) )
631 {
632 SvxBitmapListItem aItem( *(const SvxBitmapListItem*)(
633 pSh->GetItem( SID_BITMAP_LIST ) ) );
634 pLbFillAttr->Enable();
635 pLbFillAttr->Fill( aItem.GetBitmapList() );
636 }
637 else
638 pLbFillAttr->Disable();
639 }
640 break;
641 }
717 // release focus. Needed to get focus automatically back to EditView
718 if(mpLbFillType->IsRelease())
719 {
720 SfxViewShell* pViewShell = SfxViewShell::Current();
642
721
643 if( eXFS != XFILL_NONE ) // Wurde schon erledigt
644 {
645 if ( pBox )
646 pLbFillType->Selected();
647
648 // release focus
649 if ( pBox && pLbFillType->IsRelease() )
650 {
651 SfxViewShell* pViewShell = SfxViewShell::Current();
652 if( pViewShell && pViewShell->GetWindow() )
653 pViewShell->GetWindow()->GrabFocus();
654 }
655 }
722 if(pViewShell && pViewShell->GetWindow())
723 {
724 pViewShell->GetWindow()->GrabFocus();
725 }
656 }
726 }
657 return 0;
727
728 return 0;
658}
659
660//------------------------------------------------------------------------
661
729}
730
731//------------------------------------------------------------------------
732
662IMPL_LINK( FillControl, SelectFillAttrHdl, ListBox *, pBox )
733void FillControl::updateLastFillAttrControlSelectEntryPos()
663{
734{
664 XFillStyle eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos();
665 XFillStyleItem aXFillStyleItem( eXFS );
666 sal_Bool bAction = pBox && !pLbFillAttr->IsTravelSelect();
735 mnLastFillAttrControlSelectEntryPos = mpLbFillAttr->GetSelectEntryPos();
736}
667
737
668 SfxObjectShell* pSh = SfxObjectShell::Current();
669 if ( bAction )
738IMPL_LINK(FillControl, SelectFillAttrHdl, ListBox *, pBox)
739{
740 if(!pBox) // only work with real calls from ListBox, do not accept direct calls with zeros here
670 {
741 {
742 return 0;
743 }
744
745 const bool bAction(
746 !mpLbFillAttr->IsTravelSelect() // keep TravelSelect, this means keyboard up/down in the list
747 && mpLbFillAttr->GetSelectEntryCount()
748 && mpLbFillAttr->GetSelectEntryPos() != mnLastFillAttrControlSelectEntryPos);
749
750 updateLastFillAttrControlSelectEntryPos();
751
752 if(bAction)
753 {
754 SfxObjectShell* pSh = SfxObjectShell::Current();
755
756 // Need to prepare the PropertyValue for the FillStyle dispatch action early,
757 // else the call for FillType to Dispatch(".uno:FillStyle") will already destroy the current state
758 // of selection in mpLbFillAttr again by calls to StateChanged which *will* set to no
759 // selection again (e.g. when two objects, same fill style, but different fill attributes)
671 Any a;
760 Any a;
672 Sequence< PropertyValue > aArgs( 1 );
673
674 // First set the style
675 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ));
676 aXFillStyleItem.QueryValue( a );
677 aArgs[0].Value = a;
678 ((SvxFillToolBoxControl*)GetData())->Dispatch(
679 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillStyle" )), aArgs );
761 Sequence< PropertyValue > aArgsFillAttr(1);
762 ::rtl::OUString aFillAttrCommand;
763 XFillStyle eXFS(static_cast< XFillStyle >(mpLbFillType->GetSelectEntryPos()));
680
764
681 switch( eXFS )
765 switch(eXFS)
682 {
683 case XFILL_NONE:
684 {
766 {
767 case XFILL_NONE:
768 {
769 // handled in SelectFillTypeHdl, nothing to do here
770 break;
685 }
771 }
686 break;
687
688 case XFILL_SOLID:
689 {
772
773 case XFILL_SOLID:
774 {
690 // NEU
691 //Eintrag wird auf temporaere Farbe geprueft
775 //Eintrag wird auf temporaere Farbe geprueft
692 String aTmpStr = pLbFillAttr->GetSelectEntry();
693 if( aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
776 String aTmpStr = mpLbFillAttr->GetSelectEntry();
777
778 if(aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len() - 1) == TMP_STR_END)
694 {
779 {
695 aTmpStr.Erase( aTmpStr.Len()-1, 1 );
696 aTmpStr.Erase( 0, 1 );
780 aTmpStr.Erase(aTmpStr.Len() - 1,1);
781 aTmpStr.Erase(0,1);
697 }
698
782 }
783
699 XFillColorItem aXFillColorItem( aTmpStr, pLbFillAttr->GetSelectEntryColor() );
700
701 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ));
702 aXFillColorItem.QueryValue( a );
703 aArgs[0].Value = a;
704 ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillColor" )),
705 aArgs );
784 XFillColorItem aXFillColorItem(aTmpStr,mpLbFillAttr->GetSelectEntryColor());
785 aArgsFillAttr[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillColor"));
786 aXFillColorItem.QueryValue(a);
787 aArgsFillAttr[0].Value = a;
788 aFillAttrCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FillColor"));
789 break;
706 }
790 }
707 break;
708 case XFILL_GRADIENT:
709 {
791 case XFILL_GRADIENT:
792 {
710 sal_uInt16 nPos = pLbFillAttr->GetSelectEntryPos();
793 sal_uInt16 nPos = mpLbFillAttr->GetSelectEntryPos();
711
794
712 if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_GRADIENT_LIST ) )
795 if(nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem(SID_GRADIENT_LIST))
713 {
796 {
714 SvxGradientListItem aItem(
715 *(const SvxGradientListItem*)( pSh->GetItem( SID_GRADIENT_LIST ) ) );
797 const SvxGradientListItem* pItem = static_cast< const SvxGradientListItem* >(pSh->GetItem(SID_GRADIENT_LIST));
716
798
717 if ( nPos < aItem.GetGradientList()->Count() ) // kein temp. Eintrag ?
799 if(nPos < pItem->GetGradientList()->Count()) // kein temp. Eintrag ?
718 {
800 {
719 XGradient aGradient = aItem.GetGradientList()->GetGradient( nPos )->GetGradient();
720 XFillGradientItem aXFillGradientItem( pLbFillAttr->GetSelectEntry(), aGradient );
721
722 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" ));
723 aXFillGradientItem.QueryValue( a );
724 aArgs[0].Value = a;
725 ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillGradient" )),
726 aArgs );
801 XGradient aGradient = pItem->GetGradientList()->GetGradient(nPos)->GetGradient();
802 XFillGradientItem aXFillGradientItem(mpLbFillAttr->GetSelectEntry(),aGradient);
803 aArgsFillAttr[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillGradient"));
804 aXFillGradientItem.QueryValue(a);
805 aArgsFillAttr[0].Value = a;
806 aFillAttrCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FillGradient"));
727 }
728 }
807 }
808 }
809 break;
729 }
810 }
730 break;
731
732 case XFILL_HATCH:
733 {
811
812 case XFILL_HATCH:
813 {
734 sal_uInt16 nPos = pLbFillAttr->GetSelectEntryPos();
814 sal_uInt16 nPos = mpLbFillAttr->GetSelectEntryPos();
735
815
736 if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_HATCH_LIST ) )
816 if(nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem(SID_HATCH_LIST))
737 {
817 {
738 SvxHatchListItem aItem( *(const SvxHatchListItem*)( pSh->GetItem( SID_HATCH_LIST ) ) );
818 const SvxHatchListItem* pItem = static_cast< const SvxHatchListItem* >(pSh->GetItem(SID_HATCH_LIST));
739
819
740 if ( nPos < aItem.GetHatchList()->Count() ) // kein temp. Eintrag ?
820 if(nPos < pItem->GetHatchList()->Count()) // kein temp. Eintrag ?
741 {
821 {
742 XHatch aHatch = aItem.GetHatchList()->GetHatch( nPos )->GetHatch();
743 XFillHatchItem aXFillHatchItem( pLbFillAttr->GetSelectEntry(), aHatch );
822 XHatch aHatch = pItem->GetHatchList()->GetHatch(nPos)->GetHatch();
823 XFillHatchItem aXFillHatchItem(mpLbFillAttr->GetSelectEntry(),aHatch);
744
824
745 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillHatch" ));
746 aXFillHatchItem.QueryValue( a );
747 aArgs[0].Value = a;
748 ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillHatch" )),
749 aArgs );
825 aArgsFillAttr[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillHatch"));
826 aXFillHatchItem.QueryValue(a);
827 aArgsFillAttr[0].Value = a;
828 aFillAttrCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FillHatch"));
750 }
751 }
829 }
830 }
831 break;
752 }
832 }
753 break;
754
755 case XFILL_BITMAP:
756 {
833
834 case XFILL_BITMAP:
835 {
757 sal_uInt16 nPos = pLbFillAttr->GetSelectEntryPos();
836 sal_uInt16 nPos = mpLbFillAttr->GetSelectEntryPos();
758
837
759 if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_BITMAP_LIST ) )
838 if(nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem(SID_BITMAP_LIST))
760 {
839 {
761 SvxBitmapListItem aItem(
762 *(const SvxBitmapListItem*)( pSh->GetItem( SID_BITMAP_LIST ) ) );
840 const SvxBitmapListItem* pItem = static_cast< const SvxBitmapListItem* >(pSh->GetItem(SID_BITMAP_LIST));
763
841
764 if ( nPos < aItem.GetBitmapList()->Count() ) // kein temp. Eintrag ?
842 if(nPos < pItem->GetBitmapList()->Count()) // kein temp. Eintrag ?
765 {
843 {
766 const XBitmapEntry* pXBitmapEntry = aItem.GetBitmapList()->GetBitmap(nPos);
767 const XFillBitmapItem aXFillBitmapItem(pLbFillAttr->GetSelectEntry(), pXBitmapEntry->GetGraphicObject());
844 const XBitmapEntry* pXBitmapEntry = pItem->GetBitmapList()->GetBitmap(nPos);
845 const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectEntry(),pXBitmapEntry->GetGraphicObject());
768
846
769 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillBitmap" ));
770 aXFillBitmapItem.QueryValue( a );
771 aArgs[0].Value = a;
772 ((SvxFillToolBoxControl*)GetData())->Dispatch(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FillBitmap")), aArgs);
847 aArgsFillAttr[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillBitmap"));
848 aXFillBitmapItem.QueryValue(a);
849 aArgsFillAttr[0].Value = a;
850 aFillAttrCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FillBitmap"));
773 }
774 }
851 }
852 }
853 break;
775 }
854 }
776 break;
777 }
778
855 }
856
779 // release focus
780 if ( pLbFillAttr->IsRelease() && pBox )
781 {
782 SfxViewShell* pViewShell = SfxViewShell::Current();
783 if( pViewShell && pViewShell->GetWindow() )
784 {
785 pViewShell->GetWindow()->GrabFocus();
786 }
787 }
857 // this is the place where evtl. a new slot action may be introduced to avoid the
858 // two undo entries. Reason for this is that indeed two actions are executed, the fill style
859 // and the fill attribute change. The sidebar already handles both separately, so
860 // changing the fill style already changes the object and adds a default fill attribute for
861 // the newly choosen fill style.
862 // This control uses the older user's two-step action to select a fill style and a fill attribute. In
863 // this case a lot of things may go wrong (e.g. the user stops that action and does something
864 // different), thus the solution of the sidebar should be preferred from my POV in the future
865
866 // first set the fill style if changed
867 if(mbFillTypeChanged)
868 {
869 Sequence< PropertyValue > aArgsFillStyle(1);
870 XFillStyleItem aXFillStyleItem(eXFS);
871
872 aArgsFillStyle[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle"));
873 aXFillStyleItem.QueryValue(a);
874 aArgsFillStyle[0].Value = a;
875 ((SvxFillToolBoxControl*)GetData())->Dispatch(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FillStyle")), aArgsFillStyle);
876 mbFillTypeChanged = false;
877 }
878
879 // second set fill attribute when a change was detected and prepared
880 if(aFillAttrCommand.getLength())
881 {
882 ((SvxFillToolBoxControl*)GetData())->Dispatch(aFillAttrCommand, aArgsFillAttr);
883 }
884
885 // release focus. Needed to get focus automatically back to EditView
886 if(mpLbFillAttr->IsRelease() && pBox)
887 {
888 SfxViewShell* pViewShell = SfxViewShell::Current();
889
890 if(pViewShell && pViewShell->GetWindow())
891 {
892 pViewShell->GetWindow()->GrabFocus();
893 }
894 }
788 }
789
790 return 0;
791}
792
793//------------------------------------------------------------------------
794
795void FillControl::Resize()
796{
895 }
896
897 return 0;
898}
899
900//------------------------------------------------------------------------
901
902void FillControl::Resize()
903{
797 // Breite der beiden ListBoxen nicht 1/2 : 1/2, sondern 2/5 : 3/5
798 long nW = GetOutputSizePixel().Width() / 5;
799 long nH = 180;
800 long nSep = 0; // war vorher 4
904 // Breite der beiden ListBoxen nicht 1/2 : 1/2, sondern 2/5 : 3/5
905 long nW = GetOutputSizePixel().Width() / 5;
906 long nH = 180;
907 long nSep = 0; // war vorher 4
801
908
802 pLbFillType->SetSizePixel( Size( nW * 2 - nSep, nH ) );
803 pLbFillAttr->SetPosSizePixel( Point( nW * 2 + nSep, 0 ), Size( nW * 3 - nSep, nH ) );
909 mpLbFillType->SetSizePixel(Size(nW * 2 - nSep,nH));
910 mpLbFillAttr->SetPosSizePixel(Point(nW * 2 + nSep,0),Size(nW * 3 - nSep,nH));
804}
911}
805/* -----------------------------08.03.2002 15:04------------------------------
806
912
807 ---------------------------------------------------------------------------*/
913//------------------------------------------------------------------------
808
914
809void FillControl::DataChanged( const DataChangedEvent& rDCEvt )
915void FillControl::DataChanged(const DataChangedEvent& rDCEvt)
810{
916{
811 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
812 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
917 if((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
918 (rDCEvt.GetFlags() & SETTINGS_STYLE))
813 {
919 {
814 Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT));
815 Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT));
816 pLbFillType->SetSizePixel(aTypeSize);
817 pLbFillAttr->SetSizePixel(aAttrSize);
920 Size aTypeSize(LogicToPixel(maLogicalFillSize,MAP_APPFONT));
921 Size aAttrSize(LogicToPixel(maLogicalAttrSize,MAP_APPFONT));
922 mpLbFillType->SetSizePixel(aTypeSize);
923 mpLbFillAttr->SetSizePixel(aAttrSize);
924
818 //to get the base height
925 //to get the base height
819 aTypeSize = pLbFillType->GetSizePixel();
820 aAttrSize = pLbFillAttr->GetSizePixel();
821 Point aAttrPnt = pLbFillAttr->GetPosPixel();
926 aTypeSize = mpLbFillType->GetSizePixel();
927 aAttrSize = mpLbFillAttr->GetSizePixel();
928 Point aAttrPnt = mpLbFillAttr->GetPosPixel();
822
823 SetSizePixel(
929
930 SetSizePixel(
824 Size( aAttrPnt.X() + aAttrSize.Width(),
825 Max( aAttrSize.Height(), aTypeSize.Height() ) ) );
931 Size(aAttrPnt.X() + aAttrSize.Width(),
932 Max(aAttrSize.Height(),aTypeSize.Height())));
826 }
933 }
827 Window::DataChanged( rDCEvt );
934 Window::DataChanged(rDCEvt);
828}
829
935}
936
937//------------------------------------------------------------------------
938//eof