summaryrefslogtreecommitdiff
path: root/xmlhelp
diff options
context:
space:
mode:
authorAndreas Bille <abi@openoffice.org>2001-10-31 12:03:33 +0000
committerAndreas Bille <abi@openoffice.org>2001-10-31 12:03:33 +0000
commitf2ecdf1d78e9836cda5bdde9b4c709aeacf36292 (patch)
tree4b6007b00d0a846c803a042cea7721f0e1fba514 /xmlhelp
parent5e1f8e1bd855a36e9559c166bba1880d2811d3b7 (diff)
#83054#
Replacing now for the treeview the variables
Diffstat (limited to 'xmlhelp')
-rw-r--r--xmlhelp/source/treeview/tvread.cxx420
-rw-r--r--xmlhelp/source/treeview/tvread.hxx27
2 files changed, 269 insertions, 178 deletions
diff --git a/xmlhelp/source/treeview/tvread.cxx b/xmlhelp/source/treeview/tvread.cxx
index d8c774265cf8..bc426cb2f8f1 100644
--- a/xmlhelp/source/treeview/tvread.cxx
+++ b/xmlhelp/source/treeview/tvread.cxx
@@ -164,6 +164,71 @@ using namespace com::sun::star::container;
+void SAL_CALL ConfigData::replaceName( rtl::OUString& oustring ) const
+{
+ sal_Int32 idx = -1,k = 0,add,off;
+ bool cap = false;
+ rtl::OUStringBuffer aStrBuf( 0 );
+
+ while( ( idx = oustring.indexOf( sal_Unicode('%'),++idx ) ) != -1 )
+ {
+ if( oustring.indexOf( rtl::OUString::createFromAscii( "%PRODUCTNAME" ),
+ idx ) == idx )
+ {
+ add = 12;
+ off = PRODUCTNAME;
+ }
+ else if( oustring.indexOf( rtl::OUString::createFromAscii( "%PRODUCTVERSION" ),
+ idx ) == idx )
+ {
+ add = 15;
+ off = PRODUCTVERSION;
+ }
+ else if( oustring.indexOf( rtl::OUString::createFromAscii( "%VENDORNAME" ),
+ idx ) == idx )
+ {
+ add = 11;
+ off = VENDORNAME;
+ }
+ else if( oustring.indexOf( rtl::OUString::createFromAscii( "%VENDORVERSION" ),
+ idx ) == idx )
+ {
+ add = 14;
+ off = VENDORVERSION;
+ }
+ else if( oustring.indexOf( rtl::OUString::createFromAscii( "%VENDORSHORT" ),
+ idx ) == idx )
+ {
+ add = 12;
+ off = VENDORSHORT;
+ }
+ else
+ add = 0;
+
+ if( add )
+ {
+ if( ! cap )
+ {
+ cap = true;
+ aStrBuf.ensureCapacity( 256 );
+ }
+
+ aStrBuf.append( &oustring.getStr()[k],idx - k );
+ aStrBuf.append( m_vReplacement[off] );
+ k = idx + add;
+ }
+ }
+
+ if( cap )
+ {
+ if( k < oustring.getLength() )
+ aStrBuf.append( &oustring.getStr()[k],oustring.getLength()-k );
+ oustring = aStrBuf.makeStringAndClear();
+ }
+}
+
+
+
//////////////////////////////////////////////////////////////////////////
// XInterface
@@ -235,6 +300,7 @@ TVRead::TVRead( const ConfigData& configData,TVDom* tvDom )
return;
Title = tvDom->title;
+ configData.replaceName( Title );
if( tvDom->isLeaf() )
{
TargetURL = ( tvDom->getTargetURL() + configData.appendix );
@@ -585,179 +651,63 @@ TVChildTarget::hasByHierarchicalName( const rtl::OUString& aName )
ConfigData TVChildTarget::init( const Reference< XMultiServiceFactory >& xSMgr )
{
ConfigData configData;
+ Reference< XMultiServiceFactory > sProvider( getConfiguration(xSMgr) );
+
+ /**********************************************************************/
+ /* reading Office.Common */
+ /**********************************************************************/
+
+ Reference< XHierarchicalNameAccess > xHierAccess( getHierAccess( sProvider,
+ "org.openoffice.Office.Common" ) );
+ rtl::OUString system( getKey( xHierAccess,"Help/System" ) );
+ rtl::OUString instPath( getKey( xHierAccess,"Path/Current/Help" ) );
+ if( ! instPath.getLength() )
+ // try to determine path from default
+ instPath = rtl::OUString::createFromAscii( "$(instpath)/help" );
+
+ // replace anything like $(instpath);
+ subst( xSMgr,instPath );
+
+ /**********************************************************************/
+ /* reading Webtop.Common */
+ /**********************************************************************/
+
+ xHierAccess = getHierAccess( sProvider,
+ "org.openoffice.Webtop.Common" );
+ rtl::OUString vendorName( getKey( xHierAccess,"Product/ooName" ) );
+
+ rtl::OUString setupversion( getKey( xHierAccess,"Product/ooSetupVersion" ) );
+ rtl::OUString setupextension( getKey( xHierAccess,"Product/ooSetupExtension") );
+ rtl::OUString vendorVersion( setupversion +
+ rtl::OUString::createFromAscii( " " ) +
+ setupextension );
+ rtl::OUString vendorShort = vendorName;
+
+ /**********************************************************************/
+ /* reading setup */
+ /**********************************************************************/
+
+ xHierAccess = getHierAccess( sProvider,
+ "org.openoffice.Setup" );
+
+ rtl::OUString productName( getKey( xHierAccess,"Product/ooName" ) );
+ setupversion = getKey( xHierAccess,"Product/ooSetupVersion" );
+ setupextension = getKey( xHierAccess,"Product/ooSetupExtension");
+ rtl::OUString productVersion( setupversion +
+ rtl::OUString::createFromAscii( " " ) +
+ setupextension );
+ rtl::OUString locale( getKey( xHierAccess,"L10N/ooLocale" ) );
- rtl::OUString sProviderService =
- rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" );
-
- Any aAny;
- aAny <<= rtl::OUString::createFromAscii( "local" );
- PropertyValue aProp( rtl::OUString::createFromAscii( "servertype" ),
- -1,
- aAny,
- PropertyState_DIRECT_VALUE );
-
- Sequence< Any > seq(1);
- seq[0] <<= aProp;
-
- Reference< XMultiServiceFactory > sProvider;
- try
- {
- sProvider =
- Reference< XMultiServiceFactory >(
- xSMgr->createInstanceWithArguments( sProviderService,seq ),
- UNO_QUERY );
- }
- catch( const com::sun::star::uno::Exception& )
- {
- VOS_ENSHURE( sProvider.is()," cant instantiate the multiservicefactory " );
- }
-
-
- if( ! sProvider.is() )
- return configData;
-
- rtl::OUString sReaderService =
- rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" );
-
- seq[0] <<= rtl::OUString::createFromAscii( "org.openoffice.Office.Common" );
-
-
- Reference< XHierarchicalNameAccess > xHierAccess;
- try
- {
- xHierAccess =
- Reference< XHierarchicalNameAccess >
- ( sProvider->createInstanceWithArguments( sReaderService,seq ),
- UNO_QUERY );
- }
- catch( const com::sun::star::uno::Exception& )
- {
- VOS_ENSHURE( xHierAccess.is()," cant instantiate the reader service " );
- }
-
- if( ! xHierAccess.is() )
- return configData;
-
- try
- {
- aAny =
- xHierAccess->getByHierarchicalName( rtl::OUString::createFromAscii("Path/Current/Help") );
- }
- catch( const com::sun::star::container::NoSuchElementException& )
- {
- VOS_ENSHURE( false," path to help files could not be determined " );
- return configData;
- }
-
-
- rtl::OUString instPath;
- bool err = ! ( aAny >>= instPath );
-
- if( err )
- {
- VOS_ENSHURE( false," path to help files could not be determined " );
- return configData;
- }
-
- Reference< XConfigManager > xCfgMgr;
- try
- {
- xCfgMgr =
- Reference< XConfigManager >(
- xSMgr->createInstance( rtl::OUString::createFromAscii( "com.sun.star.config.SpecialConfigManager" ) ),
- UNO_QUERY );
- }
- catch( const com::sun::star::uno::Exception& )
- {
- VOS_ENSHURE( xCfgMgr.is()," cant instantiate the special config manager " );
- }
-
-
- if( ! xCfgMgr.is() )
- return configData;
-
- instPath = xCfgMgr->substituteVariables( instPath );
+ // Determine fileurl from url and locale
rtl::OUString url;
osl::FileBase::RC errFile = osl::FileBase::getFileURLFromSystemPath( instPath,url );
- if( errFile != osl::FileBase::E_None )
- return configData;
-
-
- Any aAny1;
- try
- {
- aAny1 =
- xHierAccess->getByHierarchicalName( rtl::OUString::createFromAscii("Help/System") );
- }
- catch( const com::sun::star::container::NoSuchElementException& )
- {
- VOS_ENSHURE( false," " );
- return configData;
- }
-
-
- rtl::OUString system;
- err = ! ( aAny1 >>= system );
-
- if( err )
- {
- VOS_ENSHURE( false," path to help files could not be determined " );
- return configData;
- }
-
-
- // Reading Locale
-
- seq[0] <<= rtl::OUString::createFromAscii( "org.openoffice.Setup" );
-
- try
- {
- xHierAccess =
- Reference< XHierarchicalNameAccess >
- ( sProvider->createInstanceWithArguments( sReaderService,seq ),
- UNO_QUERY );
- }
- catch( const com::sun::star::uno::Exception& )
- {
- VOS_ENSHURE( xHierAccess.is()," cant instantiate the reader service " );
- }
-
- if( ! xHierAccess.is() )
- return configData;
-
- Any aAny2;
- try
- {
- aAny2 =
- xHierAccess->getByHierarchicalName( rtl::OUString::createFromAscii("L10N/ooLocale") );
- }
- catch( const com::sun::star::container::NoSuchElementException& )
- {
- VOS_ENSHURE( false," path to help files could not be determined " );
- return configData;
- }
-
- rtl::OUString locale;
- err = ! ( aAny2 >>= locale );
-
- if( err )
- {
- VOS_ENSHURE( false," ");
- return configData;
- }
-
-
- // Determine fileurl from url and locale
-
+ if( errFile != osl::FileBase::E_None ) return configData;
if( url.lastIndexOf( sal_Unicode( '/' ) ) != url.getLength() - 1 )
url += rtl::OUString::createFromAscii( "/" );
-
rtl::OUString ret;
-
sal_Int32 idx;
osl::DirectoryItem aDirItem;
-
if( osl::FileBase::E_None == osl::DirectoryItem::get( url + locale,aDirItem ) )
ret = locale;
else if( ( ( idx = locale.indexOf( '-' ) ) != -1 ||
@@ -802,20 +752,13 @@ ConfigData TVChildTarget::init( const Reference< XMultiServiceFactory >& xSMgr )
aDirectory.close();
}
-// url = url + ret + rtl::OUString::createFromAscii( "/treeview.xml" );
-
-// // Determine the filelen
-// sal_uInt64 filelen = 0;
-
-// osl::FileStatus aStatus( FileStatusMask_FileSize );
-// if( osl::FileBase::E_None == osl::DirectoryItem::get( url,aDirItem ) &&
-// osl::FileBase::E_None == aDirItem.getFileStatus( aStatus ) &&
-// aStatus.isValid( FileStatusMask_FileSize ) )
-// filelen = aStatus.getFileSize();
-// configData.fileurl = url;
-// configData.filelen = filelen;
+ configData.m_vReplacement[0] = productName;
+ configData.m_vReplacement[1] = productVersion;
+ configData.m_vReplacement[2] = vendorName;
+ configData.m_vReplacement[3] = vendorVersion;
+ configData.m_vReplacement[4] = vendorShort;
- configData.system = system;
+ configData.system = system;
configData.locale = locale;
configData.appendix =
rtl::OUString::createFromAscii( "?Language=" ) +
@@ -825,3 +768,126 @@ ConfigData TVChildTarget::init( const Reference< XMultiServiceFactory >& xSMgr )
return configData;
}
+
+
+
+
+
+
+
+
+
+Reference< XMultiServiceFactory >
+TVChildTarget::getConfiguration(const Reference< XMultiServiceFactory >& m_xSMgr) const
+{
+ Reference< XMultiServiceFactory > sProvider;
+ if( m_xSMgr.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_xSMgr->createInstanceWithArguments( sProviderService,seq ),
+ UNO_QUERY );
+ }
+ catch( const com::sun::star::uno::Exception& )
+ {
+ OSL_ENSURE( sProvider.is(),"cant instantiate configuration" );
+ }
+ }
+
+ return sProvider;
+}
+
+
+
+Reference< XHierarchicalNameAccess >
+TVChildTarget::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
+TVChildTarget::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;
+}
+
+
+
+void TVChildTarget::subst( const Reference< XMultiServiceFactory >& m_xSMgr,
+ rtl::OUString& instpath ) const
+{
+ Reference< XConfigManager > xCfgMgr;
+ if( m_xSMgr.is() )
+ {
+ try
+ {
+ xCfgMgr =
+ Reference< XConfigManager >(
+ m_xSMgr->createInstance( rtl::OUString::createFromAscii( "com.sun.star.config.SpecialConfigManager" ) ),
+ UNO_QUERY );
+ }
+ catch( const com::sun::star::uno::Exception& e )
+ {
+ OSL_ENSURE( xCfgMgr.is()," cant instantiate the special config manager " );
+ }
+ }
+
+ OSL_ENSURE( xCfgMgr.is(), "specialconfigmanager not found\n" );
+
+ if( xCfgMgr.is() )
+ instpath = xCfgMgr->substituteVariables( instpath );
+}
diff --git a/xmlhelp/source/treeview/tvread.hxx b/xmlhelp/source/treeview/tvread.hxx
index 134a5183192d..f2da2e996c87 100644
--- a/xmlhelp/source/treeview/tvread.hxx
+++ b/xmlhelp/source/treeview/tvread.hxx
@@ -46,14 +46,23 @@
namespace treeview {
- struct ConfigData
+ class ConfigData
{
+ public:
+#define PRODUCTNAME 0
+#define PRODUCTVERSION 1
+#define VENDORNAME 2
+#define VENDORVERSION 3
+#define VENDORSHORT 4
#define MAX_MODULE_COUNT 16
+ rtl::OUString m_vReplacement[5];
sal_uInt64 filelen[MAX_MODULE_COUNT];
rtl::OUString fileurl[MAX_MODULE_COUNT];
rtl::OUString locale,system;
rtl::OUString appendix;
+
+ void SAL_CALL replaceName( rtl::OUString& oustring ) const;
};
@@ -286,6 +295,22 @@ namespace treeview {
ConfigData init(
const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xMSF );
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ getConfiguration(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSgr ) 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 subst(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSgr,
+ rtl::OUString& instpath ) const;
+
}; // end class TVChildTarget
}