editeng/source/misc/SvXMLAutoCorrectImport.cxx | 2 editeng/source/misc/svxacorr.cxx | 11 +-- include/editeng/svxacorr.hxx | 2 include/unotools/fontdefs.hxx | 2 sw/inc/swacorr.hxx | 2 sw/source/core/sw3io/swacorr.cxx | 4 - unotools/source/misc/fontcvt.cxx | 10 +-- unotools/source/misc/fontdefs.cxx | 11 ++- vcl/inc/PhysicalFontCollection.hxx | 1 vcl/source/font/PhysicalFontCollection.cxx | 76 ++++++++++--------------- vcl/source/font/PhysicalFontFamily.cxx | 11 +++ vcl/source/gdi/font.cxx | 4 - vcl/source/outdev/font.cxx | 17 +---- 13 files changed, 74 insertions(+), 79 deletions(-)
New commits: commit 8d6697587776136f3121733e1c29d4200720dbd9 Author: Michael Meeks <michael.me...@collabora.com> Date: Fri Aug 22 00:37:46 2014 +0100 fdo#79761 - avoid re-canonicalising each font name on clone repeatedly. Change-Id: I5b32787943ab3f824249359e9924eae25ba5783b diff --git a/vcl/source/font/PhysicalFontFamily.cxx b/vcl/source/font/PhysicalFontFamily.cxx index 3cba470..6307ac0 100644 --- a/vcl/source/font/PhysicalFontFamily.cxx +++ b/vcl/source/font/PhysicalFontFamily.cxx @@ -281,6 +281,10 @@ void PhysicalFontFamily::GetFontHeights( std::set<int>& rHeights ) const void PhysicalFontFamily::UpdateCloneFontList( PhysicalFontCollection& rFontCollection, bool bScalable, bool bEmbeddable ) const { + // This is rather expensive to do per face. + OUString aFamilyName = GetEnglishSearchFontName( GetFamilyName() ); + PhysicalFontFamily* pFamily = rFontCollection.FindOrCreateFamily( aFamilyName ); + for( PhysicalFontFace* pFace = mpFirst; pFace; pFace = pFace->GetNextFace() ) { if( bScalable && !pFace->IsScalable() ) @@ -289,7 +293,12 @@ void PhysicalFontFamily::UpdateCloneFontList( PhysicalFontCollection& rFontColle continue; PhysicalFontFace* pClonedFace = pFace->Clone(); - rFontCollection.Add( pClonedFace ); + + assert( pClonedFace->GetFamilyName() == GetFamilyName() ); + assert( rFontCollection.FindOrCreateFamily( GetEnglishSearchFontName( pClonedFace->GetFamilyName() ) ) == pFamily ); + + if (! pFamily->AddFontFace( pClonedFace ) ) + delete pClonedFace; } } commit 46ac7d60dde9a09239709716efcfcf66dd0e0a85 Author: Michael Meeks <michael.me...@collabora.com> Date: Fri Aug 22 00:08:04 2014 +0100 font lookup - cleanup GetEnglishSearchName function signature. Change-Id: I6e3ca358d88e0285fe6e07b0617f3078a5edb857 diff --git a/include/unotools/fontdefs.hxx b/include/unotools/fontdefs.hxx index 6e20b88..7ac715e 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 1cb82c1..f91ab9a 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 4a45fce..3b6b722 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 15552c4..af2440c 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 a2fb925..233baba 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 e1e431c..bf2680f 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 ) { commit e2adbfc33c2cf9ad9844427f6c393da64bf48852 Author: Michael Meeks <michael.me...@collabora.com> Date: Thu Aug 21 23:37:44 2014 +0100 vcl: factor out font name lookup for future re-use. Change-Id: I35f80610862528d7525fa61135604468271ca37a diff --git a/vcl/inc/PhysicalFontCollection.hxx b/vcl/inc/PhysicalFontCollection.hxx index e91124a..86488fc 100644 --- a/vcl/inc/PhysicalFontCollection.hxx +++ b/vcl/inc/PhysicalFontCollection.hxx @@ -54,6 +54,7 @@ public: // find the device font PhysicalFontFamily* FindFontFamily( const OUString& rFontName ) const; + PhysicalFontFamily* FindOrCreateFamily( const OUString &rFamilyName ); PhysicalFontFamily* ImplFindByFont( FontSelectPattern& ) const; PhysicalFontFamily* ImplFindBySearchName( const OUString& ) const; diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx index e195065..15552c4 100644 --- a/vcl/source/font/PhysicalFontCollection.cxx +++ b/vcl/source/font/PhysicalFontCollection.cxx @@ -353,16 +353,7 @@ void PhysicalFontCollection::Add( PhysicalFontFace* pNewData ) GetEnglishSearchFontName( aSearchName ); PhysicalFontFamilies::const_iterator it = maPhysicalFontFamilies.find( aSearchName ); - PhysicalFontFamily* pFoundData = NULL; - - if( it != maPhysicalFontFamilies.end() ) - pFoundData = (*it).second; - - if( !pFoundData ) - { - pFoundData = new PhysicalFontFamily( aSearchName ); - maPhysicalFontFamilies[ aSearchName ] = pFoundData; - } + PhysicalFontFamily* pFoundData = FindOrCreateFamily( aSearchName ); bool bKeepNewData = pFoundData->AddFontFace( pNewData ); @@ -434,6 +425,23 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( const OUString& rFon return pFound; } +PhysicalFontFamily *PhysicalFontCollection::FindOrCreateFamily( const OUString &rFamilyName ) +{ + PhysicalFontFamilies::const_iterator it = maPhysicalFontFamilies.find( rFamilyName ); + PhysicalFontFamily* pFoundData = NULL; + + if( it != maPhysicalFontFamilies.end() ) + pFoundData = (*it).second; + + if( !pFoundData ) + { + pFoundData = new PhysicalFontFamily( rFamilyName ); + maPhysicalFontFamilies[ rFamilyName ] = pFoundData; + } + + return pFoundData; +} + PhysicalFontFamily* PhysicalFontCollection::ImplFindByTokenNames(const OUString& rTokenStr) const { PhysicalFontFamily* pFoundData = NULL; commit dd1c49d172e57e08f87ec69c4143f190b2a14a04 Author: Michael Meeks <michael.me...@collabora.com> Date: Thu Aug 21 22:48:22 2014 +0100 Simplify autocorrect loading - removing redundant parameter. Change-Id: Idc1ebba8d859ec79b6744228cfe3ef1f0992e41d diff --git a/editeng/source/misc/SvXMLAutoCorrectImport.cxx b/editeng/source/misc/SvXMLAutoCorrectImport.cxx index fcc47f1..80e5d02 100644 --- a/editeng/source/misc/SvXMLAutoCorrectImport.cxx +++ b/editeng/source/misc/SvXMLAutoCorrectImport.cxx @@ -129,7 +129,7 @@ SvXMLWordContext::SvXMLWordContext( if( !bOnlyTxt ) { const OUString sLongSave( sRight ); - if( !rLocalRef.rAutoCorrect.GetLongText( rLocalRef.xStorage, OUString(), sWrong, sRight ) && + if( !rLocalRef.rAutoCorrect.GetLongText( rLocalRef.xStorage, sWrong, sRight ) && !sLongSave.isEmpty() ) { sRight = sLongSave; diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 5816b94..5fb9424 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -1620,18 +1620,17 @@ bool SvxAutoCorrect::MakeCombinedChanges( std::vector<SvxAutocorrWord>& aNewEntr } - - // - return the replacement text (only for SWG-Format, all other - // can be taken from the word list!) +// - return the replacement text (only for SWG-Format, all other +// can be taken from the word list!) bool SvxAutoCorrect::GetLongText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, - const OUString&, const OUString&, OUString& ) + const OUString&, OUString& ) { return false; } - // Text with attribution (only the SWG - SWG format!) +// Text with attribution (only the SWG - SWG format!) bool SvxAutoCorrect::PutText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, - const OUString&, const OUString&, SfxObjectShell&, OUString& ) + const OUString&, const OUString&, SfxObjectShell&, OUString& ) { return false; } diff --git a/include/editeng/svxacorr.hxx b/include/editeng/svxacorr.hxx index f2d06655..9564de3 100644 --- a/include/editeng/svxacorr.hxx +++ b/include/editeng/svxacorr.hxx @@ -276,7 +276,7 @@ public: sal_Unicode GetQuote( sal_Unicode cInsChar, bool bSttQuote, LanguageType eLang ) const; virtual bool GetLongText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg, - const OUString& rFileName, const OUString& rShort, OUString& rLong ); + const OUString& rShort, OUString& rLong ); TYPEINFO(); diff --git a/sw/inc/swacorr.hxx b/sw/inc/swacorr.hxx index b22deec..5bb3c93 100644 --- a/sw/inc/swacorr.hxx +++ b/sw/inc/swacorr.hxx @@ -32,7 +32,7 @@ protected: // Return replacement text (only for SWG-format, all others can be obtained from wordlist!). // rShort is stream-name - encrypted! virtual bool GetLongText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, - const OUString& rFileName, const OUString& rShort, OUString& rLong ) SAL_OVERRIDE; + const OUString& rShort, OUString& rLong ) SAL_OVERRIDE; // Text with attributes (only SWG-format!). // rShort is stream-name - encrypted! diff --git a/sw/source/core/sw3io/swacorr.cxx b/sw/source/core/sw3io/swacorr.cxx index 8bae702..be4d6d5 100644 --- a/sw/source/core/sw3io/swacorr.cxx +++ b/sw/source/core/sw3io/swacorr.cxx @@ -34,13 +34,13 @@ TYPEINIT1( SwAutoCorrect, SvxAutoCorrect ); // rShort ist der Stream-Name - gecryptet! bool SwAutoCorrect::GetLongText( const uno::Reference < embed::XStorage >& rStg, - const OUString& rFileName, const OUString& rShort, OUString& rLong ) + const OUString& rShort, OUString& rLong ) { sal_uLong nRet = 0; if (rStg.is()) { // mba: relative URLs don't make sense here - SwXMLTextBlocks aBlk( rStg, rFileName ); + SwXMLTextBlocks aBlk( rStg, OUString() ); nRet = aBlk.GetText( rShort, rLong ); } else { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits