summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2012-12-04 00:16:18 +0100
committerJan Holesovsky <kendy@suse.cz>2012-12-04 16:23:14 +0100
commit03f04a9ee298ad968d00910f0f96a0a834ec7cda (patch)
tree6ae30929c2953e501d0182b43c52bc1ac1471060 /cui
parent2437cf972a9dbf7ab11e18e7fd8b43ef5f6a63e0 (diff)
Personas: File dialog for the selection of the background image.
Change-Id: Iafb5c62f310a6fd1658a7fa80346fa3510fc38e7
Diffstat (limited to 'cui')
-rw-r--r--cui/source/options/personalization.cxx40
1 files changed, 38 insertions, 2 deletions
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 <officecfg/Office/Common.hxx>
#include <vcl/msgbox.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+
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;
}