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 .
20 #include "AreaPropertyPanel.hxx"
21 #include <svx/svxids.hrc>
22 #include <svx/xfltrit.hxx>
23 #include <svx/xflftrit.hxx>
24 #include <sfx2/dispatch.hxx>
25 #include <sfx2/bindings.hxx>
26 #include <svl/itemset.hxx>
30 using namespace css::uno
;
32 namespace svx::sidebar
{
34 AreaPropertyPanel::AreaPropertyPanel(
35 weld::Widget
* pParent
,
36 const css::uno::Reference
<css::frame::XFrame
>& rxFrame
,
37 SfxBindings
* pBindings
)
38 : AreaPropertyPanelBase(pParent
, rxFrame
),
39 maStyleControl(SID_ATTR_FILL_STYLE
, *pBindings
, *this),
40 maColorControl(SID_ATTR_FILL_COLOR
, *pBindings
, *this),
41 maGradientControl(SID_ATTR_FILL_GRADIENT
, *pBindings
, *this),
42 maHatchControl(SID_ATTR_FILL_HATCH
, *pBindings
, *this),
43 maBitmapControl(SID_ATTR_FILL_BITMAP
, *pBindings
, *this),
44 maGradientListControl(SID_GRADIENT_LIST
, *pBindings
, *this),
45 maHatchListControl(SID_HATCH_LIST
, *pBindings
, *this),
46 maBitmapListControl(SID_BITMAP_LIST
, *pBindings
, *this),
47 maPatternListControl(SID_PATTERN_LIST
, *pBindings
, *this),
48 maFillTransparenceController(SID_ATTR_FILL_TRANSPARENCE
, *pBindings
, *this),
49 maFillFloatTransparenceController(SID_ATTR_FILL_FLOATTRANSPARENCE
, *pBindings
, *this),
50 maFillUseSlideBackgroundController(SID_ATTR_FILL_USE_SLIDE_BACKGROUND
, *pBindings
, *this),
55 AreaPropertyPanel::~AreaPropertyPanel()
57 maStyleControl
.dispose();
58 maColorControl
.dispose();
59 maGradientControl
.dispose();
60 maHatchControl
.dispose();
61 maBitmapControl
.dispose();
62 maGradientListControl
.dispose();
63 maHatchListControl
.dispose();
64 maBitmapListControl
.dispose();
65 maPatternListControl
.dispose();
66 maFillTransparenceController
.dispose();
67 maFillFloatTransparenceController
.dispose();
70 std::unique_ptr
<PanelLayout
> AreaPropertyPanel::Create (
71 weld::Widget
* pParent
,
72 const css::uno::Reference
<css::frame::XFrame
>& rxFrame
,
73 SfxBindings
* pBindings
)
75 if (pParent
== nullptr)
76 throw lang::IllegalArgumentException(u
"no parent Window given to AreaPropertyPanel::Create"_ustr
, nullptr, 0);
78 throw lang::IllegalArgumentException(u
"no XFrame given to AreaPropertyPanel::Create"_ustr
, nullptr, 1);
79 if (pBindings
== nullptr)
80 throw lang::IllegalArgumentException(u
"no SfxBindings given to AreaPropertyPanel::Create"_ustr
, nullptr, 2);
82 return std::make_unique
<AreaPropertyPanel
>(pParent
, rxFrame
, pBindings
);
85 void AreaPropertyPanel::setFillTransparence(const XFillTransparenceItem
& rItem
)
87 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_FILL_TRANSPARENCE
,
88 SfxCallMode::RECORD
, { &rItem
});
91 void AreaPropertyPanel::setFillUseBackground(const XFillStyleItem
* pStyleItem
,
92 const XFillUseSlideBackgroundItem
& rItem
)
94 SfxPoolItemHolder aResult
;
95 auto pDispatcher
= GetBindings()->GetDispatcher();
96 auto state
= pDispatcher
->QueryState(SID_ATTR_FILL_USE_SLIDE_BACKGROUND
, aResult
);
97 // FillUseSlideBackground is only available in Impress
98 if (state
== SfxItemState::DISABLED
)
100 setFillStyle(*pStyleItem
);
104 pDispatcher
->ExecuteList(SID_ATTR_FILL_USE_SLIDE_BACKGROUND
, SfxCallMode::RECORD
,
105 std::initializer_list
<SfxPoolItem
const*>{ &rItem
, pStyleItem
});
109 void AreaPropertyPanel::setFillFloatTransparence(const XFillFloatTransparenceItem
& rItem
)
111 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_FILL_FLOATTRANSPARENCE
,
112 SfxCallMode::RECORD
, { &rItem
});
115 void AreaPropertyPanel::setFillStyle(const XFillStyleItem
& rItem
)
117 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_FILL_STYLE
,
118 SfxCallMode::RECORD
, { &rItem
});
121 void AreaPropertyPanel::setFillStyleAndColor(const XFillStyleItem
* pStyleItem
,
122 const XFillColorItem
& rColorItem
)
124 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_FILL_COLOR
,
125 SfxCallMode::RECORD
, pStyleItem
126 ? std::initializer_list
<SfxPoolItem
const*>{ &rColorItem
, pStyleItem
}
127 : std::initializer_list
<SfxPoolItem
const*>{ &rColorItem
});
130 void AreaPropertyPanel::setFillStyleAndGradient(const XFillStyleItem
* pStyleItem
,
131 const XFillGradientItem
& rGradientItem
)
133 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_FILL_GRADIENT
,
134 SfxCallMode::RECORD
, pStyleItem
135 ? std::initializer_list
<SfxPoolItem
const*>{ &rGradientItem
, pStyleItem
}
136 : std::initializer_list
<SfxPoolItem
const*>{ &rGradientItem
});
139 void AreaPropertyPanel::setFillStyleAndHatch(const XFillStyleItem
* pStyleItem
,
140 const XFillHatchItem
& rHatchItem
)
142 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_FILL_HATCH
,
143 SfxCallMode::RECORD
, pStyleItem
144 ? std::initializer_list
<SfxPoolItem
const*>{ &rHatchItem
, pStyleItem
}
145 : std::initializer_list
<SfxPoolItem
const*>{ &rHatchItem
});
148 void AreaPropertyPanel::setFillStyleAndBitmap(const XFillStyleItem
* pStyleItem
,
149 const XFillBitmapItem
& rBitmapItem
)
151 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_FILL_BITMAP
,
152 SfxCallMode::RECORD
, pStyleItem
153 ? std::initializer_list
<SfxPoolItem
const*>{ &rBitmapItem
, pStyleItem
}
154 : std::initializer_list
<SfxPoolItem
const*>{ &rBitmapItem
});
157 void AreaPropertyPanel::HandleContextChange(const vcl::EnumContext
& rContext
)
159 AreaPropertyPanelBase::HandleContextChange(rContext
);
160 if (rContext
.GetContext() != vcl::EnumContext::Context::Default
)
162 std::unique_ptr
<SfxPoolItem
> pFillState
;
163 SfxItemState eState
= mpBindings
->QueryState( SID_ATTR_FILL_STYLE
, pFillState
);
164 NotifyItemUpdate(SID_ATTR_FILL_STYLE
, eState
, pFillState
.get());
168 } // end of namespace svx::sidebar
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */