Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/unoidl/unomodule.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 <com/sun/star/frame/DispatchResultState.hpp>
21
#include <cppuhelper/supportsservice.hxx>
22
23
#include <sddll.hxx>
24
#include <sdmod.hxx>
25
#include "unomodule.hxx"
26
#include <sfx2/objface.hxx>
27
#include <sfx2/bindings.hxx>
28
#include <sfx2/request.hxx>
29
#include <vcl/svapp.hxx>
30
31
using namespace ::com::sun::star;
32
33
    // XNotifyingDispatch
34
void SAL_CALL SdUnoModule::dispatchWithNotification( const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs, const uno::Reference< frame::XDispatchResultListener >& xListener )
35
0
{
36
    // there is no guarantee, that we are holded alive during this method!
37
    // May the outside dispatch container will be updated by a CONTEXT_CHANGED
38
    // asynchronous ...
39
0
    uno::Reference< uno::XInterface > xThis(static_cast< frame::XNotifyingDispatch* >(this));
40
41
0
    SolarMutexGuard aGuard;
42
0
    SdDLL::Init();
43
0
    SdModule* mod = SdModule::get();
44
0
    const SfxSlot* pSlot = mod->GetInterface()->GetSlot( aURL.Complete );
45
46
0
    sal_Int16 aState = frame::DispatchResultState::DONTKNOW;
47
0
    if ( !pSlot )
48
0
        aState = frame::DispatchResultState::FAILURE;
49
0
    else
50
0
    {
51
0
        SfxRequest aReq( pSlot, aArgs, SfxCallMode::SYNCHRON, mod->GetPool() );
52
0
        const SfxPoolItemHolder aResult(mod->ExecuteSlot(aReq));
53
0
        if (aResult)
54
0
            aState = frame::DispatchResultState::SUCCESS;
55
0
        else
56
0
            aState = frame::DispatchResultState::FAILURE;
57
0
    }
58
59
0
    if ( xListener.is() )
60
0
    {
61
0
        xListener->dispatchFinished(
62
0
            frame::DispatchResultEvent(
63
0
                    xThis, aState, uno::Any()));
64
0
    }
65
0
}
66
    // XDispatch
67
void SAL_CALL SdUnoModule::dispatch( const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs )
68
0
{
69
0
    dispatchWithNotification(aURL, aArgs, uno::Reference< frame::XDispatchResultListener >());
70
0
}
71
72
void SAL_CALL SdUnoModule::addStatusListener(const uno::Reference< frame::XStatusListener > &, const util::URL&)
73
0
{
74
0
}
75
76
void SAL_CALL SdUnoModule::removeStatusListener(const uno::Reference< frame::XStatusListener > &, const util::URL&)
77
0
{
78
0
}
79
80
uno::Sequence< uno::Reference< frame::XDispatch > > SAL_CALL SdUnoModule::queryDispatches( const uno::Sequence< frame::DispatchDescriptor >& seqDescripts )
81
0
{
82
0
    sal_Int32 nCount = seqDescripts.getLength();
83
0
    uno::Sequence< uno::Reference< frame::XDispatch > > lDispatcher( nCount );
84
85
0
    std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.getArray(),
86
0
        [this](const frame::DispatchDescriptor& rDescr) -> uno::Reference<frame::XDispatch> {
87
0
            return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); });
88
89
0
    return lDispatcher;
90
0
}
91
92
// XDispatchProvider
93
uno::Reference< frame::XDispatch > SAL_CALL SdUnoModule::queryDispatch( const util::URL& aURL, const OUString&, sal_Int32 )
94
0
{
95
0
    SolarMutexGuard aGuard;
96
0
    SdDLL::Init();
97
0
    const SfxSlot* pSlot = SdModule::get()->GetInterface()->GetSlot(aURL.Complete);
98
99
0
    uno::Reference< frame::XDispatch > xSlot;
100
0
    if ( pSlot )
101
0
        xSlot = this;
102
103
0
    return xSlot;
104
0
}
105
106
// XServiceInfo
107
OUString SAL_CALL SdUnoModule::getImplementationName(  )
108
0
{
109
0
    return u"com.sun.star.comp.Draw.DrawingModule"_ustr;
110
0
}
111
112
sal_Bool SAL_CALL SdUnoModule::supportsService( const OUString& sServiceName )
113
0
{
114
0
    return cppu::supportsService(this, sServiceName);
115
0
}
116
117
uno::Sequence< OUString > SAL_CALL SdUnoModule::getSupportedServiceNames(  )
118
0
{
119
0
    return { u"com.sun.star.drawing.ModuleDispatcher"_ustr };
120
0
}
121
122
123
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
124
com_sun_star_comp_Draw_DrawingModule_get_implementation(css::uno::XComponentContext* ,
125
                                                        css::uno::Sequence<css::uno::Any> const &)
126
0
{
127
0
    SolarMutexGuard aGuard;
128
129
0
    return cppu::acquire(new SdUnoModule);
130
0
}
131
132
133
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */