framework/source/uielement/recentfilesmenucontroller.cxx | 28 ++++----------- include/tools/urlobj.hxx | 8 ++++ tools/source/fsys/urlobj.cxx | 6 +++ 3 files changed, 23 insertions(+), 19 deletions(-)
New commits: commit 2092f8810a20938a0d0dbf5364c850a6ad9981ad Author: Samuel Mehrbrodt <s.mehrbr...@gmail.com> Date: Tue Apr 30 20:13:30 2013 +0200 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/3700 Reviewed-by: Jan Holesovsky <ke...@suse.cz> Tested-by: Jan Holesovsky <ke...@suse.cz> diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx index 3d8d9c9..2be9117 100644 --- a/framework/source/uielement/recentfilesmenucontroller.cxx +++ b/framework/source/uielement/recentfilesmenucontroller.cxx @@ -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 ); diff --git a/include/tools/urlobj.hxx b/include/tools/urlobj.hxx index fef9f46..8905334 100644 --- a/include/tools/urlobj.hxx +++ b/include/tools/urlobj.hxx @@ -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)); } diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 2724b71..071ca7a 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -4192,6 +4192,12 @@ OUString INetURLObject::GetScheme(INetProtocol eTheScheme) } // static +OUString INetURLObject::GetSchemeName(INetProtocol eTheScheme) +{ + return OUString::createFromAscii(getSchemeInfo(eTheScheme).m_pScheme); +} + +// static INetProtocol INetURLObject::CompareProtocolScheme(OUString const & rTheAbsURIRef) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits