diff options
author | Oliver Bolte <obo@openoffice.org> | 2004-03-17 09:16:42 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2004-03-17 09:16:42 +0000 |
commit | 254eaa5ab82c27825eaba20559a61968a253f327 (patch) | |
tree | eafaaa03fd51c4d61556b04fa15f864348c22e0d /extensions/source/plugin | |
parent | 8726a96e41862440a3006292848cc7941368668a (diff) |
INTEGRATION: CWS vcl18 (1.8.138); FILE MERGED
2004/02/10 14:45:43 pl 1.8.138.1: #i12911# improved mimetype evaluation
Diffstat (limited to 'extensions/source/plugin')
-rw-r--r-- | extensions/source/plugin/unx/unxmgr.cxx | 68 |
1 files changed, 49 insertions, 19 deletions
diff --git a/extensions/source/plugin/unx/unxmgr.cxx b/extensions/source/plugin/unx/unxmgr.cxx index 907f1ff49bbd..acb18ce45559 100644 --- a/extensions/source/plugin/unx/unxmgr.cxx +++ b/extensions/source/plugin/unx/unxmgr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unxmgr.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: vg $ $Date: 2003-05-28 12:39:14 $ + * last change: $Author: obo $ $Date: 2004-03-17 10:16:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,6 +63,7 @@ #include <sys/types.h> #include <dirent.h> #include <osl/thread.h> +#include <rtl/strbuf.hxx> #include <vcl/svapp.hxx> #include <plugin/impl.hxx> @@ -117,27 +118,57 @@ static bool CheckPlugin( const ByteString& rPath, list< PluginDescription* >& rD int nDescriptions = 0; if( pResult ) { - ByteString aMIME; + OStringBuffer aMIME; char buf[256]; while( fgets( buf, sizeof( buf ), pResult ) ) - aMIME += buf; + { + for( int i = 0; i < sizeof(buf) && buf[i]; ++i ) + { + if( buf[i] == '\n' ) + buf[i] = ';'; + } + aMIME.append( buf ); + } pclose( pResult ); - if( aMIME.Len() > 0 ) + + if( aMIME.getLength() > 0 ) { - if( aMIME.GetChar( aMIME.Len()-1 ) == '\n' ) - aMIME.Erase( aMIME.Len()-1 ); - xub_StrLen nIndex = 0; - while( nIndex != STRING_NOTFOUND ) + OString aLine = aMIME.makeStringAndClear(); + + sal_Int32 nIndex = 0; + while( nIndex != -1 ) { - ByteString aType = aMIME.GetToken( 0, ';', nIndex ); + OString aType = aLine.getToken( 0, ';', nIndex ); + + sal_Int32 nTypeIndex = 0; + OString aMimetype = aType.getToken( 0, ':', nTypeIndex ); + OString aExtLine = aType.getToken( 0, ':', nTypeIndex ); + if( nTypeIndex < 0 ) // ensure at least three tokens + continue; + OString aDesc = aType.getToken( 0, ':', nTypeIndex ); + + // create extension list string + sal_Int32 nExtIndex = 0; + OStringBuffer aExtension; + while( nExtIndex != -1 ) + { + OString aExt = aExtLine.getToken( 0, ',', nExtIndex); + if( aExt.indexOf( "*." ) != 0 ) + aExtension.append( "*." ); + aExtension.append( aExt ); + if( nExtIndex != -1 ) + aExtension.append( ';' ); + } PluginDescription* pNew = new PluginDescription; - pNew->PluginName = String( rPath, aEncoding ); - pNew->Mimetype = String( aType.GetToken( 0, ':' ), aEncoding ); - ByteString aExt( "*." ); - aExt += aType.GetToken( 1, ':' ).EraseLeadingChars().EraseTrailingChars(); - pNew->Extension = String( aExt, aEncoding ); - pNew->Description= String( aType.GetToken( 2, ':' ), aEncoding ); + // set plugin name (path to library) + pNew->PluginName = OStringToOUString( rPath, aEncoding ); + // set mimetype + pNew->Mimetype = OStringToOUString( aMimetype, aEncoding ); + // set extension line + pNew->Extension = OStringToOUString( aExtension.makeStringAndClear(), aEncoding ); + // set description + pNew->Description= OStringToOUString( aDesc, aEncoding ); rDescriptions.push_back( pNew ); #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, "Mimetype: %s\nExtension: %s\n" @@ -151,9 +182,8 @@ static bool CheckPlugin( const ByteString& rPath, list< PluginDescription* >& rD } #if OSL_DEBUG_LEVEL > 1 else - fprintf( stderr, "result of \"%s\" contains no mimtype:\n%s\n", - aCommand.GetBuffer(), - aMIME.GetBuffer() ); + fprintf( stderr, "result of \"%s\" contains no mimtype\n", + aCommand.GetBuffer() ); #endif } #if OSL_DEBUG_LEVEL > 1 |