summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohann Messner <johann.messner@jku.at>2012-08-28 10:51:15 +0100
committerNoel Power <noel.power@suse.com>2012-08-28 11:12:44 +0100
commitf727644ad18838a78525256623a33f864fe13fb2 (patch)
tree93523dc27d562b757a8ce81c9fea1c7a9fa65f9a
parentfdo#52052 fix RTF import of page breaks on landscape pages (diff)
downloadcore-f727644ad18838a78525256623a33f864fe13fb2.tar.gz
core-f727644ad18838a78525256623a33f864fe13fb2.zip
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
-rw-r--r--cui/source/tabpages/numfmt.cxx9
-rw-r--r--sc/source/core/tool/cellform.cxx6
-rw-r--r--sc/source/ui/view/output2.cxx6
-rw-r--r--svl/inc/svl/zforlist.hxx4
-rw-r--r--svl/source/numbers/zforlist.cxx14
-rw-r--r--svl/source/numbers/zformat.cxx6
6 files changed, 28 insertions, 17 deletions
diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx
index c603726d5e31..855cc90e7d16 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 5fdd0d2f1035..93f71fbcb090 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 d4f2f7e28e14..956bf686336a 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 983cf83089f9..1cace08d22bf 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 2dbed7993c03..c5172a2972b9 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 729ea17c6171..8c30d2442390 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;