Kaydet (Commit) 2092f881 authored tarafından Samuel Mehrbrodt's avatar Samuel Mehrbrodt Kaydeden (comit) Jan Holesovsky

Show only filename in "Recent Files" list

As discussed here: http://nabble.documentfoundation.org/Libreoffice-ux-advise-Recent-files-dropdown-td4052945.html#a4052996

The changes are (inspired by Gedit):
* Display only the filename, not the (abbreviated) path
* Show the protocol name before the file, if not local (e.g. "ftp: myfile.odt")
* After the keyboard shortcut (a number from 1 to 10) display a '.' instead of a ':' (because the protocol has a ':')
* FIX: Display whitespace as whitespace, not "%20"

Change-Id: I47472c901aa866adb76c7c7ab36bc871f82ad8df
Reviewed-on: https://gerrit.libreoffice.org/3700Reviewed-by: 's avatarJan Holesovsky <kendy@suse.cz>
Tested-by: 's avatarJan Holesovsky <kendy@suse.cz>
üst 802a87e1
......@@ -40,13 +40,12 @@ using namespace com::sun::star::frame;
using namespace com::sun::star::beans;
using namespace com::sun::star::util;
#define MAX_STR_WIDTH 46
#define MAX_MENU_ITEMS 99
static const char SFX_REFERER_USER[] = "private:user";
static const char CMD_CLEAR_LIST[] = ".uno:ClearRecentFileList";
static const char CMD_PREFIX[] = "vnd.sun.star.popup:RecentFileList?entry=";
static const char MENU_SHOTCUT[] = "~N: ";
static const char MENU_SHORTCUT[] = "~N. ";
namespace framework
{
......@@ -133,17 +132,17 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
if ( i <= 9 )
{
if ( i == 9 )
aMenuShortCut.append( "1~0: " );
aMenuShortCut.append( "1~0. " );
else
{
aMenuShortCut.append( MENU_SHOTCUT );
aMenuShortCut.append( MENU_SHORTCUT );
aMenuShortCut[ 1 ] = sal_Unicode( i + '1' );
}
}
else
{
aMenuShortCut.append( sal_Int32( i + 1 ) );
aMenuShortCut.append( ": " );
aMenuShortCut.append( ". " );
}
OUStringBuffer aStrBuffer;
......@@ -152,28 +151,19 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
OUString aURLString( aStrBuffer.makeStringAndClear() );
// Abbreviate URL
OUString aTipHelpText;
OUString aMenuTitle;
INetURLObject aURL( m_aRecentFilesItems[i].aURL );
OUString aTipHelpText( aURL.getFSysPath( INetURLObject::FSYS_DETECT ) );
if ( aURL.GetProtocol() == INET_PROT_FILE )
{
// Do handle file URL differently => convert it to a system
// path and abbreviate it with a special function:
OUString aSystemPath( aURL.getFSysPath( INetURLObject::FSYS_DETECT ) );
aTipHelpText = aSystemPath;
OUString aCompactedSystemPath;
if ( osl_abbreviateSystemPath( aSystemPath.pData, &aCompactedSystemPath.pData, MAX_STR_WIDTH, NULL ) == osl_File_E_None )
aMenuTitle = aCompactedSystemPath;
else
aMenuTitle = aSystemPath;
// Do handle file URL differently: don't show the protocol, just the file name
aMenuTitle = aURL.GetLastName(INetURLObject::DECODE_WITH_CHARSET, RTL_TEXTENCODING_UTF8);
}
else
{
// Use INetURLObject to abbreviate all other URLs
aMenuTitle = aURL.getAbbreviated( xStringLength, MAX_STR_WIDTH, INetURLObject::DECODE_UNAMBIGUOUS );
aTipHelpText = aURLString;
// In all other URLs show the protocol name before the file name
aMenuTitle = aURL.GetSchemeName(aURL.GetProtocol()) + ": " + aURL.getName();
}
aMenuShortCut.append( aMenuTitle );
......
......@@ -484,6 +484,14 @@ public:
*/
static OUString GetScheme(INetProtocol eTheScheme);
/** Return the a human-readable name for a given scheme.
@param eTheScheme One of the supported URL schemes.
@return The protocol name of URLs of the given scheme.
*/
static OUString GetSchemeName(INetProtocol eTheScheme);
static inline INetProtocol CompareProtocolScheme(const OString&
rTheAbsURIRef)
{ return CompareProtocolScheme(extend(rTheAbsURIRef)); }
......
......@@ -4191,6 +4191,12 @@ OUString INetURLObject::GetScheme(INetProtocol eTheScheme)
return OUString::createFromAscii(getSchemeInfo(eTheScheme).m_pPrefix);
}
// static
OUString INetURLObject::GetSchemeName(INetProtocol eTheScheme)
{
return OUString::createFromAscii(getSchemeInfo(eTheScheme).m_pScheme);
}
// static
INetProtocol INetURLObject::CompareProtocolScheme(OUString const &
rTheAbsURIRef)
......
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