1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _PSPRINT_FONTCACHE_HXX
21 #define _PSPRINT_FONTCACHE_HXX
23 #include "vcl/dllapi.h"
24 #include "vcl/fontmanager.hxx"
26 #include "tools/string.hxx"
28 #include <boost/unordered_map.hpp>
33 class VCL_PLUGIN_PUBLIC FontCache
36 friend struct FontDir
;
38 friend struct FontFile
;
40 typedef std::list
< PrintFontManager::PrintFont
* > FontCacheEntry
;
43 FontCacheEntry m_aEntry
;
46 typedef boost::unordered_map
< ::rtl::OString
, FontFile
, ::rtl::OStringHash
> FontDirMap
;
49 sal_Int64 m_nTimestamp
;
51 bool m_bUserOverrideOnly
;
52 FontDirMap m_aEntries
;
54 FontDir() : m_nTimestamp(0), m_bNoFiles(false), m_bUserOverrideOnly( false ) {}
57 typedef boost::unordered_map
< int, FontDir
> FontCacheData
;
58 FontCacheData m_aCache
;
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;
69 void createCacheDir( int nDirID
);
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 );
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
);
89 #endif // _PSPRINT_FONTCACHE_HXX
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */