1*89dcb3daSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*89dcb3daSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*89dcb3daSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*89dcb3daSAndrew Rist * distributed with this work for additional information 6*89dcb3daSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*89dcb3daSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*89dcb3daSAndrew Rist * "License"); you may not use this file except in compliance 9*89dcb3daSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*89dcb3daSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*89dcb3daSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*89dcb3daSAndrew Rist * software distributed under the License is distributed on an 15*89dcb3daSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*89dcb3daSAndrew Rist * KIND, either express or implied. See the License for the 17*89dcb3daSAndrew Rist * specific language governing permissions and limitations 18*89dcb3daSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*89dcb3daSAndrew Rist *************************************************************/ 21*89dcb3daSAndrew Rist 22*89dcb3daSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmlhelp.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir /************************************************************************** 28cdf0e10cSrcweir TODO 29cdf0e10cSrcweir ************************************************************************** 30cdf0e10cSrcweir 31cdf0e10cSrcweir *************************************************************************/ 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <stdio.h> 34cdf0e10cSrcweir #include <osl/file.hxx> 35cdf0e10cSrcweir #ifndef _VOS_DIAGNOSE_HXX_ 36cdf0e10cSrcweir #include <vos/diagnose.hxx> 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir #include <ucbhelper/contentidentifier.hxx> 39cdf0e10cSrcweir #include <com/sun/star/frame/XConfigManager.hpp> 40cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBBUTE_HPP_ 41cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 42cdf0e10cSrcweir #endif 43cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 44cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp> 45cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 46cdf0e10cSrcweir #include <com/sun/star/container/XNameReplace.hpp> 47cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 48cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 49cdf0e10cSrcweir #include <rtl/bootstrap.hxx> 50cdf0e10cSrcweir 51cdf0e10cSrcweir #include "databases.hxx" 52cdf0e10cSrcweir #include "provider.hxx" 53cdf0e10cSrcweir #include "content.hxx" 54cdf0e10cSrcweir #include "databases.hxx" 55cdf0e10cSrcweir 56cdf0e10cSrcweir using namespace com::sun::star; 57cdf0e10cSrcweir using namespace chelp; 58cdf0e10cSrcweir 59cdf0e10cSrcweir //========================================================================= 60cdf0e10cSrcweir //========================================================================= 61cdf0e10cSrcweir // 62cdf0e10cSrcweir // ContentProvider Implementation. 63cdf0e10cSrcweir // 64cdf0e10cSrcweir //========================================================================= 65cdf0e10cSrcweir //========================================================================= 66cdf0e10cSrcweir 67cdf0e10cSrcweir ContentProvider::ContentProvider( 68cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rSMgr ) 69cdf0e10cSrcweir : ::ucbhelper::ContentProviderImplHelper( rSMgr ), 70cdf0e10cSrcweir isInitialized( false ), 71cdf0e10cSrcweir m_aScheme( rtl::OUString::createFromAscii( MYUCP_URL_SCHEME ) ), 72cdf0e10cSrcweir m_pDatabases( 0 ) 73cdf0e10cSrcweir { 74cdf0e10cSrcweir } 75cdf0e10cSrcweir 76cdf0e10cSrcweir //========================================================================= 77cdf0e10cSrcweir // virtual 78cdf0e10cSrcweir ContentProvider::~ContentProvider() 79cdf0e10cSrcweir { 80cdf0e10cSrcweir delete m_pDatabases; 81cdf0e10cSrcweir } 82cdf0e10cSrcweir 83cdf0e10cSrcweir //========================================================================= 84cdf0e10cSrcweir // 85cdf0e10cSrcweir // XInterface methods. 86cdf0e10cSrcweir // 87cdf0e10cSrcweir //========================================================================= 88cdf0e10cSrcweir 89cdf0e10cSrcweir XINTERFACE_IMPL_6( ContentProvider, 90cdf0e10cSrcweir lang::XTypeProvider, 91cdf0e10cSrcweir lang::XServiceInfo, 92cdf0e10cSrcweir ucb::XContentProvider, 93cdf0e10cSrcweir lang::XComponent, 94cdf0e10cSrcweir lang::XEventListener, /* base of XContainerListener */ 95cdf0e10cSrcweir container::XContainerListener); 96cdf0e10cSrcweir 97cdf0e10cSrcweir //========================================================================= 98cdf0e10cSrcweir // 99cdf0e10cSrcweir // XTypeProvider methods. 100cdf0e10cSrcweir // 101cdf0e10cSrcweir //========================================================================= 102cdf0e10cSrcweir 103cdf0e10cSrcweir XTYPEPROVIDER_IMPL_5( ContentProvider, 104cdf0e10cSrcweir lang::XTypeProvider, 105cdf0e10cSrcweir lang::XServiceInfo, 106cdf0e10cSrcweir ucb::XContentProvider, 107cdf0e10cSrcweir lang::XComponent, 108cdf0e10cSrcweir container::XContainerListener); 109cdf0e10cSrcweir 110cdf0e10cSrcweir //========================================================================= 111cdf0e10cSrcweir // 112cdf0e10cSrcweir // XServiceInfo methods. 113cdf0e10cSrcweir // 114cdf0e10cSrcweir //========================================================================= 115cdf0e10cSrcweir 116cdf0e10cSrcweir rtl::OUString SAL_CALL ContentProvider::getImplementationName() 117cdf0e10cSrcweir throw( uno::RuntimeException ) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir return getImplementationName_Static(); 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir rtl::OUString ContentProvider::getImplementationName_Static() 123cdf0e10cSrcweir { 124cdf0e10cSrcweir return rtl::OUString::createFromAscii("CHelpContentProvider" ); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir sal_Bool SAL_CALL 128cdf0e10cSrcweir ContentProvider::supportsService(const rtl::OUString& ServiceName ) 129cdf0e10cSrcweir throw( uno::RuntimeException ) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir uno::Sequence< rtl::OUString > aSNL = getSupportedServiceNames(); 132cdf0e10cSrcweir const rtl::OUString* pArray = aSNL.getArray(); 133cdf0e10cSrcweir for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir if( pArray[ i ] == ServiceName ) 136cdf0e10cSrcweir return sal_True; 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir return sal_False; 140cdf0e10cSrcweir } 141cdf0e10cSrcweir 142cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL 143cdf0e10cSrcweir ContentProvider::getSupportedServiceNames() 144cdf0e10cSrcweir throw( uno::RuntimeException ) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir return getSupportedServiceNames_Static(); 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir static uno::Reference< uno::XInterface > SAL_CALL 150cdf0e10cSrcweir ContentProvider_CreateInstance( 151cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory> & rSMgr ) 152cdf0e10cSrcweir throw( uno::Exception ) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >( 155cdf0e10cSrcweir new ContentProvider( rSMgr ) ); 156cdf0e10cSrcweir return uno::Reference< uno::XInterface >::query( pX ); 157cdf0e10cSrcweir } 158cdf0e10cSrcweir 159cdf0e10cSrcweir uno::Sequence< rtl::OUString > 160cdf0e10cSrcweir ContentProvider::getSupportedServiceNames_Static() 161cdf0e10cSrcweir { 162cdf0e10cSrcweir uno::Sequence< rtl::OUString > aSNS( 2 ); 163cdf0e10cSrcweir aSNS.getArray()[ 0 ] = 164cdf0e10cSrcweir rtl::OUString::createFromAscii( 165cdf0e10cSrcweir MYUCP_CONTENT_PROVIDER_SERVICE_NAME1 ); 166cdf0e10cSrcweir aSNS.getArray()[ 1 ] = 167cdf0e10cSrcweir rtl::OUString::createFromAscii( 168cdf0e10cSrcweir MYUCP_CONTENT_PROVIDER_SERVICE_NAME2 ); 169cdf0e10cSrcweir 170cdf0e10cSrcweir return aSNS; 171cdf0e10cSrcweir } 172cdf0e10cSrcweir 173cdf0e10cSrcweir //========================================================================= 174cdf0e10cSrcweir // 175cdf0e10cSrcweir // Service factory implementation. 176cdf0e10cSrcweir // 177cdf0e10cSrcweir //========================================================================= 178cdf0e10cSrcweir 179cdf0e10cSrcweir ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider ); 180cdf0e10cSrcweir 181cdf0e10cSrcweir //========================================================================= 182cdf0e10cSrcweir // 183cdf0e10cSrcweir // XContentProvider methods. 184cdf0e10cSrcweir // 185cdf0e10cSrcweir //========================================================================= 186cdf0e10cSrcweir 187cdf0e10cSrcweir // virtual 188cdf0e10cSrcweir uno::Reference< ucb::XContent > SAL_CALL 189cdf0e10cSrcweir ContentProvider::queryContent( 190cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& xCanonicId ) 191cdf0e10cSrcweir throw( ucb::IllegalIdentifierException, uno::RuntimeException ) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir if ( !xCanonicId->getContentProviderScheme() 194cdf0e10cSrcweir .equalsIgnoreAsciiCase( m_aScheme ) ) 195cdf0e10cSrcweir { // Wrong URL-scheme 196cdf0e10cSrcweir throw ucb::IllegalIdentifierException(); 197cdf0e10cSrcweir } 198cdf0e10cSrcweir 199cdf0e10cSrcweir { 200cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 201cdf0e10cSrcweir if( !isInitialized ) 202cdf0e10cSrcweir init(); 203cdf0e10cSrcweir } 204cdf0e10cSrcweir 205cdf0e10cSrcweir if( !m_pDatabases ) 206cdf0e10cSrcweir throw uno::RuntimeException(); 207cdf0e10cSrcweir 208cdf0e10cSrcweir rtl::OUString aOUString( m_pDatabases->getInstallPathAsURL() ); 209cdf0e10cSrcweir rtl::OString aOString( aOUString.getStr(), 210cdf0e10cSrcweir aOUString.getLength(), 211cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ); 212cdf0e10cSrcweir 213cdf0e10cSrcweir // Check, if a content with given id already exists... 214cdf0e10cSrcweir uno::Reference< ucb::XContent > xContent 215cdf0e10cSrcweir = queryExistingContent( xCanonicId ).get(); 216cdf0e10cSrcweir if ( xContent.is() ) 217cdf0e10cSrcweir return xContent; 218cdf0e10cSrcweir 219cdf0e10cSrcweir xContent = new Content( m_xSMgr, this, xCanonicId, m_pDatabases ); 220cdf0e10cSrcweir 221cdf0e10cSrcweir // register new content 222cdf0e10cSrcweir registerNewContent( xContent ); 223cdf0e10cSrcweir 224cdf0e10cSrcweir // Further checks 225cdf0e10cSrcweir 226cdf0e10cSrcweir if ( !xContent->getIdentifier().is() ) 227cdf0e10cSrcweir throw ucb::IllegalIdentifierException(); 228cdf0e10cSrcweir 229cdf0e10cSrcweir return xContent; 230cdf0e10cSrcweir } 231cdf0e10cSrcweir 232cdf0e10cSrcweir void SAL_CALL 233cdf0e10cSrcweir ContentProvider::dispose() 234cdf0e10cSrcweir throw ( uno::RuntimeException) 235cdf0e10cSrcweir { 236cdf0e10cSrcweir if(m_xContainer.is()) 237cdf0e10cSrcweir { 238cdf0e10cSrcweir m_xContainer->removeContainerListener(this); 239cdf0e10cSrcweir m_xContainer.clear(); 240cdf0e10cSrcweir } 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243cdf0e10cSrcweir void SAL_CALL 244cdf0e10cSrcweir ContentProvider::elementReplaced(const container::ContainerEvent& Event) 245cdf0e10cSrcweir throw (uno::RuntimeException) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir if(!m_pDatabases) 248cdf0e10cSrcweir return; 249cdf0e10cSrcweir 250cdf0e10cSrcweir rtl::OUString accessor; 251cdf0e10cSrcweir Event.Accessor >>= accessor; 252cdf0e10cSrcweir if(accessor.compareToAscii("HelpStyleSheet")) 253cdf0e10cSrcweir return; 254cdf0e10cSrcweir 255cdf0e10cSrcweir rtl::OUString replacedElement,element; 256cdf0e10cSrcweir Event.ReplacedElement >>= replacedElement; 257cdf0e10cSrcweir Event.Element >>= element; 258cdf0e10cSrcweir 259cdf0e10cSrcweir if(replacedElement == element) 260cdf0e10cSrcweir return; 261cdf0e10cSrcweir 262cdf0e10cSrcweir m_pDatabases->changeCSS(element); 263cdf0e10cSrcweir } 264cdf0e10cSrcweir 265cdf0e10cSrcweir void ContentProvider::init() 266cdf0e10cSrcweir { 267cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 268cdf0e10cSrcweir 269cdf0e10cSrcweir isInitialized = true; 270cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > sProvider( 271cdf0e10cSrcweir getConfiguration() ); 272cdf0e10cSrcweir uno::Reference< container::XHierarchicalNameAccess > xHierAccess( 273cdf0e10cSrcweir getHierAccess( sProvider, 274cdf0e10cSrcweir "org.openoffice.Office.Common" ) ); 275cdf0e10cSrcweir 276cdf0e10cSrcweir rtl::OUString instPath( getKey( xHierAccess,"Path/Current/Help" ) ); 277cdf0e10cSrcweir if( ! instPath.getLength() ) 278cdf0e10cSrcweir // try to determine path from default 279cdf0e10cSrcweir instPath = rtl::OUString::createFromAscii( "$(instpath)/help" ); 280cdf0e10cSrcweir // replace anything like $(instpath); 281cdf0e10cSrcweir subst( instPath ); 282cdf0e10cSrcweir 283cdf0e10cSrcweir rtl::OUString stylesheet( getKey( xHierAccess,"Help/HelpStyleSheet" ) ); 284cdf0e10cSrcweir try 285cdf0e10cSrcweir { 286cdf0e10cSrcweir // now adding as configuration change listener for the stylesheet 287cdf0e10cSrcweir uno::Reference< container::XNameAccess> xAccess( 288cdf0e10cSrcweir xHierAccess, uno::UNO_QUERY ); 289cdf0e10cSrcweir if( xAccess.is() ) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir uno::Any aAny = 292cdf0e10cSrcweir xAccess->getByName( rtl::OUString::createFromAscii( "Help" ) ); 293cdf0e10cSrcweir aAny >>= m_xContainer; 294cdf0e10cSrcweir if( m_xContainer.is() ) 295cdf0e10cSrcweir m_xContainer->addContainerListener( this ); 296cdf0e10cSrcweir } 297cdf0e10cSrcweir } 298cdf0e10cSrcweir catch( uno::Exception const & ) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir } 301cdf0e10cSrcweir 302cdf0e10cSrcweir /** 303cdf0e10cSrcweir * now determing 304cdf0e10cSrcweir * productname, 305cdf0e10cSrcweir * productversion, 306cdf0e10cSrcweir */ 307cdf0e10cSrcweir 308cdf0e10cSrcweir xHierAccess = getHierAccess( sProvider, "org.openoffice.Setup" ); 309cdf0e10cSrcweir rtl::OUString productname( 310cdf0e10cSrcweir getKey( xHierAccess,"Product/ooName" ) ); 311cdf0e10cSrcweir 312cdf0e10cSrcweir rtl::OUString setupversion( 313cdf0e10cSrcweir getKey( xHierAccess,"Product/ooSetupVersion" ) ); 314cdf0e10cSrcweir rtl::OUString setupextension; 315cdf0e10cSrcweir 316cdf0e10cSrcweir try 317cdf0e10cSrcweir { 318cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xConfigProvider( 319cdf0e10cSrcweir m_xSMgr ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), uno::UNO_QUERY_THROW); 320cdf0e10cSrcweir 321cdf0e10cSrcweir uno::Sequence < uno::Any > lParams(1); 322cdf0e10cSrcweir beans::PropertyValue aParam ; 323cdf0e10cSrcweir aParam.Name = ::rtl::OUString::createFromAscii("nodepath"); 324cdf0e10cSrcweir aParam.Value <<= ::rtl::OUString::createFromAscii("/org.openoffice.Setup/Product"); 325cdf0e10cSrcweir lParams[0] = uno::makeAny(aParam); 326cdf0e10cSrcweir 327cdf0e10cSrcweir // open it 328cdf0e10cSrcweir uno::Reference< uno::XInterface > xCFG( xConfigProvider->createInstanceWithArguments( 329cdf0e10cSrcweir ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"), 330cdf0e10cSrcweir lParams) ); 331cdf0e10cSrcweir 332cdf0e10cSrcweir uno::Reference< container::XNameAccess > xDirectAccess(xCFG, uno::UNO_QUERY); 333cdf0e10cSrcweir uno::Any aRet = xDirectAccess->getByName(::rtl::OUString::createFromAscii("ooSetupExtension")); 334cdf0e10cSrcweir 335cdf0e10cSrcweir aRet >>= setupextension; 336cdf0e10cSrcweir } 337cdf0e10cSrcweir catch ( uno::Exception& ) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir } 340cdf0e10cSrcweir 341cdf0e10cSrcweir rtl::OUString productversion( 342cdf0e10cSrcweir setupversion + 343cdf0e10cSrcweir rtl::OUString::createFromAscii( " " ) + 344cdf0e10cSrcweir setupextension ); 345cdf0e10cSrcweir 346cdf0e10cSrcweir uno::Sequence< rtl::OUString > aImagesZipPaths( 2 ); 347cdf0e10cSrcweir xHierAccess = getHierAccess( sProvider, "org.openoffice.Office.Common" ); 348cdf0e10cSrcweir 349cdf0e10cSrcweir rtl::OUString aPath( getKey( xHierAccess, "Path/Current/UserConfig" ) ); 350cdf0e10cSrcweir subst( aPath ); 351cdf0e10cSrcweir aImagesZipPaths[ 0 ] = aPath; 352cdf0e10cSrcweir 353cdf0e10cSrcweir aPath = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$OOO_BASE_DIR/share/config")); 354cdf0e10cSrcweir rtl::Bootstrap::expandMacros(aPath); 355cdf0e10cSrcweir aImagesZipPaths[ 1 ] = aPath; 356cdf0e10cSrcweir 357cdf0e10cSrcweir uno::Reference< uno::XComponentContext > xContext; 358cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( m_xSMgr, uno::UNO_QUERY ); 359cdf0e10cSrcweir OSL_ASSERT( xProps.is() ); 360cdf0e10cSrcweir if (xProps.is()) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir xProps->getPropertyValue( 363cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xContext; 364cdf0e10cSrcweir OSL_ASSERT( xContext.is() ); 365cdf0e10cSrcweir } 366cdf0e10cSrcweir 367cdf0e10cSrcweir sal_Bool showBasic = getBooleanKey(xHierAccess,"Help/ShowBasic"); 368cdf0e10cSrcweir m_pDatabases = new Databases( showBasic, 369cdf0e10cSrcweir instPath, 370cdf0e10cSrcweir aImagesZipPaths, 371cdf0e10cSrcweir productname, 372cdf0e10cSrcweir productversion, 373cdf0e10cSrcweir stylesheet, 374cdf0e10cSrcweir xContext ); 375cdf0e10cSrcweir } 376cdf0e10cSrcweir 377cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > 378cdf0e10cSrcweir ContentProvider::getConfiguration() const 379cdf0e10cSrcweir { 380cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > sProvider; 381cdf0e10cSrcweir if( m_xSMgr.is() ) 382cdf0e10cSrcweir { 383cdf0e10cSrcweir try 384cdf0e10cSrcweir { 385cdf0e10cSrcweir rtl::OUString sProviderService = 386cdf0e10cSrcweir rtl::OUString::createFromAscii( 387cdf0e10cSrcweir "com.sun.star.configuration.ConfigurationProvider" ); 388cdf0e10cSrcweir sProvider = 389cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory >( 390cdf0e10cSrcweir m_xSMgr->createInstance( sProviderService ), 391cdf0e10cSrcweir uno::UNO_QUERY ); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir catch( const uno::Exception& ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir OSL_ENSURE( sProvider.is(), "cant instantiate configuration" ); 396cdf0e10cSrcweir } 397cdf0e10cSrcweir } 398cdf0e10cSrcweir 399cdf0e10cSrcweir return sProvider; 400cdf0e10cSrcweir } 401cdf0e10cSrcweir 402cdf0e10cSrcweir uno::Reference< container::XHierarchicalNameAccess > 403cdf0e10cSrcweir ContentProvider::getHierAccess( 404cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& sProvider, 405cdf0e10cSrcweir const char* file ) const 406cdf0e10cSrcweir { 407cdf0e10cSrcweir uno::Reference< container::XHierarchicalNameAccess > xHierAccess; 408cdf0e10cSrcweir 409cdf0e10cSrcweir if( sProvider.is() ) 410cdf0e10cSrcweir { 411cdf0e10cSrcweir uno::Sequence< uno::Any > seq( 1 ); 412cdf0e10cSrcweir rtl::OUString sReaderService( 413cdf0e10cSrcweir rtl::OUString::createFromAscii( 414cdf0e10cSrcweir "com.sun.star.configuration.ConfigurationAccess" ) ); 415cdf0e10cSrcweir 416cdf0e10cSrcweir seq[ 0 ] <<= rtl::OUString::createFromAscii( file ); 417cdf0e10cSrcweir 418cdf0e10cSrcweir try 419cdf0e10cSrcweir { 420cdf0e10cSrcweir xHierAccess = 421cdf0e10cSrcweir uno::Reference< container::XHierarchicalNameAccess >( 422cdf0e10cSrcweir sProvider->createInstanceWithArguments( 423cdf0e10cSrcweir sReaderService, seq ), 424cdf0e10cSrcweir uno::UNO_QUERY ); 425cdf0e10cSrcweir } 426cdf0e10cSrcweir catch( const uno::Exception& ) 427cdf0e10cSrcweir { 428cdf0e10cSrcweir } 429cdf0e10cSrcweir } 430cdf0e10cSrcweir return xHierAccess; 431cdf0e10cSrcweir } 432cdf0e10cSrcweir 433cdf0e10cSrcweir 434cdf0e10cSrcweir 435cdf0e10cSrcweir rtl::OUString 436cdf0e10cSrcweir ContentProvider::getKey( 437cdf0e10cSrcweir const uno::Reference< container::XHierarchicalNameAccess >& xHierAccess, 438cdf0e10cSrcweir const char* key ) const 439cdf0e10cSrcweir { 440cdf0e10cSrcweir rtl::OUString instPath; 441cdf0e10cSrcweir if( xHierAccess.is() ) 442cdf0e10cSrcweir { 443cdf0e10cSrcweir uno::Any aAny; 444cdf0e10cSrcweir try 445cdf0e10cSrcweir { 446cdf0e10cSrcweir aAny = 447cdf0e10cSrcweir xHierAccess->getByHierarchicalName( 448cdf0e10cSrcweir rtl::OUString::createFromAscii( key ) ); 449cdf0e10cSrcweir } 450cdf0e10cSrcweir catch( const container::NoSuchElementException& ) 451cdf0e10cSrcweir { 452cdf0e10cSrcweir } 453cdf0e10cSrcweir aAny >>= instPath; 454cdf0e10cSrcweir } 455cdf0e10cSrcweir return instPath; 456cdf0e10cSrcweir } 457cdf0e10cSrcweir 458cdf0e10cSrcweir sal_Bool 459cdf0e10cSrcweir ContentProvider::getBooleanKey( 460cdf0e10cSrcweir const uno::Reference< container::XHierarchicalNameAccess >& xHierAccess, 461cdf0e10cSrcweir const char* key ) const 462cdf0e10cSrcweir { 463cdf0e10cSrcweir sal_Bool ret = sal_False; 464cdf0e10cSrcweir if( xHierAccess.is() ) 465cdf0e10cSrcweir { 466cdf0e10cSrcweir uno::Any aAny; 467cdf0e10cSrcweir try 468cdf0e10cSrcweir { 469cdf0e10cSrcweir aAny = 470cdf0e10cSrcweir xHierAccess->getByHierarchicalName( 471cdf0e10cSrcweir rtl::OUString::createFromAscii( key ) ); 472cdf0e10cSrcweir } 473cdf0e10cSrcweir catch( const container::NoSuchElementException& ) 474cdf0e10cSrcweir { 475cdf0e10cSrcweir } 476cdf0e10cSrcweir aAny >>= ret; 477cdf0e10cSrcweir } 478cdf0e10cSrcweir return ret; 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir void ContentProvider::subst( rtl::OUString& instpath ) const 482cdf0e10cSrcweir { 483cdf0e10cSrcweir uno::Reference< frame::XConfigManager > xCfgMgr; 484cdf0e10cSrcweir if( m_xSMgr.is() ) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir try 487cdf0e10cSrcweir { 488cdf0e10cSrcweir xCfgMgr = 489cdf0e10cSrcweir uno::Reference< frame::XConfigManager >( 490cdf0e10cSrcweir m_xSMgr->createInstance( 491cdf0e10cSrcweir rtl::OUString::createFromAscii( 492cdf0e10cSrcweir "com.sun.star.config.SpecialConfigManager" ) ), 493cdf0e10cSrcweir uno::UNO_QUERY ); 494cdf0e10cSrcweir } 495cdf0e10cSrcweir catch( const uno::Exception&) 496cdf0e10cSrcweir { 497cdf0e10cSrcweir OSL_ENSURE( xCfgMgr.is(), 498cdf0e10cSrcweir "cant instantiate the special config manager " ); 499cdf0e10cSrcweir } 500cdf0e10cSrcweir } 501cdf0e10cSrcweir 502cdf0e10cSrcweir OSL_ENSURE( xCfgMgr.is(), "specialconfigmanager not found\n" ); 503cdf0e10cSrcweir 504cdf0e10cSrcweir if( xCfgMgr.is() ) 505cdf0e10cSrcweir instpath = xCfgMgr->substituteVariables( instpath ); 506cdf0e10cSrcweir } 507