summaryrefslogtreecommitdiffstats
path: root/fpicker
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-10-18 11:37:12 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2021-10-19 11:16:57 +0200
commitfd53425ea58d86c0031bdc764391e1e6a925ed42 (patch)
treee8f1663213b61525d97a6268a112617c627eb8d8 /fpicker
parentRelated: tdf#145173 Ensure known supported system and default document locale (diff)
downloadcore-fd53425ea58d86c0031bdc764391e1e6a925ed42.tar.gz
core-fd53425ea58d86c0031bdc764391e1e6a925ed42.zip
Related: tdf#145169 change to selected dir on remote "save"
if a dir is selected then try to change to that dir when save is clicked instead of saving using that as basename, which is consistent with standard fpicker. don't change the contents of the Entry, leave it alone. Change-Id: Id19fbf0f3ef2b8220059a1fa166b7783feb8d57d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123773 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/office/RemoteFilesDialog.cxx43
-rw-r--r--fpicker/source/office/RemoteFilesDialog.hxx2
2 files changed, 21 insertions, 24 deletions
diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx
index ff4e0b75c07f..a48620fe3839 100644
--- a/fpicker/source/office/RemoteFilesDialog.cxx
+++ b/fpicker/source/office/RemoteFilesDialog.cxx
@@ -379,21 +379,18 @@ void RemoteFilesDialog::OpenURL( OUString const & sURL )
}
}
-void RemoteFilesDialog::AddFileExtension()
+OUString RemoteFilesDialog::AddFileExtension(const OUString& rFileName)
{
if (m_nCurrentFilter == -1)
- return;
+ return rFileName;
OUString sExt = m_aFilters[m_nCurrentFilter].second;
- OUString sFileName = m_xName_ed->get_text();
+ sal_Int32 nDotPos = rFileName.lastIndexOf( '.' );
- sal_Int32 nDotPos = sFileName.lastIndexOf( '.' );
+ if (nDotPos == -1)
+ return rFileName + sExt.subView( 1 ); // without '*'
- if ( nDotPos == -1 )
- {
- sFileName += sExt.subView( 1 ); // without '*'
- m_xName_ed->set_text( sFileName );
- }
+ return rFileName;
}
void RemoteFilesDialog::EnableControls()
@@ -825,18 +822,18 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, NewFolderHdl, weld::Button&, void )
IMPL_LINK_NOARG ( RemoteFilesDialog, OkHdl, weld::Button&, void )
{
- OUString sNameNoExt = m_xName_ed->get_text();
- OUString sPathNoExt;
-
- // auto extension
- if( m_eMode == REMOTEDLG_MODE_SAVE )
- AddFileExtension();
+ OUString sUserSelectedPath;
// check if file/path exists
-
OUString sCurrentPath = m_xFileView->GetViewURL();
OUString sSelectedItem = m_xFileView->GetCurrentURL();
- OUString sName = m_xName_ed->get_text();
+ OUString sUserTypedName = m_xName_ed->get_text();
+ OUString sFileName;
+ // auto extension
+ if( m_eMode == REMOTEDLG_MODE_SAVE )
+ sFileName = AddFileExtension(sUserTypedName);
+ else
+ sFileName = sUserTypedName;
bool bFileDlg = ( m_eType == REMOTEDLG_TYPE_FILEDLG );
bool bSelected = ( m_xFileView->GetSelectionCount() > 0 );
@@ -846,8 +843,8 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, OkHdl, weld::Button&, void )
if( !bSelected )
{
- m_sPath = sCurrentPath + INetURLObject::encode( sName, INetURLObject::PART_FPATH, INetURLObject::EncodeMechanism::All );
- sPathNoExt = sCurrentPath + INetURLObject::encode( sNameNoExt, INetURLObject::PART_FPATH, INetURLObject::EncodeMechanism::All );
+ m_sPath = sCurrentPath + INetURLObject::encode(sFileName, INetURLObject::PART_FPATH, INetURLObject::EncodeMechanism::All);
+ sUserSelectedPath = sCurrentPath + INetURLObject::encode(sUserTypedName, INetURLObject::PART_FPATH, INetURLObject::EncodeMechanism::All);
}
else
{
@@ -863,6 +860,7 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, OkHdl, weld::Button&, void )
aURL.SetUser( aCurrentURL.GetUser() );
m_sPath = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ sUserSelectedPath = m_sPath;
}
bool bExists = false;
@@ -877,7 +875,7 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, OkHdl, weld::Button&, void )
if( m_eMode == REMOTEDLG_MODE_SAVE )
{
OUString sMsg = FpsResId( STR_SVT_ALREADYEXISTOVERWRITE );
- sMsg = sMsg.replaceFirst( "$filename$", sName );
+ sMsg = sMsg.replaceFirst("$filename$", sFileName);
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Question, VclButtonsType::YesNo, sMsg));
if (xBox->run() != RET_YES)
@@ -886,10 +884,9 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, OkHdl, weld::Button&, void )
}
else
{
- if( ContentIsFolder( sPathNoExt ) )
+ if (ContentIsFolder(sUserSelectedPath))
{
- OpenURL( sPathNoExt );
- m_xName_ed->set_text( "" );
+ OpenURL(sUserSelectedPath);
if (!bSelected)
m_xName_ed->grab_focus();
diff --git a/fpicker/source/office/RemoteFilesDialog.hxx b/fpicker/source/office/RemoteFilesDialog.hxx
index 55cfa2870d59..3d95ff913c4f 100644
--- a/fpicker/source/office/RemoteFilesDialog.hxx
+++ b/fpicker/source/office/RemoteFilesDialog.hxx
@@ -149,7 +149,7 @@ private:
void OpenURL( OUString const & sURL );
- void AddFileExtension();
+ OUString AddFileExtension(const OUString& rFileName);
void EnableExtraMenuItems(bool bEnable);
void EnableControls();