summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-10-18 09:58:26 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-10-18 12:39:57 +0200
commitf845ee17d52bca18b86bf6f28a74147085175d6a (patch)
treeac147a1d2686c3a989ef294688165422ea01ea92 /fpicker
parent5acba60cbd97f2f181037cbd3ab049e7ebff5332 (diff)
Related: tdf#145169 use INetURLObject::getName and removeSegment
to get the name and link for each part of the path otherwise for sftp:// clicking on the "Root" doesn't work for me Change-Id: If6f0ac8f105afd8be2d264b54f76a3d8f345ad75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123735 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/office/breadcrumb.cxx56
1 files changed, 22 insertions, 34 deletions
diff --git a/fpicker/source/office/breadcrumb.cxx b/fpicker/source/office/breadcrumb.cxx
index d884d5b3fc8e..0b27367d8a8e 100644
--- a/fpicker/source/office/breadcrumb.cxx
+++ b/fpicker/source/office/breadcrumb.cxx
@@ -68,61 +68,49 @@ void Breadcrumb::SetRootName( const OUString& rURL )
void Breadcrumb::SetURL( const OUString& rURL )
{
m_aCurrentURL = rURL;
- INetURLObject aURL( rURL );
+ INetURLObject aURL(rURL);
aURL.setFinalSlash();
- //prepare the Host port
- OUString sHostPort;
- if( aURL.HasPort() )
- {
- sHostPort += ":" + OUString::number( aURL.GetPort() );
- }
-
- OUString sUser = aURL.GetUser( INetURLObject::DecodeMechanism::NONE );
- OUString sPath = aURL.GetURLPath(INetURLObject::DecodeMechanism::WithCharset);
- OUString sRootPath = INetURLObject::GetScheme( aURL.GetProtocol() )
- + sUser
- + ( sUser.isEmpty() ? OUString() : "@" )
- + aURL.GetHost()
- + sHostPort;
+ bool bClear = m_eMode == SvtBreadcrumbMode::ONLY_CURRENT_PATH;
int nSegments = aURL.getSegmentCount();
- unsigned int nPos = 0;
- bool bClear = ( m_eMode == SvtBreadcrumbMode::ONLY_CURRENT_PATH );
-
- // root field
- m_aSegments[0]->m_xLink->set_label( m_sRootName );
- m_aSegments[0]->m_xLink->set_sensitive(true);
- m_aSegments[0]->m_xLink->set_uri(sRootPath);
- m_aUris[m_aSegments[0]->m_xLink.get()] = sRootPath;
+ size_t nVecSizeRequired = nSegments + 1;
- // fill the other fields
+ while (m_aSegments.size() < nVecSizeRequired)
+ appendField();
- for( unsigned int i = 1; i < static_cast<unsigned int>(nSegments) + 1; i++ )
+ // fill the fields under root
+ for (int i = nSegments; i; --i)
{
- if( i >= m_aSegments.size() )
- appendField();
+ OUString sLabel = aURL.getName(INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset);
+ OUString sLink = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
- unsigned int nEnd = sPath.indexOf( '/', nPos + 1 );
- OUString sLabel = sPath.copy( nPos + 1, nEnd - nPos - 1 );
-
- if( m_eMode == SvtBreadcrumbMode::ALL_VISITED )
+ if (m_eMode == SvtBreadcrumbMode::ALL_VISITED)
{
if( m_aSegments[i]->m_xLink->get_label() != sLabel )
bClear = true;
}
- m_aSegments[i]->m_xLink->set_label( sLabel );
- m_aUris[m_aSegments[i]->m_xLink.get()] = sRootPath + sPath.subView(0, nEnd);
m_aSegments[i]->m_xLink->hide();
+ m_aSegments[i]->m_xLink->set_label(sLabel);
m_aSegments[i]->m_xLink->set_sensitive(true);
+ m_aSegments[i]->m_xLink->set_uri(sLink);
+ m_aUris[m_aSegments[i]->m_xLink.get()] = sLink;
m_aSegments[i]->m_xSeparator->hide();
- nPos = nEnd;
+ aURL.removeSegment();
}
+ OUString sRootPath = aURL.GetMainURL(INetURLObject::DecodeMechanism::WithCharset);
+
+ // root field
+ m_aSegments[0]->m_xLink->set_label( m_sRootName );
+ m_aSegments[0]->m_xLink->set_sensitive(true);
+ m_aSegments[0]->m_xLink->set_uri(sRootPath);
+ m_aUris[m_aSegments[0]->m_xLink.get()] = sRootPath;
+
// clear unused fields
for (size_t i = nSegments + 1; i < m_aSegments.size(); i++ )
{