1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_desktop.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <map> 32*cdf0e10cSrcweir #include <new> 33*cdf0e10cSrcweir #include <set> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include "migration.hxx" 36*cdf0e10cSrcweir #include "migration_impl.hxx" 37*cdf0e10cSrcweir #include "cfgfilter.hxx" 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <unotools/textsearch.hxx> 40*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 41*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 42*cdf0e10cSrcweir #include <unotools/bootstrap.hxx> 43*cdf0e10cSrcweir #include <rtl/bootstrap.hxx> 44*cdf0e10cSrcweir #include <rtl/uri.hxx> 45*cdf0e10cSrcweir #include <tools/config.hxx> 46*cdf0e10cSrcweir #include <i18npool/lang.h> 47*cdf0e10cSrcweir #include <tools/urlobj.hxx> 48*cdf0e10cSrcweir #include <osl/file.hxx> 49*cdf0e10cSrcweir #include <osl/mutex.hxx> 50*cdf0e10cSrcweir #include <ucbhelper/content.hxx> 51*cdf0e10cSrcweir #include <osl/security.hxx> 52*cdf0e10cSrcweir #include <unotools/configmgr.hxx> 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir #include <com/sun/star/configuration/Update.hpp> 55*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 56*cdf0e10cSrcweir #include <com/sun/star/task/XJob.hpp> 57*cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp> 58*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 59*cdf0e10cSrcweir #include <com/sun/star/util/XRefreshable.hpp> 60*cdf0e10cSrcweir #include <com/sun/star/util/XChangesBatch.hpp> 61*cdf0e10cSrcweir #include <com/sun/star/util/XStringSubstitution.hpp> 62*cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp> 63*cdf0e10cSrcweir #include <com/sun/star/embed/XStorage.hpp> 64*cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfiguration.hpp> 65*cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfigurationStorage.hpp> 66*cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfigurationPersistence.hpp> 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir using namespace rtl; 69*cdf0e10cSrcweir using namespace osl; 70*cdf0e10cSrcweir using namespace std; 71*cdf0e10cSrcweir using namespace com::sun::star::task; 72*cdf0e10cSrcweir using namespace com::sun::star::lang; 73*cdf0e10cSrcweir using namespace com::sun::star::beans; 74*cdf0e10cSrcweir using namespace com::sun::star::util; 75*cdf0e10cSrcweir using namespace com::sun::star::container; 76*cdf0e10cSrcweir using com::sun::star::uno::Exception; 77*cdf0e10cSrcweir using namespace com::sun::star; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir namespace desktop { 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir static const ::rtl::OUString ITEM_DESCRIPTOR_COMMANDURL = ::rtl::OUString::createFromAscii("CommandURL"); 82*cdf0e10cSrcweir static const ::rtl::OUString ITEM_DESCRIPTOR_CONTAINER = ::rtl::OUString::createFromAscii("ItemDescriptorContainer"); 83*cdf0e10cSrcweir static const ::rtl::OUString ITEM_DESCRIPTOR_LABEL = ::rtl::OUString::createFromAscii("Label"); 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir static const ::rtl::OUString MENU_SEPERATOR = ::rtl::OUString::createFromAscii(" | "); 86*cdf0e10cSrcweir static const ::rtl::OUString MENU_SUBMENU = ::rtl::OUString::createFromAscii("..."); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir ::rtl::OUString retrieveLabelFromCommand(const ::rtl::OUString& sCommand, const ::rtl::OUString& sModuleIdentifier) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir ::rtl::OUString sLabel; 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir uno::Reference< container::XNameAccess > xUICommands; 93*cdf0e10cSrcweir uno::Reference< container::XNameAccess > xNameAccess( ::comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.UICommandDescription") ), uno::UNO_QUERY ); 94*cdf0e10cSrcweir if ( xNameAccess.is() ) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir uno::Any a = xNameAccess->getByName( sModuleIdentifier ); 97*cdf0e10cSrcweir a >>= xUICommands; 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir if (xUICommands.is()) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir if ( sCommand.getLength() > 0 ) 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir rtl::OUString aStr; 104*cdf0e10cSrcweir ::uno::Sequence< beans::PropertyValue > aPropSeq; 105*cdf0e10cSrcweir try 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir uno::Any a( xUICommands->getByName( sCommand )); 108*cdf0e10cSrcweir if ( a >>= aPropSeq ) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir if ( aPropSeq[i].Name.equalsAscii( "Label" )) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir aPropSeq[i].Value >>= aStr; 115*cdf0e10cSrcweir break; 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir sLabel = aStr; 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir catch(container::NoSuchElementException&) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir sLabel = sCommand; 126*cdf0e10cSrcweir sal_Int32 nIndex = sLabel.indexOf(':'); 127*cdf0e10cSrcweir if (nIndex>=0 && nIndex <= sLabel.getLength()-1) 128*cdf0e10cSrcweir sLabel = sLabel.copy(nIndex+1); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir return sLabel; 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir ::rtl::OUString stripHotKey( const ::rtl::OUString& str ) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir sal_Int32 index = str.indexOf( '~' ); 140*cdf0e10cSrcweir if ( index == -1 ) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir return str; 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir else 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir return str.replaceAt( index, 1, ::rtl::OUString() ); 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir ::rtl::OUString mapModuleShortNameToIdentifier(const ::rtl::OUString& sShortName) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir ::rtl::OUString sIdentifier; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir if (sShortName.equals(::rtl::OUString::createFromAscii("StartModule"))) 155*cdf0e10cSrcweir sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.frame.StartModule"); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir else if (sShortName.equals(::rtl::OUString::createFromAscii("swriter"))) 158*cdf0e10cSrcweir sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.text.TextDocument"); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir else if (sShortName.equals(::rtl::OUString::createFromAscii("scalc"))) 161*cdf0e10cSrcweir sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.sheet.SpreadsheetDocument"); 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir else if (sShortName.equals(::rtl::OUString::createFromAscii("sdraw"))) 164*cdf0e10cSrcweir sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.drawing.DrawingDocument"); 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir else if (sShortName.equals(::rtl::OUString::createFromAscii("simpress"))) 167*cdf0e10cSrcweir sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.presentation.PresentationDocument"); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir else if (sShortName.equals(::rtl::OUString::createFromAscii("smath"))) 170*cdf0e10cSrcweir sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.formula.FormulaProperties"); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir else if (sShortName.equals(::rtl::OUString::createFromAscii("schart"))) 173*cdf0e10cSrcweir sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.chart2.ChartDocument"); 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir else if (sShortName.equals(::rtl::OUString::createFromAscii("BasicIDE"))) 176*cdf0e10cSrcweir sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.script.BasicIDE"); 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir else if (sShortName.equals(::rtl::OUString::createFromAscii("dbapp"))) 179*cdf0e10cSrcweir sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.sdb.OfficeDatabaseDocument"); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir else if (sShortName.equals(::rtl::OUString::createFromAscii("sglobal"))) 182*cdf0e10cSrcweir sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.text.GlobalDocument"); 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir else if (sShortName.equals(::rtl::OUString::createFromAscii("sweb"))) 185*cdf0e10cSrcweir sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.text.WebDocument"); 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir else if (sShortName.equals(::rtl::OUString::createFromAscii("swxform"))) 188*cdf0e10cSrcweir sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.xforms.XMLFormDocument"); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir else if (sShortName.equals(::rtl::OUString::createFromAscii("sbibliography"))) 191*cdf0e10cSrcweir sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.frame.Bibliography"); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir return sIdentifier; 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir static MigrationImpl *pImpl = 0; 197*cdf0e10cSrcweir static Mutex aMutex; 198*cdf0e10cSrcweir static MigrationImpl *getImpl() 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir MutexGuard aGuard(aMutex); 201*cdf0e10cSrcweir if (pImpl == 0) 202*cdf0e10cSrcweir pImpl = new MigrationImpl(comphelper::getProcessServiceFactory()); 203*cdf0e10cSrcweir return pImpl; 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir static void releaseImpl() 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir MutexGuard aGuard(aMutex); 209*cdf0e10cSrcweir if (pImpl != 0) 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir delete pImpl; 212*cdf0e10cSrcweir pImpl = 0; 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir // static main entry point for the migration process 217*cdf0e10cSrcweir void Migration::doMigration() 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir sal_Bool bResult = sal_False; 220*cdf0e10cSrcweir try { 221*cdf0e10cSrcweir bResult = getImpl()->doMigration(); 222*cdf0e10cSrcweir } catch (Exception& e) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir OString aMsg("doMigration() exception: "); 225*cdf0e10cSrcweir aMsg += OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US); 226*cdf0e10cSrcweir OSL_ENSURE(sal_False, aMsg.getStr()); 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir OSL_ENSURE(bResult, "Migration has not been successfull"); 229*cdf0e10cSrcweir // shut down migration framework 230*cdf0e10cSrcweir releaseImpl(); 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir void Migration::cancelMigration() 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir releaseImpl(); 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir sal_Bool Migration::checkMigration() 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir return getImpl()->checkMigration(); 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir OUString Migration::getOldVersionName() 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir return getImpl()->getOldVersionName(); 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir OUString MigrationImpl::getOldVersionName() 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir return m_aInfo.productname; 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir sal_Bool MigrationImpl::checkMigration() 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir if (m_aInfo.userdata.getLength() > 0 && ! checkMigrationCompleted()) 256*cdf0e10cSrcweir return sal_True; 257*cdf0e10cSrcweir else 258*cdf0e10cSrcweir return sal_False; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir MigrationImpl::MigrationImpl(const uno::Reference< XMultiServiceFactory >& xFactory) 262*cdf0e10cSrcweir : m_vrVersions(new strings_v) 263*cdf0e10cSrcweir , m_xFactory(xFactory) 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir readAvailableMigrations(m_vMigrationsAvailable); 266*cdf0e10cSrcweir sal_Int32 nIndex = findPreferedMigrationProcess(m_vMigrationsAvailable); 267*cdf0e10cSrcweir if ( nIndex >= 0 ) 268*cdf0e10cSrcweir m_vrMigrations = readMigrationSteps(m_vMigrationsAvailable[nIndex].name); 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir MigrationImpl::~MigrationImpl() 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir sal_Bool MigrationImpl::doMigration() 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir // compile file list for migration 279*cdf0e10cSrcweir m_vrFileList = compileFileList(); 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir sal_Bool result = sal_False; 282*cdf0e10cSrcweir try 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir NewVersionUIInfo aNewVersionUIInfo; 285*cdf0e10cSrcweir ::std::vector< MigrationModuleInfo > vModulesInfo = dectectUIChangesForAllModules(); 286*cdf0e10cSrcweir aNewVersionUIInfo.init(vModulesInfo); 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir copyFiles(); 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir const ::rtl::OUString sMenubarResourceURL = ::rtl::OUString::createFromAscii("private:resource/menubar/menubar"); 291*cdf0e10cSrcweir const ::rtl::OUString sToolbarResourcePre = ::rtl::OUString::createFromAscii("private:resource/toolbar/"); 292*cdf0e10cSrcweir for (sal_uInt32 i=0; i<vModulesInfo.size(); ++i) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir ::rtl::OUString sModuleIdentifier = mapModuleShortNameToIdentifier(vModulesInfo[i].sModuleShortName); 295*cdf0e10cSrcweir if (sModuleIdentifier.getLength()==0) 296*cdf0e10cSrcweir continue; 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir uno::Sequence< uno::Any > lArgs(2); 299*cdf0e10cSrcweir ::rtl::OUString aOldCfgDataPath = m_aInfo.userdata + ::rtl::OUString::createFromAscii("/user/config/soffice.cfg/modules/"); 300*cdf0e10cSrcweir lArgs[0] <<= aOldCfgDataPath + vModulesInfo[i].sModuleShortName; 301*cdf0e10cSrcweir lArgs[1] <<= embed::ElementModes::READ; 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir uno::Reference< lang::XSingleServiceFactory > xStorageFactory(m_xFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.embed.FileSystemStorageFactory")), uno::UNO_QUERY); 304*cdf0e10cSrcweir uno::Reference< embed::XStorage > xModules; 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir xModules = uno::Reference< embed::XStorage >(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY); 307*cdf0e10cSrcweir uno::Reference< ui::XUIConfigurationManager > xOldCfgManager( m_xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.ui.UIConfigurationManager")), uno::UNO_QUERY ); 308*cdf0e10cSrcweir uno::Reference< ui::XUIConfigurationStorage > xOldCfgStorage( xOldCfgManager, uno::UNO_QUERY ); 309*cdf0e10cSrcweir uno::Reference< ui::XUIConfigurationPersistence > xOldCfgPersistence( xOldCfgManager, uno::UNO_QUERY ); 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir if ( xOldCfgStorage.is() && xOldCfgPersistence.is() && xModules.is() ) 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir xOldCfgStorage->setStorage( xModules ); 314*cdf0e10cSrcweir xOldCfgPersistence->reload(); 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir uno::Reference< ui::XUIConfigurationManager > xCfgManager = aNewVersionUIInfo.getConfigManager(vModulesInfo[i].sModuleShortName); 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir if (vModulesInfo[i].bHasMenubar) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir uno::Reference< container::XIndexContainer > xOldVersionMenuSettings = uno::Reference< container::XIndexContainer >(xOldCfgManager->getSettings(sMenubarResourceURL, sal_True), uno::UNO_QUERY); 322*cdf0e10cSrcweir uno::Reference< container::XIndexContainer > xNewVersionMenuSettings = aNewVersionUIInfo.getNewMenubarSettings(vModulesInfo[i].sModuleShortName); 323*cdf0e10cSrcweir ::rtl::OUString sParent; 324*cdf0e10cSrcweir compareOldAndNewConfig(sParent, xOldVersionMenuSettings, xNewVersionMenuSettings, sMenubarResourceURL); 325*cdf0e10cSrcweir mergeOldToNewVersion(xCfgManager, xNewVersionMenuSettings, sModuleIdentifier, sMenubarResourceURL); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir sal_Int32 nToolbars = vModulesInfo[i].m_vToolbars.size(); 329*cdf0e10cSrcweir if (nToolbars >0) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir for (sal_Int32 j=0; j<nToolbars; ++j) 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir ::rtl::OUString sToolbarName = vModulesInfo[i].m_vToolbars[j]; 334*cdf0e10cSrcweir ::rtl::OUString sToolbarResourceURL = sToolbarResourcePre + sToolbarName; 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir uno::Reference< container::XIndexContainer > xOldVersionToolbarSettings = uno::Reference< container::XIndexContainer >(xOldCfgManager->getSettings(sToolbarResourceURL, sal_True), uno::UNO_QUERY); 337*cdf0e10cSrcweir uno::Reference< container::XIndexContainer > xNewVersionToolbarSettings = aNewVersionUIInfo.getNewToolbarSettings(vModulesInfo[i].sModuleShortName, sToolbarName); 338*cdf0e10cSrcweir ::rtl::OUString sParent; 339*cdf0e10cSrcweir compareOldAndNewConfig(sParent, xOldVersionToolbarSettings, xNewVersionToolbarSettings, sToolbarResourceURL); 340*cdf0e10cSrcweir mergeOldToNewVersion(xCfgManager, xNewVersionToolbarSettings, sModuleIdentifier, sToolbarResourceURL); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir m_aOldVersionItemsHashMap.clear(); 345*cdf0e10cSrcweir m_aNewVersionItemsHashMap.clear(); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir // execute the migration items from Setup.xcu 349*cdf0e10cSrcweir copyConfig(); 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir // execute custom migration services from Setup.xcu 352*cdf0e10cSrcweir // and refresh the cache 353*cdf0e10cSrcweir runServices(); 354*cdf0e10cSrcweir refresh(); 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir result = sal_True; 357*cdf0e10cSrcweir } catch (...) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir OString aMsg("An unexpected exception was thrown during migration"); 360*cdf0e10cSrcweir aMsg += "\nOldVersion: " + OUStringToOString(m_aInfo.productname, RTL_TEXTENCODING_ASCII_US); 361*cdf0e10cSrcweir aMsg += "\nDataPath : " + OUStringToOString(m_aInfo.userdata, RTL_TEXTENCODING_ASCII_US); 362*cdf0e10cSrcweir OSL_ENSURE(sal_False, aMsg.getStr()); 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir // prevent running the migration multiple times 366*cdf0e10cSrcweir setMigrationCompleted(); 367*cdf0e10cSrcweir return result; 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir void MigrationImpl::refresh() 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir uno::Reference< XRefreshable > xRefresh(m_xFactory->createInstance( 373*cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), uno::UNO_QUERY); 374*cdf0e10cSrcweir if (xRefresh.is()) 375*cdf0e10cSrcweir xRefresh->refresh(); 376*cdf0e10cSrcweir else 377*cdf0e10cSrcweir OSL_ENSURE(sal_False, "could not get XRefresh interface from default config provider. No refresh done."); 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir void MigrationImpl::setMigrationCompleted() 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir try { 384*cdf0e10cSrcweir uno::Reference< XPropertySet > aPropertySet(getConfigAccess("org.openoffice.Setup/Office", true), uno::UNO_QUERY_THROW); 385*cdf0e10cSrcweir aPropertySet->setPropertyValue(OUString::createFromAscii("MigrationCompleted"), uno::makeAny(sal_True)); 386*cdf0e10cSrcweir uno::Reference< XChangesBatch >(aPropertySet, uno::UNO_QUERY_THROW)->commitChanges(); 387*cdf0e10cSrcweir } catch (...) { 388*cdf0e10cSrcweir // fail silently 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir sal_Bool MigrationImpl::checkMigrationCompleted() 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir sal_Bool bMigrationCompleted = sal_False; 395*cdf0e10cSrcweir try { 396*cdf0e10cSrcweir uno::Reference< XPropertySet > aPropertySet( 397*cdf0e10cSrcweir getConfigAccess("org.openoffice.Setup/Office"), uno::UNO_QUERY_THROW); 398*cdf0e10cSrcweir aPropertySet->getPropertyValue( 399*cdf0e10cSrcweir OUString::createFromAscii("MigrationCompleted")) >>= bMigrationCompleted; 400*cdf0e10cSrcweir } catch (Exception&) { 401*cdf0e10cSrcweir // just return false... 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir return bMigrationCompleted; 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir static void insertSorted(migrations_available& rAvailableMigrations, supported_migration& aSupportedMigration) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir bool bInserted( false ); 409*cdf0e10cSrcweir migrations_available::iterator pIter = rAvailableMigrations.begin(); 410*cdf0e10cSrcweir while ( !bInserted && pIter != rAvailableMigrations.end()) 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir if ( pIter->nPriority < aSupportedMigration.nPriority ) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir rAvailableMigrations.insert(pIter, aSupportedMigration ); 415*cdf0e10cSrcweir bInserted = true; 416*cdf0e10cSrcweir break; // i111193: insert invalidates iterator! 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir ++pIter; 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir if ( !bInserted ) 421*cdf0e10cSrcweir rAvailableMigrations.push_back( aSupportedMigration ); 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir bool MigrationImpl::readAvailableMigrations(migrations_available& rAvailableMigrations) 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir // get supported version names 427*cdf0e10cSrcweir uno::Reference< XNameAccess > aMigrationAccess(getConfigAccess("org.openoffice.Setup/Migration/SupportedVersions"), uno::UNO_QUERY_THROW); 428*cdf0e10cSrcweir uno::Sequence< OUString > seqSupportedVersions = aMigrationAccess->getElementNames(); 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir const OUString aVersionIdentifiers( RTL_CONSTASCII_USTRINGPARAM( "VersionIdentifiers" )); 431*cdf0e10cSrcweir const OUString aPriorityIdentifier( RTL_CONSTASCII_USTRINGPARAM( "Priority" )); 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir for (sal_Int32 i=0; i<seqSupportedVersions.getLength(); i++) 434*cdf0e10cSrcweir { 435*cdf0e10cSrcweir sal_Int32 nPriority( 0 ); 436*cdf0e10cSrcweir uno::Sequence< OUString > seqVersions; 437*cdf0e10cSrcweir uno::Reference< XNameAccess > xMigrationData( aMigrationAccess->getByName(seqSupportedVersions[i]), uno::UNO_QUERY_THROW ); 438*cdf0e10cSrcweir xMigrationData->getByName( aVersionIdentifiers ) >>= seqVersions; 439*cdf0e10cSrcweir xMigrationData->getByName( aPriorityIdentifier ) >>= nPriority; 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir supported_migration aSupportedMigration; 442*cdf0e10cSrcweir aSupportedMigration.name = seqSupportedVersions[i]; 443*cdf0e10cSrcweir aSupportedMigration.nPriority = nPriority; 444*cdf0e10cSrcweir for (sal_Int32 j=0; j<seqVersions.getLength(); j++) 445*cdf0e10cSrcweir aSupportedMigration.supported_versions.push_back(seqVersions[j].trim()); 446*cdf0e10cSrcweir insertSorted( rAvailableMigrations, aSupportedMigration ); 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir return true; 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir migrations_vr MigrationImpl::readMigrationSteps(const ::rtl::OUString& rMigrationName) 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir // get migration access 455*cdf0e10cSrcweir uno::Reference< XNameAccess > aMigrationAccess(getConfigAccess("org.openoffice.Setup/Migration/SupportedVersions"), uno::UNO_QUERY_THROW); 456*cdf0e10cSrcweir uno::Reference< XNameAccess > xMigrationData( aMigrationAccess->getByName(rMigrationName), uno::UNO_QUERY_THROW ); 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir // get migration description from from org.openoffice.Setup/Migration 459*cdf0e10cSrcweir // and build vector of migration steps 460*cdf0e10cSrcweir OUString aMigrationSteps( RTL_CONSTASCII_USTRINGPARAM( "MigrationSteps" )); 461*cdf0e10cSrcweir uno::Reference< XNameAccess > theNameAccess(xMigrationData->getByName(aMigrationSteps), uno::UNO_QUERY_THROW); 462*cdf0e10cSrcweir uno::Sequence< OUString > seqMigrations = theNameAccess->getElementNames(); 463*cdf0e10cSrcweir uno::Reference< XNameAccess > tmpAccess; 464*cdf0e10cSrcweir uno::Reference< XNameAccess > tmpAccess2; 465*cdf0e10cSrcweir uno::Sequence< OUString > tmpSeq; 466*cdf0e10cSrcweir migrations_vr vrMigrations(new migrations_v); 467*cdf0e10cSrcweir for (sal_Int32 i = 0; i < seqMigrations.getLength(); i++) 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir // get current migration step 470*cdf0e10cSrcweir theNameAccess->getByName(seqMigrations[i]) >>= tmpAccess; 471*cdf0e10cSrcweir // tmpStepPtr = new migration_step(); 472*cdf0e10cSrcweir migration_step tmpStep; 473*cdf0e10cSrcweir tmpStep.name = seqMigrations[i]; 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir // read included files from current step description 476*cdf0e10cSrcweir ::rtl::OUString aSeqEntry; 477*cdf0e10cSrcweir if (tmpAccess->getByName(OUString::createFromAscii("IncludedFiles")) >>= tmpSeq) 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir for (sal_Int32 j=0; j<tmpSeq.getLength(); j++) 480*cdf0e10cSrcweir { 481*cdf0e10cSrcweir aSeqEntry = tmpSeq[j]; 482*cdf0e10cSrcweir tmpStep.includeFiles.push_back(aSeqEntry); 483*cdf0e10cSrcweir } 484*cdf0e10cSrcweir } 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir // exluded files... 487*cdf0e10cSrcweir if (tmpAccess->getByName(OUString::createFromAscii("ExcludedFiles")) >>= tmpSeq) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir for (sal_Int32 j=0; j<tmpSeq.getLength(); j++) 490*cdf0e10cSrcweir tmpStep.excludeFiles.push_back(tmpSeq[j]); 491*cdf0e10cSrcweir } 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir // included nodes... 494*cdf0e10cSrcweir if (tmpAccess->getByName(OUString::createFromAscii("IncludedNodes")) >>= tmpSeq) 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir for (sal_Int32 j=0; j<tmpSeq.getLength(); j++) 497*cdf0e10cSrcweir tmpStep.includeConfig.push_back(tmpSeq[j]); 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir // excluded nodes... 501*cdf0e10cSrcweir if (tmpAccess->getByName(OUString::createFromAscii("ExcludedNodes")) >>= tmpSeq) 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir for (sal_Int32 j=0; j<tmpSeq.getLength(); j++) 504*cdf0e10cSrcweir tmpStep.excludeConfig.push_back(tmpSeq[j]); 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir // included extensions... 508*cdf0e10cSrcweir if (tmpAccess->getByName(OUString::createFromAscii("IncludedExtensions")) >>= tmpSeq) 509*cdf0e10cSrcweir { 510*cdf0e10cSrcweir for (sal_Int32 j=0; j<tmpSeq.getLength(); j++) 511*cdf0e10cSrcweir tmpStep.includeExtensions.push_back(tmpSeq[j]); 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir // excluded extensions... 515*cdf0e10cSrcweir if (tmpAccess->getByName(OUString::createFromAscii("ExcludedExtensions")) >>= tmpSeq) 516*cdf0e10cSrcweir { 517*cdf0e10cSrcweir for (sal_Int32 j=0; j<tmpSeq.getLength(); j++) 518*cdf0e10cSrcweir { 519*cdf0e10cSrcweir aSeqEntry = tmpSeq[j]; 520*cdf0e10cSrcweir tmpStep.excludeExtensions.push_back(aSeqEntry); 521*cdf0e10cSrcweir } 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir // generic service 525*cdf0e10cSrcweir tmpAccess->getByName(OUString::createFromAscii("MigrationService")) >>= tmpStep.service; 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir vrMigrations->push_back(tmpStep); 528*cdf0e10cSrcweir } 529*cdf0e10cSrcweir return vrMigrations; 530*cdf0e10cSrcweir } 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir static FileBase::RC _checkAndCreateDirectory(INetURLObject& dirURL) 533*cdf0e10cSrcweir { 534*cdf0e10cSrcweir FileBase::RC result = Directory::create(dirURL.GetMainURL(INetURLObject::DECODE_TO_IURI)); 535*cdf0e10cSrcweir if (result == FileBase::E_NOENT) 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir INetURLObject baseURL(dirURL); 538*cdf0e10cSrcweir baseURL.removeSegment(); 539*cdf0e10cSrcweir _checkAndCreateDirectory(baseURL); 540*cdf0e10cSrcweir return Directory::create(dirURL.GetMainURL(INetURLObject::DECODE_TO_IURI)); 541*cdf0e10cSrcweir } else 542*cdf0e10cSrcweir return result; 543*cdf0e10cSrcweir } 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir install_info MigrationImpl::findInstallation(const strings_v& rVersions) 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir rtl::OUString aProductName; 548*cdf0e10cSrcweir uno::Any aRet = ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME ); 549*cdf0e10cSrcweir aRet >>= aProductName; 550*cdf0e10cSrcweir aProductName = aProductName.toAsciiLowerCase(); 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir install_info aInfo; 553*cdf0e10cSrcweir strings_v::const_iterator i_ver = rVersions.begin(); 554*cdf0e10cSrcweir uno::Reference < util::XStringSubstitution > xSubst( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.PathSubstitution")), uno::UNO_QUERY ); 555*cdf0e10cSrcweir while (i_ver != rVersions.end()) 556*cdf0e10cSrcweir { 557*cdf0e10cSrcweir ::rtl::OUString aVersion, aProfileName; 558*cdf0e10cSrcweir sal_Int32 nSeparatorIndex = (*i_ver).indexOf('='); 559*cdf0e10cSrcweir if ( nSeparatorIndex != -1 ) 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir aVersion = (*i_ver).copy( 0, nSeparatorIndex ); 562*cdf0e10cSrcweir aProfileName = (*i_ver).copy( nSeparatorIndex+1 ); 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir if ( aVersion.getLength() && aProfileName.getLength() && 566*cdf0e10cSrcweir ( !aInfo.userdata.getLength() || !aProfileName.toAsciiLowerCase().compareTo( aProductName, aProductName.getLength() ) ) 567*cdf0e10cSrcweir ) 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir ::rtl::OUString aUserInst; 570*cdf0e10cSrcweir osl::Security().getConfigDir( aUserInst ); 571*cdf0e10cSrcweir if ( aUserInst.getLength() && aUserInst[ aUserInst.getLength()-1 ] != '/' ) 572*cdf0e10cSrcweir aUserInst += ::rtl::OUString::createFromAscii("/"); 573*cdf0e10cSrcweir #if defined UNX && ! defined MACOSX 574*cdf0e10cSrcweir // tribute to whoever had the "great" idea to use different names on Windows and Unix 575*cdf0e10cSrcweir aUserInst += ::rtl::OUString::createFromAscii("."); 576*cdf0e10cSrcweir #endif 577*cdf0e10cSrcweir aUserInst += aProfileName; 578*cdf0e10cSrcweir try 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir INetURLObject aObj(aUserInst); 581*cdf0e10cSrcweir ::ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment > () ); 582*cdf0e10cSrcweir aCnt.isDocument(); 583*cdf0e10cSrcweir aInfo.userdata = aObj.GetMainURL( INetURLObject::NO_DECODE ); 584*cdf0e10cSrcweir aInfo.productname = aVersion; 585*cdf0e10cSrcweir } 586*cdf0e10cSrcweir catch( uno::Exception& ){} 587*cdf0e10cSrcweir } 588*cdf0e10cSrcweir ++i_ver; 589*cdf0e10cSrcweir } 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir return aInfo; 592*cdf0e10cSrcweir } 593*cdf0e10cSrcweir 594*cdf0e10cSrcweir sal_Int32 MigrationImpl::findPreferedMigrationProcess(const migrations_available& rAvailableMigrations) 595*cdf0e10cSrcweir { 596*cdf0e10cSrcweir sal_Int32 nIndex( -1 ); 597*cdf0e10cSrcweir sal_Int32 i( 0 ); 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir migrations_available::const_iterator rIter = rAvailableMigrations.begin(); 600*cdf0e10cSrcweir while ( rIter != rAvailableMigrations.end() ) 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir install_info aInstallInfo = findInstallation(rIter->supported_versions); 603*cdf0e10cSrcweir if (aInstallInfo.productname.getLength() > 0 ) 604*cdf0e10cSrcweir { 605*cdf0e10cSrcweir m_aInfo = aInstallInfo; 606*cdf0e10cSrcweir nIndex = i; 607*cdf0e10cSrcweir break; 608*cdf0e10cSrcweir } 609*cdf0e10cSrcweir ++i; 610*cdf0e10cSrcweir ++rIter; 611*cdf0e10cSrcweir } 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir return nIndex; 614*cdf0e10cSrcweir } 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir strings_vr MigrationImpl::applyPatterns(const strings_v& vSet, const strings_v& vPatterns) const 617*cdf0e10cSrcweir { 618*cdf0e10cSrcweir using namespace utl; 619*cdf0e10cSrcweir strings_vr vrResult(new strings_v); 620*cdf0e10cSrcweir strings_v::const_iterator i_set; 621*cdf0e10cSrcweir strings_v::const_iterator i_pat = vPatterns.begin(); 622*cdf0e10cSrcweir while (i_pat != vPatterns.end()) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir // find matches for this pattern in input set 625*cdf0e10cSrcweir // and copy them to the result 626*cdf0e10cSrcweir SearchParam param(*i_pat, SearchParam::SRCH_REGEXP); 627*cdf0e10cSrcweir TextSearch ts(param, LANGUAGE_DONTKNOW); 628*cdf0e10cSrcweir i_set = vSet.begin(); 629*cdf0e10cSrcweir xub_StrLen start = 0; 630*cdf0e10cSrcweir xub_StrLen end = 0; 631*cdf0e10cSrcweir while (i_set != vSet.end()) 632*cdf0e10cSrcweir { 633*cdf0e10cSrcweir end = (xub_StrLen)(i_set->getLength()); 634*cdf0e10cSrcweir if (ts.SearchFrwrd(*i_set, &start, &end)) 635*cdf0e10cSrcweir vrResult->push_back(*i_set); 636*cdf0e10cSrcweir i_set++; 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir i_pat++; 639*cdf0e10cSrcweir } 640*cdf0e10cSrcweir return vrResult; 641*cdf0e10cSrcweir } 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir strings_vr MigrationImpl::getAllFiles(const OUString& baseURL) const 644*cdf0e10cSrcweir { 645*cdf0e10cSrcweir using namespace osl; 646*cdf0e10cSrcweir strings_vr vrResult(new strings_v); 647*cdf0e10cSrcweir 648*cdf0e10cSrcweir // get sub dirs 649*cdf0e10cSrcweir Directory dir(baseURL); 650*cdf0e10cSrcweir if (dir.open() == FileBase::E_None) 651*cdf0e10cSrcweir { 652*cdf0e10cSrcweir strings_v vSubDirs; 653*cdf0e10cSrcweir strings_vr vrSubResult; 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir // work through directory contents... 656*cdf0e10cSrcweir DirectoryItem item; 657*cdf0e10cSrcweir FileStatus fs(FileStatusMask_Type | FileStatusMask_FileURL); 658*cdf0e10cSrcweir while (dir.getNextItem(item) == FileBase::E_None) 659*cdf0e10cSrcweir { 660*cdf0e10cSrcweir if (item.getFileStatus(fs) == FileBase::E_None) 661*cdf0e10cSrcweir { 662*cdf0e10cSrcweir if (fs.getFileType() == FileStatus::Directory) 663*cdf0e10cSrcweir vSubDirs.push_back(fs.getFileURL()); 664*cdf0e10cSrcweir else 665*cdf0e10cSrcweir vrResult->push_back(fs.getFileURL()); 666*cdf0e10cSrcweir } 667*cdf0e10cSrcweir } 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir // recurse subfolders 670*cdf0e10cSrcweir strings_v::const_iterator i = vSubDirs.begin(); 671*cdf0e10cSrcweir while (i != vSubDirs.end()) 672*cdf0e10cSrcweir { 673*cdf0e10cSrcweir vrSubResult = getAllFiles(*i); 674*cdf0e10cSrcweir vrResult->insert(vrResult->end(), vrSubResult->begin(), vrSubResult->end()); 675*cdf0e10cSrcweir i++; 676*cdf0e10cSrcweir } 677*cdf0e10cSrcweir } 678*cdf0e10cSrcweir return vrResult; 679*cdf0e10cSrcweir } 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir strings_vr MigrationImpl::compileFileList() 682*cdf0e10cSrcweir { 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir strings_vr vrResult(new strings_v); 685*cdf0e10cSrcweir strings_vr vrInclude; 686*cdf0e10cSrcweir strings_vr vrExclude; 687*cdf0e10cSrcweir strings_vr vrTemp; 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir #ifdef SAL_OS2 690*cdf0e10cSrcweir if (m_aInfo.userdata.getLength() == 0) 691*cdf0e10cSrcweir return vrResult; 692*cdf0e10cSrcweir #endif 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir // get a list of all files: 695*cdf0e10cSrcweir strings_vr vrFiles = getAllFiles(m_aInfo.userdata); 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir // get a file list result for each migration step 698*cdf0e10cSrcweir migrations_v::const_iterator i_migr = m_vrMigrations->begin(); 699*cdf0e10cSrcweir while (i_migr != m_vrMigrations->end()) 700*cdf0e10cSrcweir { 701*cdf0e10cSrcweir vrInclude = applyPatterns(*vrFiles, i_migr->includeFiles); 702*cdf0e10cSrcweir vrExclude = applyPatterns(*vrFiles, i_migr->excludeFiles); 703*cdf0e10cSrcweir substract(*vrInclude, *vrExclude); 704*cdf0e10cSrcweir vrResult->insert(vrResult->end(), vrInclude->begin(), vrInclude->end()); 705*cdf0e10cSrcweir i_migr++; 706*cdf0e10cSrcweir } 707*cdf0e10cSrcweir return vrResult; 708*cdf0e10cSrcweir } 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir namespace { 711*cdf0e10cSrcweir 712*cdf0e10cSrcweir struct componentParts { 713*cdf0e10cSrcweir std::set< rtl::OUString > includedPaths; 714*cdf0e10cSrcweir std::set< rtl::OUString > excludedPaths; 715*cdf0e10cSrcweir }; 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir typedef std::map< rtl::OUString, componentParts > Components; 718*cdf0e10cSrcweir 719*cdf0e10cSrcweir bool getComponent(rtl::OUString const & path, rtl::OUString * component) { 720*cdf0e10cSrcweir OSL_ASSERT(component != 0); 721*cdf0e10cSrcweir if (path.getLength() == 0 || path[0] != '/') { 722*cdf0e10cSrcweir OSL_TRACE( 723*cdf0e10cSrcweir ("configuration migration in/exclude path %s ignored (does not" 724*cdf0e10cSrcweir " start with slash)"), 725*cdf0e10cSrcweir rtl::OUStringToOString(path, RTL_TEXTENCODING_UTF8).getStr()); 726*cdf0e10cSrcweir return false; 727*cdf0e10cSrcweir } 728*cdf0e10cSrcweir sal_Int32 i = path.indexOf('/', 1); 729*cdf0e10cSrcweir *component = i < 0 ? path.copy(1) : path.copy(1, i - 1); 730*cdf0e10cSrcweir return true; 731*cdf0e10cSrcweir } 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir uno::Sequence< rtl::OUString > setToSeq(std::set< rtl::OUString > const & set) { 734*cdf0e10cSrcweir std::set< rtl::OUString >::size_type n = set.size(); 735*cdf0e10cSrcweir if (n > SAL_MAX_INT32) { 736*cdf0e10cSrcweir throw std::bad_alloc(); 737*cdf0e10cSrcweir } 738*cdf0e10cSrcweir uno::Sequence< rtl::OUString > seq(static_cast< sal_Int32 >(n)); 739*cdf0e10cSrcweir sal_Int32 i = 0; 740*cdf0e10cSrcweir for (std::set< rtl::OUString >::const_iterator j(set.begin()); 741*cdf0e10cSrcweir j != set.end(); ++j) 742*cdf0e10cSrcweir { 743*cdf0e10cSrcweir seq[i++] = *j; 744*cdf0e10cSrcweir } 745*cdf0e10cSrcweir return seq; 746*cdf0e10cSrcweir } 747*cdf0e10cSrcweir 748*cdf0e10cSrcweir } 749*cdf0e10cSrcweir 750*cdf0e10cSrcweir void MigrationImpl::copyConfig() { 751*cdf0e10cSrcweir Components comps; 752*cdf0e10cSrcweir for (migrations_v::const_iterator i(m_vrMigrations->begin()); 753*cdf0e10cSrcweir i != m_vrMigrations->end(); ++i) 754*cdf0e10cSrcweir { 755*cdf0e10cSrcweir for (strings_v::const_iterator j(i->includeConfig.begin()); 756*cdf0e10cSrcweir j != i->includeConfig.end(); ++j) 757*cdf0e10cSrcweir { 758*cdf0e10cSrcweir rtl::OUString comp; 759*cdf0e10cSrcweir if (getComponent(*j, &comp)) { 760*cdf0e10cSrcweir comps[comp].includedPaths.insert(*j); 761*cdf0e10cSrcweir } 762*cdf0e10cSrcweir } 763*cdf0e10cSrcweir for (strings_v::const_iterator j(i->excludeConfig.begin()); 764*cdf0e10cSrcweir j != i->excludeConfig.end(); ++j) 765*cdf0e10cSrcweir { 766*cdf0e10cSrcweir rtl::OUString comp; 767*cdf0e10cSrcweir if (getComponent(*j, &comp)) { 768*cdf0e10cSrcweir comps[comp].excludedPaths.insert(*j); 769*cdf0e10cSrcweir } 770*cdf0e10cSrcweir } 771*cdf0e10cSrcweir } 772*cdf0e10cSrcweir for (Components::const_iterator i(comps.begin()); i != comps.end(); ++i) { 773*cdf0e10cSrcweir if (!i->second.includedPaths.empty()) { 774*cdf0e10cSrcweir rtl::OUStringBuffer buf(m_aInfo.userdata); 775*cdf0e10cSrcweir buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("/user/registry/data")); 776*cdf0e10cSrcweir sal_Int32 n = 0; 777*cdf0e10cSrcweir do { 778*cdf0e10cSrcweir rtl::OUString seg(i->first.getToken(0, '.', n)); 779*cdf0e10cSrcweir rtl::OUString enc( 780*cdf0e10cSrcweir rtl::Uri::encode( 781*cdf0e10cSrcweir seg, rtl_UriCharClassPchar, rtl_UriEncodeStrict, 782*cdf0e10cSrcweir RTL_TEXTENCODING_UTF8)); 783*cdf0e10cSrcweir if (enc.getLength() == 0 && seg.getLength() != 0) { 784*cdf0e10cSrcweir OSL_TRACE( 785*cdf0e10cSrcweir ("configuration migration component %s ignored (cannot" 786*cdf0e10cSrcweir " be encoded as file path)"), 787*cdf0e10cSrcweir rtl::OUStringToOString( 788*cdf0e10cSrcweir i->first, RTL_TEXTENCODING_UTF8).getStr()); 789*cdf0e10cSrcweir goto next; 790*cdf0e10cSrcweir } 791*cdf0e10cSrcweir buf.append(sal_Unicode('/')); 792*cdf0e10cSrcweir buf.append(enc); 793*cdf0e10cSrcweir } while (n >= 0); 794*cdf0e10cSrcweir buf.appendAscii(RTL_CONSTASCII_STRINGPARAM(".xcu")); 795*cdf0e10cSrcweir configuration::Update::get( 796*cdf0e10cSrcweir comphelper::getProcessComponentContext())-> 797*cdf0e10cSrcweir insertModificationXcuFile( 798*cdf0e10cSrcweir buf.makeStringAndClear(), setToSeq(i->second.includedPaths), 799*cdf0e10cSrcweir setToSeq(i->second.excludedPaths)); 800*cdf0e10cSrcweir } else { 801*cdf0e10cSrcweir OSL_TRACE( 802*cdf0e10cSrcweir ("configuration migration component %s ignored (only excludes," 803*cdf0e10cSrcweir " no includes)"), 804*cdf0e10cSrcweir rtl::OUStringToOString( 805*cdf0e10cSrcweir i->first, RTL_TEXTENCODING_UTF8).getStr()); 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir next:; 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir } 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir // removes elements of vector 2 in vector 1 812*cdf0e10cSrcweir void MigrationImpl::substract(strings_v& va, const strings_v& vb_c) const 813*cdf0e10cSrcweir { 814*cdf0e10cSrcweir strings_v vb(vb_c); 815*cdf0e10cSrcweir // ensure uniqueness of entries 816*cdf0e10cSrcweir sort(va.begin(), va.end()); 817*cdf0e10cSrcweir sort(vb.begin(), vb.end()); 818*cdf0e10cSrcweir unique(va.begin(), va.end()); 819*cdf0e10cSrcweir unique(vb.begin(), vb.end()); 820*cdf0e10cSrcweir 821*cdf0e10cSrcweir strings_v::const_iterator i_ex = vb.begin(); 822*cdf0e10cSrcweir strings_v::iterator i_in; 823*cdf0e10cSrcweir strings_v::iterator i_next; 824*cdf0e10cSrcweir while (i_ex != vb.end()) 825*cdf0e10cSrcweir { 826*cdf0e10cSrcweir i_in = va.begin(); 827*cdf0e10cSrcweir while (i_in != va.end()) 828*cdf0e10cSrcweir { 829*cdf0e10cSrcweir if ( *i_in == *i_ex) 830*cdf0e10cSrcweir { 831*cdf0e10cSrcweir i_next = i_in+1; 832*cdf0e10cSrcweir va.erase(i_in); 833*cdf0e10cSrcweir i_in = i_next; 834*cdf0e10cSrcweir // we can only find one match since we 835*cdf0e10cSrcweir // ensured uniquness of the entries. ergo: 836*cdf0e10cSrcweir break; 837*cdf0e10cSrcweir } 838*cdf0e10cSrcweir else 839*cdf0e10cSrcweir i_in++; 840*cdf0e10cSrcweir } 841*cdf0e10cSrcweir i_ex++; 842*cdf0e10cSrcweir } 843*cdf0e10cSrcweir } 844*cdf0e10cSrcweir 845*cdf0e10cSrcweir uno::Reference< XNameAccess > MigrationImpl::getConfigAccess(const sal_Char* pPath, sal_Bool bUpdate) 846*cdf0e10cSrcweir { 847*cdf0e10cSrcweir uno::Reference< XNameAccess > xNameAccess; 848*cdf0e10cSrcweir try{ 849*cdf0e10cSrcweir OUString sConfigSrvc = OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider"); 850*cdf0e10cSrcweir OUString sAccessSrvc; 851*cdf0e10cSrcweir if (bUpdate) 852*cdf0e10cSrcweir sAccessSrvc = OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"); 853*cdf0e10cSrcweir else 854*cdf0e10cSrcweir sAccessSrvc = OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"); 855*cdf0e10cSrcweir 856*cdf0e10cSrcweir OUString sConfigURL = OUString::createFromAscii(pPath); 857*cdf0e10cSrcweir 858*cdf0e10cSrcweir // get configuration provider 859*cdf0e10cSrcweir uno::Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory(); 860*cdf0e10cSrcweir uno::Reference< XMultiServiceFactory > theConfigProvider = uno::Reference< XMultiServiceFactory > ( 861*cdf0e10cSrcweir theMSF->createInstance( sConfigSrvc ),uno::UNO_QUERY_THROW ); 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir // access the provider 864*cdf0e10cSrcweir uno::Sequence< uno::Any > theArgs(1); 865*cdf0e10cSrcweir theArgs[ 0 ] <<= sConfigURL; 866*cdf0e10cSrcweir xNameAccess = uno::Reference< XNameAccess > ( 867*cdf0e10cSrcweir theConfigProvider->createInstanceWithArguments( 868*cdf0e10cSrcweir sAccessSrvc, theArgs ), uno::UNO_QUERY_THROW ); 869*cdf0e10cSrcweir } catch (com::sun::star::uno::Exception& e) 870*cdf0e10cSrcweir { 871*cdf0e10cSrcweir OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US); 872*cdf0e10cSrcweir OSL_ENSURE(sal_False, aMsg.getStr()); 873*cdf0e10cSrcweir } 874*cdf0e10cSrcweir return xNameAccess; 875*cdf0e10cSrcweir } 876*cdf0e10cSrcweir 877*cdf0e10cSrcweir void MigrationImpl::copyFiles() 878*cdf0e10cSrcweir { 879*cdf0e10cSrcweir strings_v::const_iterator i_file = m_vrFileList->begin(); 880*cdf0e10cSrcweir OUString localName; 881*cdf0e10cSrcweir OUString destName; 882*cdf0e10cSrcweir OUString userInstall; 883*cdf0e10cSrcweir utl::Bootstrap::PathStatus aStatus; 884*cdf0e10cSrcweir aStatus = utl::Bootstrap::locateUserInstallation(userInstall); 885*cdf0e10cSrcweir if (aStatus == utl::Bootstrap::PATH_EXISTS) 886*cdf0e10cSrcweir { 887*cdf0e10cSrcweir while (i_file != m_vrFileList->end()) 888*cdf0e10cSrcweir { 889*cdf0e10cSrcweir 890*cdf0e10cSrcweir // remove installation prefix from file 891*cdf0e10cSrcweir localName = i_file->copy(m_aInfo.userdata.getLength()); 892*cdf0e10cSrcweir destName = userInstall + localName; 893*cdf0e10cSrcweir INetURLObject aURL(destName); 894*cdf0e10cSrcweir // check whether destination directory exists 895*cdf0e10cSrcweir aURL.removeSegment(); 896*cdf0e10cSrcweir _checkAndCreateDirectory(aURL); 897*cdf0e10cSrcweir FileBase::RC copyResult = File::copy(*i_file, destName); 898*cdf0e10cSrcweir if (copyResult != FileBase::E_None) 899*cdf0e10cSrcweir { 900*cdf0e10cSrcweir OString msg("Cannot copy "); 901*cdf0e10cSrcweir msg += OUStringToOString(*i_file, RTL_TEXTENCODING_UTF8) + " to " 902*cdf0e10cSrcweir + OUStringToOString(destName, RTL_TEXTENCODING_UTF8); 903*cdf0e10cSrcweir OSL_ENSURE(sal_False, msg.getStr()); 904*cdf0e10cSrcweir } 905*cdf0e10cSrcweir i_file++; 906*cdf0e10cSrcweir } 907*cdf0e10cSrcweir } 908*cdf0e10cSrcweir else 909*cdf0e10cSrcweir { 910*cdf0e10cSrcweir OSL_ENSURE(sal_False, "copyFiles: UserInstall does not exist"); 911*cdf0e10cSrcweir } 912*cdf0e10cSrcweir } 913*cdf0e10cSrcweir 914*cdf0e10cSrcweir void MigrationImpl::runServices() 915*cdf0e10cSrcweir { 916*cdf0e10cSrcweir // Build argument array 917*cdf0e10cSrcweir uno::Sequence< uno::Any > seqArguments(3); 918*cdf0e10cSrcweir seqArguments[0] = uno::makeAny(NamedValue( 919*cdf0e10cSrcweir OUString::createFromAscii("Productname"), 920*cdf0e10cSrcweir uno::makeAny(m_aInfo.productname))); 921*cdf0e10cSrcweir seqArguments[1] = uno::makeAny(NamedValue( 922*cdf0e10cSrcweir OUString::createFromAscii("UserData"), 923*cdf0e10cSrcweir uno::makeAny(m_aInfo.userdata))); 924*cdf0e10cSrcweir 925*cdf0e10cSrcweir 926*cdf0e10cSrcweir // create an instance of every migration service 927*cdf0e10cSrcweir // and execute the migration job 928*cdf0e10cSrcweir uno::Reference< XJob > xMigrationJob; 929*cdf0e10cSrcweir 930*cdf0e10cSrcweir migrations_v::const_iterator i_mig = m_vrMigrations->begin(); 931*cdf0e10cSrcweir while (i_mig != m_vrMigrations->end()) 932*cdf0e10cSrcweir { 933*cdf0e10cSrcweir if( i_mig->service.getLength() > 0) 934*cdf0e10cSrcweir { 935*cdf0e10cSrcweir 936*cdf0e10cSrcweir try 937*cdf0e10cSrcweir { 938*cdf0e10cSrcweir // set black list for extension migration 939*cdf0e10cSrcweir uno::Sequence< rtl::OUString > seqExtBlackList; 940*cdf0e10cSrcweir sal_uInt32 nSize = i_mig->excludeExtensions.size(); 941*cdf0e10cSrcweir if ( nSize > 0 ) 942*cdf0e10cSrcweir seqExtBlackList = comphelper::arrayToSequence< ::rtl::OUString >( 943*cdf0e10cSrcweir &i_mig->excludeExtensions[0], nSize ); 944*cdf0e10cSrcweir seqArguments[2] = uno::makeAny(NamedValue( 945*cdf0e10cSrcweir OUString::createFromAscii("ExtensionBlackList"), 946*cdf0e10cSrcweir uno::makeAny( seqExtBlackList ))); 947*cdf0e10cSrcweir 948*cdf0e10cSrcweir xMigrationJob = uno::Reference< XJob >(m_xFactory->createInstanceWithArguments( 949*cdf0e10cSrcweir i_mig->service, seqArguments), uno::UNO_QUERY_THROW); 950*cdf0e10cSrcweir 951*cdf0e10cSrcweir xMigrationJob->execute(uno::Sequence< NamedValue >()); 952*cdf0e10cSrcweir 953*cdf0e10cSrcweir 954*cdf0e10cSrcweir } catch (Exception& e) 955*cdf0e10cSrcweir { 956*cdf0e10cSrcweir OString aMsg("Execution of migration service failed (Exception caught).\nService: "); 957*cdf0e10cSrcweir aMsg += OUStringToOString(i_mig->service, RTL_TEXTENCODING_ASCII_US) + "\nMessage: "; 958*cdf0e10cSrcweir aMsg += OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US); 959*cdf0e10cSrcweir OSL_ENSURE(sal_False, aMsg.getStr()); 960*cdf0e10cSrcweir } catch (...) 961*cdf0e10cSrcweir { 962*cdf0e10cSrcweir OString aMsg("Execution of migration service failed (Exception caught).\nService: "); 963*cdf0e10cSrcweir aMsg += OUStringToOString(i_mig->service, RTL_TEXTENCODING_ASCII_US) + 964*cdf0e10cSrcweir "\nNo message available"; 965*cdf0e10cSrcweir OSL_ENSURE(sal_False, aMsg.getStr()); 966*cdf0e10cSrcweir } 967*cdf0e10cSrcweir 968*cdf0e10cSrcweir } 969*cdf0e10cSrcweir i_mig++; 970*cdf0e10cSrcweir } 971*cdf0e10cSrcweir } 972*cdf0e10cSrcweir 973*cdf0e10cSrcweir ::std::vector< MigrationModuleInfo > MigrationImpl::dectectUIChangesForAllModules() const 974*cdf0e10cSrcweir { 975*cdf0e10cSrcweir ::std::vector< MigrationModuleInfo > vModulesInfo; 976*cdf0e10cSrcweir const ::rtl::OUString MENUBAR = ::rtl::OUString::createFromAscii("menubar"); 977*cdf0e10cSrcweir const ::rtl::OUString TOOLBAR = ::rtl::OUString::createFromAscii("toolbar"); 978*cdf0e10cSrcweir 979*cdf0e10cSrcweir uno::Sequence< uno::Any > lArgs(2); 980*cdf0e10cSrcweir lArgs[0] <<= m_aInfo.userdata + ::rtl::OUString::createFromAscii("/user/config/soffice.cfg/modules"); 981*cdf0e10cSrcweir lArgs[1] <<= embed::ElementModes::READ; 982*cdf0e10cSrcweir 983*cdf0e10cSrcweir uno::Reference< lang::XSingleServiceFactory > xStorageFactory(m_xFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.embed.FileSystemStorageFactory")), uno::UNO_QUERY); 984*cdf0e10cSrcweir uno::Reference< embed::XStorage > xModules; 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir xModules = uno::Reference< embed::XStorage >(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY); 987*cdf0e10cSrcweir if (!xModules.is()) 988*cdf0e10cSrcweir return vModulesInfo; 989*cdf0e10cSrcweir 990*cdf0e10cSrcweir uno::Reference< container::XNameAccess > xAccess = uno::Reference< container::XNameAccess >(xModules, uno::UNO_QUERY); 991*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > lNames = xAccess->getElementNames(); 992*cdf0e10cSrcweir sal_Int32 nLength = lNames.getLength(); 993*cdf0e10cSrcweir for (sal_Int32 i=0; i<nLength; ++i) 994*cdf0e10cSrcweir { 995*cdf0e10cSrcweir ::rtl::OUString sModuleShortName = lNames[i]; 996*cdf0e10cSrcweir uno::Reference< embed::XStorage > xModule = xModules->openStorageElement(sModuleShortName, embed::ElementModes::READ); 997*cdf0e10cSrcweir if (xModule.is()) 998*cdf0e10cSrcweir { 999*cdf0e10cSrcweir MigrationModuleInfo aModuleInfo; 1000*cdf0e10cSrcweir 1001*cdf0e10cSrcweir uno::Reference< embed::XStorage > xMenubar = xModule->openStorageElement(MENUBAR, embed::ElementModes::READ); 1002*cdf0e10cSrcweir if (xMenubar.is()) 1003*cdf0e10cSrcweir { 1004*cdf0e10cSrcweir uno::Reference< container::XNameAccess > xNameAccess = uno::Reference< container::XNameAccess >(xMenubar, uno::UNO_QUERY); 1005*cdf0e10cSrcweir if (xNameAccess->getElementNames().getLength() > 0) 1006*cdf0e10cSrcweir { 1007*cdf0e10cSrcweir aModuleInfo.sModuleShortName = sModuleShortName; 1008*cdf0e10cSrcweir aModuleInfo.bHasMenubar = sal_True; 1009*cdf0e10cSrcweir } 1010*cdf0e10cSrcweir } 1011*cdf0e10cSrcweir 1012*cdf0e10cSrcweir uno::Reference< embed::XStorage > xToolbar = xModule->openStorageElement(TOOLBAR, embed::ElementModes::READ); 1013*cdf0e10cSrcweir if (xToolbar.is()) 1014*cdf0e10cSrcweir { 1015*cdf0e10cSrcweir const ::rtl::OUString RESOURCEURL_CUSTOM_ELEMENT = ::rtl::OUString::createFromAscii("custom_"); 1016*cdf0e10cSrcweir sal_Int32 nCustomLen = 7; 1017*cdf0e10cSrcweir 1018*cdf0e10cSrcweir uno::Reference< container::XNameAccess > xNameAccess = uno::Reference< container::XNameAccess >(xToolbar, uno::UNO_QUERY); 1019*cdf0e10cSrcweir ::uno::Sequence< ::rtl::OUString > lToolbars = xNameAccess->getElementNames(); 1020*cdf0e10cSrcweir for (sal_Int32 j=0; j<lToolbars.getLength(); ++j) 1021*cdf0e10cSrcweir { 1022*cdf0e10cSrcweir ::rtl::OUString sToolbarName = lToolbars[j]; 1023*cdf0e10cSrcweir if (sToolbarName.getLength()>=nCustomLen && 1024*cdf0e10cSrcweir sToolbarName.copy(0, nCustomLen).equals(RESOURCEURL_CUSTOM_ELEMENT)) 1025*cdf0e10cSrcweir continue; 1026*cdf0e10cSrcweir 1027*cdf0e10cSrcweir aModuleInfo.sModuleShortName = sModuleShortName; 1028*cdf0e10cSrcweir sal_Int32 nIndex = sToolbarName.lastIndexOf('.'); 1029*cdf0e10cSrcweir if (nIndex > 0) 1030*cdf0e10cSrcweir { 1031*cdf0e10cSrcweir ::rtl::OUString sExtension(sToolbarName.copy(nIndex)); 1032*cdf0e10cSrcweir ::rtl::OUString sToolbarResourceName(sToolbarName.copy(0, nIndex)); 1033*cdf0e10cSrcweir if (sToolbarResourceName.getLength()>0 && sExtension.equalsAsciiL(".xml", 4)) 1034*cdf0e10cSrcweir aModuleInfo.m_vToolbars.push_back(sToolbarResourceName); 1035*cdf0e10cSrcweir } 1036*cdf0e10cSrcweir } 1037*cdf0e10cSrcweir } 1038*cdf0e10cSrcweir 1039*cdf0e10cSrcweir if (aModuleInfo.sModuleShortName.getLength()>0) 1040*cdf0e10cSrcweir vModulesInfo.push_back(aModuleInfo); 1041*cdf0e10cSrcweir } 1042*cdf0e10cSrcweir } 1043*cdf0e10cSrcweir 1044*cdf0e10cSrcweir return vModulesInfo; 1045*cdf0e10cSrcweir } 1046*cdf0e10cSrcweir 1047*cdf0e10cSrcweir void MigrationImpl::compareOldAndNewConfig(const ::rtl::OUString& sParent, 1048*cdf0e10cSrcweir const uno::Reference< container::XIndexContainer >& xIndexOld, 1049*cdf0e10cSrcweir const uno::Reference< container::XIndexContainer >& xIndexNew, 1050*cdf0e10cSrcweir const ::rtl::OUString& sResourceURL) 1051*cdf0e10cSrcweir { 1052*cdf0e10cSrcweir ::std::vector< MigrationItem > vOldItems; 1053*cdf0e10cSrcweir ::std::vector< MigrationItem > vNewItems; 1054*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aProp; 1055*cdf0e10cSrcweir sal_Int32 nOldCount = xIndexOld->getCount(); 1056*cdf0e10cSrcweir sal_Int32 nNewCount = xIndexNew->getCount(); 1057*cdf0e10cSrcweir 1058*cdf0e10cSrcweir for (int n=0; n<nOldCount; ++n) 1059*cdf0e10cSrcweir { 1060*cdf0e10cSrcweir MigrationItem aMigrationItem; 1061*cdf0e10cSrcweir if (xIndexOld->getByIndex(n) >>= aProp) 1062*cdf0e10cSrcweir { 1063*cdf0e10cSrcweir for(int i=0; i<aProp.getLength(); ++i) 1064*cdf0e10cSrcweir { 1065*cdf0e10cSrcweir if (aProp[i].Name.equals(ITEM_DESCRIPTOR_COMMANDURL)) 1066*cdf0e10cSrcweir aProp[i].Value >>= aMigrationItem.m_sCommandURL; 1067*cdf0e10cSrcweir else if (aProp[i].Name.equals(ITEM_DESCRIPTOR_CONTAINER)) 1068*cdf0e10cSrcweir aProp[i].Value >>= aMigrationItem.m_xPopupMenu; 1069*cdf0e10cSrcweir } 1070*cdf0e10cSrcweir 1071*cdf0e10cSrcweir if (aMigrationItem.m_sCommandURL.getLength()) 1072*cdf0e10cSrcweir vOldItems.push_back(aMigrationItem); 1073*cdf0e10cSrcweir } 1074*cdf0e10cSrcweir } 1075*cdf0e10cSrcweir 1076*cdf0e10cSrcweir for (int n=0; n<nNewCount; ++n) 1077*cdf0e10cSrcweir { 1078*cdf0e10cSrcweir MigrationItem aMigrationItem; 1079*cdf0e10cSrcweir if (xIndexNew->getByIndex(n) >>= aProp) 1080*cdf0e10cSrcweir { 1081*cdf0e10cSrcweir for(int i=0; i<aProp.getLength(); ++i) 1082*cdf0e10cSrcweir { 1083*cdf0e10cSrcweir if (aProp[i].Name.equals(ITEM_DESCRIPTOR_COMMANDURL)) 1084*cdf0e10cSrcweir aProp[i].Value >>= aMigrationItem.m_sCommandURL; 1085*cdf0e10cSrcweir else if (aProp[i].Name.equals(ITEM_DESCRIPTOR_CONTAINER)) 1086*cdf0e10cSrcweir aProp[i].Value >>= aMigrationItem.m_xPopupMenu; 1087*cdf0e10cSrcweir } 1088*cdf0e10cSrcweir 1089*cdf0e10cSrcweir if (aMigrationItem.m_sCommandURL.getLength()) 1090*cdf0e10cSrcweir vNewItems.push_back(aMigrationItem); 1091*cdf0e10cSrcweir } 1092*cdf0e10cSrcweir } 1093*cdf0e10cSrcweir 1094*cdf0e10cSrcweir ::std::vector< MigrationItem >::iterator it; 1095*cdf0e10cSrcweir 1096*cdf0e10cSrcweir ::rtl::OUString sSibling; 1097*cdf0e10cSrcweir for (it = vOldItems.begin(); it!=vOldItems.end(); ++it) 1098*cdf0e10cSrcweir { 1099*cdf0e10cSrcweir ::std::vector< MigrationItem >::iterator pFound = ::std::find(vNewItems.begin(), vNewItems.end(), *it); 1100*cdf0e10cSrcweir if (pFound != vNewItems.end() && it->m_xPopupMenu.is()) 1101*cdf0e10cSrcweir { 1102*cdf0e10cSrcweir ::rtl::OUString sName; 1103*cdf0e10cSrcweir if (sParent.getLength()>0) 1104*cdf0e10cSrcweir sName = sParent + MENU_SEPERATOR + it->m_sCommandURL; 1105*cdf0e10cSrcweir else 1106*cdf0e10cSrcweir sName = it->m_sCommandURL; 1107*cdf0e10cSrcweir compareOldAndNewConfig(sName, it->m_xPopupMenu, pFound->m_xPopupMenu, sResourceURL); 1108*cdf0e10cSrcweir } 1109*cdf0e10cSrcweir else if (pFound == vNewItems.end()) 1110*cdf0e10cSrcweir { 1111*cdf0e10cSrcweir MigrationItem aMigrationItem(sParent, sSibling, it->m_sCommandURL, it->m_xPopupMenu); 1112*cdf0e10cSrcweir if (m_aOldVersionItemsHashMap.find(sResourceURL)==m_aOldVersionItemsHashMap.end()) 1113*cdf0e10cSrcweir { 1114*cdf0e10cSrcweir ::std::vector< MigrationItem > vMigrationItems; 1115*cdf0e10cSrcweir m_aOldVersionItemsHashMap.insert(MigrationHashMap::value_type(sResourceURL, vMigrationItems)); 1116*cdf0e10cSrcweir m_aOldVersionItemsHashMap[sResourceURL].push_back(aMigrationItem); 1117*cdf0e10cSrcweir } 1118*cdf0e10cSrcweir else 1119*cdf0e10cSrcweir { 1120*cdf0e10cSrcweir if (::std::find(m_aOldVersionItemsHashMap[sResourceURL].begin(), m_aOldVersionItemsHashMap[sResourceURL].end(), aMigrationItem)==m_aOldVersionItemsHashMap[sResourceURL].end()) 1121*cdf0e10cSrcweir m_aOldVersionItemsHashMap[sResourceURL].push_back(aMigrationItem); 1122*cdf0e10cSrcweir } 1123*cdf0e10cSrcweir } 1124*cdf0e10cSrcweir 1125*cdf0e10cSrcweir sSibling = it->m_sCommandURL; 1126*cdf0e10cSrcweir } 1127*cdf0e10cSrcweir 1128*cdf0e10cSrcweir ::rtl::OUString sNewSibling; 1129*cdf0e10cSrcweir uno::Reference< container::XIndexContainer > xPopup; 1130*cdf0e10cSrcweir for (it = vNewItems.begin(); it!=vNewItems.end(); ++it) 1131*cdf0e10cSrcweir { 1132*cdf0e10cSrcweir ::std::vector< MigrationItem >::iterator pFound = ::std::find(vOldItems.begin(), vOldItems.end(), *it); 1133*cdf0e10cSrcweir if (pFound != vOldItems.end() && it->m_xPopupMenu.is()) 1134*cdf0e10cSrcweir { 1135*cdf0e10cSrcweir ::rtl::OUString sName; 1136*cdf0e10cSrcweir if (sParent.getLength()>0) 1137*cdf0e10cSrcweir sName = sParent + MENU_SEPERATOR + it->m_sCommandURL; 1138*cdf0e10cSrcweir else 1139*cdf0e10cSrcweir sName = it->m_sCommandURL; 1140*cdf0e10cSrcweir compareOldAndNewConfig(sName, pFound->m_xPopupMenu, it->m_xPopupMenu, sResourceURL); 1141*cdf0e10cSrcweir } 1142*cdf0e10cSrcweir else if (::std::find(vOldItems.begin(), vOldItems.end(), *it) == vOldItems.end()) 1143*cdf0e10cSrcweir { 1144*cdf0e10cSrcweir MigrationItem aMigrationItem(sParent, sSibling, it->m_sCommandURL, it->m_xPopupMenu); 1145*cdf0e10cSrcweir if (m_aNewVersionItemsHashMap.find(sResourceURL)==m_aNewVersionItemsHashMap.end()) 1146*cdf0e10cSrcweir { 1147*cdf0e10cSrcweir ::std::vector< MigrationItem > vMigrationItems; 1148*cdf0e10cSrcweir m_aNewVersionItemsHashMap.insert(MigrationHashMap::value_type(sResourceURL, vMigrationItems)); 1149*cdf0e10cSrcweir m_aNewVersionItemsHashMap[sResourceURL].push_back(aMigrationItem); 1150*cdf0e10cSrcweir } 1151*cdf0e10cSrcweir else 1152*cdf0e10cSrcweir { 1153*cdf0e10cSrcweir if (::std::find(m_aNewVersionItemsHashMap[sResourceURL].begin(), m_aNewVersionItemsHashMap[sResourceURL].end(), aMigrationItem)==m_aNewVersionItemsHashMap[sResourceURL].end()) 1154*cdf0e10cSrcweir m_aNewVersionItemsHashMap[sResourceURL].push_back(aMigrationItem); 1155*cdf0e10cSrcweir } 1156*cdf0e10cSrcweir } 1157*cdf0e10cSrcweir } 1158*cdf0e10cSrcweir } 1159*cdf0e10cSrcweir 1160*cdf0e10cSrcweir void MigrationImpl::mergeOldToNewVersion(const uno::Reference< ui::XUIConfigurationManager >& xCfgManager, 1161*cdf0e10cSrcweir const uno::Reference< container::XIndexContainer>& xIndexContainer, 1162*cdf0e10cSrcweir const ::rtl::OUString& sModuleIdentifier, 1163*cdf0e10cSrcweir const ::rtl::OUString& sResourceURL) 1164*cdf0e10cSrcweir { 1165*cdf0e10cSrcweir MigrationHashMap::iterator pFound = m_aOldVersionItemsHashMap.find(sResourceURL); 1166*cdf0e10cSrcweir if (pFound==m_aOldVersionItemsHashMap.end()) 1167*cdf0e10cSrcweir return; 1168*cdf0e10cSrcweir 1169*cdf0e10cSrcweir ::std::vector< MigrationItem >::iterator it; 1170*cdf0e10cSrcweir for (it=pFound->second.begin(); it!=pFound->second.end(); ++it) 1171*cdf0e10cSrcweir { 1172*cdf0e10cSrcweir uno::Reference< container::XIndexContainer > xTemp = xIndexContainer; 1173*cdf0e10cSrcweir 1174*cdf0e10cSrcweir ::rtl::OUString sParentNodeName = it->m_sParentNodeName; 1175*cdf0e10cSrcweir sal_Int32 nIndex = 0; 1176*cdf0e10cSrcweir do 1177*cdf0e10cSrcweir { 1178*cdf0e10cSrcweir ::rtl::OUString sToken = sParentNodeName.getToken(0, '|', nIndex).trim(); 1179*cdf0e10cSrcweir if (sToken.getLength()<=0) 1180*cdf0e10cSrcweir break; 1181*cdf0e10cSrcweir 1182*cdf0e10cSrcweir sal_Int32 nCount = xTemp->getCount(); 1183*cdf0e10cSrcweir for (sal_Int32 i=0; i<nCount; ++i) 1184*cdf0e10cSrcweir { 1185*cdf0e10cSrcweir ::rtl::OUString sCommandURL; 1186*cdf0e10cSrcweir ::rtl::OUString sLabel; 1187*cdf0e10cSrcweir uno::Reference< container::XIndexContainer > xChild; 1188*cdf0e10cSrcweir 1189*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aPropSeq; 1190*cdf0e10cSrcweir xTemp->getByIndex(i) >>= aPropSeq; 1191*cdf0e10cSrcweir for (sal_Int32 j=0; j<aPropSeq.getLength(); ++j) 1192*cdf0e10cSrcweir { 1193*cdf0e10cSrcweir ::rtl::OUString sPropName = aPropSeq[j].Name; 1194*cdf0e10cSrcweir if (sPropName.equals(ITEM_DESCRIPTOR_COMMANDURL)) 1195*cdf0e10cSrcweir aPropSeq[j].Value >>= sCommandURL; 1196*cdf0e10cSrcweir else if (sPropName.equals(ITEM_DESCRIPTOR_LABEL)) 1197*cdf0e10cSrcweir aPropSeq[j].Value >>= sLabel; 1198*cdf0e10cSrcweir else if (sPropName.equals(ITEM_DESCRIPTOR_CONTAINER)) 1199*cdf0e10cSrcweir aPropSeq[j].Value >>= xChild; 1200*cdf0e10cSrcweir } 1201*cdf0e10cSrcweir 1202*cdf0e10cSrcweir if (sCommandURL == sToken) 1203*cdf0e10cSrcweir { 1204*cdf0e10cSrcweir xTemp = xChild; 1205*cdf0e10cSrcweir break; 1206*cdf0e10cSrcweir } 1207*cdf0e10cSrcweir } 1208*cdf0e10cSrcweir 1209*cdf0e10cSrcweir } while (nIndex>=0); 1210*cdf0e10cSrcweir 1211*cdf0e10cSrcweir if (nIndex == -1) 1212*cdf0e10cSrcweir { 1213*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aPropSeq(3); 1214*cdf0e10cSrcweir 1215*cdf0e10cSrcweir aPropSeq[0].Name = ITEM_DESCRIPTOR_COMMANDURL; 1216*cdf0e10cSrcweir aPropSeq[0].Value <<= it->m_sCommandURL; 1217*cdf0e10cSrcweir aPropSeq[1].Name = ITEM_DESCRIPTOR_LABEL; 1218*cdf0e10cSrcweir aPropSeq[1].Value <<= retrieveLabelFromCommand(it->m_sCommandURL, sModuleIdentifier); 1219*cdf0e10cSrcweir aPropSeq[2].Name = ITEM_DESCRIPTOR_CONTAINER; 1220*cdf0e10cSrcweir aPropSeq[2].Value <<= it->m_xPopupMenu; 1221*cdf0e10cSrcweir 1222*cdf0e10cSrcweir if (it->m_sPrevSibling.getLength() == 0) 1223*cdf0e10cSrcweir xTemp->insertByIndex(0, uno::makeAny(aPropSeq)); 1224*cdf0e10cSrcweir else if (it->m_sPrevSibling.getLength() > 0) 1225*cdf0e10cSrcweir { 1226*cdf0e10cSrcweir sal_Int32 nCount = xTemp->getCount(); 1227*cdf0e10cSrcweir sal_Int32 i = 0; 1228*cdf0e10cSrcweir for (; i<nCount; ++i) 1229*cdf0e10cSrcweir { 1230*cdf0e10cSrcweir ::rtl::OUString sCmd; 1231*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aTempPropSeq; 1232*cdf0e10cSrcweir xTemp->getByIndex(i) >>= aTempPropSeq; 1233*cdf0e10cSrcweir for (sal_Int32 j=0; j<aTempPropSeq.getLength(); ++j) 1234*cdf0e10cSrcweir { 1235*cdf0e10cSrcweir if (aTempPropSeq[j].Name.equals(ITEM_DESCRIPTOR_COMMANDURL)) 1236*cdf0e10cSrcweir { 1237*cdf0e10cSrcweir aTempPropSeq[j].Value >>= sCmd; 1238*cdf0e10cSrcweir break; 1239*cdf0e10cSrcweir } 1240*cdf0e10cSrcweir } 1241*cdf0e10cSrcweir 1242*cdf0e10cSrcweir if (sCmd.equals(it->m_sPrevSibling)) 1243*cdf0e10cSrcweir break; 1244*cdf0e10cSrcweir } 1245*cdf0e10cSrcweir 1246*cdf0e10cSrcweir xTemp->insertByIndex(i+1, uno::makeAny(aPropSeq)); 1247*cdf0e10cSrcweir } 1248*cdf0e10cSrcweir } 1249*cdf0e10cSrcweir } 1250*cdf0e10cSrcweir 1251*cdf0e10cSrcweir uno::Reference< container::XIndexAccess > xIndexAccess(xIndexContainer, uno::UNO_QUERY); 1252*cdf0e10cSrcweir if (xIndexAccess.is()) 1253*cdf0e10cSrcweir xCfgManager->replaceSettings(sResourceURL, xIndexAccess); 1254*cdf0e10cSrcweir 1255*cdf0e10cSrcweir uno::Reference< ui::XUIConfigurationPersistence > xUIConfigurationPersistence(xCfgManager, uno::UNO_QUERY); 1256*cdf0e10cSrcweir if (xUIConfigurationPersistence.is()) 1257*cdf0e10cSrcweir xUIConfigurationPersistence->store(); 1258*cdf0e10cSrcweir } 1259*cdf0e10cSrcweir 1260*cdf0e10cSrcweir uno::Reference< ui::XUIConfigurationManager > NewVersionUIInfo::getConfigManager(const ::rtl::OUString& sModuleShortName) const 1261*cdf0e10cSrcweir { 1262*cdf0e10cSrcweir uno::Reference< ui::XUIConfigurationManager > xCfgManager; 1263*cdf0e10cSrcweir 1264*cdf0e10cSrcweir for (sal_Int32 i=0; i<m_lCfgManagerSeq.getLength(); ++i) 1265*cdf0e10cSrcweir { 1266*cdf0e10cSrcweir if (m_lCfgManagerSeq[i].Name.equals(sModuleShortName)) 1267*cdf0e10cSrcweir { 1268*cdf0e10cSrcweir m_lCfgManagerSeq[i].Value >>= xCfgManager; 1269*cdf0e10cSrcweir break; 1270*cdf0e10cSrcweir } 1271*cdf0e10cSrcweir } 1272*cdf0e10cSrcweir 1273*cdf0e10cSrcweir return xCfgManager; 1274*cdf0e10cSrcweir } 1275*cdf0e10cSrcweir 1276*cdf0e10cSrcweir uno::Reference< container::XIndexContainer > NewVersionUIInfo::getNewMenubarSettings(const ::rtl::OUString& sModuleShortName) const 1277*cdf0e10cSrcweir { 1278*cdf0e10cSrcweir uno::Reference< container::XIndexContainer > xNewMenuSettings; 1279*cdf0e10cSrcweir 1280*cdf0e10cSrcweir for (sal_Int32 i=0; i<m_lNewVersionMenubarSettingsSeq.getLength(); ++i) 1281*cdf0e10cSrcweir { 1282*cdf0e10cSrcweir if (m_lNewVersionMenubarSettingsSeq[i].Name.equals(sModuleShortName)) 1283*cdf0e10cSrcweir { 1284*cdf0e10cSrcweir m_lNewVersionMenubarSettingsSeq[i].Value >>= xNewMenuSettings; 1285*cdf0e10cSrcweir break; 1286*cdf0e10cSrcweir } 1287*cdf0e10cSrcweir } 1288*cdf0e10cSrcweir 1289*cdf0e10cSrcweir return xNewMenuSettings; 1290*cdf0e10cSrcweir } 1291*cdf0e10cSrcweir 1292*cdf0e10cSrcweir uno::Reference< container::XIndexContainer > NewVersionUIInfo::getNewToolbarSettings(const ::rtl::OUString& sModuleShortName, const ::rtl::OUString& sToolbarName) const 1293*cdf0e10cSrcweir { 1294*cdf0e10cSrcweir uno::Reference< container::XIndexContainer > xNewToolbarSettings; 1295*cdf0e10cSrcweir 1296*cdf0e10cSrcweir for (sal_Int32 i=0; i<m_lNewVersionToolbarSettingsSeq.getLength(); ++i) 1297*cdf0e10cSrcweir { 1298*cdf0e10cSrcweir if (m_lNewVersionToolbarSettingsSeq[i].Name.equals(sModuleShortName)) 1299*cdf0e10cSrcweir { 1300*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > lToolbarSettingsSeq; 1301*cdf0e10cSrcweir m_lNewVersionToolbarSettingsSeq[i].Value >>= lToolbarSettingsSeq; 1302*cdf0e10cSrcweir for (sal_Int32 j=0; j<lToolbarSettingsSeq.getLength(); ++j) 1303*cdf0e10cSrcweir { 1304*cdf0e10cSrcweir if (lToolbarSettingsSeq[j].Name.equals(sToolbarName)) 1305*cdf0e10cSrcweir { 1306*cdf0e10cSrcweir lToolbarSettingsSeq[j].Value >>= xNewToolbarSettings; 1307*cdf0e10cSrcweir break; 1308*cdf0e10cSrcweir } 1309*cdf0e10cSrcweir } 1310*cdf0e10cSrcweir 1311*cdf0e10cSrcweir break; 1312*cdf0e10cSrcweir } 1313*cdf0e10cSrcweir } 1314*cdf0e10cSrcweir 1315*cdf0e10cSrcweir return xNewToolbarSettings; 1316*cdf0e10cSrcweir } 1317*cdf0e10cSrcweir 1318*cdf0e10cSrcweir void NewVersionUIInfo::init(const ::std::vector< MigrationModuleInfo >& vModulesInfo) 1319*cdf0e10cSrcweir { 1320*cdf0e10cSrcweir m_lCfgManagerSeq.realloc(vModulesInfo.size()); 1321*cdf0e10cSrcweir m_lNewVersionMenubarSettingsSeq.realloc(vModulesInfo.size()); 1322*cdf0e10cSrcweir m_lNewVersionToolbarSettingsSeq.realloc(vModulesInfo.size()); 1323*cdf0e10cSrcweir 1324*cdf0e10cSrcweir const ::rtl::OUString sModuleCfgSupplier = ::rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier"); 1325*cdf0e10cSrcweir const ::rtl::OUString sMenubarResourceURL = ::rtl::OUString::createFromAscii("private:resource/menubar/menubar"); 1326*cdf0e10cSrcweir const ::rtl::OUString sToolbarResourcePre = ::rtl::OUString::createFromAscii("private:resource/toolbar/"); 1327*cdf0e10cSrcweir 1328*cdf0e10cSrcweir uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xModuleCfgSupplier = uno::Reference< ui::XModuleUIConfigurationManagerSupplier >(::comphelper::getProcessServiceFactory()->createInstance(sModuleCfgSupplier), uno::UNO_QUERY); 1329*cdf0e10cSrcweir 1330*cdf0e10cSrcweir for (sal_uInt32 i=0; i<vModulesInfo.size(); ++i) 1331*cdf0e10cSrcweir { 1332*cdf0e10cSrcweir ::rtl::OUString sModuleIdentifier = mapModuleShortNameToIdentifier(vModulesInfo[i].sModuleShortName); 1333*cdf0e10cSrcweir if (sModuleIdentifier.getLength() > 0) 1334*cdf0e10cSrcweir { 1335*cdf0e10cSrcweir uno::Reference< ui::XUIConfigurationManager > xCfgManager = xModuleCfgSupplier->getUIConfigurationManager(sModuleIdentifier); 1336*cdf0e10cSrcweir m_lCfgManagerSeq[i].Name = vModulesInfo[i].sModuleShortName; 1337*cdf0e10cSrcweir m_lCfgManagerSeq[i].Value <<= xCfgManager; 1338*cdf0e10cSrcweir 1339*cdf0e10cSrcweir if (vModulesInfo[i].bHasMenubar) 1340*cdf0e10cSrcweir { 1341*cdf0e10cSrcweir m_lNewVersionMenubarSettingsSeq[i].Name = vModulesInfo[i].sModuleShortName; 1342*cdf0e10cSrcweir m_lNewVersionMenubarSettingsSeq[i].Value <<= xCfgManager->getSettings(sMenubarResourceURL, sal_True); 1343*cdf0e10cSrcweir } 1344*cdf0e10cSrcweir 1345*cdf0e10cSrcweir sal_Int32 nToolbars = vModulesInfo[i].m_vToolbars.size(); 1346*cdf0e10cSrcweir if (nToolbars > 0) 1347*cdf0e10cSrcweir { 1348*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > lPropSeq(nToolbars); 1349*cdf0e10cSrcweir for (sal_Int32 j=0; j<nToolbars; ++j) 1350*cdf0e10cSrcweir { 1351*cdf0e10cSrcweir ::rtl::OUString sToolbarName = vModulesInfo[i].m_vToolbars[j]; 1352*cdf0e10cSrcweir ::rtl::OUString sToolbarResourceURL = sToolbarResourcePre + sToolbarName; 1353*cdf0e10cSrcweir 1354*cdf0e10cSrcweir lPropSeq[j].Name = sToolbarName; 1355*cdf0e10cSrcweir lPropSeq[j].Value <<= xCfgManager->getSettings(sToolbarResourceURL, sal_True); 1356*cdf0e10cSrcweir } 1357*cdf0e10cSrcweir 1358*cdf0e10cSrcweir m_lNewVersionToolbarSettingsSeq[i].Name = vModulesInfo[i].sModuleShortName; 1359*cdf0e10cSrcweir m_lNewVersionToolbarSettingsSeq[i].Value <<= lPropSeq; 1360*cdf0e10cSrcweir } 1361*cdf0e10cSrcweir } 1362*cdf0e10cSrcweir } 1363*cdf0e10cSrcweir } 1364*cdf0e10cSrcweir 1365*cdf0e10cSrcweir } // namespace desktop 1366