diff options
Diffstat (limited to 'xmlhelp/source/cxxhelp/provider/provider.cxx')
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/provider.cxx | 162 |
1 files changed, 91 insertions, 71 deletions
diff --git a/xmlhelp/source/cxxhelp/provider/provider.cxx b/xmlhelp/source/cxxhelp/provider/provider.cxx index 87dd04cb06..7e6931e22d 100644 --- a/xmlhelp/source/cxxhelp/provider/provider.cxx +++ b/xmlhelp/source/cxxhelp/provider/provider.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -52,10 +52,9 @@ #include <com/sun/star/container/XContainer.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameReplace.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <rtl/bootstrap.hxx> -#include <unotools/configmgr.hxx> #include "databases.hxx" #include "provider.hxx" @@ -73,7 +72,7 @@ using namespace chelp; //========================================================================= //========================================================================= -ContentProvider::ContentProvider( +ContentProvider::ContentProvider( const uno::Reference< lang::XMultiServiceFactory >& rSMgr ) : ::ucbhelper::ContentProviderImplHelper( rSMgr ), isInitialized( false ), @@ -194,8 +193,8 @@ ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider ); //========================================================================= // virtual -uno::Reference< ucb::XContent > SAL_CALL -ContentProvider::queryContent( +uno::Reference< ucb::XContent > SAL_CALL +ContentProvider::queryContent( const uno::Reference< ucb::XContentIdentifier >& xCanonicId ) throw( ucb::IllegalIdentifierException, uno::RuntimeException ) { @@ -204,43 +203,43 @@ ContentProvider::queryContent( { // Wrong URL-scheme throw ucb::IllegalIdentifierException(); } - + { osl::MutexGuard aGuard( m_aMutex ); if( !isInitialized ) init(); } - + if( !m_pDatabases ) throw uno::RuntimeException(); - + rtl::OUString aOUString( m_pDatabases->getInstallPathAsURL() ); rtl::OString aOString( aOUString.getStr(), aOUString.getLength(), RTL_TEXTENCODING_UTF8 ); - + // Check, if a content with given id already exists... uno::Reference< ucb::XContent > xContent = queryExistingContent( xCanonicId ).get(); if ( xContent.is() ) return xContent; - + xContent = new Content( m_xSMgr, this, xCanonicId, m_pDatabases ); // register new content registerNewContent( xContent ); // Further checks - + if ( !xContent->getIdentifier().is() ) throw ucb::IllegalIdentifierException(); - + return xContent; } void SAL_CALL ContentProvider::dispose() - throw ( uno::RuntimeException) + throw ( uno::RuntimeException) { if(m_xContainer.is()) { @@ -250,7 +249,7 @@ ContentProvider::dispose() } void SAL_CALL -ContentProvider::elementReplaced(const container::ContainerEvent& Event) +ContentProvider::elementReplaced(const container::ContainerEvent& Event) throw (uno::RuntimeException) { if(!m_pDatabases) @@ -260,25 +259,25 @@ ContentProvider::elementReplaced(const container::ContainerEvent& Event) Event.Accessor >>= accessor; if(accessor.compareToAscii("HelpStyleSheet")) return; - + rtl::OUString replacedElement,element; Event.ReplacedElement >>= replacedElement; Event.Element >>= element; - + if(replacedElement == element) return; - + m_pDatabases->changeCSS(element); } void ContentProvider::init() { osl::MutexGuard aGuard( m_aMutex ); - + isInitialized = true; - uno::Reference< lang::XMultiServiceFactory > sProvider( + uno::Reference< lang::XMultiServiceFactory > sProvider( getConfiguration() ); - uno::Reference< container::XHierarchicalNameAccess > xHierAccess( + uno::Reference< container::XHierarchicalNameAccess > xHierAccess( getHierAccess( sProvider, "org.openoffice.Office.Common" ) ); @@ -288,14 +287,14 @@ void ContentProvider::init() instPath = rtl::OUString::createFromAscii( "$(instpath)/help" ); // replace anything like $(instpath); subst( instPath ); - + rtl::OUString stylesheet( getKey( xHierAccess,"Help/HelpStyleSheet" ) ); - try + try { // now adding as configuration change listener for the stylesheet uno::Reference< container::XNameAccess> xAccess( - xHierAccess, uno::UNO_QUERY ); - if( xAccess.is() ) + xHierAccess, uno::UNO_QUERY ); + if( xAccess.is() ) { uno::Any aAny = xAccess->getByName( rtl::OUString::createFromAscii( "Help" ) ); @@ -303,11 +302,11 @@ void ContentProvider::init() if( m_xContainer.is() ) m_xContainer->addContainerListener( this ); } - } - catch( uno::Exception const & ) + } + catch( uno::Exception const & ) { } - + /** * now determing * productname, @@ -316,41 +315,62 @@ void ContentProvider::init() * vendorversion, * vendorshort */ - + xHierAccess = getHierAccess( sProvider, "org.openoffice.Setup" ); - rtl::OUString productname( + rtl::OUString productname( getKey( xHierAccess,"Product/ooName" ) ); - rtl::OUString setupversion( + rtl::OUString setupversion( getKey( xHierAccess,"Product/ooSetupVersion" ) ); rtl::OUString setupextension; - utl::ConfigManager * mgr = utl::ConfigManager::GetConfigManager(); - if (mgr != NULL) { - mgr->GetDirectConfigProperty(utl::ConfigManager::PRODUCTEXTENSION) >>= - setupextension; + + try + { + uno::Reference< lang::XMultiServiceFactory > xConfigProvider( + m_xSMgr ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), uno::UNO_QUERY_THROW); + + uno::Sequence < uno::Any > lParams(1); + beans::PropertyValue aParam ; + aParam.Name = ::rtl::OUString::createFromAscii("nodepath"); + aParam.Value <<= ::rtl::OUString::createFromAscii("/org.openoffice.Setup/Product"); + lParams[0] = uno::makeAny(aParam); + + // open it + uno::Reference< uno::XInterface > xCFG( xConfigProvider->createInstanceWithArguments( + ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"), + lParams) ); + + uno::Reference< container::XNameAccess > xDirectAccess(xCFG, uno::UNO_QUERY); + uno::Any aRet = xDirectAccess->getByName(::rtl::OUString::createFromAscii("ooSetupExtension")); + + aRet >>= setupextension; + } + catch ( uno::Exception& ) + { } - rtl::OUString productversion( - setupversion + + + rtl::OUString productversion( + setupversion + rtl::OUString::createFromAscii( " " ) + setupextension ); - + xHierAccess = getHierAccess( sProvider, "org.openoffice.Webtop.Common" ); - rtl::OUString vendorname( + rtl::OUString vendorname( getKey( xHierAccess,"Product/ooName" ) ); - setupversion = rtl::OUString( + setupversion = rtl::OUString( getKey( xHierAccess,"Product/ooSetupVersion" ) ); - setupextension = rtl::OUString( - getKey( xHierAccess,"Product/ooSetupExtension") ); - rtl::OUString vendorversion( - setupversion + + setupextension = rtl::OUString( + getKey( xHierAccess,"Product/ooSetupExtension") ); + rtl::OUString vendorversion( + setupversion + rtl::OUString::createFromAscii( " " ) + setupextension ); rtl::OUString vendorshort = vendorname; - + uno::Sequence< rtl::OUString > aImagesZipPaths( 2 ); xHierAccess = getHierAccess( sProvider, "org.openoffice.Office.Common" ); - + rtl::OUString aPath( getKey( xHierAccess, "Path/Current/UserConfig" ) ); subst( aPath ); aImagesZipPaths[ 0 ] = aPath; @@ -368,9 +388,9 @@ void ContentProvider::init() ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xContext; OSL_ASSERT( xContext.is() ); } - + sal_Bool showBasic = getBooleanKey(xHierAccess,"Help/ShowBasic"); - m_pDatabases = new Databases( showBasic, + m_pDatabases = new Databases( showBasic, instPath, aImagesZipPaths, productname, @@ -379,10 +399,10 @@ void ContentProvider::init() vendorversion, vendorshort, stylesheet, - xContext ); + xContext ); } -uno::Reference< lang::XMultiServiceFactory > +uno::Reference< lang::XMultiServiceFactory > ContentProvider::getConfiguration() const { uno::Reference< lang::XMultiServiceFactory > sProvider; @@ -390,23 +410,23 @@ ContentProvider::getConfiguration() const { uno::Any aAny; aAny <<= rtl::OUString::createFromAscii( "plugin" ); - beans::PropertyValue aProp( + beans::PropertyValue aProp( rtl::OUString::createFromAscii( "servertype" ), -1, aAny, beans::PropertyState_DIRECT_VALUE ); - + uno::Sequence< uno::Any > seq(1); seq[0] <<= aProp; - + try { rtl::OUString sProviderService = - rtl::OUString::createFromAscii( + rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ); sProvider = uno::Reference< lang::XMultiServiceFactory >( - m_xSMgr->createInstanceWithArguments( + m_xSMgr->createInstanceWithArguments( sProviderService,seq ), uno::UNO_QUERY ); } @@ -415,31 +435,31 @@ ContentProvider::getConfiguration() const OSL_ENSURE( sProvider.is(), "cant instantiate configuration" ); } } - + return sProvider; } uno::Reference< container::XHierarchicalNameAccess > -ContentProvider::getHierAccess( +ContentProvider::getHierAccess( const uno::Reference< lang::XMultiServiceFactory >& sProvider, const char* file ) const { uno::Reference< container::XHierarchicalNameAccess > xHierAccess; - + if( sProvider.is() ) { uno::Sequence< uno::Any > seq( 1 ); rtl::OUString sReaderService( - rtl::OUString::createFromAscii( + rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" ) ); - - seq[ 0 ] <<= rtl::OUString::createFromAscii( file ); - + + seq[ 0 ] <<= rtl::OUString::createFromAscii( file ); + try { - xHierAccess = - uno::Reference< container::XHierarchicalNameAccess >( - sProvider->createInstanceWithArguments( + xHierAccess = + uno::Reference< container::XHierarchicalNameAccess >( + sProvider->createInstanceWithArguments( sReaderService, seq ), uno::UNO_QUERY ); } @@ -453,7 +473,7 @@ ContentProvider::getHierAccess( rtl::OUString -ContentProvider::getKey( +ContentProvider::getKey( const uno::Reference< container::XHierarchicalNameAccess >& xHierAccess, const char* key ) const { @@ -507,8 +527,8 @@ void ContentProvider::subst( rtl::OUString& instpath ) const { xCfgMgr = uno::Reference< frame::XConfigManager >( - m_xSMgr->createInstance( - rtl::OUString::createFromAscii( + m_xSMgr->createInstance( + rtl::OUString::createFromAscii( "com.sun.star.config.SpecialConfigManager" ) ), uno::UNO_QUERY ); } @@ -518,9 +538,9 @@ void ContentProvider::subst( rtl::OUString& instpath ) const "cant instantiate the special config manager " ); } } - + OSL_ENSURE( xCfgMgr.is(), "specialconfigmanager not found\n" ); - + if( xCfgMgr.is() ) instpath = xCfgMgr->substituteVariables( instpath ); } |