diff options
author | Rachit Gupta <rachitgupta1792@gmail.com> | 2014-06-27 23:52:42 +0530 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2014-08-14 19:43:29 +0200 |
commit | 4017908018a0ccc771247f09c47798dd20644db3 (patch) | |
tree | 28319be1d08e4b1d1203c798e75ba60e4c66ad6d /cui/source | |
parent | e7e5ab1683a86de587f2c8b5511d13c334548903 (diff) |
The Personas can be install through oxt extensions.
The user can install an oxt extension and choose his/her theme from
the Personalization page.
* Created a template in Common.xcs registry to hold the values for the
PersonasList set.
* Added 3 buttons to personalization_tab.ui to incorporate the latest 3
personas installed through extensions.
* Currently, only 3 installed personas are shown alongwith the default
available personas.
Change-Id: I30a40ae48d17f4ed8caef33854ef88afcbec5a54
Diffstat (limited to 'cui/source')
-rw-r--r-- | cui/source/options/personalization.cxx | 54 | ||||
-rw-r--r-- | cui/source/options/personalization.hxx | 2 |
2 files changed, 55 insertions, 1 deletions
diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx index 022472ef6738..4c9781cbe53c 100644 --- a/cui/source/options/personalization.cxx +++ b/cui/source/options/personalization.cxx @@ -14,6 +14,8 @@ #include <comphelper/processfactory.hxx> #include <officecfg/Office/Common.hxx> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <osl/file.hxx> #include <rtl/bootstrap.hxx> #include <tools/urlobj.hxx> @@ -31,6 +33,7 @@ using namespace com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::ucb; +using namespace ::com::sun::star::beans; SelectPersonaDialog::SelectPersonaDialog( Window *pParent ) : ModalDialog( pParent, "SelectPersonaDialog", "cui/ui/select_persona_dialog.ui" ) @@ -241,6 +244,15 @@ SvxPersonalizationTabPage::SvxPersonalizationTabPage( Window *pParent, const Sfx get( m_vDefaultPersonaImages[2], "default3" ); m_vDefaultPersonaImages[2]->SetClickHdl( LINK( this, SvxPersonalizationTabPage, DefaultPersona ) ); + get( m_vExtensionPersonas[0], "extension1" ); + m_vExtensionPersonas[0]->SetClickHdl( LINK( this, SvxPersonalizationTabPage, DefaultPersona ) ); + + get( m_vExtensionPersonas[1], "extension2" ); + m_vExtensionPersonas[1]->SetClickHdl( LINK( this, SvxPersonalizationTabPage, DefaultPersona ) ); + + get( m_vExtensionPersonas[2], "extension3" ); + m_vExtensionPersonas[2]->SetClickHdl( LINK( this, SvxPersonalizationTabPage, DefaultPersona ) ); + LoadDefaultImages(); } @@ -273,7 +285,6 @@ bool SvxPersonalizationTabPage::FillItemSet( SfxItemSet * ) // write boost::shared_ptr< comphelper::ConfigurationChanges > batch( comphelper::ConfigurationChanges::create() ); - officecfg::Office::Common::Misc::Persona::set( aPersona, batch ); officecfg::Office::Common::Misc::PersonaSettings::set( m_aPersonaSettings, batch ); batch->commit(); @@ -316,6 +327,8 @@ void SvxPersonalizationTabPage::SetPersonaSettings( const OUString aPersonaSetti void SvxPersonalizationTabPage::LoadDefaultImages() { + // Load the pre saved personas + OUString gallery( "" ); gallery = "$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER; gallery += "/gallery/personas/"; @@ -345,6 +358,38 @@ void SvxPersonalizationTabPage::LoadDefaultImages() m_vDefaultPersonaImages[nIndex]->Show(); m_vDefaultPersonaImages[nIndex++]->SetModeImage( Image( aBmp ) ); } + + // See if any extensions are used to install personas. If yes, load them. + + css::uno::Sequence<OUString> installedPersonas( officecfg::Office::Common::Misc::PersonasList::get()->getElementNames() ); + sal_Int32 nLength = installedPersonas.getLength(); + sal_Int32 nCount = 0; + nIndex = 0; + + if( nLength == 0 ) + return; + + if( nLength > 3 ) + nIndex = nLength - 3; + + for( ; nIndex < nLength; nIndex++ ) + { + Reference< XPropertySet > xPropertySet( officecfg::Office::Common::Misc::PersonasList::get()->getByName( installedPersonas[nIndex] ), UNO_QUERY_THROW ); + Any aValue = xPropertySet->getPropertyValue( "PersonaPreview" ); + OUString aPreviewFile; + aValue >>= aPreviewFile; + INetURLObject aURLObj( aPreviewFile ); + aFilter.ImportGraphic( aGraphic, aURLObj ); + Bitmap aBmp = aGraphic.GetBitmap(); + m_vExtensionPersonas[nCount]->Show(); + m_vExtensionPersonas[nCount++]->SetModeImage( Image( aBmp ) ); + + aValue = xPropertySet->getPropertyValue( "PersonaSettings" ); + OUString sPersonaSettings; + aValue >>= sPersonaSettings; + rtl::Bootstrap::expandMacros( sPersonaSettings ); + m_vExtensionPersonaSettings.push_back( sPersonaSettings ); + } } IMPL_LINK( SvxPersonalizationTabPage, SelectPersona, PushButton*, /*pButton*/ ) @@ -381,6 +426,13 @@ IMPL_LINK( SvxPersonalizationTabPage, DefaultPersona, PushButton*, pButton ) if( pButton == m_vDefaultPersonaImages[nIndex] ) m_aPersonaSettings = m_vDefaultPersonaSettings[nIndex]; } + + for( sal_Int32 nIndex = 0; nIndex < 3; nIndex++ ) + { + if( pButton == m_vExtensionPersonas[nIndex] ) + m_aPersonaSettings = m_vExtensionPersonaSettings[nIndex]; + } + return 0; } diff --git a/cui/source/options/personalization.hxx b/cui/source/options/personalization.hxx index 5e2308c59e2c..98bff5d244b3 100644 --- a/cui/source/options/personalization.hxx +++ b/cui/source/options/personalization.hxx @@ -30,9 +30,11 @@ private: RadioButton *m_pOwnPersona; ///< Use the user-defined bitmap PushButton *m_pSelectPersona; ///< Let the user select in the 'own' case PushButton *m_vDefaultPersonaImages[3]; ///< Buttons to show the default persona images + PushButton *m_vExtensionPersonas[3]; ///< Buttons to show the last 3 personas installed via extensions OUString m_aPersonaSettings; ///< Header and footer images + color to be set in the settings. std::vector<OUString> m_vDefaultPersonaSettings; + std::vector<OUString> m_vExtensionPersonaSettings; public: ::rtl::Reference< SearchAndParseThread > m_rApplyThread; |