summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorAndreas Bille <abi@openoffice.org>2002-10-29 12:41:23 +0000
committerAndreas Bille <abi@openoffice.org>2002-10-29 12:41:23 +0000
commita7b3844c0ab4b596b3c7180aaa921672addc0edc (patch)
treea282aa46613ee5a81d377df7c7a274ad9518186d /ucb
parenta6cda3aa22d877423feb4c2da223a1388796a802 (diff)
#92761# Removed dependency from unotoools
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/file/makefile.mk7
-rw-r--r--ucb/source/ucp/file/prov.cxx263
-rw-r--r--ucb/source/ucp/file/prov.hxx25
3 files changed, 128 insertions, 167 deletions
diff --git a/ucb/source/ucp/file/makefile.mk b/ucb/source/ucp/file/makefile.mk
index 6e13a37790df..7207fe6c9ec1 100644
--- a/ucb/source/ucp/file/makefile.mk
+++ b/ucb/source/ucp/file/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.10 $
+# $Revision: 1.11 $
#
-# last change: $Author: kso $ $Date: 2002-06-25 13:04:58 $
+# last change: $Author: abi $ $Date: 2002-10-29 13:41:23 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -101,8 +101,7 @@ SHL1STDLIBS=\
$(CPPULIB) \
$(SALLIB) \
$(VOSLIB) \
- $(UCBHELPERLIB) \
- $(UNOTOOLSLIB)
+ $(UCBHELPERLIB)
.IF "$(OS)"=="MACOSX"
.ELSE
diff --git a/ucb/source/ucp/file/prov.cxx b/ucb/source/ucp/file/prov.cxx
index bbd60f7dd8f9..61485054fa4c 100644
--- a/ucb/source/ucp/file/prov.cxx
+++ b/ucb/source/ucp/file/prov.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: prov.cxx,v $
*
- * $Revision: 1.34 $
+ * $Revision: 1.35 $
*
- * last change: $Author: abi $ $Date: 2002-04-25 10:54:26 $
+ * last change: $Author: abi $ $Date: 2002-10-29 13:41:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -107,7 +107,6 @@
#include "prov.hxx"
#endif
-#include <unotools/configmgr.hxx>
#include <algorithm>
@@ -117,7 +116,7 @@ using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
using namespace com::sun::star::ucb;
-
+using namespace com::sun::star::container;
//=========================================================================
static sal_Bool writeInfo( void * pRegistryKey,
@@ -339,153 +338,6 @@ FileProvider::FileProvider( const Reference< XMultiServiceFactory >& xMultiServi
}
-
-// FileProvider::FileProvider( const Reference< XMultiServiceFactory >& xMultiServiceFactory )
-// : m_xMultiServiceFactory( xMultiServiceFactory ),
-// m_pMyShell( 0 )
-// {
-// if( ! m_pMyShell )
-// m_pMyShell = new shell( m_xMultiServiceFactory, this );
-
-// try
-// {
-// rtl::OUString sProviderService =
-// rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" );
-
-
-// // New access to configuration with locally cached components
-// rtl::OUString plugin = rtl::OUString::createFromAscii( "plugin" );
-// Any aAny;
-// aAny <<= plugin;
-// PropertyValue aProp( rtl::OUString::createFromAscii( "servertype" ),
-// -1,
-// aAny,
-// PropertyState_DIRECT_VALUE );
-
-// Sequence< Any > seq(1);
-// seq[0] <<= aProp;
-
-// Reference< XMultiServiceFactory >
-// sProvider(
-// m_xMultiServiceFactory->createInstanceWithArguments( sProviderService,seq ),
-// UNO_QUERY );
-
-
-// /*
-// // Old access to configuration without locally cached components
-// Reference< XMultiServiceFactory >
-// sProvider(
-// m_xMultiServiceFactory->createInstance( sProviderService ),
-// UNO_QUERY );
-// */
-
-// rtl::OUString sReaderService =
-// rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" );
-
-// Sequence< Any > aArguments( 1 );
-
-// aArguments[0] <<=
-// rtl::OUString::createFromAscii( "org.openoffice.Webtop.Security" );
-
-// Reference< container::XHierarchicalNameAccess > xHierAccess;
-// if( sProvider.is() )
-// xHierAccess =
-// Reference< container::XHierarchicalNameAccess >(
-// sProvider->createInstanceWithArguments( sReaderService,aArguments ),
-// UNO_QUERY );
-
-// Reference< container::XNameAccess > xSubNode;
-// if( xHierAccess.is() )
-// xSubNode = Reference< container::XNameAccess >( xHierAccess,UNO_QUERY );
-
-// rtl::OUString d = rtl::OUString::createFromAscii( "oowSecDir" );
-// rtl::OUString a = rtl::OUString::createFromAscii( "oowSecAlias" );
-
-// rtl::OUString aRootDirectory;
-// if( xSubNode.is() )
-// {
-// Any aAny = xSubNode->getByName( rtl::OUString::createFromAscii("MountPoints" ) );
-// Reference< container::XNameAccess > xSubSubNode;
-// aAny >>= xSubSubNode;
-
-// Sequence< rtl::OUString > seqNames =
-// xSubSubNode->getElementNames();
-// for( sal_Int32 k = 0; k < seqNames.getLength(); ++k )
-// {
-// Any nocheinany = xSubSubNode->getByName( seqNames[k] );
-// Reference< container::XNameAccess > xAuaAuaAuaNode;
-// nocheinany >>= xAuaAuaAuaNode;
-
-// Any vorletztesany = xAuaAuaAuaNode->getByName( d );
-// rtl::OUString aDirectory;
-// vorletztesany >>= aDirectory;
-
-// Any letztesany = xAuaAuaAuaNode->getByName( a );
-// rtl::OUString aAliasName;
-// letztesany >>= aAliasName;
-
-// rtl::OUString aUnqDir;
-// rtl::OUString aUnqAl;
-
-// initSubstVars();
-
-// rtl::OUString aDir = subst( aDirectory );
-// // old,assuming URL: osl::FileBase::getNormalizedPathFromFileURL( aDir, aUnqDir );
-// // new, assuming system path:
-// osl::FileBase::getFileURLFromSystemPath( aDir,aUnqDir );
-
-// rtl::OUString aAlias = subst( aAliasName );
-// // old, assuming URL: osl::FileBase::getNormalizedPathFromFileURL( aAlias, aUnqAl );
-// // new, assuming system path:
-// osl::FileBase::getFileURLFromSystemPath( aAlias,aUnqAl );
-
-// if ( !aUnqDir.getLength() )
-// osl::FileBase::getFileURLFromSystemPath( aDirectory,aUnqDir );
-// // m_pMyShell->getUnqFromUrl( aDirectory,aUnqDir );
-
-// if ( !aUnqAl.getLength() )
-// osl::FileBase::getFileURLFromSystemPath( aAliasName,aUnqAl );
-// // m_pMyShell->getUnqFromUrl( aAliasName,aUnqAl );
-
-// rtl::OUString aRealUnqDir;
-// rtl::OUString aRealUnqAlias;
-
-// getResolvedURL( aUnqDir.pData, &aRealUnqDir.pData );
-// aRealUnqAlias = aUnqAl;
-
-// if ( !aRealUnqAlias.getLength() )
-// aRealUnqAlias = aUnqAl;
-
-// if ( aRealUnqDir.getLength() && aRealUnqAlias.getLength() )
-// {
-// m_pMyShell->m_vecMountPoint.push_back(
-// shell::MountPoint( aRealUnqAlias, aRealUnqDir ) );
-// m_pMyShell->m_bFaked = true;
-// }
-
-// }
-
-// // Cut trailing slashes
-
-// for ( sal_uInt32 j = 0; j < m_pMyShell->m_vecMountPoint.size(); j++ )
-// {
-// sal_Int32 nLen = m_pMyShell->m_vecMountPoint[j].m_aDirectory.getLength();
-
-// if ( m_pMyShell->m_vecMountPoint[j].m_aDirectory.lastIndexOf( '/' ) == nLen - 1 )
-// m_pMyShell->m_vecMountPoint[j].m_aDirectory = m_pMyShell->m_vecMountPoint[j].m_aDirectory.copy( 0, nLen - 1 );
-// }
-
-// // Now sort the mount point entries according to the length
-
-// std::stable_sort( m_pMyShell->m_vecMountPoint.begin(), m_pMyShell->m_vecMountPoint.end(), moreLength );
-// }
-// }
-// catch( ... )
-// {
-
-// }
-// }
-
FileProvider::~FileProvider()
{
if( m_pMyShell )
@@ -1054,20 +906,19 @@ rtl::OUString SAL_CALL FileProvider::getSystemPathFromFileURL( const rtl::OUStri
////////////////////////
void SAL_CALL FileProvider::initSubstVars()
{
- m_sUserPath = rtl::OUString();
- m_sInstPath = rtl::OUString();
+ Reference<XMultiServiceFactory> sProvider(getConfiguration());
+ Reference<XHierarchicalNameAccess>
+ xHierAccess( getHierAccess(sProvider,
+ "org.openoffice.Office.Common"));
+ m_sInstPath = getKey(xHierAccess,"Path/Current/OfficeInstall");
- utl::ConfigManager* pCfgMgr = utl::ConfigManager::GetConfigManager();
- if( pCfgMgr != NULL )
- {
- com::sun::star::uno::Any aAny = pCfgMgr->GetDirectConfigProperty( utl::ConfigManager::OFFICEINSTALL );
- aAny >>= m_sInstPath;
- aAny = pCfgMgr->GetDirectConfigProperty( utl::ConfigManager::INSTALLPATH );
- aAny >>= m_sUserPath;
- }
+ xHierAccess = getHierAccess(sProvider,
+ "org.openoffice.Setup");
+ m_sUserPath = getKey(xHierAccess,"Office/ooSetupInstallPath");
}
+
void SAL_CALL FileProvider::subst( rtl::OUString& sValue )
{
if( sValue.compareToAscii( "$(userpath)" ) == 0 )
@@ -1075,3 +926,93 @@ void SAL_CALL FileProvider::subst( rtl::OUString& sValue )
else if( sValue.compareToAscii( "$(instpath)" ) == 0 )
sValue = m_sInstPath;
}
+
+
+
+Reference< XMultiServiceFactory > FileProvider::getConfiguration() const
+{
+ Reference< XMultiServiceFactory > sProvider;
+ if( m_xMultiServiceFactory.is() )
+ {
+ Any aAny;
+ aAny <<= rtl::OUString::createFromAscii( "plugin" );
+ PropertyValue aProp( rtl::OUString::createFromAscii( "servertype" ),
+ -1,
+ aAny,
+ PropertyState_DIRECT_VALUE );
+
+ Sequence< Any > seq(1);
+ seq[0] <<= aProp;
+
+ try
+ {
+ rtl::OUString sProviderService =
+ rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" );
+ sProvider =
+ Reference< XMultiServiceFactory >(
+ m_xMultiServiceFactory->createInstanceWithArguments(
+ sProviderService,seq ),
+ UNO_QUERY );
+ }
+ catch( const com::sun::star::uno::Exception& )
+ {
+ OSL_ENSURE( sProvider.is(),"cant instantiate configuration" );
+ }
+ }
+
+ return sProvider;
+}
+
+
+
+Reference< XHierarchicalNameAccess >
+FileProvider::getHierAccess( const Reference< XMultiServiceFactory >& sProvider,
+ const char* file ) const
+{
+ Reference< XHierarchicalNameAccess > xHierAccess;
+
+ if( sProvider.is() )
+ {
+ Sequence< Any > seq(1);
+ rtl::OUString sReaderService =
+ rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" );
+
+ seq[0] <<= rtl::OUString::createFromAscii( file );
+
+ try
+ {
+ xHierAccess =
+ Reference< XHierarchicalNameAccess >
+ ( sProvider->createInstanceWithArguments( sReaderService,seq ),
+ UNO_QUERY );
+ }
+ catch( const com::sun::star::uno::Exception& )
+ {
+ }
+ }
+
+ return xHierAccess;
+}
+
+
+
+rtl::OUString
+FileProvider::getKey( const Reference< XHierarchicalNameAccess >& xHierAccess,
+ const char* key ) const
+{
+ rtl::OUString instPath;
+ if( xHierAccess.is() )
+ {
+ Any aAny;
+ try
+ {
+ aAny =
+ xHierAccess->getByHierarchicalName( rtl::OUString::createFromAscii( key ) );
+ }
+ catch( const com::sun::star::container::NoSuchElementException& )
+ {
+ }
+ aAny >>= instPath;
+ }
+ return instPath;
+}
diff --git a/ucb/source/ucp/file/prov.hxx b/ucb/source/ucp/file/prov.hxx
index d3fd5ec65059..48dffedbea2a 100644
--- a/ucb/source/ucp/file/prov.hxx
+++ b/ucb/source/ucp/file/prov.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: prov.hxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: abi $ $Date: 2002-04-25 10:54:26 $
+ * last change: $Author: abi $ $Date: 2002-10-29 13:41:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -98,6 +98,9 @@
#ifndef _COM_SUN_STAR_UCB_XFILEIDENTIFIERCONVERTER_HPP_
#include <com/sun/star/ucb/XFileIdentifierConverter.hpp>
#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#endif
// FileProvider
@@ -270,8 +273,26 @@ namespace fileaccess {
private:
// methods
+
+ com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >
+ getConfiguration() const;
+
+ com::sun::star::uno::Reference<
+ com::sun::star::container::XHierarchicalNameAccess >
+ getHierAccess( const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >& sProvider,
+ const char* file ) const;
+
+ rtl::OUString
+ getKey( const com::sun::star::uno::Reference<
+ com::sun::star::container::XHierarchicalNameAccess >&
+ xHierAccess,
+ const char* key ) const;
+
void SAL_CALL initSubstVars( void );
void SAL_CALL subst( rtl::OUString& sValue );
+
rtl::OUString m_sInstPath;
rtl::OUString m_sUserPath;