diff options
author | Daniel Rentz <dr@openoffice.org> | 2010-06-17 11:32:18 +0200 |
---|---|---|
committer | Daniel Rentz <dr@openoffice.org> | 2010-06-17 11:32:18 +0200 |
commit | 0fb004299f88eff2e6077b8aabac07dde3ec3f02 (patch) | |
tree | 610bce7fab84cba84744c0bc74aed70b21a72853 /desktop | |
parent | 00cb4072a3052e4dca32a39fb692f34a1d7e4d35 (diff) | |
parent | 79fa123bd79e794dfa9bf57e1df28ff46b16671d (diff) |
mib16: rebase to m82
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/prj/build.lst | 2 | ||||
-rw-r--r-- | desktop/source/app/makefile.mk | 1 | ||||
-rw-r--r-- | desktop/source/deployment/gui/dp_gui_dialog2.cxx | 2 | ||||
-rw-r--r-- | desktop/source/deployment/gui/makefile.mk | 1 | ||||
-rw-r--r-- | desktop/source/deployment/makefile.mk | 3 | ||||
-rw-r--r-- | desktop/source/deployment/misc/dp_dependencies.cxx | 16 | ||||
-rw-r--r-- | desktop/source/deployment/misc/dp_platform.cxx | 6 | ||||
-rw-r--r-- | desktop/source/deployment/registry/configuration/dp_configuration.cxx | 12 | ||||
-rw-r--r-- | desktop/source/migration/migration.cxx | 613 | ||||
-rw-r--r-- | desktop/source/migration/migration_impl.hxx | 122 | ||||
-rw-r--r-- | desktop/source/splash/makefile.mk | 1 | ||||
-rw-r--r-- | desktop/test/deployment/boxt/Addons.xcu | 50 | ||||
-rw-r--r-- | desktop/test/deployment/boxt/ProtocolHandler.xcu | 38 | ||||
-rw-r--r-- | desktop/test/deployment/boxt/boxt.cxx | 235 | ||||
-rw-r--r-- | desktop/test/deployment/boxt/description.xml | 39 | ||||
-rw-r--r-- | desktop/test/deployment/boxt/makefile.mk | 70 | ||||
-rw-r--r-- | desktop/test/deployment/boxt/manifest.xml | 37 | ||||
-rw-r--r-- | desktop/util/makefile.mk | 71 |
18 files changed, 1225 insertions, 94 deletions
diff --git a/desktop/prj/build.lst b/desktop/prj/build.lst index 9253b4e82bc7..6f611926a0df 100644 --- a/desktop/prj/build.lst +++ b/desktop/prj/build.lst @@ -1,4 +1,4 @@ -dt desktop : l10n sfx2 stoc BERKELEYDB:berkeleydb sysui SO:sysui_so BOOST:boost svx xmlhelp sal unoil officecfg configmgr NULL +dt desktop : l10n sfx2 stoc BERKELEYDB:berkeleydb sysui SO:sysui_so BOOST:boost svx xmlhelp sal unoil officecfg offuh NULL dt desktop usr1 - all dt_mkout NULL dt desktop\inc nmake - all dt_inc NULL dt desktop\prj get - all dt_prj NULL diff --git a/desktop/source/app/makefile.mk b/desktop/source/app/makefile.mk index 83bec9011283..d9db7c163481 100644 --- a/desktop/source/app/makefile.mk +++ b/desktop/source/app/makefile.mk @@ -65,7 +65,6 @@ SHL1LIBS = $(SLB)$/mig.lib SHL1STDLIBS = \ $(COMPHELPERLIB) \ - $(CONFIGMGRLIB) \ $(CPPUHELPERLIB) \ $(CPPULIB) \ $(I18NISOLANGLIB) \ diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 2d0733dfbae3..21ec1ce46ff5 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -30,7 +30,7 @@ #include "dp_gui.hrc" #include "svtools/controldims.hrc" -#include "svl/svtools.hrc" +#include "svtools/svtools.hrc" #include "dp_gui.h" #include "dp_gui_dialog2.hxx" diff --git a/desktop/source/deployment/gui/makefile.mk b/desktop/source/deployment/gui/makefile.mk index 6a9c7b6bbb38..52092a077a4b 100644 --- a/desktop/source/deployment/gui/makefile.mk +++ b/desktop/source/deployment/gui/makefile.mk @@ -77,6 +77,7 @@ SHL1STDLIBS = \ $(SVTOOLLIB) \ $(SVLLIB) \ $(SVXLIB) \ + $(SVXCORELIB) \ $(SFXLIB) \ $(DEPLOYMENTMISCLIB) \ $(OLE32LIB) diff --git a/desktop/source/deployment/makefile.mk b/desktop/source/deployment/makefile.mk index 7eda0f582e15..173ff35bec1d 100644 --- a/desktop/source/deployment/makefile.mk +++ b/desktop/source/deployment/makefile.mk @@ -80,8 +80,7 @@ SHL1STDLIBS = \ $(SVLLIB) \ $(UNOTOOLSLIB) \ $(DEPLOYMENTMISCLIB) \ - $(HELPLINKERLIB) \ - $(CONFIGMGRLIB) + $(HELPLINKERLIB) SHL1DEPN = SHL1IMPLIB = i$(TARGET) diff --git a/desktop/source/deployment/misc/dp_dependencies.cxx b/desktop/source/deployment/misc/dp_dependencies.cxx index 63badbb0c211..9534f166f2f0 100644 --- a/desktop/source/deployment/misc/dp_dependencies.cxx +++ b/desktop/source/deployment/misc/dp_dependencies.cxx @@ -56,17 +56,13 @@ namespace css = ::com::sun::star; static char const xmlNamespace[] = "http://openoffice.org/extensions/description/2006"; -::dp_misc::Order compareWithVersion(::rtl::OUString const & version) { +bool satisfiesMinimalVersion(::rtl::OUString const & version) { ::rtl::OUString v( RTL_CONSTASCII_USTRINGPARAM( "${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("version") ":Version:OOOPackageVersion}")); ::rtl::Bootstrap::expandMacros(v); - return ::dp_misc::compareVersions(v, version); -} - -bool satisfiesMinimalVersion(::rtl::OUString const & version) { - return compareWithVersion(version) != ::dp_misc::LESS; + return ::dp_misc::compareVersions(v, version) != ::dp_misc::LESS; } } @@ -102,8 +98,14 @@ check(::dp_misc::DescriptionInfoset const & infoset) { RTL_CONSTASCII_STRINGPARAM( "OpenOffice.org-maximal-version"))) { + ::rtl::OUString v( + RTL_CONSTASCII_USTRINGPARAM( + "${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("version") + ":Version:OOOBaseVersion}")); + ::rtl::Bootstrap::expandMacros(v); sat = - compareWithVersion( + ::dp_misc::compareVersions( + v, e->getAttribute( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("value")))) != ::dp_misc::GREATER; diff --git a/desktop/source/deployment/misc/dp_platform.cxx b/desktop/source/deployment/misc/dp_platform.cxx index 4a144f3fdf20..ac28b6816708 100644 --- a/desktop/source/deployment/misc/dp_platform.cxx +++ b/desktop/source/deployment/misc/dp_platform.cxx @@ -39,6 +39,8 @@ #define PLATFORM_WIN_X86 "windows_x86" #define PLATFORM_LINUX_X86 "linux_x86" #define PLATFORM_LINUX_X86_64 "linux_x86_64" +#define PLATFORM_KFREEBSD_X86 "kfreebsd_x86" +#define PLATFORM_KFREEBSD_X86_64 "kfreebsd_x86_64" #define PLATFORM_LINUX_SPARC "linux_sparc" #define PLATFORM_LINUX_POWERPC "linux_powerpc" #define PLATFORM_LINUX_POWERPC64 "linux_powerpc64" @@ -129,6 +131,10 @@ namespace ret = checkOSandCPU(OUSTR("Linux"), OUSTR("x86")); else if (token.equals(OUSTR(PLATFORM_LINUX_X86_64))) ret = checkOSandCPU(OUSTR("Linux"), OUSTR("X86_64")); + else if (token.equals(OUSTR(PLATFORM_KFREEBSD_X86))) + ret = checkOSandCPU(OUSTR("kFreeBSD"), OUSTR("x86")); + else if (token.equals(OUSTR(PLATFORM_KFREEBSD_X86_64))) + ret = checkOSandCPU(OUSTR("kFreeBSD"), OUSTR("X86_64")); else if (token.equals(OUSTR(PLATFORM_LINUX_SPARC))) ret = checkOSandCPU(OUSTR("Linux"), OUSTR("SPARC")); else if (token.equals(OUSTR(PLATFORM_LINUX_POWERPC))) diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index 460ba5e9fed0..6cf6d4ff7818 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -45,9 +45,9 @@ #include "ucbhelper/content.hxx" #include "comphelper/anytostring.hxx" #include "comphelper/servicedecl.hxx" -#include "configmgr/update.hxx" #include "xmlscript/xml_helper.hxx" #include "svl/inettype.hxx" +#include "com/sun/star/configuration/Update.hpp" #include "com/sun/star/ucb/NameClash.hpp" #include "com/sun/star/io/XActiveDataSink.hpp" #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" @@ -645,14 +645,16 @@ void BackendImpl::PackageImpl::processPackage_( { if (m_isSchema) { - configmgr::update::insertExtensionXcsFile( - that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); + com::sun::star::configuration::Update::get( + that->m_xComponentContext)->insertExtensionXcsFile( + that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); } else { url = replaceOrigin(url, xCmdEnv); - configmgr::update::insertExtensionXcuFile( - that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); + com::sun::star::configuration::Update::get( + that->m_xComponentContext)->insertExtensionXcuFile( + that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); } that->addToConfigmgrIni( m_isSchema, url, xCmdEnv ); diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx index cefc3cebf0fd..314537836921 100644 --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -29,6 +29,7 @@ #include "precompiled_desktop.hxx" #include <map> +#include <new> #include <set> #include "migration.hxx" @@ -38,7 +39,6 @@ #include <unotools/textsearch.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/sequence.hxx> -#include <configmgr/update.hxx> #include <unotools/bootstrap.hxx> #include <rtl/bootstrap.hxx> #include <rtl/uri.hxx> @@ -51,6 +51,7 @@ #include <osl/security.hxx> #include <unotools/configmgr.hxx> +#include <com/sun/star/configuration/Update.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/task/XJob.hpp> #include <com/sun/star/beans/NamedValue.hpp> @@ -58,6 +59,11 @@ #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/embed/ElementModes.hpp> +#include <com/sun/star/embed/XStorage.hpp> +#include <com/sun/star/ui/XUIConfiguration.hpp> +#include <com/sun/star/ui/XUIConfigurationStorage.hpp> +#include <com/sun/star/ui/XUIConfigurationPersistence.hpp> using namespace rtl; using namespace osl; @@ -72,6 +78,120 @@ using namespace com::sun::star; namespace desktop { +static const ::rtl::OUString ITEM_DESCRIPTOR_COMMANDURL = ::rtl::OUString::createFromAscii("CommandURL"); +static const ::rtl::OUString ITEM_DESCRIPTOR_CONTAINER = ::rtl::OUString::createFromAscii("ItemDescriptorContainer"); +static const ::rtl::OUString ITEM_DESCRIPTOR_LABEL = ::rtl::OUString::createFromAscii("Label"); + +static const ::rtl::OUString MENU_SEPERATOR = ::rtl::OUString::createFromAscii(" | "); +static const ::rtl::OUString MENU_SUBMENU = ::rtl::OUString::createFromAscii("..."); + +::rtl::OUString retrieveLabelFromCommand(const ::rtl::OUString& sCommand, const ::rtl::OUString& sModuleIdentifier) +{ + ::rtl::OUString sLabel; + + uno::Reference< container::XNameAccess > xUICommands; + uno::Reference< container::XNameAccess > xNameAccess( ::comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.UICommandDescription") ), uno::UNO_QUERY ); + if ( xNameAccess.is() ) + { + uno::Any a = xNameAccess->getByName( sModuleIdentifier ); + a >>= xUICommands; + } + if (xUICommands.is()) + { + if ( sCommand.getLength() > 0 ) + { + rtl::OUString aStr; + ::uno::Sequence< beans::PropertyValue > aPropSeq; + try + { + uno::Any a( xUICommands->getByName( sCommand )); + if ( a >>= aPropSeq ) + { + for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) + { + if ( aPropSeq[i].Name.equalsAscii( "Label" )) + { + aPropSeq[i].Value >>= aStr; + break; + } + } + } + + sLabel = aStr; + } + + catch(container::NoSuchElementException&) + { + sLabel = sCommand; + sal_Int32 nIndex = sLabel.indexOf(':'); + if (nIndex>=0 && nIndex <= sLabel.getLength()-1) + sLabel = sLabel.copy(nIndex+1); + } + + } + } + + return sLabel; +} + +::rtl::OUString stripHotKey( const ::rtl::OUString& str ) +{ + sal_Int32 index = str.indexOf( '~' ); + if ( index == -1 ) + { + return str; + } + else + { + return str.replaceAt( index, 1, ::rtl::OUString() ); + } +} + +::rtl::OUString mapModuleShortNameToIdentifier(const ::rtl::OUString& sShortName) +{ + ::rtl::OUString sIdentifier; + + if (sShortName.equals(::rtl::OUString::createFromAscii("StartModule"))) + sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.frame.StartModule"); + + else if (sShortName.equals(::rtl::OUString::createFromAscii("swriter"))) + sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.text.TextDocument"); + + else if (sShortName.equals(::rtl::OUString::createFromAscii("scalc"))) + sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.sheet.SpreadsheetDocument"); + + else if (sShortName.equals(::rtl::OUString::createFromAscii("sdraw"))) + sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.drawing.DrawingDocument"); + + else if (sShortName.equals(::rtl::OUString::createFromAscii("simpress"))) + sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.presentation.PresentationDocument"); + + else if (sShortName.equals(::rtl::OUString::createFromAscii("smath"))) + sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.formula.FormulaProperties"); + + else if (sShortName.equals(::rtl::OUString::createFromAscii("schart"))) + sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.chart2.ChartDocument"); + + else if (sShortName.equals(::rtl::OUString::createFromAscii("BasicIDE"))) + sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.script.BasicIDE"); + + else if (sShortName.equals(::rtl::OUString::createFromAscii("dbapp"))) + sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.sdb.OfficeDatabaseDocument"); + + else if (sShortName.equals(::rtl::OUString::createFromAscii("sglobal"))) + sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.text.GlobalDocument"); + + else if (sShortName.equals(::rtl::OUString::createFromAscii("sweb"))) + sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.text.WebDocument"); + + else if (sShortName.equals(::rtl::OUString::createFromAscii("swxform"))) + sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.xforms.XMLFormDocument"); + + else if (sShortName.equals(::rtl::OUString::createFromAscii("sbibliography"))) + sIdentifier = ::rtl::OUString::createFromAscii("com.sun.star.frame.Bibliography"); + + return sIdentifier; +} static MigrationImpl *pImpl = 0; static Mutex aMutex; @@ -159,9 +279,72 @@ sal_Bool MigrationImpl::doMigration() m_vrFileList = compileFileList(); sal_Bool result = sal_False; - try{ + try + { + NewVersionUIInfo aNewVersionUIInfo; + ::std::vector< MigrationModuleInfo > vModulesInfo = dectectUIChangesForAllModules(); + aNewVersionUIInfo.init(vModulesInfo); + copyFiles(); + const ::rtl::OUString sMenubarResourceURL = ::rtl::OUString::createFromAscii("private:resource/menubar/menubar"); + const ::rtl::OUString sToolbarResourcePre = ::rtl::OUString::createFromAscii("private:resource/toolbar/"); + for (sal_uInt32 i=0; i<vModulesInfo.size(); ++i) + { + ::rtl::OUString sModuleIdentifier = mapModuleShortNameToIdentifier(vModulesInfo[i].sModuleShortName); + if (sModuleIdentifier.getLength()==0) + continue; + + uno::Sequence< uno::Any > lArgs(2); + ::rtl::OUString aOldCfgDataPath = m_aInfo.userdata + ::rtl::OUString::createFromAscii("/user/config/soffice.cfg/modules/"); + lArgs[0] <<= aOldCfgDataPath + vModulesInfo[i].sModuleShortName; + lArgs[1] <<= embed::ElementModes::READ; + + uno::Reference< lang::XSingleServiceFactory > xStorageFactory(m_xFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.embed.FileSystemStorageFactory")), uno::UNO_QUERY); + uno::Reference< embed::XStorage > xModules; + + xModules = uno::Reference< embed::XStorage >(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY); + uno::Reference< ui::XUIConfigurationManager > xOldCfgManager( m_xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.ui.UIConfigurationManager")), uno::UNO_QUERY ); + uno::Reference< ui::XUIConfigurationStorage > xOldCfgStorage( xOldCfgManager, uno::UNO_QUERY ); + uno::Reference< ui::XUIConfigurationPersistence > xOldCfgPersistence( xOldCfgManager, uno::UNO_QUERY ); + + if ( xOldCfgStorage.is() && xOldCfgPersistence.is() && xModules.is() ) + { + xOldCfgStorage->setStorage( xModules ); + xOldCfgPersistence->reload(); + } + + uno::Reference< ui::XUIConfigurationManager > xCfgManager = aNewVersionUIInfo.getConfigManager(vModulesInfo[i].sModuleShortName); + + if (vModulesInfo[i].bHasMenubar) + { + uno::Reference< container::XIndexContainer > xOldVersionMenuSettings = uno::Reference< container::XIndexContainer >(xOldCfgManager->getSettings(sMenubarResourceURL, sal_True), uno::UNO_QUERY); + uno::Reference< container::XIndexContainer > xNewVersionMenuSettings = aNewVersionUIInfo.getNewMenubarSettings(vModulesInfo[i].sModuleShortName); + ::rtl::OUString sParent; + compareOldAndNewConfig(sParent, xOldVersionMenuSettings, xNewVersionMenuSettings, sMenubarResourceURL); + mergeOldToNewVersion(xCfgManager, xNewVersionMenuSettings, sModuleIdentifier, sMenubarResourceURL); + } + + sal_Int32 nToolbars = vModulesInfo[i].m_vToolbars.size(); + if (nToolbars >0) + { + for (sal_Int32 j=0; j<nToolbars; ++j) + { + ::rtl::OUString sToolbarName = vModulesInfo[i].m_vToolbars[j]; + ::rtl::OUString sToolbarResourceURL = sToolbarResourcePre + sToolbarName; + + uno::Reference< container::XIndexContainer > xOldVersionToolbarSettings = uno::Reference< container::XIndexContainer >(xOldCfgManager->getSettings(sToolbarResourceURL, sal_True), uno::UNO_QUERY); + uno::Reference< container::XIndexContainer > xNewVersionToolbarSettings = aNewVersionUIInfo.getNewToolbarSettings(vModulesInfo[i].sModuleShortName, sToolbarName); + ::rtl::OUString sParent; + compareOldAndNewConfig(sParent, xOldVersionToolbarSettings, xNewVersionToolbarSettings, sToolbarResourceURL); + mergeOldToNewVersion(xCfgManager, xNewVersionToolbarSettings, sModuleIdentifier, sToolbarResourceURL); + } + } + + m_aOldVersionItemsHashMap.clear(); + m_aNewVersionItemsHashMap.clear(); + } + // execute the migration items from Setup.xcu copyConfig(); @@ -290,10 +473,14 @@ migrations_vr MigrationImpl::readMigrationSteps(const ::rtl::OUString& rMigratio tmpStep.name = seqMigrations[i]; // read included files from current step description + ::rtl::OUString aSeqEntry; if (tmpAccess->getByName(OUString::createFromAscii("IncludedFiles")) >>= tmpSeq) { for (sal_Int32 j=0; j<tmpSeq.getLength(); j++) - tmpStep.includeFiles.push_back(tmpSeq[j]); + { + aSeqEntry = tmpSeq[j]; + tmpStep.includeFiles.push_back(aSeqEntry); + } } // exluded files... @@ -328,7 +515,10 @@ migrations_vr MigrationImpl::readMigrationSteps(const ::rtl::OUString& rMigratio if (tmpAccess->getByName(OUString::createFromAscii("ExcludedExtensions")) >>= tmpSeq) { for (sal_Int32 j=0; j<tmpSeq.getLength(); j++) - tmpStep.excludeExtensions.push_back(tmpSeq[j]); + { + aSeqEntry = tmpSeq[j]; + tmpStep.excludeExtensions.push_back(aSeqEntry); + } } // generic service @@ -540,6 +730,21 @@ bool getComponent(rtl::OUString const & path, rtl::OUString * component) { return true; } +uno::Sequence< rtl::OUString > setToSeq(std::set< rtl::OUString > const & set) { + std::set< rtl::OUString >::size_type n = set.size(); + if (n > SAL_MAX_INT32) { + throw std::bad_alloc(); + } + uno::Sequence< rtl::OUString > seq(static_cast< sal_Int32 >(n)); + sal_Int32 i = 0; + for (std::set< rtl::OUString >::const_iterator j(set.begin()); + j != set.end(); ++j) + { + seq[i++] = *j; + } + return seq; +} + } void MigrationImpl::copyConfig() { @@ -587,9 +792,11 @@ void MigrationImpl::copyConfig() { buf.append(enc); } while (n >= 0); buf.appendAscii(RTL_CONSTASCII_STRINGPARAM(".xcu")); - configmgr::update::insertModificationXcuFile( - buf.makeStringAndClear(), i->second.includedPaths, - i->second.excludedPaths); + configuration::Update::get( + comphelper::getProcessComponentContext())-> + insertModificationXcuFile( + buf.makeStringAndClear(), setToSeq(i->second.includedPaths), + setToSeq(i->second.excludedPaths)); } else { OSL_TRACE( ("configuration migration component %s ignored (only excludes," @@ -763,4 +970,396 @@ void MigrationImpl::runServices() } } +::std::vector< MigrationModuleInfo > MigrationImpl::dectectUIChangesForAllModules() const +{ + ::std::vector< MigrationModuleInfo > vModulesInfo; + const ::rtl::OUString MENUBAR = ::rtl::OUString::createFromAscii("menubar"); + const ::rtl::OUString TOOLBAR = ::rtl::OUString::createFromAscii("toolbar"); + + uno::Sequence< uno::Any > lArgs(2); + lArgs[0] <<= m_aInfo.userdata + ::rtl::OUString::createFromAscii("/user/config/soffice.cfg/modules"); + lArgs[1] <<= embed::ElementModes::READ; + + uno::Reference< lang::XSingleServiceFactory > xStorageFactory(m_xFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.embed.FileSystemStorageFactory")), uno::UNO_QUERY); + uno::Reference< embed::XStorage > xModules; + + xModules = uno::Reference< embed::XStorage >(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY); + if (!xModules.is()) + return vModulesInfo; + + uno::Reference< container::XNameAccess > xAccess = uno::Reference< container::XNameAccess >(xModules, uno::UNO_QUERY); + uno::Sequence< ::rtl::OUString > lNames = xAccess->getElementNames(); + sal_Int32 nLength = lNames.getLength(); + for (sal_Int32 i=0; i<nLength; ++i) + { + ::rtl::OUString sModuleShortName = lNames[i]; + uno::Reference< embed::XStorage > xModule = xModules->openStorageElement(sModuleShortName, embed::ElementModes::READ); + if (xModule.is()) + { + MigrationModuleInfo aModuleInfo; + + uno::Reference< embed::XStorage > xMenubar = xModule->openStorageElement(MENUBAR, embed::ElementModes::READ); + if (xMenubar.is()) + { + uno::Reference< container::XNameAccess > xNameAccess = uno::Reference< container::XNameAccess >(xMenubar, uno::UNO_QUERY); + if (xNameAccess->getElementNames().getLength() > 0) + { + aModuleInfo.sModuleShortName = sModuleShortName; + aModuleInfo.bHasMenubar = sal_True; + } + } + + uno::Reference< embed::XStorage > xToolbar = xModule->openStorageElement(TOOLBAR, embed::ElementModes::READ); + if (xToolbar.is()) + { + const ::rtl::OUString RESOURCEURL_CUSTOM_ELEMENT = ::rtl::OUString::createFromAscii("custom_"); + sal_Int32 nCustomLen = 7; + + uno::Reference< container::XNameAccess > xNameAccess = uno::Reference< container::XNameAccess >(xToolbar, uno::UNO_QUERY); + ::uno::Sequence< ::rtl::OUString > lToolbars = xNameAccess->getElementNames(); + for (sal_Int32 j=0; j<lToolbars.getLength(); ++j) + { + ::rtl::OUString sToolbarName = lToolbars[j]; + if (sToolbarName.getLength()>=nCustomLen && + sToolbarName.copy(0, nCustomLen).equals(RESOURCEURL_CUSTOM_ELEMENT)) + continue; + + aModuleInfo.sModuleShortName = sModuleShortName; + sal_Int32 nIndex = sToolbarName.lastIndexOf('.'); + if (nIndex > 0) + { + ::rtl::OUString sExtension(sToolbarName.copy(nIndex)); + ::rtl::OUString sToolbarResourceName(sToolbarName.copy(0, nIndex)); + if (sToolbarResourceName.getLength()>0 && sExtension.equalsAsciiL(".xml", 4)) + aModuleInfo.m_vToolbars.push_back(sToolbarResourceName); + } + } + } + + if (aModuleInfo.sModuleShortName.getLength()>0) + vModulesInfo.push_back(aModuleInfo); + } + } + + return vModulesInfo; +} + +void MigrationImpl::compareOldAndNewConfig(const ::rtl::OUString& sParent, + const uno::Reference< container::XIndexContainer >& xIndexOld, + const uno::Reference< container::XIndexContainer >& xIndexNew, + const ::rtl::OUString& sResourceURL) +{ + ::std::vector< MigrationItem > vOldItems; + ::std::vector< MigrationItem > vNewItems; + uno::Sequence< beans::PropertyValue > aProp; + sal_Int32 nOldCount = xIndexOld->getCount(); + sal_Int32 nNewCount = xIndexNew->getCount(); + + for (int n=0; n<nOldCount; ++n) + { + MigrationItem aMigrationItem; + if (xIndexOld->getByIndex(n) >>= aProp) + { + for(int i=0; i<aProp.getLength(); ++i) + { + if (aProp[i].Name.equals(ITEM_DESCRIPTOR_COMMANDURL)) + aProp[i].Value >>= aMigrationItem.m_sCommandURL; + else if (aProp[i].Name.equals(ITEM_DESCRIPTOR_CONTAINER)) + aProp[i].Value >>= aMigrationItem.m_xPopupMenu; + } + + if (aMigrationItem.m_sCommandURL.getLength()) + vOldItems.push_back(aMigrationItem); + } + } + + for (int n=0; n<nNewCount; ++n) + { + MigrationItem aMigrationItem; + if (xIndexNew->getByIndex(n) >>= aProp) + { + for(int i=0; i<aProp.getLength(); ++i) + { + if (aProp[i].Name.equals(ITEM_DESCRIPTOR_COMMANDURL)) + aProp[i].Value >>= aMigrationItem.m_sCommandURL; + else if (aProp[i].Name.equals(ITEM_DESCRIPTOR_CONTAINER)) + aProp[i].Value >>= aMigrationItem.m_xPopupMenu; + } + + if (aMigrationItem.m_sCommandURL.getLength()) + vNewItems.push_back(aMigrationItem); + } + } + + ::std::vector< MigrationItem >::iterator it; + + ::rtl::OUString sSibling; + for (it = vOldItems.begin(); it!=vOldItems.end(); ++it) + { + ::std::vector< MigrationItem >::iterator pFound = ::std::find(vNewItems.begin(), vNewItems.end(), *it); + if (pFound != vNewItems.end() && it->m_xPopupMenu.is()) + { + ::rtl::OUString sName; + if (sParent.getLength()>0) + sName = sParent + MENU_SEPERATOR + it->m_sCommandURL; + else + sName = it->m_sCommandURL; + compareOldAndNewConfig(sName, it->m_xPopupMenu, pFound->m_xPopupMenu, sResourceURL); + } + else if (pFound == vNewItems.end()) + { + MigrationItem aMigrationItem(sParent, sSibling, it->m_sCommandURL, it->m_xPopupMenu); + if (m_aOldVersionItemsHashMap.find(sResourceURL)==m_aOldVersionItemsHashMap.end()) + { + ::std::vector< MigrationItem > vMigrationItems; + m_aOldVersionItemsHashMap.insert(MigrationHashMap::value_type(sResourceURL, vMigrationItems)); + m_aOldVersionItemsHashMap[sResourceURL].push_back(aMigrationItem); + } + else + { + if (::std::find(m_aOldVersionItemsHashMap[sResourceURL].begin(), m_aOldVersionItemsHashMap[sResourceURL].end(), aMigrationItem)==m_aOldVersionItemsHashMap[sResourceURL].end()) + m_aOldVersionItemsHashMap[sResourceURL].push_back(aMigrationItem); + } + } + + sSibling = it->m_sCommandURL; + } + + ::rtl::OUString sNewSibling; + uno::Reference< container::XIndexContainer > xPopup; + for (it = vNewItems.begin(); it!=vNewItems.end(); ++it) + { + ::std::vector< MigrationItem >::iterator pFound = ::std::find(vOldItems.begin(), vOldItems.end(), *it); + if (pFound != vOldItems.end() && it->m_xPopupMenu.is()) + { + ::rtl::OUString sName; + if (sParent.getLength()>0) + sName = sParent + MENU_SEPERATOR + it->m_sCommandURL; + else + sName = it->m_sCommandURL; + compareOldAndNewConfig(sName, pFound->m_xPopupMenu, it->m_xPopupMenu, sResourceURL); + } + else if (::std::find(vOldItems.begin(), vOldItems.end(), *it) == vOldItems.end()) + { + MigrationItem aMigrationItem(sParent, sSibling, it->m_sCommandURL, it->m_xPopupMenu); + if (m_aNewVersionItemsHashMap.find(sResourceURL)==m_aNewVersionItemsHashMap.end()) + { + ::std::vector< MigrationItem > vMigrationItems; + m_aNewVersionItemsHashMap.insert(MigrationHashMap::value_type(sResourceURL, vMigrationItems)); + m_aNewVersionItemsHashMap[sResourceURL].push_back(aMigrationItem); + } + else + { + if (::std::find(m_aNewVersionItemsHashMap[sResourceURL].begin(), m_aNewVersionItemsHashMap[sResourceURL].end(), aMigrationItem)==m_aNewVersionItemsHashMap[sResourceURL].end()) + m_aNewVersionItemsHashMap[sResourceURL].push_back(aMigrationItem); + } + } + } +} + +void MigrationImpl::mergeOldToNewVersion(const uno::Reference< ui::XUIConfigurationManager >& xCfgManager, + const uno::Reference< container::XIndexContainer>& xIndexContainer, + const ::rtl::OUString& sModuleIdentifier, + const ::rtl::OUString& sResourceURL) +{ + MigrationHashMap::iterator pFound = m_aOldVersionItemsHashMap.find(sResourceURL); + if (pFound==m_aOldVersionItemsHashMap.end()) + return; + + ::std::vector< MigrationItem >::iterator it; + for (it=pFound->second.begin(); it!=pFound->second.end(); ++it) + { + uno::Reference< container::XIndexContainer > xTemp = xIndexContainer; + + ::rtl::OUString sParentNodeName = it->m_sParentNodeName; + sal_Int32 nIndex = 0; + do + { + ::rtl::OUString sToken = sParentNodeName.getToken(0, '|', nIndex).trim(); + if (sToken.getLength()<=0) + break; + + sal_Int32 nCount = xTemp->getCount(); + for (sal_Int32 i=0; i<nCount; ++i) + { + ::rtl::OUString sCommandURL; + ::rtl::OUString sLabel; + uno::Reference< container::XIndexContainer > xChild; + + uno::Sequence< beans::PropertyValue > aPropSeq; + xTemp->getByIndex(i) >>= aPropSeq; + for (sal_Int32 j=0; j<aPropSeq.getLength(); ++j) + { + ::rtl::OUString sPropName = aPropSeq[j].Name; + if (sPropName.equals(ITEM_DESCRIPTOR_COMMANDURL)) + aPropSeq[j].Value >>= sCommandURL; + else if (sPropName.equals(ITEM_DESCRIPTOR_LABEL)) + aPropSeq[j].Value >>= sLabel; + else if (sPropName.equals(ITEM_DESCRIPTOR_CONTAINER)) + aPropSeq[j].Value >>= xChild; + } + + if (sCommandURL == sToken) + { + xTemp = xChild; + break; + } + } + + } while (nIndex>=0); + + if (nIndex == -1) + { + uno::Sequence< beans::PropertyValue > aPropSeq(3); + + aPropSeq[0].Name = ITEM_DESCRIPTOR_COMMANDURL; + aPropSeq[0].Value <<= it->m_sCommandURL; + aPropSeq[1].Name = ITEM_DESCRIPTOR_LABEL; + aPropSeq[1].Value <<= retrieveLabelFromCommand(it->m_sCommandURL, sModuleIdentifier); + aPropSeq[2].Name = ITEM_DESCRIPTOR_CONTAINER; + aPropSeq[2].Value <<= it->m_xPopupMenu; + + if (it->m_sPrevSibling.getLength() == 0) + xTemp->insertByIndex(0, uno::makeAny(aPropSeq)); + else if (it->m_sPrevSibling.getLength() > 0) + { + sal_Int32 nCount = xTemp->getCount(); + sal_Int32 i = 0; + for (; i<nCount; ++i) + { + ::rtl::OUString sCmd; + uno::Sequence< beans::PropertyValue > aTempPropSeq; + xTemp->getByIndex(i) >>= aTempPropSeq; + for (sal_Int32 j=0; j<aTempPropSeq.getLength(); ++j) + { + if (aTempPropSeq[j].Name.equals(ITEM_DESCRIPTOR_COMMANDURL)) + { + aTempPropSeq[j].Value >>= sCmd; + break; + } + } + + if (sCmd.equals(it->m_sPrevSibling)) + break; + } + + xTemp->insertByIndex(i+1, uno::makeAny(aPropSeq)); + } + } + } + + uno::Reference< container::XIndexAccess > xIndexAccess(xIndexContainer, uno::UNO_QUERY); + if (xIndexAccess.is()) + xCfgManager->replaceSettings(sResourceURL, xIndexAccess); + + uno::Reference< ui::XUIConfigurationPersistence > xUIConfigurationPersistence(xCfgManager, uno::UNO_QUERY); + if (xUIConfigurationPersistence.is()) + xUIConfigurationPersistence->store(); +} + +uno::Reference< ui::XUIConfigurationManager > NewVersionUIInfo::getConfigManager(const ::rtl::OUString& sModuleShortName) const +{ + uno::Reference< ui::XUIConfigurationManager > xCfgManager; + + for (sal_Int32 i=0; i<m_lCfgManagerSeq.getLength(); ++i) + { + if (m_lCfgManagerSeq[i].Name.equals(sModuleShortName)) + { + m_lCfgManagerSeq[i].Value >>= xCfgManager; + break; + } + } + + return xCfgManager; +} + +uno::Reference< container::XIndexContainer > NewVersionUIInfo::getNewMenubarSettings(const ::rtl::OUString& sModuleShortName) const +{ + uno::Reference< container::XIndexContainer > xNewMenuSettings; + + for (sal_Int32 i=0; i<m_lNewVersionMenubarSettingsSeq.getLength(); ++i) + { + if (m_lNewVersionMenubarSettingsSeq[i].Name.equals(sModuleShortName)) + { + m_lNewVersionMenubarSettingsSeq[i].Value >>= xNewMenuSettings; + break; + } + } + + return xNewMenuSettings; +} + +uno::Reference< container::XIndexContainer > NewVersionUIInfo::getNewToolbarSettings(const ::rtl::OUString& sModuleShortName, const ::rtl::OUString& sToolbarName) const +{ + uno::Reference< container::XIndexContainer > xNewToolbarSettings; + + for (sal_Int32 i=0; i<m_lNewVersionToolbarSettingsSeq.getLength(); ++i) + { + if (m_lNewVersionToolbarSettingsSeq[i].Name.equals(sModuleShortName)) + { + uno::Sequence< beans::PropertyValue > lToolbarSettingsSeq; + m_lNewVersionToolbarSettingsSeq[i].Value >>= lToolbarSettingsSeq; + for (sal_Int32 j=0; j<lToolbarSettingsSeq.getLength(); ++j) + { + if (lToolbarSettingsSeq[j].Name.equals(sToolbarName)) + { + lToolbarSettingsSeq[j].Value >>= xNewToolbarSettings; + break; + } + } + + break; + } + } + + return xNewToolbarSettings; +} + +void NewVersionUIInfo::init(const ::std::vector< MigrationModuleInfo >& vModulesInfo) +{ + m_lCfgManagerSeq.realloc(vModulesInfo.size()); + m_lNewVersionMenubarSettingsSeq.realloc(vModulesInfo.size()); + m_lNewVersionToolbarSettingsSeq.realloc(vModulesInfo.size()); + + const ::rtl::OUString sModuleCfgSupplier = ::rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier"); + const ::rtl::OUString sMenubarResourceURL = ::rtl::OUString::createFromAscii("private:resource/menubar/menubar"); + const ::rtl::OUString sToolbarResourcePre = ::rtl::OUString::createFromAscii("private:resource/toolbar/"); + + uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xModuleCfgSupplier = uno::Reference< ui::XModuleUIConfigurationManagerSupplier >(::comphelper::getProcessServiceFactory()->createInstance(sModuleCfgSupplier), uno::UNO_QUERY); + + for (sal_uInt32 i=0; i<vModulesInfo.size(); ++i) + { + ::rtl::OUString sModuleIdentifier = mapModuleShortNameToIdentifier(vModulesInfo[i].sModuleShortName); + if (sModuleIdentifier.getLength() > 0) + { + uno::Reference< ui::XUIConfigurationManager > xCfgManager = xModuleCfgSupplier->getUIConfigurationManager(sModuleIdentifier); + m_lCfgManagerSeq[i].Name = vModulesInfo[i].sModuleShortName; + m_lCfgManagerSeq[i].Value <<= xCfgManager; + + if (vModulesInfo[i].bHasMenubar) + { + m_lNewVersionMenubarSettingsSeq[i].Name = vModulesInfo[i].sModuleShortName; + m_lNewVersionMenubarSettingsSeq[i].Value <<= xCfgManager->getSettings(sMenubarResourceURL, sal_True); + } + + sal_Int32 nToolbars = vModulesInfo[i].m_vToolbars.size(); + if (nToolbars > 0) + { + uno::Sequence< beans::PropertyValue > lPropSeq(nToolbars); + for (sal_Int32 j=0; j<nToolbars; ++j) + { + ::rtl::OUString sToolbarName = vModulesInfo[i].m_vToolbars[j]; + ::rtl::OUString sToolbarResourceURL = sToolbarResourcePre + sToolbarName; + + lPropSeq[j].Name = sToolbarName; + lPropSeq[j].Value <<= xCfgManager->getSettings(sToolbarResourceURL, sal_True); + } + + m_lNewVersionToolbarSettingsSeq[i].Name = vModulesInfo[i].sModuleShortName; + m_lNewVersionToolbarSettingsSeq[i].Value <<= lPropSeq; + } + } + } +} + } // namespace desktop diff --git a/desktop/source/migration/migration_impl.hxx b/desktop/source/migration/migration_impl.hxx index 8cad1cce4b16..f73e44fea523 100644 --- a/desktop/source/migration/migration_impl.hxx +++ b/desktop/source/migration/migration_impl.hxx @@ -30,6 +30,7 @@ #include <vector> #include <algorithm> #include <memory> +#include <hash_map> #include "migration.hxx" @@ -41,6 +42,13 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/lang/XSingleComponentFactory.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp> +#include <com/sun/star/ui/XUIConfigurationManager.hpp> +#include <com/sun/star/ui/XUIConfigurationPersistence.hpp> #define NS_CSS com::sun::star #define NS_UNO com::sun::star::uno @@ -80,6 +88,107 @@ typedef std::vector< migration_step > migrations_v; typedef std::auto_ptr< migrations_v > migrations_vr; typedef std::vector< supported_migration > migrations_available; +//__________________________________________ +/** + define the item, e.g.:menuitem, toolbaritem, to be migrated. we keep the information + of the command URL, the previous sibling node and the parent node of a item +*/ +struct MigrationItem +{ + ::rtl::OUString m_sParentNodeName; + ::rtl::OUString m_sPrevSibling; + ::rtl::OUString m_sCommandURL; + NS_UNO::Reference< NS_CSS::container::XIndexContainer > m_xPopupMenu; + + MigrationItem() + :m_xPopupMenu(0) + { + } + + MigrationItem(const ::rtl::OUString& sParentNodeName, + const ::rtl::OUString& sPrevSibling, + const ::rtl::OUString& sCommandURL, + const NS_UNO::Reference< NS_CSS::container::XIndexContainer > xPopupMenu) + { + m_sParentNodeName = sParentNodeName; + m_sPrevSibling = sPrevSibling; + m_sCommandURL = sCommandURL; + m_xPopupMenu = xPopupMenu; + } + + MigrationItem& operator=(const MigrationItem& aMigrationItem) + { + m_sParentNodeName = aMigrationItem.m_sParentNodeName; + m_sPrevSibling = aMigrationItem.m_sPrevSibling; + m_sCommandURL = aMigrationItem.m_sCommandURL; + m_xPopupMenu = aMigrationItem.m_xPopupMenu; + + return *this; + } + + sal_Bool operator==(const MigrationItem& aMigrationItem) + { + return ( aMigrationItem.m_sParentNodeName == m_sParentNodeName && + aMigrationItem.m_sPrevSibling == m_sPrevSibling && + aMigrationItem.m_sCommandURL == m_sCommandURL && + aMigrationItem.m_xPopupMenu.is() == m_xPopupMenu.is() ); + } + + ::rtl::OUString GetPrevSibling() const { return m_sPrevSibling; } +}; + +typedef ::std::hash_map< ::rtl::OUString, + ::std::vector< MigrationItem >, + ::rtl::OUStringHash, + ::std::equal_to< ::rtl::OUString > > MigrationHashMap; + +struct MigrationItemInfo +{ + ::rtl::OUString m_sResourceURL; + MigrationItem m_aMigrationItem; + + MigrationItemInfo(){} + + MigrationItemInfo(const ::rtl::OUString& sResourceURL, const MigrationItem& aMigratiionItem) + { + m_sResourceURL = sResourceURL; + m_aMigrationItem = aMigratiionItem; + } +}; + +//__________________________________________ +/** + information for the UI elements to be migrated for one module +*/ +struct MigrationModuleInfo +{ + ::rtl::OUString sModuleShortName; + sal_Bool bHasMenubar; + ::std::vector< ::rtl::OUString > m_vToolbars; + + MigrationModuleInfo():bHasMenubar(sal_False){}; +}; + +//__________________________________________ +/** + get the information before copying the ui configuration files of old version to new version +*/ +class NewVersionUIInfo +{ +public: + + NS_UNO::Reference< NS_CSS::ui::XUIConfigurationManager > getConfigManager(const ::rtl::OUString& sModuleShortName) const; + NS_UNO::Reference< NS_CSS::container::XIndexContainer > getNewMenubarSettings(const ::rtl::OUString& sModuleShortName) const; + NS_UNO::Reference< NS_CSS::container::XIndexContainer > getNewToolbarSettings(const ::rtl::OUString& sModuleShortName, const ::rtl::OUString& sToolbarName) const; + void init(const ::std::vector< MigrationModuleInfo >& vModulesInfo); + +private: + + NS_UNO::Sequence< NS_CSS::beans::PropertyValue > m_lCfgManagerSeq; + NS_UNO::Sequence< NS_CSS::beans::PropertyValue > m_lNewVersionMenubarSettingsSeq; + NS_UNO::Sequence< NS_CSS::beans::PropertyValue > m_lNewVersionToolbarSettingsSeq; +}; + class MigrationImpl { @@ -91,6 +200,9 @@ private: migrations_vr m_vrMigrations; // list of all migration specs from config install_info m_aInfo; // info about the version being migrated strings_vr m_vrFileList; // final list of files to be copied + MigrationHashMap m_aOldVersionItemsHashMap; + MigrationHashMap m_aNewVersionItemsHashMap; + ::rtl::OUString m_sModuleIdentifier; // functions to control the migration process bool readAvailableMigrations(migrations_available&); @@ -105,6 +217,16 @@ 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); + ::std::vector< MigrationModuleInfo > dectectUIChangesForAllModules() const; + void compareOldAndNewConfig(const ::rtl::OUString& sParentNodeName, + const NS_UNO::Reference< NS_CSS::container::XIndexContainer >& xOldIndexContainer, + const NS_UNO::Reference< NS_CSS::container::XIndexContainer >& xNewIndexContainer, + const ::rtl::OUString& sToolbarName); + void mergeOldToNewVersion(const NS_UNO::Reference< NS_CSS::ui::XUIConfigurationManager >& xCfgManager, + const NS_UNO::Reference< NS_CSS::container::XIndexContainer>& xIndexContainer, + const ::rtl::OUString& sModuleIdentifier, + const ::rtl::OUString& sResourceURL); + // actual processing function that perform the migration steps void copyFiles(); void copyConfig(); diff --git a/desktop/source/splash/makefile.mk b/desktop/source/splash/makefile.mk index 2f163fe7b9d6..89609687438c 100644 --- a/desktop/source/splash/makefile.mk +++ b/desktop/source/splash/makefile.mk @@ -63,7 +63,6 @@ SHL1STDLIBS= \ $(SVLLIB) \ $(SVTOOLLIB) \ $(COMPHELPERLIB) \ - $(CONFIGMGRLIB) \ $(UNOTOOLSLIB) \ $(TOOLSLIB) \ $(UCBHELPERLIB) \ diff --git a/desktop/test/deployment/boxt/Addons.xcu b/desktop/test/deployment/boxt/Addons.xcu new file mode 100644 index 000000000000..3df7e2de274c --- /dev/null +++ b/desktop/test/deployment/boxt/Addons.xcu @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<o:component-data xmlns:o="http://openoffice.org/2001/registry" + o:package="org.openoffice.Office" o:name="Addons"> + <node o:name="AddonUI"> + <node o:name="OfficeMenuBar"> + <node o:name="org.openoffice.test.desktop.deployment.boxt" o:op="replace"> + <prop o:name="Title" xml:lang="en-US"> + <value>boxt</value> + </prop> + <node o:name="Submenu"> + <node o:name="1" o:op="replace"> + <prop o:name="URL"> + <value>vnd.org.openoffice.test.desktop.deployment.boxt:</value> + </prop> + <prop o:name="Title" xml:lang="en-US"> + <value>boxt</value> + </prop> + </node> + </node> + </node> + </node> + </node> +</o:component-data> diff --git a/desktop/test/deployment/boxt/ProtocolHandler.xcu b/desktop/test/deployment/boxt/ProtocolHandler.xcu new file mode 100644 index 000000000000..fe448aedbe17 --- /dev/null +++ b/desktop/test/deployment/boxt/ProtocolHandler.xcu @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<o:component-data xmlns:o="http://openoffice.org/2001/registry" + o:package="org.openoffice.Office" o:name="ProtocolHandler"> + <node o:name="HandlerSet"> + <node o:name="com.sun.star.test.deployment.boxt" o:op="replace"> + <prop o:name="Protocols"> + <value>vnd.org.openoffice.test.desktop.deployment.boxt:*</value> + </prop> + </node> + </node> +</o:component-data> diff --git a/desktop/test/deployment/boxt/boxt.cxx b/desktop/test/deployment/boxt/boxt.cxx new file mode 100644 index 000000000000..dc82c0c004d6 --- /dev/null +++ b/desktop/test/deployment/boxt/boxt.cxx @@ -0,0 +1,235 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "precompiled_desktop.hxx" +#include "sal/config.h" + +#include "boost/noncopyable.hpp" +#include "com/sun/star/beans/PropertyValue.hpp" +#include "com/sun/star/frame/DispatchDescriptor.hpp" +#include "com/sun/star/frame/XDispatch.hpp" +#include "com/sun/star/frame/XDispatchProvider.hpp" +#include "com/sun/star/frame/XStatusListener.hpp" +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/lang/XSingleComponentFactory.hpp" +#include "com/sun/star/uno/Any.hxx" +#include "com/sun/star/uno/Exception.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/uno/XInterface.hpp" +#include "com/sun/star/util/URL.hpp" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/implbase3.hxx" +#include "cppuhelper/implementationentry.hxx" +#include "cppuhelper/weak.hxx" +#include "filter/msfilter/countryid.hxx" +#include "osl/diagnose.h" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "uno/lbnames.h" +#include "vcl/svapp.hxx" + +namespace { + +namespace css = com::sun::star; + +namespace service { + +rtl::OUString getImplementationName() { + return rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.test.deployment.boxt")); +} + +css::uno::Sequence< rtl::OUString > getSupportedServiceNames() { + rtl::OUString name( + RTL_CONSTASCII_USTRINGPARAM("com.sun.star.test.deployment.boxt")); + return css::uno::Sequence< rtl::OUString >(&name, 1); +} + +} + +class Service: + public cppu::WeakImplHelper3< + css::lang::XServiceInfo, css::frame::XDispatchProvider, + css::frame::XDispatch >, + private boost::noncopyable +{ +public: + Service() {} + +private: + virtual ~Service() {} + + virtual rtl::OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { return service::getImplementationName(); } + + virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) + throw (css::uno::RuntimeException) + { return ServiceName == getSupportedServiceNames()[0]; } //TODO + + virtual css::uno::Sequence< rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (css::uno::RuntimeException) + { return service::getSupportedServiceNames(); } + + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( + css::util::URL const &, rtl::OUString const &, sal_Int32) + throw (css::uno::RuntimeException) + { return this; } + + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > + SAL_CALL queryDispatches( + css::uno::Sequence< css::frame::DispatchDescriptor > const & Requests) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL dispatch( + css::util::URL const &, + css::uno::Sequence< css::beans::PropertyValue > const &) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL addStatusListener( + css::uno::Reference< css::frame::XStatusListener > const &, + css::util::URL const &) + throw (css::uno::RuntimeException) + {} + + virtual void SAL_CALL removeStatusListener( + css::uno::Reference< css::frame::XStatusListener > const &, + css::util::URL const &) + throw (css::uno::RuntimeException) + {} +}; + +css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > +Service::queryDispatches( + css::uno::Sequence< css::frame::DispatchDescriptor > const & Requests) + throw (css::uno::RuntimeException) +{ + css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > s( + Requests.getLength()); + for (sal_Int32 i = 0; i < s.getLength(); ++i) { + s[i] = queryDispatch( + Requests[i].FeatureURL, Requests[i].FrameName, + Requests[i].SearchFlags); + } + return s; +} + +void Service::dispatch( + css::util::URL const &, + css::uno::Sequence< css::beans::PropertyValue > const &) + throw (css::uno::RuntimeException) +{ + msfilter::ConvertCountryToLanguage(msfilter::COUNTRY_DONTKNOW); + // link against some obscure library that is unlikely already loaded + Application::ShowNativeErrorBox( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("boxt")), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test"))); +} + +class Factory: + public cppu::WeakImplHelper1< css::lang::XSingleComponentFactory >, + private boost::noncopyable +{ +public: + Factory() {} + +private: + virtual ~Factory() {} + + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL + createInstanceWithContext( + css::uno::Reference< css::uno::XComponentContext > const &) + throw (css::uno::Exception, css::uno::RuntimeException) + { return static_cast< cppu::OWeakObject * >(new Service); } + + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL + createInstanceWithArgumentsAndContext( + css::uno::Sequence< css::uno::Any > const &, + css::uno::Reference< css::uno::XComponentContext > const & Context) + throw (css::uno::Exception, css::uno::RuntimeException) + { return createInstanceWithContext(Context); } +}; + +css::uno::Reference< css::uno::XInterface > SAL_CALL dummy( + css::uno::Reference< css::uno::XComponentContext > const &) + SAL_THROW((css::uno::Exception)) +{ + OSL_ASSERT(false); + return css::uno::Reference< css::uno::XInterface >(); +} + +rtl::OUString SAL_CALL getImplementationName() { + return rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.test.deployment.boxt")); +} + +css::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() { + rtl::OUString name( + RTL_CONSTASCII_USTRINGPARAM("com.sun.star.test.deployment.boxt")); + return css::uno::Sequence< rtl::OUString >(&name, 1); +} + +css::uno::Reference< css::lang::XSingleComponentFactory > SAL_CALL +createFactory( + cppu::ComponentFactoryFunc, rtl::OUString const &, + css::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *) + SAL_THROW(()) +{ + return new Factory; +} + +static cppu::ImplementationEntry const services[] = { + { &dummy, &service::getImplementationName, + &service::getSupportedServiceNames, &createFactory, 0, 0 }, + { 0, 0, 0, 0, 0, 0 } +}; + +} + +extern "C" void * SAL_CALL component_getFactory( + char const * pImplName, void * pServiceManager, void * pRegistryKey) +{ + return cppu::component_getFactoryHelper( + pImplName, pServiceManager, pRegistryKey, services); +} + +extern "C" void SAL_CALL component_getImplementationEnvironment( + char const ** ppEnvTypeName, uno_Environment **) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +extern "C" sal_Bool SAL_CALL component_writeInfo( + void * pServiceManager, void * pRegistryKey) +{ + return component_writeInfoHelper(pServiceManager, pRegistryKey, services); +} diff --git a/desktop/test/deployment/boxt/description.xml b/desktop/test/deployment/boxt/description.xml new file mode 100644 index 000000000000..5a67bf3e949f --- /dev/null +++ b/desktop/test/deployment/boxt/description.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<d:description xmlns:d="http://openoffice.org/extensions/description/2006"> + <d:identifier value="org.openoffice/framework/desktop/test/deployment/boxt"/> + <d:version value="@VERSION@"/> + <d:platform value="@PLATFORM@"/> + <d:dependencies> + <d:OpenOffice.org-minimal-version d:name="OpenOffice.org @VERSION@" + value="@VERSION@"/> + <d:OpenOffice.org-maximal-version d:name="OpenOffice.org @VERSION@ or older" + d:OpenOffice.org-minimal-version="2.3" value="@VERSION@"/> + </d:dependencies> +</d:description> diff --git a/desktop/test/deployment/boxt/makefile.mk b/desktop/test/deployment/boxt/makefile.mk new file mode 100644 index 000000000000..63f123fcc608 --- /dev/null +++ b/desktop/test/deployment/boxt/makefile.mk @@ -0,0 +1,70 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#***********************************************************************/ + +PRJ = ../../.. +PRJNAME = desktop +TARGET = test_deployment_boxt + +ENABLE_EXCEPTIONS = TRUE + +.INCLUDE: settings.mk +.INCLUDE: rtlbootstrap.mk + +#TODO: The underlying OOo base version needed here is currently only available +# as instsetoo_native/util/openoffice.lst OOOBASEVERSION, so hard-coding it here +# for now (see issue 110653): +my_version = 3.3 + +DLLPRE = + +SLOFILES = $(SHL1OBJS) + +SHL1TARGET = boxt.uno +SHL1OBJS = $(SLO)/boxt.obj +SHL1RPATH = BOXT +SHL1STDLIBS = \ + $(CPPUHELPERLIB) $(CPPULIB) $(MSFILTERLIB) $(SALLIB) $(TOOLSLIB) $(VCLLIB) +SHL1VERSIONMAP = $(SOLARENV)/src/component.map +DEF1NAME = $(SHL1TARGET) + +.INCLUDE: target.mk + +ALLTAR : $(MISC)/boxt.oxt + +$(MISC)/boxt.oxt .ERRREMOVE : manifest.xml description.xml Addons.xcu \ + ProtocolHandler.xcu $(SHL1TARGETN) + $(RM) -r $@ $(MISC)/$(TARGET).zip + $(MKDIR) $(MISC)/$(TARGET).zip + $(MKDIR) $(MISC)/$(TARGET).zip/META-INF + $(SED) -e 's|@PATH@|$(SHL1TARGETN:f)|g' < manifest.xml \ + > $(MISC)/$(TARGET).zip/META-INF/manifest.xml + $(SED) -e 's|@PLATFORM@|$(RTL_OS:l)_$(RTL_ARCH:l)|g' \ + -e 's|@VERSION@|$(my_version)|g' < description.xml \ + > $(MISC)/$(TARGET).zip/description.xml + $(COPY) Addons.xcu ProtocolHandler.xcu $(SHL1TARGETN) $(MISC)/$(TARGET).zip + cd $(MISC)/$(TARGET).zip && zip ../boxt.oxt META-INF/manifest.xml \ + description.xml Addons.xcu ProtocolHandler.xcu $(SHL1TARGETN:f) diff --git a/desktop/test/deployment/boxt/manifest.xml b/desktop/test/deployment/boxt/manifest.xml new file mode 100644 index 000000000000..73ebfc306e30 --- /dev/null +++ b/desktop/test/deployment/boxt/manifest.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<m:manifest xmlns:m="http://openoffice.org/2001/manifest"> + <m:file-entry m:media-type="application/vnd.sun.star.configuration-data" + m:full-path="Addons.xcu"/> + <m:file-entry m:media-type="application/vnd.sun.star.configuration-data" + m:full-path="ProtocolHandler.xcu"/> + <m:file-entry + m:media-type="application/vnd.sun.star.uno-component;type=native" + m:full-path="@PATH@"/> +</m:manifest> diff --git a/desktop/util/makefile.mk b/desktop/util/makefile.mk index c669206bb3f3..47885dfd6b73 100644 --- a/desktop/util/makefile.mk +++ b/desktop/util/makefile.mk @@ -81,41 +81,7 @@ APP1TARGET=so$/$(TARGET) APP1NOSAL=TRUE APP1RPATH=BRAND APP1OBJS=$(OBJ)$/copyright_ascii_sun.obj $(OBJ)$/main.obj -APP1STDLIBS = \ - $(SALLIB) \ - $(SOFFICELIB) \ - $(COMPHELPERLIB) \ - $(CPPUHELPERLIB) \ - $(CPPULIB) \ - $(I18NISOLANGLIB) \ - $(SALLIB) \ - $(SFXLIB) \ - $(SVLLIB) \ - $(SVTOOLLIB) \ - $(TKLIB) \ - $(TOOLSLIB) \ - $(UCBHELPERLIB) \ - $(UNOTOOLSLIB) \ - $(VCLLIB) \ - $(FWELIB) \ - $(BASICLIB) \ - $(XMLSCRIPTLIB) \ - $(SALHELPERLIB) \ - $(SOTLIB) \ - $(SAXLIB) \ - $(FWILIB) \ - $(ICUUCLIB) \ - $(I18NUTILLIB) \ - $(ICULIB) \ - $(JVMFWKLIB) \ - $(BASEGFXLIB) \ - $(ICUDATALIB) \ - $(ICULELIB) \ - $(JVMACCESSLIB) \ - $(SALHELPERLIB) \ - $(VOSLIB) - - +APP1STDLIBS = $(SALLIB) $(SOFFICELIB) APP1DEPN= $(APP1RES) verinfo.rc .IF "$(GUI)" == "WNT" @@ -140,40 +106,7 @@ APP5TARGET=soffice APP5NOSAL=TRUE APP5RPATH=BRAND APP5OBJS=$(OBJ)$/copyright_ascii_ooo.obj $(OBJ)$/main.obj -APP5STDLIBS = \ - $(SALLIB) \ - $(SOFFICELIB) \ - $(COMPHELPERLIB) \ - $(CPPUHELPERLIB) \ - $(CPPULIB) \ - $(I18NISOLANGLIB) \ - $(SALLIB) \ - $(SFXLIB) \ - $(SVLLIB) \ - $(SVTOOLLIB) \ - $(TKLIB) \ - $(TOOLSLIB) \ - $(UCBHELPERLIB) \ - $(UNOTOOLSLIB) \ - $(VCLLIB) \ - $(FWELIB) \ - $(BASICLIB) \ - $(XMLSCRIPTLIB) \ - $(SALHELPERLIB) \ - $(SOTLIB) \ - $(SAXLIB) \ - $(FWILIB) \ - $(ICUUCLIB) \ - $(I18NUTILLIB) \ - $(ICULIB) \ - $(JVMFWKLIB) \ - $(BASEGFXLIB) \ - $(ICUDATALIB) \ - $(ICULELIB) \ - $(JVMACCESSLIB) \ - $(SALHELPERLIB) \ - $(VOSLIB) - +APP5STDLIBS = $(SALLIB) $(SOFFICELIB) .IF "$(OS)" == "LINUX" APP5STDLIBS+= -lXext #APP5STDLIBS+= -lXext -lSM -lICE |