LCOV - code coverage report
Current view: top level - vcl/source/app - brand.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 26 3.8 %
Date: 2014-11-03 Functions: 2 5 40.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <config_folders.h>
      21             : 
      22             : #include <rtl/ustring.hxx>
      23             : #include <rtl/bootstrap.hxx>
      24             : #include <osl/process.h>
      25             : #include <tools/urlobj.hxx>
      26             : #include <tools/stream.hxx>
      27             : #include <vcl/pngread.hxx>
      28             : #include <vcl/svapp.hxx>
      29             : #include <vcl/svgdata.hxx>
      30             : 
      31             : namespace {
      32           0 :     static bool loadPng( const OUString & rPath, BitmapEx &rBitmap)
      33             :     {
      34           0 :         INetURLObject aObj( rPath );
      35           0 :         SvFileStream aStrm( aObj.PathToFileName(), STREAM_STD_READ );
      36           0 :         if ( !aStrm.GetError() ) {
      37           0 :             vcl::PNGReader aReader( aStrm );
      38           0 :             rBitmap = aReader.Read();
      39           0 :             return !rBitmap.IsEmpty();
      40             :         }
      41             :         else
      42           0 :             return false;
      43             :     }
      44           0 :     static bool tryLoadPng( const OUString& rBaseDir, const OUString& rName, BitmapEx& rBitmap )
      45             :     {
      46           0 :         return loadPng( rBaseDir + "/" LIBO_ETC_FOLDER + rName, rBitmap);
      47             :     }
      48             : }
      49             : 
      50           0 : bool Application::LoadBrandBitmap (const char* pName, BitmapEx &rBitmap)
      51             : {
      52             :     // TODO - if we want more flexibility we could add a branding path
      53             :     // in an rc file perhaps fallback to "about.bmp"
      54           0 :     OUString aBaseDir( "$BRAND_BASE_DIR");
      55           0 :     rtl::Bootstrap::expandMacros( aBaseDir );
      56           0 :     OUString aBaseName( "/" + OUString::createFromAscii( pName ) );
      57           0 :     OUString aPng( ".png" );
      58             : 
      59           0 :     rtl_Locale *pLoc = NULL;
      60           0 :     osl_getProcessLocale (&pLoc);
      61           0 :     LanguageTag aLanguageTag( *pLoc);
      62             : 
      63           0 :     ::std::vector< OUString > aFallbacks( aLanguageTag.getFallbackStrings( true));
      64           0 :     for (size_t i=0; i < aFallbacks.size(); ++i)
      65             :     {
      66           0 :         if (tryLoadPng( aBaseDir, aBaseName + "-" + aFallbacks[i] + aPng, rBitmap))
      67           0 :             return true;
      68             :     }
      69             : 
      70           0 :     if (tryLoadPng( aBaseDir, aBaseName + aPng, rBitmap))
      71           0 :         return true;
      72             : 
      73           0 :     return false;
      74        1233 : }
      75             : 
      76             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10