1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #include "svx/sidebar/PopupContainer.hxx"
25 #include "AreaTransparencyGradientControl.hxx"
26
27 #include <sfx2/sidebar/ResourceDefinitions.hrc>
28 #include <sfx2/sidebar/Theme.hxx>
29 #include <sfx2/sidebar/ControlFactory.hxx>
30 #include <sfx2/sidebar/Layouter.hxx>
31 #include <AreaPropertyPanel.hxx>
32 #include <AreaPropertyPanel.hrc>
33 #include <svx/dialogs.hrc>
34 #include <svx/dialmgr.hxx>
35 #include <sfx2/objsh.hxx>
36 #include <svx/xfltrit.hxx>
37 #include <svx/xflftrit.hxx>
38 #include <svx/xtable.hxx>
39 #include <sfx2/dispatch.hxx>
40 #include <sfx2/bindings.hxx>
41 #include <helpid.hrc>
42 #include <svtools/valueset.hxx>
43 #include <unotools/pathoptions.hxx>
44 #include <svx/svxitems.hrc>
45 #include <vcl/toolbox.hxx>
46 #include <svtools/toolbarmenu.hxx>
47 #include <svx/sidebar/ColorControl.hxx>
48
49 #include <boost/bind.hpp>
50
51 using namespace css;
52 using namespace cssu;
53 using ::sfx2::sidebar::Layouter;
54 using ::sfx2::sidebar::Theme;
55
56 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
57
58
59
60
61 namespace svx { namespace sidebar {
62
63 const sal_Int32 AreaPropertyPanel::DEFAULT_CENTERX = 50;
64 const sal_Int32 AreaPropertyPanel::DEFAULT_CENTERY = 50;
65 const sal_Int32 AreaPropertyPanel::DEFAULT_ANGLE = 0;
66 const sal_Int32 AreaPropertyPanel::DEFAULT_STARTVALUE = 0;
67 const sal_Int32 AreaPropertyPanel::DEFAULT_ENDVALUE = 16777215;
68 const sal_Int32 AreaPropertyPanel::DEFAULT_BORDER = 0;
69
70
AreaPropertyPanel(Window * pParent,const cssu::Reference<css::frame::XFrame> & rxFrame,SfxBindings * pBindings)71 AreaPropertyPanel::AreaPropertyPanel(
72 Window* pParent,
73 const cssu::Reference<css::frame::XFrame>& rxFrame,
74 SfxBindings* pBindings)
75 : Control(pParent, SVX_RES(RID_SIDEBAR_AREA_PANEL)),
76 meLastXFS(-1),
77 maLastColor(Color(COL_DEFAULT_SHAPE_FILLING)),
78 mnLastPosGradient(0),
79 mnLastPosHatch(0),
80 mnLastPosBitmap(0),
81 mnLastTransSolid(50),
82 maGradientLinear(),
83 maGradientAxial(),
84 maGradientRadial(),
85 maGradientElliptical(),
86 maGradientSquare(),
87 maGradientRect(),
88 mpColorTextFT(new FixedText(this, SVX_RES(FT_COLOR_LIST))),
89 mpLbFillType(new SvxFillTypeBox(this)),
90 mpLbFillAttr(new SvxFillAttrBox(this)),
91 mpToolBoxColorBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)),
92 mpToolBoxColor(sfx2::sidebar::ControlFactory::CreateToolBox(mpToolBoxColorBackground.get(), SVX_RES(TB_COLOR))),
93 mpTrspTextFT(new FixedText(this, SVX_RES(FL_TRSP_TEXT))),
94 mpLBTransType(new ListBox(this, SVX_RES(LB_TRGR_TYPES))),
95 mpMTRTransparent(new MetricField(this, SVX_RES(MTR_TRANSPARENT))),
96 mpBTNGradientBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)),
97 mpBTNGradient(sfx2::sidebar::ControlFactory::CreateToolBox(mpBTNGradientBackground.get(), SVX_RES(BTN_GRADIENT))),
98 mpColorUpdater(new ::svx::ToolboxButtonColorUpdater(SID_ATTR_FILL_COLOR, TBI_COLOR, mpToolBoxColor.get(), TBX_UPDATER_MODE_CHAR_COLOR_NEW)),
99 mpStyleItem(),
100 mpColorItem(),
101 mpFillGradientItem(),
102 mpHatchItem(),
103 mpBitmapItem(),
104 maStyleControl(SID_ATTR_FILL_STYLE, *pBindings, *this),
105 maColorControl(SID_ATTR_FILL_COLOR, *pBindings, *this),
106 maGradientControl(SID_ATTR_FILL_GRADIENT, *pBindings, *this),
107 maHatchControl(SID_ATTR_FILL_HATCH, *pBindings, *this),
108 maBitmapControl(SID_ATTR_FILL_BITMAP, *pBindings, *this),
109 maColorTableControl(SID_COLOR_TABLE, *pBindings, *this),
110 maGradientListControl(SID_GRADIENT_LIST, *pBindings, *this),
111 maHatchListControl(SID_HATCH_LIST, *pBindings, *this),
112 maBitmapListControl(SID_BITMAP_LIST, *pBindings, *this),
113 maFillTransparenceController(SID_ATTR_FILL_TRANSPARENCE, *pBindings, *this),
114 maFillFloatTransparenceController(SID_ATTR_FILL_FLOATTRANSPARENCE, *pBindings, *this),
115 maImgAxial(SVX_RES(IMG_AXIAL)),
116 maImgElli(SVX_RES(IMG_ELLI)),
117 maImgQuad(SVX_RES(IMG_QUAD)),
118 maImgRadial(SVX_RES(IMG_RADIAL)),
119 maImgSquare(SVX_RES(IMG_SQUARE)),
120 maImgLinear(SVX_RES(IMG_LINEAR)),
121 maImgColor(SVX_RES(IMG_COLOR)),
122 maImgAxialH(SVX_RES(IMG_AXIAL_H)),
123 maImgElliH(SVX_RES(IMG_ELLI_H)),
124 maImgQuadH(SVX_RES(IMG_QUAD_H)),
125 maImgRadialH(SVX_RES(IMG_RADIAL_H)),
126 maImgSquareH(SVX_RES(IMG_SQUARE_H)),
127 maImgLinearH(SVX_RES(IMG_LINEAR_H)),
128 maImgColorH(SVX_RES(IMG_COLOR_H)),
129 msHelpFillType(SVX_RES(STR_HELP_TYPE)),
130 msHelpFillAttr(SVX_RES(STR_HELP_ATTR)),
131 maTrGrPopup(this, ::boost::bind(&AreaPropertyPanel::CreateTransparencyGradientControl, this, _1)),
132 maColorPopup(this, ::boost::bind(&AreaPropertyPanel::CreateColorPopupControl, this, _1)),
133 mpFloatTransparenceItem(),
134 mpTransparanceItem(),
135 mxFrame(rxFrame),
136 mpBindings(pBindings),
137 mbColorAvail(true),
138 maLayouter(*this)
139 {
140 Initialize();
141 FreeResource();
142
143 // Setup the grid layouter.
144 const sal_Int32 nMappedMboxWidth (Layouter::MapWidth(*this, MBOX_WIDTH));
145
146 maLayouter.GetCell(0,0).SetControl(*mpColorTextFT).SetGridWidth(3);
147 maLayouter.GetCell(1,0).SetControl(*mpLbFillType);
148 maLayouter.GetCell(1,2,0).SetControl(*mpToolBoxColorBackground).SetFixedWidth();
149 maLayouter.GetCell(1,2,1).SetControl(*mpLbFillAttr);
150
151 maLayouter.GetCell(2,0).SetControl(*mpTrspTextFT).SetGridWidth(3);
152 maLayouter.GetCell(3,0).SetControl(*mpLBTransType);
153 maLayouter.GetCell(3,2,0).SetControl(*mpMTRTransparent);
154 maLayouter.GetCell(3,2,1).SetControl(*mpBTNGradient);
155
156 maLayouter.GetColumn(0)
157 .SetWeight(1)
158 .SetLeftPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL))
159 .SetMinimumWidth(nMappedMboxWidth);
160 maLayouter.GetColumn(1)
161 .SetWeight(0)
162 .SetMinimumWidth(Layouter::MapWidth(*this, CONTROL_SPACING_HORIZONTAL));
163 maLayouter.GetColumn(2)
164 .SetWeight(1)
165 .SetMinimumWidth(nMappedMboxWidth)
166 .SetRightPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL));
167
168 // Make controls that display text handle short widths more
169 // graceful.
170 Layouter::PrepareForLayouting(*mpColorTextFT);
171 Layouter::PrepareForLayouting(*mpTrspTextFT);
172 }
173
174
175
~AreaPropertyPanel()176 AreaPropertyPanel::~AreaPropertyPanel()
177 {
178 // Destroy the toolboxes, then their background windows.
179 mpToolBoxColor.reset();
180 mpBTNGradient.reset();
181 mpToolBoxColorBackground.reset();
182 mpBTNGradientBackground.reset();
183 }
184
185
186
Initialize()187 void AreaPropertyPanel::Initialize()
188 {
189 mpColorTextFT->SetBackground(Wallpaper());
190 mpTrspTextFT->SetBackground(Wallpaper());
191
192 maGradientLinear.SetXOffset(DEFAULT_CENTERX);
193 maGradientLinear.SetYOffset(DEFAULT_CENTERY);
194 maGradientLinear.SetAngle(DEFAULT_ANGLE);
195 maGradientLinear.SetStartColor(Color(DEFAULT_STARTVALUE));
196 maGradientLinear.SetEndColor(Color(DEFAULT_ENDVALUE));
197 maGradientLinear.SetBorder(DEFAULT_BORDER);
198 maGradientLinear.SetGradientStyle(XGRAD_LINEAR);
199
200 maGradientAxial = maGradientLinear;
201 maGradientAxial.SetGradientStyle(XGRAD_AXIAL);
202
203 maGradientRadial = maGradientLinear;
204 maGradientRadial.SetGradientStyle(XGRAD_RADIAL);
205
206 maGradientElliptical = maGradientLinear;
207 maGradientElliptical.SetGradientStyle(XGRAD_ELLIPTICAL);
208
209 maGradientSquare = maGradientLinear;
210 maGradientSquare.SetGradientStyle(XGRAD_SQUARE);
211
212 maGradientRect = maGradientLinear;
213 maGradientRect.SetGradientStyle(XGRAD_RECT);
214
215 Size aLogicalFillSize(MBOX_WIDTH,LISTBOX_HEIGHT);
216 Size aLogicalAttrSize(MBOX_WIDTH + 1,LISTBOX_HEIGHT);
217
218 Point aPoint(SECTIONPAGE_MARGIN_HORIZONTAL,SECTIONPAGE_MARGIN_VERTICAL_TOP + FIXED_TEXT_HEIGHT + TEXT_CONTROL_SPACING_VERTICAL);
219 Point aPoint_Picker(SECTIONPAGE_MARGIN_HORIZONTAL + MBOX_WIDTH + CONTROL_SPACING_HORIZONTAL,SECTIONPAGE_MARGIN_VERTICAL_TOP + FIXED_TEXT_HEIGHT + TEXT_CONTROL_SPACING_VERTICAL);
220
221 Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT));
222 Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT));
223
224 Point aTypePoint(LogicToPixel(aPoint, MAP_APPFONT));
225 Point aAttrPoint(LogicToPixel(aPoint_Picker, MAP_APPFONT));
226
227 mpLbFillType->SetPosSizePixel(aTypePoint,aTypeSize);
228 mpLbFillAttr->SetPosSizePixel(aAttrPoint,aAttrSize);
229
230 mpLbFillType->SetHelpId(HID_PPROPERTYPANEL_AREA_LB_FILL_TYPES);
231 mpLbFillAttr->SetHelpId(HID_PPROPERTYPANEL_AREA_LB_FILL_ATTR);
232
233 mpLbFillType->SetQuickHelpText(msHelpFillType);
234 mpLbFillAttr->SetQuickHelpText(msHelpFillAttr);
235
236 mpLbFillType->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Fill"))); // wj acc
237 mpLbFillAttr->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Fill"))); // wj acc
238
239 Link aLink = LINK( this, AreaPropertyPanel, SelectFillTypeHdl );
240 mpLbFillType->SetSelectHdl( aLink );
241
242 aLink = LINK( this, AreaPropertyPanel, SelectFillAttrHdl );
243 mpLbFillAttr->SetSelectHdl( aLink );
244
245 // add for new color picker
246 mpLbFillAttr->Hide();
247 mpToolBoxColor->SetItemImage(TBI_COLOR, GetDisplayBackground().GetColor().IsDark()? maImgColorH : maImgColor);
248 Size aTbxSize( mpToolBoxColor->CalcWindowSizePixel() );
249 mpToolBoxColor->SetOutputSizePixel( aTbxSize );
250 mpToolBoxColor->SetItemBits( TBI_COLOR, mpToolBoxColor->GetItemBits( TBI_COLOR ) | TIB_DROPDOWNONLY );
251 mpToolBoxColor->SetBackground(Wallpaper());
252 mpToolBoxColor->SetPaintTransparent(true);
253 mpToolBoxColor->SetQuickHelpText(TBI_COLOR, String(SVX_RES(STR_HELP_COLOR))); // wj acc
254 //mpToolBoxColor->SetItemText(TBI_COLOR, msHelpFillAttr);
255
256 long aHeightLBStyle = mpLbFillType->GetSizePixel().getHeight();
257 long aLBPosY = mpLbFillType->GetPosPixel().getY();
258 long aHeightTBAttr = mpToolBoxColor->GetSizePixel().getHeight();
259 Point aPointTBAttr = mpToolBoxColor->GetPosPixel();
260 aPointTBAttr.setY( aLBPosY + aHeightLBStyle / 2 - aHeightTBAttr / 2);
261 mpToolBoxColor->SetPosPixel(aPointTBAttr);
262
263 aLink = LINK(this, AreaPropertyPanel, ToolBoxColorDropHdl);
264 mpToolBoxColor->SetDropdownClickHdl ( aLink );
265 mpToolBoxColor->SetSelectHdl ( aLink );
266
267 // add end
268 mpLBTransType->SetSelectHdl(LINK(this, AreaPropertyPanel, ChangeTrgrTypeHdl_Impl));
269 mpLBTransType->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Transparency"))); // wj acc
270
271 mpMTRTransparent->SetValue( 50 );
272 mpMTRTransparent->SetModifyHdl(LINK(this, AreaPropertyPanel, ModifyTransparentHdl_Impl));
273 mpMTRTransparent->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Transparency"))); // wj acc
274
275 mpBTNGradient->SetItemBits( TBI_BTX_GRADIENT, mpBTNGradient->GetItemBits( TBI_BTX_GRADIENT ) | TIB_DROPDOWNONLY );
276 aLink = LINK( this, AreaPropertyPanel, ClickTrGrHdl_Impl );
277 mpBTNGradient->SetDropdownClickHdl( aLink );
278 mpBTNGradient->SetSelectHdl( aLink );
279 aTbxSize = mpBTNGradient->CalcWindowSizePixel();
280 mpBTNGradient->SetOutputSizePixel( aTbxSize );
281 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,maImgLinear);
282 mpBTNGradient->SetQuickHelpText(TBI_BTX_GRADIENT, String(SVX_RES(STR_HELP_GRADIENT))); // wj acc
283 mpBTNGradient->Hide();
284
285 long aHeightLBTrans = mpLBTransType->GetSizePixel().getHeight();
286 Point aPointLB = mpLBTransType->GetPosPixel();
287 long aPosY = aPointLB.getY();
288
289 Point aPointMetric = mpMTRTransparent->GetPosPixel();
290 Point aPointTB = mpMTRTransparent->GetPosPixel();
291 long aHeightMetric = mpMTRTransparent->GetSizePixel().getHeight();
292 long aHeightTool = mpBTNGradient->GetSizePixel().getHeight();
293 aPointMetric.setY(aPosY+aHeightLBTrans/2-aHeightMetric/2);
294 aPointTB.setY(aPosY+aHeightLBTrans/2-aHeightTool/2);
295 aPointTB.setX(aPointTB.getX()+3);
296 mpMTRTransparent->SetPosPixel(aPointMetric);
297 mpBTNGradient->SetPosPixel(aPointTB);
298
299 mpLbFillType->SetAccessibleRelationLabeledBy(mpColorTextFT.get());
300 mpLbFillAttr->SetAccessibleRelationLabeledBy(mpLbFillAttr.get());
301 mpToolBoxColor->SetAccessibleRelationLabeledBy(mpToolBoxColor.get());
302 mpLBTransType->SetAccessibleRelationLabeledBy(mpTrspTextFT.get());
303 mpMTRTransparent->SetAccessibleRelationLabeledBy(mpMTRTransparent.get());
304 mpBTNGradient->SetAccessibleRelationLabeledBy(mpBTNGradient.get());
305
306 SetupIcons();
307 }
308
309
310
IMPL_LINK(AreaPropertyPanel,SelectFillTypeHdl,ListBox *,pToolBox)311 IMPL_LINK( AreaPropertyPanel, SelectFillTypeHdl, ListBox *, pToolBox )
312 {
313 const XFillStyle eXFS = (XFillStyle)mpLbFillType->GetSelectEntryPos();
314
315 if((XFillStyle)meLastXFS != eXFS)
316 {
317 mpLbFillAttr->Clear();
318 SfxObjectShell* pSh = SfxObjectShell::Current();
319 const XFillStyleItem aXFillStyleItem(eXFS);
320
321 // #122676# Do no longer trigger two Execute calls, one for SID_ATTR_FILL_STYLE
322 // and one for setting the fill attribute itself, but add two SfxPoolItems to the
323 // call to get just one action at the SdrObject and to create only one Undo action, too.
324 // Checked that this works in all apps.
325 switch( eXFS )
326 {
327 case XFILL_NONE:
328 {
329 mpLbFillAttr->Show();
330 mpToolBoxColor->Hide();
331 mpLbFillType->Selected();
332 mpLbFillAttr->Disable();
333
334 // #122676# need to call a single SID_ATTR_FILL_STYLE change
335 GetBindings()->GetDispatcher()->Execute(
336 SID_ATTR_FILL_STYLE, SFX_CALLMODE_RECORD, &aXFillStyleItem, 0L);
337 break;
338 }
339 case XFILL_SOLID:
340 {
341 mpLbFillAttr->Hide();
342 mpToolBoxColor->Show();
343 const String aTmpStr;
344 const Color aColor = maLastColor;
345 const XFillColorItem aXFillColorItem( aTmpStr, aColor );
346
347 // #122676# change FillStyle and Color in one call
348 GetBindings()->GetDispatcher()->Execute(
349 SID_ATTR_FILL_COLOR, SFX_CALLMODE_RECORD, &aXFillColorItem, &aXFillStyleItem, 0L);
350 break;
351 }
352 case XFILL_GRADIENT:
353 {
354 mpLbFillAttr->Show();
355 mpToolBoxColor->Hide();
356
357 if(pSh && pSh->GetItem(SID_GRADIENT_LIST))
358 {
359 if(!mpLbFillAttr->GetEntryCount())
360 {
361 const SvxGradientListItem aItem(*(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST)));
362 mpLbFillAttr->Enable();
363 mpLbFillAttr->Clear();
364 mpLbFillAttr->Fill(aItem.GetGradientList());
365 }
366
367 mpLbFillAttr->AdaptDropDownLineCountToMaximum();
368
369 if(LISTBOX_ENTRY_NOTFOUND != mnLastPosGradient)
370 {
371 const SvxGradientListItem aItem(*(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST)));
372
373 if(mnLastPosGradient < aItem.GetGradientList()->Count())
374 {
375 const XGradient aGradient = aItem.GetGradientList()->GetGradient(mnLastPosGradient)->GetGradient();
376 const XFillGradientItem aXFillGradientItem(mpLbFillAttr->GetEntry(mnLastPosGradient), aGradient);
377
378 // #122676# change FillStyle and Gradient in one call
379 GetBindings()->GetDispatcher()->Execute(
380 SID_ATTR_FILL_GRADIENT, SFX_CALLMODE_RECORD, &aXFillGradientItem, &aXFillStyleItem, 0L);
381 mpLbFillAttr->SelectEntryPos(mnLastPosGradient);
382 }
383 }
384 }
385 else
386 {
387 mpLbFillAttr->Disable();
388 }
389 break;
390 }
391 case XFILL_HATCH:
392 {
393 mpLbFillAttr->Show();
394 mpToolBoxColor->Hide();
395
396 if(pSh && pSh->GetItem(SID_HATCH_LIST))
397 {
398 if(!mpLbFillAttr->GetEntryCount())
399 {
400 const SvxHatchListItem aItem( *(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST)));
401 mpLbFillAttr->Enable();
402 mpLbFillAttr->Clear();
403 mpLbFillAttr->Fill(aItem.GetHatchList());
404 }
405
406 mpLbFillAttr->AdaptDropDownLineCountToMaximum();
407
408 if(LISTBOX_ENTRY_NOTFOUND != mnLastPosHatch)
409 {
410 const SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST)));
411
412 if(mnLastPosHatch < aItem.GetHatchList()->Count())
413 {
414 const XHatch aHatch = aItem.GetHatchList()->GetHatch(mnLastPosHatch)->GetHatch();
415 const XFillHatchItem aXFillHatchItem(mpLbFillAttr->GetSelectEntry(), aHatch);
416
417 // #122676# change FillStyle and Hatch in one call
418 GetBindings()->GetDispatcher()->Execute(
419 SID_ATTR_FILL_HATCH, SFX_CALLMODE_RECORD, &aXFillHatchItem, &aXFillStyleItem, 0L);
420 mpLbFillAttr->SelectEntryPos(mnLastPosHatch);
421 }
422 }
423 }
424 else
425 {
426 mpLbFillAttr->Disable();
427 }
428 break;
429 }
430 case XFILL_BITMAP:
431 {
432 mpLbFillAttr->Show();
433 mpToolBoxColor->Hide();
434
435 if(pSh && pSh->GetItem(SID_BITMAP_LIST))
436 {
437 if(!mpLbFillAttr->GetEntryCount())
438 {
439 const SvxBitmapListItem aItem( *(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST)));
440 mpLbFillAttr->Enable();
441 mpLbFillAttr->Clear();
442 mpLbFillAttr->Fill(aItem.GetBitmapList());
443 }
444
445 mpLbFillAttr->AdaptDropDownLineCountToMaximum();
446
447 if(LISTBOX_ENTRY_NOTFOUND != mnLastPosBitmap)
448 {
449 const SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST)));
450
451 if(mnLastPosBitmap < aItem.GetBitmapList()->Count())
452 {
453 const XBitmapEntry* pXBitmapEntry = aItem.GetBitmapList()->GetBitmap(mnLastPosBitmap);
454 const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectEntry(), pXBitmapEntry->GetGraphicObject());
455
456 // #122676# change FillStyle and Bitmap in one call
457 GetBindings()->GetDispatcher()->Execute(
458 SID_ATTR_FILL_BITMAP, SFX_CALLMODE_RECORD, &aXFillBitmapItem, &aXFillStyleItem, 0L);
459 mpLbFillAttr->SelectEntryPos(mnLastPosBitmap);
460 }
461 }
462 }
463 else
464 {
465 mpLbFillAttr->Disable();
466 }
467 break;
468 }
469 }
470
471 meLastXFS = (sal_uInt16)eXFS;
472
473 if(XFILL_NONE != eXFS)
474 {
475 if(pToolBox)
476 {
477 mpLbFillType->Selected();
478 }
479 }
480
481 maLayouter.Layout();
482 }
483
484 return 0;
485 }
486
487
488
IMPL_LINK(AreaPropertyPanel,SelectFillAttrHdl,ListBox *,pToolBox)489 IMPL_LINK( AreaPropertyPanel, SelectFillAttrHdl, ListBox*, pToolBox )
490 {
491 const XFillStyle eXFS = (XFillStyle)mpLbFillType->GetSelectEntryPos();
492 const XFillStyleItem aXFillStyleItem(eXFS);
493 SfxObjectShell* pSh = SfxObjectShell::Current();
494
495 if(pToolBox)
496 {
497 // #122676# dependent from bFillStyleChange, do execute a single or two
498 // changes in one Execute call
499 const bool bFillStyleChange((XFillStyle) meLastXFS != eXFS);
500
501 switch(eXFS)
502 {
503 case XFILL_SOLID:
504 {
505 if(bFillStyleChange)
506 {
507 // #122676# Single FillStyle change call needed here
508 GetBindings()->GetDispatcher()->Execute(SID_ATTR_FILL_STYLE, SFX_CALLMODE_RECORD, &aXFillStyleItem, 0L);
509 }
510 break;
511 }
512 case XFILL_GRADIENT:
513 {
514 sal_uInt16 nPos = mpLbFillAttr->GetSelectEntryPos();
515
516 if(LISTBOX_ENTRY_NOTFOUND == nPos)
517 {
518 nPos = mnLastPosGradient;
519 }
520
521 if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_GRADIENT_LIST))
522 {
523 const SvxGradientListItem aItem(*(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST)));
524
525 if(nPos < aItem.GetGradientList()->Count())
526 {
527 const XGradient aGradient = aItem.GetGradientList()->GetGradient(nPos)->GetGradient();
528 const XFillGradientItem aXFillGradientItem(mpLbFillAttr->GetSelectEntry(), aGradient);
529
530 // #122676# Change FillStyle and Gradient in one call
531 GetBindings()->GetDispatcher()->Execute(
532 SID_ATTR_FILL_GRADIENT, SFX_CALLMODE_RECORD, &aXFillGradientItem,
533 bFillStyleChange ? &aXFillStyleItem : 0L, 0L);
534 }
535 }
536
537 if(LISTBOX_ENTRY_NOTFOUND != nPos)
538 {
539 mnLastPosGradient = nPos;
540 }
541 break;
542 }
543 case XFILL_HATCH:
544 {
545 sal_uInt16 nPos = mpLbFillAttr->GetSelectEntryPos();
546
547 if(LISTBOX_ENTRY_NOTFOUND == nPos)
548 {
549 nPos = mnLastPosHatch;
550 }
551
552 if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_HATCH_LIST))
553 {
554 const SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST)));
555
556 if(nPos < aItem.GetHatchList()->Count())
557 {
558 const XHatch aHatch = aItem.GetHatchList()->GetHatch(nPos)->GetHatch();
559 const XFillHatchItem aXFillHatchItem( mpLbFillAttr->GetSelectEntry(), aHatch);
560
561 // #122676# Change FillStyle and Hatch in one call
562 GetBindings()->GetDispatcher()->Execute(
563 SID_ATTR_FILL_HATCH, SFX_CALLMODE_RECORD, &aXFillHatchItem,
564 bFillStyleChange ? &aXFillStyleItem : 0L, 0L);
565 }
566 }
567
568 if(LISTBOX_ENTRY_NOTFOUND != nPos)
569 {
570 mnLastPosHatch = nPos;
571 }
572 break;
573 }
574 case XFILL_BITMAP:
575 {
576 sal_uInt16 nPos = mpLbFillAttr->GetSelectEntryPos();
577
578 if(LISTBOX_ENTRY_NOTFOUND == nPos)
579 {
580 nPos = mnLastPosBitmap;
581 }
582
583 if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_BITMAP_LIST))
584 {
585 const SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST)));
586
587 if(nPos < aItem.GetBitmapList()->Count())
588 {
589 const XBitmapEntry* pXBitmapEntry = aItem.GetBitmapList()->GetBitmap(nPos);
590 const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectEntry(), pXBitmapEntry->GetGraphicObject());
591
592 // #122676# Change FillStyle and Bitmap in one call
593 GetBindings()->GetDispatcher()->Execute(
594 SID_ATTR_FILL_BITMAP, SFX_CALLMODE_RECORD, &aXFillBitmapItem,
595 bFillStyleChange ? &aXFillStyleItem : 0L, 0L);
596 }
597 }
598
599 if(LISTBOX_ENTRY_NOTFOUND != nPos)
600 {
601 mnLastPosBitmap = nPos;
602 }
603 break;
604 }
605 default: break;
606 }
607 }
608
609 return 0;
610 }
611
612
IMPL_LINK(AreaPropertyPanel,ToolBoxColorDropHdl,ToolBox *,pToolBox)613 IMPL_LINK(AreaPropertyPanel, ToolBoxColorDropHdl, ToolBox*, pToolBox)
614 {
615 const sal_uInt16 nId = pToolBox->GetCurItemId();
616
617 if(TBI_COLOR == nId)
618 {
619 maColorPopup.Show(*pToolBox);
620
621 if (mpColorItem)
622 {
623 maColorPopup.SetCurrentColor(mpColorItem->GetColorValue(), mbColorAvail);
624 }
625 else
626 {
627 maColorPopup.SetCurrentColor(COL_WHITE, false);
628 }
629 }
630
631 return 0;
632 }
633
634
635
SetColor(const String & rsColorName,const Color aColor)636 void AreaPropertyPanel::SetColor (
637 const String& rsColorName,
638 const Color aColor)
639 {
640 const XFillColorItem aXFillColorItem(rsColorName, aColor);
641 mpBindings->GetDispatcher()->Execute(SID_ATTR_FILL_COLOR, SFX_CALLMODE_RECORD, &aXFillColorItem, 0L);
642 maLastColor = aColor;
643 }
644
645
646
647
CreateTransparencyGradientControl(PopupContainer * pParent)648 PopupControl* AreaPropertyPanel::CreateTransparencyGradientControl (PopupContainer* pParent)
649 {
650 return new AreaTransparencyGradientControl(pParent, *this);
651 }
652
653
654
655
CreateColorPopupControl(PopupContainer * pParent)656 PopupControl* AreaPropertyPanel::CreateColorPopupControl (PopupContainer* pParent)
657 {
658 return new ColorControl(
659 pParent,
660 mpBindings,
661 SVX_RES(RID_POPUPPANEL_AERAPAGE_COLOR),
662 SVX_RES(VS_COLOR),
663 ::boost::bind(&AreaPropertyPanel::GetLastColor, this),
664 ::boost::bind(&AreaPropertyPanel::SetColor, this, _1,_2),
665 pParent,
666 0);
667 }
668
669
670
671
SetupIcons(void)672 void AreaPropertyPanel::SetupIcons(void)
673 {
674 if(Theme::GetBoolean(Theme::Bool_UseSymphonyIcons))
675 {
676 // todo
677 }
678 else
679 {
680 // todo
681 }
682 }
683
684
685
Create(Window * pParent,const cssu::Reference<css::frame::XFrame> & rxFrame,SfxBindings * pBindings)686 AreaPropertyPanel* AreaPropertyPanel::Create (
687 Window* pParent,
688 const cssu::Reference<css::frame::XFrame>& rxFrame,
689 SfxBindings* pBindings)
690 {
691 if (pParent == NULL)
692 throw lang::IllegalArgumentException(A2S("no parent Window given to AreaPropertyPanel::Create"), NULL, 0);
693 if ( ! rxFrame.is())
694 throw lang::IllegalArgumentException(A2S("no XFrame given to AreaPropertyPanel::Create"), NULL, 1);
695 if (pBindings == NULL)
696 throw lang::IllegalArgumentException(A2S("no SfxBindings given to AreaPropertyPanel::Create"), NULL, 2);
697
698 return new AreaPropertyPanel(
699 pParent,
700 rxFrame,
701 pBindings);
702 }
703
704
705
DataChanged(const DataChangedEvent & rEvent)706 void AreaPropertyPanel::DataChanged(
707 const DataChangedEvent& rEvent)
708 {
709 (void)rEvent;
710
711 SetupIcons();
712 }
713
714
715
ImpUpdateTransparencies()716 void AreaPropertyPanel::ImpUpdateTransparencies()
717 {
718 if(mpTransparanceItem.get() && mpFloatTransparenceItem.get())
719 {
720 bool bZeroValue(false);
721
722 if(mpTransparanceItem.get())
723 {
724 const sal_uInt16 nValue(mpTransparanceItem->GetValue());
725
726 if(!nValue)
727 {
728 bZeroValue = true;
729 }
730 else if(nValue <= 100)
731 {
732 mpLBTransType->Enable();
733 mpTrspTextFT->Enable();
734 mpLBTransType->SelectEntryPos(1);
735 mpBTNGradient->Hide();
736 mpMTRTransparent->Show();
737 mpMTRTransparent->Enable();
738 mpMTRTransparent->SetValue(nValue);
739 }
740
741 if(!bZeroValue)
742 {
743 maTrGrPopup.Hide();
744 }
745 }
746
747 if(bZeroValue && mpFloatTransparenceItem.get())
748 {
749 if(mpFloatTransparenceItem->IsEnabled())
750 {
751 const XGradient& rGradient = mpFloatTransparenceItem->GetGradientValue();
752 const bool bHighContrast(GetSettings().GetStyleSettings().GetHighContrastMode());
753 sal_uInt16 nEntryPos(0);
754 Image* pImage = 0;
755
756 mpLBTransType->Enable();
757 mpTrspTextFT->Enable();
758 mpMTRTransparent->Hide();
759 mpBTNGradient->Enable();
760 mpBTNGradient->Show();
761
762 switch(rGradient.GetGradientStyle())
763 {
764 case XGRAD_LINEAR:
765 {
766 nEntryPos = 2;
767 pImage = bHighContrast ? &maImgLinearH : &maImgLinear;
768 break;
769 }
770 case XGRAD_AXIAL:
771 {
772 nEntryPos = 3;
773 pImage = bHighContrast ? &maImgAxialH : &maImgAxial;
774 break;
775 }
776 case XGRAD_RADIAL:
777 {
778 nEntryPos = 4;
779 pImage = bHighContrast ? &maImgRadialH : &maImgRadial;
780 break;
781 }
782 case XGRAD_ELLIPTICAL:
783 {
784 nEntryPos = 5;
785 pImage = bHighContrast ? &maImgElliH : &maImgElli;
786 break;
787 }
788 case XGRAD_SQUARE:
789 {
790 nEntryPos = 6;
791 pImage = bHighContrast ? &maImgQuadH : &maImgQuad;
792 break;
793 }
794 case XGRAD_RECT:
795 {
796 nEntryPos = 7;
797 pImage = bHighContrast ? &maImgSquareH : &maImgSquare;
798 break;
799 }
800 }
801
802 mpLBTransType->SelectEntryPos(nEntryPos);
803 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT, *pImage);
804 bZeroValue = false;
805 }
806 else
807 {
808 bZeroValue = true;
809 }
810 }
811
812 if(bZeroValue)
813 {
814 mpLBTransType->Enable();
815 mpTrspTextFT->Enable();
816 mpLBTransType->SelectEntryPos(0);
817 mpBTNGradient->Hide();
818 mpMTRTransparent->Enable();
819 mpMTRTransparent->Show();
820 mpMTRTransparent->SetValue(0);
821 }
822 }
823 else
824 {
825 // no transparency at all
826 mpLBTransType->SetNoSelection();
827 mpLBTransType->Disable();
828 mpTrspTextFT->Disable();
829 mpMTRTransparent->Disable();
830 mpMTRTransparent->Show();
831 mpBTNGradient->Disable();
832 mpBTNGradient->Hide();
833 }
834 }
835
836
837
NotifyItemUpdate(sal_uInt16 nSID,SfxItemState eState,const SfxPoolItem * pState,const bool bIsEnabled)838 void AreaPropertyPanel::NotifyItemUpdate(
839 sal_uInt16 nSID,
840 SfxItemState eState,
841 const SfxPoolItem* pState,
842 const bool bIsEnabled)
843 {
844 (void)bIsEnabled;
845 const bool bDisabled(SFX_ITEM_DISABLED == eState);
846
847 switch(nSID)
848 {
849 case SID_ATTR_FILL_TRANSPARENCE:
850 case SID_ATTR_FILL_FLOATTRANSPARENCE:
851 {
852 bool bFillTransparenceChanged(false);
853
854 if(SID_ATTR_FILL_TRANSPARENCE == nSID)
855 {
856 bFillTransparenceChanged = true;
857
858 if(eState >= SFX_ITEM_AVAILABLE)
859 {
860 const SfxUInt16Item* pItem = dynamic_cast< const SfxUInt16Item* >(pState);
861
862 if(pItem && (!mpTransparanceItem || *pItem != *mpTransparanceItem))
863 {
864 mpTransparanceItem.reset((SfxUInt16Item*)pItem->Clone());
865 }
866 else
867 {
868 mpTransparanceItem.reset();
869 }
870 }
871 else
872 {
873 mpTransparanceItem.reset();
874 }
875 }
876 else // if(SID_ATTR_FILL_FLOATTRANSPARENCE == nSID)
877 {
878 bFillTransparenceChanged = true;
879
880 if(eState >= SFX_ITEM_AVAILABLE)
881 {
882 const XFillFloatTransparenceItem* pItem = dynamic_cast< const XFillFloatTransparenceItem* >(pState);
883
884 if(pItem && (!mpFloatTransparenceItem || *pItem != *mpFloatTransparenceItem))
885 {
886 mpFloatTransparenceItem.reset((XFillFloatTransparenceItem*)pItem->Clone());
887 }
888 else
889 {
890 mpFloatTransparenceItem.reset();
891 }
892 }
893 else
894 {
895 mpFloatTransparenceItem.reset();
896 }
897 }
898
899 if(bFillTransparenceChanged)
900 {
901 // update transparency settings dependent of mpTransparanceItem and mpFloatTransparenceItem
902 ImpUpdateTransparencies();
903 }
904 break;
905 }
906 case SID_ATTR_FILL_STYLE:
907 {
908 if(bDisabled)
909 {
910 mpLbFillType->Disable();
911 mpColorTextFT->Disable();
912 mpLbFillType->SetNoSelection();
913 mpLbFillAttr->Show();
914 mpLbFillAttr->Disable();
915 mpLbFillAttr->SetNoSelection();
916 mpToolBoxColor->Hide();
917 meLastXFS = -1;
918 mpStyleItem.reset();
919 }
920
921 if(eState >= SFX_ITEM_AVAILABLE)
922 {
923 const XFillStyleItem* pItem = dynamic_cast< const XFillStyleItem* >(pState);
924
925 if(pItem)
926 {
927 mpStyleItem.reset(dynamic_cast< XFillStyleItem* >(pItem->Clone()));
928 mpLbFillType->Enable();
929 mpColorTextFT->Enable();
930 XFillStyle eXFS = (XFillStyle)mpStyleItem->GetValue();
931 meLastXFS = eXFS;
932 mpLbFillType->SelectEntryPos(sal::static_int_cast< sal_uInt16 >(eXFS));
933
934 if(XFILL_NONE == eXFS)
935 {
936 mpLbFillAttr->SetNoSelection();
937 mpLbFillAttr->Disable();
938 }
939
940 Update();
941 break;
942 }
943 }
944
945 mpLbFillType->SetNoSelection();
946 mpLbFillAttr->Show();
947 mpLbFillAttr->Disable();
948 mpLbFillAttr->SetNoSelection();
949 mpToolBoxColor->Hide();
950 meLastXFS = -1;
951 mpStyleItem.reset();
952 break;
953 }
954 case SID_ATTR_FILL_COLOR:
955 {
956 if(SFX_ITEM_AVAILABLE == eState)
957 {
958 mpColorItem.reset(pState ? (XFillColorItem*)pState->Clone() : 0);
959 }
960
961 if(mpStyleItem && XFILL_SOLID == (XFillStyle)mpStyleItem->GetValue())
962 {
963 mpLbFillAttr->Hide();
964 mpToolBoxColor->Show();
965
966 if(SFX_ITEM_AVAILABLE == eState)
967 {
968 mpToolBoxColor->Enable();
969 mbColorAvail = true;
970 //maLastColor = mpColorItem->GetColorValue();
971 Update();
972 }
973 else if(SFX_ITEM_DISABLED == eState)
974 {
975 mpToolBoxColor->Disable();
976 mbColorAvail = false;
977 mpColorUpdater->Update(COL_WHITE);
978 }
979 else
980 {
981 mbColorAvail = false;
982 mpColorUpdater->Update(COL_WHITE);
983 }
984 }
985 break;
986 }
987 case SID_ATTR_FILL_GRADIENT:
988 {
989 if(SFX_ITEM_AVAILABLE == eState)
990 {
991 mpFillGradientItem.reset(pState ? (XFillGradientItem*)pState->Clone() : 0);
992 }
993
994 if(mpStyleItem && XFILL_GRADIENT == (XFillStyle)mpStyleItem->GetValue())
995 {
996 mpLbFillAttr->Show();
997 mpToolBoxColor->Hide();
998
999 if(SFX_ITEM_AVAILABLE == eState)
1000 {
1001 mpLbFillAttr->Enable();
1002 Update();
1003 }
1004 else if(SFX_ITEM_DISABLED == eState )
1005 {
1006 mpLbFillAttr->Disable();
1007 mpLbFillAttr->SetNoSelection();
1008 }
1009 else
1010 {
1011 mpLbFillAttr->SetNoSelection();
1012 }
1013 }
1014 break;
1015 }
1016 case SID_ATTR_FILL_HATCH:
1017 {
1018 if(SFX_ITEM_AVAILABLE == eState)
1019 {
1020 mpHatchItem.reset(pState ? (XFillHatchItem*)pState->Clone() : 0);
1021 }
1022
1023 if(mpStyleItem && XFILL_HATCH == (XFillStyle)mpStyleItem->GetValue())
1024 {
1025 mpLbFillAttr->Show();
1026 mpToolBoxColor->Hide();
1027
1028 if(SFX_ITEM_AVAILABLE == eState)
1029 {
1030 mpLbFillAttr->Enable();
1031 Update();
1032 }
1033 else if(SFX_ITEM_DISABLED == eState )
1034 {
1035 mpLbFillAttr->Disable();
1036 mpLbFillAttr->SetNoSelection();
1037 }
1038 else
1039 {
1040 mpLbFillAttr->SetNoSelection();
1041 }
1042 }
1043 break;
1044 }
1045 case SID_ATTR_FILL_BITMAP:
1046 {
1047 if(SFX_ITEM_AVAILABLE == eState)
1048 {
1049 mpBitmapItem.reset(pState ? (XFillBitmapItem*)pState->Clone() : 0);
1050 }
1051
1052 if(mpStyleItem && XFILL_BITMAP == (XFillStyle)mpStyleItem->GetValue())
1053 {
1054 mpLbFillAttr->Show();
1055 mpToolBoxColor->Hide();
1056
1057 if(SFX_ITEM_AVAILABLE == eState)
1058 {
1059 mpLbFillAttr->Enable();
1060 Update();
1061 }
1062 else if(SFX_ITEM_DISABLED == eState )
1063 {
1064 mpLbFillAttr->Disable();
1065 mpLbFillAttr->SetNoSelection();
1066 }
1067 else
1068 {
1069 mpLbFillAttr->SetNoSelection();
1070 }
1071 }
1072 break;
1073 }
1074 case SID_COLOR_TABLE:
1075 {
1076 if(SFX_ITEM_AVAILABLE == eState)
1077 {
1078 if(mpStyleItem && XFILL_SOLID == (XFillStyle)mpStyleItem->GetValue())
1079 {
1080 if(mpColorItem)
1081 {
1082 const Color aColor = mpColorItem->GetColorValue();
1083 const SfxObjectShell* pSh = SfxObjectShell::Current();
1084 const SvxColorTableItem aItem(*(const SvxColorTableItem*)(pSh->GetItem(SID_COLOR_TABLE)));
1085
1086 mpLbFillAttr->Clear();
1087 mpLbFillAttr->Enable();
1088 mpLbFillAttr->Fill(aItem.GetColorTable());
1089 mpLbFillAttr->SelectEntry(aColor);
1090 }
1091 else
1092 {
1093 mpLbFillAttr->SetNoSelection();
1094 }
1095 }
1096 }
1097 break;
1098 }
1099 case SID_GRADIENT_LIST:
1100 {
1101 if(SFX_ITEM_AVAILABLE == eState)
1102 {
1103 if(mpStyleItem && XFILL_GRADIENT == (XFillStyle)mpStyleItem->GetValue())
1104 {
1105 if(mpFillGradientItem)
1106 {
1107 const String aString( mpFillGradientItem->GetName() );
1108 const SfxObjectShell* pSh = SfxObjectShell::Current();
1109 const SvxGradientListItem aItem( *(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST)));
1110
1111 mpLbFillAttr->Clear();
1112 mpLbFillAttr->Enable();
1113 mpLbFillAttr->Fill(aItem.GetGradientList());
1114 mpLbFillAttr->SelectEntry(aString);
1115 }
1116 else
1117 {
1118 mpLbFillAttr->SetNoSelection();
1119 }
1120 }
1121 }
1122 break;
1123 }
1124 case SID_HATCH_LIST:
1125 {
1126 if(SFX_ITEM_AVAILABLE == eState)
1127 {
1128 if(mpStyleItem && XFILL_HATCH == (XFillStyle)mpStyleItem->GetValue())
1129 {
1130 if(mpHatchItem)
1131 {
1132 const String aString( mpHatchItem->GetName() );
1133 const SfxObjectShell* pSh = SfxObjectShell::Current();
1134 const SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST)));
1135
1136 mpLbFillAttr->Clear();
1137 mpLbFillAttr->Enable();
1138 mpLbFillAttr->Fill(aItem.GetHatchList());
1139 mpLbFillAttr->SelectEntry(aString);
1140 }
1141 else
1142 {
1143 mpLbFillAttr->SetNoSelection();
1144 }
1145 }
1146 }
1147 break;
1148 }
1149 case SID_BITMAP_LIST:
1150 {
1151 if(SFX_ITEM_AVAILABLE == eState)
1152 {
1153 if(mpStyleItem && XFILL_BITMAP == (XFillStyle)mpStyleItem->GetValue())
1154 {
1155 if(mpBitmapItem)
1156 {
1157 const String aString( mpBitmapItem->GetName() );
1158 const SfxObjectShell* pSh = SfxObjectShell::Current();
1159 const SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST)));
1160
1161 mpLbFillAttr->Clear();
1162 mpLbFillAttr->Enable();
1163 mpLbFillAttr->Fill(aItem.GetBitmapList());
1164 mpLbFillAttr->SelectEntry(aString);
1165 }
1166 else
1167 {
1168 mpLbFillAttr->SetNoSelection();
1169 }
1170 }
1171 }
1172 break;
1173 }
1174 }
1175
1176 maLayouter.Layout();
1177 }
1178
1179
1180
GetBindings()1181 SfxBindings* AreaPropertyPanel::GetBindings()
1182 {
1183 return mpBindings;
1184 }
1185
1186
1187
Update()1188 void AreaPropertyPanel::Update()
1189 {
1190 if(mpStyleItem)
1191 {
1192 const XFillStyle eXFS = (XFillStyle)mpStyleItem->GetValue();
1193 SfxObjectShell* pSh = SfxObjectShell::Current();
1194
1195 switch( eXFS )
1196 {
1197 case XFILL_NONE:
1198 {
1199 mpLbFillAttr->Show();
1200 mpToolBoxColor->Hide();
1201 break;
1202 }
1203 case XFILL_SOLID:
1204 {
1205 if(mpColorItem)
1206 {
1207 mpLbFillAttr->Hide();
1208 mpToolBoxColor->Show();
1209 mpColorUpdater->Update(mpColorItem->GetColorValue());
1210 }
1211 else
1212 {
1213 mpColorUpdater->Update(COL_WHITE);
1214 }
1215 break;
1216 }
1217 case XFILL_GRADIENT:
1218 {
1219 mpLbFillAttr->Show();
1220 mpToolBoxColor->Hide();
1221
1222 if(pSh && pSh->GetItem(SID_GRADIENT_LIST))
1223 {
1224 const SvxGradientListItem aItem(*(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST)));
1225 mpLbFillAttr->Enable();
1226 mpLbFillAttr->Clear();
1227 mpLbFillAttr->Fill(aItem.GetGradientList());
1228
1229 if(mpFillGradientItem)
1230 {
1231 const String aString(mpFillGradientItem->GetName());
1232
1233 mpLbFillAttr->SelectEntry(aString);
1234 }
1235 else
1236 {
1237 mpLbFillAttr->SetNoSelection();
1238 }
1239 }
1240 else
1241 {
1242 mpLbFillAttr->SetNoSelection();
1243 }
1244 break;
1245 }
1246 case XFILL_HATCH:
1247 {
1248 mpLbFillAttr->Show();
1249 mpToolBoxColor->Hide();
1250
1251 if(pSh && pSh->GetItem(SID_HATCH_LIST))
1252 {
1253 const SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST)));
1254 mpLbFillAttr->Enable();
1255 mpLbFillAttr->Clear();
1256 mpLbFillAttr->Fill(aItem.GetHatchList());
1257
1258 if(mpHatchItem)
1259 {
1260 const String aString(mpHatchItem->GetName());
1261
1262 mpLbFillAttr->SelectEntry( aString );
1263 }
1264 else
1265 {
1266 mpLbFillAttr->SetNoSelection();
1267 }
1268 }
1269 else
1270 {
1271 mpLbFillAttr->SetNoSelection();
1272 }
1273 break;
1274 }
1275 case XFILL_BITMAP:
1276 {
1277 mpLbFillAttr->Show();
1278 mpToolBoxColor->Hide();
1279
1280 if(pSh && pSh->GetItem(SID_BITMAP_LIST))
1281 {
1282 const SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST)));
1283 mpLbFillAttr->Enable();
1284 mpLbFillAttr->Clear();
1285 mpLbFillAttr->Fill(aItem.GetBitmapList());
1286
1287 if(mpBitmapItem)
1288 {
1289 const String aString(mpBitmapItem->GetName());
1290
1291 mpLbFillAttr->SelectEntry(aString);
1292 }
1293 else
1294 {
1295 mpLbFillAttr->SetNoSelection();
1296 }
1297 }
1298 else
1299 {
1300 mpLbFillAttr->SetNoSelection();
1301 }
1302 break;
1303 }
1304 default:
1305 DBG_ERROR( "Non supported FillType (!)" );
1306 break;
1307 }
1308 }
1309 }
1310
1311
1312
IMPL_LINK(AreaPropertyPanel,ImplPopupModeEndHdl,FloatingWindow *,EMPTYARG)1313 IMPL_LINK( AreaPropertyPanel, ImplPopupModeEndHdl, FloatingWindow*, EMPTYARG )
1314 {
1315 return 0;
1316 }
1317
1318
1319
IMPL_LINK(AreaPropertyPanel,ClickTrGrHdl_Impl,ToolBox *,pToolBox)1320 IMPL_LINK( AreaPropertyPanel, ClickTrGrHdl_Impl, ToolBox*, pToolBox )
1321 {
1322 maTrGrPopup.Rearrange(mpFloatTransparenceItem.get());
1323 OSL_ASSERT(pToolBox->GetCurItemId() == TBI_BTX_GRADIENT);
1324 maTrGrPopup.Show(*pToolBox);
1325
1326 return (0L);
1327 }
1328
1329
1330
IMPL_LINK(AreaPropertyPanel,ChangeTrgrTypeHdl_Impl,void *,EMPTYARG)1331 IMPL_LINK(AreaPropertyPanel, ChangeTrgrTypeHdl_Impl, void *, EMPTYARG)
1332 {
1333 sal_uInt16 nSelectType = mpLBTransType->GetSelectEntryPos();
1334 bool bGradient = false;
1335 sal_uInt16 nTrans = 0;
1336
1337 if(!nSelectType)
1338 {
1339 mpBTNGradient->Hide();
1340 mpMTRTransparent->Show();
1341 mpMTRTransparent->Enable();
1342 mpMTRTransparent->SetValue(0);
1343 }
1344 else if(1 == nSelectType)
1345 {
1346 mpBTNGradient->Hide();
1347 mpMTRTransparent->Show();
1348 nTrans = mnLastTransSolid;
1349 mpMTRTransparent->SetValue(nTrans);
1350 mpLBTransType->SelectEntryPos(1);
1351 mpMTRTransparent->Enable();
1352 }
1353 else
1354 {
1355 mpBTNGradient->Show();
1356
1357 switch (nSelectType)
1358 {
1359 case 2:
1360 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgLinearH : maImgLinear);
1361 break;
1362 case 3:
1363 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgAxialH : maImgAxial);
1364 break;
1365 case 4:
1366 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgRadialH : maImgRadial);
1367 break;
1368 case 5:
1369 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgElliH : maImgElli );
1370 break;
1371 case 6:
1372 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgQuadH : maImgQuad );
1373 break;
1374 case 7:
1375 mpBTNGradient->SetItemImage(TBI_BTX_GRADIENT,GetSettings().GetStyleSettings().GetHighContrastMode()? maImgSquareH : maImgSquare);
1376 break;
1377 }
1378
1379 mpMTRTransparent->Hide();
1380 mpBTNGradient->Enable();
1381 bGradient = true;
1382 }
1383
1384 const XFillTransparenceItem aLinearItem(nTrans);
1385 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_TRANSPARENCE, SFX_CALLMODE_RECORD, &aLinearItem, 0L );
1386
1387 if(nSelectType > 1)
1388 {
1389 nSelectType -= 2;
1390 }
1391
1392 XGradient aTmpGradient;
1393
1394 switch(nSelectType)
1395 {
1396 case XGRAD_LINEAR:
1397 aTmpGradient = maGradientLinear;
1398 break;
1399 case XGRAD_AXIAL:
1400 aTmpGradient = maGradientAxial;
1401 break;
1402 case XGRAD_RADIAL:
1403 aTmpGradient = maGradientRadial;
1404 break;
1405 case XGRAD_ELLIPTICAL:
1406 aTmpGradient = maGradientElliptical;
1407 break;
1408 case XGRAD_SQUARE:
1409 aTmpGradient = maGradientSquare;
1410 break;
1411 case XGRAD_RECT:
1412 aTmpGradient = maGradientRect;
1413 break;
1414 }
1415
1416 SfxItemPool* pPool = 0;
1417 const XFillFloatTransparenceItem aGradientItem(pPool, aTmpGradient, sal_Bool(bGradient));
1418 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_FLOATTRANSPARENCE, SFX_CALLMODE_RECORD, &aGradientItem, 0L );
1419
1420 return( 0L );
1421 }
1422
1423
1424
IMPL_LINK(AreaPropertyPanel,ModifyTransparentHdl_Impl,void *,EMPTYARG)1425 IMPL_LINK(AreaPropertyPanel, ModifyTransparentHdl_Impl, void*, EMPTYARG)
1426 {
1427 const sal_uInt16 nTrans = (sal_uInt16)mpMTRTransparent->GetValue();
1428 mnLastTransSolid = nTrans;
1429 const sal_uInt16 nSelectType = mpLBTransType->GetSelectEntryPos();
1430
1431 if(nTrans && !nSelectType)
1432 {
1433 mpLBTransType->SelectEntryPos(1);
1434 }
1435
1436 const XFillTransparenceItem aLinearItem(nTrans);
1437 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_TRANSPARENCE, SFX_CALLMODE_RECORD, &aLinearItem, 0L );
1438
1439 return 0L;
1440 }
1441
1442
GetLastColor(void) const1443 Color AreaPropertyPanel::GetLastColor (void) const
1444 {
1445 return maLastColor;
1446 }
1447
1448
1449
1450
GetGradient(const XGradientStyle eStyle) const1451 XGradient AreaPropertyPanel::GetGradient (const XGradientStyle eStyle) const
1452 {
1453 switch (eStyle)
1454 {
1455 default:
1456 case XGRAD_LINEAR:
1457 return maGradientLinear;
1458 case XGRAD_AXIAL:
1459 return maGradientAxial;
1460 case XGRAD_RADIAL:
1461 return maGradientRadial;
1462 case XGRAD_ELLIPTICAL:
1463 return maGradientElliptical;
1464 case XGRAD_SQUARE:
1465 return maGradientSquare;
1466 case XGRAD_RECT:
1467 return maGradientRect;
1468 }
1469 }
1470
1471
1472
1473
SetGradient(const XGradient & rGradient)1474 void AreaPropertyPanel::SetGradient (const XGradient& rGradient)
1475 {
1476 switch (rGradient.GetGradientStyle())
1477 {
1478 case XGRAD_LINEAR:
1479 maGradientLinear = rGradient;
1480 break;
1481 case XGRAD_AXIAL:
1482 maGradientAxial = rGradient;
1483 break;
1484 case XGRAD_RADIAL:
1485 maGradientRadial = rGradient;
1486 break;
1487 case XGRAD_ELLIPTICAL:
1488 maGradientElliptical = rGradient;
1489 break;
1490 case XGRAD_SQUARE:
1491 maGradientSquare = rGradient;
1492 break;
1493 case XGRAD_RECT:
1494 maGradientRect = rGradient;
1495 break;
1496 }
1497 }
1498
1499
1500
1501
GetSelectedTransparencyTypeIndex(void) const1502 sal_Int32 AreaPropertyPanel::GetSelectedTransparencyTypeIndex (void) const
1503 {
1504 return mpLBTransType->GetSelectEntryPos();
1505 }
1506
1507
1508
1509
Resize(void)1510 void AreaPropertyPanel::Resize (void)
1511 {
1512 maLayouter.Layout();
1513 }
1514
1515
1516
1517 } } // end of namespace svx::sidebar
1518
1519 // eof
1520