ooo-build r13485 - in trunk: . patches/dev300



Author: tml
Date: Wed Aug  6 16:24:57 2008
New Revision: 13485
URL: http://svn.gnome.org/viewvc/ooo-build?rev=13485&view=rev

Log:
2008-08-06  Tor Lillqvist  <tml novell com>

	* patches/dev300/desktop-config-migration.diff
	* patches/dev300/desktop-config-migration-m28.diff: Split into
	separate versions, original for [ < dev300-m29 < ooo300-m1 ] and
	an updated one for [ >= dev300-m29 >= ooo300-m1 ].

	* patches/dev300/apply: Do it.



Added:
   trunk/patches/dev300/desktop-config-migration-m28.diff
Modified:
   trunk/ChangeLog
   trunk/patches/dev300/desktop-config-migration.diff

Added: trunk/patches/dev300/desktop-config-migration-m28.diff
==============================================================================
--- (empty file)
+++ trunk/patches/dev300/desktop-config-migration-m28.diff	Wed Aug  6 16:24:57 2008
@@ -0,0 +1,606 @@
+diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx
+index 43e8b48..9722617 100644
+--- desktop/source/migration/migration.cxx
++++ desktop/source/migration/migration.cxx
+@@ -58,6 +58,10 @@
+ #include <com/sun/star/configuration/backend/XSingleLayerStratum.hpp>
+ #include <com/sun/star/util/XRefreshable.hpp>
+ #include <com/sun/star/util/XChangesBatch.hpp>
++#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
++#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
++#include <com/sun/star/awt/Key.hpp>
++#include <com/sun/star/awt/KeyEvent.hpp>
+  
+ using namespace rtl;
+ using namespace osl;
+@@ -71,6 +75,8 @@ using namespace com::sun::star::container;
+ using namespace com::sun::star::configuration;
+ using namespace com::sun::star::configuration::backend;
+ 
++#define ascii( asc ) \
++    ::rtl::OUString::intern( RTL_CONSTASCII_USTRINGPARAM( asc ) )
+ 
+ namespace desktop {
+ 
+@@ -128,17 +134,148 @@ OUString Migration::getOldVersionName()
+     return getImpl()->getOldVersionName();
+ }
+ 
++MigrationImpl::VersionNumber::VersionNumber() :
++    mnMajor(0), mnMinor(0), mnMicro(0)
++{
++}
++
++MigrationImpl::VersionNumber::VersionNumber(sal_Int32 nMajor, sal_Int32 nMinor, sal_Int32 nMicro) :
++    mnMajor(nMajor), mnMinor(nMinor), mnMicro(nMicro)
++{
++}
++
+ OUString MigrationImpl::getOldVersionName()
+ {
+     return m_aInfo.productname;
+ }
+ 
+-sal_Bool MigrationImpl::checkMigration()
++static bool splitVersionString(const OUString& rVer, MigrationImpl::VersionNumber& rVerNum)
++{
++    rVerNum.mnMajor = 0;
++    rVerNum.mnMinor = 0;
++    rVerNum.mnMicro = 0;
++
++    sal_Int32 nLen = rVer.getLength();
++    const sal_Unicode* pStr = rVer.getStr();
++    OUStringBuffer buf;
++    sal_uInt8 nPos = 0; // 0 = major; 1 = minor; 2 = micro
++    for (sal_Int32 i = 0; i < nLen; ++i)
++    {
++        const sal_Unicode c = pStr[i];
++        if (c >= sal_Unicode('0') && c <= sal_Unicode('9'))
++            buf.append(c);
++        else if (c == sal_Unicode('.'))
++        {
++            if (buf.getLength() == 0)
++                // no numbers.
++                return false;
++
++            sal_Int32 nTmp = buf.makeStringAndClear().toInt32();
++            if (nTmp < 0 || nTmp > 255)
++                // only 0 - 255 allowed in a version number.
++                return false;
++
++            switch (nPos)
++            {
++                case 0: rVerNum.mnMajor = static_cast<sal_uInt8>(nTmp); break;
++                case 1: rVerNum.mnMinor = static_cast<sal_uInt8>(nTmp); break;
++                case 2: rVerNum.mnMicro = static_cast<sal_uInt8>(nTmp); break;
++            }
++
++            nPos += 1;
++            if (nPos > 2)
++                return true;
++        }
++        else
++            return false;
++    }
++
++    return true;
++}
++
++/** returns -1 if rVer1 < rVer2, 0 if rVer1 == rVer2, or 1 if rVer1 >
++    rVer2. */
++static short compareVersion(const MigrationImpl::VersionNumber& rVer1, 
++                            const MigrationImpl::VersionNumber& rVer2)
+ {
+-    if (m_aInfo.userdata.getLength() > 0 && ! checkMigrationCompleted())
++    // major version
++    if (rVer1.mnMajor < rVer2.mnMajor)
++        return -1;
++    if (rVer1.mnMajor > rVer2.mnMajor)
++        return 1;
++
++    // minor version
++    if (rVer1.mnMinor < rVer2.mnMinor)
++        return -1;
++    if (rVer1.mnMinor > rVer2.mnMinor)
++        return 1;
++
++    // micro version
++    if (rVer1.mnMicro < rVer2.mnMicro)
++        return -1;
++    if (rVer1.mnMicro > rVer2.mnMicro)
++        return 1;
++
++    return 0;
++}
++
++static sal_Bool isMigrationNeeded(const OUString& rConfVerStr, const OUString& rAppVerStr, 
++                                  MigrationImpl::VersionNumber& rConfVerNum, 
++                                  MigrationImpl::VersionNumber& rAppVerNum)
++{
++    if (!splitVersionString(rConfVerStr, rConfVerNum))
++        return sal_False;
++
++    if (!splitVersionString(rAppVerStr, rAppVerNum))
++        return sal_False;
++
++#if 0
++    fprintf(stdout, "desktop::isMigrationNeeded: config ver = %d.%d.%d\n", 
++            rConfVerNum.mnMajor,rConfVerNum.mnMinor,rConfVerNum.mnMicro);
++
++    fprintf(stdout, "desktop::isMigrationNeeded: app ver = %d.%d.%d\n", 
++            rAppVerNum.mnMajor,rAppVerNum.mnMinor,rAppVerNum.mnMicro);
++#endif    
++
++    if (compareVersion(rConfVerNum, rAppVerNum) < 0)
+         return sal_True;
+-    else
++
++    return sal_False;
++}
++
++sal_Bool MigrationImpl::checkMigration()
++{
++    if (m_bMigrationCompleted)
++        // migration is already complete.
+         return sal_False;
++
++    try
++    {
++        Reference< XPropertySet > aPropSet(getConfigAccess("org.openoffice.Setup/Product"), UNO_QUERY_THROW);
++        Any any = aPropSet->getPropertyValue(ascii("ooSetupVersionAboutBox"));
++        if (!(any >>= m_aAppVerStr))
++            // Current version unknown.  Don't do migration (this should not happen).
++            return sal_False;
++
++        aPropSet.set(getConfigAccess("org.openoffice.Setup/Configuration"), UNO_QUERY_THROW);    
++        any = aPropSet->getPropertyValue(ascii("ooLastVersionTouched"));
++        OUString aLastVersion;
++        if (!(any >>= aLastVersion))
++        {
++            // last touched version unknown.  Do the migration.
++            splitVersionString(m_aAppVerStr, m_aAppVerNum);
++            m_aConfigVerNum.mnMajor = 0;
++            m_aConfigVerNum.mnMinor = 0;
++            m_aConfigVerNum.mnMicro = 0;
++            return sal_True;
++        }
++
++        return isMigrationNeeded(aLastVersion, m_aAppVerStr, m_aConfigVerNum, m_aAppVerNum);
++    }
++    catch (const Exception&)
++    {
++    }
++    return sal_True;
+ }
+ 
+ MigrationImpl::MigrationImpl(const Reference< XMultiServiceFactory >& xFactory)
+@@ -148,6 +285,7 @@ MigrationImpl::MigrationImpl(const Reference< XMultiServiceFactory >& xFactory)
+     , m_aInfo(findInstallation())    
+     , m_vrFileList(compileFileList())
+     , m_vrServiceList(compileServiceList())
++    , m_bMigrationCompleted(false)
+ {
+ }
+ 
+@@ -158,28 +296,13 @@ MigrationImpl::~MigrationImpl()
+ 
+ sal_Bool MigrationImpl::doMigration()
+ {
+-    sal_Bool result = sal_False;
+-    try{
+-        copyFiles();
+-
+-		// execute the migration items from Setup.xcu 
+-		// and refresh the cache
+-        copyConfig();
+-		refresh();
+-
+-		// execute custom migration services from Setup.xcu
+-		// and refresh the cache
+-        runServices();            
+-        refresh();
+-		
+-
+-        result = sal_True;
+-    } catch (...)
++    try
++    {
++        transKeyConfig();
++        cleanCSVImportCharSet();
++    }
++    catch (const Exception&)
+     {
+-        OString aMsg("An unexpected exception was thrown during migration");
+-        aMsg += "\nOldVersion: " + OUStringToOString(m_aInfo.productname, RTL_TEXTENCODING_ASCII_US);
+-        aMsg += "\nDataPath  : " + OUStringToOString(m_aInfo.userdata, RTL_TEXTENCODING_ASCII_US);
+-        OSL_ENSURE(sal_False, aMsg.getStr());
+     }
+ 
+ 	// prevent running the migration multiple times
+@@ -187,42 +310,83 @@ sal_Bool MigrationImpl::doMigration()
+     return sal_False;
+ }
+ 
+-void MigrationImpl::refresh()
++void MigrationImpl::transKeyConfig()
+ {
+-    Reference< XRefreshable > xRefresh(m_xFactory->createInstance(
+-                OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), UNO_QUERY);
+-    if (xRefresh.is())
+-        xRefresh->refresh();
+-    else
+-        OSL_ENSURE(sal_False, "could not get XRefresh interface from default config provider. No refresh done.");    
+-            
++    using namespace ::com::sun::star;
++    using namespace ::com::sun::star::ui;
++
++#if 0
++    fprintf(stdout, "MigrationImpl::transKeyConfig:   config ver = %ld.%ld.%ld\n",
++            m_aConfigVerNum.mnMajor, m_aConfigVerNum.mnMinor, m_aConfigVerNum.mnMicro);
++
++    fprintf(stdout, "MigrationImpl::transKeyConfig:   app ver = %ld.%ld.%ld\n",
++            m_aAppVerNum.mnMajor, m_aAppVerNum.mnMinor, m_aAppVerNum.mnMicro);
++#endif
++
++    if (compareVersion(m_aConfigVerNum, VersionNumber(2,4,0)) < 0)
++    {
++        // For config versions older than 2.4.0 only.
++
++        Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgSupplier(
++            m_xFactory->createInstance(
++                ascii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")), UNO_QUERY_THROW);
++    
++        // Grab the Calc configuration.
++        Reference< XUIConfigurationManager > xConfigMgr = 
++            xModuleCfgSupplier->getUIConfigurationManager(
++                ascii("com.sun.star.sheet.SpreadsheetDocument"));
++    
++        if (xConfigMgr.is())
++        {
++            Reference< XAcceleratorConfiguration > xScAccel(
++                xConfigMgr->getShortCutManager(), UNO_QUERY_THROW);
++        
++            // Backsapce key
++            awt::KeyEvent aBackEv;
++            aBackEv.KeyCode = awt::Key::BACKSPACE;
++            aBackEv.Modifiers = 0;
++            xScAccel->setKeyEvent(aBackEv, ascii(".uno:Delete"));
++        
++            // Delete key
++            awt::KeyEvent aDeleteEv;
++            aDeleteEv.KeyCode = awt::Key::DELETE;
++            aDeleteEv.Modifiers = 0;
++            xScAccel->setKeyEvent(aDeleteEv, ascii(".uno:ClearContents"));
++        
++            xScAccel->store();
++        }
++    }
+ }
+ 
+-void MigrationImpl::setMigrationCompleted() 
++void MigrationImpl::cleanCSVImportCharSet()
+ {
+-	try {
+-		Reference< XPropertySet > aPropertySet(getConfigAccess("org.openoffice.Setup/Office", true), UNO_QUERY_THROW);
+-		aPropertySet->setPropertyValue(OUString::createFromAscii("MigrationCompleted"), makeAny(sal_True));
+-		Reference< XChangesBatch >(aPropertySet, UNO_QUERY_THROW)->commitChanges();
+-	} catch (...) {
+-		// fail silently
+-	}
++    // Overwrite the character set value for CSV import to -1 (unset) on every 
++    // upgrade, to prevent it from being incorrectly set to Unicode. (n#376473)
++
++    Reference< XPropertySet > aPropSet;
++    aPropSet.set(getConfigAccess("org.openoffice.Office.Calc/Dialogs/CSVImport", true), UNO_QUERY_THROW);
++    aPropSet->setPropertyValue(ascii("CharSet"), makeAny(static_cast<sal_Int32>(-1)));
++    Reference< XChangesBatch >(aPropSet, UNO_QUERY_THROW)->commitChanges();
+ }
+ 
+-sal_Bool MigrationImpl::checkMigrationCompleted() 
++void MigrationImpl::setMigrationCompleted() 
+ {
+-    sal_Bool bMigrationCompleted = sal_False;
+-    try {
+-        Reference< XPropertySet > aPropertySet(
+-            getConfigAccess("org.openoffice.Setup/Office"), UNO_QUERY_THROW);    
+-        aPropertySet->getPropertyValue(
+-            OUString::createFromAscii("MigrationCompleted")) >>= bMigrationCompleted;
+-    } catch (Exception&) {
+-        // just return false...
+-    }
+-    return bMigrationCompleted;
+-}
++	try
++    {
++        Reference< XPropertySet > aPropSet;
++        if (m_aAppVerStr.getLength() > 0)
++        {
++            aPropSet.set(getConfigAccess("org.openoffice.Setup/Configuration", true), UNO_QUERY_THROW);
++            aPropSet->setPropertyValue(ascii("ooLastVersionTouched"), makeAny(m_aAppVerStr));
++            Reference< XChangesBatch >(aPropSet, UNO_QUERY_THROW)->commitChanges();
++        }
+ 
++        m_bMigrationCompleted = true;
++	} 
++    catch (const Exception&)
++    {
++	}
++}
+ 
+ migrations_vr MigrationImpl::readMigrationSteps()
+ {
+@@ -442,82 +606,6 @@ strings_vr MigrationImpl::compileFileList()
+     return vrResult;
+ }
+ 
+-
+-void MigrationImpl::copyConfig()
+-{
+-    try {
+-        // 1. get a list of all components from hierachy browser
+-        Reference< XJob > xBrowser(m_xFactory->createInstance(
+-            OUString::createFromAscii("com.sun.star.configuration.backend.LocalHierarchyBrowser")), UNO_QUERY_THROW);
+-
+-        Sequence< NamedValue > seqArgs(2);
+-        seqArgs[0] = NamedValue(
+-            OUString::createFromAscii("LayerDataUrl"),
+-            makeAny(m_aInfo.userdata + OUString::createFromAscii("/user/registry")));
+-        seqArgs[1] = NamedValue(
+-            OUString::createFromAscii("FetchComponentNames"),
+-            makeAny(sal_True));
+-
+-        // execute the search
+-        Any aResult = xBrowser->execute(seqArgs);
+-        Sequence< OUString > seqComponents;
+-        aResult >>= seqComponents;
+-        OSL_ENSURE(seqComponents.getLength()>0, "MigrationImpl::copyConfig(): no config components available");
+-                    
+-        // 2. create an importer 
+-        Reference< XJob > xImporter(m_xFactory->createInstance(
+-            OUString::createFromAscii("com.sun.star.configuration.backend.LocalDataImporter")), UNO_QUERY_THROW);
+-
+-        // 3. for each migration step...
+-        Sequence< NamedValue > importerArgs(3);
+-        importerArgs[0] = NamedValue(
+-            OUString::createFromAscii("LayerDataUrl"),
+-            makeAny(m_aInfo.userdata + OUString::createFromAscii("/user/registry")));
+-        importerArgs[1] = NamedValue(
+-            OUString::createFromAscii("LayerFilter"),
+-            Any());        
+-        importerArgs[2] = NamedValue(
+-            OUString::createFromAscii("Component"),
+-            Any());        
+-
+-        migrations_v::const_iterator i_mig = m_vrMigrations->begin();
+-        while (i_mig != m_vrMigrations->end())
+-        {
+-            //   a. create config filter for step            
+-            Reference< XInitialization > xFilter(
+-                new CConfigFilter(&(i_mig->includeConfig), &(i_mig->excludeConfig)));
+-            importerArgs[1].Value = makeAny(xFilter);
+-
+-            //   b. run each importer with config filter
+-            for (sal_Int32 i=0; i<seqComponents.getLength(); i++)
+-            {
+-                OUString component = seqComponents[i];
+-                importerArgs[2].Value = makeAny(seqComponents[i]);                
+-                try {
+-                    aResult = xImporter->execute(importerArgs);
+-                    Exception myException;
+-                    if (aResult >>= myException) throw myException;
+-                } catch(Exception& aException) {
+-                    OString aMsg("Exception in config layer import.\ncomponent: ");
+-                    aMsg += OUStringToOString(seqComponents[i], RTL_TEXTENCODING_ASCII_US);
+-                    aMsg += "\nmessage: ";
+-                    aMsg += OUStringToOString(aException.Message, RTL_TEXTENCODING_ASCII_US);
+-                    OSL_ENSURE(sal_False, aMsg.getStr());
+-                }
+-            }
+-            i_mig++;
+-        }
+-    }
+-    catch (Exception& e)
+-    {
+-        OString aMsg("Exception in config layer import.\nmessage: ");
+-        aMsg += OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);
+-        OSL_ENSURE(sal_False, aMsg.getStr());            
+-    }    
+-
+-
+-}
+-
+ // removes elements of vector 2 in vector 1
+ void MigrationImpl::substract(strings_v& va, const strings_v& vb_c) const
+ {
+@@ -597,123 +685,6 @@ static FileBase::RC _checkAndCreateDirectory(INetURLObject& dirURL)
+         return result;
+ }       
+ 
+-void MigrationImpl::copyFiles()
+-{
+-    strings_v::const_iterator i_file = m_vrFileList->begin();
+-    OUString localName;
+-    OUString destName;
+-    OUString userInstall;
+-    utl::Bootstrap::PathStatus aStatus;
+-    aStatus = utl::Bootstrap::locateUserInstallation(userInstall);
+-    if (aStatus == utl::Bootstrap::PATH_EXISTS)
+-    {
+-        while (i_file != m_vrFileList->end())
+-        {
+-            
+-            // remove installation prefix from file
+-            localName = i_file->copy(m_aInfo.userdata.getLength());
+-            destName = userInstall + localName;
+-            INetURLObject aURL(destName);
+-            // check whether destination directory exists
+-            aURL.removeSegment();
+-            _checkAndCreateDirectory(aURL);            
+-            FileBase::RC copyResult = File::copy(*i_file, destName);
+-            if (copyResult != FileBase::E_None)
+-            {
+-                OString msg("Cannot copy ");
+-                msg += OUStringToOString(*i_file, RTL_TEXTENCODING_UTF8) + " to "
+-                    +  OUStringToOString(destName, RTL_TEXTENCODING_UTF8);
+-                OSL_ENSURE(sal_False, msg.getStr());
+-            }
+-            i_file++;
+-        }
+-    } 
+-    else
+-    {
+-        OSL_ENSURE(sal_False, "copyFiles: UserInstall does not exist");
+-    }
+-}
+-
+-void MigrationImpl::runServices()
+-{
+-    
+-    //create stratum for old user layer
+-    OUString aOldLayerURL = m_aInfo.userdata;
+-    aOldLayerURL += OUString::createFromAscii("/user/registry");
+-    OUString aStratumSvc = OUString::createFromAscii("com.sun.star.configuration.backend.LocalSingleStratum");
+-    Sequence< Any > stratumArgs(1);
+-    stratumArgs[0] = makeAny(aOldLayerURL);
+-    Reference< XSingleLayerStratum> xStartum( m_xFactory->createInstanceWithArguments(
+-        aStratumSvc, stratumArgs), UNO_QUERY);   
+-
+-    // Build argument array
+-    Sequence< Any > seqArguments(3);
+-    seqArguments[0] = makeAny(NamedValue(
+-        OUString::createFromAscii("Productname"),
+-        makeAny(m_aInfo.productname)));
+-    seqArguments[1] = makeAny(NamedValue(
+-        OUString::createFromAscii("UserData"),
+-        makeAny(m_aInfo.userdata)));
+-
+-
+-    // create an instance of every migration service
+-    // and execute the migration job
+-    Reference< XJob > xMigrationJob;
+-
+-    migrations_v::const_iterator i_mig  = m_vrMigrations->begin();    
+-    while (i_mig != m_vrMigrations->end())
+-    {
+-        if( i_mig->service.getLength() > 0)
+-        {
+-            
+-            try
+-            {
+-                // create access to old configuration components in the user layer
+-                // that were requested by the migration service
+-                Sequence< NamedValue > seqComponents(i_mig->configComponents.size());
+-                strings_v::const_iterator i_comp = i_mig->configComponents.begin();
+-                sal_Int32 i = 0;
+-                while (i_comp != i_mig->configComponents.end() && xStartum.is())
+-                {
+-                    // create Layer for i_comp
+-                    seqComponents[i] =  NamedValue(
+-                        *i_comp, makeAny(xStartum->getLayer(*i_comp, OUString())));
+-
+-                    // next component
+-                    i_comp++;
+-                    i++;
+-                }
+-                // set old config argument
+-                seqArguments[2] = makeAny(NamedValue(
+-                    OUString::createFromAscii("OldConfiguration"),
+-                    makeAny(seqComponents)));
+-
+-                xMigrationJob = Reference< XJob >(m_xFactory->createInstanceWithArguments(
+-                    i_mig->service, seqArguments), UNO_QUERY_THROW);
+-
+-                xMigrationJob->execute(Sequence< NamedValue >());
+-
+-
+-            } catch (Exception& e)
+-            {
+-                OString aMsg("Execution of migration service failed (Exception caught).\nService: ");
+-                aMsg += OUStringToOString(i_mig->service, RTL_TEXTENCODING_ASCII_US) + "\nMessage: ";
+-                aMsg += OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);
+-                OSL_ENSURE(sal_False, aMsg.getStr());
+-            } catch (...)
+-            {
+-                OString aMsg("Execution of migration service failed (Exception caught).\nService: ");
+-                aMsg += OUStringToOString(i_mig->service, RTL_TEXTENCODING_ASCII_US) + 
+-					"\nNo message available";
+-                OSL_ENSURE(sal_False, aMsg.getStr());
+-            }
+-
+-        }
+-        i_mig++;
+-    }
+-}
+-
+-
+ strings_vr MigrationImpl::compileServiceList()
+ {
+     strings_vr vrResult(new strings_v);
+diff --git a/desktop/source/migration/migration_impl.hxx b/desktop/source/migration/migration_impl.hxx
+index b31a2a9..5553d04 100644
+--- desktop/source/migration/migration_impl.hxx
++++ desktop/source/migration/migration_impl.hxx
+@@ -81,6 +81,16 @@ typedef std::auto_ptr< migrations_v > migrations_vr;
+ 
+ class MigrationImpl
+ {
++public:
++    struct VersionNumber
++    {
++        sal_Int32 mnMajor;
++        sal_Int32 mnMinor;
++        sal_Int32 mnMicro;
++
++        explicit VersionNumber();
++        explicit VersionNumber(sal_Int32 nMajor, sal_Int32 nMinor, sal_Int32 nMicro);
++    };
+ 
+ private:
+     strings_vr m_vrVersions;
+@@ -90,6 +100,10 @@ private:
+     strings_vr m_vrFileList;      // final list of files to be copied
+     strings_vr m_vrConfigList;    // final list of nodes to be copied
+     strings_vr m_vrServiceList;   // final list of services to be called
++    ::rtl::OUString m_aAppVerStr;
++    bool m_bMigrationCompleted;
++    VersionNumber m_aAppVerNum;
++    VersionNumber m_aConfigVerNum;
+ 
+     // initializer functions...
+     migrations_vr readMigrationSteps();
+@@ -104,14 +118,10 @@ private:
+     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);
+ 
+-    // actual processing function that perform the migration steps
+-    void copyFiles();
+-    void copyConfig();
+-    void runServices();
+-    void refresh();
++    void transKeyConfig();
++    void cleanCSVImportCharSet();
+ 
+     void setMigrationCompleted();
+-    sal_Bool checkMigrationCompleted();
+     
+ public:
+     MigrationImpl(const NS_UNO::Reference< NS_CSS::lang::XMultiServiceFactory >&);
+diff --git a/officecfg/registry/schema/org/openoffice/Setup.xcs b/officecfg/registry/schema/org/openoffice/Setup.xcs
+index 5c11fb4..bae1820 100644
+--- officecfg/registry/schema/org/openoffice/Setup.xcs
++++ officecfg/registry/schema/org/openoffice/Setup.xcs
+@@ -422,6 +422,14 @@
+                     <desc>Deprecated</desc>
+ 				</info>
+ 			</prop>
++            <prop oor:name="ooLastVersionTouched" oor:type="xs:string">
++                <info>
++                    <author>Kohei Yoshida</author>
++                    <desc>Specifies the version of OOo that touched the configration for the last time.  The format must 
++                    be in the form of major.minor.micro (e.g. 2.3.1).  Note that this value may not always be present if the 
++                    last touched version is very old.</desc>
++                </info>
++            </prop>
+ 		</group>
+ 		<group oor:name="Migration">
+ 			<info>

Modified: trunk/patches/dev300/desktop-config-migration.diff
==============================================================================
--- trunk/patches/dev300/desktop-config-migration.diff	(original)
+++ trunk/patches/dev300/desktop-config-migration.diff	Wed Aug  6 16:24:57 2008
@@ -3,9 +3,9 @@
 --- desktop/source/migration/migration.cxx
 +++ desktop/source/migration/migration.cxx
 @@ -58,6 +58,10 @@
- #include <com/sun/star/configuration/backend/XSingleLayerStratum.hpp>
  #include <com/sun/star/util/XRefreshable.hpp>
  #include <com/sun/star/util/XChangesBatch.hpp>
+ #include <com/sun/star/util/XStringSubstitution.hpp>
 +#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
 +#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
 +#include <com/sun/star/awt/Key.hpp>
@@ -13,15 +13,16 @@
   
  using namespace rtl;
  using namespace osl;
-@@ -71,6 +75,8 @@ using namespace com::sun::star::container;
- using namespace com::sun::star::configuration;
- using namespace com::sun::star::configuration::backend;
+@@ -71,6 +75,9 @@ using namespace com::sun::star::container;
+ using com::sun::star::uno::Exception;
+ using namespace com::sun::star;
  
 +#define ascii( asc ) \
 +    ::rtl::OUString::intern( RTL_CONSTASCII_USTRINGPARAM( asc ) )
- 
++
  namespace desktop {
  
+ 
 @@ -128,17 +134,148 @@ OUString Migration::getOldVersionName()
      return getImpl()->getOldVersionName();
  }
@@ -182,7 +183,7 @@
  {
  }
  
-@@ -158,28 +296,13 @@ MigrationImpl::~MigrationImpl()
+@@ -158,70 +296,97 @@ MigrationImpl::~MigrationImpl()
  
  sal_Bool MigrationImpl::doMigration()
  {
@@ -190,16 +191,15 @@
 -    try{
 -        copyFiles();
 -
--		// execute the migration items from Setup.xcu 
+-		// execute the migration items from Setup.xcu
 -		// and refresh the cache
 -        copyConfig();
 -		refresh();
 -
 -		// execute custom migration services from Setup.xcu
 -		// and refresh the cache
--        runServices();            
+-        runServices();
 -        refresh();
--		
 -
 -        result = sal_True;
 -    } catch (...)
@@ -217,20 +217,20 @@
      }
  
  	// prevent running the migration multiple times
-@@ -187,42 +310,83 @@ sal_Bool MigrationImpl::doMigration()
-     return sal_False;
+ 	setMigrationCompleted();
+     return result;
  }
  
 -void MigrationImpl::refresh()
 +void MigrationImpl::transKeyConfig()
  {
--    Reference< XRefreshable > xRefresh(m_xFactory->createInstance(
--                OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), UNO_QUERY);
+-	uno::Reference< XRefreshable > xRefresh(m_xFactory->createInstance(
+-                OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), uno::UNO_QUERY);
 -    if (xRefresh.is())
 -        xRefresh->refresh();
 -    else
--        OSL_ENSURE(sal_False, "could not get XRefresh interface from default config provider. No refresh done.");    
--            
+-        OSL_ENSURE(sal_False, "could not get XRefresh interface from default config provider. No refresh done.");
+-
 +    using namespace ::com::sun::star;
 +    using namespace ::com::sun::star::ui;
 +
@@ -277,13 +277,13 @@
 +    }
  }
  
