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 
29 using namespace css;
30 using namespace css::uno;
31 
32 namespace svx::sidebar {
33 
34 LinePropertyPanel::LinePropertyPanel(
35  vcl::Window* pParent,
36  const uno::Reference<css::frame::XFrame>& rxFrame,
37  SfxBindings* pBindings)
38 : LinePropertyPanelBase(pParent, rxFrame),
39  maStyleControl(SID_ATTR_LINE_STYLE, *pBindings, *this),
40  maDashControl (SID_ATTR_LINE_DASH, *pBindings, *this),
41  maWidthControl(SID_ATTR_LINE_WIDTH, *pBindings, *this),
42  maTransControl(SID_ATTR_LINE_TRANSPARENCE, *pBindings, *this),
43  maEdgeStyle(SID_ATTR_LINE_JOINT, *pBindings, *this),
44  maCapStyle(SID_ATTR_LINE_CAP, *pBindings, *this),
45  mpBindings(pBindings),
46  maContext()
47 {
49 }
50 
52 {
53  disposeOnce();
54 }
55 
57 {
64 
66 }
67 
69  vcl::Window* pParent,
70  const uno::Reference<css::frame::XFrame>& rxFrame,
71  SfxBindings* pBindings)
72 {
73  if (pParent == nullptr)
74  throw lang::IllegalArgumentException("no parent Window given to LinePropertyPanel::Create", nullptr, 0);
75  if ( ! rxFrame.is())
76  throw lang::IllegalArgumentException("no XFrame given to LinePropertyPanel::Create", nullptr, 1);
77  if (pBindings == nullptr)
78  throw lang::IllegalArgumentException("no SfxBindings given to LinePropertyPanel::Create", nullptr, 2);
79 
80  return VclPtr<LinePropertyPanel>::Create(pParent, rxFrame, pBindings);
81 }
82 
84  sal_uInt16 nSID,
85  SfxItemState eState,
86  const SfxPoolItem* pState)
87 {
88  const bool bDisabled(SfxItemState::DISABLED == eState);
89  const bool bSetOrDefault = eState >= SfxItemState::DEFAULT;
90 
91  switch(nSID)
92  {
93  case SID_ATTR_LINE_TRANSPARENCE:
94  {
95  updateLineTransparence(bDisabled, bSetOrDefault, pState);
96  break;
97  }
98  case SID_ATTR_LINE_WIDTH:
99  {
100  updateLineWidth(bDisabled, bSetOrDefault, pState);
101  break;
102  }
103  case SID_ATTR_LINE_JOINT:
104  {
105  updateLineJoint(bDisabled, bSetOrDefault, pState);
106  break;
107  }
108  case SID_ATTR_LINE_CAP:
109  {
110  updateLineCap(bDisabled, bSetOrDefault, pState);
111  break;
112  }
113  }
115 }
116 
118  const vcl::EnumContext& rContext)
119 {
120  if(maContext == rContext)
121  {
122  // Nothing to do
123  return;
124  }
125 
126  maContext = rContext;
127  bool bShowArrows = false;
128 
130  {
131  case CombinedEnumContext(Application::Calc, Context::DrawLine):
132  case CombinedEnumContext(Application::DrawImpress, Context::DrawLine):
133  case CombinedEnumContext(Application::DrawImpress, Context::Draw):
134  case CombinedEnumContext(Application::WriterVariants, Context::Draw):
135  // TODO : Implement DrawLine context in Writer
136  bShowArrows = true;
137  break;
138  }
139 
140  if (!bShowArrows)
142  else
143  enableArrowHead();
144 }
145 
147 {
148  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_JOINT,
149  SfxCallMode::RECORD, { pItem });
150 }
151 
153 {
154  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_CAP,
155  SfxCallMode::RECORD, { pItem });
156 }
157 
159 {
160  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_STYLE,
161  SfxCallMode::RECORD, { &rItem });
162 }
163 
165 {
166  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_WIDTH,
167  SfxCallMode::RECORD, { &rItem });
168 }
169 
170 } // end of namespace svx::sidebar
171 
172 /* 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 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)
sfx2::sidebar::ControllerItem maCapStyle
virtual void dispose()
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)
sfx2::sidebar::ControllerItem maEdgeStyle
SfxItemState
void updateLineCap(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
void updateLineJoint(bool bDisabled, bool bSetOrDefault, const SfxPoolItem *pItem)
virtual void dispose() override
static VclPtr< reference_type > Create(Arg &&...arg)
sfx2::sidebar::ControllerItem maWidthControl
SfxDispatcher * GetDispatcher() const
virtual void setLineWidth(const XLineWidthItem &rItem) override
#define CombinedEnumContext(a, e)