summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYogesh Desai <er.yogeshdesai@gmail.com>2016-01-05 21:26:47 +0530
committerEike Rathke <erack@redhat.com>2016-01-20 17:10:28 +0000
commit812ebe795219966a05baca5719b528c186a0baf6 (patch)
treef4446a8917a3228fa1f16e049486f17b16500f0e
parentca27812e67663574cbc8a56b43e482dfaf3debc0 (diff)
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 <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/source/ui/view/output2.cxx28
1 files changed, 21 insertions, 7 deletions
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 39577bbeb92b..3021961615ce 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;