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 
22 #include <svx/svxids.hrc>
23 #include <svx/xlnwtit.hxx>
24 #include <svx/linectrl.hxx>
25 #include <svx/itemwin.hxx>
26 
27 using namespace ::com::sun::star::uno;
28 using namespace ::com::sun::star::beans;
29 using namespace ::com::sun::star::util;
30 using namespace ::com::sun::star::frame;
31 using namespace ::com::sun::star::lang;
32 using namespace ::com::sun::star;
33 
35 
37  sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
38  SfxToolBoxControl( nSlotId, nId, rTbx )
39 {
40  addStatusListener( ".uno:MetricUnit");
41 }
42 
43 
45 {
46 }
47 
48 
50  sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
51 {
52  SvxMetricField* pFld = static_cast<SvxMetricField*>(
54  DBG_ASSERT( pFld, "Window not found" );
55 
56  if ( nSID == SID_ATTR_METRIC )
57  {
58  pFld->RefreshDlgUnit();
59  }
60  else
61  {
62  if ( eState == SfxItemState::DISABLED )
63  {
64  pFld->set_sensitive(false);
65  }
66  else
67  {
68  pFld->set_sensitive(true);
69 
70  if ( eState == SfxItemState::DEFAULT )
71  {
72  DBG_ASSERT( dynamic_cast<const XLineWidthItem*>( pState) != nullptr, "wrong ItemType" );
73 
74  // Core-Unit handed over to MetricField
75  // Should not happen in CreateItemWin ()!
76  // CD!!! GetCoreMetric();
77  pFld->SetCoreUnit( MapUnit::Map100thMM );
78 
79  pFld->Update( static_cast<const XLineWidthItem*>(pState) );
80  }
81  else
82  pFld->Update( nullptr );
83  }
84  }
85 }
86 
88 {
90  pWindow->Show();
91 
92  return pWindow;
93 }
94 
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~SvxLineWidthToolBoxControl() override
ToolBox & GetToolBox() const
SvxLineWidthToolBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx)
css::uno::Reference< css::lang::XComponent > m_xFrame
void set_sensitive(bool bSensitive)
Definition: itemwin.cxx:76
virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
#define DBG_ASSERT(sCon, aError)
void Update(const XLineWidthItem *pItem)
Definition: itemwin.cxx:84
vcl::Window * GetItemWindow(sal_uInt16 nItemId) const
void SetCoreUnit(MapUnit eUnit)
Definition: itemwin.cxx:120
void RefreshDlgUnit()
Definition: itemwin.cxx:125
SfxItemState
unsigned short GetId() const
static VclPtr< reference_type > Create(Arg &&...arg)
SFX_IMPL_TOOLBOX_CONTROL(SvxLineWidthToolBoxControl, XLineWidthItem)
virtual VclPtr< vcl::Window > CreateItemWindow(vcl::Window *pParent) override