Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/tbxctrls/linewidthctrl.cxx
Line
Count
Source
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 <tools/debug.hxx>
28
#include "linemetricbox.hxx"
29
30
using namespace ::com::sun::star;
31
32
SFX_IMPL_TOOLBOX_CONTROL( SvxLineWidthToolBoxControl, XLineWidthItem );
33
34
SvxLineWidthToolBoxControl::SvxLineWidthToolBoxControl(
35
    sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ) :
36
0
    SfxToolBoxControl( nSlotId, nId, rTbx )
37
0
{
38
0
    addStatusListener( u".uno:MetricUnit"_ustr);
39
0
}
40
41
42
SvxLineWidthToolBoxControl::~SvxLineWidthToolBoxControl()
43
0
{
44
0
}
45
46
void SvxLineWidthToolBoxControl::StateChangedAtToolBoxControl(
47
    sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
48
0
{
49
0
    SvxMetricField* pFld = static_cast<SvxMetricField*>(
50
0
                           GetToolBox().GetItemWindow( GetId() ));
51
0
    DBG_ASSERT( pFld, "Window not found" );
52
53
0
    if ( nSID == SID_ATTR_METRIC )
54
0
    {
55
0
        pFld->RefreshDlgUnit();
56
0
    }
57
0
    else
58
0
    {
59
0
        if ( eState == SfxItemState::DISABLED )
60
0
        {
61
0
            pFld->set_sensitive(false);
62
0
        }
63
0
        else
64
0
        {
65
0
            pFld->set_sensitive(true);
66
67
0
            if ( eState == SfxItemState::DEFAULT )
68
0
            {
69
0
                DBG_ASSERT( dynamic_cast<const XLineWidthItem*>( pState) !=  nullptr, "wrong ItemType" );
70
71
0
                pFld->SetDestCoreUnit(GetCoreMetric());
72
73
0
                pFld->Update( static_cast<const XLineWidthItem*>(pState) );
74
0
            }
75
0
            else
76
0
                pFld->Update( nullptr );
77
0
        }
78
0
    }
79
0
}
80
81
MapUnit SvxLineWidthToolBoxControl::GetCoreMetric()
82
0
{
83
0
    SfxObjectShell* pSh = SfxObjectShell::Current();
84
0
    SfxItemPool& rPool = pSh ? pSh->GetPool() : SfxGetpApp()->GetPool();
85
0
    sal_uInt16 nWhich = rPool.GetWhichIDFromSlotID(SID_ATTR_LINE_WIDTH);
86
0
    return rPool.GetMetric(nWhich);
87
0
}
88
89
VclPtr<InterimItemWindow> SvxLineWidthToolBoxControl::CreateItemWindow(vcl::Window *pParent)
90
0
{
91
0
    VclPtr<SvxMetricField> pWindow = VclPtr<SvxMetricField>::Create(pParent, m_xFrame);
92
0
    pWindow->Show();
93
94
0
    return pWindow;
95
0
}
96
97
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */