[Libreoffice-commits] core.git: cui/source offapi/com sc/source svtools/source vcl/win

Noel Grandin noel at peralex.com
Tue Mar 5 08:13:14 PST 2013


 cui/source/options/personalization.cxx        |    3 +-
 offapi/com/sun/star/ui/dialogs/FilePicker.idl |    1 
 sc/source/ui/xmlsource/xmlsourcedlg.cxx       |    3 +-
 svtools/source/control/filectrl2.cxx          |    3 +-
 vcl/win/source/gdi/salprn.cxx                 |   30 +++++++++-----------------
 5 files changed, 17 insertions(+), 23 deletions(-)

New commits:
commit 3554b3653049cb8fffa2a56ca0c9a2d8e972f5ec
Author: Noel Grandin <noel at peralex.com>
Date:   Tue Mar 5 11:34:53 2013 +0200

    fix for fdo#61801
    
    ... "crash on Tools - Options - LibreOffice - Personalization - Select Background Image"
    
    The root cause of this is my conversion of the UNO code to use the
    new-style FilePicker service constructor in commit
    4b51374a7021d52f7f1be1861e2ee6a011b30ecd
    
    Unfortunately, the new-style service constructor will always call
    initialize(Sequence<Any>), which the old code did not do.
    And initialize does not like being called without any arguments.
    
    The cleanest fix for this is to simply remove the createDefault()
    service constructor method and make all the call sites explicitly
    choose the style of FilePicker dialog they want.
    
    As a bonus, this simplifies some of the call sites.
    
    Change-Id: I75f5e03cff4e39abe22cd9650a079ec78ab636c4
    Reviewed-on: https://gerrit.libreoffice.org/2553
    Reviewed-by: Kohei Yoshida <kohei.yoshida at gmail.com>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
    Tested-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx
index f1ba980..86e7fff 100644
--- a/cui/source/options/personalization.cxx
+++ b/cui/source/options/personalization.cxx
@@ -25,6 +25,7 @@
 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
 #include <com/sun/star/ui/dialogs/FilePicker.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
 
@@ -211,7 +212,7 @@ IMPL_LINK( SvxPersonalizationTabPage, SelectBackground, PushButton*, /*pButton*/
 {
     uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
 
-    uno::Reference< ui::dialogs::XFilePicker3 > xFilePicker = ui::dialogs::FilePicker::createDefault(xContext);
+    uno::Reference< ui::dialogs::XFilePicker3 > xFilePicker = ui::dialogs::FilePicker::createWithMode(xContext, ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE);
 
     xFilePicker->setMultiSelectionMode( false );
 
diff --git a/offapi/com/sun/star/ui/dialogs/FilePicker.idl b/offapi/com/sun/star/ui/dialogs/FilePicker.idl
index 39cd6511..4636748 100644
--- a/offapi/com/sun/star/ui/dialogs/FilePicker.idl
+++ b/offapi/com/sun/star/ui/dialogs/FilePicker.idl
@@ -38,7 +38,6 @@ module com { module sun { module star { module ui { module dialogs {
 
 published service FilePicker : XFilePicker3
 {
-    createDefault();
 
     /** Provides the ability to choose between different custom templates that
         do extend the subset of common controls a FilePicker usually supports.
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 9a366d7..838b7d1 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/ui/dialogs/FilePicker.hpp>
 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
 
 using namespace com::sun::star;
 
@@ -177,7 +178,7 @@ void ScXMLSourceDlg::SelectSourceFile()
     if (!xServiceMgr.is())
         return;
 
-    uno::Reference<ui::dialogs::XFilePicker3> xFilePicker = ui::dialogs::FilePicker::createDefault( comphelper::getComponentContext(xServiceMgr) );
+    uno::Reference<ui::dialogs::XFilePicker3> xFilePicker = ui::dialogs::FilePicker::createWithMode( comphelper::getComponentContext(xServiceMgr), ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE );
 
     if (maSrcPath.isEmpty())
         // Use default path.
diff --git a/svtools/source/control/filectrl2.cxx b/svtools/source/control/filectrl2.cxx
index cb48f42..bf69f32 100644
--- a/svtools/source/control/filectrl2.cxx
+++ b/svtools/source/control/filectrl2.cxx
@@ -21,6 +21,7 @@
 // this file contains code from filectrl.cxx which needs to be compiled with enabled exception hanling
 #include <svtools/filectrl.hxx>
 #include <com/sun/star/ui/dialogs/FilePicker.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
 #include <comphelper/processfactory.hxx>
 #include <tools/urlobj.hxx>
 #include <osl/file.h>
@@ -37,7 +38,7 @@ void FileControl::ImplBrowseFile( )
         XubString aNewText;
 
         Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
-        Reference < dialogs::XFilePicker3 > xFilePicker = dialogs::FilePicker::createDefault( xContext );
+        Reference < dialogs::XFilePicker3 > xFilePicker = dialogs::FilePicker::createWithMode( xContext, dialogs::TemplateDescription::FILEOPEN_SIMPLE );
         // transform the system notation text into a file URL
         ::rtl::OUString sSystemNotation = GetText(), sFileURL;
         oslFileError nError = osl_getFileURLFromSystemPath( sSystemNotation.pData, &sFileURL.pData );
diff --git a/vcl/win/source/gdi/salprn.cxx b/vcl/win/source/gdi/salprn.cxx
index 57440cd..d1904a7 100644
--- a/vcl/win/source/gdi/salprn.cxx
+++ b/vcl/win/source/gdi/salprn.cxx
@@ -1601,27 +1601,19 @@ sal_Bool WinSalPrinter::StartJob( const rtl::OUString* pFileName,
     {
 
         uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
-        uno::Reference< XFilePicker3 > xFilePicker = FilePicker::createDefault(xContext);
+        uno::Reference< XFilePicker3 > xFilePicker = FilePicker::createWithMode(xContext, TemplateDescription::FILESAVE_SIMPLE);
 
-        uno::Reference< XInitialization > xInit( xFilePicker, UNO_QUERY );
-        uno::Reference< XFilterManager > xFilterMgr( xFilePicker, UNO_QUERY );
-        if( xInit.is() && xFilePicker.is() && xFilterMgr.is() )
+        if( xFilePicker->execute() == ExecutableDialogResults::OK )
         {
-            Sequence< Any > aServiceType( 1 );
-            aServiceType[0] <<= TemplateDescription::FILESAVE_SIMPLE;
-            xInit->initialize( aServiceType );
-            if( xFilePicker->execute() == ExecutableDialogResults::OK )
-            {
-                Sequence< OUString > aPathSeq( xFilePicker->getFiles() );
-                INetURLObject aObj( aPathSeq[0] );
-                // we're using ansi calls (StartDocA) so convert the string
-                aOutFileName = aObj.PathToFileName();
-            }
-            else
-            {
-                mnError = SAL_PRINTER_ERROR_ABORT;
-                return FALSE;
-            }
+            Sequence< OUString > aPathSeq( xFilePicker->getFiles() );
+            INetURLObject aObj( aPathSeq[0] );
+            // we're using ansi calls (StartDocA) so convert the string
+            aOutFileName = aObj.PathToFileName();
+        }
+        else
+        {
+            mnError = SAL_PRINTER_ERROR_ABORT;
+            return FALSE;
         }
     }
 


More information about the Libreoffice-commits mailing list