Resolves: rhbz#975421 wrong chart direction in Farsi

Where Farsi (and apparenly Moroccon) are RTL but have LTR
math and charts should reportedly follow the math direction

Change-Id: Ib60eaaaa90fe46ef240030a91169fdff3f736329
This commit is contained in:
Caolán McNamara
2014-02-06 13:00:50 +00:00
parent eb07ab05c3
commit b37bce11cf
7 changed files with 67 additions and 38 deletions

View File

@@ -1303,7 +1303,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance(
if( aTemplateWithService.first.is())
aTemplateWithService.first->resetStyles( xDiagram );//#i109371#
xTemplate->changeDiagram( xDiagram );
if( Application::GetSettings().GetLayoutRTL() )
if( Application::GetSettings().GetMathLayoutRTL() )
AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
ThreeDHelper::setScheme( xDiagram, e3DScheme );
}

View File

@@ -329,7 +329,7 @@ bool ChartTypeDialogController::commitToModel( const ChartTypeParameter& rParame
if( aTemplateWithService.first.is())
aTemplateWithService.first->resetStyles( xDiagram );
xTemplate->changeDiagram( xDiagram );
if( Application::GetSettings().GetLayoutRTL() )
if( Application::GetSettings().GetMathLayoutRTL() )
AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
if( rParameter.b3DLook )
ThreeDHelper::setScheme( xDiagram, rParameter.eThreeDLookScheme );

View File

@@ -412,7 +412,7 @@ void SAL_CALL ChartModel::initNew()
setFirstDiagram( xDiagram );
bool bIsRTL = Application::GetSettings().GetLayoutRTL();
bool bIsRTL = Application::GetSettings().GetMathLayoutRTL();
//reverse x axis for rtl charts
if( bIsRTL )
AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );

View File

@@ -232,6 +232,15 @@ bool MsLangId::isRightToLeft( LanguageType nLang )
return false;
}
// static
bool MsLangId::isRightToLeftMath( LanguageType nLang )
{
//http://www.w3.org/TR/arabic-math/
if (nLang == LANGUAGE_FARSI || nLang == LANGUAGE_ARABIC_MOROCCO)
return false;
return isRightToLeft(nLang);
}
// static
bool MsLangId::isSimplifiedChinese( LanguageType nLang )
{

View File

@@ -107,9 +107,12 @@ public:
static LanguageType resolveSystemLanguageByScriptType( LanguageType nLang, sal_Int16 nType );
/** Whether locale has a Right-To-Left orientation. */
/** Whether locale has a Right-To-Left orientation for text. */
static bool isRightToLeft( LanguageType nLang );
/** Whether locale has a Right-To-Left orientation for math. */
static bool isRightToLeftMath( LanguageType nLang );
/** Whether locale is a CJK locale */
static bool isCJK( LanguageType nLang );

View File

@@ -1144,7 +1144,8 @@ public:
const LanguageTag& GetLanguageTag() const;
void SetUILanguageTag( const LanguageTag& rLanguageTag );
const LanguageTag& GetUILanguageTag() const;
bool GetLayoutRTL() const; // returns true if UI language requires right-to-left UI
bool GetLayoutRTL() const; // returns true if UI language requires right-to-left Text Layout
bool GetMathLayoutRTL() const; // returns true if UI language requires right-to-left Math Layout
const LocaleDataWrapper& GetLocaleDataWrapper() const;
const LocaleDataWrapper& GetUILocaleDataWrapper() const;
const vcl::I18nHelper& GetLocaleI18nHelper() const;

View File

@@ -1591,47 +1591,63 @@ void AllSettings::SetUILanguageTag( const LanguageTag& )
// -----------------------------------------------------------------------
bool AllSettings::GetLayoutRTL() const
namespace
{
static const char* pEnv = getenv("SAL_RTL_ENABLED" );
static int nUIMirroring = -1; // -1: undef, 0: auto, 1: on 2: off
// environment always overrides
if( pEnv )
return true;
bool bRTL = false;
if( nUIMirroring == -1 )
bool GetConfigLayoutRTL(bool bMath)
{
nUIMirroring = 0; // ask configuration only once
utl::OConfigurationNode aNode = utl::OConfigurationTreeRoot::tryCreateWithComponentContext(
comphelper::getProcessComponentContext(),
OUString("org.openoffice.Office.Common/I18N/CTL") ); // note: case sensitive !
if ( aNode.isValid() )
static const char* pEnv = getenv("SAL_RTL_ENABLED" );
static int nUIMirroring = -1; // -1: undef, 0: auto, 1: on 2: off
// environment always overrides
if( pEnv )
return true;
bool bRTL = false;
if( nUIMirroring == -1 )
{
sal_Bool bTmp = sal_Bool();
::com::sun::star::uno::Any aValue = aNode.getNodeValue( OUString("UIMirroring") );
if( aValue >>= bTmp )
nUIMirroring = 0; // ask configuration only once
utl::OConfigurationNode aNode = utl::OConfigurationTreeRoot::tryCreateWithComponentContext(
comphelper::getProcessComponentContext(),
OUString("org.openoffice.Office.Common/I18N/CTL") ); // note: case sensitive !
if ( aNode.isValid() )
{
// found true or false; if it was nil, nothing is changed
nUIMirroring = bTmp ? 1 : 2;
sal_Bool bTmp = sal_Bool();
::com::sun::star::uno::Any aValue = aNode.getNodeValue( OUString("UIMirroring") );
if( aValue >>= bTmp )
{
// found true or false; if it was nil, nothing is changed
nUIMirroring = bTmp ? 1 : 2;
}
}
}
}
if( nUIMirroring == 0 ) // no config found (eg, setup) or default (nil) was set: check language
{
LanguageType aLang = LANGUAGE_DONTKNOW;
ImplSVData* pSVData = ImplGetSVData();
if ( pSVData->maAppData.mpSettings )
aLang = pSVData->maAppData.mpSettings->GetUILanguageTag().getLanguageType();
bRTL = MsLangId::isRightToLeft( aLang );
}
else
bRTL = (nUIMirroring == 1);
if( nUIMirroring == 0 ) // no config found (eg, setup) or default (nil) was set: check language
{
LanguageType aLang = LANGUAGE_DONTKNOW;
ImplSVData* pSVData = ImplGetSVData();
if ( pSVData->maAppData.mpSettings )
aLang = pSVData->maAppData.mpSettings->GetUILanguageTag().getLanguageType();
if (bMath)
bRTL = MsLangId::isRightToLeftMath( aLang );
else
bRTL = MsLangId::isRightToLeft( aLang );
}
else
bRTL = (nUIMirroring == 1);
return bRTL;
return bRTL;
}
}
bool AllSettings::GetLayoutRTL() const
{
return GetConfigLayoutRTL(false);
}
bool AllSettings::GetMathLayoutRTL() const
{
return GetConfigLayoutRTL(true);
}
// -----------------------------------------------------------------------