vcl/source/gdi/outdev3.cxx | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-)
New commits: commit ea7102c93c33884a68d4dba0de7d52f8ed4f4579 Author: Chris Sherlock <chris.sherloc...@gmail.com> Date: Tue Mar 25 21:54:20 2014 +1100 fdo#74702 OutputDevice::ImplInitFontList() fails if no fonts on device It makes no sense that ImplInitFontList() only fails for Window instances. I have carefully checked all the functions that use this function, and there are no good cases when no fonts won't cause problems. In fact, we have a number of functions that specifically rely on the fact that ImplInitFontList will populate OutputDevice::mpFontCollection with at least one font. Therefore, I'm making this abort if it can't populate the collection, regardless of whether it is a Window, Printer or VirtualDevice. I have also refactored GetDefaultDevice - I now check the default pOutDev parameter to see if it is NULL (the default), in which case it is referring to the default window, so I call on Application::GetDefaultDevice() instead of going straight to the pimpl data structure used by the Application class. Change-Id: I2861521d876d776d7862fc4a7ec56b7acf818789 Reviewed-on: https://gerrit.libreoffice.org/8741 Reviewed-by: Chris Sherlock <chris.sherloc...@gmail.com> Tested-by: Chris Sherlock <chris.sherloc...@gmail.com> diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index 093da2f..6e22bd3 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -451,16 +451,22 @@ void ImplFontSubstitute( OUString& rFontName ) Font OutputDevice::GetDefaultFont( sal_uInt16 nType, LanguageType eLang, sal_uLong nFlags, const OutputDevice* pOutDev ) { + if (!pOutDev) // default is NULL + pOutDev = Application::GetDefaultDevice(); + LanguageTag aLanguageTag( ( eLang == LANGUAGE_NONE || eLang == LANGUAGE_SYSTEM || eLang == LANGUAGE_DONTKNOW ) ? Application::GetSettings().GetUILanguageTag() : LanguageTag( eLang )); utl::DefaultFontConfiguration& rDefaults = utl::DefaultFontConfiguration::get(); - OUString aSearch = rDefaults.getUserInterfaceFont( aLanguageTag ); // ensure a fallback OUString aDefault = rDefaults.getDefaultFont( aLanguageTag, nType ); + OUString aSearch; + if( !aDefault.isEmpty() ) aSearch = aDefault; + else + aSearch = rDefaults.getUserInterfaceFont( aLanguageTag ); // use the UI font as a fallback Font aFont; aFont.SetPitch( PITCH_VARIABLE ); @@ -552,11 +558,9 @@ Font OutputDevice::GetDefaultFont( sal_uInt16 nType, LanguageType eLang, { if ( nFlags & DEFAULTFONT_FLAGS_ONLYONE ) { - - if( !pOutDev ) - pOutDev = (const OutputDevice *)ImplGetSVData()->mpDefaultWin; if( !pOutDev ) { + SAL_WARN ("vcl.gdi", "No default window has been set for the application - we really shouldn't be able to get here"); sal_Int32 nIndex = 0; aFont.SetName( aSearch.getToken( 0, ';', nIndex ) ); } @@ -1186,26 +1190,28 @@ bool OutputDevice::ImplIsUnderlineAbove( const Font& rFont ) void OutputDevice::ImplInitFontList() const { - if( ! mpFontCollection->Count() ) + if( !mpFontCollection->Count() ) { if( mpGraphics || ImplGetGraphics() ) { SAL_INFO( "vcl.gdi", "OutputDevice::ImplInitFontList()" ); mpGraphics->GetDevFontList( mpFontCollection ); + + // There is absolutely no way there should be no fonts available on the device + if( !mpFontCollection->Count() ) + { + OUString aError( "Application error: no fonts and no vcl resource found on your system" ); + ResMgr* pMgr = ImplGetResMgr(); + if( pMgr ) + { + OUString aResStr(ResId(SV_ACCESSERROR_NO_FONTS, *pMgr).toString()); + if( !aResStr.isEmpty() ) + aError = aResStr; + } + Application::Abort( aError ); + } } } - if( meOutDevType == OUTDEV_WINDOW && ! mpFontCollection->Count() ) - { - OUString aError( "Application error: no fonts and no vcl resource found on your system" ); - ResMgr* pMgr = ImplGetResMgr(); - if( pMgr ) - { - OUString aResStr(ResId(SV_ACCESSERROR_NO_FONTS, *pMgr).toString()); - if( !aResStr.isEmpty() ) - aError = aResStr; - } - Application::Abort( aError ); - } } void OutputDevice::ImplInitFont() const _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits