Kaydet (Commit) 6ca75f60 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

fpicker-kde-non-utf8.diff: Work even with non-UTF-8 locales.

n#168616.
üst 955a13d3
......@@ -226,38 +226,14 @@ void FileDialog::customEvent( QCustomEvent *pEvent )
{
KURL::List qList( selectedURLs() );
for ( KURL::List::const_iterator it = qList.begin(); it != qList.end(); ++it )
{
qString.append( " " );
QString qUrlStr = addExtension( (*it).url() );
if ( !isExecuting() && !isSupportedProtocol( KURL( qUrlStr ).protocol() ) )
qUrlStr = localCopy( qUrlStr );
if ( qUrlStr.startsWith( "file:/" ) && qUrlStr.mid( 6, 1 ) != "/" )
qUrlStr.replace( "file:/", "file:///" );
if ( !qUrlStr.isEmpty() )
appendEscaped( qString, qUrlStr );
}
appendURL( qString, (*it) );
}
else
{
// we have to return the selected files anyway
const KFileItemList *pItems = ops->selectedItems();
for ( KFileItemListIterator it( *pItems ); it.current(); ++it )
{
qString.append( " " );
QString qUrlStr = addExtension( (*it)->url().url() );
if ( !isExecuting() && !isSupportedProtocol( KURL( qUrlStr ).protocol() ) )
qUrlStr = localCopy( qUrlStr );
if ( qUrlStr.startsWith( "file:/" ) && qUrlStr.mid( 6, 1 ) != "/" )
qUrlStr.replace( "file:/", "file:///" );
if ( !qUrlStr.isEmpty() )
appendEscaped( qString, qUrlStr );
}
appendURL( qString, (*it)->url() );
}
sendCommand( qString );
......@@ -627,7 +603,8 @@ KURL FileDialog::mostLocalURL( const KURL &rURL ) const
QString FileDialog::localCopy( const QString &rFileName ) const
{
KURL qLocalURL = mostLocalURL( KURL( rFileName ) );
// 106 == MIB enum for UTF-8
KURL qLocalURL = mostLocalURL( KURL( rFileName, 106 ) );
if ( qLocalURL.isLocalFile() )
return qLocalURL.url();
......@@ -678,6 +655,28 @@ void FileDialog::sendCommand( const QString &rCommand )
::std::cout << rCommand.utf8() << ::std::endl;
}
void FileDialog::appendURL( QString &rBuffer, const KURL &rURL )
{
// From Martin Kretzschmar:
// file:///path/to/test%E0.odt is not a valid URL from OOo's point of
// view. (?Most modern parts of?) OOo assume(s) that the URL contains only
// ASCII characters (which test%E0.odt does) and is UTF-8 after unescaping
// (which file:///path/test%E0.odt is not).
// Cf. the comment in sal/inc/osl/file.h.
// 106 == MIB enum for UTF-8
QString qUrlStr = addExtension( rURL.url( 0, 106 ) );
if ( !isExecuting() && !isSupportedProtocol( rURL.protocol() ) )
qUrlStr = localCopy( qUrlStr );
if ( qUrlStr.startsWith( "file:/" ) && qUrlStr.mid( 6, 1 ) != "/" )
qUrlStr.replace( "file:/", "file:///" );
rBuffer.append( " " );
if ( !qUrlStr.isEmpty() )
appendEscaped( rBuffer, qUrlStr );
}
void FileDialog::appendEscaped( QString &rBuffer, const QString &rString )
{
const QChar *pUnicode = rString.unicode();
......
......@@ -108,6 +108,7 @@ protected slots:
protected:
void sendCommand( const QString &rCommand );
void appendURL( QString &rBuffer, const KURL &rURL );
void appendEscaped( QString &rBuffer, const QString &rString );
QString escapeString( const QString &rString );
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment