diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2013-02-05 16:40:29 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2013-02-06 18:37:34 +0100 |
commit | 0376a4c13ccffa64c938c6361a337264ad8f2b67 (patch) | |
tree | ff0b58cb64767496200c89bf4a4909d0702fc282 | |
parent | 624d46964215c1f066ded64ab684d6ccc98705d9 (diff) |
if a font is not available, show its name in italic in the font combo
Change-Id: Ia7d0de2c3017f450b9ace31753a351601ca6f1f0
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 40 | ||||
-rw-r--r-- | vcl/inc/vcl/combobox.hxx | 4 |
2 files changed, 42 insertions, 2 deletions
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index d49fc251d775..01f0e5e9a0a2 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -191,6 +191,7 @@ private: void ReleaseFocus_Impl(); void EnableControls_Impl(); + void CheckAndMarkUnknownFont( const OUString& fontname ); protected: virtual void Select(); @@ -208,6 +209,8 @@ public: void Fill( const FontList* pList ) { FontNameBox::Fill( pList ); nFtCount = pList->GetFontNameCount(); } + virtual void SetText( const OUString& rStr ) SAL_OVERRIDE; + virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) SAL_OVERRIDE; virtual long PreNotify( NotifyEvent& rNEvt ); virtual long Notify( NotifyEvent& rNEvt ); virtual Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); @@ -781,6 +784,43 @@ void SvxFontNameBox_Impl::FillList() SetSelection( aOldSel ); } +void SvxFontNameBox_Impl::SetText( const OUString& rStr ) +{ + CheckAndMarkUnknownFont( rStr ); + return FontNameBox::SetText( rStr ); +} + +void SvxFontNameBox_Impl::SetText( const OUString& rStr, const Selection& rNewSelection ) +{ + CheckAndMarkUnknownFont( rStr ); + return FontNameBox::SetText( rStr, rNewSelection ); +} + +void SvxFontNameBox_Impl::CheckAndMarkUnknownFont( const OUString& 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 ) diff --git a/vcl/inc/vcl/combobox.hxx b/vcl/inc/vcl/combobox.hxx index 499479778160..33a4382d5cbf 100644 --- a/vcl/inc/vcl/combobox.hxx +++ b/vcl/inc/vcl/combobox.hxx @@ -123,8 +123,8 @@ public: void EnableDDAutoWidth( sal_Bool b ); - void SetText( const OUString& rStr ); - void SetText( const OUString& rStr, const Selection& rNewSelection ); + virtual void SetText( const OUString& rStr ); + virtual void SetText( const OUString& rStr, const Selection& rNewSelection ); sal_uInt16 InsertEntry( const XubString& rStr, sal_uInt16 nPos = COMBOBOX_APPEND ); sal_uInt16 InsertEntry( const XubString& rStr, const Image& rImage, sal_uInt16 nPos = COMBOBOX_APPEND ); |