[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-5-2+backports' - sdext/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Dec 5 14:10:40 UTC 2018


 sdext/source/minimizer/optimizerdialog.cxx |   33 ++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 10 deletions(-)

New commits:
commit 411147db70fa9f3e3acb40a94fcece2667394a03
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Fri Nov 23 12:55:02 2018 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Dec 5 15:10:17 2018 +0100

    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 at CIB.de>
    Reviewed-on: https://gerrit.libreoffice.org/64624
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sdext/source/minimizer/optimizerdialog.cxx b/sdext/source/minimizer/optimizerdialog.cxx
index 4b789ca7e408..bf17f9c4643c 100644
--- a/sdext/source/minimizer/optimizerdialog.cxx
+++ b/sdext/source/minimizer/optimizerdialog.cxx
@@ -21,6 +21,8 @@
 #include "optimizerdialog.hxx"
 #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>
@@ -510,24 +512,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::DECODE_WITH_CHARSET ) );
-                        // Add "(minimized)"
-                        aName += " ";
-                        aName += mrOptimizerDialog.getString(STR_FILENAME_SUFFIX);
-                        aFileOpenDialog.setDefaultName( aName );
+                        aName = aURLObj.getName(INetURLObject::LAST_SEGMENT, false,
+                                                INetURLObject::DECODE_WITH_CHARSET);
                     }
                 }
-                 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 ) );


More information about the Libreoffice-commits mailing list