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  */
19 
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>
29 
30 using namespace css;
31 using namespace css::uno;
32 
33 namespace svx::sidebar {
34 
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),
46  mpBindings(pBindings),
47  maContext()
48 {
50 }
51 
53 {
60 }
61 
62 std::unique_ptr<PanelLayout> LinePropertyPanel::Create (
63  weld::Widget* pParent,
64  const uno::Reference<css::frame::XFrame>& rxFrame,
65  SfxBindings* pBindings)
66 {
67  if (pParent == nullptr)
68  throw lang::IllegalArgumentException("no parent Window given to LinePropertyPanel::Create", nullptr, 0);
69  if ( ! rxFrame.is())
70  throw lang::IllegalArgumentException("no XFrame given to LinePropertyPanel::Create", nullptr, 1);
71  if (pBindings == nullptr)
72  throw lang::IllegalArgumentException("no SfxBindings given to LinePropertyPanel::Create", nullptr, 2);
73 
74  return std::make_unique<LinePropertyPanel>(pParent, rxFrame, pBindings);
75 }
76 
78  sal_uInt16 nSID,
79  SfxItemState eState,
80  const SfxPoolItem* pState)
81 {
82  const bool bDisabled(SfxItemState::DISABLED == eState);
83  const bool bSetOrDefault = eState >= SfxItemState::DEFAULT;
84 
85  switch(nSID)
86  {
87  case SID_ATTR_LINE_TRANSPARENCE:
88  {
89  updateLineTransparence(bDisabled, bSetOrDefault, pState);
90  break;
91  }
92  case SID_ATTR_LINE_WIDTH:
93  {
94  updateLineWidth(bDisabled, bSetOrDefault, pState);
95  break;
96  }
97  case SID_ATTR_LINE_JOINT:
98  {
99  updateLineJoint(bDisabled, bSetOrDefault, pState);
100  break;
101  }
102  case SID_ATTR_LINE_CAP:
103  {
104  updateLineCap(bDisabled, bSetOrDefault, pState);
105  break;
106  }
107  }
109 }
110 
112  const vcl::EnumContext& rContext)
113 {
114  if(maContext == rContext)
115  {
116  // Nothing to do
117  return;
118  }
119 
120  maContext = rContext;
121  bool bShowArrows = false;
122 
124  {
125  case CombinedEnumContext(Application::Calc, Context::DrawLine):
126  case CombinedEnumContext(Application::DrawImpress, Context::DrawLine):
127  case CombinedEnumContext(Application::DrawImpress, Context::Draw):
128  case CombinedEnumContext(Application::WriterVariants, Context::Draw):
129  // TODO : Implement DrawLine context in Writer
130  bShowArrows = true;
131  break;
132  }
133 
134  if (!bShowArrows)
136  else
137  enableArrowHead();
138 }
139 
141 {
142  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_JOINT,
143  SfxCallMode::RECORD, { pItem });
144 }
145 
147 {
148  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_CAP,
149  SfxCallMode::RECORD, { pItem });
150 }
151 
153 {
154  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_STYLE,
155  SfxCallMode::RECORD, { &rItem });
156 }
157 
159 {
160  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_WIDTH,
161  SfxCallMode::RECORD, { &rItem });
162 }
163 
164 } // end of namespace svx::sidebar
165 
166 /* 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
virtual void updateLineWidth(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
SlideShowContext maContext
virtual void setLineCap(const XLineCapItem *pItem) override
sfx2::sidebar::ControllerItem maDashControl
virtual void HandleContextChange(const vcl::EnumContext &rContext) override
MapUnit GetCoreMetric() const
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)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame, SfxBindings *pBindings)
sfx2::sidebar::ControllerItem maCapStyle
virtual void dispose()
virtual void setLineJoint(const XLineJointItem *pItem) override
sfx2::sidebar::ControllerItem maEdgeStyle
SfxItemState
void updateLineCap(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
void updateLineJoint(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
sfx2::sidebar::ControllerItem maWidthControl
SfxDispatcher * GetDispatcher() const
virtual void setLineWidth(const XLineWidthItem &rItem) override
#define CombinedEnumContext(a, e)