[Libreoffice-commits] .: 2 commits - cui/source i18npool/source sc/source svl/inc svl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Aug 28 03:13:21 PDT 2012
cui/source/tabpages/numfmt.cxx | 9 +++++----
i18npool/source/localedata/data/en_GB.xml | 6 ++++++
i18npool/source/localedata/data/en_US.xml | 6 ++++++
sc/source/core/tool/cellform.cxx | 6 +++---
sc/source/ui/view/output2.cxx | 6 +++---
svl/inc/svl/zforlist.hxx | 4 ++--
svl/source/numbers/zforlist.cxx | 14 ++++++++++++--
svl/source/numbers/zformat.cxx | 6 +++---
8 files changed, 40 insertions(+), 17 deletions(-)
New commits:
commit 84c54990c0dbd3385a4a653afe63d0fa7b1c435b
Author: Johann Messner <johann.messner at jku.at>
Date: Tue Aug 28 11:08:58 2012 +0100
add some built in number formats for "fill in character" support in Calc
Change-Id: Ib70b737af3628c77a72b6b8e9267ad31890597c8
diff --git a/i18npool/source/localedata/data/en_GB.xml b/i18npool/source/localedata/data/en_GB.xml
index 8f23482..02ec91d 100644
--- a/i18npool/source/localedata/data/en_GB.xml
+++ b/i18npool/source/localedata/data/en_GB.xml
@@ -187,6 +187,12 @@
<FormatElement msgid="CurrencyFormatskey6" default="false" type="medium" usage="CURRENCY" formatindex="17">
<FormatCode>[CURRENCY]#,##0.--;[RED]-[CURRENCY]#,##0.--</FormatCode>
</FormatElement>
+ <FormatElement msgid="CurrencyFormatskey7" default="false" type="short" usage="CURRENCY" formatindex="72">
+ <FormatCode>[CURRENCY]* #,##0;-[CURRENCY]* #,##0</FormatCode>
+ </FormatElement>
+ <FormatElement msgid="CurrencyFormatskey8" default="false" type="medium" usage="CURRENCY" formatindex="73">
+ <FormatCode>[CURRENCY]* #,##0.00;-[CURRENCY]* #,##0.00</FormatCode>
+ </FormatElement>
<FormatElement msgid="PercentFormatskey1" default="true" type="short" usage="PERCENT_NUMBER" formatindex="8">
<FormatCode>0%</FormatCode>
</FormatElement>
diff --git a/i18npool/source/localedata/data/en_US.xml b/i18npool/source/localedata/data/en_US.xml
index f3172bf..69f4939 100644
--- a/i18npool/source/localedata/data/en_US.xml
+++ b/i18npool/source/localedata/data/en_US.xml
@@ -107,6 +107,12 @@
<FormatElement msgid="CurrencyFormatskey6" default="false" type="medium" usage="CURRENCY" formatindex="17">
<FormatCode>[CURRENCY]#,##0.--;[RED]-[CURRENCY]#,##0.--</FormatCode>
</FormatElement>
+ <FormatElement msgid="CurrencyFormatskey7" default="false" type="short" usage="CURRENCY" formatindex="72">
+ <FormatCode>[CURRENCY]* #,##0;-[CURRENCY]* #,##0</FormatCode>
+ </FormatElement>
+ <FormatElement msgid="CurrencyFormatskey8" default="false" type="medium" usage="CURRENCY" formatindex="73">
+ <FormatCode>[CURRENCY]* #,##0.00;-[CURRENCY]* #,##0.00</FormatCode>
+ </FormatElement>
<FormatElement msgid="DateFormatskey1" default="true" type="short" usage="DATE" formatindex="18">
<FormatCode>M/D/YY</FormatCode>
</FormatElement>
commit f727644ad18838a78525256623a33f864fe13fb2
Author: Johann Messner <johann.messner at jku.at>
Date: Tue Aug 28 10:51:15 2012 +0100
tweaking the "fill in character" support in Calc Number Format Strings
a) changed ordering of repeat code marker ( 0x1b ) and repeat code to more
sensible ( and correct imo ) order
b) prevent some possible div/0 errors
c) added some missing formatter 'GetOutputString' calls
diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx
index c603726..855cc90 100644
--- a/cui/source/tabpages/numfmt.cxx
+++ b/cui/source/tabpages/numfmt.cxx
@@ -132,8 +132,7 @@ void SvxNumberPreviewImpl::NotifyChange( const String& rPrevStr,
mnPos = aPrevStr.Search( 0x1B );
if ( mnPos != STRING_NOTFOUND )
{
- --mnPos;
- mnChar = aPrevStr.GetChar( mnPos );
+ mnChar = aPrevStr.GetChar( mnPos + 1 );
// delete placeholder and char to repeat
aPrevStr.Erase( mnPos, 2 );
}
@@ -168,9 +167,11 @@ void SvxNumberPreviewImpl::Paint( const Rectangle& )
if ( mnPos != STRING_NOTFOUND )
{
long nCharWidth = GetTextWidth( rtl::OUString::valueOf( mnChar ) );
- int nNumCharsToInsert = nLeadSpace / nCharWidth;
- if ( nNumCharsToInsert )
+ int nNumCharsToInsert = 0;
+ if (nCharWidth > 0) nNumCharsToInsert = nLeadSpace / nCharWidth;
+
+ if ( nNumCharsToInsert > 0)
{
for ( int i = 0; i < nNumCharsToInsert; ++i )
aTmpStr.Insert( mnChar, mnPos );
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index 5fdd0d2..93f71fb 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -63,7 +63,7 @@ void ScCellFormat::GetString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUStrin
case CELLTYPE_STRING:
{
rtl::OUString aCellString = ((ScStringCell*)pCell)->GetString();
- rFormatter.GetOutputString( aCellString, nFormat, rString, ppColor );
+ rFormatter.GetOutputString( aCellString, nFormat, rString, ppColor, bUseStarFormat );
}
break;
case CELLTYPE_EDIT:
@@ -135,12 +135,12 @@ void ScCellFormat::GetString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUStrin
if ( !bNullVals && fValue == 0.0 )
rString = rtl::OUString();
else
- rFormatter.GetOutputString( fValue, nFormat, rString, ppColor );
+ rFormatter.GetOutputString( fValue, nFormat, rString, ppColor, bUseStarFormat );
}
else
{
rtl::OUString aCellString = pFCell->GetString();
- rFormatter.GetOutputString( aCellString, nFormat, rString, ppColor );
+ rFormatter.GetOutputString( aCellString, nFormat, rString, ppColor, bUseStarFormat );
}
}
}
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index d4f2f7e..956bf68 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -508,8 +508,7 @@ sal_Bool ScDrawStringsVars::SetText( ScBaseCell* pCell )
nPos = aString.Search( 0x1B );
if ( nPos != STRING_NOTFOUND )
{
- nPos = nPos - 1;
- nChar = aString.GetChar( nPos );
+ nChar = aString.GetChar( nPos + 1 );
// delete placeholder and char to repeat
aString.Erase( nPos, 2 );
}
@@ -553,10 +552,11 @@ void ScDrawStringsVars::SetHashText()
void ScDrawStringsVars::RepeatToFill( long colWidth )
{
- if ( nPos == STRING_NOTFOUND || nPos >= aString.Len() )
+ if ( nPos == STRING_NOTFOUND || nPos > aString.Len() )
return;
long charWidth = pOutput->pFmtDevice->GetTextWidth(rtl::OUString(nChar));
+ if ( charWidth < 1) return;
if (bPixelToLogic)
colWidth = pOutput->mpRefDevice->PixelToLogic(Size(colWidth,0)).Width();
// Are there restrictions on the cell type we should filter out here ?
diff --git a/svl/inc/svl/zforlist.hxx b/svl/inc/svl/zforlist.hxx
index 983cf83..1cace08 100644
--- a/svl/inc/svl/zforlist.hxx
+++ b/svl/inc/svl/zforlist.hxx
@@ -489,14 +489,14 @@ public:
Formats only if the format code is of type text or the 4th subcode
of a format code is specified, otherwise sOutString will be == "" */
void GetOutputString( String& sString, sal_uInt32 nFIndex,
- String& sOutString, Color** ppColor );
+ String& sOutString, Color** ppColor, bool bUseStarFormat = false );
/** Format a string according to a format index, return string and color.
Formats only if the format code is of type text or the 4th subcode
of a format code is specified, otherwise sOutString will be == "" */
void GetOutputString( rtl::OUString& sString, sal_uInt32 nFIndex,
- rtl::OUString& sOutString, Color** ppColor );
+ rtl::OUString& sOutString, Color** ppColor, bool bUseStarFormat = false );
/** Format a number according to the standard default format matching
the given format index */
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 2dbed79..c5172a2 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -1441,7 +1441,8 @@ void SvNumberFormatter::GetOutputString(const double& fOutNumber,
void SvNumberFormatter::GetOutputString(String& sString,
sal_uInt32 nFIndex,
String& sOutString,
- Color** ppColor )
+ Color** ppColor,
+ bool bUseStarFormat )
{
SvNumberformat* pFormat = GetFormatEntry( nFIndex );
if (!pFormat)
@@ -1454,7 +1455,11 @@ void SvNumberFormatter::GetOutputString(String& sString,
else
{
ChangeIntl(pFormat->GetLanguage());
+ if ( bUseStarFormat )
+ pFormat->SetStarFormatSupport( true );
pFormat->GetOutputString(sString, sOutString, ppColor);
+ if ( bUseStarFormat )
+ pFormat->SetStarFormatSupport( false );
}
}
@@ -1485,7 +1490,8 @@ void SvNumberFormatter::GetOutputString(const double& fOutNumber,
void SvNumberFormatter::GetOutputString(rtl::OUString& sString,
sal_uInt32 nFIndex,
rtl::OUString& sOutString,
- Color** ppColor)
+ Color** ppColor,
+ bool bUseStarFormat )
{
SvNumberformat* pFormat = GetFormatEntry( nFIndex );
if (!pFormat)
@@ -1500,7 +1506,11 @@ void SvNumberFormatter::GetOutputString(rtl::OUString& sString,
ChangeIntl(pFormat->GetLanguage());
String aString = sString;
String aOutString = sOutString;
+ if ( bUseStarFormat )
+ pFormat->SetStarFormatSupport( true );
pFormat->GetOutputString(aString, aOutString, ppColor);
+ if ( bUseStarFormat )
+ pFormat->SetStarFormatSupport( false );
sString = aString;
sOutString = aOutString;
}
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 729ea17..8c30d24 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -3881,8 +3881,8 @@ bool SvNumberformat::ImpGetNumberOutput(double fNumber,
case NF_SYMBOLTYPE_STAR:
if( bStarFlag )
{
- sStr.Insert( (sal_Unicode) 0x1B, k /*++*/ );
sStr.Insert(rInfo.sStrArray[j].GetChar(1),k);
+ sStr.Insert( (sal_Unicode) 0x1B, k );
bRes = true;
}
break;
@@ -4001,8 +4001,8 @@ bool SvNumberformat::ImpNumberFillWithThousands(
case NF_SYMBOLTYPE_STAR:
if( bStarFlag )
{
- sStr.Insert( (sal_Unicode) 0x1B, k/*++*/ );
sStr.Insert(rInfo.sStrArray[j].GetChar(1),k);
+ sStr.Insert( (sal_Unicode) 0x1B, k );
bRes = true;
}
break;
@@ -4165,8 +4165,8 @@ bool SvNumberformat::ImpNumberFill( String& sStr, // number string
case NF_SYMBOLTYPE_STAR:
if( bStarFlag )
{
- sStr.Insert( sal_Unicode(0x1B), k++ );
sStr.Insert(rInfo.sStrArray[j].GetChar(1),k);
+ sStr.Insert( sal_Unicode(0x1B), k );
bRes = true;
}
break;
More information about the Libreoffice-commits
mailing list