Files
libreoffice/xmlhelp/source/treeview/tvread.cxx

968 lines
26 KiB
C++
Raw Normal View History

/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: tvread.cxx,v $
*
* $Revision: 1.22 $
*
* last change: $Author: vg $ $Date: 2006-11-01 13:50:18 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_xmlhelp.hxx"
2001-07-11 14:35:25 +00:00
#include <string.h>
#ifndef _RTL_USTRBUF_HXX_
#include <rtl/ustrbuf.hxx>
#endif
2001-07-12 12:32:24 +00:00
#ifndef _VOS_DIAGNOSE_HXX_
#include <vos/diagnose.hxx>
#endif
#ifndef _TREEVIEW_TVREAD_HXX_
#include "tvread.hxx"
#endif
#ifdef SYSTEM_EXPAT
#include <expat.h>
#else
2001-07-11 14:35:25 +00:00
#ifndef XmlParse_INCLUDED
#include <expat/xmlparse.h>
#endif
#endif
2001-07-11 14:35:25 +00:00
#ifndef _OSL_FILE_HXX_
#include <osl/file.hxx>
#endif
2001-07-12 12:32:24 +00:00
#ifndef _COM_SUN_STAR_FRAME_XCONFIGMANAGER_HPP_
#include <com/sun/star/frame/XConfigManager.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
#include <com/sun/star/beans/PropertyValue.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTYSTATE_HPP_
#include <com/sun/star/beans/PropertyState.hpp>
#endif
namespace treeview {
class TVDom
{
friend class TVChildTarget;
friend class TVRead;
public:
TVDom( TVDom* arent = 0 )
: kind( other ),
parent( arent ),
childs( 0 )
2001-07-12 12:32:24 +00:00
{
}
~TVDom()
{
for( unsigned i = 0; i < childs.size(); ++i )
delete childs[i];
}
TVDom* newChild()
{
childs.push_back( new TVDom( this ) );
return childs.back();
}
TVDom* getParent() const
{
if( parent )
return parent;
else
return const_cast<TVDom*>(this); // I am my own parent, if I am the root
2001-07-12 12:32:24 +00:00
}
enum Kind {
tree_view,
tree_node,
tree_leaf,
other
};
bool isLeaf() const { return kind == TVDom::tree_leaf; }
void setKind( Kind ind ) { kind = ind; }
Kind getKind( ) const { return kind; }
void setApplication( const char* appl )
{
application = rtl::OUString( (sal_Char*)(appl),
strlen( appl ),
RTL_TEXTENCODING_UTF8 );
}
void setTitle( const char* itle )
{
title += rtl::OUString( (sal_Char*)(itle),
strlen( itle ),
RTL_TEXTENCODING_UTF8 );
2001-07-12 12:32:24 +00:00
}
void setTitle( const XML_Char* itle,int len )
{
title += rtl::OUString( (sal_Char*)(itle),
len,
RTL_TEXTENCODING_UTF8 );
2001-07-12 12:32:24 +00:00
}
void setId( const char* d )
{
id = rtl::OUString( (sal_Char*)(d),
strlen( d ),
RTL_TEXTENCODING_UTF8 );
}
void setAnchor( const char* nchor )
{
anchor = rtl::OUString( (sal_Char*)(nchor),
strlen( nchor ),
RTL_TEXTENCODING_UTF8 );
}
rtl::OUString getTargetURL()
{
if( ! targetURL.getLength() )
{
sal_Int32 len;
for ( const TVDom* p = this;; p = p->parent )
{
len = p->application.getLength();
if ( len != 0 )
break;
}
2001-07-12 12:32:24 +00:00
rtl::OUStringBuffer strBuff( 22 + len + id.getLength() );
strBuff.appendAscii(
"vnd.sun.star.help://"
).append(id);
targetURL = strBuff.makeStringAndClear();
2001-07-12 12:32:24 +00:00
}
return targetURL;
}
private:
Kind kind;
rtl::OUString application;
rtl::OUString title;
rtl::OUString id;
rtl::OUString anchor;
rtl::OUString targetURL;
TVDom *parent;
std::vector< TVDom* > childs;
};
}
2001-07-11 14:35:25 +00:00
using namespace treeview;
using namespace com::sun::star;
using namespace com::sun::star::uno;
2001-07-12 12:32:24 +00:00
using namespace com::sun::star::beans;
using namespace com::sun::star::lang;
using namespace com::sun::star::util;
2001-07-12 12:32:24 +00:00
using namespace com::sun::star::frame;
using namespace com::sun::star::container;
2001-10-31 12:53:36 +00:00
ConfigData::ConfigData()
: prodName( rtl::OUString::createFromAscii( "%PRODUCTNAME" ) ),
prodVersion( rtl::OUString::createFromAscii( "%PRODUCTVERSION" ) ),
vendName( rtl::OUString::createFromAscii( "%VENDORNAME" ) ),
vendVersion( rtl::OUString::createFromAscii( "%VENDORVERSION" ) ),
vendShort( rtl::OUString::createFromAscii( "%VENDORSHORT" ) )
{
}
void SAL_CALL ConfigData::replaceName( rtl::OUString& oustring ) const
{
2001-10-31 12:53:36 +00:00
sal_Int32 idx = -1,k = 0,off;
bool cap = false;
rtl::OUStringBuffer aStrBuf( 0 );
while( ( idx = oustring.indexOf( sal_Unicode('%'),++idx ) ) != -1 )
{
2001-10-31 12:53:36 +00:00
if( oustring.indexOf( prodName,idx ) == idx )
off = PRODUCTNAME;
2001-10-31 12:53:36 +00:00
else if( oustring.indexOf( prodVersion,idx ) == idx )
off = PRODUCTVERSION;
2001-10-31 12:53:36 +00:00
else if( oustring.indexOf( vendName,idx ) == idx )
off = VENDORNAME;
2001-10-31 12:53:36 +00:00
else if( oustring.indexOf( vendVersion,idx ) == idx )
off = VENDORVERSION;
2001-10-31 12:53:36 +00:00
else if( oustring.indexOf( vendShort,idx ) == idx )
off = VENDORSHORT;
else
2001-10-31 12:53:36 +00:00
off = -1;
2001-10-31 12:53:36 +00:00
if( off != -1 )
{
if( ! cap )
{
cap = true;
aStrBuf.ensureCapacity( 256 );
}
aStrBuf.append( &oustring.getStr()[k],idx - k );
aStrBuf.append( m_vReplacement[off] );
2001-10-31 12:53:36 +00:00
k = idx + m_vAdd[off];
}
}
if( cap )
{
if( k < oustring.getLength() )
aStrBuf.append( &oustring.getStr()[k],oustring.getLength()-k );
oustring = aStrBuf.makeStringAndClear();
}
}
//////////////////////////////////////////////////////////////////////////
// XInterface
//////////////////////////////////////////////////////////////////////////
void SAL_CALL
2001-07-12 14:48:32 +00:00
TVBase::acquire(
void )
2001-10-26 10:42:02 +00:00
throw()
{
OWeakObject::acquire();
}
void SAL_CALL
2001-07-12 14:48:32 +00:00
TVBase::release(
void )
2001-10-26 10:42:02 +00:00
throw()
{
OWeakObject::release();
}
Any SAL_CALL
2001-07-12 14:48:32 +00:00
TVBase::queryInterface(
const Type& rType )
throw( RuntimeException )
{
Any aRet = cppu::queryInterface( rType,
SAL_STATIC_CAST( XTypeProvider*, this ),
SAL_STATIC_CAST( XNameAccess*, this ),
SAL_STATIC_CAST( XHierarchicalNameAccess*, this ),
SAL_STATIC_CAST( XChangesNotifier*, this ),
SAL_STATIC_CAST( XComponent*, this ) );
return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
}
////////////////////////////////////////////////////////////////////////////////
//
// XTypeProvider methods.
2001-07-12 14:48:32 +00:00
XTYPEPROVIDER_IMPL_5( TVBase,
XTypeProvider,
XNameAccess,
XHierarchicalNameAccess,
XChangesNotifier,
XComponent );
2001-07-12 14:48:32 +00:00
// TVRead
TVRead::TVRead()
{
}
TVRead::TVRead( const ConfigData& configData,TVDom* tvDom )
{
if( ! tvDom )
return;
Title = tvDom->title;
configData.replaceName( Title );
2001-07-12 14:48:32 +00:00
if( tvDom->isLeaf() )
{
TargetURL = ( tvDom->getTargetURL() + configData.appendix );
if( tvDom->anchor.getLength() )
TargetURL += ( rtl::OUString::createFromAscii( "#" ) +
tvDom->anchor );
}
else
Children = new TVChildTarget( configData,tvDom );
}
TVRead::~TVRead()
{
}
// XNameAccess
Any SAL_CALL
TVRead::getByName( const rtl::OUString& aName )
throw( NoSuchElementException,
WrappedTargetException,
2001-07-11 14:35:25 +00:00
RuntimeException )
{
2001-07-11 14:35:25 +00:00
bool found( true );
Any aAny;
if( aName.compareToAscii( "Title" ) == 0 )
aAny <<= Title;
else if( aName.compareToAscii( "TargetURL" ) == 0 )
aAny <<= TargetURL;
2001-07-11 14:35:25 +00:00
else if( aName.compareToAscii( "Children" ) == 0 )
{
2001-07-11 14:35:25 +00:00
cppu::OWeakObject* p = Children.get();
aAny <<= Reference< XInterface >( p );
}
2001-07-11 14:35:25 +00:00
else
found = false;
2001-07-11 14:35:25 +00:00
if( found )
return aAny;
throw NoSuchElementException();
}
Sequence< rtl::OUString > SAL_CALL
TVRead::getElementNames( )
throw( RuntimeException )
{
2001-07-11 14:35:25 +00:00
Sequence< rtl::OUString > seq( 3 );
seq[0] = rtl::OUString::createFromAscii( "Title" );
seq[1] = rtl::OUString::createFromAscii( "TargetURL" );
seq[2] = rtl::OUString::createFromAscii( "Children" );
return seq;
}
sal_Bool SAL_CALL
TVRead::hasByName( const rtl::OUString& aName )
throw( RuntimeException )
{
if( aName.compareToAscii( "Title" ) == 0 ||
2001-07-11 14:35:25 +00:00
aName.compareToAscii( "TargetURL" ) == 0 ||
aName.compareToAscii( "Children" ) == 0 )
return true;
return false;
}
// XHierarchicalNameAccess
Any SAL_CALL
TVRead::getByHierarchicalName( const rtl::OUString& aName )
throw( NoSuchElementException,
RuntimeException )
{
sal_Int32 idx;
rtl::OUString name( aName );
2001-07-11 14:35:25 +00:00
if( ( idx = name.indexOf( sal_Unicode( '/' ) ) ) != -1 &&
name.copy( 0,idx ).compareToAscii( "Children" ) == 0 )
return Children->getByHierarchicalName( name.copy( 1 + idx ) );
return getByName( name );
}
sal_Bool SAL_CALL
TVRead::hasByHierarchicalName( const rtl::OUString& aName )
throw( RuntimeException )
{
sal_Int32 idx;
rtl::OUString name( aName );
if( ( idx = name.indexOf( sal_Unicode( '/' ) ) ) != -1 &&
name.copy( 0,idx ).compareToAscii( "Children" ) == 0 )
return Children->hasByHierarchicalName( name.copy( 1 + idx ) );
return hasByName( name );
}
/**************************************************************************/
/* */
/* TVChildTarget */
/* */
/**************************************************************************/
extern "C" void start_handler(void *userData,
2001-07-11 14:35:25 +00:00
const XML_Char *name,
const XML_Char **atts)
{
2001-07-12 12:32:24 +00:00
TVDom::Kind kind;
2001-07-11 14:35:25 +00:00
2001-07-12 12:32:24 +00:00
if( strcmp( name,"help_section" ) == 0 ||
strcmp( name,"node" ) == 0 )
kind = TVDom::tree_node;
else if( strcmp( name,"topic" ) == 0 )
kind = TVDom::tree_leaf;
else
return;
2001-07-11 14:35:25 +00:00
2001-07-12 12:32:24 +00:00
TVDom **tvDom = static_cast< TVDom** >( userData );
TVDom *p;
p = *tvDom;
2001-07-11 14:35:25 +00:00
2001-07-12 13:35:29 +00:00
*tvDom = p->newChild();
p = *tvDom;
2001-07-11 14:35:25 +00:00
2001-07-12 12:32:24 +00:00
p->setKind( kind );
while( *atts )
{
if( strcmp( *atts,"application" ) == 0 )
p->setApplication( *(atts+1) );
else if( strcmp( *atts,"title" ) == 0 )
p->setTitle( *(atts+1) );
else if( strcmp( *atts,"id" ) == 0 )
p->setId( *(atts+1) );
else if( strcmp( *atts,"anchor" ) == 0 )
p->setAnchor( *(atts+1) );
atts+=2;
2001-07-11 14:35:25 +00:00
}
}
extern "C" void end_handler(void *userData,
2001-07-11 14:35:25 +00:00
const XML_Char *name )
{
(void)name;
2001-07-12 12:32:24 +00:00
TVDom **tvDom = static_cast< TVDom** >( userData );
2001-07-12 13:35:29 +00:00
*tvDom = (*tvDom)->getParent();
2001-07-11 14:35:25 +00:00
}
extern "C" void data_handler( void *userData,
2001-07-11 14:35:25 +00:00
const XML_Char *s,
int len)
{
2001-07-12 12:32:24 +00:00
TVDom **tvDom = static_cast< TVDom** >( userData );
if( (*tvDom)->isLeaf() )
(*tvDom)->setTitle( s,len );
2001-07-11 14:35:25 +00:00
}
2001-07-12 12:32:24 +00:00
TVChildTarget::TVChildTarget( const ConfigData& configData,TVDom* tvDom )
2001-07-11 14:35:25 +00:00
{
2001-07-12 12:32:24 +00:00
Elements.resize( tvDom->childs.size() );
for( unsigned i = 0; i < Elements.size(); ++i )
Elements[i] = new TVRead( configData,tvDom->childs[i] );
2001-07-11 14:35:25 +00:00
}
2001-07-12 12:32:24 +00:00
TVChildTarget::TVChildTarget( const Reference< XMultiServiceFactory >& xMSF )
2001-07-11 14:35:25 +00:00
{
2001-07-12 12:32:24 +00:00
ConfigData configData = init( xMSF );
2001-07-11 14:35:25 +00:00
if( ! configData.locale.getLength() ||
! configData.system.getLength() )
2001-07-12 12:32:24 +00:00
return;
2001-07-11 14:35:25 +00:00
sal_uInt64 ret,len = 0;
int j = 0;
2001-07-11 14:35:25 +00:00
// Count number of items
while( configData.fileurl[j].getLength() )
++j;
2001-07-11 14:35:25 +00:00
2001-07-12 12:32:24 +00:00
TVDom tvDom;
TVDom* pTVDom = &tvDom;
2001-07-11 14:35:25 +00:00
while( j )
{
len = configData.filelen[--j];
char* s = new char[ int(len) ]; // the buffer to hold the installed files
osl::File aFile( configData.fileurl[j] );
aFile.open( OpenFlag_Read );
aFile.read( s,len,ret );
aFile.close();
XML_Parser parser = XML_ParserCreate( 0 );
XML_SetElementHandler( parser,
start_handler,
end_handler );
XML_SetCharacterDataHandler( parser,
data_handler);
XML_SetUserData( parser,&pTVDom ); // does not return this
int parsed = XML_Parse( parser,s,int( len ),j==0 );
(void)parsed;
XML_ParserFree( parser );
delete[] s;
}
2001-07-12 12:32:24 +00:00
// now TVDom holds the relevant information
Elements.resize( tvDom.childs.size() );
for( unsigned i = 0; i < Elements.size(); ++i )
Elements[i] = new TVRead( configData,tvDom.childs[i] );
2001-07-11 14:35:25 +00:00
}
TVChildTarget::~TVChildTarget()
{
}
Any SAL_CALL
TVChildTarget::getByName( const rtl::OUString& aName )
throw( NoSuchElementException,
WrappedTargetException,
RuntimeException )
{
2001-07-12 14:33:36 +00:00
rtl::OUString num( aName.getStr()+2,aName.getLength()-4 );
sal_Int32 idx = num.toInt32() - 1;
2001-07-11 14:35:25 +00:00
if( idx < 0 || Elements.size() <= sal_uInt32( idx ) )
throw NoSuchElementException();
Any aAny;
cppu::OWeakObject* p = Elements[idx].get();
aAny <<= Reference< XInterface >( p );
return aAny;
}
Sequence< rtl::OUString > SAL_CALL
TVChildTarget::getElementNames( )
throw( RuntimeException )
{
Sequence< rtl::OUString > seq( Elements.size() );
for( unsigned i = 0; i < Elements.size(); ++i )
seq[i] = rtl::OUString::valueOf( sal_Int32( 1+i ) );
return seq;
}
sal_Bool SAL_CALL
TVChildTarget::hasByName( const rtl::OUString& aName )
throw( RuntimeException )
{
2001-07-12 14:33:36 +00:00
rtl::OUString num( aName.getStr()+2,aName.getLength()-4 );
sal_Int32 idx = num.toInt32() - 1;
2001-07-11 14:35:25 +00:00
if( idx < 0 || Elements.size() <= sal_uInt32( idx ) )
return false;
return true;
}
// XHierarchicalNameAccess
Any SAL_CALL
TVChildTarget::getByHierarchicalName( const rtl::OUString& aName )
throw( NoSuchElementException,
RuntimeException )
{
sal_Int32 idx;
rtl::OUString name( aName );
if( ( idx = name.indexOf( sal_Unicode( '/' ) ) ) != -1 )
{
2001-07-12 14:33:36 +00:00
rtl::OUString num( name.getStr()+2,idx-4 );
sal_Int32 pref = num.toInt32() - 1;
2001-07-11 14:35:25 +00:00
if( pref < 0 || Elements.size() <= sal_uInt32( pref ) )
throw NoSuchElementException();
2001-07-11 14:35:25 +00:00
return Elements[pref]->getByHierarchicalName( name.copy( 1 + idx ) );
}
else
return getByName( name );
}
sal_Bool SAL_CALL
2001-07-11 14:35:25 +00:00
TVChildTarget::hasByHierarchicalName( const rtl::OUString& aName )
throw( RuntimeException )
{
sal_Int32 idx;
rtl::OUString name( aName );
2001-07-11 14:35:25 +00:00
if( ( idx = name.indexOf( sal_Unicode( '/' ) ) ) != -1 )
{
2001-07-12 14:33:36 +00:00
rtl::OUString num( name.getStr()+2,idx-4 );
sal_Int32 pref = num.toInt32() - 1;
2001-07-11 14:35:25 +00:00
if( pref < 0 || Elements.size() <= sal_uInt32( pref ) )
return false;
2001-07-11 14:35:25 +00:00
return Elements[pref]->hasByHierarchicalName( name.copy( 1 + idx ) );
}
else
return hasByName( name );
}
2001-07-12 12:32:24 +00:00
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" ) );
sal_Bool showBasic( getBooleanKey(xHierAccess,"Help/ShowBasic") );
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" ) );
2001-07-12 12:32:24 +00:00
// Determine fileurl from url and locale
2001-07-12 12:32:24 +00:00
rtl::OUString url;
osl::FileBase::RC errFile = osl::FileBase::getFileURLFromSystemPath( instPath,url );
if( errFile != osl::FileBase::E_None ) return configData;
2001-07-12 12:32:24 +00:00
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 ||
( idx = locale.indexOf( '_' ) ) != -1 ) &&
osl::FileBase::E_None == osl::DirectoryItem::get( url + locale.copy( 0,idx ),
aDirItem ) )
ret = locale.copy( 0,idx );
else
{
locale = rtl::OUString::createFromAscii( "en-US" );
ret = rtl::OUString::createFromAscii("en");
}
url = url + ret;
2001-07-12 12:32:24 +00:00
// first of all, try do determine whether there are any *.tree files present
2001-07-12 12:32:24 +00:00
osl::Directory aDirectory( url );
osl::FileStatus aFileStatus( FileStatusMask_FileName | FileStatusMask_FileSize | FileStatusMask_FileURL );
if( osl::Directory::E_None == aDirectory.open() )
{
int idx_ = 0,j = 0;
rtl::OUString aFileUrl, aFileName;
while( aDirectory.getNextItem( aDirItem ) == osl::FileBase::E_None &&
aDirItem.getFileStatus( aFileStatus ) == osl::FileBase::E_None &&
aFileStatus.isValid( FileStatusMask_FileURL ) &&
aFileStatus.isValid( FileStatusMask_FileName ) )
{
aFileUrl = aFileStatus.getFileURL();
aFileName = aFileStatus.getFileName();
idx_ = aFileName.lastIndexOf( sal_Unicode( '.' ) );
if( idx_ == -1 )
continue;
const sal_Unicode* str = aFileName.getStr();
if( aFileName.getLength() == idx_ + 5 &&
( str[idx_ + 1] == 't' || str[idx_ + 1] == 'T' ) &&
( str[idx_ + 2] == 'r' || str[idx_ + 2] == 'R' ) &&
( str[idx_ + 3] == 'e' || str[idx_ + 3] == 'E' ) &&
( str[idx_ + 4] == 'e' || str[idx_ + 4] == 'E' ) )
{
OSL_ENSURE( j < MAX_MODULE_COUNT,"too many modules installed" );
OSL_ENSURE( aFileStatus.isValid( FileStatusMask_FileSize ),
"invalid file size" );
rtl::OUString baseName = aFileName.copy(0,idx_).toAsciiLowerCase();
if(! showBasic && baseName.compareToAscii("sbasic") == 0 )
continue;
configData.filelen[j] = aFileStatus.getFileSize();
configData.fileurl[j++] = aFileUrl ;
}
}
aDirectory.close();
}
2001-10-31 12:53:36 +00:00
configData.m_vAdd[0] = 12;
configData.m_vAdd[1] = 15;
configData.m_vAdd[2] = 11;
configData.m_vAdd[3] = 14;
configData.m_vAdd[4] = 12;
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;
2001-07-12 12:32:24 +00:00
configData.system = system;
2001-07-12 12:32:24 +00:00
configData.locale = locale;
configData.appendix =
rtl::OUString::createFromAscii( "?Language=" ) +
configData.locale +
rtl::OUString::createFromAscii( "&System=" ) +
configData.system +
rtl::OUString::createFromAscii( "&UseDB=no" ) ;
2001-07-12 12:32:24 +00:00
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;
}
sal_Bool
TVChildTarget::getBooleanKey(const Reference<
XHierarchicalNameAccess >& xHierAccess,
const char* key) const
{
sal_Bool ret = sal_False;
if( xHierAccess.is() )
{
Any aAny;
try
{
aAny =
xHierAccess->getByHierarchicalName(
rtl::OUString::createFromAscii(key));
}
catch( const com::sun::star::container::NoSuchElementException& )
{
}
aAny >>= ret;
}
return ret;
}
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& )
{
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 );
}