summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-08-22 00:08:04 +0100
committerMichael Meeks <michael.meeks@collabora.com>2014-08-22 16:22:13 +0100
commit46ac7d60dde9a09239709716efcfcf66dd0e0a85 (patch)
tree28aecc878cb912be387ac6985a4f3b25ecce9d00
parente2adbfc33c2cf9ad9844427f6c393da64bf48852 (diff)
font lookup - cleanup GetEnglishSearchName function signature.
Change-Id: I6e3ca358d88e0285fe6e07b0617f3078a5edb857
-rw-r--r--include/unotools/fontdefs.hxx2
-rw-r--r--unotools/source/misc/fontcvt.cxx10
-rw-r--r--unotools/source/misc/fontdefs.cxx11
-rw-r--r--vcl/source/font/PhysicalFontCollection.cxx50
-rw-r--r--vcl/source/gdi/font.cxx4
-rw-r--r--vcl/source/outdev/font.cxx17
6 files changed, 36 insertions, 58 deletions
diff --git a/include/unotools/fontdefs.hxx b/include/unotools/fontdefs.hxx
index 6e20b88e0e2f..7ac715eb829b 100644
--- a/include/unotools/fontdefs.hxx
+++ b/include/unotools/fontdefs.hxx
@@ -81,7 +81,7 @@ public:
UNOTOOLS_DLLPUBLIC OUString GetNextFontToken( const OUString& rTokenStr, sal_Int32& rIndex );
-UNOTOOLS_DLLPUBLIC void GetEnglishSearchFontName( OUString& rName );
+UNOTOOLS_DLLPUBLIC OUString GetEnglishSearchFontName( const OUString& rName );
/** Determine if the font is the special Star|Open Symbol font
diff --git a/unotools/source/misc/fontcvt.cxx b/unotools/source/misc/fontcvt.cxx
index 1cb82c1202c3..f91ab9a83ea0 100644
--- a/unotools/source/misc/fontcvt.cxx
+++ b/unotools/source/misc/fontcvt.cxx
@@ -1412,11 +1412,10 @@ static ConvertChar aImplStarSymbolCvt = { NULL, "StarBats", ImplStarSymbolToStar
const ConvertChar* ConvertChar::GetRecodeData( const OUString& rOrgFontName, const OUString& rMapFontName )
{
const ConvertChar* pCvt = NULL;
- OUString aOrgName( rOrgFontName );
- GetEnglishSearchFontName( aOrgName );
- OUString aMapName( rMapFontName );
+
// clean up and lowercase font name
- GetEnglishSearchFontName( aMapName );
+ OUString aOrgName( GetEnglishSearchFontName( rOrgFontName ) );
+ OUString aMapName( GetEnglishSearchFontName( rMapFontName ) );
if( aMapName == "starsymbol"
|| aMapName == "opensymbol" )
@@ -1457,8 +1456,7 @@ FontToSubsFontConverter CreateFontToSubsFontConverter( const OUString& rOrgName,
{
const ConvertChar* pCvt = NULL;
- OUString aName = rOrgName;
- GetEnglishSearchFontName( aName );
+ OUString aName = GetEnglishSearchFontName( rOrgName );
if ( nFlags & FONTTOSUBSFONT_IMPORT )
{
diff --git a/unotools/source/misc/fontdefs.cxx b/unotools/source/misc/fontdefs.cxx
index 4a45fce78951..3b6b72278079 100644
--- a/unotools/source/misc/fontdefs.cxx
+++ b/unotools/source/misc/fontdefs.cxx
@@ -320,8 +320,10 @@ static ImplLocalizedFontName aImplLocalizedNamesList[] =
{ NULL, NULL },
};
-void GetEnglishSearchFontName( OUString& rName )
+OUString GetEnglishSearchFontName( const OUString& rInName )
{
+ OUString rName( rInName );
+
bool bNeedTranslation = false;
sal_Int32 nLen = rName.getLength();
@@ -438,6 +440,8 @@ void GetEnglishSearchFontName( OUString& rName )
if( it != aDictionary.end() )
rName = OUString::createFromAscii ( it->second );
}
+
+ return rName;
}
OUString GetNextFontToken( const OUString& rTokenStr, sal_Int32& rIndex )
@@ -519,9 +523,8 @@ OUString GetSubsFontName( const OUString& rName, sal_uLong nFlags )
OUString aName;
sal_Int32 nIndex = 0;
- OUString aOrgName = GetNextFontToken( rName, nIndex );
- // clean up and lowercase font name
- GetEnglishSearchFontName( aOrgName );
+ OUString aOrgName = GetEnglishSearchFontName(
+ GetNextFontToken( rName, nIndex ) );
// #93662# do not try to replace StarSymbol with MS only font
if( nFlags == (SUBSFONT_MS|SUBSFONT_ONLYONE)
diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx
index 15552c4472cb..af2440ca7866 100644
--- a/vcl/source/font/PhysicalFontCollection.cxx
+++ b/vcl/source/font/PhysicalFontCollection.cxx
@@ -294,7 +294,7 @@ PhysicalFontFamily* PhysicalFontCollection::GetGlyphFallbackFont( FontSelectPatt
// call the hook to query the best matching glyph fallback font
if( mpFallbackHook->FindFontSubstitute( rFontSelData, rMissingCodes ) )
// apply outdev3.cxx specific fontname normalization
- GetEnglishSearchFontName( rFontSelData.maSearchName );
+ rFontSelData.maSearchName = GetEnglishSearchFontName( rFontSelData.maSearchName );
else
rFontSelData.maSearchName = "";
@@ -349,10 +349,8 @@ PhysicalFontFamily* PhysicalFontCollection::GetGlyphFallbackFont( FontSelectPatt
void PhysicalFontCollection::Add( PhysicalFontFace* pNewData )
{
- OUString aSearchName = pNewData->GetFamilyName();
- GetEnglishSearchFontName( aSearchName );
+ OUString aSearchName = GetEnglishSearchFontName( pNewData->GetFamilyName() );
- PhysicalFontFamilies::const_iterator it = maPhysicalFontFamilies.find( aSearchName );
PhysicalFontFamily* pFoundData = FindOrCreateFamily( aSearchName );
bool bKeepNewData = pFoundData->AddFontFace( pNewData );
@@ -364,11 +362,8 @@ void PhysicalFontCollection::Add( PhysicalFontFace* pNewData )
// find the font from the normalized font family name
PhysicalFontFamily* PhysicalFontCollection::ImplFindBySearchName( const OUString& rSearchName ) const
{
-#ifdef DEBUG
- OUString aTempName = rSearchName;
- GetEnglishSearchFontName( aTempName );
- DBG_ASSERT( aTempName == rSearchName, "PhysicalFontCollection::ImplFindBySearchName() called with non-normalized name" );
-#endif
+ // must be called with a normalized name.
+ assert( GetEnglishSearchFontName( rSearchName ) == rSearchName );
PhysicalFontFamilies::const_iterator it = maPhysicalFontFamilies.find( rSearchName );
if( it == maPhysicalFontFamilies.end() )
@@ -417,12 +412,7 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindByAliasName(const OUString&
PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( const OUString& rFontName ) const
{
- // normalize the font family name and
- OUString aName = rFontName;
- GetEnglishSearchFontName( aName );
-
- PhysicalFontFamily* pFound = ImplFindBySearchName( aName );
- return pFound;
+ return ImplFindBySearchName( GetEnglishSearchFontName( rFontName ) );
}
PhysicalFontFamily *PhysicalFontCollection::FindOrCreateFamily( const OUString &rFamilyName )
@@ -449,12 +439,11 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindByTokenNames(const OUString&
// use normalized font name tokens to find the font
for( sal_Int32 nTokenPos = 0; nTokenPos != -1; )
{
- OUString aSearchName = GetNextFontToken( rTokenStr, nTokenPos );
- if( aSearchName.isEmpty() )
+ OUString aFamilyName = GetNextFontToken( rTokenStr, nTokenPos );
+ if( aFamilyName.isEmpty() )
continue;
- GetEnglishSearchFontName( aSearchName );
- pFoundData = ImplFindBySearchName( aSearchName );
+ pFoundData = FindFontFamily( aFamilyName );
if( pFoundData )
break;
@@ -471,10 +460,7 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindBySubstFontAttr( const utl::
::std::vector< OUString >::const_iterator it = rFontAttr.Substitutions.begin();
for(; it != rFontAttr.Substitutions.end(); ++it )
{
- OUString aSearchName( *it );
- GetEnglishSearchFontName( aSearchName );
-
- pFoundData = ImplFindBySearchName( aSearchName );
+ pFoundData = FindFontFamily( *it );
if( pFoundData )
return pFoundData;
}
@@ -1076,7 +1062,7 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindByFont( FontSelectPattern& r
#endif
- GetEnglishSearchFontName( aSearchName );
+ aSearchName = GetEnglishSearchFontName( aSearchName );
ImplFontSubstitute( aSearchName );
// #114999# special emboldening for Ricoh fonts
// TODO: smarter check for special cases by using PreMatch infrastructure?
@@ -1131,8 +1117,7 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindByFont( FontSelectPattern& r
if (sStrippedName != rFSD.maTargetName)
{
rFSD.maTargetName = sStrippedName;
- aSearchName = rFSD.maTargetName;
- GetEnglishSearchFontName(aSearchName);
+ aSearchName = GetEnglishSearchFontName(rFSD.maTargetName);
pFoundData = ImplFindBySearchName(aSearchName);
if( pFoundData )
return pFoundData;
@@ -1141,7 +1126,7 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindByFont( FontSelectPattern& r
if( mpPreMatchHook )
{
if( mpPreMatchHook->FindFontSubstitute( rFSD ) )
- GetEnglishSearchFontName( aSearchName );
+ aSearchName = GetEnglishSearchFontName( aSearchName );
}
#if ENABLE_GRAPHITE
// the prematch hook uses the target name to search, but we now need
@@ -1168,14 +1153,13 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindByFont( FontSelectPattern& r
if( bMultiToken )
{
rFSD.maTargetName = GetNextFontToken( rFSD.GetFamilyName(), nTokenPos );
- aSearchName = rFSD.maTargetName;
- GetEnglishSearchFontName( aSearchName );
+ aSearchName = GetEnglishSearchFontName( rFSD.maTargetName );
}
else
nTokenPos = -1;
if( mpPreMatchHook )
if( mpPreMatchHook->FindFontSubstitute( rFSD ) )
- GetEnglishSearchFontName( aSearchName );
+ aSearchName = GetEnglishSearchFontName( aSearchName );
ImplFontSubstitute( aSearchName );
PhysicalFontFamily* pFoundData = ImplFindBySearchName( aSearchName );
if( pFoundData )
@@ -1188,8 +1172,7 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindByFont( FontSelectPattern& r
{
nTokenPos = 0;
rFSD.maTargetName = GetNextFontToken( rFSD.GetFamilyName(), nTokenPos );
- aSearchName = rFSD.maTargetName;
- GetEnglishSearchFontName( aSearchName );
+ aSearchName = GetEnglishSearchFontName( rFSD.maTargetName );
}
OUString aSearchShortName;
@@ -1262,8 +1245,7 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindByFont( FontSelectPattern& r
if( rFSD.maTargetName.isEmpty() )
continue;
- aSearchName = rFSD.maTargetName;
- GetEnglishSearchFontName( aSearchName );
+ aSearchName = GetEnglishSearchFontName( rFSD.maTargetName );
OUString aTempShortName;
OUString aTempFamilyName;
diff --git a/vcl/source/gdi/font.cxx b/vcl/source/gdi/font.cxx
index a2fb92514ac1..233babad24b4 100644
--- a/vcl/source/gdi/font.cxx
+++ b/vcl/source/gdi/font.cxx
@@ -155,8 +155,8 @@ void Impl_Font::AskConfig()
sal_uLong nType = 0;
FontWeight eWeight = WEIGHT_DONTKNOW;
FontWidth eWidthType = WIDTH_DONTKNOW;
- OUString aMapName = maFamilyName;
- GetEnglishSearchFontName( aMapName );
+ OUString aMapName = GetEnglishSearchFontName( maFamilyName );
+
utl::FontSubstConfiguration::getMapName( aMapName,
aShortName, aFamilyName, eWeight, eWidthType, nType );
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index e1e431c90860..bf2680fc42ab 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -676,10 +676,8 @@ ImplFontSubstEntry::ImplFontSubstEntry( const OUString& rFontName,
, maReplaceName( rSubstFontName )
, mnFlags( nSubstFlags )
{
- maSearchName = rFontName;
- maSearchReplaceName = rSubstFontName;
- GetEnglishSearchFontName( maSearchName );
- GetEnglishSearchFontName( maSearchReplaceName );
+ maSearchName = GetEnglishSearchFontName( rFontName );
+ maSearchReplaceName = GetEnglishSearchFontName( rSubstFontName );
}
void OutputDevice::RemoveFontSubstitute( sal_uInt16 n )
@@ -727,11 +725,8 @@ bool ImplDirectFontSubstitution::FindFontSubstitute( OUString& rSubstName,
void ImplFontSubstitute( OUString& rFontName )
{
-#ifdef DBG_UTIL
- OUString aTempName = rFontName;
- GetEnglishSearchFontName( aTempName );
- DBG_ASSERT( aTempName == rFontName, "ImplFontSubstitute() called without a searchname" );
-#endif
+ // must be canonicalised
+ assert( GetEnglishSearchFontName( rFontName ) == rFontName );
OUString aSubstFontName;
@@ -836,8 +831,8 @@ Font OutputDevice::GetDefaultFont( sal_uInt16 nType, LanguageType eLang,
sal_Int32 nIndex = 0;
do
{
- aSearchName = GetNextFontToken( aSearch, nIndex );
- GetEnglishSearchFontName( aSearchName );
+ aSearchName = GetEnglishSearchFontName( GetNextFontToken( aSearch, nIndex ) );
+
PhysicalFontFamily* pFontFamily = pOutDev->mpFontCollection->ImplFindBySearchName( aSearchName );
if( pFontFamily )
{