Impress Remote 1.0.5, tag sdremote-1.0.5
[LibreOffice.git] / vcl / inc / fontcache.hxx
blob8a9e736605d66486ba9396f39c9fabe0b3221890
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
30 namespace psp
33 class VCL_PLUGIN_PUBLIC FontCache
35 struct FontDir;
36 friend struct FontDir;
37 struct FontFile;
38 friend struct FontFile;
40 typedef std::list< PrintFontManager::PrintFont* > FontCacheEntry;
41 struct FontFile
43 FontCacheEntry m_aEntry;
46 typedef boost::unordered_map< ::rtl::OString, FontFile, ::rtl::OStringHash > FontDirMap;
47 struct FontDir
49 sal_Int64 m_nTimestamp;
50 bool m_bNoFiles;
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;
59 String m_aCacheFile;
60 bool m_bDoFlush;
62 void read();
63 void clearCache();
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 );
70 public:
71 FontCache();
72 ~FontCache();
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 );
84 void flush();
87 } // namespace psp
89 #endif // _PSPRINT_FONTCACHE_HXX
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */