Kaydet (Commit) 96189af5 authored tarafından Eike Rathke's avatar Eike Rathke

slightly improved parameter passing

Change-Id: I75b6bc42285cb3c671dcd4b437db54d5003a2898
üst ab6ebe24
...@@ -27,11 +27,10 @@ ...@@ -27,11 +27,10 @@
#include <vcl/svgdata.hxx> #include <vcl/svgdata.hxx>
namespace { namespace {
static bool loadPng(const char *pPath, const rtl::OUString &rName, BitmapEx &rBitmap) static bool loadPng( rtl::OUString aUri, BitmapEx &rBitmap)
{ {
rtl::OUString uri = rtl::OUString::createFromAscii( pPath ) + rName; rtl::Bootstrap::expandMacros( aUri );
rtl::Bootstrap::expandMacros( uri ); INetURLObject aObj( aUri );
INetURLObject aObj( uri );
SvFileStream aStrm( aObj.PathToFileName(), STREAM_STD_READ ); SvFileStream aStrm( aObj.PathToFileName(), STREAM_STD_READ );
if ( !aStrm.GetError() ) { if ( !aStrm.GetError() ) {
vcl::PNGReader aReader( aStrm ); vcl::PNGReader aReader( aStrm );
...@@ -41,6 +40,12 @@ namespace { ...@@ -41,6 +40,12 @@ namespace {
else else
return false; return false;
} }
static bool tryLoadPng( const OUString& rName, BitmapEx& rBitmap )
{
return
loadPng( "$BRAND_BASE_DIR/program/edition" + rName, rBitmap) ||
loadPng( "$BRAND_BASE_DIR/program" + rName, rBitmap);
}
static bool loadSvg(rtl::OUString aUri, BitmapEx &rBitmap) static bool loadSvg(rtl::OUString aUri, BitmapEx &rBitmap)
{ {
rtl::Bootstrap::expandMacros( aUri ); rtl::Bootstrap::expandMacros( aUri );
...@@ -49,13 +54,12 @@ namespace { ...@@ -49,13 +54,12 @@ namespace {
rBitmap = aSvgData.getReplacement(); rBitmap = aSvgData.getReplacement();
return !rBitmap.IsEmpty(); return !rBitmap.IsEmpty();
} }
} static bool tryLoadSvg( const OUString& rName, BitmapEx& rBitmap )
{
static bool lcl_loadPng( const OUString& rName, BitmapEx& rBitmap ) return
{ loadSvg( "$BRAND_BASE_DIR/program/edition" + rName, rBitmap) ||
return loadSvg( "$BRAND_BASE_DIR/program" + rName, rBitmap);
loadPng( "$BRAND_BASE_DIR/program/edition", rName, rBitmap) || }
loadPng( "$BRAND_BASE_DIR/program", rName, rBitmap);
} }
bool Application::LoadBrandBitmap (const char* pName, BitmapEx &rBitmap) bool Application::LoadBrandBitmap (const char* pName, BitmapEx &rBitmap)
...@@ -72,23 +76,16 @@ bool Application::LoadBrandBitmap (const char* pName, BitmapEx &rBitmap) ...@@ -72,23 +76,16 @@ bool Application::LoadBrandBitmap (const char* pName, BitmapEx &rBitmap)
::std::vector< OUString > aFallbacks( aLanguageTag.getFallbackStrings()); ::std::vector< OUString > aFallbacks( aLanguageTag.getFallbackStrings());
for (size_t i=0; i < aFallbacks.size(); ++i) for (size_t i=0; i < aFallbacks.size(); ++i)
{ {
if (lcl_loadPng( aBaseName + "-" + aFallbacks[i] + aPng, rBitmap)) if (tryLoadPng( aBaseName + "-" + aFallbacks[i] + aPng, rBitmap))
return true; return true;
} }
if (lcl_loadPng( aBaseName + aPng, rBitmap)) if (tryLoadPng( aBaseName + aPng, rBitmap))
return true; return true;
return false; return false;
} }
static bool lcl_loadSvg( const OUString& rName, BitmapEx& rBitmap )
{
return
loadSvg( "$BRAND_BASE_DIR/program/edition" + rName, rBitmap) ||
loadSvg( "$BRAND_BASE_DIR/program" + rName, rBitmap);
}
bool Application::LoadBrandSVG (const char *pName, BitmapEx &rBitmap) bool Application::LoadBrandSVG (const char *pName, BitmapEx &rBitmap)
{ {
rtl::OUString aBaseName( "/" + rtl::OUString::createFromAscii( pName ) ); rtl::OUString aBaseName( "/" + rtl::OUString::createFromAscii( pName ) );
...@@ -101,11 +98,11 @@ bool Application::LoadBrandSVG (const char *pName, BitmapEx &rBitmap) ...@@ -101,11 +98,11 @@ bool Application::LoadBrandSVG (const char *pName, BitmapEx &rBitmap)
::std::vector< OUString > aFallbacks( aLanguageTag.getFallbackStrings()); ::std::vector< OUString > aFallbacks( aLanguageTag.getFallbackStrings());
for (size_t i=0; i < aFallbacks.size(); ++i) for (size_t i=0; i < aFallbacks.size(); ++i)
{ {
if (lcl_loadSvg( aBaseName + "-" + aFallbacks[i] + aSvg, rBitmap)) if (tryLoadSvg( aBaseName + "-" + aFallbacks[i] + aSvg, rBitmap))
return true; return true;
} }
if (lcl_loadSvg( aBaseName + aSvg, rBitmap)) if (tryLoadSvg( aBaseName + aSvg, rBitmap))
return true; return true;
return false; return false;
......
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