LCOV - code coverage report
Current view: top level - libreoffice/vcl/source/gdi - temporaryfonts.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 8 29 27.6 %
Date: 2012-12-27 Functions: 1 3 33.3 %
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             : 
      10             : #include <vcl/temporaryfonts.hxx>
      11             : 
      12             : #include <osl/file.hxx>
      13             : #include <rtl/bootstrap.hxx>
      14             : #include <vcl/svapp.hxx>
      15             : #include <vcl/outdev.hxx>
      16             : 
      17          32 : void TemporaryFonts::clear()
      18             : {
      19          32 :     OUString path = "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}";
      20          32 :     rtl::Bootstrap::expandMacros( path );
      21          32 :     path += "/user/temp/fonts/";
      22          32 :     osl::Directory dir( path );
      23          32 :     if( dir.reset() == osl::Directory::E_None )
      24             :     {
      25           0 :         for(;;)
      26             :         {
      27           0 :             osl::DirectoryItem item;
      28           0 :             if( dir.getNextItem( item ) != osl::Directory::E_None )
      29             :                 break;
      30           0 :             osl::FileStatus status( osl_FileStatus_Mask_FileURL );
      31           0 :             if( item.getFileStatus( status ) == osl::File::E_None )
      32           0 :                 osl::File::remove( status.getFileURL());
      33           0 :         }
      34          32 :     }
      35          32 : }
      36             : 
      37           0 : OUString TemporaryFonts::fileUrlForFont( const OUString& fontName, const char* fontStyle )
      38             : {
      39           0 :     OUString path = "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}";
      40           0 :     rtl::Bootstrap::expandMacros( path );
      41           0 :     path += "/user/temp/fonts/";
      42           0 :     osl::Directory::createPath( path );
      43           0 :     OUString filename = fontName;
      44           0 :     filename += OStringToOUString( fontStyle, RTL_TEXTENCODING_ASCII_US );
      45           0 :     filename += ".ttf"; // TODO is it always ttf?
      46           0 :     return path + filename;
      47             : }
      48             : 
      49           0 : void TemporaryFonts::activateFont( const OUString& fontName, const OUString& fileUrl )
      50             : {
      51           0 :     OutputDevice *pDevice = Application::GetDefaultDevice();
      52           0 :     pDevice->AddTempDevFont( fileUrl, fontName );
      53           0 :     pDevice->ImplUpdateAllFontData( true );
      54           0 : }
      55             : 
      56             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10