[Libreoffice-commits] core.git: sdext/Library_PresentationMinimizer.mk sdext/source

Takeshi Abe tabe at fixedpoint.jp
Tue Jan 24 13:23:06 UTC 2017


 sdext/Library_PresentationMinimizer.mk     |    1 +
 sdext/source/minimizer/optimizerdialog.cxx |   27 +++++++++------------------
 2 files changed, 10 insertions(+), 18 deletions(-)

New commits:
commit d8aa4503966e2c8882c238a1a30c05b72bdf6f68
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Tue Jan 24 18:55:20 2017 +0900

    tdf#105382 Set URL-decoded default filename for minimized presentation
    
    See mailing-list thread starting at
    <https://lists.freedesktop.org/archives/libreoffice/2017-January/076702.html>
    for a discussion on the original presentation file's URL.
    
    Change-Id: I51ccd7672513118f39518c4ed21902de16b2298f
    Reviewed-on: https://gerrit.libreoffice.org/33261
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sdext/Library_PresentationMinimizer.mk b/sdext/Library_PresentationMinimizer.mk
index 2ae650a..eb8995f 100644
--- a/sdext/Library_PresentationMinimizer.mk
+++ b/sdext/Library_PresentationMinimizer.mk
@@ -28,6 +28,7 @@ $(eval $(call gb_Library_use_libraries,PresentationMinimizer,\
     cppu \
     cppuhelper \
     sal \
+    tl \
 ))
 
 $(eval $(call gb_Library_add_exception_objects,PresentationMinimizer,\
diff --git a/sdext/source/minimizer/optimizerdialog.cxx b/sdext/source/minimizer/optimizerdialog.cxx
index 78c044a..0142285 100644
--- a/sdext/source/minimizer/optimizerdialog.cxx
+++ b/sdext/source/minimizer/optimizerdialog.cxx
@@ -29,6 +29,7 @@
 #include <com/sun/star/frame/XLayoutManager.hpp>
 #include <sal/macros.h>
 #include <osl/time.h>
+#include <tools/urlobj.hxx>
 
 
 using namespace ::com::sun::star::io;
@@ -511,24 +512,14 @@ void ActionListener::actionPerformed( const ActionEvent& rEvent )
                 Reference< XStorable > xStorable( mrOptimizerDialog.mxController->getModel(), UNO_QUERY );
                 if ( xStorable.is() && xStorable->hasLocation() )
                 {
-                    OUString aLocation( xStorable->getLocation() );
-                    if ( !aLocation.isEmpty() )
-                    {
-                        sal_Int32 nIndex = aLocation.lastIndexOf( '/', aLocation.getLength() - 1 );
-                        if ( nIndex >= 0 )
-                        {
-                            if ( nIndex < aLocation.getLength() - 1 )
-                                aLocation = aLocation.copy( nIndex + 1 );
-
-                            // remove extension
-                            nIndex = aLocation.lastIndexOf( '.', aLocation.getLength() - 1 );
-                            if ( nIndex >= 0 )
-                                aLocation = aLocation.copy( 0, nIndex );
-
-                            // adding .mini
-                            aLocation = aLocation.concat( ".mini" );
-                            aFileOpenDialog.setDefaultName( aLocation );
-                        }
+                    INetURLObject aURLObj( xStorable->getLocation() );
+                    if ( !aURLObj.hasFinalSlash() &&
+                         aURLObj.setExtension( "mini", INetURLObject::LAST_SEGMENT, false ) ) {
+                        // tdf#105382 uri-decode file name
+                        auto aName( aURLObj.getName( INetURLObject::LAST_SEGMENT,
+                                                     false,
+                                                     INetURLObject::DecodeMechanism::WithCharset ) );
+                        aFileOpenDialog.setDefaultName( aName );
                     }
                 }
                  bool bDialogExecuted = aFileOpenDialog.execute() == dialogs::ExecutableDialogResults::OK;


More information about the Libreoffice-commits mailing list