office-gobmx/include/svtools/ctrltool.hxx
Chris Sherlock f5a81a119c vcl: remove OutputDevice's GetDevFontSizeCount() and GetDevFontSize()
The OutputDevice::GetDevFontSize() function is only used for
non-scalable (bitmap) fonts. We have stopped supporting bitmap fonts
since LO 5.3, see tdf#103514: Support for bitmap-only fonts on Windows
has been removed (Khaled Hosny)

I found the following when removing PhysicalFontFace::SetBitmapSize():

 1. as mnHeight and mnWidth and not set by anyone, I realized I could
    remove them, which meant removing GetHeight() and GetWidth()

 2. PhysicalFontFamily::GetFontHeights() populates heights from the
    collection of font faces into a sorted vector of font heights taken
    from PhysicalFontFace. As this no longer exists this function
    serves no purpose, it has been removed.

 3. PhysicalFontFamily::GetDeviceFontSizeList() calls upon
    PhysicalFontFace::GetFontHeights(). This function takes this sorted
    list of font heights, and then populates and returns a new list of
    sizes (or rather, heights). As the heights aren't available any
    more, this function is also unneeded, so it has been removed.

 4. OutputDevice::GetDevFontSizeCount() calls upon
    PhysicalFontFamily::GetDeviceFontSizeList(). This function has the
    side effect of initializing the list of fonts.

 5. When I checked what calls on GetDevFontSizeCount(), there is only
    one caller - FontList::GetSizeAry() in svtools. The function returns
    a standard font size list if the family name is empty, or there are
    no font sizes (via OutputDevice::GetDevFontSizeCount()). As this
    will *always* be empty (see chain above) then this function just
    needs to always return a standard font size list.

    Thus OutputDevice::GetDevFontSizeCount() and GetFontSizeList() are
    no longer called upon by anything, so they can be removed.

 6. svtool's FontList::GetSizeAry() no longer uses the FontMetric
    parameter, so this has been removed from the function signature, and
    cleanup done of the function that calls upon it in svtools,
    framework, editeng, and desktop. A number of variables that were no
    longer used due to this change were also removed.

 7. This change removed the need for the mpSizeAry unique_ptr in
    FontList. ImplFontListFontMetric::GetDevice() and mpDevice could
    also be removed as it was no longer used anywhere.

 8. After simplifying GetSizeAry(), it turns out it was the same as
    GetStdSizeAry(), so removed FontList::GetSizeAry() and used
    FontList::GetStdSizeAry() in its place.

 9. Changing to use GetStdSizeAry() revealed that FontSizeBox::Fill()
    no longer used the pFontMetric paramter, so this was removed, and
    call sites updated.

10. Due to change to Fill():

    a. SvxFontSizeBox_Base::UpdateFont() no longer uses the
       const css::awt::FontDescriptor& rCurrentFont parameter, so
       removed this. This also removed the member variable
       m_aCurrentFont

    b. SvxCharNamePage::FillSizeBox_Impl() had a number of newly
       unused variables removed.

    c. SwStdFontTabPage::Reset() and
       SwStdFontTabPage::LoseFocusHdl() had a number of newly unused
       variables removed.

Change-Id: If840e240155c36ed351c63e3136b5b44bb058697
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121932
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-09-21 07:54:59 +02:00

