Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sfx2/source/bastyp/fltlst.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 "fltlst.hxx"
22
23
#include <com/sun/star/document/FilterConfigRefresh.hpp>
24
#include <comphelper/processfactory.hxx>
25
26
#include <sfx2/fcontnr.hxx>
27
28
#include <vcl/svapp.hxx>
29
#include <cppuhelper/implbase.hxx>
30
31
32
//  namespaces
33
34
using namespace ::com::sun::star;
35
36
namespace {
37
38
class SfxRefreshListener : public ::cppu::WeakImplHelper<css::util::XRefreshListener>
39
{
40
    private:
41
        SfxFilterListener *m_pOwner;
42
43
    public:
44
        explicit SfxRefreshListener(SfxFilterListener *pOwner)
45
0
            : m_pOwner(pOwner)
46
0
        {
47
0
        }
48
49
        // util.XRefreshListener
50
        virtual void SAL_CALL refreshed( const css::lang::EventObject& rEvent ) override
51
0
        {
52
0
            m_pOwner->refreshed(rEvent);
53
0
        }
54
55
        // lang.XEventListener
56
        virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent) override
57
0
        {
58
0
            m_pOwner->disposing(rEvent);
59
0
        }
60
};
61
62
}
63
64
/*-************************************************************************************************************
65
    @short          ctor
66
    @descr          These initialize an instance of a SfxFilterListener class. Created object listen automatically
67
                    on right FilterFactory-Service for all changes and synchronize right SfxFilterContainer with
68
                    corresponding framework-cache.
69
                    We use given "sFactory" value to decide which query must be used to fill "pContainer" with new values.
70
                    Given "pContainer" hold us alive as uno reference and we use it to synchronize it with framework caches.
71
                    We will die, if he die! see dtor for further information.
72
73
    @seealso        dtor
74
    @seealso        class framework::FilterCache
75
    @seealso        service ::document::FilterFactory
76
77
    @param          "sFactory"  , short name of module which contains filter container
78
    @param          "pContainer", pointer to filter container which will be informed
79
    @onerror        We show some assertions in non product version.
80
                    Otherwise we do nothing!
81
    @threadsafe     yes
82
*//*-*************************************************************************************************************/
83
SfxFilterListener::SfxFilterListener()
84
0
    : m_xFilterCache(document::FilterConfigRefresh::create( comphelper::getProcessComponentContext() ) ),
85
0
      m_xFilterCacheListener(new SfxRefreshListener(this))
86
0
{
87
0
    m_xFilterCache->addRefreshListener( m_xFilterCacheListener );
88
0
}
89
90
SfxFilterListener::~SfxFilterListener()
91
0
{
92
0
}
93
94
void SfxFilterListener::refreshed( const lang::EventObject& aSource )
95
0
{
96
0
    SolarMutexGuard aGuard;
97
0
    uno::Reference< util::XRefreshable > xContainer( aSource.Source, uno::UNO_QUERY );
98
0
    if(
99
0
        (xContainer.is()           ) &&
100
0
        (xContainer==m_xFilterCache)
101
0
      )
102
0
    {
103
0
        SfxFilterContainer::ReadFilters_Impl( true );
104
0
    }
105
0
}
106
107
void SfxFilterListener::disposing( const lang::EventObject& aSource )
108
0
{
109
0
    SolarMutexGuard aGuard;
110
0
    uno::Reference< util::XRefreshable > xNotifier( aSource.Source, uno::UNO_QUERY );
111
0
    if (!xNotifier.is())
112
0
        return;
113
114
0
    if (xNotifier == m_xFilterCache)
115
0
        m_xFilterCache.clear();
116
0
}
117
118
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */