[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Dec 12 12:46:11 PST 2011


 sc/source/ui/inc/output.hxx   |    1 
 sc/source/ui/view/output2.cxx |   50 ++++++++++++++++++++++++++++++++++++------
 2 files changed, 45 insertions(+), 6 deletions(-)

New commits:
commit 66778dd58d69426d527edd6ea5d847ce62c950ac
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Dec 12 15:45:04 2011 -0500

    fdo#32530: Correct default horizontal alignment for complex script.

diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index 72934cf..9a81555 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 de1506a..82a9905 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;


More information about the Libreoffice-commits mailing list