Kaydet (Commit) a2500801 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

Personas: Read the bitmaps in StyleSettings.

Change-Id: I52b67c82f69059a7d2babf1b49e59f27062cc02c
üst 0c22f3ea
...@@ -146,7 +146,7 @@ sal_Bool SvxPersonalizationTabPage::FillItemSet( SfxItemSet & ) ...@@ -146,7 +146,7 @@ sal_Bool SvxPersonalizationTabPage::FillItemSet( SfxItemSet & )
aPersona = "own"; aPersona = "own";
bool bModified = false; bool bModified = false;
uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
if ( xContext.is() && if ( xContext.is() &&
( aBackground != officecfg::Office::Common::Misc::BackgroundImage::get( xContext ) || ( aBackground != officecfg::Office::Common::Misc::BackgroundImage::get( xContext ) ||
m_aBackgroundURL != officecfg::Office::Common::Misc::BackgroundImageURL::get( xContext ) || m_aBackgroundURL != officecfg::Office::Common::Misc::BackgroundImageURL::get( xContext ) ||
...@@ -171,7 +171,7 @@ sal_Bool SvxPersonalizationTabPage::FillItemSet( SfxItemSet & ) ...@@ -171,7 +171,7 @@ sal_Bool SvxPersonalizationTabPage::FillItemSet( SfxItemSet & )
void SvxPersonalizationTabPage::Reset( const SfxItemSet & ) void SvxPersonalizationTabPage::Reset( const SfxItemSet & )
{ {
uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
// background image // background image
OUString aBackground( "default" ); OUString aBackground( "default" );
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <i18npool/languagetag.hxx> #include <i18npool/languagetag.hxx>
#include <unotools/syslocale.hxx> #include <unotools/syslocale.hxx>
class BitmapEx;
class CollatorWrapper; class CollatorWrapper;
class LocaleDataWrapper; class LocaleDataWrapper;
...@@ -347,6 +348,11 @@ private: ...@@ -347,6 +348,11 @@ private:
DialogStyle maDialogStyle; DialogStyle maDialogStyle;
FrameStyle maFrameStyle; FrameStyle maFrameStyle;
const void* mpFontOptions; const void* mpFontOptions;
OUString maPersonaHeaderFooter; ///< Cache the settings to detect changes.
BitmapEx* mpPersonaHeaderBitmap; ///< Cache the header bitmap.
BitmapEx* mpPersonaFooterBitmap; ///< Cache the footer bitmap.
}; };
#define DEFAULT_WORKSPACE_GRADIENT_START_COLOR Color( 0xa3, 0xae, 0xb8 ) #define DEFAULT_WORKSPACE_GRADIENT_START_COLOR Color( 0xa3, 0xae, 0xb8 )
...@@ -860,6 +866,9 @@ public: ...@@ -860,6 +866,9 @@ public:
void SetFrameStyle( const FrameStyle& rStyle ) void SetFrameStyle( const FrameStyle& rStyle )
{ CopyData(); mpData->maFrameStyle = rStyle; } { CopyData(); mpData->maFrameStyle = rStyle; }
const BitmapEx* GetPersonaHeader() const;
const BitmapEx* GetPersonaFooter() const;
void SetStandardStyles(); void SetStandardStyles();
const StyleSettings& operator =( const StyleSettings& rSet ); const StyleSettings& operator =( const StyleSettings& rSet );
......
...@@ -17,9 +17,13 @@ ...@@ -17,9 +17,13 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <officecfg/Office/Common.hxx>
#include <svsys.h> #include <svsys.h>
#include "comphelper/processfactory.hxx" #include "comphelper/processfactory.hxx"
#include <rtl/bootstrap.hxx>
#include "tools/debug.hxx" #include "tools/debug.hxx"
#include <vcl/graphicfilter.hxx>
#include "i18npool/mslangid.hxx" #include "i18npool/mslangid.hxx"
#include "i18npool/languagetag.hxx" #include "i18npool/languagetag.hxx"
...@@ -38,7 +42,7 @@ ...@@ -38,7 +42,7 @@
#include "unotools/confignode.hxx" #include "unotools/confignode.hxx"
#include "unotools/syslocaleoptions.hxx" #include "unotools/syslocaleoptions.hxx"
using ::rtl::OUString; using namespace ::com::sun::star;
#include "svdata.hxx" #include "svdata.hxx"
#include "impimagetree.hxx" #include "impimagetree.hxx"
...@@ -198,7 +202,10 @@ sal_Bool MouseSettings::operator ==( const MouseSettings& rSet ) const ...@@ -198,7 +202,10 @@ sal_Bool MouseSettings::operator ==( const MouseSettings& rSet ) const
// ======================================================================= // =======================================================================
ImplStyleData::ImplStyleData() ImplStyleData::ImplStyleData() :
maPersonaHeaderFooter(),
mpPersonaHeaderBitmap( NULL ),
mpPersonaFooterBitmap( NULL )
{ {
mnRefCount = 1; mnRefCount = 1;
mnScrollBarSize = 16; mnScrollBarSize = 16;
...@@ -296,7 +303,10 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) : ...@@ -296,7 +303,10 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) :
maGroupFont( rData.maGroupFont ), maGroupFont( rData.maGroupFont ),
maWorkspaceGradient( rData.maWorkspaceGradient ), maWorkspaceGradient( rData.maWorkspaceGradient ),
maDialogStyle( rData.maDialogStyle ), maDialogStyle( rData.maDialogStyle ),
maFrameStyle( rData.maFrameStyle ) maFrameStyle( rData.maFrameStyle ),
maPersonaHeaderFooter( rData.maPersonaHeaderFooter ),
mpPersonaHeaderBitmap( NULL ),
mpPersonaFooterBitmap( NULL )
{ {
mnRefCount = 1; mnRefCount = 1;
mnBorderSize = rData.mnBorderSize; mnBorderSize = rData.mnBorderSize;
...@@ -677,6 +687,100 @@ sal_Bool StyleSettings::GetUseImagesInMenus() const ...@@ -677,6 +687,100 @@ sal_Bool StyleSettings::GetUseImagesInMenus() const
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
static BitmapEx* readBitmapEx( const OUString& rPath )
{
OUString aPath( rPath );
rtl::Bootstrap::expandMacros( aPath );
// import the image
Graphic aGraphic;
if ( GraphicFilter::LoadGraphic( aPath, String(), aGraphic ) != GRFILTER_OK )
return NULL;
const BitmapEx& rBitmap( aGraphic.GetBitmapEx() );
if ( rBitmap.IsEmpty() )
return NULL;
return new BitmapEx( rBitmap );
}
enum WhichPersona { PERSONA_HEADER, PERSONA_FOOTER };
/** Update the setting of the Persona header / footer in ImplStyleData */
static void setupPersonaHeaderFooter( WhichPersona eWhich, OUString& rHeaderFooter, BitmapEx*& pHeaderFooterBitmap )
{
uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
if ( !xContext.is() )
return;
// read from the configuration
OUString aPersona( officecfg::Office::Common::Misc::Persona::get( xContext ) );
OUString aPersonaSettings( officecfg::Office::Common::Misc::PersonaSettings::get( xContext ) );
// have the settings changed?
OUString aOldValue( aPersona + ";" + aPersonaSettings );
if ( rHeaderFooter == aOldValue )
return;
rHeaderFooter = aOldValue;
// now read the new values and setup bitmaps
OUString aHeader, aFooter;
if ( aPersona == "own" )
{
sal_Int32 nIndex = 0;
aHeader = aPersonaSettings.getToken( 0, ';', nIndex );
if ( nIndex > 0 )
aFooter = aPersonaSettings.getToken( 0, ';', nIndex );
}
else if ( aPersona == "default" )
{
aHeader = "header.jpg";
aFooter = "footer.jpg";
}
OUString aName;
switch ( eWhich ) {
case PERSONA_HEADER: aName = aHeader; break;
case PERSONA_FOOTER: aName = aFooter; break;
}
delete pHeaderFooterBitmap;
pHeaderFooterBitmap = NULL;
if ( !aName.isEmpty() )
{
// try the gallery first, then edition, and the program path if
// everything else fails
OUString gallery = "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}";
rtl::Bootstrap::expandMacros( gallery );
gallery += "/user/gallery/personas/";
if ( aPersona == "own" )
pHeaderFooterBitmap = readBitmapEx( gallery + aName );
if ( !pHeaderFooterBitmap )
pHeaderFooterBitmap = readBitmapEx( "$BRAND_BASE_DIR/program/edition/" + aName );
if ( !pHeaderFooterBitmap )
pHeaderFooterBitmap = readBitmapEx( "$BRAND_BASE_DIR/program/" + aName );
}
}
const BitmapEx* StyleSettings::GetPersonaHeader() const
{
setupPersonaHeaderFooter( PERSONA_HEADER, mpData->maPersonaHeaderFooter, mpData->mpPersonaHeaderBitmap );
return mpData->mpPersonaHeaderBitmap;
}
const BitmapEx* StyleSettings::GetPersonaFooter() const
{
setupPersonaHeaderFooter( PERSONA_FOOTER, mpData->maPersonaHeaderFooter, mpData->mpPersonaFooterBitmap );
return mpData->mpPersonaFooterBitmap;
}
// -----------------------------------------------------------------------
void StyleSettings::SetStandardStyles() void StyleSettings::SetStandardStyles()
{ {
CopyData(); CopyData();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment