diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2021-09-21 07:19:15 +1000 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-21 07:54:59 +0200 |
commit | f5a81a119cb63152c2c2e2473a1ea183a30c8db9 (patch) | |
tree | ba72abd1a3ab858f38a6716ed9bdb059018fde36 /svtools | |
parent | 4bd09020870e708b7ff1500356952d15fb52836d (diff) |
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>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/control/ctrlbox.cxx | 14 | ||||
-rw-r--r-- | svtools/source/control/ctrltool.cxx | 55 |
2 files changed, 7 insertions, 62 deletions
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx index 217c47967448..33218f9cb9ed 100644 --- a/svtools/source/control/ctrlbox.cxx +++ b/svtools/source/control/ctrlbox.cxx @@ -1079,7 +1079,7 @@ IMPL_LINK(FontSizeBox, ModifyHdl, weld::ComboBox&, rBox, void) m_aChangeHdl.Call(rBox); } -void FontSizeBox::Fill( const FontMetric* pFontMetric, const FontList* pList ) +void FontSizeBox::Fill( const FontList* pList ) { // remember for relative mode pFontList = pList; @@ -1092,15 +1092,7 @@ void FontSizeBox::Fill( const FontMetric* pFontMetric, const FontList* pList ) const int* pTempAry; const int* pAry = nullptr; - if( pFontMetric ) - { - aFontMetric = *pFontMetric; - pAry = pList->GetSizeAry( *pFontMetric ); - } - else - { - pAry = FontList::GetStdSizeAry(); - } + pAry = FontList::GetStdSizeAry(); // first insert font size names (for simplified/traditional chinese) FontSizeNames aFontSizeNames( Application::GetSettings().GetUILanguageTag().getLanguageType() ); @@ -1245,7 +1237,7 @@ void FontSizeBox::SetRelative( bool bNewRelative ) SetRange(20, 9999); SetUnit(FieldUnit::POINT); if ( pFontList) - Fill( &aFontMetric, pFontList ); + Fill( pFontList ); } set_active_or_entry_text(aStr); diff --git a/svtools/source/control/ctrltool.cxx b/svtools/source/control/ctrltool.cxx index df3b84759a86..5cacc8037bda 100644 --- a/svtools/source/control/ctrltool.cxx +++ b/svtools/source/control/ctrltool.cxx @@ -79,17 +79,14 @@ class ImplFontListFontMetric : public FontMetric friend FontList; private: - VclPtr<OutputDevice> mpDevice; ImplFontListFontMetric* mpNext; public: - ImplFontListFontMetric( const FontMetric& rInfo, - OutputDevice* pDev ) : - FontMetric( rInfo ), mpDevice(pDev), mpNext(nullptr) + ImplFontListFontMetric( const FontMetric& rInfo ) : + FontMetric( rInfo ), mpNext(nullptr) { } - OutputDevice* GetDevice() const { return mpDevice; } }; enum class FontListFontNameType @@ -100,7 +97,6 @@ enum class FontListFontNameType }; } - namespace o3tl { template<> struct typed_flags<FontListFontNameType> : is_typed_flags<FontListFontNameType, 0x3> {}; @@ -274,7 +270,7 @@ void FontList::ImplInsertFonts(OutputDevice* pDevice, bool bInsertData) { if ( bInsertData ) { - ImplFontListFontMetric* pNewInfo = new ImplFontListFontMetric( aFontMetric, pDevice ); + ImplFontListFontMetric* pNewInfo = new ImplFontListFontMetric( aFontMetric ); pData = new ImplFontListNameInfo( aSearchName ); pData->mpFirst = pNewInfo; pNewInfo->mpNext = nullptr; @@ -293,7 +289,7 @@ void FontList::ImplInsertFonts(OutputDevice* pDevice, bool bInsertData) bool bInsert = true; ImplFontListFontMetric* pPrev = nullptr; ImplFontListFontMetric* pTemp = pData->mpFirst; - ImplFontListFontMetric* pNewInfo = new ImplFontListFontMetric( aFontMetric, pDevice ); + ImplFontListFontMetric* pNewInfo = new ImplFontListFontMetric( aFontMetric ); while ( pTemp ) { sal_Int32 eComp = ImplCompareFontMetric( pNewInfo, pTemp ); @@ -744,49 +740,6 @@ const FontMetric& FontList::GetFontMetric( sal_Handle hFontMetric ) return *pInfo; } -const int* FontList::GetSizeAry( const FontMetric& rInfo ) const -{ - // first delete Size-Array - mpSizeAry.reset(); - - // use standard sizes if no name - if ( rInfo.GetFamilyName().isEmpty() ) - return aStdSizeAry; - - // first search fontname in order to use device from the matching font - OutputDevice* pDevice = mpDev; - ImplFontListNameInfo* pData = ImplFindByName( rInfo.GetFamilyName() ); - if ( pData ) - pDevice = pData->mpFirst->GetDevice(); - - int nDevSizeCount = pDevice->GetDevFontSizeCount( rInfo ); - if ( !nDevSizeCount || - (pDevice->GetDevFontSize( rInfo, 0 ).Height() == 0) ) - return aStdSizeAry; - - MapMode aOldMapMode = pDevice->GetMapMode(); - MapMode aMap( MapUnit::Map10thInch, Point(), Fraction( 1, 72 ), Fraction( 1, 72 ) ); - pDevice->SetMapMode( aMap ); - - int nRealCount = 0; - tools::Long nOldHeight = 0; - mpSizeAry.reset(new int[nDevSizeCount+1] ); - for (int i = 0; i < nDevSizeCount; ++i) - { - Size aSize = pDevice->GetDevFontSize( rInfo, i ); - if ( aSize.Height() != nOldHeight ) - { - nOldHeight = aSize.Height(); - mpSizeAry[nRealCount] = nOldHeight; - nRealCount++; - } - } - mpSizeAry[nRealCount] = 0; - - pDevice->SetMapMode( aOldMapMode ); - return mpSizeAry.get(); -} - struct ImplFSNameItem { sal_Int32 mnSize; |