LCOV - code coverage report
Current view: top level - include/svtools - ctrltool.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 3 8 37.5 %
Date: 2014-04-11 Functions: 2 7 28.6 %
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 _CTRLTOOL_HXX
      21             : #define _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             : Beschreibung
      37             : ============
      38             : 
      39             : class FontList
      40             : 
      41             : Diese Klasse verwaltet alle Fonts, die auf einem oder zwei Ausgabegeraeten
      42             : dargestellt werden koennen. Zusaetzlich bietet die Klasse Methoden an, um
      43             : aus Fett und Kursiv den StyleName zu generieren oder aus einem Stylename
      44             : die fehlenden Attribute. Zusaetzlich kann diese Klasse syntetisch nachgebildete
      45             : Fonts verarbeiten. Diese Klasse kann mit verschiedenen Standard-Controls und
      46             : Standard-Menus zusammenarbeiten.
      47             : 
      48             : Querverweise
      49             : 
      50             : class FontNameBox, class FontStyleBox, class FontSizeBox,
      51             : class FontNameMenu, class FontSizeMenu
      52             : 
      53             : --------------------------------------------------------------------------
      54             : 
      55             : FontList::FontList( OutputDevice* pDevice, OutputDevice* pDevice2 = NULL,
      56             :                     bool bAll = true );
      57             : 
      58             : Konstruktor der Klasse FontList. Vom uebergebenen OutputDevice werden die
      59             : entsprechenden Fonts abgefragt. Das OutputDevice muss solange existieren,
      60             : wie auch die Klasse FontList existiert. Optional kann noch ein 2tes
      61             : Ausgabedevice uebergeben werden, damit man zum Beispiel die Fonts von
      62             : einem Drucker und dem Bildschirm zusammen in einer FontListe verwalten kann
      63             : und somit auch den FontListen und FontMenus die Fonts von beiden OutputDevices
      64             : zu uebergeben. Auch das pDevice2 muss solange existieren, wie die Klasse
      65             : FontList existiert.
      66             : 
      67             : Das OutputDevice, welches als erstes uebergeben wird, sollte das bevorzugte
      68             : sein. Dies sollte im normalfall der Drucker sein. Denn wenn 2 verschiede
      69             : Device-Schriften (eine fuer Drucker und eine fuer den Bildschirm) vorhanden
      70             : sind, wird die vom uebergebenen Device "pDevice" bevorzugt.
      71             : 
      72             : Mit dem dritten Parameter kann man angeben, ob nur skalierbare Schriften
      73             : abgefragt werden sollen oder alle. Wenn sal_True uebergeben wird, werden auch
      74             : Bitmap-Schriften mit abgefragt. Bei sal_False werden Vector-Schriften und
      75             : scalierbare Schriften abgefragt.
      76             : 
      77             : --------------------------------------------------------------------------
      78             : 
      79             : String FontList::GetStyleName( const FontInfo& rInfo ) const;
      80             : 
      81             : Diese Methode gibt den StyleName von einer FontInfo zurueck. Falls kein
      82             : StyleName gesetzt ist, wird aus den gesetzten Attributen ein entsprechender
      83             : Name generiert, der dem Anwender praesentiert werden kann.
      84             : 
      85             : --------------------------------------------------------------------------
      86             : 
      87             : OUString FontList::GetFontMapText( const FontInfo& rInfo ) const;
      88             : 
      89             : Diese Methode gibt einen Matchstring zurueck, der dem Anwender
      90             : anzeigen soll, welche Probleme es mit diesem Font geben kann.
      91             : 
      92             : --------------------------------------------------------------------------
      93             : 
      94             : FontInfo FontList::Get( const String& rName, const String& rStyleName ) const;
      95             : 
      96             : Diese Methode sucht aus dem uebergebenen Namen und dem uebergebenen StyleName
      97             : die entsprechende FontInfo-Struktur raus. Der Stylename kann in dieser
      98             : Methode auch ein syntetischer sein. In diesem Fall werden die entsprechenden
      99             : Werte in der FontInfo-Struktur entsprechend gesetzt. Wenn ein StyleName
     100             : uebergeben wird, kann jedoch eine FontInfo-Struktur ohne Stylename
     101             : zurueckgegeben werden. Um den StyleName dem Anwender zu repraesentieren,
     102             : muss GetStyleName() mit dieser FontInfo-Struktur aufgerufen werden.
     103             : 
     104             : Querverweise
     105             : 
     106             : FontList::GetStyleName()
     107             : 
     108             : --------------------------------------------------------------------------
     109             : 
     110             : FontInfo FontList::Get( const String& rName, FontWeight eWeight,
     111             :                         FontItalic eItalic ) const;
     112             : 
     113             : Diese Methode sucht aus dem uebergebenen Namen und den uebergebenen Styles
     114             : die entsprechende FontInfo-Struktur raus. Diese Methode kann auch eine
     115             : FontInfo-Struktur ohne Stylename zurueckgegeben. Um den StyleName dem
     116             : Anwender zu repraesentieren, muss GetStyleName() mit dieser FontInfo-Struktur
     117             : aufgerufen werden.
     118             : 
     119             : Querverweise
     120             : 
     121             : FontList::GetStyleName()
     122             : 
     123             : --------------------------------------------------------------------------
     124             : 
     125             : const sal_IntPtr* FontList::GetSizeAry( const FontInfo& rInfo ) const;
     126             : 
     127             : Diese Methode liefert zum uebergebenen Font die vorhandenen Groessen.
     128             : Falls es sich dabei um einen skalierbaren Font handelt, werden Standard-
     129             : Groessen zurueckgegeben. Das Array enthaelt die Hoehen des Fonts in 10tel
     130             : Point. Der letzte Wert des Array ist 0. Das Array, was zurueckgegeben wird,
     131             : wird von der FontList wieder zerstoert. Nach dem Aufruf der naechsten Methode
     132             : von der FontList, sollte deshalb das Array nicht mehr referenziert werden.
     133             : 
     134             : */
     135             : 
     136             : 
     137             : #define FONTLIST_FONTINFO_NOTFOUND  ((sal_uInt16)0xFFFF)
     138             : 
     139             : #define FONTLIST_FONTNAMETYPE_PRINTER           ((sal_uInt16)0x0001)
     140             : #define FONTLIST_FONTNAMETYPE_SCREEN            ((sal_uInt16)0x0002)
     141             : 
     142             : class SVT_DLLPUBLIC FontList
     143             : {
     144             : private:
     145             :     OUString                maMapBoth;
     146             :     OUString                maMapPrinterOnly;
     147             :     OUString                maMapScreenOnly;
     148             :     OUString                maMapSizeNotAvailable;
     149             :     OUString                maMapStyleNotAvailable;
     150             :     mutable OUString        maMapNotAvailable;
     151             :     OUString                maLight;
     152             :     OUString                maLightItalic;
     153             :     OUString                maNormal;
     154             :     OUString                maNormalItalic;
     155             :     OUString                maBold;
     156             :     OUString                maBoldItalic;
     157             :     OUString                maBlack;
     158             :     OUString                maBlackItalic;
     159             :     sal_IntPtr*             mpSizeAry;
     160             :     OutputDevice*           mpDev;
     161             :     OutputDevice*           mpDev2;
     162             :     boost::ptr_vector<ImplFontListNameInfo> maEntries;
     163             : 
     164             :     SVT_DLLPRIVATE ImplFontListNameInfo*    ImplFind( const OUString& rSearchName, sal_uLong* pIndex ) const;
     165             :     SVT_DLLPRIVATE ImplFontListNameInfo*    ImplFindByName( const OUString& rStr ) const;
     166             :     SVT_DLLPRIVATE void                 ImplInsertFonts( OutputDevice* pDev, bool bAll,
     167             :                                              bool bInsertData );
     168             : 
     169             : public:
     170             :                             FontList( OutputDevice* pDevice,
     171             :                                       OutputDevice* pDevice2 = NULL,
     172             :                                       bool bAll = true );
     173             :                             ~FontList();
     174             : 
     175             :     FontList*               Clone() const;
     176             : 
     177             :     OutputDevice*           GetDevice() const { return mpDev; }
     178             :     OutputDevice*           GetDevice2() const { return mpDev2; }
     179             :     OUString                GetFontMapText( const FontInfo& rInfo ) const;
     180             : 
     181           0 :     const OUString&         GetNormalStr() const { return maNormal; }
     182           0 :     const OUString&         GetItalicStr() const { return maNormalItalic; }
     183           0 :     const OUString&         GetBoldStr() const { return maBold; }
     184           0 :     const OUString&         GetBoldItalicStr() const { return maBoldItalic; }
     185             :     const OUString&         GetStyleName( FontWeight eWeight, FontItalic eItalic ) const;
     186             :     OUString                GetStyleName( const FontInfo& rInfo ) const;
     187             : 
     188             :     FontInfo                Get( const OUString& rName,
     189             :                                  const OUString& rStyleName ) const;
     190             :     FontInfo                Get( const OUString& rName,
     191             :                                  FontWeight eWeight,
     192             :                                  FontItalic eItalic ) const;
     193             : 
     194             :     bool                    IsAvailable( const OUString& rName ) const;
     195        3942 :     sal_uInt16              GetFontNameCount() const
     196             :     {
     197        3942 :         return (sal_uInt16)maEntries.size();
     198             :     }
     199             :     const FontInfo&         GetFontName( sal_uInt16 nFont ) const;
     200             :     sal_Handle              GetFirstFontInfo( const OUString& rName ) const;
     201             :     sal_Handle              GetNextFontInfo( sal_Handle hFontInfo ) const;
     202             :     const FontInfo&         GetFontInfo( sal_Handle hFontInfo ) const;
     203             : 
     204             :     const sal_IntPtr*       GetSizeAry( const FontInfo& rInfo ) const;
     205             :     static const sal_IntPtr* GetStdSizeAry();
     206             : 
     207             : private:
     208             :                             FontList( const FontList& );
     209             :     FontList&               operator =( const FontList& );
     210             : };
     211             : 
     212             : 
     213             : 
     214             : // - FontSizeNames -
     215             : 
     216             : 
     217             : class SVT_DLLPUBLIC FontSizeNames
     218             : {
     219             : private:
     220             :     const struct ImplFSNameItem*    mpArray;
     221             :     sal_uLong                   mnElem;
     222             : 
     223             : public:
     224             :                             FontSizeNames( LanguageType eLanguage /* = LANGUAGE_DONTKNOW */ );
     225             : 
     226           0 :     sal_uLong               Count() const { return mnElem; }
     227        1371 :     bool                    IsEmpty() const { return !mnElem; }
     228             : 
     229             :     long                    Name2Size( const OUString& ) const;
     230             :     OUString                Size2Name( long ) const;
     231             : 
     232             :     OUString                GetIndexName( sal_uLong nIndex ) const;
     233             :     long                    GetIndexSize( sal_uLong nIndex ) const;
     234             : };
     235             : 
     236             : #endif  // _CTRLTOOL_HXX
     237             : 
     238             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10