1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef DBACCESS_MIGRATIONLOG_HXX
29 #define DBACCESS_MIGRATIONLOG_HXX
30 
31 #include "dbmm_types.hxx"
32 
33 /** === begin UNO includes === **/
34 /** === end UNO includes === **/
35 
36 #include <rtl/ustring.hxx>
37 
38 #include <memory>
39 
40 //........................................................................
41 namespace dbmm
42 {
43 //........................................................................
44 
45     typedef sal_Int16 DocumentID;
46     struct MigrationError;
47 
48 	//====================================================================
49 	//= MigrationLog
50 	//====================================================================
51     struct MigrationLog_Data;
52 	class MigrationLog
53 	{
54     public:
55         MigrationLog();
56         ~MigrationLog();
57 
58 	    //----------------------------------------------------------------
59 	    //- event logging
60 
61         /** logs an unrecoverable error during the migration process
62         */
63         void        logFailure( const MigrationError& _rError );
64 
65         /** logs a recoverable (or at least ignorable) error during the migration process
66         */
67         void        logRecoverable( const MigrationError& _rError );
68 
69         /// checks whether logFailure has been called
70         bool        hadFailure() const;
71 
72         /// logs the fact that the database document has been backed up
73         void        backedUpDocument( const ::rtl::OUString& _rNewDocumentLocation );
74 
75         /** logs that the migration for a certain sub document has been started, returns
76             a unique ID for this sub document which is to be used in later calls
77         */
78         DocumentID  startedDocument( const SubDocumentType _eType, const ::rtl::OUString& _rName );
79 
80         /** logs the event that a macro or script library has been moved from within a
81             sub document to the database document
82         */
83         void        movedLibrary(
84                         const DocumentID _nDocID,
85                         const ScriptType _eScriptType,
86                         const ::rtl::OUString& _rOriginalLibName,
87                         const ::rtl::OUString& _rNewLibName
88                     );
89 
90         /** logs that the migration for a certain document has been finished
91         */
92         void        finishedDocument( const DocumentID _nDocID );
93 
94 	    //----------------------------------------------------------------
95 	    //- information retrieval
96 
97         /** retrieves the new name of a library
98 
99             The new library name must previously have been logger by calling
100             <member>movedLibrary</member>. If not, an assertion will be raised in
101             the non-product builds, and an empty string will be returned.
102         */
103         const ::rtl::OUString&
104                     getNewLibraryName(
105                         DocumentID _nDocID,
106                         ScriptType _eScriptType,
107                         const ::rtl::OUString& _rOriginalLibName
108                     ) const;
109 
110         /** determines whether for the given document, any library needed to be (and was) moved
111         */
112         bool    movedAnyLibrary( const DocumentID );
113 
114         /** provides a human-readable version of the log, explaining a user what happened during
115             the migration.
116         */
117         ::rtl::OUString
118                     getCompleteLog() const;
119 
120     private:
121         ::std::auto_ptr< MigrationLog_Data >    m_pData;
122 	};
123 
124 //........................................................................
125 } // namespace dbmm
126 //........................................................................
127 
128 #endif // DBACCESS_MIGRATIONLOG_HXX
129