Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/form/formtoolbars.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 <formtoolbars.hxx>
21
22
#include <com/sun/star/beans/XPropertySet.hpp>
23
#include <osl/diagnose.h>
24
#include <comphelper/diagnose_ex.hxx>
25
26
#include <svx/svxids.hrc>
27
28
29
namespace svxform
30
{
31
32
33
    using namespace ::com::sun::star::uno;
34
    using namespace ::com::sun::star::frame;
35
    using namespace ::com::sun::star::beans;
36
37
    FormToolboxes::FormToolboxes( const Reference< XFrame >& _rxFrame )
38
0
    {
39
        // the layout manager
40
0
        Reference< XPropertySet > xFrameProps( _rxFrame, UNO_QUERY );
41
0
        if ( xFrameProps.is() )
42
0
            xFrameProps->getPropertyValue(u"LayoutManager"_ustr) >>= m_xLayouter;
43
0
    }
44
45
46
    void FormToolboxes::toggleToolbox( sal_uInt16 _nSlotId ) const
47
0
    {
48
0
        try
49
0
        {
50
0
            Reference< XLayoutManager > xManager( m_xLayouter );
51
0
            OSL_ENSURE( xManager. is(), "FormToolboxes::toggleToolbox: couldn't obtain the layout manager!" );
52
0
            if ( xManager. is() )
53
0
            {
54
0
                OUString sToolboxResource( getToolboxResourceName( _nSlotId ) );
55
0
                if ( xManager->isElementVisible( sToolboxResource ) )
56
0
                {
57
0
                    xManager->hideElement( sToolboxResource );
58
0
                    xManager->destroyElement( sToolboxResource );
59
0
                }
60
0
                else
61
0
                {
62
0
                    xManager->createElement( sToolboxResource );
63
0
                    xManager->showElement( sToolboxResource );
64
0
                }
65
0
            }
66
0
        }
67
0
        catch( const Exception& )
68
0
        {
69
0
            TOOLS_WARN_EXCEPTION( "svx", "FormToolboxes::toggleToolbox" );
70
0
        }
71
0
    }
72
73
74
    bool FormToolboxes::isToolboxVisible( sal_uInt16 _nSlotId ) const
75
0
    {
76
0
        return m_xLayouter.is() && m_xLayouter->isElementVisible(
77
0
            getToolboxResourceName( _nSlotId ) );
78
0
    }
79
80
81
    OUString FormToolboxes::getToolboxResourceName( sal_uInt16 _nSlotId )
82
0
    {
83
0
        OSL_ENSURE( _nSlotId == SID_FM_FORM_DESIGN_TOOLS ,
84
0
            "FormToolboxes::getToolboxResourceName: unsupported slot!" );
85
86
0
        return u"private:resource/toolbar/formdesign"_ustr;
87
0
    }
88
89
90
}
91
92
93
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */