LCOV - code coverage report
Current view: top level - vcl/inc - outdev.h (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 14 19 73.7 %
Date: 2015-06-13 12:38:46 Functions: 15 26 57.7 %
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 INCLUDED_VCL_INC_OUTDEV_H
      21             : #define INCLUDED_VCL_INC_OUTDEV_H
      22             : 
      23             : #include <list>
      24             : #include <set>
      25             : #include <vector>
      26             : 
      27             : #include <tools/gen.hxx>
      28             : #include <vcl/vclptr.hxx>
      29             : 
      30             : #include "outfont.hxx"
      31             : #include "PhysicalFontFace.hxx"
      32             : 
      33             : class Size;
      34             : namespace vcl { class Font; }
      35             : class VirtualDevice;
      36             : class ImplGetDevFontList;
      37             : class GetDevSizeList;
      38             : class PhysicalFontCollection;
      39             : enum class AddFontSubstituteFlags;
      40             : 
      41             : // an ImplGetDevFontList is created by an PhysicalFontCollection
      42             : // it becomes invalid when original PhysicalFontCollection is modified
      43        4570 : class ImplGetDevFontList
      44             : {
      45             : private:
      46             :     std::vector<PhysicalFontFace*> maDevFontVector;
      47             : 
      48             : public:
      49        4592 :                         ImplGetDevFontList()        { maDevFontVector.reserve(1024); }
      50     1023124 :     void                Add( PhysicalFontFace* pFace )  { maDevFontVector.push_back( pFace ); }
      51     1613405 :     PhysicalFontFace*   Get( int nIndex ) const     { return maDevFontVector[ nIndex ]; }
      52     1620857 :     int                 Count() const               { return maDevFontVector.size(); }
      53             : };
      54             : 
      55        1673 : class ImplGetDevSizeList
      56             : {
      57             : private:
      58             :     OUString            maFontName;
      59             :     std::vector<int>    maSizeList;
      60             : 
      61             : public:
      62        1673 :                         ImplGetDevSizeList( const OUString& rFontName )
      63        1673 :                         : maFontName( rFontName ) { maSizeList.reserve( 32 ); }
      64           0 :     void                Add( int nHeight )      { maSizeList.push_back( nHeight ); }
      65        1673 :     int                 Count() const           { return maSizeList.size(); }
      66           0 :     int                 Get( int nIndex ) const { return maSizeList[ nIndex ]; }
      67             :     const OUString&     GetFontName() const     { return maFontName; }
      68             : };
      69             : 
      70             : // nowadays these substitutions are needed for backward compatibility and tight platform integration:
      71             : // - substitutions from configuration entries (Tools->Options->FontReplacement and/or fontconfig)
      72             : // - device specific substitutions (e.g. for PS printer builtin fonts)
      73             : // - substitutions for missing fonts defined by configuration entries (generic and/or platform dependent fallbacks)
      74             : // - substitutions for missing fonts defined by multi-token fontnames (e.g. fontname="SpecialFont;FallbackA;FallbackB")
      75             : // - substitutions for incomplete fonts (implicit, generic, EUDC and/or platform dependent fallbacks)
      76             : // - substitutions for missing symbol fonts by translating code points into other symbol fonts
      77             : 
      78         205 : class ImplFontSubstitution
      79             : {
      80             :     // TODO: there is more commonality between the different substitutions
      81             : protected:
      82         410 :     virtual ~ImplFontSubstitution() {}
      83             : };
      84             : 
      85             : // ImplDirectFontSubstitution is for Tools->Options->FontReplacement and PsPrinter substitutions
      86             : // The clss is just a simple port of the unmaintainable manual-linked-list based mechanism
      87             : // TODO: get rid of this class when the Tools->Options->FontReplacement tabpage is gone for good
      88             : 
      89           0 : struct ImplFontSubstEntry
      90             : {
      91             :     OUString                  maName;
      92             :     OUString                  maReplaceName;
      93             :     OUString                  maSearchName;
      94             :     OUString                  maSearchReplaceName;
      95             :     AddFontSubstituteFlags    mnFlags;
      96             : 
      97             :     ImplFontSubstEntry(  const OUString& rFontName, const OUString& rSubstFontName, AddFontSubstituteFlags nSubstFlags );
      98             : };
      99             : 
     100           0 : class ImplDirectFontSubstitution
     101             : :   public ImplFontSubstitution
     102             : {
     103             : private:
     104             :     typedef std::list<ImplFontSubstEntry> FontSubstList;
     105             :     FontSubstList maFontSubstList;
     106             : public:
     107             :     void    AddFontSubstitute( const OUString& rFontName, const OUString& rSubstName, AddFontSubstituteFlags nFlags );
     108             :     void    RemoveFontSubstitute( int nIndex );
     109           0 :     int     GetFontSubstituteCount() const { return maFontSubstList.size(); };
     110             :     bool    Empty() const { return maFontSubstList.empty(); }
     111             :     void    Clear() { maFontSubstList.clear(); }
     112             : 
     113             :     bool    FindFontSubstitute( OUString& rSubstName, const OUString& rFontName, AddFontSubstituteFlags nFlags ) const;
     114             : };
     115             : 
     116             : // PreMatchFontSubstitution
     117             : // abstracts the concept of a configured font substitution
     118             : // before the availability of the originally selected font has been checked
     119         410 : class ImplPreMatchFontSubstitution
     120             : :   public ImplFontSubstitution
     121             : {
     122             : public:
     123             :     virtual bool FindFontSubstitute( FontSelectPattern& ) const = 0;
     124             : };
     125             : 
     126             : // ImplGlyphFallbackFontSubstitution
     127             : // abstracts the concept of finding the best font to support an incomplete font
     128         205 : class ImplGlyphFallbackFontSubstitution
     129             : :   public ImplFontSubstitution
     130             : {
     131             : public:
     132             :     virtual bool FindFontSubstitute( FontSelectPattern&, OUString& rMissingCodes ) const = 0;
     133             : };
     134             : 
     135             : // TODO: closely couple with PhysicalFontCollection
     136             : 
     137             : class ImplFontCache
     138             : {
     139             : private:
     140             :     ImplFontEntry*      mpFirstEntry;
     141             :     int                 mnRef0Count;    // number of unreferenced ImplFontEntries
     142             : 
     143             :     // cache of recently used font instances
     144             :     struct IFSD_Equal { bool operator()( const FontSelectPattern&, const FontSelectPattern& ) const; };
     145             :     struct IFSD_Hash { size_t operator()( const FontSelectPattern& ) const; };
     146             :     typedef std::unordered_map<FontSelectPattern,ImplFontEntry*,IFSD_Hash,IFSD_Equal > FontInstanceList;
     147             :     FontInstanceList    maFontInstanceList;
     148             : 
     149             :     int                 CountUnreferencedEntries() const;
     150             : 
     151             : public:
     152             :                         ImplFontCache();
     153             :                         ~ImplFontCache();
     154             : 
     155             :     ImplFontEntry*      GetFontEntry( PhysicalFontCollection*,
     156             :                              const vcl::Font&, const Size& rPixelSize, float fExactHeight);
     157             :     ImplFontEntry*      GetFontEntry( PhysicalFontCollection*, FontSelectPattern& );
     158             :     ImplFontEntry*      GetGlyphFallbackFont( PhysicalFontCollection*, FontSelectPattern&,
     159             :                             int nFallbackLevel, OUString& rMissingCodes );
     160             :     void                Release( ImplFontEntry* );
     161             :     void                Invalidate();
     162             : };
     163             : 
     164             : namespace vcl { struct ControlLayoutData; }
     165             : // #i75163#
     166             : namespace basegfx { class B2DHomMatrix; }
     167             : 
     168      841703 : struct ImplOutDevData
     169             : {
     170             :     VclPtr<VirtualDevice>       mpRotateDev;
     171             :     vcl::ControlLayoutData*     mpRecordLayout;
     172             :     Rectangle                   maRecordRect;
     173             : 
     174             :     // #i75163#
     175             :     basegfx::B2DHomMatrix*      mpViewTransform;
     176             :     basegfx::B2DHomMatrix*      mpInverseViewTransform;
     177             : };
     178             : 
     179             : void ImplFontSubstitute( OUString& rFontName );
     180             : 
     181             : #endif // INCLUDED_VCL_INC_OUTDEV_H
     182             : 
     183             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11