LCOV - code coverage report
Current view: top level - vcl/inc - outdev.h (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 18 25 72.0 %
Date: 2012-08-25 Functions: 20 32 62.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 31 25.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _SV_OUTDEV_H
      30                 :            : #define _SV_OUTDEV_H
      31                 :            : 
      32                 :            : #include <tools/solar.h>
      33                 :            : #include <outfont.hxx>
      34                 :            : 
      35                 :            : #include <vector>
      36                 :            : #include <list>
      37                 :            : #include <set>
      38                 :            : 
      39                 :            : class Size;
      40                 :            : class Font;
      41                 :            : class VirtualDevice;
      42                 :            : class ImplGetDevFontList;
      43                 :            : class GetDevSizeList;
      44                 :            : 
      45                 :            : // -----------------------
      46                 :            : // - ImplDevFontListData -
      47                 :            : // -----------------------
      48                 :            : 
      49                 :            : // flags for mnMatchType member
      50                 :            : #define IMPL_DEVFONT_SCALABLE       ((sal_uIntPtr)0x00000001)
      51                 :            : #define IMPL_DEVFONT_SYMBOL         ((sal_uIntPtr)0x00000002)
      52                 :            : #define IMPL_DEVFONT_NONESYMBOL     ((sal_uIntPtr)0x00000004)
      53                 :            : #define IMPL_DEVFONT_LIGHT          ((sal_uIntPtr)0x00000010)
      54                 :            : #define IMPL_DEVFONT_BOLD           ((sal_uIntPtr)0x00000020)
      55                 :            : #define IMPL_DEVFONT_NORMAL         ((sal_uIntPtr)0x00000040)
      56                 :            : #define IMPL_DEVFONT_NONEITALIC     ((sal_uIntPtr)0x00000100)
      57                 :            : #define IMPL_DEVFONT_ITALIC         ((sal_uIntPtr)0x00000200)
      58                 :            : 
      59                 :            : // TODO: rename ImplDevFontListData to PhysicalFontFamily
      60                 :            : class ImplDevFontListData
      61                 :            : {
      62                 :            : public:
      63                 :            :                         ImplDevFontListData( const String& rSearchName );
      64                 :            :                         ~ImplDevFontListData();
      65                 :            : 
      66                 :       9357 :     const String&       GetFamilyName() const    { return maName; }
      67                 :     166011 :     const String&       GetSearchName() const    { return maSearchName; }
      68                 :            :     const String&       GetAliasNames() const    { return maMapNames; }
      69                 :          0 :     bool                IsScalable() const       { return mpFirst->IsScalable(); }
      70                 :          0 :     int                 GetMinQuality() const    { return mnMinQuality; }
      71                 :            : 
      72                 :            :     bool                AddFontFace( PhysicalFontFace* );
      73                 :            :     void                InitMatchData( const utl::FontSubstConfiguration&,
      74                 :            :                             const String& rSearchName );
      75                 :            :     PhysicalFontFace*   FindBestFontFace( const FontSelectPattern& rFSD ) const;
      76                 :            : 
      77                 :            :     void                GetFontHeights( std::set<int>& rHeights ) const;
      78                 :            :     void                UpdateDevFontList( ImplGetDevFontList& ) const;
      79                 :            :     void                UpdateCloneFontList( ImplDevFontList&,
      80                 :            :                                              bool bScalable, bool bEmbeddable ) const;
      81                 :            : 
      82                 :            : private:
      83                 :            : friend class ImplDevFontList; // TODO: remove soon
      84                 :            :     PhysicalFontFace*   mpFirst;            // linked list of physical font faces
      85                 :            :     String              maName;             // Fontname (original font family name)
      86                 :            :     String              maSearchName;       // normalized font family name
      87                 :            :     String              maMapNames;         // fontname aliases
      88                 :            :     sal_uIntPtr         mnTypeFaces;        // Typeface Flags
      89                 :            :     sal_uIntPtr         mnMatchType;        // MATCH - Type
      90                 :            :     String              maMatchFamilyName;  // MATCH - FamilyName
      91                 :            :     FontWeight          meMatchWeight;      // MATCH - Weight
      92                 :            :     FontWidth           meMatchWidth;       // MATCH - Width
      93                 :            :     FontFamily          meFamily;
      94                 :            :     FontPitch           mePitch;
      95                 :            :     int                 mnMinQuality;       // quality of the worst font face
      96                 :            : };
      97                 :            : 
      98                 :            : 
      99                 :            : // ----------------------
     100                 :            : // - ImplGetDevFontList -
     101                 :            : // ----------------------
     102                 :            : 
     103                 :            : // an ImplGetDevFontList is created by an ImplDevFontList
     104                 :            : // it becomes invalid when original ImplDevFontList is modified
     105                 :       2809 : class ImplGetDevFontList
     106                 :            : {
     107                 :            : private:
     108                 :            :     std::vector<PhysicalFontFace*> maDevFontVector;
     109                 :            : 
     110                 :            : public:
     111         [ +  - ]:       2925 :                         ImplGetDevFontList()        { maDevFontVector.reserve(1024); }
     112                 :     366768 :     void                Add( PhysicalFontFace* pFace )  { maDevFontVector.push_back( pFace ); }
     113                 :     526410 :     PhysicalFontFace*   Get( int nIndex ) const     { return maDevFontVector[ nIndex ]; }
     114                 :     530635 :     int                 Count() const               { return maDevFontVector.size(); }
     115                 :            : };
     116                 :            : 
     117                 :            : // ----------------------
     118                 :            : // - ImplGetDevSizeList -
     119                 :            : // ----------------------
     120                 :            : 
     121                 :       1481 : class ImplGetDevSizeList
     122                 :            : {
     123                 :            : private:
     124                 :            :     String              maFontName;
     125                 :            :     std::vector<int>    maSizeList;
     126                 :            : 
     127                 :            : public:
     128                 :       1481 :                         ImplGetDevSizeList( const String& rFontName )
     129 [ +  - ][ +  - ]:       1481 :                         : maFontName( rFontName ) { maSizeList.reserve( 32 ); }
     130                 :          0 :     void                Add( int nHeight )      { maSizeList.push_back( nHeight ); }
     131                 :       1481 :     int                 Count() const           { return maSizeList.size(); }
     132                 :          0 :     int                 Get( int nIndex ) const { return maSizeList[ nIndex ]; }
     133                 :            :     const String&       GetFontName() const     { return maFontName; }
     134                 :            : };
     135                 :            : 
     136                 :            : // ------------------------
     137                 :            : // - ImplFontSubstitution -
     138                 :            : // ------------------------
     139                 :            : // nowadays these substitutions are needed for backward compatibility and tight platform integration:
     140                 :            : // - substitutions from configuration entries (Tools->Options->FontReplacement and/or fontconfig)
     141                 :            : // - device specific substitutions (e.g. for PS printer builtin fonts)
     142                 :            : // - substitutions for missing fonts defined by configuration entries (generic and/or platform dependent fallbacks)
     143                 :            : // - substitutions for missing fonts defined by multi-token fontnames (e.g. fontname="SpecialFont;FallbackA;FallbackB")
     144                 :            : // - substitutions for incomplete fonts (implicit, generic, EUDC and/or platform dependent fallbacks)
     145                 :            : // - substitutions for missing symbol fonts by translating code points into other symbol fonts
     146                 :            : 
     147                 :       3881 : class ImplFontSubstitution
     148                 :            : {
     149                 :            :     // TODO: there is more commonality between the different substitutions
     150                 :            : protected:
     151         [ -  + ]:       4020 :     virtual ~ImplFontSubstitution() {}
     152                 :            : };
     153                 :            : 
     154                 :            : // ImplDirectFontSubstitution is for Tools->Options->FontReplacement and PsPrinter substitutions
     155                 :            : // The clss is just a simple port of the unmaintainable manual-linked-list based mechanism
     156                 :            : // TODO: get rid of this class when the Tools->Options->FontReplacement tabpage is gone for good
     157                 :            : 
     158      [ #  #  # ]:          0 : struct ImplFontSubstEntry
              [ #  #  # ]
              [ #  #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     159                 :            : {
     160                 :            :     String                  maName;
     161                 :            :     String                  maReplaceName;
     162                 :            :     String                  maSearchName;
     163                 :            :     String                  maSearchReplaceName;
     164                 :            :     sal_uInt16                  mnFlags;
     165                 :            : 
     166                 :            :     ImplFontSubstEntry(  const String& rFontName, const String& rSubstFontName, sal_uInt16 nSubstFlags );
     167                 :            : };
     168                 :            : 
     169 [ -  + ][ +  - ]:       7193 : class ImplDirectFontSubstitution
     170                 :            : :   public ImplFontSubstitution
     171                 :            : {
     172                 :            : private:
     173                 :            :     typedef std::list<ImplFontSubstEntry> FontSubstList;
     174                 :            :     FontSubstList maFontSubstList;
     175                 :            : public:
     176                 :            :     void    AddFontSubstitute( const String& rFontName, const String& rSubstName, sal_uInt16 nFlags );
     177                 :            :     void    RemoveFontSubstitute( int nIndex );
     178                 :          0 :     int     GetFontSubstituteCount() const { return maFontSubstList.size(); };
     179                 :        276 :     bool    Empty() const { return maFontSubstList.empty(); }
     180                 :          0 :     void    Clear() { maFontSubstList.clear(); }
     181                 :            : 
     182                 :            :     bool    FindFontSubstitute( String& rSubstName, const String& rFontName, sal_uInt16 nFlags ) const;
     183                 :            : };
     184                 :            : 
     185                 :            : // PreMatchFontSubstitution
     186                 :            : // abstracts the concept of a configured font substitution
     187                 :            : // before the availability of the originally selected font has been checked
     188         [ -  + ]:        472 : class ImplPreMatchFontSubstitution
     189                 :            : :   public ImplFontSubstitution
     190                 :            : {
     191                 :            : public:
     192                 :            :     virtual bool FindFontSubstitute( FontSelectPattern& ) const = 0;
     193                 :            : };
     194                 :            : 
     195                 :            : // ImplGlyphFallbackFontSubstitution
     196                 :            : // abstracts the concept of finding the best font to support an incomplete font
     197         [ -  + ]:        236 : class ImplGlyphFallbackFontSubstitution
     198                 :            : :   public ImplFontSubstitution
     199                 :            : {
     200                 :            : public:
     201                 :            :     virtual bool FindFontSubstitute( FontSelectPattern&, rtl::OUString& rMissingCodes ) const = 0;
     202                 :            : };
     203                 :            : 
     204                 :            : // -----------------
     205                 :            : // - ImplFontCache -
     206                 :            : // -----------------
     207                 :            : // TODO: closely couple with ImplDevFontList
     208                 :            : 
     209                 :            : class ImplFontCache
     210                 :            : {
     211                 :            : private:
     212                 :            :     ImplFontEntry*      mpFirstEntry;
     213                 :            :     int                 mnRef0Count;    // number of unreferenced ImplFontEntries
     214                 :            :     bool                mbPrinter;
     215                 :            : 
     216                 :            :     // cache of recently used font instances
     217                 :            :     struct IFSD_Equal { bool operator()( const FontSelectPattern&, const FontSelectPattern& ) const; };
     218                 :            :     struct IFSD_Hash { size_t operator()( const FontSelectPattern& ) const; };
     219                 :            :     typedef ::boost::unordered_map<FontSelectPattern,ImplFontEntry*,IFSD_Hash,IFSD_Equal > FontInstanceList;
     220                 :            :     FontInstanceList    maFontInstanceList;
     221                 :            : 
     222                 :            :     // cache of recently requested font names vs. selected font names
     223                 :            :     typedef ::boost::unordered_map<String,String,FontNameHash> FontNameList;
     224                 :            :     FontNameList        maFontNameList;
     225                 :            : 
     226                 :            : public:
     227                 :            :                         ImplFontCache( bool bPrinter );
     228                 :            :                         ~ImplFontCache();
     229                 :            : 
     230                 :            :     ImplFontEntry*      GetFontEntry( ImplDevFontList*,
     231                 :            :                              const Font&, const Size& rPixelSize, float fExactHeight,
     232                 :            :                 ImplDirectFontSubstitution* pDevSpecific );
     233                 :            :     ImplFontEntry*      GetFontEntry( ImplDevFontList*,
     234                 :            :                     FontSelectPattern&, ImplDirectFontSubstitution* pDevSpecific );
     235                 :            :     ImplFontEntry*      GetGlyphFallbackFont( ImplDevFontList*, FontSelectPattern&,
     236                 :            :                             int nFallbackLevel, rtl::OUString& rMissingCodes );
     237                 :            :     void                Release( ImplFontEntry* );
     238                 :            :     void                Invalidate();
     239                 :            : };
     240                 :            : 
     241                 :            : // ------------------
     242                 :            : // - ImplOutDevData -
     243                 :            : // ------------------
     244                 :            : 
     245                 :            : namespace vcl { struct ControlLayoutData; }
     246                 :            : // #i75163#
     247                 :            : namespace basegfx { class B2DHomMatrix; }
     248                 :            : 
     249                 :       7193 : struct ImplOutDevData
     250                 :            : {
     251                 :            :     VirtualDevice*              mpRotateDev;
     252                 :            :     vcl::ControlLayoutData*     mpRecordLayout;
     253                 :            :     Rectangle                   maRecordRect;
     254                 :            :     ImplDirectFontSubstitution      maDevFontSubst;
     255                 :            : 
     256                 :            :     // #i75163#
     257                 :            :     basegfx::B2DHomMatrix*      mpViewTransform;
     258                 :            :     basegfx::B2DHomMatrix*      mpInverseViewTransform;
     259                 :            : };
     260                 :            : 
     261                 :            : void ImplFreeOutDevFontData();
     262                 :            : 
     263                 :            : #endif // _SV_OUTDEV_H
     264                 :            : 
     265                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10