19f62ea84SAndrew Rist /************************************************************** 27168672cSAriel Constenla-Haile * 39f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 49f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 59f62ea84SAndrew Rist * distributed with this work for additional information 69f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 79f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 89f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 99f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 107168672cSAriel Constenla-Haile * 119f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 127168672cSAriel Constenla-Haile * 139f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 149f62ea84SAndrew Rist * software distributed under the License is distributed on an 159f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 179f62ea84SAndrew Rist * specific language governing permissions and limitations 189f62ea84SAndrew Rist * under the License. 197168672cSAriel Constenla-Haile * 209f62ea84SAndrew Rist *************************************************************/ 219f62ea84SAndrew Rist 229f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <vcl/bitmapex.hxx> 28cdf0e10cSrcweir #include <vcl/imagerepository.hxx> 29cdf0e10cSrcweir #include <vcl/svapp.hxx> 307168672cSAriel Constenla-Haile #include <vcl/image.hxx> 317168672cSAriel Constenla-Haile #include <vcl/pngread.hxx> 327168672cSAriel Constenla-Haile #include <rtl/bootstrap.hxx> 337168672cSAriel Constenla-Haile #include <tools/stream.hxx> 347168672cSAriel Constenla-Haile #include <tools/urlobj.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include "impimagetree.hxx" 37cdf0e10cSrcweir 38cdf0e10cSrcweir namespace vcl 39cdf0e10cSrcweir { loadImage(const::rtl::OUString & _rName,BitmapEx & _out_rImage,bool _bSearchLanguageDependent)407168672cSAriel Constenla-Haile bool ImageRepository::loadImage( const ::rtl::OUString& _rName, 417168672cSAriel Constenla-Haile BitmapEx& _out_rImage, 427168672cSAriel Constenla-Haile bool _bSearchLanguageDependent ) 43cdf0e10cSrcweir { 447168672cSAriel Constenla-Haile ::rtl::OUString sCurrentSymbolsStyle = 457168672cSAriel Constenla-Haile Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyleName(); 46cdf0e10cSrcweir 47cdf0e10cSrcweir ImplImageTreeSingletonRef aImplImageTree; 487168672cSAriel Constenla-Haile 497168672cSAriel Constenla-Haile return aImplImageTree->loadImage( _rName, 507168672cSAriel Constenla-Haile sCurrentSymbolsStyle, 517168672cSAriel Constenla-Haile _out_rImage, 527168672cSAriel Constenla-Haile _bSearchLanguageDependent ); 537168672cSAriel Constenla-Haile } 547168672cSAriel Constenla-Haile 557168672cSAriel Constenla-Haile lcl_loadPNG(const rtl::OUString & rPath,const rtl::OUString & rImageFileName,Image & rImage)567168672cSAriel Constenla-Haile static bool lcl_loadPNG( const rtl::OUString &rPath, 577168672cSAriel Constenla-Haile const rtl::OUString &rImageFileName, 587168672cSAriel Constenla-Haile Image &rImage ) 597168672cSAriel Constenla-Haile { 607168672cSAriel Constenla-Haile INetURLObject aObj( rPath ); 617168672cSAriel Constenla-Haile aObj.insertName( rImageFileName ); 627168672cSAriel Constenla-Haile SvFileStream aStrm( aObj.PathToFileName(), STREAM_STD_READ ); 637168672cSAriel Constenla-Haile if ( !aStrm.GetError() ) 647168672cSAriel Constenla-Haile { 657168672cSAriel Constenla-Haile PNGReader aReader( aStrm ); 667168672cSAriel Constenla-Haile BitmapEx aBmp = aReader.Read(); 6793917342SAriel Constenla-Haile if (!aBmp.IsEmpty()) 68e8b66d38SAriel Constenla-Haile { 69e8b66d38SAriel Constenla-Haile rImage = Image( aBmp ); 70e8b66d38SAriel Constenla-Haile return true; 71e8b66d38SAriel Constenla-Haile } 727168672cSAriel Constenla-Haile } 737168672cSAriel Constenla-Haile 747168672cSAriel Constenla-Haile return false; 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 777168672cSAriel Constenla-Haile /* TODO support bSearchLanguageDependent */ loadBrandingImage(const rtl::OUString & rName,Image & rImage,bool)787168672cSAriel Constenla-Haile bool ImageRepository::loadBrandingImage( const rtl::OUString &rName, 797168672cSAriel Constenla-Haile Image &rImage, 807168672cSAriel Constenla-Haile bool /* bSearchLanguageDependent */ ) 817168672cSAriel Constenla-Haile { 827168672cSAriel Constenla-Haile rtl::OUString sImages; 837168672cSAriel Constenla-Haile rtl::OUStringBuffer aBuff( rName ); 84*910823aeSJürgen Schmidt rtl::OUString aBasePath( RTL_CONSTASCII_USTRINGPARAM( "$OOO_BASE_DIR/program" ) ); 857168672cSAriel Constenla-Haile rtl::Bootstrap::expandMacros( aBasePath ); 867168672cSAriel Constenla-Haile 877168672cSAriel Constenla-Haile bool bLoaded = false; 887168672cSAriel Constenla-Haile sal_Int32 nIndex = 0; 897168672cSAriel Constenla-Haile 907168672cSAriel Constenla-Haile if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) 917168672cSAriel Constenla-Haile { 927168672cSAriel Constenla-Haile aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( "_hc.png," ) ); 937168672cSAriel Constenla-Haile aBuff.append( rName ); 947168672cSAriel Constenla-Haile } 95cdf0e10cSrcweir 967168672cSAriel Constenla-Haile aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( ".png" ) ); 977168672cSAriel Constenla-Haile sImages = aBuff.makeStringAndClear(); 987168672cSAriel Constenla-Haile 997168672cSAriel Constenla-Haile do 1007168672cSAriel Constenla-Haile { 1017168672cSAriel Constenla-Haile bLoaded = lcl_loadPNG( aBasePath, 1027168672cSAriel Constenla-Haile sImages.getToken( 0, ',', nIndex ), 1037168672cSAriel Constenla-Haile rImage ); 1047168672cSAriel Constenla-Haile } 1057168672cSAriel Constenla-Haile while ( !bLoaded && ( nIndex >= 0 ) ); 1067168672cSAriel Constenla-Haile 1077168672cSAriel Constenla-Haile return bLoaded; 1087168672cSAriel Constenla-Haile } 1097168672cSAriel Constenla-Haile } 110