213 lines
8.1 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <config_options.h>
#include <svtools/svtdllapi.h>
#include <rtl/ustring.hxx>
#include <sal/types.h>
#include <vcl/metric.hxx>
#include <vcl/vclptr.hxx>
#include <vector>
#include <memory>
#include <string_view>
class ImplFontListNameInfo;
class OutputDevice;
/*
Description
============
class FontList
This class manages all fonts which can be display on one or two output devices.
Additionally, this class offers methods for generating the StyleName from
bold and italics or the missing attributes from a StyleName.
Furthermore, this class can handle synthetically reproduced fonts.
It also works with several standard controls and standard menus.
Links:
class FontNameBox, class FontStyleBox, class FontSizeBox,
class FontNameMenu, class FontSizeMenu
--------------------------------------------------------------------------
FontList::FontList( OutputDevice* pDevice, OutputDevice* pDevice2 = NULL,
bool bAll = true );
Constructor of the FontList class. The relevant fonts will be queried from
the OutputDevice. The OutputDevice needs to exist as long as the FontList
class exists. Optionally, a second output device can be given in order to,
e.g., manage the fonts from both, a printer and a screen in a single FontList
and thus also give FontMenus the fonts if both OutputDevices.
The pDevice2 needs to exist as long as the FontList class exists.
The OutputDevice given first should be the preferred one. This is usually
the printer. Because if two different device fonts (one for the printer and
one for the screen) exist, the ones from the "pDevice" are preferred.
The third parameter governs whether only scalable or all fonts shall be queried.
With sal_True bitmap fonts will also be queried.
With sal_False vectorized and scalable fonts will be queried.
--------------------------------------------------------------------------
String FontList::GetStyleName( const FontMetric& rFontMetric ) const;
This method returns the StyleName of a FontMetric.
If no StyleName is set, a name will be generated from the set attributes.
--------------------------------------------------------------------------
OUString FontList::GetFontMapText( const FontMetric& rFontMetric ) const;
This method returns a Matchstring which indicates the problem that could
arise when using a font. This string should be displayed to the user.
--------------------------------------------------------------------------
FontMetric FontList::Get( const String& rName, const String& rStyleName ) const;
This method search a FontMetric for the given name and the given style name.
The Stylename can also be a synthetic one.
In that case the relevant FontMetric fields will be set.
If a StyleName is provided, a FontMetric structure without a Stylename can be
returned. To get a representation of the StyleName for displaying it to the user,
call GetStyleName() on this FontMetric structure.
Links:
FontList::GetStyleName()
--------------------------------------------------------------------------
FontMetric FontList::Get( const String& rName, FontWeight eWeight,
FontItalic eItalic ) const;
This method search a FontMetric structure for a provided name and styles.
This method can also return a FontMetric without a Stylename.
To get a representation of the StyleName to be presented to the user
call GetStyleName() with this FontMetric.
Links:
FontList::GetStyleName()
--------------------------------------------------------------------------
static const int* FontList::GetStdSizeAry();
This method returns the available sizes for the given font.
As all fonts are scalable, standard sizes are returned.
The array contains the heights of the font in tenth (1/10) point.
The last value of the array is 0.
The returned array will destroyed by the FontList.
You should thus not reference the array after the next method call on the
FontList.
*/
class SVT_DLLPUBLIC FontList
{
private:
static const int aStdSizeAry[];
OUString maMapBoth;
OUString maMapPrinterOnly;
OUString maMapStyleNotAvailable;
mutable OUString maMapNotAvailable;
OUString maLight;
OUString maLightItalic;
OUString maNormal;
OUString maNormalItalic;
OUString maBold;
OUString maBoldItalic;
OUString maBlack;
OUString maBlackItalic;
VclPtr<OutputDevice> mpDev;
VclPtr<OutputDevice> mpDev2;
std::vector<std::unique_ptr<ImplFontListNameInfo>> m_Entries;
SVT_DLLPRIVATE ImplFontListNameInfo* ImplFind( const OUString& rSearchName, sal_uInt32* pIndex ) const;
SVT_DLLPRIVATE ImplFontListNameInfo* ImplFindByName( const OUString& rStr ) const;
SVT_DLLPRIVATE void ImplInsertFonts(OutputDevice* pDev, bool bInsertData);
public:
FontList( OutputDevice* pDevice,
OutputDevice* pDevice2 = nullptr);
~FontList();
std::unique_ptr<FontList> Clone() const;
OUString GetFontMapText( const FontMetric& rFontMetric ) const;
const OUString& GetNormalStr() const { return maNormal; }
const OUString& GetItalicStr() const { return maNormalItalic; }
const OUString& GetBoldStr() const { return maBold; }
const OUString& GetBoldItalicStr() const { return maBoldItalic; }
const OUString& GetStyleName( FontWeight eWeight, FontItalic eItalic ) const;
OUString GetStyleName( const FontMetric& rFontMetric ) const;
FontMetric Get( const OUString& rName,
const OUString& rStyleName ) const;
FontMetric Get( const OUString& rName,
FontWeight eWeight,
FontItalic eItalic ) const;
bool IsAvailable( const OUString& rName ) const;
size_t GetFontNameCount() const
{
return m_Entries.size();
}
const FontMetric& GetFontName(size_t nFont) const;
sal_Handle GetFirstFontMetric( const OUString& rName ) const;
static sal_Handle GetNextFontMetric( sal_Handle hFontMetric );
static const FontMetric& GetFontMetric( sal_Handle hFontMetric );
static const int* GetStdSizeAry() { return aStdSizeAry; }
private:
FontList( const FontList& ) = delete;
FontList& operator =( const FontList& ) = delete;
};
class UNLESS_MERGELIBS(SVT_DLLPUBLIC) FontSizeNames
{
private:
const struct ImplFSNameItem* mpArray;
sal_Int32 mnElem;
public:
FontSizeNames( LanguageType eLanguage /* = LANGUAGE_DONTKNOW */ );
sal_Int32 Count() const { return mnElem; }
bool IsEmpty() const { return !mnElem; }
sal_Int32 Name2Size( std::u16string_view ) const;
OUString Size2Name( sal_Int32 ) const;
OUString GetIndexName( sal_Int32 nIndex ) const;
sal_Int32 GetIndexSize( sal_Int32 nIndex ) const;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */