LCOV - code coverage report
Current view: top level - libreoffice/vcl/inc - fontcache.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 3 100.0 %
Date: 2012-12-27 Functions: 4 4 100.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             : #ifndef _PSPRINT_FONTCACHE_HXX
      21             : #define _PSPRINT_FONTCACHE_HXX
      22             : 
      23             : #include "vcl/dllapi.h"
      24             : #include "vcl/fontmanager.hxx"
      25             : 
      26             : #include "tools/string.hxx"
      27             : 
      28             : #include <boost/unordered_map.hpp>
      29             : 
      30             : namespace psp
      31             : {
      32             : 
      33             : class VCL_PLUGIN_PUBLIC FontCache
      34             : {
      35             :     struct FontDir;
      36             :     friend struct FontDir;
      37             :     struct FontFile;
      38             :     friend struct FontFile;
      39             : 
      40             :     typedef std::list< PrintFontManager::PrintFont* > FontCacheEntry;
      41        4360 :     struct FontFile
      42             :     {
      43             :         FontCacheEntry      m_aEntry;
      44             :     };
      45             : 
      46             :     typedef boost::unordered_map< ::rtl::OString, FontFile, ::rtl::OStringHash > FontDirMap;
      47         559 :     struct FontDir
      48             :     {
      49             :         sal_Int64   m_nTimestamp;
      50             :         bool        m_bNoFiles;
      51             :         bool        m_bUserOverrideOnly;
      52             :         FontDirMap  m_aEntries;
      53             : 
      54         559 :         FontDir() : m_nTimestamp(0), m_bNoFiles(false), m_bUserOverrideOnly( false ) {}
      55             :     };
      56             : 
      57             :     typedef boost::unordered_map< int, FontDir > FontCacheData;
      58             :     FontCacheData   m_aCache;
      59             :     String          m_aCacheFile;
      60             :     bool            m_bDoFlush;
      61             : 
      62             :     void read();
      63             :     void clearCache();
      64             : 
      65             :     void copyPrintFont( const PrintFontManager::PrintFont* pFrom, PrintFontManager::PrintFont* pTo ) const;
      66             :     bool equalsPrintFont( const PrintFontManager::PrintFont* pLeft, PrintFontManager::PrintFont* pRight ) const;
      67             :     PrintFontManager::PrintFont* clonePrintFont( const PrintFontManager::PrintFont* pFont ) const;
      68             : 
      69             :     void createCacheDir( int nDirID );
      70             : public:
      71             :     FontCache();
      72             :     ~FontCache();
      73             : 
      74             :     bool getFontCacheFile( int nDirID, const rtl::OString& rFile, std::list< PrintFontManager::PrintFont* >& rNewFonts ) const;
      75             :     void updateFontCacheEntry( const PrintFontManager::PrintFont*, bool bFlush );
      76             :     void markEmptyDir( int nDirID, bool bNoFiles = true );
      77             : 
      78             :     // returns false for non cached directory
      79             :     // a cached but empty directory will return true but not append anything
      80             :     bool listDirectory( const rtl::OString& rDir, std::list< PrintFontManager::PrintFont* >& rNewFonts ) const;
      81             :     // returns true for directoris that contain only user overridden fonts
      82             :     bool scanAdditionalFiles( const rtl::OString& rDir );
      83             : 
      84             :     void flush();
      85             : };
      86             : 
      87             : } // namespace psp
      88             : 
      89             : #endif // _PSPRINT_FONTCACHE_HXX
      90             : 
      91             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10