1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_DESKTOP_SOURCE_MIGRATION_MIGRATION_IMPL_HXX
20 #define INCLUDED_DESKTOP_SOURCE_MIGRATION_MIGRATION_IMPL_HXX
25 #include <boost/unordered_map.hpp>
27 #include "migration.hxx"
29 #include <sal/types.h>
30 #include <rtl/string.hxx>
31 #include <rtl/ustring.hxx>
33 #include <com/sun/star/uno/Reference.hxx>
35 #include <com/sun/star/container/XNameAccess.hpp>
36 #include <com/sun/star/container/XIndexAccess.hpp>
37 #include <com/sun/star/container/XIndexContainer.hpp>
38 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
39 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
40 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
41 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
42 #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
49 OUString productname
; // human readeable product name
50 OUString userdata
; // file: url for user installation
53 typedef std::vector
< OUString
> strings_v
;
54 typedef std::auto_ptr
< strings_v
> strings_vr
;
59 strings_v includeFiles
;
60 strings_v excludeFiles
;
61 strings_v includeConfig
;
62 strings_v excludeConfig
;
63 strings_v includeExtensions
;
64 strings_v excludeExtensions
;
68 struct supported_migration
72 strings_v supported_versions
;
75 typedef std::vector
< migration_step
> migrations_v
;
76 typedef std::auto_ptr
< migrations_v
> migrations_vr
;
77 typedef std::vector
< supported_migration
> migrations_available
;
79 //__________________________________________
81 define the item, e.g.:menuitem, toolbaritem, to be migrated. we keep the information
82 of the command URL, the previous sibling node and the parent node of a item
86 OUString m_sParentNodeName
;
87 OUString m_sPrevSibling
;
88 OUString m_sCommandURL
;
89 css::uno::Reference
< css::container::XIndexContainer
> m_xPopupMenu
;
96 MigrationItem(const OUString
& sParentNodeName
,
97 const OUString
& sPrevSibling
,
98 const OUString
& sCommandURL
,
99 const css::uno::Reference
< css::container::XIndexContainer
> xPopupMenu
)
101 m_sParentNodeName
= sParentNodeName
;
102 m_sPrevSibling
= sPrevSibling
;
103 m_sCommandURL
= sCommandURL
;
104 m_xPopupMenu
= xPopupMenu
;
107 MigrationItem
& operator=(const MigrationItem
& aMigrationItem
)
109 m_sParentNodeName
= aMigrationItem
.m_sParentNodeName
;
110 m_sPrevSibling
= aMigrationItem
.m_sPrevSibling
;
111 m_sCommandURL
= aMigrationItem
.m_sCommandURL
;
112 m_xPopupMenu
= aMigrationItem
.m_xPopupMenu
;
117 sal_Bool
operator==(const MigrationItem
& aMigrationItem
)
119 return ( aMigrationItem
.m_sParentNodeName
== m_sParentNodeName
&&
120 aMigrationItem
.m_sPrevSibling
== m_sPrevSibling
&&
121 aMigrationItem
.m_sCommandURL
== m_sCommandURL
&&
122 aMigrationItem
.m_xPopupMenu
.is() == m_xPopupMenu
.is() );
125 OUString
GetPrevSibling() const { return m_sPrevSibling
; }
128 typedef ::boost::unordered_map
< OUString
,
129 ::std::vector
< MigrationItem
>,
131 ::std::equal_to
< OUString
> > MigrationHashMap
;
133 struct MigrationItemInfo
135 OUString m_sResourceURL
;
136 MigrationItem m_aMigrationItem
;
138 MigrationItemInfo(){}
140 MigrationItemInfo(const OUString
& sResourceURL
, const MigrationItem
& aMigrationItem
)
141 : m_sResourceURL(sResourceURL
), m_aMigrationItem(aMigrationItem
)
146 //__________________________________________
148 information for the UI elements to be migrated for one module
150 struct MigrationModuleInfo
152 OUString sModuleShortName
;
153 sal_Bool bHasMenubar
;
154 ::std::vector
< OUString
> m_vToolbars
;
156 MigrationModuleInfo():bHasMenubar(sal_False
){};
159 //__________________________________________
161 get the information before copying the ui configuration files of old version to new version
163 class NewVersionUIInfo
167 css::uno::Reference
< css::ui::XUIConfigurationManager
> getConfigManager(const OUString
& sModuleShortName
) const;
168 css::uno::Reference
< css::container::XIndexContainer
> getNewMenubarSettings(const OUString
& sModuleShortName
) const;
169 css::uno::Reference
< css::container::XIndexContainer
> getNewToolbarSettings(const OUString
& sModuleShortName
, const OUString
& sToolbarName
) const;
170 void init(const ::std::vector
< MigrationModuleInfo
>& vModulesInfo
);
174 css::uno::Sequence
< css::beans::PropertyValue
> m_lCfgManagerSeq
;
175 css::uno::Sequence
< css::beans::PropertyValue
> m_lNewVersionMenubarSettingsSeq
;
176 css::uno::Sequence
< css::beans::PropertyValue
> m_lNewVersionToolbarSettingsSeq
;
183 strings_vr m_vrVersions
;
185 migrations_available m_vMigrationsAvailable
; // list of all available migrations
186 migrations_vr m_vrMigrations
; // list of all migration specs from config
187 install_info m_aInfo
; // info about the version being migrated
188 strings_vr m_vrFileList
; // final list of files to be copied
189 MigrationHashMap m_aOldVersionItemsHashMap
;
190 MigrationHashMap m_aNewVersionItemsHashMap
;
191 OUString m_sModuleIdentifier
;
193 // functions to control the migration process
194 bool readAvailableMigrations(migrations_available
&);
195 bool alreadyMigrated();
196 migrations_vr
readMigrationSteps(const OUString
& rMigrationName
);
197 sal_Int32
findPreferedMigrationProcess(const migrations_available
&);
198 #if defined UNX && ! defined MACOSX
199 OUString
preXDGConfigDir(const OUString
& rConfigDir
);
201 void setInstallInfoIfExist(install_info
& aInfo
, const OUString
& rConfigDir
, const OUString
& rVersion
);
202 install_info
findInstallation(const strings_v
& rVersions
);
203 strings_vr
compileFileList();
206 strings_vr
getAllFiles(const OUString
& baseURL
) const;
207 strings_vr
applyPatterns(const strings_v
& vSet
, const strings_v
& vPatterns
) const;
208 css::uno::Reference
< css::container::XNameAccess
> getConfigAccess(const sal_Char
* path
, sal_Bool rw
=sal_False
);
210 ::std::vector
< MigrationModuleInfo
> dectectUIChangesForAllModules() const;
211 void compareOldAndNewConfig(const OUString
& sParentNodeName
,
212 const css::uno::Reference
< css::container::XIndexContainer
>& xOldIndexContainer
,
213 const css::uno::Reference
< css::container::XIndexContainer
>& xNewIndexContainer
,
214 const OUString
& sToolbarName
);
215 void mergeOldToNewVersion(const css::uno::Reference
< css::ui::XUIConfigurationManager
>& xCfgManager
,
216 const css::uno::Reference
< css::container::XIndexContainer
>& xIndexContainer
,
217 const OUString
& sModuleIdentifier
,
218 const OUString
& sResourceURL
);
220 // actual processing function that perform the migration steps
226 void setMigrationCompleted();
227 bool checkMigrationCompleted();
232 bool initializeMigration();
233 sal_Bool
doMigration();
234 OUString
getOldVersionName();
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */