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 {
49 }
50 
52 {
59 }
60 
61 std::unique_ptr<PanelLayout> LinePropertyPanel::Create (
62  weld::Widget* pParent,
63  const uno::Reference<css::frame::XFrame>& rxFrame,
64  SfxBindings* pBindings)
65 {
66  if (pParent == nullptr)
67  throw lang::IllegalArgumentException("no parent Window given to LinePropertyPanel::Create", nullptr, 0);
68  if ( ! rxFrame.is())
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);
72 
73  return std::make_unique<LinePropertyPanel>(pParent, rxFrame, pBindings);
74 }
75 
77  sal_uInt16 nSID,
78  SfxItemState eState,
79  const SfxPoolItem* pState)
80 {
81  const bool bDisabled(SfxItemState::DISABLED == eState);
82  const bool bSetOrDefault = eState >= SfxItemState::DEFAULT;
83 
84  switch(nSID)
85  {
86  case SID_ATTR_LINE_TRANSPARENCE:
87  {
88  updateLineTransparence(bDisabled, bSetOrDefault, pState);
89  break;
90  }
91  case SID_ATTR_LINE_WIDTH:
92  {
93  updateLineWidth(bDisabled, bSetOrDefault, pState);
94  break;
95  }
96  case SID_ATTR_LINE_JOINT:
97  {
98  updateLineJoint(bDisabled, bSetOrDefault, pState);
99  break;
100  }
101  case SID_ATTR_LINE_CAP:
102  {
103  updateLineCap(bDisabled, bSetOrDefault, pState);
104  break;
105  }
106  }
108 }
109 
111  const vcl::EnumContext& rContext)
112 {
113  if(maContext == rContext)
114  {
115  // Nothing to do
116  return;
117  }
118 
119  maContext = rContext;
120  bool bShowArrows = false;
121 
123  {
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
129  bShowArrows = true;
130  break;
131  }
132 
133  if (!bShowArrows)
135  else
136  enableArrowHead();
137 }
138 
140 {
141  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_JOINT,
142  SfxCallMode::RECORD, { pItem });
143 }
144 
146 {
147  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_CAP,
148  SfxCallMode::RECORD, { pItem });
149 }
150 
152 {
153  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_STYLE,
154  SfxCallMode::RECORD, { &rItem });
155 }
156 
158 {
159  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_WIDTH,
160  SfxCallMode::RECORD, { &rItem });
161 }
162 
163 } // end of namespace svx::sidebar
164 
165 /* 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)
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)