Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/tbxctrls/tbxdrctl.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
21
#include <svl/eitem.hxx>
22
#include <vcl/toolbox.hxx>
23
24
#include <svx/tbxctl.hxx>
25
26
#include <com/sun/star/frame/XLayoutManager.hpp>
27
28
SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlDraw, SfxBoolItem);
29
30
using namespace ::com::sun::star::uno;
31
using namespace ::com::sun::star::frame;
32
33
34
SvxTbxCtlDraw::SvxTbxCtlDraw( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ) :
35
0
    SfxToolBoxControl( nSlotId, nId, rTbx )
36
0
{
37
0
    rTbx.SetItemBits( nId, ToolBoxItemBits::CHECKABLE | rTbx.GetItemBits( nId ) );
38
0
    rTbx.Invalidate();
39
0
}
40
41
void SAL_CALL SvxTbxCtlDraw::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
42
0
{
43
0
    svt::ToolboxController::initialize(aArguments);
44
    /*
45
     * Toolbar name is defined as "private:resource/toolbar/drawbar" in writer and calc,
46
     * "private:resource/toolbar/toolbar" in draw and impress. Control is added for this
47
     * difference.
48
     */
49
0
    if( m_aCommandURL==".uno:TrackChangesBar")
50
0
        m_sToolboxName="private:resource/toolbar/changes";
51
0
    else if ( m_sModuleName == "com.sun.star.presentation.PresentationDocument" || m_sModuleName == "com.sun.star.drawing.DrawingDocument" )
52
0
        m_sToolboxName="private:resource/toolbar/toolbar";
53
0
    else
54
0
        m_sToolboxName="private:resource/toolbar/drawbar";
55
0
}
56
57
58
void SvxTbxCtlDraw::StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState,
59
                                  const SfxPoolItem* pState )
60
0
{
61
0
    GetToolBox().EnableItem( GetId(), ( eState != SfxItemState::DISABLED ) );
62
0
    SfxToolBoxControl::StateChangedAtToolBoxControl( nSID, eState, pState );
63
64
0
    Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
65
0
    if ( xLayoutMgr.is() )
66
0
        GetToolBox().CheckItem(
67
0
            GetId(), xLayoutMgr->isElementVisible( m_sToolboxName ) );
68
0
}
69
70
71
void SvxTbxCtlDraw::toggleToolbox()
72
0
{
73
0
    Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
74
0
    if ( !xLayoutMgr.is() )
75
0
        return;
76
77
0
    bool bCheck = false;
78
0
    if ( xLayoutMgr->isElementVisible( m_sToolboxName ) )
79
0
    {
80
0
        xLayoutMgr->hideElement( m_sToolboxName );
81
0
        xLayoutMgr->destroyElement( m_sToolboxName );
82
0
    }
83
0
    else
84
0
    {
85
0
        bCheck = true;
86
0
        xLayoutMgr->createElement( m_sToolboxName );
87
0
        xLayoutMgr->showElement( m_sToolboxName );
88
0
    }
89
90
0
    GetToolBox().CheckItem( GetId(), bCheck );
91
0
}
92
93
94
void SvxTbxCtlDraw::Select(sal_uInt16 /*nSelectModifier*/)
95
0
{
96
0
    toggleToolbox();
97
0
}
98
99
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */