From 03f04a9ee298ad968d00910f0f96a0a834ec7cda Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Tue, 4 Dec 2012 00:16:18 +0100 Subject: Personas: File dialog for the selection of the background image. Change-Id: Iafb5c62f310a6fd1658a7fa80346fa3510fc38e7 --- cui/source/options/personalization.cxx | 40 ++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'cui') diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx index 1bfe549c2be8..25cc8d04c46a 100644 --- a/cui/source/options/personalization.cxx +++ b/cui/source/options/personalization.cxx @@ -13,6 +13,13 @@ #include #include +#include +#include +#include +#include +#include +#include + using namespace com::sun::star; /** Dialog that will allow the user to choose a Persona to use. @@ -134,8 +141,37 @@ void SvxPersonalizationTabPage::Reset( const SfxItemSet & ) IMPL_LINK( SvxPersonalizationTabPage, SelectBackground, PushButton*, /*pButton*/ ) { - // TODO m_pOwnBackground->Check(); if something selected - // TODO parse the results + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); + if ( !xFactory.is() ) + return 0; + + uno::Reference< ui::dialogs::XFilePicker > xFilePicker( xFactory->createInstance( "com.sun.star.ui.dialogs.FilePicker" ), uno::UNO_QUERY ); + if ( !xFilePicker.is() ) + return 0; + + xFilePicker->setMultiSelectionMode( false ); + + uno::Reference< ui::dialogs::XFilePickerControlAccess > xController( xFilePicker, uno::UNO_QUERY ); + if ( xController.is() ) + xController->setValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, uno::makeAny( sal_True ) ); + + uno::Reference< ui::dialogs::XFilterManager > xFilterMgr( xFilePicker, uno::UNO_QUERY ); + if ( xFilterMgr.is() ) + xFilterMgr->appendFilter( "Background images (*.jpg;*.png)", "*.jpg;*.png" ); // TODO localize + + while ( xFilePicker->execute() == ui::dialogs::ExecutableDialogResults::OK ) + { + OUString aFile( xFilePicker->getFiles()[0] ); + + if ( aFile.startsWith( "file:///" ) && ( aFile.endsWith( ".png" ) || aFile.endsWith( ".jpg" ) ) ) + { + m_aBackgroundURL = aFile; + m_pOwnBackground->Check(); + break; + } + + // TODO display what is wrong (not a file:// or not .png / .jpg) + } return 0; } -- cgit