summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-10-21 09:33:39 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-10-21 11:27:39 +0100
commite84482a38363004d5dc2fde24e57d4215b48797a (patch)
tree3b060be8bfb764ac030b520d2347be407100a4df /svx
parent41c083a7ade3feb7f5b6516f859db00fa8e2cf72 (diff)
Use language/script specific CTL/CJK sample text in font preview
i.e. font names are often typically in English, so fairly useless to take the English name to preview what effect the font will have in a CTL/CJK script. More languages and scripts need to be added, but this should be sufficient to bootstrap this up
Diffstat (limited to 'svx')
-rw-r--r--svx/inc/svx/fntctrl.hxx3
-rw-r--r--svx/source/dialog/fntctrl.cxx33
2 files changed, 31 insertions, 5 deletions
diff --git a/svx/inc/svx/fntctrl.hxx b/svx/inc/svx/fntctrl.hxx
index 2d5083337121..6a5c32fa25dc 100644
--- a/svx/inc/svx/fntctrl.hxx
+++ b/svx/inc/svx/fntctrl.hxx
@@ -53,7 +53,8 @@ private:
SVX_DLLPRIVATE void InitSettings( sal_Bool bForeground, sal_Bool bBackground );
SVX_DLLPRIVATE void Init ();
- SVX_DLLPRIVATE void SetFontSize( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont );
+ SVX_DLLPRIVATE void SetFontSize(const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont);
+ SVX_DLLPRIVATE void SetFontLang(const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont);
public:
SvxFontPrevWindow( Window* pParent );
diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx
index 4e8db6956211..c9548d92001d 100644
--- a/svx/source/dialog/fntctrl.cxx
+++ b/svx/source/dialog/fntctrl.cxx
@@ -48,6 +48,7 @@
#endif
#include <vector>
#include <svtools/colorcfg.hxx>
+#include <svtools/sampletext.hxx>
#include <svx/fntctrl.hxx>
#include <svx/dialogs.hrc>
@@ -80,6 +81,7 @@
#include <editeng/charreliefitem.hxx> // SvxCharReliefItem
#include <editeng/twolinesitem.hxx> // SvxTwoLinesItem
#include <editeng/charscaleitem.hxx> // SvxCharScaleWidthItem
+#include <editeng/langitem.hxx> // SvxLanguageItem
// define ----------------------------------------------------------------
@@ -694,18 +696,20 @@ void SvxFontPrevWindow::Paint( const Rectangle& )
if ( !pImpl->bSelection || pImpl->bUseFontNameAsText )
{
+ using namespace com::sun::star::i18n::ScriptType;
pImpl->aText = rFont.GetName();
if (pImpl->m_bCJKEnabled)
{
if (pImpl->aText.Len())
pImpl->aText.AppendAscii(" ");
- pImpl->aText += rCJKFont.GetName();
+ pImpl->aText += makeRepresentativeTextForFont(ASIAN, rCJKFont);
+
}
if (pImpl->m_bCTLEnabled)
{
if (pImpl->aText.Len())
pImpl->aText.AppendAscii(" ");
- pImpl->aText += rCTLFont.GetName();
+ pImpl->aText += makeRepresentativeTextForFont(COMPLEX, rCTLFont);
}
}
@@ -919,13 +923,13 @@ static void SetPrevFontStyle( const SfxItemSet& rSet, sal_uInt16 nPosture, sal_u
sal_uInt16 nWhich;
if( GetWhich( rSet, nPosture, nWhich ) )
{
- const SvxPostureItem& rItem = ( SvxPostureItem& ) rSet.Get( nWhich );
+ const SvxPostureItem& rItem = ( const SvxPostureItem& ) rSet.Get( nWhich );
rFont.SetItalic( ( FontItalic ) rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE );
}
if( GetWhich( rSet, nWeight, nWhich ) )
{
- SvxWeightItem& rItem = ( SvxWeightItem& ) rSet.Get( nWhich );
+ const SvxWeightItem& rItem = ( const SvxWeightItem& ) rSet.Get( nWhich );
rFont.SetWeight( ( FontWeight ) rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL );
}
}
@@ -946,6 +950,17 @@ void SvxFontPrevWindow::SetFontSize( const SfxItemSet& rSet, sal_uInt16 nSlot, S
rFont.SetSize( Size( 0, nH ) );
}
+void SvxFontPrevWindow::SetFontLang(const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont)
+{
+ sal_uInt16 nWhich;
+ LanguageType nLang;
+ if( GetWhich( rSet, nSlot, nWhich ) )
+ nLang = static_cast<const SvxLanguageItem&>(rSet.Get(nWhich)).GetLanguage();
+ else
+ nLang = LANGUAGE_NONE;
+ rFont.SetLanguage(nLang);
+}
+
static void SetPrevFontEscapement(SvxFont& _rFont, sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
{
_rFont.SetPropr( nProp );
@@ -1121,6 +1136,11 @@ void SvxFontPrevWindow::SetFromItemSet( const SfxItemSet &rSet,
SetFontSize( rSet, SID_ATTR_CHAR_CJK_FONTHEIGHT, rCJKFont );
SetFontSize( rSet, SID_ATTR_CHAR_CTL_FONTHEIGHT, rCTLFont );
+ // Language
+ SetFontLang( rSet, SID_ATTR_CHAR_LANGUAGE, rFont );
+ SetFontLang( rSet, SID_ATTR_CHAR_CJK_LANGUAGE, rCJKFont );
+ SetFontLang( rSet, SID_ATTR_CHAR_CTL_LANGUAGE, rCTLFont );
+
// Color
if( GetWhich( rSet, SID_ATTR_CHAR_COLOR, nWhich ) )
{
@@ -1364,6 +1384,11 @@ void SvxFontPrevWindow::Init( const SfxItemSet& rSet )
SetFontSize( rSet, SID_ATTR_CHAR_CJK_FONTHEIGHT, rCJKFont );
SetFontSize( rSet, SID_ATTR_CHAR_CTL_FONTHEIGHT, rCTLFont );
+ // Language
+ SetFontLang( rSet, SID_ATTR_CHAR_LANGUAGE, rFont );
+ SetFontLang( rSet, SID_ATTR_CHAR_CJK_LANGUAGE, rCJKFont );
+ SetFontLang( rSet, SID_ATTR_CHAR_CTL_LANGUAGE, rCTLFont );
+
// Color
nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_COLOR );
if( ISITEMSET )