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 "linemetricbox.hxx"
28
29using namespace ::com::sun::star::uno;
30using namespace ::com::sun::star::beans;
31using namespace ::com::sun::star::util;
32using namespace ::com::sun::star::frame;
33using namespace ::com::sun::star::lang;
34using namespace ::com::sun::star;
35
37
39 sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ) :
40 SfxToolBoxControl( nSlotId, nId, rTbx )
41{
42 addStatusListener( ".uno:MetricUnit");
43}
44
45
47{
48}
49
51 sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
52{
53 SvxMetricField* pFld = static_cast<SvxMetricField*>(
55 DBG_ASSERT( pFld, "Window not found" );
56
57 if ( nSID == SID_ATTR_METRIC )
58 {
59 pFld->RefreshDlgUnit();
60 }
61 else
62 {
63 if ( eState == SfxItemState::DISABLED )
64 {
65 pFld->set_sensitive(false);
66 }
67 else
68 {
69 pFld->set_sensitive(true);
70
71 if ( eState == SfxItemState::DEFAULT )
72 {
73 DBG_ASSERT( dynamic_cast<const XLineWidthItem*>( pState) != nullptr, "wrong ItemType" );
74
76
77 pFld->Update( static_cast<const XLineWidthItem*>(pState) );
78 }
79 else
80 pFld->Update( nullptr );
81 }
82 }
83}
84
86{
88 SfxItemPool& rPool = pSh ? pSh->GetPool() : SfxGetpApp()->GetPool();
89 sal_uInt16 nWhich = rPool.GetWhich(SID_ATTR_LINE_WIDTH);
90 return rPool.GetMetric(nWhich);
91}
92
94{
96 pWindow->Show();
97
98 return pWindow;
99}
100
101/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::lang::XComponent > m_xFrame
SfxApplication * SfxGetpApp()
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
static SfxObjectShell * Current()
SfxItemPool & GetPool() const
ToolBoxItemId GetId() const
ToolBox & GetToolBox() const
SvxLineWidthToolBoxControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
virtual ~SvxLineWidthToolBoxControl() override
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
static MapUnit GetCoreMetric()
void SetDestCoreUnit(MapUnit eUnit)
Definition: itemwin.cxx:125
void set_sensitive(bool bSensitive)
Definition: itemwin.cxx:81
void Update(const XLineWidthItem *pItem)
Definition: itemwin.cxx:89
void RefreshDlgUnit()
Definition: itemwin.cxx:130
vcl::Window * GetItemWindow(ToolBoxItemId nItemId) const
static VclPtr< reference_type > Create(Arg &&... arg)
#define DBG_ASSERT(sCon, aError)
SFX_IMPL_TOOLBOX_CONTROL(SvxLineWidthToolBoxControl, XLineWidthItem)
MapUnit
sal_Int16 nId
SfxItemState