diff options
author | Michael Stahl <mstahl@redhat.com> | 2011-11-30 16:08:23 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2011-12-03 00:48:13 +0100 |
commit | 5754213c709428b19c68d5242df54683bf83536e (patch) | |
tree | a1f23a0e7218884f9186cd063ba46515a26cab6c /sfx2 | |
parent | db74fdf5346c4f97256522ee2a3200fcdce1af5a (diff) |
sfx2::FileDialogHelper: refactor construction:
There are currently 2 different ways to specify what kind of file dialog
should be created: the nDialogType and nFlags ctor parameters.
Simplify that by using the nDialogType for the API specified variety,
and the nFlags only for options that cannot be specified by the API.
This allows to get rid of 3 constructors, and the following constants:
WB_OPEN, WB_SAVEAS, WB_PASSWORD, SFXWB_PASSWORD, SFXWB_SHOWSTYLES
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/filedlghelper.hxx | 44 | ||||
-rw-r--r-- | sfx2/source/appl/appopen.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/appl/opengrf.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/appl/shutdownicon.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/dialog/filedlghelper.cxx | 72 | ||||
-rw-r--r-- | sfx2/source/doc/docinsert.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/doc/docvor.cxx | 4 |
7 files changed, 31 insertions, 107 deletions
diff --git a/sfx2/inc/sfx2/filedlghelper.hxx b/sfx2/inc/sfx2/filedlghelper.hxx index edc3b091fc4a..a96f54055b0a 100644 --- a/sfx2/inc/sfx2/filedlghelper.hxx +++ b/sfx2/inc/sfx2/filedlghelper.hxx @@ -72,20 +72,12 @@ class SvStringsDtor; class Window; //----------------------------------------------------------------------------- -/* -#define WB_OPEN 0x00200000L -#define WB_SAVEAS 0x00400000L -#define WB_PASSWORD 0x01000000L -*/ - -#define SFXWB_INSERT ( 0x04000000L | WB_OPEN ) // ((WinBits)0x00200000) -#define SFXWB_PASSWORD WB_PASSWORD // ((WinBits)0x01000000) -#define SFXWB_MULTISELECTION 0x20000000L - -#define SFXWB_GRAPHIC 0x00800000L // FileOpen with link and preview box -#define SFXWB_SHOWSTYLES 0x01000000L // FileOpen with link and preview box and styles -#define SFXWB_EXPORT ( 0x040000000L | WB_SAVEAS ) // Export dialog +// the SFXWB constants are for the nFlags parameter of the constructor +#define SFXWB_INSERT 0x04000000L // turn Open into Insert dialog +#define SFXWB_EXPORT 0x40000000L // turn Save into Export dialog +#define SFXWB_MULTISELECTION 0x20000000L +#define SFXWB_GRAPHIC 0x00800000L // register graphic formats #define FILEDIALOG_FILTER_ALL "*.*" @@ -127,21 +119,10 @@ private: FileDialogHelper_Impl *mpImp; - SAL_DLLPRIVATE sal_Int16 getDialogType( sal_Int64 nFlags ) const; - public: - FileDialogHelper( sal_Int64 nFlags, - const String& rFact, - sal_Int16 nDialog, - SfxFilterFlags nMust, - SfxFilterFlags nDont, - const String& rStandardDir, - const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList); - - FileDialogHelper( sal_Int64 nFlags, - const String& rFactory, - SfxFilterFlags nMust = 0, - SfxFilterFlags nDont = 0 ); + FileDialogHelper( sal_Int16 nDialogType, + sal_Int64 nFlags, + Window* _pPreferredParent = NULL ); FileDialogHelper( sal_Int16 nDialogType, sal_Int64 nFlags, @@ -158,12 +139,6 @@ public: const String& rStandardDir, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList); - FileDialogHelper( sal_Int64 nFlags ); - - FileDialogHelper( sal_Int16 nDialogType, - sal_Int64 nFlags, - Window* _pPreferredParent = NULL ); - FileDialogHelper( sal_Int16 nDialogType, sal_Int64 nFlags, const ::rtl::OUString& aFilterUIName, @@ -286,7 +261,8 @@ public: #define SFX2_IMPL_DIALOG_SYSTEM 1 #define SFX2_IMPL_DIALOG_OOO 2 -ErrCode FileOpenDialog_Impl( sal_Int64 nFlags, +ErrCode FileOpenDialog_Impl( sal_Int16 nDialogType, + sal_Int64 nFlags, const String& rFact, SvStringsDtor *& rpURLList, String& rFilter, diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 436a8a939729..54b9b26e526a 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -49,6 +49,7 @@ #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <comphelper/processfactory.hxx> #include <cppuhelper/implbase1.hxx> #include <rtl/ustring.hxx> @@ -758,6 +759,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) sal_uIntPtr nErr = sfx2::FileOpenDialog_Impl( + ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION, SFXWB_MULTISELECTION, String(), pURLList, aFilter, pSet, &aPath, nDialog, sStandardDir, aBlackList ); diff --git a/sfx2/source/appl/opengrf.cxx b/sfx2/source/appl/opengrf.cxx index 3f8e2ba81f73..826732afe759 100644 --- a/sfx2/source/appl/opengrf.cxx +++ b/sfx2/source/appl/opengrf.cxx @@ -95,8 +95,9 @@ struct SvxOpenGrf_Impl }; -SvxOpenGrf_Impl::SvxOpenGrf_Impl() : - aFileDlg(SFXWB_GRAPHIC) +SvxOpenGrf_Impl::SvxOpenGrf_Impl() + : aFileDlg(ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW, + SFXWB_GRAPHIC) { uno::Reference < XFilePicker > xFP = aFileDlg.GetFilePicker(); xCtrlAcc = uno::Reference < XFilePickerControlAccess >(xFP, UNO_QUERY); diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx index 6418317b6a81..f3293ecdf994 100644 --- a/sfx2/source/appl/shutdownicon.cxx +++ b/sfx2/source/appl/shutdownicon.cxx @@ -43,6 +43,7 @@ #include <com/sun/star/frame/XFramesSupplier.hpp> #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> #include <com/sun/star/ui/dialogs/XFilterManager.hpp> +#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/ControlActions.hpp> @@ -67,6 +68,7 @@ #include "sfx2/sfxresid.hxx" +using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::container; @@ -420,7 +422,9 @@ void ShutdownIcon::StartFileDialog() } if ( !m_pFileDlg ) - m_pFileDlg = new FileDialogHelper( SFXWB_MULTISELECTION, String() ); + m_pFileDlg = new FileDialogHelper( + ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION, + SFXWB_MULTISELECTION, String() ); m_pFileDlg->StartExecuteModal( STATIC_LINK( this, ShutdownIcon, DialogClosedHdl_Impl ) ); } diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 08af95aa3b88..1ab73ed2353e 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -2216,47 +2216,6 @@ void FileDialogHelper_Impl::SetContext( FileDialogHelper::Context _eNewContext ) // ------------------------------------------------------------------------ FileDialogHelper::FileDialogHelper( - sal_Int64 nFlags, - const String& rFact, - SfxFilterFlags nMust, - SfxFilterFlags nDont ) -{ - mpImp = new FileDialogHelper_Impl( this, getDialogType( nFlags ), nFlags ); - mxImp = mpImp; - - // create the list of filters - mpImp->addFilters( - SfxObjectShell::GetServiceNameFromFactory(rFact), nMust, nDont ); -} - -FileDialogHelper::FileDialogHelper( - sal_Int64 nFlags, - const String& rFact, - sal_Int16 nDialog, - SfxFilterFlags nMust, - SfxFilterFlags nDont, - const String& rStandardDir, - const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList) -{ - mpImp = new FileDialogHelper_Impl( this, getDialogType( nFlags ), nFlags, nDialog, NULL , rStandardDir, rBlackList ); - mxImp = mpImp; - - // create the list of filters - mpImp->addFilters( - SfxObjectShell::GetServiceNameFromFactory(rFact), nMust, nDont ); -} - -// ------------------------------------------------------------------------ -FileDialogHelper::FileDialogHelper( sal_Int64 nFlags ) -{ - sal_Int16 nDialogType = getDialogType( nFlags ); - - mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags ); - mxImp = mpImp; -} - -// ------------------------------------------------------------------------ -FileDialogHelper::FileDialogHelper( sal_Int16 nDialogType, sal_Int64 nFlags, const String& rFact, @@ -2634,31 +2593,6 @@ uno::Reference < XFilePicker > FileDialogHelper::GetFilePicker() const } // ------------------------------------------------------------------------ -sal_Int16 FileDialogHelper::getDialogType( sal_Int64 nFlags ) const -{ - sal_Int16 nDialogType = FILEOPEN_SIMPLE; - - if ( nFlags & WB_SAVEAS ) - { - if ( nFlags & SFXWB_PASSWORD ) - nDialogType = FILESAVE_AUTOEXTENSION_PASSWORD; - else - nDialogType = FILESAVE_SIMPLE; - } - else if ( nFlags & SFXWB_GRAPHIC ) - { - if ( nFlags & SFXWB_SHOWSTYLES ) - nDialogType = FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE; - else - nDialogType = FILEOPEN_LINK_PREVIEW; - } - else if ( SFXWB_INSERT != ( nFlags & SFXWB_INSERT ) ) - nDialogType = FILEOPEN_READONLY_VERSION; - - return nDialogType; -} - -// ------------------------------------------------------------------------ // XFilePickerListener Methods // ------------------------------------------------------------------------ void SAL_CALL FileDialogHelper::FileSelectionChanged( const FilePickerEvent& aEvent ) @@ -2700,7 +2634,8 @@ void SAL_CALL FileDialogHelper::DialogClosed( const DialogClosedEvent& _rEvent ) // ------------------------------------------------------------------------ -ErrCode FileOpenDialog_Impl( sal_Int64 nFlags, +ErrCode FileOpenDialog_Impl( sal_Int16 nDialogType, + sal_Int64 nFlags, const String& rFact, SvStringsDtor *& rpURLList, String& rFilter, @@ -2711,7 +2646,8 @@ ErrCode FileOpenDialog_Impl( sal_Int64 nFlags, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList ) { ErrCode nRet; - FileDialogHelper aDialog( nFlags, rFact, nDialog, 0, 0, rStandardDir, rBlackList ); + FileDialogHelper aDialog( nDialogType, nFlags, + rFact, nDialog, 0, 0, rStandardDir, rBlackList ); String aPath; if ( pPath ) diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx index cb4354b1d2d2..ec22501cdd2d 100644 --- a/sfx2/source/doc/docinsert.cxx +++ b/sfx2/source/doc/docinsert.cxx @@ -52,6 +52,7 @@ #define _SVSTDARR_STRINGSDTOR #include <svl/svstdarr.hxx> +using namespace ::com::sun::star; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::ui::dialogs; using namespace ::com::sun::star::uno; @@ -96,7 +97,9 @@ void DocumentInserter::StartExecuteModal( const Link& _rDialogClosedLink ) DELETEZ( m_pURLList ); if ( !m_pFileDlg ) { - m_pFileDlg = new FileDialogHelper( m_nDlgFlags, m_sDocFactory ); + m_pFileDlg = new FileDialogHelper( + ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, + m_nDlgFlags, m_sDocFactory ); } m_pFileDlg->StartExecuteModal( LINK( this, DocumentInserter, DialogClosedHdl ) ); } diff --git a/sfx2/source/doc/docvor.cxx b/sfx2/source/doc/docvor.cxx index 1a6204506d85..b67d273f0a2c 100644 --- a/sfx2/source/doc/docvor.cxx +++ b/sfx2/source/doc/docvor.cxx @@ -2221,7 +2221,9 @@ IMPL_LINK( SfxOrganizeDlg_Impl, AddFiles_Impl, Button *, pButton ) (void)pButton; //unused if ( pFileDlg ) delete pFileDlg; - pFileDlg = new sfx2::FileDialogHelper( 0, String() ); + pFileDlg = new sfx2::FileDialogHelper( + ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION, + 0, String() ); // add config and basic filter static String sOpenBracket( DEFINE_CONST_UNICODE( " (" ) ); |