--void MigrationImpl::setMigrationCompleted() 
+-void MigrationImpl::setMigrationCompleted()
 +void MigrationImpl::cleanCSVImportCharSet()
  {
 -	try {
--		Reference< XPropertySet > aPropertySet(getConfigAccess("org.openoffice.Setup/Office", true), UNO_QUERY_THROW);
--		aPropertySet->setPropertyValue(OUString::createFromAscii("MigrationCompleted"), makeAny(sal_True));
--		Reference< XChangesBatch >(aPropertySet, UNO_QUERY_THROW)->commitChanges();
+-		uno::Reference< XPropertySet > aPropertySet(getConfigAccess("org.openoffice.Setup/Office", true), uno::UNO_QUERY_THROW);
+-		aPropertySet->setPropertyValue(OUString::createFromAscii("MigrationCompleted"), uno::makeAny(sal_True));
+-		uno::Reference< XChangesBatch >(aPropertySet, uno::UNO_QUERY_THROW)->commitChanges();
 -	} catch (...) {
 -		// fail silently
 -	}
@@ -296,13 +296,13 @@
 +    Reference< XChangesBatch >(aPropSet, UNO_QUERY_THROW)->commitChanges();
  }
  
--sal_Bool MigrationImpl::checkMigrationCompleted() 
+-sal_Bool MigrationImpl::checkMigrationCompleted()
 +void MigrationImpl::setMigrationCompleted() 
  {
 -    sal_Bool bMigrationCompleted = sal_False;
 -    try {
--        Reference< XPropertySet > aPropertySet(
--            getConfigAccess("org.openoffice.Setup/Office"), UNO_QUERY_THROW);    
+-		uno::Reference< XPropertySet > aPropertySet(
+-            getConfigAccess("org.openoffice.Setup/Office"), uno::UNO_QUERY_THROW);
 -        aPropertySet->getPropertyValue(
 -            OUString::createFromAscii("MigrationCompleted")) >>= bMigrationCompleted;
 -    } catch (Exception&) {
@@ -338,52 +338,52 @@
 -{
 -    try {
 -        // 1. get a list of all components from hierachy browser
--        Reference< XJob > xBrowser(m_xFactory->createInstance(
--            OUString::createFromAscii("com.sun.star.configuration.backend.LocalHierarchyBrowser")), UNO_QUERY_THROW);
+-		uno::Reference< XJob > xBrowser(m_xFactory->createInstance(
+-            OUString::createFromAscii("com.sun.star.configuration.backend.LocalHierarchyBrowser")), uno::UNO_QUERY_THROW);
 -
--        Sequence< NamedValue > seqArgs(2);
+-		uno::Sequence< NamedValue > seqArgs(2);
 -        seqArgs[0] = NamedValue(
 -            OUString::createFromAscii("LayerDataUrl"),
--            makeAny(m_aInfo.userdata + OUString::createFromAscii("/user/registry")));
+-            uno::makeAny(m_aInfo.userdata + OUString::createFromAscii("/user/registry")));
 -        seqArgs[1] = NamedValue(
 -            OUString::createFromAscii("FetchComponentNames"),
--            makeAny(sal_True));
+-            uno::makeAny(sal_True));
 -
 -        // execute the search
--        Any aResult = xBrowser->execute(seqArgs);
--        Sequence< OUString > seqComponents;
+-        uno::Any aResult = xBrowser->execute(seqArgs);
+-        uno::Sequence< OUString > seqComponents;
 -        aResult >>= seqComponents;
 -        OSL_ENSURE(seqComponents.getLength()>0, "MigrationImpl::copyConfig(): no config components available");
--                    
--        // 2. create an importer 
--        Reference< XJob > xImporter(m_xFactory->createInstance(
--            OUString::createFromAscii("com.sun.star.configuration.backend.LocalDataImporter")), UNO_QUERY_THROW);
+-
+-        // 2. create an importer
+-		uno::Reference< XJob > xImporter(m_xFactory->createInstance(
+-            OUString::createFromAscii("com.sun.star.configuration.backend.LocalDataImporter")), uno::UNO_QUERY_THROW);
 -
 -        // 3. for each migration step...
--        Sequence< NamedValue > importerArgs(3);
+-        uno::Sequence< NamedValue > importerArgs(3);
 -        importerArgs[0] = NamedValue(
 -            OUString::createFromAscii("LayerDataUrl"),
--            makeAny(m_aInfo.userdata + OUString::createFromAscii("/user/registry")));
+-            uno::makeAny(m_aInfo.userdata + OUString::createFromAscii("/user/registry")));
 -        importerArgs[1] = NamedValue(
 -            OUString::createFromAscii("LayerFilter"),
--            Any());        
+-            uno::Any());
 -        importerArgs[2] = NamedValue(
 -            OUString::createFromAscii("Component"),
--            Any());        
+-            uno::Any());
 -
 -        migrations_v::const_iterator i_mig = m_vrMigrations->begin();
 -        while (i_mig != m_vrMigrations->end())
 -        {
--            //   a. create config filter for step            
--            Reference< XInitialization > xFilter(
+-            //   a. create config filter for step
+-			uno::Reference< XInitialization > xFilter(
 -                new CConfigFilter(&(i_mig->includeConfig), &(i_mig->excludeConfig)));
--            importerArgs[1].Value = makeAny(xFilter);
+-            importerArgs[1].Value = uno::makeAny(xFilter);
 -
 -            //   b. run each importer with config filter
 -            for (sal_Int32 i=0; i<seqComponents.getLength(); i++)
 -            {
 -                OUString component = seqComponents[i];
--                importerArgs[2].Value = makeAny(seqComponents[i]);                
+-                importerArgs[2].Value = uno::makeAny(seqComponents[i]);
 -                try {
 -                    aResult = xImporter->execute(importerArgs);
 -                    Exception myException;
@@ -403,8 +403,8 @@
 -    {
 -        OString aMsg("Exception in config layer import.\nmessage: ");
 -        aMsg += OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);
--        OSL_ENSURE(sal_False, aMsg.getStr());            
--    }    
+-        OSL_ENSURE(sal_False, aMsg.getStr());
+-    }
 -
 -
 -}
@@ -413,8 +413,8 @@
  void MigrationImpl::substract(strings_v& va, const strings_v& vb_c) const
  {
 @@ -597,123 +685,6 @@ static FileBase::RC _checkAndCreateDirectory(INetURLObject& dirURL)
-         return result;
- }       
+     return xNameAccess;
+ }
  
 -void MigrationImpl::copyFiles()
 -{
@@ -428,14 +428,14 @@
 -    {
 -        while (i_file != m_vrFileList->end())
 -        {
--            
+-
 -            // remove installation prefix from file
 -            localName = i_file->copy(m_aInfo.userdata.getLength());
 -            destName = userInstall + localName;
 -            INetURLObject aURL(destName);
 -            // check whether destination directory exists
 -            aURL.removeSegment();
--            _checkAndCreateDirectory(aURL);            
+-            _checkAndCreateDirectory(aURL);
 -            FileBase::RC copyResult = File::copy(*i_file, destName);
 -            if (copyResult != FileBase::E_None)
 -            {
@@ -455,62 +455,62 @@
 -
 -void MigrationImpl::runServices()
 -{
--    
+-
 -    //create stratum for old user layer
 -    OUString aOldLayerURL = m_aInfo.userdata;
 -    aOldLayerURL += OUString::createFromAscii("/user/registry");
 -    OUString aStratumSvc = OUString::createFromAscii("com.sun.star.configuration.backend.LocalSingleStratum");
--    Sequence< Any > stratumArgs(1);
--    stratumArgs[0] = makeAny(aOldLayerURL);
--    Reference< XSingleLayerStratum> xStartum( m_xFactory->createInstanceWithArguments(
--        aStratumSvc, stratumArgs), UNO_QUERY);   
+-    uno::Sequence< uno::Any > stratumArgs(1);
+-    stratumArgs[0] = uno::makeAny(aOldLayerURL);
+-	uno::Reference< XSingleLayerStratum> xStartum( m_xFactory->createInstanceWithArguments(
+-        aStratumSvc, stratumArgs), uno::UNO_QUERY);
 -
 -    // Build argument array
--    Sequence< Any > seqArguments(3);
--    seqArguments[0] = makeAny(NamedValue(
+-    uno::Sequence< uno::Any > seqArguments(3);
+-    seqArguments[0] = uno::makeAny(NamedValue(
 -        OUString::createFromAscii("Productname"),
--        makeAny(m_aInfo.productname)));
--    seqArguments[1] = makeAny(NamedValue(
+-        uno::makeAny(m_aInfo.productname)));
+-    seqArguments[1] = uno::makeAny(NamedValue(
 -        OUString::createFromAscii("UserData"),
--        makeAny(m_aInfo.userdata)));
+-        uno::makeAny(m_aInfo.userdata)));
 -
 -
 -    // create an instance of every migration service
 -    // and execute the migration job
--    Reference< XJob > xMigrationJob;
+-	uno::Reference< XJob > xMigrationJob;
 -
--    migrations_v::const_iterator i_mig  = m_vrMigrations->begin();    
+-    migrations_v::const_iterator i_mig  = m_vrMigrations->begin();
 -    while (i_mig != m_vrMigrations->end())
 -    {
 -        if( i_mig->service.getLength() > 0)
 -        {
--            
+-
 -            try
 -            {
 -                // create access to old configuration components in the user layer
 -                // that were requested by the migration service
--                Sequence< NamedValue > seqComponents(i_mig->configComponents.size());
+-                uno::Sequence< NamedValue > seqComponents(i_mig->configComponents.size());
 -                strings_v::const_iterator i_comp = i_mig->configComponents.begin();
 -                sal_Int32 i = 0;
 -                while (i_comp != i_mig->configComponents.end() && xStartum.is())
 -                {
 -                    // create Layer for i_comp
 -                    seqComponents[i] =  NamedValue(
--                        *i_comp, makeAny(xStartum->getLayer(*i_comp, OUString())));
+-                        *i_comp, uno::makeAny(xStartum->getLayer(*i_comp, OUString())));
 -
 -                    // next component
 -                    i_comp++;
 -                    i++;
 -                }
 -                // set old config argument
--                seqArguments[2] = makeAny(NamedValue(
+-                seqArguments[2] = uno::makeAny(NamedValue(
 -                    OUString::createFromAscii("OldConfiguration"),
--                    makeAny(seqComponents)));
+-                    uno::makeAny(seqComponents)));
 -
--                xMigrationJob = Reference< XJob >(m_xFactory->createInstanceWithArguments(
--                    i_mig->service, seqArguments), UNO_QUERY_THROW);
+-				xMigrationJob = uno::Reference< XJob >(m_xFactory->createInstanceWithArguments(
+-                    i_mig->service, seqArguments), uno::UNO_QUERY_THROW);
 -
--                xMigrationJob->execute(Sequence< NamedValue >());
+-                xMigrationJob->execute(uno::Sequence< NamedValue >());
 -
 -
 -            } catch (Exception& e)
@@ -522,7 +522,7 @@
 -            } catch (...)
 -            {
 -                OString aMsg("Execution of migration service failed (Exception caught).\nService: ");
--                aMsg += OUStringToOString(i_mig->service, RTL_TEXTENCODING_ASCII_US) + 
+-                aMsg += OUStringToOString(i_mig->service, RTL_TEXTENCODING_ASCII_US) +
 -					"\nNo message available";
 -                OSL_ENSURE(sal_False, aMsg.getStr());
 -            }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]