LCOV - code coverage report
Current view: top level - libreoffice/vcl/source/app - brand.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 40 0.0 %
Date: 2012-12-17 Functions: 0 3 0.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 <rtl/ustring.hxx>
      21             : #include <rtl/bootstrap.hxx>
      22             : #include <osl/process.h>
      23             : #include <tools/urlobj.hxx>
      24             : #include <tools/stream.hxx>
      25             : #include <vcl/pngread.hxx>
      26             : #include <vcl/svapp.hxx>
      27             : #include <vcl/svgdata.hxx>
      28             : 
      29             : namespace {
      30           0 :     static bool loadPng(const char *pPath, const rtl::OUString &rName, BitmapEx &rBitmap)
      31             :     {
      32           0 :         rtl::OUString uri = rtl::OUString::createFromAscii( pPath ) + rName;
      33           0 :         rtl::Bootstrap::expandMacros( uri );
      34           0 :         INetURLObject aObj( uri );
      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             : }
      45             : 
      46           0 : bool Application::LoadBrandBitmap (const char* pName, BitmapEx &rBitmap)
      47             : {
      48             :     // TODO - if we want more flexibility we could add a branding path
      49             :     // in an rc file perhaps fallback to "about.bmp"
      50             :     rtl::OUString aBaseName = ( rtl::OUString("/") +
      51           0 :                                 rtl::OUString::createFromAscii( pName ) );
      52           0 :     rtl::OUString aPng( ".png" );
      53             : 
      54           0 :     rtl_Locale *pLoc = NULL;
      55           0 :     osl_getProcessLocale (&pLoc);
      56           0 :     LanguageTag aLanguageTag( *pLoc);
      57             : 
      58           0 :     rtl::OUString aName = aBaseName + aPng;
      59           0 :     rtl::OUString aLocaleName = ( aBaseName + rtl::OUString("-") +
      60           0 :                                   aLanguageTag.getBcp47() +
      61           0 :                                   aPng );
      62             : 
      63           0 :     return ( loadPng ("$BRAND_BASE_DIR/program/edition", aLocaleName, rBitmap) ||
      64           0 :              loadPng ("$BRAND_BASE_DIR/program", aLocaleName, rBitmap) ||
      65           0 :              loadPng ("$BRAND_BASE_DIR/program/edition", aName, rBitmap) ||
      66           0 :              loadPng ("$BRAND_BASE_DIR/program", aName, rBitmap) );
      67             : }
      68             : 
      69           0 : bool Application::LoadBrandSVG (const char *pName, BitmapEx &rBitmap)
      70             : {
      71             :     rtl::OUString aBaseName = ( rtl::OUString("/") +
      72           0 :                                 rtl::OUString::createFromAscii( pName ) );
      73           0 :     rtl::OUString aSvg( ".svg" );
      74             : 
      75           0 :     rtl_Locale *pLoc = NULL;
      76           0 :     osl_getProcessLocale (&pLoc);
      77           0 :     LanguageTag aLanguageTag( *pLoc);
      78             : 
      79           0 :     rtl::OUString aName = aBaseName + aSvg;
      80           0 :     rtl::OUString aLocaleName = ( aBaseName + rtl::OUString("-") +
      81           0 :                                   aLanguageTag.getBcp47() +
      82           0 :                                   aSvg );
      83             :     //rtl::OUString uri = rtl::OUString::createFromAscii( "$BRAND_BASE_DIR/program/edition" ) + aLocaleName;
      84           0 :     rtl::OUString uri = rtl::OUString::createFromAscii( "$BRAND_BASE_DIR/program" ) + aBaseName+aSvg;
      85           0 :     rtl::Bootstrap::expandMacros( uri );
      86           0 :     INetURLObject aObj( uri );
      87           0 :     SvgData aSvgData(aObj.PathToFileName());
      88           0 :     rBitmap = aSvgData.getReplacement();
      89           0 :     return true;
      90             : }
      91             : 
      92             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10