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 #ifndef DBACCESS_MIGRATIONENGINE_HXX
25 #define DBACCESS_MIGRATIONENGINE_HXX
26 
27 /** === begin UNO includes === **/
28 #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
29 /** === end UNO includes === **/
30 
31 #include <comphelper/componentcontext.hxx>
32 
33 #include <memory>
34 
35 namespace comphelper {
36     class ComponentContext;
37 }
38 
39 //........................................................................
40 namespace dbmm
41 {
42 //........................................................................
43 
44     class IMigrationProgress;
45     class MigrationLog;
46 
47     //====================================================================
48 	//= MigrationEngine
49 	//====================================================================
50     class MigrationEngine_Impl;
51 	class MigrationEngine
52 	{
53     public:
54         /** creates the migration engine
55             @param  _rxDocument
56                 the document whose macros/scripts should be migrated
57             @param  _rProgress
58                 a callback for notifying progress. Beware of lifetimes here: The progress callback,
59                 passed herein as reference, must live as long as the engine instance lives.
60         */
61         MigrationEngine(
62             const ::comphelper::ComponentContext& _rContext,
63             const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XOfficeDatabaseDocument >& _rxDocument,
64             IMigrationProgress& _rProgress,
65             MigrationLog& _rLogger
66         );
67 
68         ~MigrationEngine();
69 
70         sal_Int32   getFormCount() const;
71         sal_Int32   getReportCount() const;
72 
73         /** starts migrating the scripts and macros in the forms/reports to the database
74             document.
75 
76             This process cannot be cancelled, as it would leave the document in an inconsistent
77             state.
78 
79             When the function returns, then the migration is finished.
80 
81             @return
82                 whether or not the migration was successful. If it wasn't, then an error has been reported
83                 to the user, using the document's interaction handler. If no such interaction handler
84                 was present, then the error has been silenced.
85         */
86         bool    migrateAll();
87 
88     private:
89         ::std::auto_ptr< MigrationEngine_Impl > m_pImpl;
90 	};
91 
92 //........................................................................
93 } // namespace dbmm
94 //........................................................................
95 
96 #endif // DBACCESS_MIGRATIONENGINE_HXX
97