Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/unotools/source/ucbhelper/progresshandlerwrap.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 <unotools/progresshandlerwrap.hxx>
21
#include <com/sun/star/task/XStatusIndicator.hpp>
22
#include <utility>
23
24
namespace utl
25
{
26
27
using namespace ::com::sun::star::uno;
28
using namespace ::com::sun::star::task;
29
using namespace ::com::sun::star::ucb;
30
31
ProgressHandlerWrap::ProgressHandlerWrap( css::uno::Reference< css::task::XStatusIndicator > xSI )
32
0
: m_xStatusIndicator(std::move( xSI ))
33
0
{
34
0
}
35
36
static bool getStatusFromAny_Impl( const Any& aAny, OUString& aText, sal_Int32& nNum )
37
0
{
38
0
    bool bNumIsSet = false;
39
40
0
    Sequence< Any > aSetList;
41
0
    if( aAny >>= aSetList )
42
0
        for (const auto& rSet : aSetList)
43
0
        {
44
0
            if( !bNumIsSet && ( rSet >>= nNum ) )
45
0
                bNumIsSet = true;
46
0
            else
47
0
                aText.isEmpty() && ( rSet >>= aText );
48
0
        }
49
50
0
    return bNumIsSet;
51
0
}
52
53
void SAL_CALL ProgressHandlerWrap::push( const Any& Status )
54
0
{
55
0
    if( !m_xStatusIndicator.is() )
56
0
        return;
57
58
0
    OUString aText;
59
0
    sal_Int32 nRange;
60
61
0
    if( getStatusFromAny_Impl( Status, aText, nRange ) )
62
0
        m_xStatusIndicator->start( aText, nRange );
63
0
}
64
65
void SAL_CALL ProgressHandlerWrap::update( const Any& Status )
66
0
{
67
0
    if( !m_xStatusIndicator.is() )
68
0
        return;
69
70
0
    OUString aText;
71
0
    sal_Int32 nValue;
72
73
0
    if( getStatusFromAny_Impl( Status, aText, nValue ) )
74
0
    {
75
0
        if( !aText.isEmpty() ) m_xStatusIndicator->setText( aText );
76
0
        m_xStatusIndicator->setValue( nValue );
77
0
    }
78
0
}
79
80
void SAL_CALL ProgressHandlerWrap::pop()
81
0
{
82
0
    if( m_xStatusIndicator.is() )
83
0
        m_xStatusIndicator->end();
84
0
}
85
86
} // namespace utl
87
88
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */