23#include <rtl/ustring.hxx>
28#include <svx/svxids.hrc>
63drawing::FillStyle toCssFillStyle( eFillStyle eXFS )
67 return drawing::FillStyle_BITMAP;
70 return static_cast<drawing::FillStyle
>(eXFS);
82 , mxFillControl(nullptr)
83 , mpLbFillType(nullptr)
84 , mpToolBoxColor(nullptr)
85 , mpLbFillAttr(nullptr)
87 , mnLastPosGradient(0)
92 addStatusListener(
".uno:FillColor");
93 addStatusListener(
".uno:FillGradient");
94 addStatusListener(
".uno:FillHatch");
95 addStatusListener(
".uno:FillBitmap");
96 addStatusListener(
".uno:ColorTableState");
97 addStatusListener(
".uno:GradientListState");
98 addStatusListener(
".uno:HatchListState");
99 addStatusListener(
".uno:BitmapListState");
111 const bool bDisabled(SfxItemState::DISABLED == eState);
115 case SID_ATTR_FILL_STYLE:
129 if(eState >= SfxItemState::DEFAULT)
138 mnLastXFS = sal::static_int_cast< sal_Int32 >(eXFS);
141 if(drawing::FillStyle_NONE == eXFS)
162 case SID_ATTR_FILL_COLOR:
164 if(SfxItemState::DEFAULT == eState)
179 case SID_ATTR_FILL_GRADIENT:
181 if(SfxItemState::DEFAULT == eState)
192 if(SfxItemState::DEFAULT == eState)
197 else if(SfxItemState::DISABLED == eState )
209 case SID_ATTR_FILL_HATCH:
211 if(SfxItemState::DEFAULT == eState)
222 if(SfxItemState::DEFAULT == eState)
227 else if(SfxItemState::DISABLED == eState )
239 case SID_ATTR_FILL_BITMAP:
241 if(SfxItemState::DEFAULT == eState)
252 if(SfxItemState::DEFAULT == eState)
257 else if(SfxItemState::DISABLED == eState )
269 case SID_GRADIENT_LIST:
271 if(SfxItemState::DEFAULT == eState)
296 if(SfxItemState::DEFAULT == eState)
319 case SID_BITMAP_LIST:
321 if(SfxItemState::DEFAULT == eState)
352 const drawing::FillStyle eXFS =
mpStyleItem->GetValue();
357 case drawing::FillStyle_NONE:
364 case drawing::FillStyle_SOLID:
374 case drawing::FillStyle_GRADIENT:
380 if(pSh && pSh->
GetItem(SID_GRADIENT_LIST))
410 xGradientList->Insert(std::make_unique<XGradientEntry>(
mpFillGradientItem->GetGradientValue(), aTmpStr));
411 xGradientList->SetDirty(
false );
412 const BitmapEx aBmp = xGradientList->GetUiBitmap( 0 );
418 pVD->SetOutputSizePixel(aBmpSize,
false);
419 pVD->DrawBitmapEx(
Point(), aBmp);
437 case drawing::FillStyle_HATCH:
443 if(pSh && pSh->
GetItem(SID_HATCH_LIST))
473 xHatchList->Insert(std::make_unique<XHatchEntry>(
mpHatchItem->GetHatchValue(), aTmpStr));
474 xHatchList->SetDirty(
false );
475 const BitmapEx & aBmp = xHatchList->GetUiBitmap( 0 );
481 pVD->SetOutputSizePixel(aBmpSize,
false);
482 pVD->DrawBitmapEx(
Point(), aBmp);
499 case drawing::FillStyle_BITMAP:
539 xBitmapList->Insert(std::make_unique<XBitmapEntry>(
mpBitmapItem->GetGraphicObject(), aTmpStr));
540 xBitmapList->SetDirty(
false );
568 OSL_ENSURE(
false,
"Non supported FillType (!)");
595 , mxLbFillType(m_xBuilder->weld_combo_box(
"type"))
596 , mxToolBoxColor(m_xBuilder->weld_toolbar(
"color"))
598 , mxLbFillAttr(m_xBuilder->weld_combo_box(
"attr"))
620 rJsonWriter.put(
"command",
".uno:FillStyle");
637 sal_uInt16 nCode = rKeyCode.
GetCode();
641 mxLbFillType->set_active(mnTypeCurPos);
649 return ChildKeyInput(rKEvt);
650 if (mxLbFillAttr->get_visible() && !mxLbFillAttr->get_sensitive())
651 return ChildKeyInput(rKEvt);
657 mnTypeCurPos = mxLbFillType->get_active();
662 mnAttrCurPos = mxLbFillAttr->get_active();
668 sal_uInt16 nCode = rKeyCode.
GetCode();
672 mxLbFillAttr->set_active(mnAttrCurPos);
677 return ChildKeyInput(rKEvt);
682 return ChildKeyInput(rKEvt);
701 sal_Int32 nXFS = mpLbFillType->get_active();
703 if(mnLastXFS == nXFS)
706 eFillStyle eXFS =
static_cast<eFillStyle
>(nXFS);
707 mpLbFillAttr->clear();
720 mpLbFillAttr->show();
721 mpToolBoxColor->hide();
722 mpLbFillAttr->set_sensitive(
false);
727 SID_ATTR_FILL_STYLE, SfxCallMode::RECORD,
728 { &aXFillStyleItem });
734 mpLbFillAttr->hide();
735 mpToolBoxColor->show();
738 const ::Color aColor = mpColorItem ? mpColorItem->GetColorValue() :
COL_AUTO;
743 SID_ATTR_FILL_COLOR, SfxCallMode::RECORD,
744 { &aXFillColorItem, &aXFillStyleItem });
750 mpLbFillAttr->show();
751 mpToolBoxColor->hide();
753 if(pSh && pSh->
GetItem(SID_GRADIENT_LIST))
755 if(!mpLbFillAttr->get_count())
757 mpLbFillAttr->set_sensitive(
true);
758 mpLbFillAttr->clear();
762 if (mnLastPosGradient != -1)
766 if(mnLastPosGradient < pItem->GetGradientList()->
Count())
769 const XFillGradientItem aXFillGradientItem(mpLbFillAttr->get_text(mnLastPosGradient), aGradient);
773 SID_ATTR_FILL_GRADIENT, SfxCallMode::RECORD,
774 { &aXFillGradientItem, &aXFillStyleItem });
775 mpLbFillAttr->set_active(mnLastPosGradient);
781 mpLbFillAttr->set_sensitive(
false);
787 mpLbFillAttr->show();
788 mpToolBoxColor->hide();
790 if(pSh && pSh->
GetItem(SID_HATCH_LIST))
792 if(!mpLbFillAttr->get_count())
794 mpLbFillAttr->set_sensitive(
true);
795 mpLbFillAttr->clear();
799 if (mnLastPosHatch != -1)
803 if(mnLastPosHatch < pItem->GetHatchList()->
Count())
806 const XFillHatchItem aXFillHatchItem(mpLbFillAttr->get_active_text(), aHatch);
810 SID_ATTR_FILL_HATCH, SfxCallMode::RECORD,
811 { &aXFillHatchItem, &aXFillStyleItem });
812 mpLbFillAttr->set_active(mnLastPosHatch);
818 mpLbFillAttr->set_sensitive(
false);
824 mpLbFillAttr->show();
825 mpToolBoxColor->hide();
827 if(pSh && pSh->
GetItem(SID_BITMAP_LIST))
829 if(!mpLbFillAttr->get_count())
831 mpLbFillAttr->set_sensitive(
true);
832 mpLbFillAttr->clear();
836 if (mnLastPosBitmap != -1)
840 if(mnLastPosBitmap < pItem->GetBitmapList()->
Count())
847 SID_ATTR_FILL_BITMAP, SfxCallMode::RECORD,
848 { &aXFillBitmapItem, &aXFillStyleItem });
849 mpLbFillAttr->set_active(mnLastPosBitmap);
855 mpLbFillAttr->set_sensitive(
false);
861 mpLbFillAttr->show();
862 mpToolBoxColor->hide();
864 if(pSh && pSh->
GetItem(SID_PATTERN_LIST))
866 if(!mpLbFillAttr->get_count())
868 mpLbFillAttr->set_sensitive(
true);
869 mpLbFillAttr->clear();
873 if (mnLastPosPattern != -1)
877 if(mnLastPosPattern < pItem->GetPatternList()->
Count())
884 SID_ATTR_FILL_BITMAP, SfxCallMode::RECORD,
885 { &aXFillBitmapItem, &aXFillStyleItem });
886 mpLbFillAttr->set_active(mnLastPosPattern);
892 mpLbFillAttr->set_sensitive(
false);
901 mxFillControl->Resize();
906 sal_Int32 nXFS = mpLbFillType->get_active();
907 eFillStyle eXFS =
static_cast<eFillStyle
>(nXFS);
914 const bool bFillStyleChange(mnLastXFS != nXFS);
920 if (bFillStyleChange && pSh)
924 SID_ATTR_FILL_STYLE, SfxCallMode::RECORD,
925 { &aXFillStyleItem });
931 sal_Int32
nPos = mpLbFillAttr->get_active();
935 nPos = mnLastPosGradient;
938 if (
nPos != -1 && pSh && pSh->
GetItem(SID_GRADIENT_LIST))
942 if(nPos < pItem->GetGradientList()->
Count())
945 const XFillGradientItem aXFillGradientItem(mpLbFillAttr->get_active_text(), aGradient);
949 SID_ATTR_FILL_GRADIENT, SfxCallMode::RECORD,
951 ? std::initializer_list<SfxPoolItem const*>{ &aXFillGradientItem, &aXFillStyleItem }
952 : std::initializer_list<SfxPoolItem const*>{ &aXFillGradientItem });
958 mnLastPosGradient =
nPos;
964 sal_Int32
nPos = mpLbFillAttr->get_active();
968 nPos = mnLastPosHatch;
971 if (
nPos != -1 && pSh && pSh->
GetItem(SID_HATCH_LIST))
975 if(nPos < pItem->GetHatchList()->
Count())
978 const XFillHatchItem aXFillHatchItem( mpLbFillAttr->get_active_text(), aHatch);
982 SID_ATTR_FILL_HATCH, SfxCallMode::RECORD,
984 ? std::initializer_list<SfxPoolItem const*>{ &aXFillHatchItem, &aXFillStyleItem }
985 : std::initializer_list<SfxPoolItem const*>{ &aXFillHatchItem });
991 mnLastPosHatch =
nPos;
997 sal_Int32
nPos = mpLbFillAttr->get_active();
1001 nPos = mnLastPosBitmap;
1004 if (
nPos != -1 && pSh && pSh->
GetItem(SID_BITMAP_LIST))
1008 if(nPos < pItem->GetBitmapList()->
Count())
1015 SID_ATTR_FILL_BITMAP, SfxCallMode::RECORD,
1017 ? std::initializer_list<SfxPoolItem const*>{ &aXFillBitmapItem, &aXFillStyleItem }
1018 : std::initializer_list<SfxPoolItem const*>{ &aXFillBitmapItem });
1024 mnLastPosBitmap =
nPos;
1030 sal_Int32
nPos = mpLbFillAttr->get_active();
1034 nPos = mnLastPosPattern;
1037 if (
nPos != -1 && pSh && pSh->
GetItem(SID_PATTERN_LIST))
1041 if(nPos < pItem->GetPatternList()->
Count())
1048 SID_ATTR_FILL_BITMAP, SfxCallMode::RECORD,
1050 ? std::initializer_list<SfxPoolItem const*>{ &aXFillBitmapItem, &aXFillStyleItem }
1051 : std::initializer_list<SfxPoolItem const*>{ &aXFillBitmapItem });
1057 mnLastPosPattern =
nPos;
1071 auto nHeight = std::max(aSize.
Height(), aFirstSize.
Height());
1079 if((rDCEvt.
GetType() == DataChangedEventType::SETTINGS) &&
1080 (rDCEvt.
GetFlags() & AllSettingsFlags::STYLE))
css::uno::Reference< css::lang::XComponent > m_xFrame
const Size & GetSizePixel() const
DataChangedEventType GetType() const
AllSettingsFlags GetFlags() const
std::unique_ptr< ToolbarUnoDispatcher > mxColorDispatch
virtual void dispose() override
virtual void GetFocus() override
std::unique_ptr< weld::ComboBox > mxLbFillType
std::unique_ptr< weld::Toolbar > mxToolBoxColor
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
static void ReleaseFocus_Impl()
FillControl(vcl::Window *pParent, const css::uno::Reference< css::frame::XFrame > &rFrame)
std::unique_ptr< weld::ComboBox > mxLbFillAttr
virtual ~FillControl() override
virtual void dispose() override
virtual void GetFocus() override
std::unique_ptr< weld::Container > m_xContainer
void InitControlBase(weld::Widget *pWidget)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
SfxDispatcher * GetDispatcher() const
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
vcl::Window * GetWindow() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const XBitmapListRef & GetBitmapList() const
const XGradientListRef & GetGradientList() const
const XHatchListRef & GetHatchList() const
const XPatternListRef & GetPatternList() const
void reset(reference_type *pBody)
reference_type * get() const
const GraphicObject & GetGraphicObject() const
virtual XFillStyleItem * Clone(SfxItemPool *pPool=nullptr) const override
static XPropertyListRef CreatePropertyList(XPropertyListType t, const OUString &rPath, const OUString &rReferer)
static XBitmapListRef AsBitmapList(rtl::Reference< XPropertyList > const &plist)
sal_uInt16 GetCode() const
Point LogicToPixel(const Point &rLogicPt) const
virtual void SetSizePixel(const Size &rNewSize)
virtual void DataChanged(const DataChangedEvent &rDCEvt)
virtual OUString get_active_text() const=0
void append(const weld::ComboBoxEntry &rItem)
virtual void set_active(int pos)=0
virtual OUString get_text(int pos) const=0
virtual void remove(int pos)=0
virtual int get_count() const=0
void set_active_text(const OUString &rStr)
void connect_changed(const Link< ComboBox &, void > &rLink)
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr OUStringLiteral TMP_STR_END
SFX_IMPL_TOOLBOX_CONTROL(SvxFillToolBoxControl, XFillStyleItem)
IMPL_STATIC_LINK(FillControl, DumpAsPropertyTreeHdl, tools::JsonWriter &, rJsonWriter, void)
IMPL_LINK_NOARG(FillControl, TypeFocusHdl, weld::Widget &, void)
constexpr OUStringLiteral TMP_STR_BEGIN
IMPL_LINK(FillControl, TypeKeyInputHdl, const KeyEvent &, rKEvt, bool)
constexpr sal_uInt16 KEY_ESCAPE
constexpr sal_uInt16 KEY_TAB
#define LINK(Instance, Class, Member)
SVX_DLLPUBLIC void Fill(weld::ComboBox &, const XHatchListRef &pList)
SVX_DLLPUBLIC void Fill(weld::ComboBox &rListBox)
constexpr OUStringLiteral PATTERN