LCOV - code coverage report
Current view: top level - include/unotools - fontcfg.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 4 0.0 %
Date: 2014-04-14 Functions: 0 11 0.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             : #ifndef INCLUDED_UNOTOOLS_FONTCFG_HXX
      20             : #define INCLUDED_UNOTOOLS_FONTCFG_HXX
      21             : 
      22             : #include <i18nlangtag/languagetag.hxx>
      23             : #include <unotools/unotoolsdllapi.h>
      24             : #include <tools/solar.h>
      25             : #include <tools/fontenum.hxx>
      26             : #include <com/sun/star/lang/Locale.hpp>
      27             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      28             : #include <com/sun/star/container/XNameAccess.hpp>
      29             : 
      30             : #include <boost/unordered_map.hpp>
      31             : #include <boost/unordered_set.hpp>
      32             : #include <vector>
      33             : 
      34             : namespace utl
      35             : {
      36             : 
      37             : class UNOTOOLS_DLLPUBLIC DefaultFontConfiguration
      38             : {
      39             :     com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
      40             :             m_xConfigProvider;
      41             :     com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >
      42             :             m_xConfigAccess;
      43             : 
      44           0 :     struct LocaleAccess
      45             :     {
      46             :         // the real string used in the configuration
      47             :         // used to get rid of upper/lower case problems
      48             :         OUString aConfigLocaleString;
      49             :         // xAccess is mutable to be able to be filled on demand
      50             :         mutable com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xAccess;
      51             :     };
      52             : 
      53             :     boost::unordered_map< OUString, LocaleAccess, OUStringHash > m_aConfig;
      54             : 
      55             :     OUString tryLocale( const OUString& rBcp47, const OUString& rType ) const;
      56             : 
      57             :     public:
      58             :     DefaultFontConfiguration();
      59             :     ~DefaultFontConfiguration();
      60             : 
      61             :     static DefaultFontConfiguration& get();
      62             : 
      63             :     OUString getDefaultFont( const LanguageTag& rLanguageTag, int nType ) const;
      64             :     OUString getUserInterfaceFont( const LanguageTag& rLanguageTag ) const;
      65             : };
      66             : 
      67             : // IMPL_FONT_ATTR_DEFAULT       - Default-Font like Andale Sans UI, Palace Script, Albany, Thorndale, Cumberland, ...
      68             : // IMPL_FONT_ATTR_STANDARD      - Standard-Font like Arial, Times, Courier, ...
      69             : // IMPL_FONT_ATTR_NORMAL        - normal Font for writing text like Arial, Verdana, Arial Narrow, Trebuchet, Times, Courier, ...
      70             : // IMPL_FONT_ATTR_SYMBOL        - Font with symbols
      71             : // IMPL_FONT_ATTR_DECORATIVE    - Readable and normally used for drawings
      72             : // IMPL_FONT_ATTR_SPECIAL       - very special design
      73             : // IMPL_FONT_ATTR_TITLING       - only uppercase characters
      74             : // IMPL_FONT_ATTR_FULL          - Font with normally all characters
      75             : // IMPL_FONT_ATTR_CAPITALS     - only uppercase characters, but lowercase characters smaller as the uppercase characters
      76             : // IMPL_FONT_ATTR_TYPEWRITER    - like a typewriter: Courier, ...
      77             : // IMPL_FONT_ATTR_SCRIPT        - Handwriting or Script
      78             : // IMPL_FONT_ATTR_HANDWRITING   - More Handwriting with normal letters
      79             : // IMPL_FONT_ATTR_CHANCERY      - Like Zapf Chancery
      80             : // IMPL_FONT_ATTR_COMIC         - Like Comic Sans MS
      81             : // IMPL_FONT_ATTR_BRUSHSCRIPT   - More Script
      82             : // IMPL_FONT_ATTR_OTHERSTYLE    - OldStyle, ... so negativ points
      83             : #define IMPL_FONT_ATTR_DEFAULT       ((sal_uLong)0x00000001)
      84             : #define IMPL_FONT_ATTR_STANDARD      ((sal_uLong)0x00000002)
      85             : #define IMPL_FONT_ATTR_NORMAL        ((sal_uLong)0x00000004)
      86             : #define IMPL_FONT_ATTR_SYMBOL        ((sal_uLong)0x00000008)
      87             : #define IMPL_FONT_ATTR_FIXED         ((sal_uLong)0x00000010)
      88             : #define IMPL_FONT_ATTR_SANSSERIF     ((sal_uLong)0x00000020)
      89             : #define IMPL_FONT_ATTR_SERIF         ((sal_uLong)0x00000040)
      90             : #define IMPL_FONT_ATTR_DECORATIVE    ((sal_uLong)0x00000080)
      91             : #define IMPL_FONT_ATTR_SPECIAL       ((sal_uLong)0x00000100)
      92             : #define IMPL_FONT_ATTR_ITALIC        ((sal_uLong)0x00000200)
      93             : #define IMPL_FONT_ATTR_TITLING       ((sal_uLong)0x00000400)
      94             : #define IMPL_FONT_ATTR_CAPITALS      ((sal_uLong)0x00000800)
      95             : #define IMPL_FONT_ATTR_CJK           ((sal_uLong)0x00001000)
      96             : #define IMPL_FONT_ATTR_CJK_JP        ((sal_uLong)0x00002000)
      97             : #define IMPL_FONT_ATTR_CJK_SC        ((sal_uLong)0x00004000)
      98             : #define IMPL_FONT_ATTR_CJK_TC        ((sal_uLong)0x00008000)
      99             : #define IMPL_FONT_ATTR_CJK_KR        ((sal_uLong)0x00010000)
     100             : #define IMPL_FONT_ATTR_CTL           ((sal_uLong)0x00020000)
     101             : #define IMPL_FONT_ATTR_NONELATIN     ((sal_uLong)0x00040000)
     102             : #define IMPL_FONT_ATTR_FULL          ((sal_uLong)0x00080000)
     103             : #define IMPL_FONT_ATTR_OUTLINE       ((sal_uLong)0x00100000)
     104             : #define IMPL_FONT_ATTR_SHADOW        ((sal_uLong)0x00200000)
     105             : #define IMPL_FONT_ATTR_ROUNDED       ((sal_uLong)0x00400000)
     106             : #define IMPL_FONT_ATTR_TYPEWRITER    ((sal_uLong)0x00800000)
     107             : #define IMPL_FONT_ATTR_SCRIPT        ((sal_uLong)0x01000000)
     108             : #define IMPL_FONT_ATTR_HANDWRITING   ((sal_uLong)0x02000000)
     109             : #define IMPL_FONT_ATTR_CHANCERY      ((sal_uLong)0x04000000)
     110             : #define IMPL_FONT_ATTR_COMIC         ((sal_uLong)0x08000000)
     111             : #define IMPL_FONT_ATTR_BRUSHSCRIPT   ((sal_uLong)0x10000000)
     112             : #define IMPL_FONT_ATTR_GOTHIC        ((sal_uLong)0x20000000)
     113             : #define IMPL_FONT_ATTR_SCHOOLBOOK    ((sal_uLong)0x40000000)
     114             : #define IMPL_FONT_ATTR_OTHERSTYLE    ((sal_uLong)0x80000000)
     115             : 
     116             : #define IMPL_FONT_ATTR_CJK_ALLLANG   (IMPL_FONT_ATTR_CJK_JP | IMPL_FONT_ATTR_CJK_SC | IMPL_FONT_ATTR_CJK_TC | IMPL_FONT_ATTR_CJK_KR)
     117             : #define IMPL_FONT_ATTR_ALLSCRIPT     (IMPL_FONT_ATTR_SCRIPT | IMPL_FONT_ATTR_HANDWRITING | IMPL_FONT_ATTR_CHANCERY | IMPL_FONT_ATTR_COMIC | IMPL_FONT_ATTR_BRUSHSCRIPT)
     118             : #define IMPL_FONT_ATTR_ALLSUBSCRIPT  (IMPL_FONT_ATTR_HANDWRITING | IMPL_FONT_ATTR_CHANCERY | IMPL_FONT_ATTR_COMIC | IMPL_FONT_ATTR_BRUSHSCRIPT)
     119             : #define IMPL_FONT_ATTR_ALLSERIFSTYLE (IMPL_FONT_ATTR_ALLSCRIPT |\
     120             :                                       IMPL_FONT_ATTR_SANSSERIF | IMPL_FONT_ATTR_SERIF |\
     121             :                                       IMPL_FONT_ATTR_FIXED | IMPL_FONT_ATTR_ITALIC |\
     122             :                                       IMPL_FONT_ATTR_GOTHIC | IMPL_FONT_ATTR_SCHOOLBOOK |\
     123             :                                       IMPL_FONT_ATTR_SHADOW | IMPL_FONT_ATTR_OUTLINE)
     124             : 
     125           0 : struct UNOTOOLS_DLLPUBLIC FontNameAttr
     126             : {
     127             :     OUString                            Name;
     128             :     ::std::vector< OUString >             Substitutions;
     129             :     ::std::vector< OUString >             MSSubstitutions;
     130             :     ::std::vector< OUString >             PSSubstitutions;
     131             :     ::std::vector< OUString >             HTMLSubstitutions;
     132             :     FontWeight                          Weight;
     133             :     FontWidth                           Width;
     134             :     unsigned long                       Type; // bitfield of IMPL_FONT_ATTR_*
     135             : };
     136             : 
     137             : class UNOTOOLS_DLLPUBLIC FontSubstConfiguration
     138             : {
     139             : private:
     140             :     com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
     141             :             m_xConfigProvider;
     142             :     com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >
     143             :             m_xConfigAccess;
     144           0 :     struct LocaleSubst
     145             :     {
     146             :         OUString                           aConfigLocaleString;
     147             :         mutable bool                            bConfigRead;
     148             :         // note: aSubstAttributes must be sorted alphabetically by Name
     149             :         // searches on the substitutes are done with Name as key, where
     150             :         // a minimal match is sufficient (that is e.g. "Thorndale" will match
     151             :         // "Thorndale BlaBlub"). Also names must be lower case.
     152             :         mutable std::vector< FontNameAttr >     aSubstAttributes;
     153             : 
     154           0 :         LocaleSubst() : bConfigRead( false ) {}
     155             :     };
     156             :     boost::unordered_map< OUString, LocaleSubst, OUStringHash > m_aSubst;
     157             :     typedef boost::unordered_set< OUString, OUStringHash > UniqueSubstHash;
     158             :     mutable UniqueSubstHash maSubstHash;
     159             : 
     160             :     void fillSubstVector( const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xFont,
     161             :                           const OUString& rType,
     162             :                           std::vector< OUString >& rSubstVector ) const;
     163             :     FontWeight getSubstWeight( const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xFont,
     164             :                           const OUString& rType ) const;
     165             :     FontWidth getSubstWidth( const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xFont,
     166             :                              const OUString& rType ) const;
     167             :     unsigned long getSubstType( const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xFont,
     168             :                                 const OUString& rType ) const;
     169             :     void readLocaleSubst( const OUString& rBcp47 ) const;
     170             : public:
     171             :     FontSubstConfiguration();
     172             :     ~FontSubstConfiguration();
     173             : 
     174             :     static FontSubstConfiguration& get();
     175             : 
     176             :     const FontNameAttr* getSubstInfo(
     177             :                                      const OUString& rFontName,
     178             :                                      const LanguageTag& rLanguageTag = LanguageTag( OUString( "en"))
     179             :                                      ) const;
     180             :     static void getMapName( const OUString& rOrgName, OUString& rShortName, OUString& rFamilyName, FontWeight& rWeight, FontWidth& rWidth, sal_uLong& rType );
     181             : };
     182             : 
     183             : } // namespace utl
     184             : 
     185             : #endif // INCLUDED_UNOTOOLS_FONTCFG_HXX
     186             : 
     187             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10