Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/source/ui/sidebar/ScPanelFactory.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 "ScPanelFactory.hxx"
21
22
#include "AlignmentPropertyPanel.hxx"
23
#include "CellAppearancePropertyPanel.hxx"
24
#include "NumberFormatPropertyPanel.hxx"
25
#include "DatabasePropertyPanel.hxx"
26
#include <navipi.hxx>
27
#include <dwfunctr.hxx>
28
29
#include <sfx2/sidebar/SidebarPanelBase.hxx>
30
#include <vcl/weld/TransportAsXWindow.hxx>
31
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
32
#include <comphelper/namedvaluecollection.hxx>
33
#include <cppuhelper/exc_hlp.hxx>
34
#include <cppuhelper/supportsservice.hxx>
35
36
using namespace css;
37
using namespace css::uno;
38
39
namespace sc::sidebar {
40
41
ScPanelFactory::ScPanelFactory()
42
0
{
43
0
}
Unexecuted instantiation: sc::sidebar::ScPanelFactory::ScPanelFactory()
Unexecuted instantiation: sc::sidebar::ScPanelFactory::ScPanelFactory()
44
45
ScPanelFactory::~ScPanelFactory()
46
0
{
47
0
}
48
49
Reference<ui::XUIElement> SAL_CALL ScPanelFactory::createUIElement (
50
    const OUString& rsResourceURL,
51
    const ::css::uno::Sequence<css::beans::PropertyValue>& rArguments)
52
0
{
53
0
    Reference<ui::XUIElement> xElement;
54
55
0
    try
56
0
    {
57
0
        const ::comphelper::NamedValueCollection aArguments (rArguments);
58
0
        Reference<frame::XFrame> xFrame (aArguments.getOrDefault(u"Frame"_ustr, Reference<frame::XFrame>()));
59
0
        Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault(u"ParentWindow"_ustr, Reference<awt::XWindow>()));
60
0
        const sal_uInt64 nBindingsValue (aArguments.getOrDefault(u"SfxBindings"_ustr, sal_uInt64(0)));
61
0
        SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
62
63
0
        weld::Widget* pParent(nullptr);
64
0
        if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
65
0
            pParent = pTunnel->getWidget();
66
67
0
        if (!pParent)
68
0
            throw RuntimeException(
69
0
                u"PanelFactory::createUIElement called without ParentWindow"_ustr,
70
0
                nullptr);
71
0
        if ( ! xFrame.is())
72
0
            throw RuntimeException(
73
0
                u"PanelFactory::createUIElement called without Frame"_ustr,
74
0
                nullptr);
75
0
        if (pBindings == nullptr)
76
0
            throw RuntimeException(
77
0
                u"PanelFactory::createUIElement called without SfxBindings"_ustr,
78
0
                nullptr);
79
80
0
        sal_Int32 nMinimumSize = -1;
81
0
        std::unique_ptr<PanelLayout> xPanel;
82
0
        if (rsResourceURL.endsWith("/AlignmentPropertyPanel"))
83
0
            xPanel = AlignmentPropertyPanel::Create( pParent, xFrame, pBindings );
84
0
        else if (rsResourceURL.endsWith("/CellAppearancePropertyPanel"))
85
0
            xPanel = CellAppearancePropertyPanel::Create( pParent, xFrame, pBindings );
86
0
        else if (rsResourceURL.endsWith("/NumberFormatPropertyPanel"))
87
0
            xPanel = NumberFormatPropertyPanel::Create( pParent, xFrame, pBindings );
88
0
        else if (rsResourceURL.endsWith("/NavigatorPanel"))
89
0
        {
90
0
            xPanel = std::make_unique<ScNavigatorDlg>(*pBindings, pParent, nullptr);
91
0
            nMinimumSize = 0;
92
0
        }
93
0
        else if (rsResourceURL.endsWith("/FunctionsPanel"))
94
0
        {
95
0
            xPanel = std::make_unique<ScFunctionWin>(pParent, pBindings);
96
0
            nMinimumSize = 0;
97
0
        }
98
0
        else if (rsResourceURL.endsWith("/DatabasePropertyPanel"))
99
0
        {
100
0
            xPanel = ScDatabasePropertyPanel::Create( pParent, xFrame, pBindings );
101
0
        }
102
103
0
        if (xPanel)
104
0
            xElement = sfx2::sidebar::SidebarPanelBase::Create(
105
0
                rsResourceURL,
106
0
                xFrame,
107
0
                std::move(xPanel),
108
0
                ui::LayoutSize(nMinimumSize,-1,-1));
109
0
    }
110
0
    catch (const uno::RuntimeException &)
111
0
    {
112
0
        throw;
113
0
    }
114
0
    catch (const uno::Exception&)
115
0
    {
116
0
        css::uno::Any anyEx = cppu::getCaughtException();
117
0
        throw lang::WrappedTargetRuntimeException(
118
0
            u"ScPanelFactory::createUIElement exception"_ustr,
119
0
            nullptr, anyEx);
120
0
    }
121
122
0
    return xElement;
123
0
}
124
125
OUString ScPanelFactory::getImplementationName()
126
0
{
127
0
    return u"org.apache.openoffice.comp.sc.sidebar.ScPanelFactory"_ustr;
128
0
}
129
130
sal_Bool ScPanelFactory::supportsService(OUString const & ServiceName)
131
0
{
132
0
    return cppu::supportsService(this, ServiceName);
133
0
}
134
135
css::uno::Sequence<OUString> ScPanelFactory::getSupportedServiceNames()
136
0
{
137
0
    return { u"com.sun.star.ui.UIElementFactory"_ustr };
138
0
}
139
140
} // end of namespace sc::sidebar
141
142
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
143
ScPanelFactory_get_implementation(css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const &)
144
0
{
145
0
    return cppu::acquire(new sc::sidebar::ScPanelFactory());
146
0
}
147
148
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */