LibreOffice Module svx (master)  1
linewidthctrl.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 <vcl/toolbox.hxx>
21 #include <sfx2/app.hxx>
22 #include <sfx2/objsh.hxx>
23 #include <svl/itempool.hxx>
24 #include <svx/svxids.hrc>
25 #include <svx/xlnwtit.hxx>
26 #include <svx/linectrl.hxx>
27 #include <svx/itemwin.hxx>
28 #include "linemetricbox.hxx"
29 
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::beans;
32 using namespace ::com::sun::star::util;
33 using namespace ::com::sun::star::frame;
34 using namespace ::com::sun::star::lang;
35 using namespace ::com::sun::star;
36 
38 
40  sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
41  SfxToolBoxControl( nSlotId, nId, rTbx )
42 {
43  addStatusListener( ".uno:MetricUnit");
44 }
45 
46 
48 {
49 }
50 
52  sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
53 {
54  SvxMetricField* pFld = static_cast<SvxMetricField*>(
56  DBG_ASSERT( pFld, "Window not found" );
57 
58  if ( nSID == SID_ATTR_METRIC )
59  {
60  pFld->RefreshDlgUnit();
61  }
62  else
63  {
64  if ( eState == SfxItemState::DISABLED )
65  {
66  pFld->set_sensitive(false);
67  }
68  else
69  {
70  pFld->set_sensitive(true);
71 
72  if ( eState == SfxItemState::DEFAULT )
73  {
74  DBG_ASSERT( dynamic_cast<const XLineWidthItem*>( pState) != nullptr, "wrong ItemType" );
75 
77 
78  pFld->Update( static_cast<const XLineWidthItem*>(pState) );
79  }
80  else
81  pFld->Update( nullptr );
82  }
83  }
84 }
85 
87 {
89  SfxItemPool& rPool = pSh ? pSh->GetPool() : SfxGetpApp()->GetPool();
90  sal_uInt16 nWhich = rPool.GetWhich(SID_ATTR_LINE_WIDTH);
91  return rPool.GetMetric(nWhich);
92 }
93 
95 {
97  pWindow->Show();
98 
99  return pWindow;
100 }
101 
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~SvxLineWidthToolBoxControl() override
static MapUnit GetCoreMetric()
ToolBox & GetToolBox() const
SvxLineWidthToolBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx)
css::uno::Reference< css::lang::XComponent > m_xFrame
static SfxObjectShell * Current()
void set_sensitive(bool bSensitive)
Definition: itemwin.cxx:80
SfxApplication * SfxGetpApp()
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
SfxItemPool & GetPool() const
#define DBG_ASSERT(sCon, aError)
void Update(const XLineWidthItem *pItem)
Definition: itemwin.cxx:88
void SetDestCoreUnit(MapUnit eUnit)
Definition: itemwin.cxx:126
vcl::Window * GetItemWindow(sal_uInt16 nItemId) const
void RefreshDlgUnit()
Definition: itemwin.cxx:131
SfxItemState
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
unsigned short GetId() const
static VclPtr< reference_type > Create(Arg &&...arg)
SFX_IMPL_TOOLBOX_CONTROL(SvxLineWidthToolBoxControl, XLineWidthItem)
MapUnit
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)