vcl/inc/PhysicalFontFace.hxx | 16 +++++----------- vcl/source/font/PhysicalFontFace.cxx | 32 ++++++++++++++++++-------------- vcl/source/font/PhysicalFontFamily.cxx | 3 +-- 3 files changed, 24 insertions(+), 27 deletions(-)
New commits: commit 60676b3b376d5f3f6fb29fa68c34117c2149bbec Author: Chris Sherlock <chris.sherloc...@gmail.com> Date: Fri Jan 1 16:30:15 2016 +1100 vcl: Get rid of FontMatchStatus structure It's used exactly once, as a parameter of PhysicalFontFace::IsBetterMatch()'s function signature. That parameter only acts as input, so I think this is a case of YAGNI creeping into the code, thus I'm getting rid of it. Change-Id: Ic5e24f484d652ba2196e512795d0d27f4239df30 diff --git a/vcl/inc/PhysicalFontFace.hxx b/vcl/inc/PhysicalFontFace.hxx index ce40712..1593e33 100644 --- a/vcl/inc/PhysicalFontFace.hxx +++ b/vcl/inc/PhysicalFontFace.hxx @@ -25,19 +25,9 @@ #include "outfont.hxx" class ImplFontEntry; -struct FontMatchStatus; class FontSelectPattern; class PhysicalFontFamily; -struct FontMatchStatus -{ -public: - int mnFaceMatch; - int mnHeightMatch; - int mnWidthMatch; - const OUString* mpTargetStyleName; -}; - // - PhysicalFontFace - // TODO: no more direct access to members @@ -78,7 +68,11 @@ public: bool IsScalable() const { return (mnHeight == 0); } bool CheckMagic( int n ) const { return (n == mnMagic); } - bool IsBetterMatch( const FontSelectPattern&, FontMatchStatus& ) const; + bool IsBetterMatch( const FontSelectPattern& rFSD, + const OUString* pTargetStyleName, + int nStatusFaceMatch=0, + int nStatusHeightMatch=0, + int nStatusWidthMatch=0 ) const; sal_Int32 CompareWithSize( const PhysicalFontFace& ) const; sal_Int32 CompareIgnoreSize( const PhysicalFontFace& ) const; virtual ~PhysicalFontFace() {} diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx index c7c7ee2..5383e36 100644 --- a/vcl/source/font/PhysicalFontFace.cxx +++ b/vcl/source/font/PhysicalFontFace.cxx @@ -84,7 +84,11 @@ sal_Int32 PhysicalFontFace::CompareWithSize( const PhysicalFontFace& rOther ) co return 0; } -bool PhysicalFontFace::IsBetterMatch( const FontSelectPattern& rFSD, FontMatchStatus& rStatus ) const +bool PhysicalFontFace::IsBetterMatch( const FontSelectPattern& rFSD, + const OUString* pTargetStyleName, + int nStatusFaceMatch, + int nStatusHeightMatch, + int nStatusWidthMatch ) const { int nMatch = 0; @@ -92,8 +96,8 @@ bool PhysicalFontFace::IsBetterMatch( const FontSelectPattern& rFSD, FontMatchSt if( rFontName.equalsIgnoreAsciiCase( GetFamilyName() ) ) nMatch += 240000; - if( rStatus.mpTargetStyleName - && GetStyleName().equalsIgnoreAsciiCase( *rStatus.mpTargetStyleName ) ) + if( pTargetStyleName + && GetStyleName().equalsIgnoreAsciiCase( *pTargetStyleName ) ) nMatch += 120000; if( (rFSD.GetPitch() != PITCH_DONTKNOW) && (rFSD.GetPitch() == GetPitch()) ) @@ -198,31 +202,31 @@ bool PhysicalFontFace::IsBetterMatch( const FontSelectPattern& rFSD, FontMatchSt } } - if( rStatus.mnFaceMatch > nMatch ) + if( nStatusFaceMatch > nMatch ) return false; - else if( rStatus.mnFaceMatch < nMatch ) + else if( nStatusFaceMatch < nMatch ) { - rStatus.mnFaceMatch = nMatch; - rStatus.mnHeightMatch = nHeightMatch; - rStatus.mnWidthMatch = nWidthMatch; + nStatusFaceMatch = nMatch; + nStatusHeightMatch = nHeightMatch; + nStatusWidthMatch = nWidthMatch; return true; } // when two fonts are still competing prefer the // one with the best matching height - if( rStatus.mnHeightMatch > nHeightMatch ) + if( nStatusHeightMatch > nHeightMatch ) return false; - else if( rStatus.mnHeightMatch < nHeightMatch ) + else if( nStatusHeightMatch < nHeightMatch ) { - rStatus.mnHeightMatch = nHeightMatch; - rStatus.mnWidthMatch = nWidthMatch; + nStatusHeightMatch = nHeightMatch; + nStatusWidthMatch = nWidthMatch; return true; } - if( rStatus.mnWidthMatch > nWidthMatch ) + if( nStatusWidthMatch > nWidthMatch ) return false; - rStatus.mnWidthMatch = nWidthMatch; + nStatusWidthMatch = nWidthMatch; return true; } diff --git a/vcl/source/font/PhysicalFontFamily.cxx b/vcl/source/font/PhysicalFontFamily.cxx index 8cc691b..cc01487 100644 --- a/vcl/source/font/PhysicalFontFamily.cxx +++ b/vcl/source/font/PhysicalFontFamily.cxx @@ -229,11 +229,10 @@ PhysicalFontFace* PhysicalFontFamily::FindBestFontFace( const FontSelectPattern& // TODO: linear search improve! PhysicalFontFace* pBestFontFace = maFontFaces[0]; - FontMatchStatus aFontMatchStatus = {0,0,0, pTargetStyleName}; for( std::vector< PhysicalFontFace* >::const_iterator it=maFontFaces.begin(); it != maFontFaces.end(); ++it ) { PhysicalFontFace* pFoundFontFace = *it; - if( pFoundFontFace->IsBetterMatch( rFSD, aFontMatchStatus ) ) + if( pFoundFontFace->IsBetterMatch( rFSD, pTargetStyleName ) ) pBestFontFace = pFoundFontFace; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits