1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <sfx2/app.hxx>
22 #include <sfx2/dispatch.hxx>
23 #include <sfx2/objsh.hxx>
24 #include <sfx2/viewfrm.hxx>
25 #include <sfx2/viewsh.hxx>
26 #include <sfx2/sidebar/SidebarToolBox.hxx>
27 #include <rtl/ustring.hxx>
28 #include <vcl/event.hxx>
29 #include <vcl/settings.hxx>
30 #include <vcl/toolbox.hxx>
31 #include <svx/svxids.hrc>
33 #define TMP_STR_BEGIN "["
34 #define TMP_STR_END "]"
36 #include <svx/drawitem.hxx>
37 #include <svx/xfillit0.hxx>
38 #include <svx/xtable.hxx>
39 #include <svx/fillctrl.hxx>
40 #include <svx/itemwin.hxx>
41 #include <svx/xflclit.hxx>
42 #include <svx/xflgrit.hxx>
43 #include <svx/xflhtit.hxx>
44 #include <svx/xbtmpit.hxx>
48 using namespace ::com::sun::star
;
49 using namespace ::com::sun::star::uno
;
50 using namespace ::com::sun::star::util
;
51 using namespace ::com::sun::star::beans
;
52 using namespace ::com::sun::star::lang
;
54 SFX_IMPL_TOOLBOX_CONTROL( SvxFillToolBoxControl
, XFillStyleItem
);
56 SvxFillToolBoxControl::SvxFillToolBoxControl(
60 : SfxToolBoxControl( nSlotId
, nId
, rTbx
)
63 , mpFillGradientItem()
66 , mpFillControl(nullptr)
67 , mpLbFillType(nullptr)
68 , mpLbFillAttr(nullptr)
69 , meLastXFS(static_cast<drawing::FillStyle
>(-1))
70 , mnLastPosGradient(0)
74 addStatusListener( ".uno:FillColor");
75 addStatusListener( ".uno:FillGradient");
76 addStatusListener( ".uno:FillHatch");
77 addStatusListener( ".uno:FillBitmap");
78 addStatusListener( ".uno:ColorTableState");
79 addStatusListener( ".uno:GradientListState");
80 addStatusListener( ".uno:HatchListState");
81 addStatusListener( ".uno:BitmapListState");
84 SvxFillToolBoxControl::~SvxFillToolBoxControl()
88 void SvxFillToolBoxControl::StateChanged(
91 const SfxPoolItem
* pState
)
93 const bool bDisabled(SfxItemState::DISABLED
== eState
);
97 case SID_ATTR_FILL_STYLE
:
101 mpLbFillType
->Disable();
102 mpLbFillType
->SetNoSelection();
103 mpLbFillAttr
->Show();
104 mpLbFillAttr
->Disable();
105 mpLbFillAttr
->SetNoSelection();
106 mpToolBoxColor
->Hide();
107 meLastXFS
= static_cast<drawing::FillStyle
>(-1);
111 if(eState
>= SfxItemState::DEFAULT
)
113 const XFillStyleItem
* pItem
= dynamic_cast< const XFillStyleItem
* >(pState
);
117 mpStyleItem
.reset(dynamic_cast< XFillStyleItem
* >(pItem
->Clone()));
118 mpLbFillType
->Enable();
119 drawing::FillStyle eXFS
= mpStyleItem
->GetValue();
121 mpLbFillType
->SelectEntryPos(sal::static_int_cast
< sal_Int32
>(eXFS
));
123 if(drawing::FillStyle_NONE
== eXFS
)
125 mpLbFillAttr
->SetNoSelection();
126 mpLbFillAttr
->Disable();
134 mpLbFillType
->SetNoSelection();
135 mpLbFillAttr
->Show();
136 mpLbFillAttr
->Disable();
137 mpLbFillAttr
->SetNoSelection();
138 mpToolBoxColor
->Hide();
139 meLastXFS
= static_cast<drawing::FillStyle
>(-1);
143 case SID_ATTR_FILL_COLOR
:
145 if(SfxItemState::DEFAULT
== eState
)
147 mpColorItem
.reset(pState
? static_cast<XFillColorItem
*>(pState
->Clone()) : nullptr);
150 if(mpStyleItem
&& drawing::FillStyle_SOLID
== mpStyleItem
->GetValue())
152 mpLbFillAttr
->Hide();
153 mpToolBoxColor
->Show();
159 case SID_ATTR_FILL_GRADIENT
:
161 if(SfxItemState::DEFAULT
== eState
)
163 mpFillGradientItem
.reset(pState
? static_cast<XFillGradientItem
*>(pState
->Clone()) : nullptr);
166 if(mpStyleItem
&& drawing::FillStyle_GRADIENT
== mpStyleItem
->GetValue())
168 mpLbFillAttr
->Show();
169 mpToolBoxColor
->Hide();
171 if(SfxItemState::DEFAULT
== eState
)
173 mpLbFillAttr
->Enable();
176 else if(SfxItemState::DISABLED
== eState
)
178 mpLbFillAttr
->Disable();
179 mpLbFillAttr
->SetNoSelection();
183 mpLbFillAttr
->SetNoSelection();
188 case SID_ATTR_FILL_HATCH
:
190 if(SfxItemState::DEFAULT
== eState
)
192 mpHatchItem
.reset(pState
? static_cast<XFillHatchItem
*>(pState
->Clone()) : nullptr);
195 if(mpStyleItem
&& drawing::FillStyle_HATCH
== mpStyleItem
->GetValue())
197 mpLbFillAttr
->Show();
198 mpToolBoxColor
->Hide();
200 if(SfxItemState::DEFAULT
== eState
)
202 mpLbFillAttr
->Enable();
205 else if(SfxItemState::DISABLED
== eState
)
207 mpLbFillAttr
->Disable();
208 mpLbFillAttr
->SetNoSelection();
212 mpLbFillAttr
->SetNoSelection();
217 case SID_ATTR_FILL_BITMAP
:
219 if(SfxItemState::DEFAULT
== eState
)
221 mpBitmapItem
.reset(pState
? static_cast<XFillBitmapItem
*>(pState
->Clone()) : nullptr);
224 if(mpStyleItem
&& drawing::FillStyle_BITMAP
== mpStyleItem
->GetValue())
226 mpLbFillAttr
->Show();
227 mpToolBoxColor
->Hide();
229 if(SfxItemState::DEFAULT
== eState
)
231 mpLbFillAttr
->Enable();
234 else if(SfxItemState::DISABLED
== eState
)
236 mpLbFillAttr
->Disable();
237 mpLbFillAttr
->SetNoSelection();
241 mpLbFillAttr
->SetNoSelection();
246 case SID_GRADIENT_LIST
:
248 if(SfxItemState::DEFAULT
== eState
)
250 if(mpStyleItem
&& drawing::FillStyle_GRADIENT
== mpStyleItem
->GetValue())
252 if(mpFillGradientItem
)
254 const OUString
aString( mpFillGradientItem
->GetName() );
255 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
257 mpLbFillAttr
->Clear();
258 mpLbFillAttr
->Enable();
259 mpLbFillAttr
->Fill(pSh
->GetItem(SID_GRADIENT_LIST
)->GetGradientList());
260 mpLbFillAttr
->SelectEntry(aString
);
264 mpLbFillAttr
->SetNoSelection();
272 if(SfxItemState::DEFAULT
== eState
)
274 if(mpStyleItem
&& drawing::FillStyle_HATCH
== mpStyleItem
->GetValue())
278 const OUString
aString( mpHatchItem
->GetName() );
279 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
281 mpLbFillAttr
->Clear();
282 mpLbFillAttr
->Enable();
283 mpLbFillAttr
->Fill(pSh
->GetItem(SID_HATCH_LIST
)->GetHatchList());
284 mpLbFillAttr
->SelectEntry(aString
);
288 mpLbFillAttr
->SetNoSelection();
294 case SID_BITMAP_LIST
:
296 if(SfxItemState::DEFAULT
== eState
)
298 if(mpStyleItem
&& drawing::FillStyle_BITMAP
== mpStyleItem
->GetValue())
302 const OUString
aString( mpBitmapItem
->GetName() );
303 const SfxObjectShell
* pSh
= SfxObjectShell::Current();
305 mpLbFillAttr
->Clear();
306 mpLbFillAttr
->Enable();
307 mpLbFillAttr
->Fill(pSh
->GetItem(SID_BITMAP_LIST
)->GetBitmapList());
308 mpLbFillAttr
->SelectEntry(aString
);
312 mpLbFillAttr
->SetNoSelection();
321 void SvxFillToolBoxControl::Update()
325 const drawing::FillStyle eXFS
= mpStyleItem
->GetValue();
326 SfxObjectShell
* pSh
= SfxObjectShell::Current();
330 case drawing::FillStyle_NONE
:
332 mpLbFillAttr
->Show();
333 mpToolBoxColor
->Hide();
336 case drawing::FillStyle_SOLID
:
340 mpLbFillAttr
->Hide();
341 mpToolBoxColor
->Show();
345 case drawing::FillStyle_GRADIENT
:
347 mpLbFillAttr
->Show();
348 mpToolBoxColor
->Hide();
350 if(pSh
&& pSh
->GetItem(SID_GRADIENT_LIST
))
352 mpLbFillAttr
->Enable();
353 mpLbFillAttr
->Clear();
354 mpLbFillAttr
->Fill(pSh
->GetItem(SID_GRADIENT_LIST
)->GetGradientList());
356 if(mpFillGradientItem
)
358 const OUString
aString(mpFillGradientItem
->GetName());
360 mpLbFillAttr
->SelectEntry(aString
);
362 // Check if the entry is not in the list
363 if (mpLbFillAttr
->GetSelectedEntry() != aString
)
365 sal_Int32 nCount
= mpLbFillAttr
->GetEntryCount();
369 // Last entry gets tested against temporary entry
370 aTmpStr
= mpLbFillAttr
->GetEntry( nCount
- 1 );
371 if( aTmpStr
.startsWith(TMP_STR_BEGIN
) &&
372 aTmpStr
.endsWith(TMP_STR_END
) )
374 mpLbFillAttr
->RemoveEntry(nCount
- 1);
377 aTmpStr
= TMP_STR_BEGIN
+ aString
+ TMP_STR_END
;
379 XGradientList
aGradientList( "", ""/*TODO?*/ );
380 aGradientList
.Insert(std::make_unique
<XGradientEntry
>(mpFillGradientItem
->GetGradientValue(), aTmpStr
));
381 aGradientList
.SetDirty( false );
382 const BitmapEx aBmp
= aGradientList
.GetUiBitmap( 0 );
386 mpLbFillAttr
->InsertEntry(aGradientList
.Get(0)->GetName(), Image(aBmp
));
387 mpLbFillAttr
->SelectEntryPos(mpLbFillAttr
->GetEntryCount() - 1);
394 mpLbFillAttr
->SetNoSelection();
399 mpLbFillAttr
->SetNoSelection();
403 case drawing::FillStyle_HATCH
:
405 mpLbFillAttr
->Show();
406 mpToolBoxColor
->Hide();
408 if(pSh
&& pSh
->GetItem(SID_HATCH_LIST
))
410 mpLbFillAttr
->Enable();
411 mpLbFillAttr
->Clear();
412 mpLbFillAttr
->Fill(pSh
->GetItem(SID_HATCH_LIST
)->GetHatchList());
416 const OUString
aString(mpHatchItem
->GetName());
418 mpLbFillAttr
->SelectEntry( aString
);
420 // Check if the entry is not in the list
421 if( mpLbFillAttr
->GetSelectedEntry() != aString
)
423 const sal_Int32 nCount
= mpLbFillAttr
->GetEntryCount();
427 // Last entry gets tested against temporary entry
428 aTmpStr
= mpLbFillAttr
->GetEntry( nCount
- 1 );
429 if( aTmpStr
.startsWith(TMP_STR_BEGIN
) &&
430 aTmpStr
.endsWith(TMP_STR_END
) )
432 mpLbFillAttr
->RemoveEntry( nCount
- 1 );
435 aTmpStr
= TMP_STR_BEGIN
+ aString
+ TMP_STR_END
;
437 XHatchList
aHatchList( "", ""/*TODO?*/ );
438 aHatchList
.Insert(std::make_unique
<XHatchEntry
>(mpHatchItem
->GetHatchValue(), aTmpStr
));
439 aHatchList
.SetDirty( false );
440 const BitmapEx
& aBmp
= aHatchList
.GetUiBitmap( 0 );
442 if( !aBmp
.IsEmpty() )
444 mpLbFillAttr
->InsertEntry(aHatchList
.GetHatch(0)->GetName(), Image(aBmp
));
445 mpLbFillAttr
->SelectEntryPos( mpLbFillAttr
->GetEntryCount() - 1 );
452 mpLbFillAttr
->SetNoSelection();
457 mpLbFillAttr
->SetNoSelection();
461 case drawing::FillStyle_BITMAP
:
463 mpLbFillAttr
->Show();
464 mpToolBoxColor
->Hide();
466 if(pSh
&& pSh
->GetItem(SID_BITMAP_LIST
))
468 mpLbFillAttr
->Enable();
469 mpLbFillAttr
->Clear();
470 mpLbFillAttr
->Fill(pSh
->GetItem(SID_BITMAP_LIST
)->GetBitmapList());
474 const OUString
aString(mpBitmapItem
->GetName());
476 mpLbFillAttr
->SelectEntry(aString
);
478 // Check if the entry is not in the list
479 if (mpLbFillAttr
->GetSelectedEntry() != aString
)
481 sal_Int32 nCount
= mpLbFillAttr
->GetEntryCount();
485 // Last entry gets tested against temporary entry
486 aTmpStr
= mpLbFillAttr
->GetEntry(nCount
- 1);
487 if( aTmpStr
.startsWith(TMP_STR_BEGIN
) &&
488 aTmpStr
.endsWith(TMP_STR_END
) )
490 mpLbFillAttr
->RemoveEntry(nCount
- 1);
493 aTmpStr
= TMP_STR_BEGIN
+ aString
+ TMP_STR_END
;
495 XBitmapListRef xBitmapList
=
496 XPropertyList::AsBitmapList(
497 XPropertyList::CreatePropertyList(
498 XPropertyListType::Bitmap
, "TmpList", ""/*TODO?*/));
499 xBitmapList
->Insert(std::make_unique
<XBitmapEntry
>(mpBitmapItem
->GetGraphicObject(), aTmpStr
));
500 xBitmapList
->SetDirty( false );
501 mpLbFillAttr
->Fill( xBitmapList
);
502 mpLbFillAttr
->SelectEntryPos(mpLbFillAttr
->GetEntryCount() - 1);
508 mpLbFillAttr
->SetNoSelection();
513 mpLbFillAttr
->SetNoSelection();
518 OSL_ENSURE(false, "Non supported FillType (!)");
525 VclPtr
<vcl::Window
> SvxFillToolBoxControl::CreateItemWindow(vcl::Window
*pParent
)
527 if(GetSlotId() == SID_ATTR_FILL_STYLE
)
529 mpFillControl
.reset(VclPtr
<FillControl
>::Create(pParent
));
531 mpLbFillType
= mpFillControl
->mpLbFillType
;
532 mpLbFillAttr
= mpFillControl
->mpLbFillAttr
;
533 mpToolBoxColor
= mpFillControl
->mpToolBoxColor
;
534 mpFillControl
->SetBackground();
535 mpFillControl
->SetPaintTransparent( true );
536 mpFillControl
->Resize();
537 mpToolBoxColor
->InsertItem(".uno:FillColor", m_xFrame
, ToolBoxItemBits::DROPDOWNONLY
, Size(mpToolBoxColor
->GetSizePixel().Width(), 0));
539 mpLbFillType
->SetSelectHdl(LINK(this,SvxFillToolBoxControl
,SelectFillTypeHdl
));
540 mpLbFillAttr
->SetSelectHdl(LINK(this,SvxFillToolBoxControl
,SelectFillAttrHdl
));
542 return mpFillControl
.get();
544 return mpFillControl
;
547 FillControl::FillControl(vcl::Window
* pParent
)
548 : Window(pParent
, WB_DIALOGCONTROL
)
549 , mpLbFillType(VclPtr
<SvxFillTypeBox
>::Create(this))
550 , mpToolBoxColor(VclPtr
<sfx2::sidebar::SidebarToolBox
>::Create(this))
551 , mpLbFillAttr(VclPtr
<SvxFillAttrBox
>::Create(this))
554 mpToolBoxColor
->set_id("colortoolbox");
557 FillControl::~FillControl()
562 void FillControl::dispose()
564 mpLbFillType
.disposeAndClear();
565 mpToolBoxColor
.disposeAndClear();
566 mpLbFillAttr
.disposeAndClear();
567 vcl::Window::dispose();
570 IMPL_LINK_NOARG(SvxFillToolBoxControl
, SelectFillTypeHdl
, ListBox
&, void)
572 const drawing::FillStyle eXFS
= static_cast<drawing::FillStyle
>(mpLbFillType
->GetSelectedEntryPos());
574 if(meLastXFS
!= eXFS
)
576 mpLbFillAttr
->Clear();
577 SfxObjectShell
* pSh
= SfxObjectShell::Current();
578 const XFillStyleItem
aXFillStyleItem(eXFS
);
580 // #i122676# Do no longer trigger two Execute calls, one for SID_ATTR_FILL_STYLE
581 // and one for setting the fill attribute itself, but add two SfxPoolItems to the
582 // call to get just one action at the SdrObject and to create only one Undo action, too.
583 // Checked that this works in all apps.
587 case drawing::FillStyle_NONE
:
589 mpLbFillAttr
->Show();
590 mpToolBoxColor
->Hide();
591 mpLbFillType
->Selected();
592 mpLbFillAttr
->Disable();
594 // #i122676# need to call a single SID_ATTR_FILL_STYLE change
595 SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
596 SID_ATTR_FILL_STYLE
, SfxCallMode::RECORD
,
597 { &aXFillStyleItem
});
600 case drawing::FillStyle_SOLID
:
602 mpLbFillAttr
->Hide();
603 mpToolBoxColor
->Show();
604 const OUString aTmpStr
;
605 const ::Color aColor
= mpColorItem
->GetColorValue();
606 const XFillColorItem
aXFillColorItem( aTmpStr
, aColor
);
608 // #i122676# change FillStyle and Color in one call
609 SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
610 SID_ATTR_FILL_COLOR
, SfxCallMode::RECORD
,
611 { &aXFillColorItem
, &aXFillStyleItem
});
614 case drawing::FillStyle_GRADIENT
:
616 mpLbFillAttr
->Show();
617 mpToolBoxColor
->Hide();
619 if(pSh
&& pSh
->GetItem(SID_GRADIENT_LIST
))
621 if(!mpLbFillAttr
->GetEntryCount())
623 mpLbFillAttr
->Enable();
624 mpLbFillAttr
->Clear();
625 mpLbFillAttr
->Fill(pSh
->GetItem(SID_GRADIENT_LIST
)->GetGradientList());
628 mpLbFillAttr
->AdaptDropDownLineCountToMaximum();
630 if(LISTBOX_ENTRY_NOTFOUND
!= mnLastPosGradient
)
632 const SvxGradientListItem
* pItem
= pSh
->GetItem(SID_GRADIENT_LIST
);
634 if(mnLastPosGradient
< pItem
->GetGradientList()->Count())
636 const XGradient aGradient
= pItem
->GetGradientList()->GetGradient(mnLastPosGradient
)->GetGradient();
637 const XFillGradientItem
aXFillGradientItem(mpLbFillAttr
->GetEntry(mnLastPosGradient
), aGradient
);
639 // #i122676# change FillStyle and Gradient in one call
640 SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
641 SID_ATTR_FILL_GRADIENT
, SfxCallMode::RECORD
,
642 { &aXFillGradientItem
, &aXFillStyleItem
});
643 mpLbFillAttr
->SelectEntryPos(mnLastPosGradient
);
649 mpLbFillAttr
->Disable();
653 case drawing::FillStyle_HATCH
:
655 mpLbFillAttr
->Show();
656 mpToolBoxColor
->Hide();
658 if(pSh
&& pSh
->GetItem(SID_HATCH_LIST
))
660 if(!mpLbFillAttr
->GetEntryCount())
662 mpLbFillAttr
->Enable();
663 mpLbFillAttr
->Clear();
664 mpLbFillAttr
->Fill(pSh
->GetItem(SID_HATCH_LIST
)->GetHatchList());
667 mpLbFillAttr
->AdaptDropDownLineCountToMaximum();
669 if(LISTBOX_ENTRY_NOTFOUND
!= mnLastPosHatch
)
671 const SvxHatchListItem
* pItem
= pSh
->GetItem(SID_HATCH_LIST
);
673 if(mnLastPosHatch
< pItem
->GetHatchList()->Count())
675 const XHatch aHatch
= pItem
->GetHatchList()->GetHatch(mnLastPosHatch
)->GetHatch();
676 const XFillHatchItem
aXFillHatchItem(mpLbFillAttr
->GetSelectedEntry(), aHatch
);
678 // #i122676# change FillStyle and Hatch in one call
679 SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
680 SID_ATTR_FILL_HATCH
, SfxCallMode::RECORD
,
681 { &aXFillHatchItem
, &aXFillStyleItem
});
682 mpLbFillAttr
->SelectEntryPos(mnLastPosHatch
);
688 mpLbFillAttr
->Disable();
692 case drawing::FillStyle_BITMAP
:
694 mpLbFillAttr
->Show();
695 mpToolBoxColor
->Hide();
697 if(pSh
&& pSh
->GetItem(SID_BITMAP_LIST
))
699 if(!mpLbFillAttr
->GetEntryCount())
701 mpLbFillAttr
->Enable();
702 mpLbFillAttr
->Clear();
703 mpLbFillAttr
->Fill(pSh
->GetItem(SID_BITMAP_LIST
)->GetBitmapList());
706 mpLbFillAttr
->AdaptDropDownLineCountToMaximum();
708 if(LISTBOX_ENTRY_NOTFOUND
!= mnLastPosBitmap
)
710 const SvxBitmapListItem
* pItem
= pSh
->GetItem(SID_BITMAP_LIST
);
712 if(mnLastPosBitmap
< pItem
->GetBitmapList()->Count())
714 const XBitmapEntry
* pXBitmapEntry
= pItem
->GetBitmapList()->GetBitmap(mnLastPosBitmap
);
715 const XFillBitmapItem
aXFillBitmapItem(mpLbFillAttr
->GetSelectedEntry(), pXBitmapEntry
->GetGraphicObject());
717 // #i122676# change FillStyle and Bitmap in one call
718 SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
719 SID_ATTR_FILL_BITMAP
, SfxCallMode::RECORD
,
720 { &aXFillBitmapItem
, &aXFillStyleItem
});
721 mpLbFillAttr
->SelectEntryPos(mnLastPosBitmap
);
727 mpLbFillAttr
->Disable();
735 if(drawing::FillStyle_NONE
!= eXFS
)
737 mpLbFillType
->Selected();
742 IMPL_LINK_NOARG(SvxFillToolBoxControl
, SelectFillAttrHdl
, ListBox
&, void)
744 const drawing::FillStyle eXFS
= static_cast<drawing::FillStyle
>(mpLbFillType
->GetSelectedEntryPos());
745 const XFillStyleItem
aXFillStyleItem(eXFS
);
746 SfxObjectShell
* pSh
= SfxObjectShell::Current();
748 // #i122676# dependent from bFillStyleChange, do execute a single or two
749 // changes in one Execute call
750 const bool bFillStyleChange(meLastXFS
!= eXFS
);
754 case drawing::FillStyle_SOLID
:
758 // #i122676# Single FillStyle change call needed here
759 SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
760 SID_ATTR_FILL_STYLE
, SfxCallMode::RECORD
,
761 { &aXFillStyleItem
});
765 case drawing::FillStyle_GRADIENT
:
767 sal_Int32 nPos
= mpLbFillAttr
->GetSelectedEntryPos();
769 if(LISTBOX_ENTRY_NOTFOUND
== nPos
)
771 nPos
= mnLastPosGradient
;
774 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
&& pSh
&& pSh
->GetItem(SID_GRADIENT_LIST
))
776 const SvxGradientListItem
* pItem
= pSh
->GetItem(SID_GRADIENT_LIST
);
778 if(nPos
< pItem
->GetGradientList()->Count())
780 const XGradient aGradient
= pItem
->GetGradientList()->GetGradient(nPos
)->GetGradient();
781 const XFillGradientItem
aXFillGradientItem(mpLbFillAttr
->GetSelectedEntry(), aGradient
);
783 // #i122676# Change FillStyle and Gradinet in one call
784 SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
785 SID_ATTR_FILL_GRADIENT
, SfxCallMode::RECORD
,
787 ? std::initializer_list
<SfxPoolItem
const*>{ &aXFillGradientItem
, &aXFillStyleItem
}
788 : std::initializer_list
<SfxPoolItem
const*>{ &aXFillGradientItem
});
792 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
794 mnLastPosGradient
= nPos
;
798 case drawing::FillStyle_HATCH
:
800 sal_Int32 nPos
= mpLbFillAttr
->GetSelectedEntryPos();
802 if(LISTBOX_ENTRY_NOTFOUND
== nPos
)
804 nPos
= mnLastPosHatch
;
807 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
&& pSh
&& pSh
->GetItem(SID_HATCH_LIST
))
809 const SvxHatchListItem
* pItem
= pSh
->GetItem(SID_HATCH_LIST
);
811 if(nPos
< pItem
->GetHatchList()->Count())
813 const XHatch aHatch
= pItem
->GetHatchList()->GetHatch(nPos
)->GetHatch();
814 const XFillHatchItem
aXFillHatchItem( mpLbFillAttr
->GetSelectedEntry(), aHatch
);
816 // #i122676# Change FillStyle and Hatch in one call
817 SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
818 SID_ATTR_FILL_HATCH
, SfxCallMode::RECORD
,
820 ? std::initializer_list
<SfxPoolItem
const*>{ &aXFillHatchItem
, &aXFillStyleItem
}
821 : std::initializer_list
<SfxPoolItem
const*>{ &aXFillHatchItem
});
825 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
827 mnLastPosHatch
= nPos
;
831 case drawing::FillStyle_BITMAP
:
833 sal_Int32 nPos
= mpLbFillAttr
->GetSelectedEntryPos();
835 if(LISTBOX_ENTRY_NOTFOUND
== nPos
)
837 nPos
= mnLastPosBitmap
;
840 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
&& pSh
&& pSh
->GetItem(SID_BITMAP_LIST
))
842 const SvxBitmapListItem
* pItem
= pSh
->GetItem(SID_BITMAP_LIST
);
844 if(nPos
< pItem
->GetBitmapList()->Count())
846 const XBitmapEntry
* pXBitmapEntry
= pItem
->GetBitmapList()->GetBitmap(nPos
);
847 const XFillBitmapItem
aXFillBitmapItem(mpLbFillAttr
->GetSelectedEntry(), pXBitmapEntry
->GetGraphicObject());
849 // #i122676# Change FillStyle and Bitmap in one call
850 SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
851 SID_ATTR_FILL_BITMAP
, SfxCallMode::RECORD
,
853 ? std::initializer_list
<SfxPoolItem
const*>{ &aXFillBitmapItem
, &aXFillStyleItem
}
854 : std::initializer_list
<SfxPoolItem
const*>{ &aXFillBitmapItem
});
858 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
860 mnLastPosBitmap
= nPos
;
868 void FillControl::Resize()
870 Size
aSize(GetOutputSizePixel());
871 long nH
= aSize
.Height();
873 Size
aTypeSize(mpLbFillType
->get_preferred_size());
874 long nPrefHeight
= aTypeSize
.Height();
875 long nOffset
= (nH
- nPrefHeight
)/2;
876 mpLbFillType
->SetPosSizePixel(Point(0, nOffset
), Size(aTypeSize
.Width(), nPrefHeight
));
877 nPrefHeight
= mpToolBoxColor
->get_preferred_size().Height();
878 nOffset
= (nH
- nPrefHeight
)/2;
879 mpToolBoxColor
->SetPosSizePixel(Point(aTypeSize
.Width(), nOffset
),Size(aSize
.Width() - aTypeSize
.Width(), nPrefHeight
));
880 nPrefHeight
= mpLbFillType
->get_preferred_size().Height();
881 nOffset
= (nH
- nPrefHeight
)/2;
882 mpLbFillAttr
->SetPosSizePixel(Point(aTypeSize
.Width(), nOffset
),Size(aSize
.Width() - aTypeSize
.Width(), nPrefHeight
));
885 void FillControl::SetOptimalSize()
887 Size
aSize(mpLbFillType
->get_preferred_size());
888 Size
aFirstSize(mpToolBoxColor
->get_preferred_size());
889 Size
aSecondSize(mpLbFillAttr
->get_preferred_size());
890 aSize
.setHeight(std::max({aSize
.Height(), aFirstSize
.Height(), aSecondSize
.Height()}));
891 aSize
.setWidth(aSize
.Width() + LogicToPixel(Size(55, 0), MapMode(MapUnit::MapAppFont
)).Width());
895 void FillControl::DataChanged(const DataChangedEvent
& rDCEvt
)
897 if((rDCEvt
.GetType() == DataChangedEventType::SETTINGS
) &&
898 (rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
))
902 Window::DataChanged(rDCEvt
);
905 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */