1 --- vcl/source/gdi/impimagetree.cxx.old 2009-08-26 10:25:02.000000000 +0000
2 +++ vcl/source/gdi/impimagetree.cxx 2009-09-11 14:53:46.000000000 +0000
4 #include "com/sun/star/uno/RuntimeException.hpp"
5 #include "com/sun/star/uno/Sequence.hxx"
6 #include "comphelper/processfactory.hxx"
7 +#include "osl/file.hxx"
8 #include "osl/diagnose.h"
9 #include "rtl/bootstrap.hxx"
10 #include "rtl/string.h"
11 @@ -123,12 +124,43 @@ ImplImageTree::ImplImageTree()
13 ImplImageTree::~ImplImageTree() {}
15 +bool ImplImageTree::checkStyle(rtl::OUString const & style)
19 + // using cache because setStyle is an expensive operation
20 + // setStyle calls resetZips => closes any opened zip files with icons, cleans the icon cache, ...
21 + if (checkStyleCacheLookup(style, exists)) {
28 + const rtl::OUString sBrandURLSuffix(RTL_CONSTASCII_USTRINGPARAM("_brand.zip"));
29 + for (Zips::iterator i(m_zips.begin()); i != m_zips.end() && !exists;) {
30 + ::rtl::OUString aZipURL = i->first;
31 + sal_Int32 nFromIndex = aZipURL.getLength() - sBrandURLSuffix.getLength();
32 + // skip brand-specific icon themes; they are incomplete and thus not useful for this check
33 + if (nFromIndex < 0 || !aZipURL.match(sBrandURLSuffix, nFromIndex)) {
34 + osl::File aZip(aZipURL);
35 + if (aZip.open(OpenFlag_Read) == ::osl::FileBase::E_None) {
42 + m_checkStyleCache[style] = exists;
46 bool ImplImageTree::loadImage(
47 rtl::OUString const & name, rtl::OUString const & style, BitmapEx & bitmap,
51 - if (cacheLookup(name, localized, bitmap)) {
52 + if (iconCacheLookup(name, localized, bitmap)) {
55 if (!bitmap.IsEmpty()) {
56 @@ -169,7 +201,7 @@ bool ImplImageTree::loadImage(
57 rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
60 - m_cache[name.intern()] = std::make_pair(localized, bitmap);
61 + m_iconCache[name.intern()] = std::make_pair(localized, bitmap);
65 @@ -178,7 +210,8 @@ void ImplImageTree::shutDown() {
66 m_style = rtl::OUString();
67 // for safety; empty m_style means "not initialized"
70 + m_iconCache.clear();
71 + m_checkStyleCache.clear();
74 void ImplImageTree::setStyle(rtl::OUString const & style) {
75 @@ -186,7 +219,7 @@ void ImplImageTree::setStyle(rtl::OUStri
76 if (style != m_style) {
80 + m_iconCache.clear();
84 @@ -243,6 +276,7 @@ void ImplImageTree::resetZips() {
85 u.GetMainURL(INetURLObject::NO_DECODE),
86 css::uno::Reference< css::container::XNameAccess >()));
88 + if ( m_style.equals(::rtl::OUString::createFromAscii("default")) )
91 RTL_CONSTASCII_USTRINGPARAM(
92 @@ -252,11 +286,23 @@ void ImplImageTree::resetZips() {
96 -bool ImplImageTree::cacheLookup(
97 +bool ImplImageTree::checkStyleCacheLookup(
98 + rtl::OUString const & style, bool &exists)
100 + CheckStyleCache::iterator i(m_checkStyleCache.find(style));
101 + if (i != m_checkStyleCache.end()) {
102 + exists = i->second;
109 +bool ImplImageTree::iconCacheLookup(
110 rtl::OUString const & name, bool localized, BitmapEx & bitmap)
112 - Cache::iterator i(m_cache.find(name));
113 - if (i != m_cache.end() && i->second.first == localized) {
114 + IconCache::iterator i(m_iconCache.find(name));
115 + if (i != m_iconCache.end() && i->second.first == localized) {
116 bitmap = i->second.second;
119 --- vcl/source/app/settings.cxx.old 2009-08-26 10:25:12.000000000 +0000
120 +++ vcl/source/app/settings.cxx 2009-09-11 15:12:56.000000000 +0000
122 #include "vcl/configsettings.hxx"
123 #include "vcl/gradient.hxx"
124 #include "vcl/unohelp.hxx"
125 +#include "vcl/bitmapex.hxx"
126 +#include "vcl/impimagetree.hxx"
127 #include "unotools/localedatawrapper.hxx"
128 #include "unotools/collatorwrapper.hxx"
129 #include "unotools/configmgr.hxx"
130 @@ -770,12 +772,12 @@ ULONG StyleSettings::GetCurrentSymbolsSt
131 // style selected in Tools -> Options... -> OpenOffice.org -> View
132 ULONG nStyle = GetSymbolsStyle();
134 - if ( nStyle == STYLE_SYMBOLS_AUTO )
135 + if ( nStyle == STYLE_SYMBOLS_AUTO || ( !CheckSymbolStyle (nStyle) ) )
137 // the preferred style can be read from the desktop setting by the desktop native widgets modules
138 ULONG nPreferredStyle = GetPreferredSymbolsStyle();
140 - if ( nPreferredStyle == STYLE_SYMBOLS_AUTO )
141 + if ( nPreferredStyle == STYLE_SYMBOLS_AUTO || ( !CheckSymbolStyle (nPreferredStyle) ) )
144 // use a hardcoded desktop-specific fallback if no preferred style has been detected
145 @@ -784,14 +786,17 @@ ULONG StyleSettings::GetCurrentSymbolsSt
147 if ( !sbFallbackDesktopChecked )
149 - snFallbackDesktopStyle = GetAutoSymbolsStyle();
150 + snFallbackDesktopStyle = GetAutoSymbolsStyle();
151 sbFallbackDesktopChecked = true;
154 nPreferredStyle = snFallbackDesktopStyle;
157 - nStyle = GetHighContrastMode()? STYLE_SYMBOLS_HICONTRAST: nPreferredStyle;
158 + if (GetHighContrastMode() && CheckSymbolStyle (STYLE_SYMBOLS_HICONTRAST) )
159 + nStyle = STYLE_SYMBOLS_HICONTRAST;
161 + nStyle = nPreferredStyle;
165 @@ -830,10 +835,43 @@ ULONG StyleSettings::GetAutoSymbolsStyle
166 nRet = STYLE_SYMBOLS_OXYGEN;
169 + // falback to any existing style
170 + if ( ! CheckSymbolStyle (nRet) )
172 + for ( ULONG n = 0 ; n <= STYLE_SYMBOLS_THEMES_MAX ; n++ )
174 + ULONG nStyleToCheck = n;
176 + // auto is not a real theme => can't be fallback
177 + if ( nStyleToCheck == STYLE_SYMBOLS_AUTO )
180 + // will check hicontrast in the end
181 + if ( nStyleToCheck == STYLE_SYMBOLS_HICONTRAST )
183 + if ( nStyleToCheck == STYLE_SYMBOLS_THEMES_MAX )
184 + nStyleToCheck = STYLE_SYMBOLS_HICONTRAST;
186 + if ( CheckSymbolStyle ( nStyleToCheck ) )
188 + nRet = nStyleToCheck;
189 + n = STYLE_SYMBOLS_THEMES_MAX;
197 // -----------------------------------------------------------------------
199 +bool StyleSettings::CheckSymbolStyle( ULONG nStyle ) const
201 + static ImplImageTreeSingletonRef aImageTree;
202 + return aImageTree->checkStyle( ImplSymbolsStyleToName( nStyle ) );
205 +// -----------------------------------------------------------------------
207 void StyleSettings::SetStandardStyles()
209 --- vcl/inc/vcl/settings.hxx.old 2009-08-26 10:25:12.000000000 +0000
210 +++ vcl/inc/vcl/settings.hxx 2009-09-10 15:27:10.000000000 +0000
211 @@ -520,7 +520,7 @@ private:
212 #define STYLE_SYMBOLS_TANGO ((ULONG)5)
213 #define STYLE_SYMBOLS_CLASSIC ((ULONG)6)
214 #define STYLE_SYMBOLS_OXYGEN ((ULONG)7)
215 -#define STYLE_SYMBOLS_THEMES_MAX ((ULONG)7)
216 +#define STYLE_SYMBOLS_THEMES_MAX ((ULONG)8)
218 #define STYLE_CURSOR_NOBLINKTIME ((ULONG)0xFFFFFFFF)
220 @@ -944,6 +944,8 @@ public:
221 void SetPreferredSymbolsStyleName( const ::rtl::OUString &rName );
222 ULONG GetPreferredSymbolsStyle() const
223 { return mpData->mnPreferredSymbolsStyle; }
224 + // check whether the symbols style is supported (icons are installed)
225 + bool CheckSymbolStyle( ULONG nStyle ) const;
226 ULONG GetAutoSymbolsStyle() const;
228 ULONG GetCurrentSymbolsStyle() const;
229 --- vcl/inc/vcl/impimagetree.hxx.old 2009-08-26 10:25:02.000000000 +0000
230 +++ vcl/inc/vcl/impimagetree.hxx 2009-09-11 14:53:11.000000000 +0000
231 @@ -54,6 +54,9 @@ public:
235 + // check whether the icon style is installed
236 + bool checkStyle(rtl::OUString const & style);
239 rtl::OUString const & name, rtl::OUString const & style,
240 BitmapEx & bitmap, bool localized = false);
241 @@ -61,7 +64,7 @@ public:
243 // a crude form of life cycle control (called from DeInitVCL; otherwise,
244 // if the ImplImageTree singleton were destroyed during exit that would
245 - // be too late for the destructors of the bitmaps in m_cache)
246 + // be too late for the destructors of the bitmaps in m_iconCache)
250 @@ -71,7 +74,9 @@ private:
251 com::sun::star::container::XNameAccess > > > Zips;
253 typedef std::hash_map<
254 - rtl::OUString, std::pair< bool, BitmapEx >, rtl::OUStringHash > Cache;
255 + rtl::OUString, bool, rtl::OUStringHash > CheckStyleCache;
256 + typedef std::hash_map<
257 + rtl::OUString, std::pair< bool, BitmapEx >, rtl::OUStringHash > IconCache;
259 rtl::OUString m_style;
261 @@ -79,13 +84,16 @@ private:
263 rtl::OUString m_style;
266 + CheckStyleCache m_checkStyleCache;
267 + IconCache m_iconCache;
269 void setStyle(rtl::OUString const & style);
274 + bool checkStyleCacheLookup(
275 + rtl::OUString const & style, bool &exists);
276 + bool iconCacheLookup(
277 rtl::OUString const & name, bool localized, BitmapEx & bitmap);
279 bool find(std::vector< rtl::OUString > const & paths, BitmapEx & bitmap);
280 --- svx/source/cui/optgdlg.cxx.old 2009-08-26 10:25:14.000000000 +0000
281 +++ svx/source/cui/optgdlg.cxx 2009-09-11 15:20:42.000000000 +0000
282 @@ -802,6 +802,31 @@ OfaViewTabPage::OfaViewTabPage(Window* p
283 m_aSystemFont.Enable( FALSE );
286 + const StyleSettings& aStyleSettings = Application::GetSettings().GetStyleSettings();
288 + // remove non-installed icon themes
289 + if( aIconStyleLB.GetEntryCount() == STYLE_SYMBOLS_THEMES_MAX )
291 + // do not check 0th item == auto; it is not a real theme
292 + aIconStyleItemId[0] = 0;
294 + for ( ULONG n=0; ++n < STYLE_SYMBOLS_THEMES_MAX; )
296 + if ( aStyleSettings.CheckSymbolStyle( n ) )
298 + // existing style => save the item id
299 + aIconStyleItemId[n] = nItem++;
303 + // non-existing style => remove item;
304 + aIconStyleLB.RemoveEntry( nItem );
305 + aIconStyleItemId[n] = 0;
311 // add real theme name to 'auto' theme, e.g. 'auto' => 'auto (classic)'
312 if( aIconStyleLB.GetEntryCount() > 1 )
314 @@ -809,20 +834,14 @@ OfaViewTabPage::OfaViewTabPage(Window* p
316 aAutoStr += ::rtl::OUString::createFromAscii( " (" );
318 - switch( Application::GetSettings().GetStyleSettings().GetAutoSymbolsStyle() )
320 - case STYLE_SYMBOLS_DEFAULT: aAutoStr += aIconStyleLB.GetEntry( 1 ); break;
321 - case STYLE_SYMBOLS_INDUSTRIAL: aAutoStr += aIconStyleLB.GetEntry( 2 ); break;
322 - case STYLE_SYMBOLS_CRYSTAL: aAutoStr += aIconStyleLB.GetEntry( 3 ); break;
323 - case STYLE_SYMBOLS_TANGO: aAutoStr += aIconStyleLB.GetEntry( 4 ); break;
324 - case STYLE_SYMBOLS_CLASSIC: aAutoStr += aIconStyleLB.GetEntry( 5 ); break;
325 - case STYLE_SYMBOLS_HICONTRAST: aAutoStr += aIconStyleLB.GetEntry( 6 ); break;
326 - case STYLE_SYMBOLS_OXYGEN: aAutoStr += aIconStyleLB.GetEntry( 7 ); break;
328 + ULONG nAutoStyle = aStyleSettings.GetAutoSymbolsStyle();
329 + if ( aIconStyleItemId[nAutoStyle] )
330 + aAutoStr += aIconStyleLB.GetEntry( aIconStyleItemId[nAutoStyle] );
332 aIconStyleLB.RemoveEntry( 0 );
333 aIconStyleLB.InsertEntry( aAutoStr += ::rtl::OUString::createFromAscii( ")" ), 0 );
334 - aIconStyleLB.SetSeparatorPos( aIconStyleLB.GetEntryCount() - 2 );
335 + // separate auto and other icon themes
336 + aIconStyleLB.SetSeparatorPos( 0 );
340 @@ -891,26 +910,18 @@ BOOL OfaViewTabPage::FillItemSet( SfxIte
341 UINT16 nStyleLB_NewSelection = aIconStyleLB.GetSelectEntryPos();
342 if( nStyleLB_InitialSelection != nStyleLB_NewSelection )
344 - sal_Int16 eSet = SFX_SYMBOLS_STYLE_AUTO;
345 - switch( nStyleLB_NewSelection )
347 - case 0: eSet = SFX_SYMBOLS_STYLE_AUTO; break;
348 - case 1: eSet = SFX_SYMBOLS_STYLE_DEFAULT; break;
349 - case 2: eSet = SFX_SYMBOLS_STYLE_HICONTRAST; break;
350 - case 3: eSet = SFX_SYMBOLS_STYLE_INDUSTRIAL; break;
351 - case 4: eSet = SFX_SYMBOLS_STYLE_CRYSTAL; break;
352 - case 5: eSet = SFX_SYMBOLS_STYLE_TANGO; break;
353 - case 6: eSet = SFX_SYMBOLS_STYLE_CLASSIC; break;
354 - case 7: eSet = SFX_SYMBOLS_STYLE_OXYGEN; break;
356 - DBG_ERROR( "OfaViewTabPage::FillItemSet(): This state of aIconStyleLB should not be possible!" );
358 - aMiscOptions.SetSymbolsStyle( eSet );
359 + // find the style name in the aIconStyleItemId table
360 + // items from the non-installed icon themes were removed
361 + for ( ULONG n=0; n < STYLE_SYMBOLS_THEMES_MAX; n++ )
362 + if ( aIconStyleItemId[n] == nStyleLB_NewSelection )
364 + aMiscOptions.SetSymbolsStyle( n );
365 + n = STYLE_SYMBOLS_THEMES_MAX;
369 BOOL bAppearanceChanged = FALSE;
373 UINT16 nOldScale = pAppearanceCfg->GetScaleFactor();
374 UINT16 nNewScale = (UINT16)aWindowSizeMF.GetValue();
375 @@ -1052,20 +1063,7 @@ void OfaViewTabPage::Reset( const SfxIte
376 aIconSizeLB.SaveValue();
378 if( aMiscOptions.GetSymbolsStyle() != SFX_SYMBOLS_STYLE_AUTO )
380 - switch ( aMiscOptions.GetCurrentSymbolsStyle() )
382 - case SFX_SYMBOLS_STYLE_DEFAULT: nStyleLB_InitialSelection = 1; break;
383 - case SFX_SYMBOLS_STYLE_HICONTRAST: nStyleLB_InitialSelection = 2; break;
384 - case SFX_SYMBOLS_STYLE_INDUSTRIAL: nStyleLB_InitialSelection = 3; break;
385 - case SFX_SYMBOLS_STYLE_CRYSTAL: nStyleLB_InitialSelection = 4; break;
386 - case SFX_SYMBOLS_STYLE_TANGO: nStyleLB_InitialSelection = 5; break;
387 - case SFX_SYMBOLS_STYLE_CLASSIC: nStyleLB_InitialSelection = 6; break;
388 - case SFX_SYMBOLS_STYLE_OXYGEN: nStyleLB_InitialSelection = 7; break;
389 - default: nStyleLB_InitialSelection = 0; break;
393 + nStyleLB_InitialSelection = aIconStyleItemId[aMiscOptions.GetCurrentSymbolsStyle()];
394 aIconStyleLB.SelectEntryPos( nStyleLB_InitialSelection );
395 aIconStyleLB.SaveValue();
397 --- svx/source/cui/optgdlg.hxx.old 2009-08-26 10:25:14.000000000 +0000
398 +++ svx/source/cui/optgdlg.hxx 2009-09-09 15:40:36.000000000 +0000
399 @@ -136,6 +136,9 @@ private:
400 UINT16 nStyleLB_InitialSelection;
401 BOOL bSfxSymbolsAuto;
403 + // item ID for the given icon theme
404 + // might be zero when the theme is not installed and the item is removed
405 + ULONG aIconStyleItemId[STYLE_SYMBOLS_THEMES_MAX];
406 SvtTabAppearanceCfg* pAppearanceCfg;
407 CanvasSettings* pCanvasSettings;
408 SvtOptionsDrawinglayer* mpDrawinglayerOpt;