diff options
author | Michael Meeks <michael.meeks@novell.com> | 2010-10-29 15:17:55 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2010-11-01 10:57:43 +0000 |
commit | 38d1ca3c32432137e159af1f290cd71ea616ab04 (patch) | |
tree | 1b8d86fb8f77a05a427e700bf43a1226394656b3 /desktop | |
parent | 376a80a025d039204ca6420be96b636bba7e0775 (diff) |
Simplify migration API, fix typos, and add trace output
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/inc/migration.hxx (renamed from desktop/source/migration/migration.hxx) | 8 | ||||
-rw-r--r-- | desktop/source/app/app.cxx | 5 | ||||
-rw-r--r-- | desktop/source/migration/migration.cxx | 54 | ||||
-rw-r--r-- | desktop/source/migration/migration_impl.hxx | 8 |
4 files changed, 27 insertions, 48 deletions
diff --git a/desktop/source/migration/migration.hxx b/desktop/inc/migration.hxx index dea7a379d0..3319d8d771 100644 --- a/desktop/source/migration/migration.hxx +++ b/desktop/inc/migration.hxx @@ -2,7 +2,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -37,11 +37,7 @@ namespace desktop { class Migration { public: - // starts the migration process - static void doMigration(); - static void cancelMigration(); - static sal_Bool checkMigration(); - static rtl::OUString getOldVersionName(); + static void migrateSettingsIfNecessary(); }; } #endif diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 8ab79ca363..e3ce4127c9 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -48,7 +48,7 @@ #include "userinstall.hxx" #include "desktopcontext.hxx" #include "exithelper.hxx" -#include "../migration/migration.hxx" +#include "migration.hxx" #include <svtools/javacontext.hxx> #include <com/sun/star/frame/XSessionManagerListener.hpp> @@ -1720,8 +1720,7 @@ void Desktop::Main() if ( bAbort ) return; - if ( Migration::checkMigration() ) - Migration::doMigration(); + Migration::migrateSettingsIfNecessary(); // keep a language options instance... pLanguageOptions.reset( new SvtLanguageOptions(sal_True)); diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx index 83e00d8529..be9d0147a2 100644 --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -214,9 +214,23 @@ static void releaseImpl() } } -// static main entry point for the migration process -void Migration::doMigration() +sal_Bool MigrationImpl::needsMigration() { + sal_Bool bRet = sal_False; + + if (m_aInfo.userdata.getLength() > 0 && ! checkMigrationCompleted()) + return sal_True; + + OSL_TRACE( "Migration %s\n", bRet ? "needed" : "not required" ); + + return bRet; +} + +void Migration::migrateSettingsIfNecessary() +{ + if ( !getImpl()->needsMigration() ) + return; + sal_Bool bResult = sal_False; try { bResult = getImpl()->doMigration(); @@ -231,34 +245,6 @@ void Migration::doMigration() releaseImpl(); } -void Migration::cancelMigration() -{ - releaseImpl(); -} - -sal_Bool Migration::checkMigration() -{ - return getImpl()->checkMigration(); -} - -OUString Migration::getOldVersionName() -{ - return getImpl()->getOldVersionName(); -} - -OUString MigrationImpl::getOldVersionName() -{ - return m_aInfo.productname; -} - -sal_Bool MigrationImpl::checkMigration() -{ - if (m_aInfo.userdata.getLength() > 0 && ! checkMigrationCompleted()) - return sal_True; - else - return sal_False; -} - MigrationImpl::MigrationImpl(const uno::Reference< XMultiServiceFactory >& xFactory) : m_vrVersions(new strings_v) , m_xFactory(xFactory) @@ -278,11 +264,11 @@ sal_Bool MigrationImpl::doMigration() { // compile file list for migration m_vrFileList = compileFileList(); - + sal_Bool result = sal_False; try { - NewVersionUIInfo aNewVersionUIInfo; + NewVersionUIInfo aNewVersionUIInfo; ::std::vector< MigrationModuleInfo > vModulesInfo = dectectUIChangesForAllModules(); aNewVersionUIInfo.init(vModulesInfo); @@ -708,7 +694,7 @@ strings_vr MigrationImpl::compileFileList() { vrInclude = applyPatterns(*vrFiles, i_migr->includeFiles); vrExclude = applyPatterns(*vrFiles, i_migr->excludeFiles); - substract(*vrInclude, *vrExclude); + subtract(*vrInclude, *vrExclude); vrResult->insert(vrResult->end(), vrInclude->begin(), vrInclude->end()); i_migr++; } @@ -817,7 +803,7 @@ void MigrationImpl::copyConfig() { } // removes elements of vector 2 in vector 1 -void MigrationImpl::substract(strings_v& va, const strings_v& vb_c) const +void MigrationImpl::subtract(strings_v& va, const strings_v& vb_c) const { strings_v vb(vb_c); // ensure uniqueness of entries diff --git a/desktop/source/migration/migration_impl.hxx b/desktop/source/migration/migration_impl.hxx index 3624edf888..e0a6e5a606 100644 --- a/desktop/source/migration/migration_impl.hxx +++ b/desktop/source/migration/migration_impl.hxx @@ -213,7 +213,7 @@ private: strings_vr compileFileList(); // helpers - void substract(strings_v& va, const strings_v& vb_c) const; + void subtract(strings_v& va, const strings_v& vb_c) const; strings_vr getAllFiles(const rtl::OUString& baseURL) const; strings_vr applyPatterns(const strings_v& vSet, const strings_v& vPatterns) const; NS_UNO::Reference< NS_CSS::container::XNameAccess > getConfigAccess(const sal_Char* path, sal_Bool rw=sal_False); @@ -236,15 +236,13 @@ private: void setMigrationCompleted(); sal_Bool checkMigrationCompleted(); - + public: MigrationImpl(const NS_UNO::Reference< NS_CSS::lang::XMultiServiceFactory >&); ~MigrationImpl(); sal_Bool doMigration(); - sal_Bool checkMigration(); + sal_Bool needsMigration(); rtl::OUString getOldVersionName(); - - }; } #undef NS_CSS |