summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-12-12 15:45:04 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2011-12-12 15:46:51 -0500
commit66778dd58d69426d527edd6ea5d847ce62c950ac (patch)
treeb6fcf14e5087b10bd5dc63f2522bf6983cd1761e /sc
parentfd866ac8f184c0910883963c9c12b45a239a9227 (diff)
fdo#32530: Correct default horizontal alignment for complex script.
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/inc/output.hxx1
-rw-r--r--sc/source/ui/view/output2.cxx50
2 files changed, 45 insertions, 6 deletions
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index 72934cfb41ed..9a81555eab05 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -102,6 +102,7 @@ private:
long mnPosX;
long mnPosY;
long mnInitPosX;
+ sal_uInt8 mnScript;
bool mbBreak;
bool mbCellIsValue;
bool mbAsianVertical;
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index de1506a6089f..82a9905677a1 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1561,9 +1561,27 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic )
bCellIsValue = pFCell->IsRunning() || pFCell->IsValue();
}
- eOutHorJust = ( aVars.GetHorJust() != SVX_HOR_JUSTIFY_STANDARD ) ?
- aVars.GetHorJust() :
- ( bCellIsValue ? SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_LEFT );
+ if (aVars.GetHorJust() == SVX_HOR_JUSTIFY_STANDARD)
+ {
+ // fdo#32530: Default alignment depends on value vs
+ // string, and the script type of the 1st letter.
+ sal_uInt8 nScript1st = 0;
+ rtl::OUString aStr = aVars.GetString();
+ if (!aStr.isEmpty())
+ {
+ aStr = aStr.copy(0, 1);
+ nScript1st = pDoc->GetStringScriptType(aStr);
+ if (!nScript1st)
+ nScript1st = ScGlobal::GetDefaultScriptType();
+ }
+
+ if (nScript1st == SCRIPTTYPE_COMPLEX)
+ eOutHorJust = bCellIsValue ? SVX_HOR_JUSTIFY_LEFT : SVX_HOR_JUSTIFY_RIGHT;
+ else
+ eOutHorJust = bCellIsValue ? SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_LEFT;
+ }
+ else
+ eOutHorJust = aVars.GetHorJust();
if ( eOutHorJust == SVX_HOR_JUSTIFY_BLOCK || eOutHorJust == SVX_HOR_JUSTIFY_REPEAT )
eOutHorJust = SVX_HOR_JUSTIFY_LEFT; // repeat is not yet implemented
@@ -2137,6 +2155,7 @@ ScOutputData::DrawEditParam::DrawEditParam(const ScPatternAttr* pPattern, const
mnArrY(0),
mnX(0), mnY(0), mnCellX(0), mnCellY(0),
mnPosX(0), mnPosY(0), mnInitPosX(0),
+ mnScript(0),
mbBreak( (meHorJust == SVX_HOR_JUSTIFY_BLOCK) || lcl_GetBoolValue(*pPattern, ATTR_LINEBREAK, pCondSet) ),
mbCellIsValue(bCellIsValue),
mbAsianVertical(false),
@@ -2567,9 +2586,16 @@ void ScOutputData::DrawEditStandard(DrawEditParam& rParam)
bHidden = true; // gedreht wird getrennt ausgegeben
}
- SvxCellHorJustify eOutHorJust =
- ( rParam.meHorJust != SVX_HOR_JUSTIFY_STANDARD ) ? rParam.meHorJust :
- ( rParam.mbCellIsValue ? SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_LEFT );
+ SvxCellHorJustify eOutHorJust = rParam.meHorJust;
+ if (eOutHorJust == SVX_HOR_JUSTIFY_STANDARD)
+ {
+ // fdo#32530: Default alignment depends on value vs string, and the
+ // script type of the 1st letter.
+ if (rParam.mnScript == SCRIPTTYPE_COMPLEX)
+ eOutHorJust = rParam.mbCellIsValue ? SVX_HOR_JUSTIFY_LEFT : SVX_HOR_JUSTIFY_RIGHT;
+ else
+ eOutHorJust = rParam.mbCellIsValue ? SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_LEFT;
+ }
if ( eOutHorJust == SVX_HOR_JUSTIFY_BLOCK || eOutHorJust == SVX_HOR_JUSTIFY_REPEAT )
eOutHorJust = SVX_HOR_JUSTIFY_LEFT; // repeat is not yet implemented
@@ -4570,6 +4596,17 @@ void ScOutputData::DrawEdit(sal_Bool bPixelToLogic)
else
lcl_ClearEdit( *pEngine ); // also calls SetUpdateMode(sal_False)
+ // fdo#32530: Get the script type of the first letter.
+ sal_uInt8 nScript = 0;
+ rtl::OUString aStr = pDoc->GetString(nCellX, nCellY, nTab);
+ if (!aStr.isEmpty())
+ {
+ aStr = aStr.copy(0, 1);
+ nScript = pDoc->GetStringScriptType(aStr);
+ }
+ if (nScript == 0)
+ nScript = ScGlobal::GetDefaultScriptType();
+
DrawEditParam aParam(pPattern, pCondSet, lcl_SafeIsValue(pCell));
aParam.mbPixelToLogic = bPixelToLogic;
aParam.mbHyphenatorSet = bHyphenatorSet;
@@ -4583,6 +4620,7 @@ void ScOutputData::DrawEdit(sal_Bool bPixelToLogic)
aParam.mnPosX = nPosX;
aParam.mnPosY = nPosY;
aParam.mnInitPosX = nInitPosX;
+ aParam.mnScript = nScript;
aParam.mpOldPattern = pOldPattern;
aParam.mpOldCondSet = pOldCondSet;
aParam.mpThisRowInfo = pThisRowInfo;