LCOV - code coverage report
Current view: top level - include/svtools - ctrltool.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 4 9 44.4 %
Date: 2015-06-13 12:38:46 Functions: 3 8 37.5 %
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_SVTOOLS_CTRLTOOL_HXX
      21             : #define INCLUDED_SVTOOLS_CTRLTOOL_HXX
      22             : 
      23             : #include <boost/ptr_container/ptr_vector.hpp>
      24             : 
      25             : #include <svtools/svtdllapi.h>
      26             : #include <rtl/ustring.hxx>
      27             : #include <sal/types.h>
      28             : #include <vcl/metric.hxx>
      29             : #include <tools/solar.h>
      30             : 
      31             : class ImplFontListNameInfo;
      32             : class OutputDevice;
      33             : 
      34             : /*
      35             : 
      36             : Description
      37             : ============
      38             : 
      39             : class FontList
      40             : 
      41             : This class manages all fonts which can be display on one or two output devices.
      42             : Additionally, this class offers methods for generating the StyleName from
      43             : bold and italics or the missing attributes from a StyleName.
      44             : Furthermore, this class can handle synthetically reproduced fonts.
      45             : It also works with several standard controls and standard menus.
      46             : 
      47             : Links:
      48             : 
      49             : class FontNameBox, class FontStyleBox, class FontSizeBox,
      50             : class FontNameMenu, class FontSizeMenu
      51             : 
      52             : --------------------------------------------------------------------------
      53             : 
      54             : FontList::FontList( OutputDevice* pDevice, OutputDevice* pDevice2 = NULL,
      55             :                     bool bAll = true );
      56             : 
      57             : Constructor of the FontList class. The relevant fonts will be queried from
      58             : the OutputDevice. The OutputDevice needs to exist as long as the FontList
      59             : class exists. Optionally, a second output device can be given in order to,
      60             : e.g., manage the fonts from both, a printer and a screen in a single FontList
      61             : and thus also give FontMenus the fonts if both OutputDevices.
      62             : The pDevice2 needs to exist as long as the FontList class exists.
      63             : 
      64             : The OutputDevice given first should be the preferred one. This is usually
      65             : the printer. Because if two different device fonts (one for the printer and
      66             : one for the screen) exist, the ones from the "pDevice" are preferred.
      67             : 
      68             : The third paramter governs whether only scalable or all fonts shall be queried.
      69             : With sal_True Bitmap-Schriften will also be queried.
      70             : With sal_False vectorized and scalable fonts will be queried.
      71             : 
      72             : --------------------------------------------------------------------------
      73             : 
      74             : String FontList::GetStyleName( const vcl::FontInfo& rInfo ) const;
      75             : 
      76             : This method returns the StyleName of a vcl::FontInfo.
      77             : If no StyleName is set, a name will be generated from the set attributes.
      78             : 
      79             : --------------------------------------------------------------------------
      80             : 
      81             : OUString FontList::GetFontMapText( const vcl::FontInfo& rInfo ) const;
      82             : 
      83             : This method returns a Matchstring which indicates the problem that could
      84             : arise when using a font. This string should be displayed to the user.
      85             : 
      86             : --------------------------------------------------------------------------
      87             : 
      88             : vcl::FontInfo FontList::Get( const String& rName, const String& rStyleName ) const;
      89             : 
      90             : This method search a vcl::FontInfo for the given name and the given style name.
      91             : The Stylename can also be a synthetic one.
      92             : In that case the relevant vcl::FontInfo fields will be set.
      93             : If a StyleName is provived, a vcl::FontInfo structure without a Stylename can be
      94             : returned. To get a representation of the StyleName for displaying it to the user,
      95             : call GetStyleName() on this vcl::FontInfo structure.
      96             : 
      97             : Links:
      98             : 
      99             : FontList::GetStyleName()
     100             : 
     101             : --------------------------------------------------------------------------
     102             : 
     103             : vcl::FontInfo FontList::Get( const String& rName, FontWeight eWeight,
     104             :                         FontItalic eItalic ) const;
     105             : 
     106             : This method search a vcl::FontInfo structure for a provided name and styles.
     107             : This method can also return a vcl::FontInfo without a Stylename.
     108             : To get a representation of the StyleName to be presented to the user
     109             : call GetStyleName() with this vcl::FontInfo.
     110             : 
     111             : Links:
     112             : 
     113             : FontList::GetStyleName()
     114             : 
     115             : --------------------------------------------------------------------------
     116             : 
     117             : const sal_IntPtr* FontList::GetSizeAry( const vcl::FontInfo& rInfo ) const;
     118             : 
     119             : This method returns the available sizes for the given font.
     120             : If it is a scalable font, standard sizes are returned.
     121             : The array contains the heights of the font in tenth (1/10) point.
     122             : The last value of the array is 0.
     123             : The returned array will destroyed by the FontList.
     124             : You should thus not reference the array after the next method call on the
     125             : FontList.
     126             : */
     127             : 
     128             : 
     129             : #define FONTLIST_FONTINFO_NOTFOUND  ((sal_uInt16)0xFFFF)
     130             : 
     131             : class SVT_DLLPUBLIC FontList
     132             : {
     133             : private:
     134             :     static const sal_IntPtr aStdSizeAry[];
     135             : 
     136             :     OUString                maMapBoth;
     137             :     OUString                maMapPrinterOnly;
     138             :     OUString                maMapScreenOnly;
     139             :     OUString                maMapStyleNotAvailable;
     140             :     mutable OUString        maMapNotAvailable;
     141             :     OUString                maLight;
     142             :     OUString                maLightItalic;
     143             :     OUString                maNormal;
     144             :     OUString                maNormalItalic;
     145             :     OUString                maBold;
     146             :     OUString                maBoldItalic;
     147             :     OUString                maBlack;
     148             :     OUString                maBlackItalic;
     149             :     sal_IntPtr*             mpSizeAry;
     150             :     VclPtr<OutputDevice>    mpDev;
     151             :     VclPtr<OutputDevice>    mpDev2;
     152             :     boost::ptr_vector<ImplFontListNameInfo> maEntries;
     153             : 
     154             :     SVT_DLLPRIVATE ImplFontListNameInfo*    ImplFind( const OUString& rSearchName, sal_uLong* pIndex ) const;
     155             :     SVT_DLLPRIVATE ImplFontListNameInfo*    ImplFindByName( const OUString& rStr ) const;
     156             :     SVT_DLLPRIVATE void                 ImplInsertFonts( OutputDevice* pDev, bool bAll,
     157             :                                              bool bInsertData );
     158             : 
     159             : public:
     160             :                             FontList( OutputDevice* pDevice,
     161             :                                       OutputDevice* pDevice2 = NULL,
     162             :                                       bool bAll = true );
     163             :                             ~FontList();
     164             : 
     165             :     FontList*               Clone() const;
     166             : 
     167             :     OutputDevice*           GetDevice() const { return mpDev; }
     168             :     OutputDevice*           GetDevice2() const { return mpDev2; }
     169             :     OUString                GetFontMapText( const vcl::FontInfo& rInfo ) const;
     170             : 
     171           0 :     const OUString&         GetNormalStr() const { return maNormal; }
     172           0 :     const OUString&         GetItalicStr() const { return maNormalItalic; }
     173           0 :     const OUString&         GetBoldStr() const { return maBold; }
     174           0 :     const OUString&         GetBoldItalicStr() const { return maBoldItalic; }
     175             :     const OUString&         GetStyleName( FontWeight eWeight, FontItalic eItalic ) const;
     176             :     OUString                GetStyleName( const vcl::FontInfo& rInfo ) const;
     177             : 
     178             :     vcl::FontInfo           Get( const OUString& rName,
     179             :                                  const OUString& rStyleName ) const;
     180             :     vcl::FontInfo           Get( const OUString& rName,
     181             :                                  FontWeight eWeight,
     182             :                                  FontItalic eItalic ) const;
     183             : 
     184             :     bool                    IsAvailable( const OUString& rName ) const;
     185        6704 :     sal_uInt16              GetFontNameCount() const
     186             :     {
     187        6704 :         return (sal_uInt16)maEntries.size();
     188             :     }
     189             :     const vcl::FontInfo&    GetFontName( sal_uInt16 nFont ) const;
     190             :     sal_Handle              GetFirstFontInfo( const OUString& rName ) const;
     191             :     static sal_Handle           GetNextFontInfo( sal_Handle hFontInfo );
     192             :     static const vcl::FontInfo& GetFontInfo( sal_Handle hFontInfo );
     193             : 
     194             :     const sal_IntPtr*       GetSizeAry( const vcl::FontInfo& rInfo ) const;
     195        3645 :     static const sal_IntPtr* GetStdSizeAry() { return aStdSizeAry; }
     196             : 
     197             : private:
     198             :                             FontList( const FontList& ) SAL_DELETED_FUNCTION;
     199             :     FontList&               operator =( const FontList& ) SAL_DELETED_FUNCTION;
     200             : };
     201             : 
     202             : class SVT_DLLPUBLIC FontSizeNames
     203             : {
     204             : private:
     205             :     const struct ImplFSNameItem*    mpArray;
     206             :     sal_uLong                   mnElem;
     207             : 
     208             : public:
     209             :                             FontSizeNames( LanguageType eLanguage /* = LANGUAGE_DONTKNOW */ );
     210             : 
     211           0 :     sal_uLong               Count() const { return mnElem; }
     212        2659 :     bool                    IsEmpty() const { return !mnElem; }
     213             : 
     214             :     long                    Name2Size( const OUString& ) const;
     215             :     OUString                Size2Name( long ) const;
     216             : 
     217             :     OUString                GetIndexName( sal_uLong nIndex ) const;
     218             :     long                    GetIndexSize( sal_uLong nIndex ) const;
     219             : };
     220             : 
     221             : #endif // INCLUDED_SVTOOLS_CTRLTOOL_HXX
     222             : 
     223             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11