1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dbaccess.hxx"
26 
27 #include "progresscapture.hxx"
28 #include "migrationprogress.hxx"
29 
30 /** === begin UNO includes === **/
31 /** === end UNO includes === **/
32 
33 #include <vcl/svapp.hxx>
34 #include <vos/mutex.hxx>
35 
36 //........................................................................
37 namespace dbmm
38 {
39 //........................................................................
40 
41 	/** === begin UNO using === **/
42 	using ::com::sun::star::uno::Reference;
43 	using ::com::sun::star::uno::XInterface;
44 	using ::com::sun::star::uno::UNO_QUERY;
45 	using ::com::sun::star::uno::UNO_QUERY_THROW;
46 	using ::com::sun::star::uno::UNO_SET_THROW;
47 	using ::com::sun::star::uno::Exception;
48 	using ::com::sun::star::uno::RuntimeException;
49 	using ::com::sun::star::uno::Any;
50 	using ::com::sun::star::uno::makeAny;
51 	/** === end UNO using === **/
52 
53 	//====================================================================
54 	//= ProgressCapture_Data
55 	//====================================================================
56     struct ProgressCapture_Data
57     {
58         ProgressCapture_Data( const ::rtl::OUString& _rObjectName, IMigrationProgress& _rMasterProgress )
59             :sObjectName( _rObjectName )
60             ,rMasterProgress( _rMasterProgress )
61             ,bDisposed( false )
62         {
63         }
64 
65         ::rtl::OUString     sObjectName;
66         IMigrationProgress& rMasterProgress;
67         bool                bDisposed;
68     };
69 
70 	//====================================================================
71 	//= ProgressCapture
72 	//====================================================================
73 	//--------------------------------------------------------------------
74     ProgressCapture::ProgressCapture( const ::rtl::OUString& _rObjectName, IMigrationProgress& _rMasterProgress )
75         :m_pData( new ProgressCapture_Data( _rObjectName, _rMasterProgress ) )
76     {
77     }
78 
79     //--------------------------------------------------------------------
80     ProgressCapture::~ProgressCapture()
81     {
82     }
83 
84     //--------------------------------------------------------------------
85     void ProgressCapture::dispose()
86     {
87         ::vos::OGuard aGuard( Application::GetSolarMutex() );
88         m_pData->bDisposed = true;
89     }
90 
91     //--------------------------------------------------------------------
92     void SAL_CALL ProgressCapture::start( const ::rtl::OUString& _rText, ::sal_Int32 _nRange ) throw (RuntimeException)
93     {
94         ::vos::OGuard aGuard( Application::GetSolarMutex() );
95         if ( !m_pData->bDisposed )
96             m_pData->rMasterProgress.startObject( m_pData->sObjectName, _rText, _nRange );
97     }
98 
99     //--------------------------------------------------------------------
100     void SAL_CALL ProgressCapture::end(  ) throw (RuntimeException)
101     {
102         ::vos::OGuard aGuard( Application::GetSolarMutex() );
103         if ( !m_pData->bDisposed )
104             m_pData->rMasterProgress.endObject();
105     }
106 
107     //--------------------------------------------------------------------
108     void SAL_CALL ProgressCapture::setText( const ::rtl::OUString& _rText ) throw (RuntimeException)
109     {
110         ::vos::OGuard aGuard( Application::GetSolarMutex() );
111         if ( !m_pData->bDisposed )
112             m_pData->rMasterProgress.setObjectProgressText( _rText );
113     }
114 
115     //--------------------------------------------------------------------
116     void SAL_CALL ProgressCapture::setValue( ::sal_Int32 _nValue ) throw (RuntimeException)
117     {
118         ::vos::OGuard aGuard( Application::GetSolarMutex() );
119         if ( !m_pData->bDisposed )
120             m_pData->rMasterProgress.setObjectProgressValue( _nValue );
121     }
122 
123     //--------------------------------------------------------------------
124     void SAL_CALL ProgressCapture::reset(  ) throw (RuntimeException)
125     {
126         OSL_ENSURE( false, "ProgressCapture::reset: not implemented!" );
127     }
128 
129 //........................................................................
130 } // namespace dbmm
131 //........................................................................
132