1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <unotools/progresshandlerwrap.hxx>
21 #include <com/sun/star/task/XStatusIndicator.hpp>
27 using namespace ::com::sun::star::uno
;
28 using namespace ::com::sun::star::task
;
29 using namespace ::com::sun::star::ucb
;
31 ProgressHandlerWrap::ProgressHandlerWrap( css::uno::Reference
< css::task::XStatusIndicator
> xSI
)
32 : m_xStatusIndicator(std::move( xSI
))
36 static bool getStatusFromAny_Impl( const Any
& aAny
, OUString
& aText
, sal_Int32
& nNum
)
38 bool bNumIsSet
= false;
40 Sequence
< Any
> aSetList
;
41 if( aAny
>>= aSetList
)
42 for( const auto& rSet
: std::as_const(aSetList
) )
44 if( !bNumIsSet
&& ( rSet
>>= nNum
) )
47 aText
.isEmpty() && ( rSet
>>= aText
);
53 void SAL_CALL
ProgressHandlerWrap::push( const Any
& Status
)
55 if( !m_xStatusIndicator
.is() )
61 if( getStatusFromAny_Impl( Status
, aText
, nRange
) )
62 m_xStatusIndicator
->start( aText
, nRange
);
65 void SAL_CALL
ProgressHandlerWrap::update( const Any
& Status
)
67 if( !m_xStatusIndicator
.is() )
73 if( getStatusFromAny_Impl( Status
, aText
, nValue
) )
75 if( !aText
.isEmpty() ) m_xStatusIndicator
->setText( aText
);
76 m_xStatusIndicator
->setValue( nValue
);
80 void SAL_CALL
ProgressHandlerWrap::pop()
82 if( m_xStatusIndicator
.is() )
83 m_xStatusIndicator
->end();
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */