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 | |
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
-rw-r--r-- | cui/source/options/personalization.cxx | 54 | ||||
-rw-r--r-- | cui/source/options/personalization.hxx | 2 | ||||
-rw-r--r-- | cui/uiconfig/ui/personalization_tab.ui | 76 | ||||
-rw-r--r-- | officecfg/registry/schema/org/openoffice/Office/Common.xcs | 23 | ||||
-rw-r--r-- | vcl/source/app/settings.cxx | 2 |
5 files changed, 137 insertions, 20 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; diff --git a/cui/uiconfig/ui/personalization_tab.ui b/cui/uiconfig/ui/personalization_tab.ui index 677d5fc13298..e2f4332724cd 100644 --- a/cui/uiconfig/ui/personalization_tab.ui +++ b/cui/uiconfig/ui/personalization_tab.ui @@ -58,24 +58,23 @@ </packing> </child> <child> - <object class="GtkBox" id="box1"> + <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="spacing">6</property> + <property name="row_spacing">6</property> + <property name="column_spacing">6</property> <child> <object class="GtkButton" id="default1"> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <child> - <placeholder/> - </child> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> @@ -84,14 +83,12 @@ <property name="receives_default">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <child> - <placeholder/> - </child> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> @@ -100,19 +97,62 @@ <property name="receives_default">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="extension1"> + <property name="can_focus">True</property> + <property name="receives_default">True</property> <child> <placeholder/> </child> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="extension2"> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="extension3"> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> </object> <packing> - <property name="expand">False</property> + <property name="expand">True</property> <property name="fill">True</property> <property name="position">2</property> </packing> diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 866ad15678fa..d5e926b12b85 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -806,6 +806,24 @@ <value/> </prop> </group> + <group oor:name="PersonasEntry"> + <info> + <desc>Stores the details of the installed personas.</desc> + </info> + <prop oor:name="PersonaPreview" oor:type="xs:string" oor:nillable="false"> + <info> + <desc>Name of the preview file for the Persona to show in the UI</desc> + </info> + </prop> + <prop oor:name="PersonaSettings" oor:type="xs:string" oor:nillable="false"> + <info> + <desc>Names of the header and footer images, and colors for text and + accent. When set, the value has form + "header.jpg;footer.jpg;#RGBTXT;#RGBACC".</desc> + </info> + <value/> + </prop> + </group> </templates> <component> <group oor:name="InternalMSExport"> @@ -5738,6 +5756,11 @@ <desc>List of names of the CMIS servers in the place edition dialog.</desc> </info> </prop> + <set oor:name="PersonasList" oor:node-type="PersonasEntry"> + <info> + <desc>Contains the Personas installed through extensions</desc> + </info> + </set> </group> <group oor:name="Forms"> <info> diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index 42787205e5fa..ebaa4eb1ebbe 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -2158,7 +2158,7 @@ static void setupPersonaHeaderFooter( WhichPersona eWhich, OUString& rHeaderFoot rtl::Bootstrap::expandMacros( gallery ); gallery += "/user/gallery/personas/"; } - else if (aPersona == "default") + else if ( aPersona == "default" && !aPersonaSettings.startsWith( "vnd.sun.star.expand" ) ) { gallery = "$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER; gallery += "/gallery/personas/"; |