summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2013-01-01 22:30:18 +0100
committerPetr Mladek <pmladek@suse.cz>2013-01-08 16:12:45 +0100
commit16f6124c811c24c89e0bcdb6fa2cb89c916a2ccc (patch)
tree84f059433e982f9563c0751beeb79e21d7e48039
parent9dc87d40c88e4ff13cb124b356f648aebff9b3a3 (diff)
Personas: Read the bitmaps in StyleSettings.
Change-Id: I52b67c82f69059a7d2babf1b49e59f27062cc02c Signed-off-by: Cor Nouws <oolst@nouenoff.nl> Signed-off-by: Olivier Hallot <olivier.hallot@documentfoundation.org> Signed-off-by: Adolfo Jayme Barrientos <fitoschido@ubuntu.com> Signed-off-by: Michael Meeks <michael.meeks@suse.com>
-rw-r--r--cui/source/options/personalization.cxx4
-rw-r--r--vcl/inc/vcl/settings.hxx9
-rw-r--r--vcl/source/app/settings.cxx110
3 files changed, 118 insertions, 5 deletions
diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx
index c0d788cc8040..62bb4b2e8038 100644
--- a/cui/source/options/personalization.cxx
+++ b/cui/source/options/personalization.cxx
@@ -124,7 +124,7 @@ sal_Bool SvxPersonalizationTabPage::FillItemSet( SfxItemSet & )
aPersona = "own";
bool bModified = false;
- uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
+ uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
if ( xContext.is() &&
( aBackground != officecfg::Office::Common::Misc::BackgroundImage::get( xContext ) ||
m_aBackgroundURL != officecfg::Office::Common::Misc::BackgroundImageURL::get( xContext ) ||
@@ -147,7 +147,7 @@ sal_Bool SvxPersonalizationTabPage::FillItemSet( SfxItemSet & )
void SvxPersonalizationTabPage::Reset( const SfxItemSet & )
{
- uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
+ uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
// background image
OUString aBackground( "default" );
diff --git a/vcl/inc/vcl/settings.hxx b/vcl/inc/vcl/settings.hxx
index 3a18de34a705..d4d44388d4c4 100644
--- a/vcl/inc/vcl/settings.hxx
+++ b/vcl/inc/vcl/settings.hxx
@@ -29,6 +29,7 @@
#include <i18npool/languagetag.hxx>
#include <unotools/syslocale.hxx>
+class BitmapEx;
class CollatorWrapper;
class LocaleDataWrapper;
@@ -347,6 +348,11 @@ private:
DialogStyle maDialogStyle;
FrameStyle maFrameStyle;
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 )
@@ -860,6 +866,9 @@ public:
void SetFrameStyle( const FrameStyle& rStyle )
{ CopyData(); mpData->maFrameStyle = rStyle; }
+ const BitmapEx* GetPersonaHeader() const;
+ const BitmapEx* GetPersonaFooter() const;
+
void SetStandardStyles();
const StyleSettings& operator =( const StyleSettings& rSet );
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 5370f1cc647a..abaff95fb5b7 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -17,9 +17,13 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <officecfg/Office/Common.hxx>
+
#include <svsys.h>
#include "comphelper/processfactory.hxx"
+#include <rtl/bootstrap.hxx>
#include "tools/debug.hxx"
+#include <vcl/graphicfilter.hxx>
#include "i18npool/mslangid.hxx"
#include "i18npool/languagetag.hxx"
@@ -38,7 +42,7 @@
#include "unotools/confignode.hxx"
#include "unotools/syslocaleoptions.hxx"
-using ::rtl::OUString;
+using namespace ::com::sun::star;
#include "svdata.hxx"
#include "impimagetree.hxx"
@@ -198,7 +202,10 @@ sal_Bool MouseSettings::operator ==( const MouseSettings& rSet ) const
// =======================================================================
-ImplStyleData::ImplStyleData()
+ImplStyleData::ImplStyleData() :
+ maPersonaHeaderFooter(),
+ mpPersonaHeaderBitmap( NULL ),
+ mpPersonaFooterBitmap( NULL )
{
mnRefCount = 1;
mnScrollBarSize = 16;
@@ -296,7 +303,10 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) :
maGroupFont( rData.maGroupFont ),
maWorkspaceGradient( rData.maWorkspaceGradient ),
maDialogStyle( rData.maDialogStyle ),
- maFrameStyle( rData.maFrameStyle )
+ maFrameStyle( rData.maFrameStyle ),
+ maPersonaHeaderFooter( rData.maPersonaHeaderFooter ),
+ mpPersonaHeaderBitmap( NULL ),
+ mpPersonaFooterBitmap( NULL )
{
mnRefCount = 1;
mnBorderSize = rData.mnBorderSize;
@@ -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()
{
CopyData();