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  vcl::Window* 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 {
54  disposeOnce();
55 }
56 
58 {
65 
67 }
68 
70  vcl::Window* pParent,
71  const uno::Reference<css::frame::XFrame>& rxFrame,
72  SfxBindings* pBindings)
73 {
74  if (pParent == nullptr)
75  throw lang::IllegalArgumentException("no parent Window given to LinePropertyPanel::Create", nullptr, 0);
76  if ( ! rxFrame.is())
77  throw lang::IllegalArgumentException("no XFrame given to LinePropertyPanel::Create", nullptr, 1);
78  if (pBindings == nullptr)
79  throw lang::IllegalArgumentException("no SfxBindings given to LinePropertyPanel::Create", nullptr, 2);
80 
81  return VclPtr<LinePropertyPanel>::Create(pParent, rxFrame, pBindings);
82 }
83 
85  sal_uInt16 nSID,
86  SfxItemState eState,
87  const SfxPoolItem* pState)
88 {
89  const bool bDisabled(SfxItemState::DISABLED == eState);
90  const bool bSetOrDefault = eState >= SfxItemState::DEFAULT;
91 
92  switch(nSID)
93  {
94  case SID_ATTR_LINE_TRANSPARENCE:
95  {
96  updateLineTransparence(bDisabled, bSetOrDefault, pState);
97  break;
98  }
99  case SID_ATTR_LINE_WIDTH:
100  {
101  updateLineWidth(bDisabled, bSetOrDefault, pState);
102  break;
103  }
104  case SID_ATTR_LINE_JOINT:
105  {
106  updateLineJoint(bDisabled, bSetOrDefault, pState);
107  break;
108  }
109  case SID_ATTR_LINE_CAP:
110  {
111  updateLineCap(bDisabled, bSetOrDefault, pState);
112  break;
113  }
114  }
116 }
117 
119  const vcl::EnumContext& rContext)
120 {
121  if(maContext == rContext)
122  {
123  // Nothing to do
124  return;
125  }
126 
127  maContext = rContext;
128  bool bShowArrows = false;
129 
131  {
132  case CombinedEnumContext(Application::Calc, Context::DrawLine):
133  case CombinedEnumContext(Application::DrawImpress, Context::DrawLine):
134  case CombinedEnumContext(Application::DrawImpress, Context::Draw):
135  case CombinedEnumContext(Application::WriterVariants, Context::Draw):
136  // TODO : Implement DrawLine context in Writer
137  bShowArrows = true;
138  break;
139  }
140 
141  if (!bShowArrows)
143  else
144  enableArrowHead();
145 }
146 
148 {
149  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_JOINT,
150  SfxCallMode::RECORD, { pItem });
151 }
152 
154 {
155  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_CAP,
156  SfxCallMode::RECORD, { pItem });
157 }
158 
160 {
161  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_STYLE,
162  SfxCallMode::RECORD, { &rItem });
163 }
164 
166 {
167  GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_WIDTH,
168  SfxCallMode::RECORD, { &rItem });
169 }
170 
171 } // end of namespace svx::sidebar
172 
173 /* 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)