diff options
author | Ariel Constenla-Haile <arielch@apache.org> | 2012-09-22 18:38:56 +0000 |
---|---|---|
committer | Ariel Constenla-Haile <arielch@apache.org> | 2012-09-22 18:38:56 +0000 |
commit | cb99ad779d66d35e7f8539d44a7549df599f8efb (patch) | |
tree | f60b97b1e0afd45c0cf019b61f0eb17d47c2593e /vcl | |
parent | fa12d0b3a7e876b543dab24919b07339bc20dff8 (diff) |
#i119418# - About Dialog improvements
Notes
Notes:
ignore: aoo
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/vcl/imagerepository.hxx | 34 | ||||
-rw-r--r-- | vcl/source/gdi/imagerepository.cxx | 80 |
2 files changed, 91 insertions, 23 deletions
diff --git a/vcl/inc/vcl/imagerepository.hxx b/vcl/inc/vcl/imagerepository.hxx index cef9d43a7ed0..82934c794299 100644 --- a/vcl/inc/vcl/imagerepository.hxx +++ b/vcl/inc/vcl/imagerepository.hxx @@ -28,16 +28,15 @@ #include <rtl/ustring.hxx> class BitmapEx; +class Image; -//........................................................................ namespace vcl { -//........................................................................ - //==================================================================== - //= ImageRepository - //==================================================================== - // provides access to the application's image repository (image.zip) + /** + provides access to the application's image repository + (packed images and brand images) + */ class VCL_DLLPUBLIC ImageRepository { public: @@ -56,11 +55,26 @@ namespace vcl BitmapEx& _out_rImage, bool bSearchLanguageDependent ); - }; -//........................................................................ -} // namespace vcl -//........................................................................ + /** load an image from the application's branding directory + + @param rName + the name of the image to load, without extension + @param rImage + will take the image upon successful return. + @param bIgnoreHighContrast + if true, high contrast mode is not taken into account when + searching for the image + @param bSearchLanguageDependent + determines whether a language-dependent image is to be searched. + */ + static bool loadBrandingImage( + const rtl::OUString &rName, + Image &rImage, + bool bSearchLanguageDependent = false + ); + }; +} #endif // VCL_IMAGEREPOSITORY_HXX diff --git a/vcl/source/gdi/imagerepository.cxx b/vcl/source/gdi/imagerepository.cxx index b21a7ea02b37..56ebfbbfaaa7 100644 --- a/vcl/source/gdi/imagerepository.cxx +++ b/vcl/source/gdi/imagerepository.cxx @@ -27,27 +27,81 @@ #include <vcl/bitmapex.hxx> #include <vcl/imagerepository.hxx> #include <vcl/svapp.hxx> +#include <vcl/image.hxx> +#include <vcl/pngread.hxx> +#include <rtl/bootstrap.hxx> +#include <tools/stream.hxx> +#include <tools/urlobj.hxx> #include "impimagetree.hxx" -//........................................................................ namespace vcl { -//........................................................................ - - //==================================================================== - //= ImageRepository - //==================================================================== - //-------------------------------------------------------------------- - bool ImageRepository::loadImage( const ::rtl::OUString& _rName, BitmapEx& _out_rImage, bool _bSearchLanguageDependent ) + bool ImageRepository::loadImage( const ::rtl::OUString& _rName, + BitmapEx& _out_rImage, + bool _bSearchLanguageDependent ) { - ::rtl::OUString sCurrentSymbolsStyle = Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyleName(); + ::rtl::OUString sCurrentSymbolsStyle = + Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyleName(); ImplImageTreeSingletonRef aImplImageTree; - return aImplImageTree->loadImage( _rName, sCurrentSymbolsStyle, _out_rImage, _bSearchLanguageDependent ); + + return aImplImageTree->loadImage( _rName, + sCurrentSymbolsStyle, + _out_rImage, + _bSearchLanguageDependent ); + } + + + static bool lcl_loadPNG( const rtl::OUString &rPath, + const rtl::OUString &rImageFileName, + Image &rImage ) + { + INetURLObject aObj( rPath ); + aObj.insertName( rImageFileName ); + SvFileStream aStrm( aObj.PathToFileName(), STREAM_STD_READ ); + if ( !aStrm.GetError() ) + { + PNGReader aReader( aStrm ); + BitmapEx aBmp = aReader.Read(); + rImage = Image( aBmp ); + + return true; + } + + return false; } -//........................................................................ -} // namespace vcl -//........................................................................ + /* TODO support bSearchLanguageDependent */ + bool ImageRepository::loadBrandingImage( const rtl::OUString &rName, + Image &rImage, + bool /* bSearchLanguageDependent */ ) + { + rtl::OUString sImages; + rtl::OUStringBuffer aBuff( rName ); + rtl::OUString aBasePath( RTL_CONSTASCII_USTRINGPARAM( "$BRAND_BASE_DIR/program" ) ); + rtl::Bootstrap::expandMacros( aBasePath ); + + bool bLoaded = false; + sal_Int32 nIndex = 0; + + if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) + { + aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( "_hc.png," ) ); + aBuff.append( rName ); + } + aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( ".png" ) ); + sImages = aBuff.makeStringAndClear(); + + do + { + bLoaded = lcl_loadPNG( aBasePath, + sImages.getToken( 0, ',', nIndex ), + rImage ); + } + while ( !bLoaded && ( nIndex >= 0 ) ); + + return bLoaded; + } +} |