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>
25 using namespace ::com::sun::star::uno
;
26 using namespace ::com::sun::star::task
;
27 using namespace ::com::sun::star::ucb
;
29 ProgressHandlerWrap::ProgressHandlerWrap( ::com::sun::star::uno::Reference
< ::com::sun::star::task::XStatusIndicator
> xSI
)
30 : m_xStatusIndicator( xSI
)
34 sal_Bool
getStatusFromAny_Impl( const Any
& aAny
, ::rtl::OUString
& aText
, sal_Int32
& nNum
)
36 sal_Bool bNumIsSet
= sal_False
;
38 Sequence
< Any
> aSetList
;
39 if( ( aAny
>>= aSetList
) && aSetList
.getLength() )
40 for( int ind
= 0; ind
< aSetList
.getLength(); ind
++ )
42 if( !bNumIsSet
&& ( aSetList
[ind
] >>= nNum
) )
45 aText
.isEmpty() && ( aSetList
[ind
] >>= aText
);
51 void SAL_CALL
ProgressHandlerWrap::push( const Any
& Status
)
52 throw( RuntimeException
)
54 if( !m_xStatusIndicator
.is() )
57 ::rtl::OUString aText
;
60 if( getStatusFromAny_Impl( Status
, aText
, nRange
) )
61 m_xStatusIndicator
->start( aText
, nRange
);
64 void SAL_CALL
ProgressHandlerWrap::update( const Any
& Status
)
65 throw( RuntimeException
)
67 if( !m_xStatusIndicator
.is() )
70 ::rtl::OUString aText
;
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()
81 throw( RuntimeException
)
83 if( m_xStatusIndicator
.is() )
84 m_xStatusIndicator
->end();
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */