Kaydet (Commit) d5c9e772 authored tarafından Caolán McNamara's avatar Caolán McNamara

Default ascii import dialog to fixed text font the the detected language

For the Ascii import dialog detect the language first and base the default
fonts off that as the default fixed width font for that language

Change-Id: I6e81c7c38900a441076dc591c070b99a2184e081
üst fc2b42ed
...@@ -149,11 +149,44 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh, ...@@ -149,11 +149,44 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh,
} }
} }
sal_uInt16 nAppScriptType = GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() );
SwDoc* pDoc = rDocSh.GetDoc(); SwDoc* pDoc = rDocSh.GetDoc();
sal_uInt16 nAppScriptType = GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ); // initialise language
{ {
sal_Bool bDelPrinter = sal_False; if( !aOpt.GetLanguage() )
{
if(pDoc)
{
sal_uInt16 nWhich = GetWhichOfScript( RES_CHRATR_LANGUAGE, nAppScriptType);
aOpt.SetLanguage( ((SvxLanguageItem&)pDoc->
GetDefault( nWhich )).GetLanguage());
}
else
{
SvtLinguOptions aLinguOpt;
SvtLinguConfig().GetOptions( aLinguOpt );
switch(nAppScriptType)
{
case SCRIPTTYPE_ASIAN:
aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, SCRIPTTYPE_ASIAN));
break;
case SCRIPTTYPE_COMPLEX:
aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, SCRIPTTYPE_COMPLEX));
break;
//SCRIPTTYPE_LATIN:
default:
aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, SCRIPTTYPE_LATIN));
}
}
}
aLanguageLB.SetLanguageList( LANG_LIST_ALL, sal_True, sal_False );
aLanguageLB.SelectLanguage( aOpt.GetLanguage() );
}
{
bool bDelPrinter = false;
SfxPrinter* pPrt = pDoc ? pDoc->getPrinter(false) : 0; SfxPrinter* pPrt = pDoc ? pDoc->getPrinter(false) : 0;
if( !pPrt ) if( !pPrt )
{ {
...@@ -162,10 +195,9 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh, ...@@ -162,10 +195,9 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh,
SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
0 ); 0 );
pPrt = new SfxPrinter( pSet ); pPrt = new SfxPrinter( pSet );
bDelPrinter = sal_True; bDelPrinter = true;
} }
// get the set of disctinct available family names // get the set of disctinct available family names
std::set< String > aFontNames; std::set< String > aFontNames;
int nFontNames = pPrt->GetDevFontCount(); int nFontNames = pPrt->GetDevFontCount();
...@@ -184,65 +216,18 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh, ...@@ -184,65 +216,18 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh,
if( !aOpt.GetFontName().Len() ) if( !aOpt.GetFontName().Len() )
{ {
if(pDoc) LanguageType eLang = aOpt.GetLanguage();
{ Font aTmpFont(OutputDevice::GetDefaultFont(DEFAULTFONT_FIXED, eLang, DEFAULTFONT_FLAGS_ONLYONE, pPrt));
sal_uInt16 nFontRes = RES_CHRATR_FONT; aOpt.SetFontName(aTmpFont.GetName());
if(SCRIPTTYPE_ASIAN == nAppScriptType)
nFontRes = RES_CHRATR_CJK_FONT;
else if(SCRIPTTYPE_COMPLEX == nAppScriptType)
nFontRes = RES_CHRATR_CTL_FONT;
aOpt.SetFontName( ((SvxFontItem&)pDoc->GetDefault(
nFontRes )).GetFamilyName() );
}
else
{
sal_uInt16 nFontType = FONT_STANDARD;
if(SCRIPTTYPE_ASIAN == nAppScriptType)
nFontType = FONT_STANDARD_CJK;
else if(SCRIPTTYPE_COMPLEX == nAppScriptType)
nFontType = FONT_STANDARD_CTL;
aOpt.SetFontName(SW_MOD()->GetStdFontConfig()->GetFontFor(nFontType));
}
} }
aFontLB.SelectEntry( aOpt.GetFontName() ); aFontLB.SelectEntry( aOpt.GetFontName() );
if( bDelPrinter ) if( bDelPrinter )
delete pPrt; delete pPrt;
} }
// initialise language
{
if( !aOpt.GetLanguage() )
{
if(pDoc)
{
sal_uInt16 nWhich = GetWhichOfScript( RES_CHRATR_LANGUAGE, nAppScriptType);
aOpt.SetLanguage( ((SvxLanguageItem&)pDoc->
GetDefault( nWhich )).GetLanguage());
}
else
{
SvtLinguOptions aLinguOpt;
SvtLinguConfig().GetOptions( aLinguOpt );
switch(nAppScriptType)
{
case SCRIPTTYPE_ASIAN:
aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, SCRIPTTYPE_ASIAN));
break;
case SCRIPTTYPE_COMPLEX:
aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, SCRIPTTYPE_COMPLEX));
break;
//SCRIPTTYPE_LATIN:
default:
aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, SCRIPTTYPE_LATIN));
}
}
}
aLanguageLB.SetLanguageList( LANG_LIST_ALL, sal_True, sal_False );
aLanguageLB.SelectLanguage( aOpt.GetLanguage() );
}
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment