From 00914dc9248760d62bea373f1fb4b78eece77dd7 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Tue, 5 Feb 2013 16:40:29 +0100 Subject: if a font is not available, show its name in italic in font combo(fate#308255) (cherry picked from commit 0376a4c13ccffa64c938c6361a337264ad8f2b67) Conflicts: vcl/inc/vcl/combobox.hxx Change-Id: Ia7d0de2c3017f450b9ace31753a351601ca6f1f0 --- svx/source/tbxctrls/tbcontrl.cxx | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'svx') diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 3e80d552d7b1..34a78599293b 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -198,6 +198,7 @@ private: void ReleaseFocus_Impl(); void EnableControls_Impl(); + void CheckAndMarkUnknownFont( const XubString& fontname ); protected: virtual void Select(); @@ -215,6 +216,8 @@ public: void Fill( const FontList* pList ) { FontNameBox::Fill( pList ); nFtCount = pList->GetFontNameCount(); } + virtual void SetText( const XubString& rStr ); + virtual void SetText( const XubString& rStr, const Selection& rNewSelection ); virtual long PreNotify( NotifyEvent& rNEvt ); virtual long Notify( NotifyEvent& rNEvt ); virtual Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); @@ -644,6 +647,43 @@ void SvxFontNameBox_Impl::FillList() SetSelection( aOldSel ); } +void SvxFontNameBox_Impl::SetText( const XubString& rStr ) +{ + CheckAndMarkUnknownFont( rStr ); + return FontNameBox::SetText( rStr ); +} + +void SvxFontNameBox_Impl::SetText( const XubString& rStr, const Selection& rNewSelection ) +{ + CheckAndMarkUnknownFont( rStr ); + return FontNameBox::SetText( rStr, rNewSelection ); +} + +void SvxFontNameBox_Impl::CheckAndMarkUnknownFont( const XubString& fontname ) +{ + if( fontname == GetText()) + return; + GetDocFontList_Impl( &pFontList, this ); + // If the font is unknown, show it in italic. + Font font = GetControlFont(); + if( pFontList != NULL && pFontList->IsAvailable( fontname )) + { + if( font.GetItalic() != ITALIC_NONE ) + { + font.SetItalic( ITALIC_NONE ); + SetControlFont( font ); + } + } + else + { + if( font.GetItalic() != ITALIC_NORMAL ) + { + font.SetItalic( ITALIC_NORMAL ); + SetControlFont( font ); + } + } +} + // ----------------------------------------------------------------------- void SvxFontNameBox_Impl::Update( const SvxFontItem* pFontItem ) -- cgit