merge the formfield patch from ooo-build
[ooovba.git] / unotools / source / ucbhelper / progresshandlerwrap.cxx
blob9c278aeeccdfc0cac5187fe1ac5a1ad36f2ab3f7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: progresshandlerwrap.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_unotools.hxx"
33 #include <unotools/progresshandlerwrap.hxx>
35 namespace utl
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::task;
40 using namespace ::com::sun::star::ucb;
42 ProgressHandlerWrap::ProgressHandlerWrap( ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > xSI )
43 : m_xStatusIndicator( xSI )
47 sal_Bool getStatusFromAny_Impl( const Any& aAny, ::rtl::OUString& aText, sal_Int32& nNum )
49 sal_Bool bNumIsSet = sal_False;
51 Sequence< Any > aSetList;
52 if( ( aAny >>= aSetList ) && aSetList.getLength() )
53 for( int ind = 0; ind < aSetList.getLength(); ind++ )
55 if( !bNumIsSet && ( aSetList[ind] >>= nNum ) )
56 bNumIsSet = sal_True;
57 else
58 !aText.getLength() && ( aSetList[ind] >>= aText );
61 return bNumIsSet;
64 void SAL_CALL ProgressHandlerWrap::push( const Any& Status )
65 throw( RuntimeException )
67 if( !m_xStatusIndicator.is() )
68 return;
70 ::rtl::OUString aText;
71 sal_Int32 nRange;
73 if( getStatusFromAny_Impl( Status, aText, nRange ) )
74 m_xStatusIndicator->start( aText, nRange );
77 void SAL_CALL ProgressHandlerWrap::update( const Any& Status )
78 throw( RuntimeException )
80 if( !m_xStatusIndicator.is() )
81 return;
83 ::rtl::OUString aText;
84 sal_Int32 nValue;
86 if( getStatusFromAny_Impl( Status, aText, nValue ) )
88 if( aText.getLength() ) m_xStatusIndicator->setText( aText );
89 m_xStatusIndicator->setValue( nValue );
93 void SAL_CALL ProgressHandlerWrap::pop()
94 throw( RuntimeException )
96 if( m_xStatusIndicator.is() )
97 m_xStatusIndicator->end();
100 } // namespace utl