[Libreoffice-commits] core.git: sc/source

2016-01-20 Thread Yogesh Desai
 sc/source/ui/view/output2.cxx |   28 +---
 1 file changed, 21 insertions(+), 7 deletions(-)

New commits:
commit 812ebe795219966a05baca5719b528c186a0baf6
Author: Yogesh Desai <er.yogeshde...@gmail.com>
Date:   Tue Jan 5 21:26:47 2016 +0530

tdf#96822 : Make cell contents left align when number formatting is text

Change-Id: I9754db93f4cf71a6001d5b3f39ee2bc2b01889cc
Reviewed-on: https://gerrit.libreoffice.org/21134
Reviewed-by: Eike Rathke <er...@redhat.com>
Tested-by: Eike Rathke <er...@redhat.com>

diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 39577bb..3021961 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -278,6 +278,14 @@ bool lcl_GetBoolValue(const ScPatternAttr& rPattern, 
sal_uInt16 nWhich, const Sf
 
 }
 
+bool lcl_isNumberFormatText(const ScDocument* pDoc, SCCOL nCellX, SCROW 
nCellY, SCTAB nTab )
+{
+sal_uInt32 nCurrentNumberFormat;
+pDoc->GetNumberFormat( nCellX, nCellY, nTab, nCurrentNumberFormat);
+SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable();
+return(pNumberFormatter->GetType( nCurrentNumberFormat ) == 
css::util::NumberFormat::TEXT);
+}
+
 void ScDrawStringsVars::SetPattern(
 const ScPatternAttr* pNew, const SfxItemSet* pSet, const ScRefCellValue& 
rCell,
 SvtScriptType nScript )
@@ -1391,7 +1399,7 @@ bool beginsWithRTLCharacter(const OUString& rStr)
 static SvxCellHorJustify getAlignmentFromContext( SvxCellHorJustify eInHorJust,
 bool bCellIsValue, const OUString& rText,
 const ScPatternAttr& rPattern, const SfxItemSet* pCondSet,
-const ScDocument* pDoc, SCTAB nTab )
+const ScDocument* pDoc, SCTAB nTab, const bool  bNumberFormatIsText )
 {
 SvxCellHorJustify eHorJustContext = eInHorJust;
 bool bUseWritingDirection = false;
@@ -1399,10 +1407,14 @@ static SvxCellHorJustify getAlignmentFromContext( 
SvxCellHorJustify eInHorJust,
 {
 // fdo#32530: Default alignment depends on value vs
 // string, and the direction of the 1st letter.
-if (beginsWithRTLCharacter( rText))
-eHorJustContext = bCellIsValue ? SVX_HOR_JUSTIFY_LEFT : 
SVX_HOR_JUSTIFY_RIGHT;
-else if (bCellIsValue)
-eHorJustContext = SVX_HOR_JUSTIFY_RIGHT;
+if (beginsWithRTLCharacter( rText)) //If language is RTL
+{
+if (bCellIsValue)
+   eHorJustContext = bNumberFormatIsText ? SVX_HOR_JUSTIFY_RIGHT : 
SVX_HOR_JUSTIFY_LEFT;
+else
+eHorJustContext = SVX_HOR_JUSTIFY_RIGHT;
+}else if (bCellIsValue) //If language is not RTL
+eHorJustContext = bNumberFormatIsText ? SVX_HOR_JUSTIFY_LEFT : 
SVX_HOR_JUSTIFY_RIGHT;
 else
 bUseWritingDirection = true;
 }
@@ -1693,8 +1705,9 @@ Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, 
bool bPaint, const ScA
 bCellIsValue = pFCell->IsRunning() || 
pFCell->IsValue();
 }
 
+const bool bNumberFormatIsText = lcl_isNumberFormatText( 
mpDoc, nCellX, nCellY, nTab );
 eOutHorJust = getAlignmentFromContext( aVars.GetHorJust(), 
bCellIsValue, aVars.GetString(),
-*pPattern, pCondSet, mpDoc, nTab);
+*pPattern, pCondSet, mpDoc, nTab, 
bNumberFormatIsText );
 
 bool bBreak = ( aVars.GetLineBreak() || aVars.GetHorJust() 
== SVX_HOR_JUSTIFY_BLOCK );
 // #i111387# #o11817313# disable automatic line breaks 
only for "General" number format
@@ -4571,8 +4584,9 @@ void ScOutputData::DrawEdit(bool bPixelToLogic)
 OUString aStr = mpDoc->GetString(nCellX, nCellY, nTab);
 
 DrawEditParam aParam(pPattern, pCondSet, 
lcl_SafeIsValue(aCell));
+const bool bNumberFormatIsText = 
lcl_isNumberFormatText( mpDoc, nCellX, nCellY, nTab );
 aParam.meHorJustContext = getAlignmentFromContext( 
aParam.meHorJustAttr,
-aParam.mbCellIsValue, aStr, *pPattern, 
pCondSet, mpDoc, nTab);
+aParam.mbCellIsValue, aStr, *pPattern, 
pCondSet, mpDoc, nTab, bNumberFormatIsText);
 aParam.meHorJustResult = (aParam.meHorJustAttr == 
SVX_HOR_JUSTIFY_BLOCK) ?
 SVX_HOR_JUSTIFY_BLOCK : 
aParam.meHorJustContext;
 aParam.mbPixelToLogic = bPixelToLogic;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


Yogesh Desai license statement

2016-01-06 Thread Yogesh Desai
Hello,

All of my past & future contributions to LibreOffice may be licensed under
the MPLv2/LGPLv3+ dual license.

My First Name:  Yogesh
My Middle Name: Bhalchandra
My Last Name:   Desai

My affiliation is : Libre Data Consultancy Services (P) Ltd

My IRC nick is yogeshdesai

Thank you!

Regards,

Yogesh Desai
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice