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>
26 using namespace ::com::sun::star::uno
;
27 using namespace ::com::sun::star::task
;
28 using namespace ::com::sun::star::ucb
;
30 ProgressHandlerWrap::ProgressHandlerWrap( css::uno::Reference
< css::task::XStatusIndicator
> const & xSI
)
31 : m_xStatusIndicator( xSI
)
35 static bool getStatusFromAny_Impl( const Any
& aAny
, OUString
& aText
, sal_Int32
& nNum
)
37 bool bNumIsSet
= false;
39 Sequence
< Any
> aSetList
;
40 if( aAny
>>= aSetList
)
41 for( const auto& rSet
: std::as_const(aSetList
) )
43 if( !bNumIsSet
&& ( rSet
>>= nNum
) )
46 aText
.isEmpty() && ( rSet
>>= aText
);
52 void SAL_CALL
ProgressHandlerWrap::push( const Any
& Status
)
54 if( !m_xStatusIndicator
.is() )
60 if( getStatusFromAny_Impl( Status
, aText
, nRange
) )
61 m_xStatusIndicator
->start( aText
, nRange
);
64 void SAL_CALL
ProgressHandlerWrap::update( const Any
& Status
)
66 if( !m_xStatusIndicator
.is() )
72 if( getStatusFromAny_Impl( Status
, aText
, nValue
) )
74 if( !aText
.isEmpty() ) m_xStatusIndicator
->setText( aText
);
75 m_xStatusIndicator
->setValue( nValue
);
79 void SAL_CALL
ProgressHandlerWrap::pop()
81 if( m_xStatusIndicator
.is() )
82 m_xStatusIndicator
->end();
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */