bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / sidebar / area / AreaPropertyPanel.cxx
blob766ba52f082143456784dd15eb167e9f62e05cf9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "svx/sidebar/PopupContainer.hxx"
20 #include "AreaTransparencyGradientControl.hxx"
22 #include <sfx2/sidebar/ResourceDefinitions.hrc>
23 #include <sfx2/sidebar/Theme.hxx>
24 #include <sfx2/sidebar/ControlFactory.hxx>
25 #include <AreaPropertyPanel.hxx>
26 #include <AreaPropertyPanel.hrc>
27 #include <svx/dialogs.hrc>
28 #include <svx/dialmgr.hxx>
29 #include <sfx2/objsh.hxx>
30 #include <svx/xfltrit.hxx>
31 #include <svx/xflftrit.hxx>
32 #include <svx/xtable.hxx>
33 #include <sfx2/dispatch.hxx>
34 #include <sfx2/bindings.hxx>
35 #include <helpid.hrc>
36 #include <svtools/valueset.hxx>
37 #include <unotools/pathoptions.hxx>
38 #include <svx/svxitems.hrc>
39 #include <vcl/toolbox.hxx>
40 #include <svtools/toolbarmenu.hxx>
42 #include <boost/bind.hpp>
44 using namespace css;
45 using namespace css::uno;
46 using ::sfx2::sidebar::Theme;
48 const char UNO_SIDEBARGRADIENT[] = ".uno:sidebargradient";
50 namespace svx { namespace sidebar {
52 const sal_Int32 AreaPropertyPanel::DEFAULT_CENTERX = 50;
53 const sal_Int32 AreaPropertyPanel::DEFAULT_CENTERY = 50;
54 const sal_Int32 AreaPropertyPanel::DEFAULT_ANGLE = 0;
55 const sal_Int32 AreaPropertyPanel::DEFAULT_STARTVALUE = 0;
56 const sal_Int32 AreaPropertyPanel::DEFAULT_ENDVALUE = 16777215;
57 const sal_Int32 AreaPropertyPanel::DEFAULT_BORDER = 0;
60 AreaPropertyPanel::AreaPropertyPanel(
61 vcl::Window* pParent,
62 const css::uno::Reference<css::frame::XFrame>& rxFrame,
63 SfxBindings* pBindings)
64 : PanelLayout(pParent, "AreaPropertyPanel", "svx/ui/sidebararea.ui", rxFrame),
65 meLastXFS(static_cast<sal_uInt16>(-1)),
66 mnLastPosGradient(0),
67 mnLastPosHatch(0),
68 mnLastPosBitmap(0),
69 mnLastTransSolid(50),
70 maGradientLinear(),
71 maGradientAxial(),
72 maGradientRadial(),
73 maGradientElliptical(),
74 maGradientSquare(),
75 maGradientRect(),
76 mpStyleItem(),
77 mpColorItem(),
78 mpFillGradientItem(),
79 mpHatchItem(),
80 mpBitmapItem(),
81 maStyleControl(SID_ATTR_FILL_STYLE, *pBindings, *this),
82 maColorControl(SID_ATTR_FILL_COLOR, *pBindings, *this),
83 maGradientControl(SID_ATTR_FILL_GRADIENT, *pBindings, *this),
84 maHatchControl(SID_ATTR_FILL_HATCH, *pBindings, *this),
85 maBitmapControl(SID_ATTR_FILL_BITMAP, *pBindings, *this),
86 maGradientListControl(SID_GRADIENT_LIST, *pBindings, *this),
87 maHatchListControl(SID_HATCH_LIST, *pBindings, *this),
88 maBitmapListControl(SID_BITMAP_LIST, *pBindings, *this),
89 maFillTransparenceController(SID_ATTR_FILL_TRANSPARENCE, *pBindings, *this),
90 maFillFloatTransparenceController(SID_ATTR_FILL_FLOATTRANSPARENCE, *pBindings, *this),
91 maImgAxial(SVX_RES(IMG_AXIAL)),
92 maImgElli(SVX_RES(IMG_ELLI)),
93 maImgQuad(SVX_RES(IMG_QUAD)),
94 maImgRadial(SVX_RES(IMG_RADIAL)),
95 maImgSquare(SVX_RES(IMG_SQUARE)),
96 maImgLinear(SVX_RES(IMG_LINEAR)),
97 maTrGrPopup(this, ::boost::bind(&AreaPropertyPanel::CreateTransparencyGradientControl, this, _1)),
98 mpFloatTransparenceItem(),
99 mpTransparanceItem(),
100 mxFrame(rxFrame),
101 mpBindings(pBindings)
103 get(mpColorTextFT, "filllabel");
104 get(mpLbFillType, "fillstyle");
105 get(mpLbFillAttr, "fillattr");
106 get(mpTrspTextFT, "transparencylabel");
107 get(mpToolBoxColor, "selectcolor");
108 get(mpLBTransType, "transtype");
109 get(mpMTRTransparent, "settransparency");
110 get(mpBTNGradient, "selectgradient");
112 Initialize();
116 AreaPropertyPanel::~AreaPropertyPanel()
118 disposeOnce();
121 void AreaPropertyPanel::dispose()
123 mpColorTextFT.clear();
124 mpLbFillType.clear();
125 mpLbFillAttr.clear();
126 mpToolBoxColor.clear();
127 mpTrspTextFT.clear();
128 mpLBTransType.clear();
129 mpMTRTransparent.clear();
130 mpBTNGradient.clear();
132 maStyleControl.dispose();
133 maColorControl.dispose();
134 maGradientControl.dispose();
135 maHatchControl.dispose();
136 maBitmapControl.dispose();
137 maGradientListControl.dispose();
138 maHatchListControl.dispose();
139 maBitmapListControl.dispose();
140 maFillTransparenceController.dispose();
141 maFillFloatTransparenceController.dispose();
143 PanelLayout::dispose();
146 void AreaPropertyPanel::Initialize()
148 maGradientLinear.SetXOffset(DEFAULT_CENTERX);
149 maGradientLinear.SetYOffset(DEFAULT_CENTERY);
150 maGradientLinear.SetAngle(DEFAULT_ANGLE);
151 maGradientLinear.SetStartColor(Color(DEFAULT_STARTVALUE));
152 maGradientLinear.SetEndColor(Color(DEFAULT_ENDVALUE));
153 maGradientLinear.SetBorder(DEFAULT_BORDER);
154 maGradientLinear.SetGradientStyle(css::awt::GradientStyle_LINEAR);
156 maGradientAxial = maGradientLinear;
157 maGradientAxial.SetGradientStyle(css::awt::GradientStyle_AXIAL);
159 maGradientRadial = maGradientLinear;
160 maGradientRadial.SetGradientStyle(css::awt::GradientStyle_RADIAL);
162 maGradientElliptical = maGradientLinear;
163 maGradientElliptical.SetGradientStyle(css::awt::GradientStyle_ELLIPTICAL);
165 maGradientSquare = maGradientLinear;
166 maGradientSquare.SetGradientStyle(css::awt::GradientStyle_SQUARE);
168 maGradientRect = maGradientLinear;
169 maGradientRect.SetGradientStyle(css::awt::GradientStyle_RECT);
171 mpLbFillType->SetAccessibleName(OUString( "Fill")); //wj acc
172 mpLbFillAttr->SetAccessibleName(OUString( "Fill")); //wj acc
174 Link<> aLink = LINK( this, AreaPropertyPanel, SelectFillTypeHdl );
175 mpLbFillType->SetSelectHdl( aLink );
177 aLink = LINK( this, AreaPropertyPanel, SelectFillAttrHdl );
178 mpLbFillAttr->SetSelectHdl( aLink );
180 mpLBTransType->SetSelectHdl(LINK(this, AreaPropertyPanel, ChangeTrgrTypeHdl_Impl));
181 mpLBTransType->SetAccessibleName(OUString( "Transparency")); //wj acc
183 mpMTRTransparent->SetValue( 50 );
184 mpMTRTransparent->SetModifyHdl(LINK(this, AreaPropertyPanel, ModifyTransparentHdl_Impl));
185 mpMTRTransparent->SetAccessibleName(OUString( "Transparency")); //wj acc
187 const sal_uInt16 nIdGradient = mpBTNGradient->GetItemId(UNO_SIDEBARGRADIENT);
188 mpBTNGradient->SetItemBits( nIdGradient, mpBTNGradient->GetItemBits( nIdGradient ) | ToolBoxItemBits::DROPDOWNONLY );
189 Link<ToolBox *, void> aLink2 = LINK( this, AreaPropertyPanel, ClickTrGrHdl_Impl );
190 mpBTNGradient->SetDropdownClickHdl( aLink2 );
191 mpBTNGradient->SetSelectHdl( aLink2 );
192 mpBTNGradient->SetItemImage(nIdGradient,maImgLinear);
193 mpBTNGradient->Hide();
195 mpLbFillType->SetAccessibleRelationLabeledBy(mpColorTextFT);
196 mpLbFillAttr->SetAccessibleRelationLabeledBy(mpLbFillAttr);
197 mpToolBoxColor->SetAccessibleRelationLabeledBy(mpToolBoxColor);
198 mpLBTransType->SetAccessibleRelationLabeledBy(mpTrspTextFT);
199 mpMTRTransparent->SetAccessibleRelationLabeledBy(mpMTRTransparent);
200 mpBTNGradient->SetAccessibleRelationLabeledBy(mpBTNGradient);
202 SetupIcons();
205 IMPL_LINK(AreaPropertyPanel, SelectFillTypeHdl, ListBox *, pToolBox)
207 const drawing::FillStyle eXFS = (drawing::FillStyle)mpLbFillType->GetSelectEntryPos();
209 if((drawing::FillStyle)meLastXFS != eXFS)
211 mpLbFillAttr->Clear();
212 SfxObjectShell* pSh = SfxObjectShell::Current();
213 const XFillStyleItem aXFillStyleItem(eXFS);
215 // #i122676# Do no longer trigger two Execute calls, one for SID_ATTR_FILL_STYLE
216 // and one for setting the fill attribute itself, but add two SfxPoolItems to the
217 // call to get just one action at the SdrObject and to create only one Undo action, too.
218 // Checked that this works in all apps.
219 switch( eXFS )
221 default:
222 case drawing::FillStyle_NONE:
224 mpLbFillAttr->Show();
225 mpToolBoxColor->Hide();
226 mpLbFillType->Selected();
227 mpLbFillAttr->Disable();
229 // #i122676# need to call a single SID_ATTR_FILL_STYLE change
230 GetBindings()->GetDispatcher()->Execute(
231 SID_ATTR_FILL_STYLE, SfxCallMode::RECORD, &aXFillStyleItem, 0L);
232 break;
234 case drawing::FillStyle_SOLID:
236 mpLbFillAttr->Hide();
237 mpToolBoxColor->Show();
238 const OUString aTmpStr;
239 const Color aColor = mpColorItem->GetColorValue();
240 const XFillColorItem aXFillColorItem( aTmpStr, aColor );
242 // #i122676# change FillStyle and Color in one call
243 GetBindings()->GetDispatcher()->Execute(
244 SID_ATTR_FILL_COLOR, SfxCallMode::RECORD, &aXFillColorItem, &aXFillStyleItem, 0L);
245 break;
247 case drawing::FillStyle_GRADIENT:
249 mpLbFillAttr->Show();
250 mpToolBoxColor->Hide();
252 if(pSh && pSh->GetItem(SID_GRADIENT_LIST))
254 if(!mpLbFillAttr->GetEntryCount())
256 const SvxGradientListItem aItem(*static_cast<const SvxGradientListItem*>(pSh->GetItem(SID_GRADIENT_LIST)));
257 mpLbFillAttr->Enable();
258 mpLbFillAttr->Clear();
259 mpLbFillAttr->Fill(aItem.GetGradientList());
262 mpLbFillAttr->AdaptDropDownLineCountToMaximum();
264 if(LISTBOX_ENTRY_NOTFOUND != mnLastPosGradient)
266 const SvxGradientListItem aItem(*static_cast<const SvxGradientListItem*>(pSh->GetItem(SID_GRADIENT_LIST)));
268 if(mnLastPosGradient < aItem.GetGradientList()->Count())
270 const XGradient aGradient = aItem.GetGradientList()->GetGradient(mnLastPosGradient)->GetGradient();
271 const XFillGradientItem aXFillGradientItem(mpLbFillAttr->GetEntry(mnLastPosGradient), aGradient);
273 // #i122676# change FillStyle and Gradient in one call
274 GetBindings()->GetDispatcher()->Execute(
275 SID_ATTR_FILL_GRADIENT, SfxCallMode::RECORD, &aXFillGradientItem, &aXFillStyleItem, 0L);
276 mpLbFillAttr->SelectEntryPos(mnLastPosGradient);
280 else
282 mpLbFillAttr->Disable();
284 break;
286 case drawing::FillStyle_HATCH:
288 mpLbFillAttr->Show();
289 mpToolBoxColor->Hide();
291 if(pSh && pSh->GetItem(SID_HATCH_LIST))
293 if(!mpLbFillAttr->GetEntryCount())
295 const SvxHatchListItem aItem( *static_cast<const SvxHatchListItem*>(pSh->GetItem(SID_HATCH_LIST)));
296 mpLbFillAttr->Enable();
297 mpLbFillAttr->Clear();
298 mpLbFillAttr->Fill(aItem.GetHatchList());
301 mpLbFillAttr->AdaptDropDownLineCountToMaximum();
303 if(LISTBOX_ENTRY_NOTFOUND != mnLastPosHatch)
305 const SvxHatchListItem aItem(*static_cast<const SvxHatchListItem*>(pSh->GetItem(SID_HATCH_LIST)));
307 if(mnLastPosHatch < aItem.GetHatchList()->Count())
309 const XHatch aHatch = aItem.GetHatchList()->GetHatch(mnLastPosHatch)->GetHatch();
310 const XFillHatchItem aXFillHatchItem(mpLbFillAttr->GetSelectEntry(), aHatch);
312 // #i122676# change FillStyle and Hatch in one call
313 GetBindings()->GetDispatcher()->Execute(
314 SID_ATTR_FILL_HATCH, SfxCallMode::RECORD, &aXFillHatchItem, &aXFillStyleItem, 0L);
315 mpLbFillAttr->SelectEntryPos(mnLastPosHatch);
319 else
321 mpLbFillAttr->Disable();
323 break;
325 case drawing::FillStyle_BITMAP:
327 mpLbFillAttr->Show();
328 mpToolBoxColor->Hide();
330 if(pSh && pSh->GetItem(SID_BITMAP_LIST))
332 if(!mpLbFillAttr->GetEntryCount())
334 const SvxBitmapListItem aItem( *static_cast<const SvxBitmapListItem*>(pSh->GetItem(SID_BITMAP_LIST)));
335 mpLbFillAttr->Enable();
336 mpLbFillAttr->Clear();
337 mpLbFillAttr->Fill(aItem.GetBitmapList());
340 mpLbFillAttr->AdaptDropDownLineCountToMaximum();
342 if(LISTBOX_ENTRY_NOTFOUND != mnLastPosBitmap)
344 const SvxBitmapListItem aItem(*static_cast<const SvxBitmapListItem*>(pSh->GetItem(SID_BITMAP_LIST)));
346 if(mnLastPosBitmap < aItem.GetBitmapList()->Count())
348 const XBitmapEntry* pXBitmapEntry = aItem.GetBitmapList()->GetBitmap(mnLastPosBitmap);
349 const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectEntry(), pXBitmapEntry->GetGraphicObject());
351 // #i122676# change FillStyle and Bitmap in one call
352 GetBindings()->GetDispatcher()->Execute(
353 SID_ATTR_FILL_BITMAP, SfxCallMode::RECORD, &aXFillBitmapItem, &aXFillStyleItem, 0L);
354 mpLbFillAttr->SelectEntryPos(mnLastPosBitmap);
358 else
360 mpLbFillAttr->Disable();
362 break;
366 meLastXFS = (sal_uInt16)eXFS;
368 if(drawing::FillStyle_NONE != eXFS)
370 if(pToolBox)
372 mpLbFillType->Selected();
377 return 0;
380 IMPL_LINK(AreaPropertyPanel, SelectFillAttrHdl, ListBox*, pToolBox)
382 const drawing::FillStyle eXFS = (drawing::FillStyle)mpLbFillType->GetSelectEntryPos();
383 const XFillStyleItem aXFillStyleItem(eXFS);
384 SfxObjectShell* pSh = SfxObjectShell::Current();
386 if(pToolBox)
388 // #i122676# dependent from bFillStyleChange, do execute a single or two
389 // changes in one Execute call
390 const bool bFillStyleChange((drawing::FillStyle) meLastXFS != eXFS);
392 switch(eXFS)
394 case drawing::FillStyle_SOLID:
396 if(bFillStyleChange)
398 // #i122676# Single FillStyle change call needed here
399 GetBindings()->GetDispatcher()->Execute(SID_ATTR_FILL_STYLE, SfxCallMode::RECORD, &aXFillStyleItem, 0L);
401 break;
403 case drawing::FillStyle_GRADIENT:
405 sal_Int32 nPos = mpLbFillAttr->GetSelectEntryPos();
407 if(LISTBOX_ENTRY_NOTFOUND == nPos)
409 nPos = mnLastPosGradient;
412 if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_GRADIENT_LIST))
414 const SvxGradientListItem aItem(*static_cast<const SvxGradientListItem*>(pSh->GetItem(SID_GRADIENT_LIST)));
416 if(nPos < aItem.GetGradientList()->Count())
418 const XGradient aGradient = aItem.GetGradientList()->GetGradient(nPos)->GetGradient();
419 const XFillGradientItem aXFillGradientItem(mpLbFillAttr->GetSelectEntry(), aGradient);
421 // #i122676# Change FillStale and Gradinet in one call
422 GetBindings()->GetDispatcher()->Execute(
423 SID_ATTR_FILL_GRADIENT, SfxCallMode::RECORD, &aXFillGradientItem,
424 bFillStyleChange ? &aXFillStyleItem : 0L, 0L);
428 if(LISTBOX_ENTRY_NOTFOUND != nPos)
430 mnLastPosGradient = nPos;
432 break;
434 case drawing::FillStyle_HATCH:
436 sal_Int32 nPos = mpLbFillAttr->GetSelectEntryPos();
438 if(LISTBOX_ENTRY_NOTFOUND == nPos)
440 nPos = mnLastPosHatch;
443 if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_HATCH_LIST))
445 const SvxHatchListItem aItem(*static_cast<const SvxHatchListItem*>(pSh->GetItem(SID_HATCH_LIST)));
447 if(nPos < aItem.GetHatchList()->Count())
449 const XHatch aHatch = aItem.GetHatchList()->GetHatch(nPos)->GetHatch();
450 const XFillHatchItem aXFillHatchItem( mpLbFillAttr->GetSelectEntry(), aHatch);
452 // #i122676# Change FillStale and Hatch in one call
453 GetBindings()->GetDispatcher()->Execute(
454 SID_ATTR_FILL_HATCH, SfxCallMode::RECORD, &aXFillHatchItem,
455 bFillStyleChange ? &aXFillStyleItem : 0L, 0L);
459 if(LISTBOX_ENTRY_NOTFOUND != nPos)
461 mnLastPosHatch = nPos;
463 break;
465 case drawing::FillStyle_BITMAP:
467 sal_Int32 nPos = mpLbFillAttr->GetSelectEntryPos();
469 if(LISTBOX_ENTRY_NOTFOUND == nPos)
471 nPos = mnLastPosBitmap;
474 if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_BITMAP_LIST))
476 const SvxBitmapListItem aItem(*static_cast<const SvxBitmapListItem*>(pSh->GetItem(SID_BITMAP_LIST)));
478 if(nPos < aItem.GetBitmapList()->Count())
480 const XBitmapEntry* pXBitmapEntry = aItem.GetBitmapList()->GetBitmap(nPos);
481 const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectEntry(), pXBitmapEntry->GetGraphicObject());
483 // #i122676# Change FillStale and Bitmap in one call
484 GetBindings()->GetDispatcher()->Execute(
485 SID_ATTR_FILL_BITMAP, SfxCallMode::RECORD, &aXFillBitmapItem,
486 bFillStyleChange ? &aXFillStyleItem : 0L, 0L);
490 if(LISTBOX_ENTRY_NOTFOUND != nPos)
492 mnLastPosBitmap = nPos;
494 break;
496 default: break;
500 return 0;
504 VclPtr<PopupControl> AreaPropertyPanel::CreateTransparencyGradientControl (PopupContainer* pParent)
506 return VclPtrInstance<AreaTransparencyGradientControl>(pParent, *this);
512 void AreaPropertyPanel::SetupIcons()
514 if(Theme::GetBoolean(Theme::Bool_UseSymphonyIcons))
516 // todo
518 else
520 // todo
526 VclPtr<vcl::Window> AreaPropertyPanel::Create (
527 vcl::Window* pParent,
528 const css::uno::Reference<css::frame::XFrame>& rxFrame,
529 SfxBindings* pBindings)
531 if (pParent == NULL)
532 throw lang::IllegalArgumentException("no parent Window given to AreaPropertyPanel::Create", NULL, 0);
533 if ( ! rxFrame.is())
534 throw lang::IllegalArgumentException("no XFrame given to AreaPropertyPanel::Create", NULL, 1);
535 if (pBindings == NULL)
536 throw lang::IllegalArgumentException("no SfxBindings given to AreaPropertyPanel::Create", NULL, 2);
538 return VclPtr<AreaPropertyPanel>::Create(
539 pParent,
540 rxFrame,
541 pBindings);
546 void AreaPropertyPanel::DataChanged(
547 const DataChangedEvent& rEvent)
549 (void)rEvent;
551 SetupIcons();
556 void AreaPropertyPanel::ImpUpdateTransparencies()
558 if(mpTransparanceItem.get() && mpFloatTransparenceItem.get())
560 bool bZeroValue(false);
562 if(mpTransparanceItem.get())
564 const sal_uInt16 nValue(mpTransparanceItem->GetValue());
566 if(!nValue)
568 bZeroValue = true;
570 else if(nValue <= 100)
572 mpLBTransType->Enable();
573 mpTrspTextFT->Enable();
574 mpLBTransType->SelectEntryPos(1);
575 mpBTNGradient->Hide();
576 mpMTRTransparent->Show();
577 mpMTRTransparent->Enable();
578 mpMTRTransparent->SetValue(nValue);
581 if(!bZeroValue)
583 maTrGrPopup.Hide();
587 if(bZeroValue && mpFloatTransparenceItem.get())
589 if(mpFloatTransparenceItem->IsEnabled())
591 const XGradient& rGradient = mpFloatTransparenceItem->GetGradientValue();
592 sal_Int32 nEntryPos(0);
593 Image* pImage = 0;
595 mpLBTransType->Enable();
596 mpTrspTextFT->Enable();
597 mpMTRTransparent->Hide();
598 mpBTNGradient->Enable();
599 mpBTNGradient->Show();
601 switch(rGradient.GetGradientStyle())
603 default:
604 case css::awt::GradientStyle_LINEAR:
606 nEntryPos = 2;
607 pImage = &maImgLinear;
608 break;
610 case css::awt::GradientStyle_AXIAL:
612 nEntryPos = 3;
613 pImage = &maImgAxial;
614 break;
616 case css::awt::GradientStyle_RADIAL:
618 nEntryPos = 4;
619 pImage = &maImgRadial;
620 break;
622 case css::awt::GradientStyle_ELLIPTICAL:
624 nEntryPos = 5;
625 pImage = &maImgElli;
626 break;
628 case css::awt::GradientStyle_SQUARE:
630 nEntryPos = 6;
631 pImage = &maImgQuad;
632 break;
634 case css::awt::GradientStyle_RECT:
636 nEntryPos = 7;
637 pImage = &maImgSquare;
638 break;
642 const sal_uInt16 nIdGradient = mpBTNGradient->GetItemId(UNO_SIDEBARGRADIENT);
643 mpLBTransType->SelectEntryPos(nEntryPos);
644 mpBTNGradient->SetItemImage(nIdGradient, *pImage);
645 bZeroValue = false;
647 else
649 bZeroValue = true;
653 if(bZeroValue)
655 mpLBTransType->Enable();
656 mpTrspTextFT->Enable();
657 mpLBTransType->SelectEntryPos(0);
658 mpBTNGradient->Hide();
659 mpMTRTransparent->Enable();
660 mpMTRTransparent->Show();
661 mpMTRTransparent->SetValue(0);
664 else
666 // no transparency at all
667 mpLBTransType->SetNoSelection();
668 mpLBTransType->Disable();
669 mpTrspTextFT->Disable();
670 mpMTRTransparent->Disable();
671 mpMTRTransparent->Show();
672 mpBTNGradient->Disable();
673 mpBTNGradient->Hide();
679 void AreaPropertyPanel::NotifyItemUpdate(
680 sal_uInt16 nSID,
681 SfxItemState eState,
682 const SfxPoolItem* pState,
683 const bool bIsEnabled)
685 (void)bIsEnabled;
686 const bool bDisabled(SfxItemState::DISABLED == eState);
688 switch(nSID)
690 case SID_ATTR_FILL_TRANSPARENCE:
691 case SID_ATTR_FILL_FLOATTRANSPARENCE:
693 bool bFillTransparenceChanged(false);
695 if(SID_ATTR_FILL_TRANSPARENCE == nSID)
697 bFillTransparenceChanged = true;
699 if(eState >= SfxItemState::DEFAULT)
701 const SfxUInt16Item* pItem = dynamic_cast< const SfxUInt16Item* >(pState);
703 if(pItem && (!mpTransparanceItem || *pItem != *mpTransparanceItem))
705 mpTransparanceItem.reset(static_cast<SfxUInt16Item*>(pItem->Clone()));
707 else
709 mpTransparanceItem.reset();
712 else
714 mpTransparanceItem.reset();
717 else // if(SID_ATTR_FILL_FLOATTRANSPARENCE == nSID)
719 bFillTransparenceChanged = true;
721 if(eState >= SfxItemState::DEFAULT)
723 const XFillFloatTransparenceItem* pItem = dynamic_cast< const XFillFloatTransparenceItem* >(pState);
725 if(pItem && (!mpFloatTransparenceItem || *pItem != *mpFloatTransparenceItem))
727 mpFloatTransparenceItem.reset(static_cast<XFillFloatTransparenceItem*>(pItem->Clone()));
729 else
731 mpFloatTransparenceItem.reset();
734 else
736 mpFloatTransparenceItem.reset();
740 if(bFillTransparenceChanged)
742 // update transparency settings dependent of mpTransparanceItem and mpFloatTransparenceItem
743 ImpUpdateTransparencies();
745 break;
747 case SID_ATTR_FILL_STYLE:
749 if(bDisabled)
751 mpLbFillType->Disable();
752 mpColorTextFT->Disable();
753 mpLbFillType->SetNoSelection();
754 mpLbFillAttr->Show();
755 mpLbFillAttr->Disable();
756 mpLbFillAttr->SetNoSelection();
757 mpToolBoxColor->Hide();
758 meLastXFS = static_cast<sal_uInt16>(-1);
759 mpStyleItem.reset();
762 if(eState >= SfxItemState::DEFAULT)
764 const XFillStyleItem* pItem = dynamic_cast< const XFillStyleItem* >(pState);
766 if(pItem)
768 mpStyleItem.reset(dynamic_cast< XFillStyleItem* >(pItem->Clone()));
769 mpLbFillType->Enable();
770 mpColorTextFT->Enable();
771 drawing::FillStyle eXFS = (drawing::FillStyle)mpStyleItem->GetValue();
772 meLastXFS = eXFS;
773 mpLbFillType->SelectEntryPos(sal::static_int_cast< sal_Int32 >(eXFS));
775 if(drawing::FillStyle_NONE == eXFS)
777 mpLbFillAttr->SetNoSelection();
778 mpLbFillAttr->Disable();
781 Update();
782 break;
786 mpLbFillType->SetNoSelection();
787 mpLbFillAttr->Show();
788 mpLbFillAttr->Disable();
789 mpLbFillAttr->SetNoSelection();
790 mpToolBoxColor->Hide();
791 meLastXFS = static_cast<sal_uInt16>(-1);
792 mpStyleItem.reset();
793 break;
795 case SID_ATTR_FILL_COLOR:
797 if(SfxItemState::DEFAULT == eState)
799 mpColorItem.reset(pState ? static_cast<XFillColorItem*>(pState->Clone()) : 0);
802 if(mpStyleItem && drawing::FillStyle_SOLID == (drawing::FillStyle)mpStyleItem->GetValue())
804 mpLbFillAttr->Hide();
805 mpToolBoxColor->Show();
807 Update();
809 break;
811 case SID_ATTR_FILL_GRADIENT:
813 if(SfxItemState::DEFAULT == eState)
815 mpFillGradientItem.reset(pState ? static_cast<XFillGradientItem*>(pState->Clone()) : 0);
818 if(mpStyleItem && drawing::FillStyle_GRADIENT == (drawing::FillStyle)mpStyleItem->GetValue())
820 mpLbFillAttr->Show();
821 mpToolBoxColor->Hide();
823 if(SfxItemState::DEFAULT == eState)
825 mpLbFillAttr->Enable();
826 Update();
828 else if(SfxItemState::DISABLED == eState )
830 mpLbFillAttr->Disable();
831 mpLbFillAttr->SetNoSelection();
833 else
835 mpLbFillAttr->SetNoSelection();
838 break;
840 case SID_ATTR_FILL_HATCH:
842 if(SfxItemState::DEFAULT == eState)
844 mpHatchItem.reset(pState ? static_cast<XFillHatchItem*>(pState->Clone()) : 0);
847 if(mpStyleItem && drawing::FillStyle_HATCH == (drawing::FillStyle)mpStyleItem->GetValue())
849 mpLbFillAttr->Show();
850 mpToolBoxColor->Hide();
852 if(SfxItemState::DEFAULT == eState)
854 mpLbFillAttr->Enable();
855 Update();
857 else if(SfxItemState::DISABLED == eState )
859 mpLbFillAttr->Disable();
860 mpLbFillAttr->SetNoSelection();
862 else
864 mpLbFillAttr->SetNoSelection();
867 break;
869 case SID_ATTR_FILL_BITMAP:
871 if(SfxItemState::DEFAULT == eState)
873 mpBitmapItem.reset(pState ? static_cast<XFillBitmapItem*>(pState->Clone()) : 0);
876 if(mpStyleItem && drawing::FillStyle_BITMAP == (drawing::FillStyle)mpStyleItem->GetValue())
878 mpLbFillAttr->Show();
879 mpToolBoxColor->Hide();
881 if(SfxItemState::DEFAULT == eState)
883 mpLbFillAttr->Enable();
884 Update();
886 else if(SfxItemState::DISABLED == eState )
888 mpLbFillAttr->Disable();
889 mpLbFillAttr->SetNoSelection();
891 else
893 mpLbFillAttr->SetNoSelection();
896 break;
898 case SID_GRADIENT_LIST:
900 if(SfxItemState::DEFAULT == eState)
902 if(mpStyleItem && drawing::FillStyle_GRADIENT == (drawing::FillStyle)mpStyleItem->GetValue())
904 if(mpFillGradientItem)
906 const OUString aString( mpFillGradientItem->GetName() );
907 const SfxObjectShell* pSh = SfxObjectShell::Current();
908 const SvxGradientListItem aItem( *static_cast<const SvxGradientListItem*>(pSh->GetItem(SID_GRADIENT_LIST)));
910 mpLbFillAttr->Clear();
911 mpLbFillAttr->Enable();
912 mpLbFillAttr->Fill(aItem.GetGradientList());
913 mpLbFillAttr->SelectEntry(aString);
915 else
917 mpLbFillAttr->SetNoSelection();
921 break;
923 case SID_HATCH_LIST:
925 if(SfxItemState::DEFAULT == eState)
927 if(mpStyleItem && drawing::FillStyle_HATCH == (drawing::FillStyle)mpStyleItem->GetValue())
929 if(mpHatchItem)
931 const OUString aString( mpHatchItem->GetName() );
932 const SfxObjectShell* pSh = SfxObjectShell::Current();
933 const SvxHatchListItem aItem(*static_cast<const SvxHatchListItem*>(pSh->GetItem(SID_HATCH_LIST)));
935 mpLbFillAttr->Clear();
936 mpLbFillAttr->Enable();
937 mpLbFillAttr->Fill(aItem.GetHatchList());
938 mpLbFillAttr->SelectEntry(aString);
940 else
942 mpLbFillAttr->SetNoSelection();
946 break;
948 case SID_BITMAP_LIST:
950 if(SfxItemState::DEFAULT == eState)
952 if(mpStyleItem && drawing::FillStyle_BITMAP == (drawing::FillStyle)mpStyleItem->GetValue())
954 if(mpBitmapItem)
956 const OUString aString( mpBitmapItem->GetName() );
957 const SfxObjectShell* pSh = SfxObjectShell::Current();
958 const SvxBitmapListItem aItem(*static_cast<const SvxBitmapListItem*>(pSh->GetItem(SID_BITMAP_LIST)));
960 mpLbFillAttr->Clear();
961 mpLbFillAttr->Enable();
962 mpLbFillAttr->Fill(aItem.GetBitmapList());
963 mpLbFillAttr->SelectEntry(aString);
965 else
967 mpLbFillAttr->SetNoSelection();
971 break;
981 void AreaPropertyPanel::Update()
983 if(mpStyleItem)
985 const drawing::FillStyle eXFS = (drawing::FillStyle)mpStyleItem->GetValue();
986 SfxObjectShell* pSh = SfxObjectShell::Current();
988 switch( eXFS )
990 case drawing::FillStyle_NONE:
992 mpLbFillAttr->Show();
993 mpToolBoxColor->Hide();
994 break;
996 case drawing::FillStyle_SOLID:
998 if(mpColorItem)
1000 mpLbFillAttr->Hide();
1001 mpToolBoxColor->Show();
1003 break;
1005 case drawing::FillStyle_GRADIENT:
1007 mpLbFillAttr->Show();
1008 mpToolBoxColor->Hide();
1010 if(pSh && pSh->GetItem(SID_GRADIENT_LIST))
1012 const SvxGradientListItem aItem(*static_cast<const SvxGradientListItem*>(pSh->GetItem(SID_GRADIENT_LIST)));
1013 mpLbFillAttr->Enable();
1014 mpLbFillAttr->Clear();
1015 mpLbFillAttr->Fill(aItem.GetGradientList());
1017 if(mpFillGradientItem)
1019 const OUString aString(mpFillGradientItem->GetName());
1021 mpLbFillAttr->SelectEntry(aString);
1023 else
1025 mpLbFillAttr->SetNoSelection();
1028 else
1030 mpLbFillAttr->SetNoSelection();
1032 break;
1034 case drawing::FillStyle_HATCH:
1036 mpLbFillAttr->Show();
1037 mpToolBoxColor->Hide();
1039 if(pSh && pSh->GetItem(SID_HATCH_LIST))
1041 const SvxHatchListItem aItem(*static_cast<const SvxHatchListItem*>(pSh->GetItem(SID_HATCH_LIST)));
1042 mpLbFillAttr->Enable();
1043 mpLbFillAttr->Clear();
1044 mpLbFillAttr->Fill(aItem.GetHatchList());
1046 if(mpHatchItem)
1048 const OUString aString(mpHatchItem->GetName());
1050 mpLbFillAttr->SelectEntry( aString );
1052 else
1054 mpLbFillAttr->SetNoSelection();
1057 else
1059 mpLbFillAttr->SetNoSelection();
1061 break;
1063 case drawing::FillStyle_BITMAP:
1065 mpLbFillAttr->Show();
1066 mpToolBoxColor->Hide();
1068 if(pSh && pSh->GetItem(SID_BITMAP_LIST))
1070 const SvxBitmapListItem aItem(*static_cast<const SvxBitmapListItem*>(pSh->GetItem(SID_BITMAP_LIST)));
1071 mpLbFillAttr->Enable();
1072 mpLbFillAttr->Clear();
1073 mpLbFillAttr->Fill(aItem.GetBitmapList());
1075 if(mpBitmapItem)
1077 const OUString aString(mpBitmapItem->GetName());
1079 mpLbFillAttr->SelectEntry(aString);
1081 else
1083 mpLbFillAttr->SetNoSelection();
1086 else
1088 mpLbFillAttr->SetNoSelection();
1090 break;
1092 default:
1093 OSL_ENSURE(false, "Non supported FillType (!)");
1094 break;
1101 IMPL_LINK_TYPED( AreaPropertyPanel, ClickTrGrHdl_Impl, ToolBox*, pToolBox, void )
1103 maTrGrPopup.Rearrange(mpFloatTransparenceItem.get());
1104 OSL_ASSERT( pToolBox->GetItemCommand(pToolBox->GetCurItemId()) == UNO_SIDEBARGRADIENT);
1105 maTrGrPopup.Show(*pToolBox);
1110 IMPL_LINK_NOARG(AreaPropertyPanel, ChangeTrgrTypeHdl_Impl)
1112 sal_Int32 nSelectType = mpLBTransType->GetSelectEntryPos();
1113 bool bGradient = false;
1114 sal_uInt16 nTrans = 0;
1116 if(!nSelectType)
1118 mpBTNGradient->Hide();
1119 mpMTRTransparent->Show();
1120 mpMTRTransparent->Enable();
1121 mpMTRTransparent->SetValue(0);
1123 else if(1 == nSelectType)
1125 mpBTNGradient->Hide();
1126 mpMTRTransparent->Show();
1127 nTrans = mnLastTransSolid;
1128 mpMTRTransparent->SetValue(nTrans);
1129 mpLBTransType->SelectEntryPos(1);
1130 mpMTRTransparent->Enable();
1132 else
1134 mpBTNGradient->Show();
1136 const sal_uInt16 nIdGradient = mpBTNGradient->GetItemId(UNO_SIDEBARGRADIENT);
1137 switch (nSelectType)
1139 case 2:
1140 mpBTNGradient->SetItemImage(nIdGradient, maImgLinear);
1141 break;
1142 case 3:
1143 mpBTNGradient->SetItemImage(nIdGradient, maImgAxial);
1144 break;
1145 case 4:
1146 mpBTNGradient->SetItemImage(nIdGradient, maImgRadial);
1147 break;
1148 case 5:
1149 mpBTNGradient->SetItemImage(nIdGradient, maImgElli );
1150 break;
1151 case 6:
1152 mpBTNGradient->SetItemImage(nIdGradient, maImgQuad );
1153 break;
1154 case 7:
1155 mpBTNGradient->SetItemImage(nIdGradient, maImgSquare);
1156 break;
1159 mpMTRTransparent->Hide();
1160 mpBTNGradient->Enable();
1161 bGradient = true;
1164 const XFillTransparenceItem aLinearItem(nTrans);
1165 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_TRANSPARENCE, SfxCallMode::RECORD, &aLinearItem, 0L );
1167 if(nSelectType > 1)
1169 nSelectType -= 2;
1172 XGradient aTmpGradient;
1174 switch(nSelectType)
1176 case css::awt::GradientStyle_LINEAR:
1177 aTmpGradient = maGradientLinear;
1178 break;
1179 case css::awt::GradientStyle_AXIAL:
1180 aTmpGradient = maGradientAxial;
1181 break;
1182 case css::awt::GradientStyle_RADIAL:
1183 aTmpGradient = maGradientRadial;
1184 break;
1185 case css::awt::GradientStyle_ELLIPTICAL:
1186 aTmpGradient = maGradientElliptical;
1187 break;
1188 case css::awt::GradientStyle_SQUARE:
1189 aTmpGradient = maGradientSquare;
1190 break;
1191 case css::awt::GradientStyle_RECT:
1192 aTmpGradient = maGradientRect;
1193 break;
1194 default:
1195 break;
1198 SfxItemPool* pPool = 0;
1199 const XFillFloatTransparenceItem aGradientItem(pPool, aTmpGradient, bGradient);
1200 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_FLOATTRANSPARENCE, SfxCallMode::RECORD, &aGradientItem, 0L );
1202 return 0L;
1207 IMPL_LINK_NOARG(AreaPropertyPanel, ModifyTransparentHdl_Impl)
1209 const sal_uInt16 nTrans = (sal_uInt16)mpMTRTransparent->GetValue();
1210 mnLastTransSolid = nTrans;
1211 const sal_Int32 nSelectType = mpLBTransType->GetSelectEntryPos();
1213 if(nTrans && !nSelectType)
1215 mpLBTransType->SelectEntryPos(1);
1218 const XFillTransparenceItem aLinearItem(nTrans);
1219 GetBindings()->GetDispatcher()->Execute( SID_ATTR_FILL_TRANSPARENCE, SfxCallMode::RECORD, &aLinearItem, 0L );
1221 return 0L;
1229 XGradient AreaPropertyPanel::GetGradient (const css::awt::GradientStyle eStyle) const
1231 switch (eStyle)
1233 default:
1234 case css::awt::GradientStyle_LINEAR:
1235 return maGradientLinear;
1236 case css::awt::GradientStyle_AXIAL:
1237 return maGradientAxial;
1238 case css::awt::GradientStyle_RADIAL:
1239 return maGradientRadial;
1240 case css::awt::GradientStyle_ELLIPTICAL:
1241 return maGradientElliptical;
1242 case css::awt::GradientStyle_SQUARE:
1243 return maGradientSquare;
1244 case css::awt::GradientStyle_RECT:
1245 return maGradientRect;
1252 void AreaPropertyPanel::SetGradient (const XGradient& rGradient)
1254 switch (rGradient.GetGradientStyle())
1256 case css::awt::GradientStyle_LINEAR:
1257 maGradientLinear = rGradient;
1258 break;
1259 case css::awt::GradientStyle_AXIAL:
1260 maGradientAxial = rGradient;
1261 break;
1262 case css::awt::GradientStyle_RADIAL:
1263 maGradientRadial = rGradient;
1264 break;
1265 case css::awt::GradientStyle_ELLIPTICAL:
1266 maGradientElliptical = rGradient;
1267 break;
1268 case css::awt::GradientStyle_SQUARE:
1269 maGradientSquare = rGradient;
1270 break;
1271 case css::awt::GradientStyle_RECT:
1272 maGradientRect = rGradient;
1273 break;
1274 default:
1275 break;
1282 sal_Int32 AreaPropertyPanel::GetSelectedTransparencyTypeIndex() const
1284 return mpLBTransType->GetSelectEntryPos();
1287 } } // end of namespace svx::sidebar
1289 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */