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 "LinePropertyPanel.hxx"
21 #include <svx/svxids.hrc>
22 #include <sfx2/bindings.hxx>
23 #include <sfx2/dispatch.hxx>
24 #include <svx/xlnwtit.hxx>
25 #include <svx/xlntrit.hxx>
26 #include <svx/xlncapit.hxx>
27 #include <svx/xlinjoit.hxx>
28 #include <com/sun/star/lang/IllegalArgumentException.hpp>
31 using namespace css::uno
;
33 namespace svx::sidebar
{
35 LinePropertyPanel::LinePropertyPanel(
36 weld::Widget
* pParent
,
37 const uno::Reference
<css::frame::XFrame
>& rxFrame
,
38 SfxBindings
* pBindings
)
39 : LinePropertyPanelBase(pParent
, rxFrame
),
40 maStyleControl(SID_ATTR_LINE_STYLE
, *pBindings
, *this),
41 maDashControl (SID_ATTR_LINE_DASH
, *pBindings
, *this),
42 maWidthControl(SID_ATTR_LINE_WIDTH
, *pBindings
, *this),
43 maTransControl(SID_ATTR_LINE_TRANSPARENCE
, *pBindings
, *this),
44 maEdgeStyle(SID_ATTR_LINE_JOINT
, *pBindings
, *this),
45 maCapStyle(SID_ATTR_LINE_CAP
, *pBindings
, *this),
48 setMapUnit(maWidthControl
.GetCoreMetric());
51 LinePropertyPanel::~LinePropertyPanel()
53 maStyleControl
.dispose();
54 maDashControl
.dispose();
55 maWidthControl
.dispose();
56 maTransControl
.dispose();
57 maEdgeStyle
.dispose();
61 std::unique_ptr
<PanelLayout
> LinePropertyPanel::Create (
62 weld::Widget
* pParent
,
63 const uno::Reference
<css::frame::XFrame
>& rxFrame
,
64 SfxBindings
* pBindings
)
66 if (pParent
== nullptr)
67 throw lang::IllegalArgumentException("no parent Window given to LinePropertyPanel::Create", nullptr, 0);
69 throw lang::IllegalArgumentException("no XFrame given to LinePropertyPanel::Create", nullptr, 1);
70 if (pBindings
== nullptr)
71 throw lang::IllegalArgumentException("no SfxBindings given to LinePropertyPanel::Create", nullptr, 2);
73 return std::make_unique
<LinePropertyPanel
>(pParent
, rxFrame
, pBindings
);
76 void LinePropertyPanel::NotifyItemUpdate(
79 const SfxPoolItem
* pState
)
81 const bool bDisabled(SfxItemState::DISABLED
== eState
);
82 const bool bSetOrDefault
= eState
>= SfxItemState::DEFAULT
;
86 case SID_ATTR_LINE_TRANSPARENCE
:
88 updateLineTransparence(bDisabled
, bSetOrDefault
, pState
);
91 case SID_ATTR_LINE_WIDTH
:
93 updateLineWidth(bDisabled
, bSetOrDefault
, pState
);
96 case SID_ATTR_LINE_JOINT
:
98 updateLineJoint(bDisabled
, bSetOrDefault
, pState
);
101 case SID_ATTR_LINE_CAP
:
103 updateLineCap(bDisabled
, bSetOrDefault
, pState
);
110 void LinePropertyPanel::HandleContextChange(
111 const vcl::EnumContext
& rContext
)
113 if(maContext
== rContext
)
119 maContext
= rContext
;
120 bool bShowArrows
= false;
122 switch(maContext
.GetCombinedContext_DI())
124 case CombinedEnumContext(Application::Calc
, Context::DrawLine
):
125 case CombinedEnumContext(Application::DrawImpress
, Context::DrawLine
):
126 case CombinedEnumContext(Application::DrawImpress
, Context::Draw
):
127 case CombinedEnumContext(Application::WriterVariants
, Context::Draw
):
128 // TODO : Implement DrawLine context in Writer
139 void LinePropertyPanel::setLineJoint(const XLineJointItem
* pItem
)
141 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_JOINT
,
142 SfxCallMode::RECORD
, { pItem
});
145 void LinePropertyPanel::setLineCap(const XLineCapItem
* pItem
)
147 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_CAP
,
148 SfxCallMode::RECORD
, { pItem
});
151 void LinePropertyPanel::setLineTransparency(const XLineTransparenceItem
& rItem
)
153 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_STYLE
,
154 SfxCallMode::RECORD
, { &rItem
});
157 void LinePropertyPanel::setLineWidth(const XLineWidthItem
& rItem
)
159 GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_WIDTH
,
160 SfxCallMode::RECORD
, { &rItem
});
163 } // end of namespace svx::sidebar
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */