LibreOffice Module svx (master)  1
LinePropertyPanel.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
20 #include "LinePropertyPanel.hxx"
21 #include <svx/svxids.hrc>
22 #include <sfx2/objsh.hxx>
23 #include <sfx2/bindings.hxx>
24 #include <sfx2/dispatch.hxx>
25 #include <svx/xtable.hxx>
26 #include <svx/xdash.hxx>
27 #include <svx/drawitem.hxx>
28 #include <svx/svxitems.hrc>
29 #include <svtools/valueset.hxx>
30 #include <unotools/pathoptions.hxx>
31 #include <unotools/viewoptions.hxx>
32 #include <i18nlangtag/mslangid.hxx>
33 #include <svx/xlineit0.hxx>
34 #include <svx/xlndsit.hxx>
35 #include <vcl/svapp.hxx>
36 #include <svx/xlnwtit.hxx>
37 #include <vcl/toolbox.hxx>
38 #include <svx/xlntrit.hxx>
39 #include <svx/xlnstit.hxx>
40 #include <svx/xlnedit.hxx>
41 #include <svx/xlncapit.hxx>
42 #include <svx/xlinjoit.hxx>
43 
44 using namespace css;
45 using namespace css::uno;
46 
47 namespace svx { namespace sidebar {
48 
49 LinePropertyPanel::LinePropertyPanel(
50  vcl::Window* pParent,
51  const uno::Reference<css::frame::XFrame>& rxFrame,
52  SfxBindings* pBindings)
53 : LinePropertyPanelBase(pParent, rxFrame),
54  maStyleControl(SID_ATTR_LINE_STYLE, *pBindings, *this),
55  maDashControl (SID_ATTR_LINE_DASH, *pBindings, *this),
56  maWidthControl(SID_ATTR_LINE_WIDTH, *pBindings, *this),
57  maStartControl(SID_ATTR_LINE_START, *pBindings, *this),
58  maEndControl(SID_ATTR_LINE_END, *pBindings, *this),
59  maLineEndListControl(SID_LINEEND_LIST, *pBindings, *this),
60  maLineStyleListControl(SID_DASH_LIST, *pBindings, *this),
61  maTransControl(SID_ATTR_LINE_TRANSPARENCE, *pBindings, *this),
62  maEdgeStyle(SID_ATTR_LINE_JOINT, *pBindings, *this),
63  maCapStyle(SID_ATTR_LINE_CAP, *pBindings, *this),
64  mpBindings(pBindings),
65  maContext()
66 {
68 }
69 
71 {
72  disposeOnce();
73 }
74 
76 {
87 
89 }
90 
92  vcl::Window* pParent,
93  const uno::Reference<css::frame::XFrame>& rxFrame,
94  SfxBindings* pBindings)
95 {
96  if (pParent == nullptr)
97  throw lang::IllegalArgumentException("no parent Window given to LinePropertyPanel::Create", nullptr, 0);
98  if ( ! rxFrame.is())
99  throw lang::IllegalArgumentException("no XFrame given to LinePropertyPanel::Create", nullptr, 1);
100  if (pBindings == nullptr)
101  throw lang::IllegalArgumentException("no SfxBindings given to LinePropertyPanel::Create", nullptr, 2);
102 
103  return VclPtr<LinePropertyPanel>::Create(pParent, rxFrame, pBindings);
104 }
105 
107  sal_uInt16 nSID,
108  SfxItemState eState,
109  const SfxPoolItem* pState)
110 {
111  const bool bDisabled(SfxItemState::DISABLED == eState);
112  const bool bSetOrDefault = eState >= SfxItemState::DEFAULT;
113 
114  switch(nSID)
115  {
116  case SID_ATTR_LINE_DASH:
117  {
118  updateLineDash(bDisabled, bSetOrDefault, pState);
119  break;
120  }
121  case SID_ATTR_LINE_STYLE:
122  {
123  updateLineStyle(bDisabled, bSetOrDefault, pState);
124  break;
125  }
126  case SID_ATTR_LINE_TRANSPARENCE:
127  {
128  updateLineTransparence(bDisabled, bSetOrDefault, pState);
129  break;
130  }
131  case SID_ATTR_LINE_WIDTH:
132  {
133  updateLineWidth(bDisabled, bSetOrDefault, pState);
134  break;
135  }
136  case SID_ATTR_LINE_START:
137  {
138  updateLineStart(bDisabled, bSetOrDefault, pState);
139  break;
140  }
141  case SID_ATTR_LINE_END:
142  {
143  updateLineEnd(bDisabled, bSetOrDefault, pState);
144  break;
145  }
146  case SID_LINEEND_LIST:
147  {
148  FillLineEndList();
149  SelectEndStyle(true);
150  SelectEndStyle(false);
151  break;
152  }
153  case SID_DASH_LIST:
154  {
156  SelectLineStyle();
157  break;
158  }
159  case SID_ATTR_LINE_JOINT:
160  {
161  updateLineJoint(bDisabled, bSetOrDefault, pState);
162  break;
163  }
164  case SID_ATTR_LINE_CAP:
165  {
166  updateLineCap(bDisabled, bSetOrDefault, pState);
167  break;
168  }
169  }
171 }
172 
174  const vcl::EnumContext& rContext)
175 {
176  if(maContext == rContext)
177  {
178  // Nothing to do
179  return;
180  }
181 
182  maContext = rContext;
183  bool bShowArrows = false;
184 
186  {
187  case CombinedEnumContext(Application::Calc, Context::DrawLine):
188  case CombinedEnumContext(Application::DrawImpress, Context::DrawLine):
189  case CombinedEnumContext(Application::DrawImpress, Context::Draw):
190  case CombinedEnumContext(Application::WriterVariants, Context::Draw):
191  // TODO : Implement DrawLine context in Writer
192  bShowArrows = true;
193  break;
194  }
195 
196  if(!bShowArrows)
198 }
199 
201 {
202  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_STYLE,
203  SfxCallMode::RECORD, { &rItem });
204 }
205 
207 {
208  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_DASH,
209  SfxCallMode::RECORD, { &rItem });
210 }
211 
213 {
214  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINEEND_STYLE,
215  SfxCallMode::RECORD, { pItem });
216 }
217 
219 {
220  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINEEND_STYLE,
221  SfxCallMode::RECORD, { pItem });
222 }
223 
225 {
226  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_JOINT,
227  SfxCallMode::RECORD, { pItem });
228 }
229 
231 {
232  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_CAP,
233  SfxCallMode::RECORD, { pItem });
234 }
235 
237 {
238  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_STYLE,
239  SfxCallMode::RECORD, { &rItem });
240 }
241 
243 {
244  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_WIDTH,
245  SfxCallMode::RECORD, { &rItem });
246 }
247 
248 }} // end of namespace svx::sidebar
249 
250 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sfx2::sidebar::ControllerItem maStyleControl
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 * >())
sfx2::sidebar::ControllerItem maTransControl
void updateLineWidth(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
SlideShowContext maContext
virtual void setLineCap(const XLineCapItem *pItem) override
sfx2::sidebar::ControllerItem maEndControl
sfx2::sidebar::ControllerItem maDashControl
virtual void HandleContextChange(const vcl::EnumContext &rContext) override
MapUnit GetCoreMetric() const
virtual void setLineStartStyle(const XLineStartItem *pItem) override
virtual void setLineEndStyle(const XLineEndItem *pItem) override
void updateLineStyle(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
virtual void setLineTransparency(const XLineTransparenceItem &rItem) override
sal_Int32 GetCombinedContext_DI() const
virtual void NotifyItemUpdate(const sal_uInt16 nSId, const SfxItemState eState, const SfxPoolItem *pState) override
void updateLineTransparence(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
void updateLineStart(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
sfx2::sidebar::ControllerItem maCapStyle
virtual void setLineJoint(const XLineJointItem *pItem) override
static VclPtr< vcl::Window > Create(vcl::Window *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame, SfxBindings *pBindings)
void updateLineDash(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
sfx2::sidebar::ControllerItem maEdgeStyle
sfx2::sidebar::ControllerItem maLineStyleListControl
SfxItemState
virtual void setLineDash(const XLineDashItem &rItem) override
void updateLineCap(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
void updateLineJoint(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
virtual void dispose() override
virtual void dispose() override
static VclPtr< reference_type > Create(Arg &&...arg)
virtual void setLineStyle(const XLineStyleItem &rItem) override
void updateLineEnd(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
sfx2::sidebar::ControllerItem maWidthControl
sfx2::sidebar::ControllerItem maStartControl
SfxDispatcher * GetDispatcher() const
sfx2::sidebar::ControllerItem maLineEndListControl
virtual void setLineWidth(const XLineWidthItem &rItem) override
#define CombinedEnumContext(a, e)