diff options
author | Vasily Melenchuk <vasily.melenchuk@cib.de> | 2018-11-23 12:55:02 +0300 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2018-12-03 23:47:30 +0100 |
commit | 16d12d50c2bfd924d2a7e6946896526a15a150d4 (patch) | |
tree | 8bdc87705043ff1c1009053a8d0c4e54dfbc659b /sdext/source | |
parent | dae741a2418f1d1dd35d364ec416516cc50f5054 (diff) |
presentation minimizer: suggest filename for a new presentation
If presentation was never saved suggested filename was empty.
Right now it will show filename like "Untitled 1 (minimized)".
Change-Id: I0077e6c9f2e86665f9de6d41fa434fd21167c779
Reviewed-on: https://gerrit.libreoffice.org/63876
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sdext/source')
-rw-r--r-- | sdext/source/minimizer/optimizerdialog.cxx | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/sdext/source/minimizer/optimizerdialog.cxx b/sdext/source/minimizer/optimizerdialog.cxx index f7aa8cb9564e..717f06a08340 100644 --- a/sdext/source/minimizer/optimizerdialog.cxx +++ b/sdext/source/minimizer/optimizerdialog.cxx @@ -22,6 +22,7 @@ #include "impoptimizer.hxx" #include "fileopendialog.hxx" #include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/frame/XTitle.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ucb/XSimpleFileAccess.hpp> #include <com/sun/star/io/XInputStream.hpp> @@ -501,24 +502,35 @@ void ActionListener::actionPerformed( const ActionEvent& rEvent ) FileOpenDialog aFileOpenDialog( mrOptimizerDialog.GetComponentContext() ); // generating default file name + OUString aName; Reference< XStorable > xStorable( mrOptimizerDialog.mxController->getModel(), UNO_QUERY ); if ( xStorable.is() && xStorable->hasLocation() ) { INetURLObject aURLObj( xStorable->getLocation() ); - if ( !aURLObj.hasFinalSlash() ) { + if ( !aURLObj.hasFinalSlash() ) + { // tdf#105382 uri-decode file name aURLObj.removeExtension(INetURLObject::LAST_SEGMENT, false); - auto aName( aURLObj.getName( INetURLObject::LAST_SEGMENT, - false, - INetURLObject::DecodeMechanism::WithCharset ) ); - // Add "(minimized)" - aName += " "; - aName += mrOptimizerDialog.getString(STR_FILENAME_SUFFIX); - aFileOpenDialog.setDefaultName( aName ); + aName = aURLObj.getName(INetURLObject::LAST_SEGMENT, false, + INetURLObject::DecodeMechanism::WithCharset); } } - bool bDialogExecuted = aFileOpenDialog.execute() == dialogs::ExecutableDialogResults::OK; - if ( bDialogExecuted ) + else + { + // If no filename, try to use model title ("Untitled 1" or something like this) + Reference<XTitle> xTitle( + mrOptimizerDialog.GetFrame()->getController()->getModel(), UNO_QUERY); + aName = xTitle->getTitle(); + } + + if (!aName.isEmpty()) + { + aName += " "; + aName += mrOptimizerDialog.getString(STR_FILENAME_SUFFIX); + aFileOpenDialog.setDefaultName(aName); + } + + if (aFileOpenDialog.execute() == dialogs::ExecutableDialogResults::OK) { aSaveAsURL = aFileOpenDialog.getURL(); mrOptimizerDialog.SetConfigProperty( TK_SaveAsURL, Any( aSaveAsURL ) ); |