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_MIGRATIONLOG_HXX 25 #define DBACCESS_MIGRATIONLOG_HXX 26 27 #include "dbmm_types.hxx" 28 29 /** === begin UNO includes === **/ 30 /** === end UNO includes === **/ 31 32 #include <rtl/ustring.hxx> 33 34 #include <memory> 35 36 //........................................................................ 37 namespace dbmm 38 { 39 //........................................................................ 40 41 typedef sal_Int16 DocumentID; 42 struct MigrationError; 43 44 //==================================================================== 45 //= MigrationLog 46 //==================================================================== 47 struct MigrationLog_Data; 48 class MigrationLog 49 { 50 public: 51 MigrationLog(); 52 ~MigrationLog(); 53 54 //---------------------------------------------------------------- 55 //- event logging 56 57 /** logs an unrecoverable error during the migration process 58 */ 59 void logFailure( const MigrationError& _rError ); 60 61 /** logs a recoverable (or at least ignorable) error during the migration process 62 */ 63 void logRecoverable( const MigrationError& _rError ); 64 65 /// checks whether logFailure has been called 66 bool hadFailure() const; 67 68 /// logs the fact that the database document has been backed up 69 void backedUpDocument( const ::rtl::OUString& _rNewDocumentLocation ); 70 71 /** logs that the migration for a certain sub document has been started, returns 72 a unique ID for this sub document which is to be used in later calls 73 */ 74 DocumentID startedDocument( const SubDocumentType _eType, const ::rtl::OUString& _rName ); 75 76 /** logs the event that a macro or script library has been moved from within a 77 sub document to the database document 78 */ 79 void movedLibrary( 80 const DocumentID _nDocID, 81 const ScriptType _eScriptType, 82 const ::rtl::OUString& _rOriginalLibName, 83 const ::rtl::OUString& _rNewLibName 84 ); 85 86 /** logs that the migration for a certain document has been finished 87 */ 88 void finishedDocument( const DocumentID _nDocID ); 89 90 //---------------------------------------------------------------- 91 //- information retrieval 92 93 /** retrieves the new name of a library 94 95 The new library name must previously have been logger by calling 96 <member>movedLibrary</member>. If not, an assertion will be raised in 97 the non-product builds, and an empty string will be returned. 98 */ 99 const ::rtl::OUString& 100 getNewLibraryName( 101 DocumentID _nDocID, 102 ScriptType _eScriptType, 103 const ::rtl::OUString& _rOriginalLibName 104 ) const; 105 106 /** determines whether for the given document, any library needed to be (and was) moved 107 */ 108 bool movedAnyLibrary( const DocumentID ); 109 110 /** provides a human-readable version of the log, explaining a user what happened during 111 the migration. 112 */ 113 ::rtl::OUString 114 getCompleteLog() const; 115 116 private: 117 ::std::auto_ptr< MigrationLog_Data > m_pData; 118 }; 119 120 //........................................................................ 121 } // namespace dbmm 122 //........................................................................ 123 124 #endif // DBACCESS_MIGRATIONLOG_HXX 125