Update ooo320-m1
[ooovba.git] / desktop / source / migration / migration_impl.hxx
blob34ba8bd62fed3a29db4b8030307fcf392905d0d4
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: migration_impl.hxx,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 ************************************************************************/
30 #ifndef _DESKTOP_MIGRATION_IMPL_HXX_
31 #define _DESKTOP_MIGRATION_IMPL_HXX_
33 #include <vector>
34 #include <algorithm>
35 #include <memory>
37 #include "migration.hxx"
39 #include <sal/types.h>
40 #include <rtl/string.hxx>
41 #include <rtl/ustring.hxx>
43 #include <com/sun/star/uno/Reference.hxx>
45 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
46 #include <com/sun/star/container/XNameAccess.hpp>
48 #define NS_CSS com::sun::star
49 #define NS_UNO com::sun::star::uno
51 namespace desktop
54 struct install_info
56 rtl::OUString productname; // human readeable product name
57 rtl::OUString userdata; // file: url for user installation
60 typedef std::vector< rtl::OUString > strings_v;
61 typedef std::auto_ptr< strings_v > strings_vr;
63 struct migration_step
65 rtl::OUString name;
66 strings_v includeFiles;
67 strings_v excludeFiles;
68 strings_v includeConfig;
69 strings_v excludeConfig;
70 strings_v configComponents;
71 rtl::OUString service;
74 typedef std::vector< migration_step > migrations_v;
75 typedef std::auto_ptr< migrations_v > migrations_vr;
77 class MigrationImpl
79 public:
80 struct VersionNumber
82 sal_Int32 mnMajor;
83 sal_Int32 mnMinor;
84 sal_Int32 mnMicro;
86 explicit VersionNumber();
87 explicit VersionNumber(sal_Int32 nMajor, sal_Int32 nMinor, sal_Int32 nMicro);
90 private:
91 strings_vr m_vrVersions;
92 NS_UNO::Reference< NS_CSS::lang::XMultiServiceFactory > m_xFactory;
93 migrations_vr m_vrMigrations; // list of all migration specs from config
94 install_info m_aInfo; // info about the version being migrated
95 strings_vr m_vrFileList; // final list of files to be copied
96 strings_vr m_vrConfigList; // final list of nodes to be copied
97 strings_vr m_vrServiceList; // final list of services to be called
98 ::rtl::OUString m_aAppVerStr;
99 bool m_bMigrationCompleted;
100 VersionNumber m_aAppVerNum;
101 VersionNumber m_aConfigVerNum;
103 void initDirectoryMigration();
105 // initializer functions...
106 migrations_vr readMigrationSteps();
107 install_info findInstallation();
108 strings_vr compileFileList();
109 strings_vr compileConfigList();
110 strings_vr compileServiceList();
112 // helpers
113 void substract(strings_v& va, const strings_v& vb_c) const;
114 strings_vr getAllFiles(const rtl::OUString& baseURL) const;
115 strings_vr applyPatterns(const strings_v& vSet, const strings_v& vPatterns) const;
116 NS_UNO::Reference< NS_CSS::container::XNameAccess > getConfigAccess(const sal_Char* path, sal_Bool rw=sal_False);
118 // actual processing function that perform the migration steps
119 void copyFiles();
120 void copyConfig();
121 void runServices();
122 void refresh();
123 void transKeyConfig();
124 void cleanCSVImportCharSet();
125 void transCalcFormulaConfig();
127 void setMigrationCompleted();
129 public:
130 MigrationImpl(const NS_UNO::Reference< NS_CSS::lang::XMultiServiceFactory >&);
131 ~MigrationImpl();
132 sal_Bool doMigration();
133 sal_Bool checkMigration();
134 rtl::OUString getOldVersionName();
139 #undef NS_CSS
140 #undef NS_UNO
142 #endif