diff options
author | Noel Power <noel.power@novell.com> | 2012-04-16 16:20:51 +0100 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2012-04-17 14:30:32 +0100 |
commit | 46e18bc915ac94a81462642cc9d56d29c04d0c46 (patch) | |
tree | a68c3816ffabb574ac91b21929a8606911c3a5ef /sc | |
parent | f39d0b837742c69488e43e919f7f1a927c2859ed (diff) |
enable '*' repeat next char to fill available width for calc num formats
but - however no support to import/export this to file format yet
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/cellform.hxx | 4 | ||||
-rw-r--r-- | sc/source/core/tool/cellform.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/view/output2.cxx | 43 |
3 files changed, 46 insertions, 6 deletions
diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx index cdfa09cc6599..3a5418d5a12d 100644 --- a/sc/inc/cellform.hxx +++ b/sc/inc/cellform.hxx @@ -53,7 +53,9 @@ public: Color** ppColor, SvNumberFormatter& rFormatter, sal_Bool bNullVals = sal_True, sal_Bool bFormula = false, - ScForceTextFmt eForceTextFmt = ftDontForce ); + ScForceTextFmt eForceTextFmt = ftDontForce, + bool bUseStarFormat = false ); + static void GetInputString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUString& rString, SvNumberFormatter& rFormatter ); diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx index f33a48c23363..0da68661d191 100644 --- a/sc/source/core/tool/cellform.cxx +++ b/sc/source/core/tool/cellform.cxx @@ -49,7 +49,8 @@ void ScCellFormat::GetString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUStrin Color** ppColor, SvNumberFormatter& rFormatter, sal_Bool bNullVals, sal_Bool bFormula, - ScForceTextFmt eForceTextFmt ) + ScForceTextFmt eForceTextFmt, + bool bUseStarFormat ) { *ppColor = NULL; if (&rFormatter==NULL) @@ -92,7 +93,7 @@ void ScCellFormat::GetString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUStrin rFormatter.GetOutputString( aTemp, nFormat, rString, ppColor ); } else - rFormatter.GetOutputString( nValue, nFormat, rString, ppColor ); + rFormatter.GetOutputString( nValue, nFormat, rString, ppColor, bUseStarFormat ); } } break; diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 2b99bb80c277..6c616eb3a056 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -128,6 +128,8 @@ class ScDrawStringsVars Color aBackConfigColor; // used for ScPatternAttr::GetFont calls Color aTextConfigColor; + sal_Int32 nPos; + sal_Unicode nChar; public: ScDrawStringsVars(ScOutputData* pData, sal_Bool bPTL); @@ -162,6 +164,7 @@ public: sal_Bool GetLineBreak() const { return bLineBreak; } sal_Bool IsRepeat() const { return bRepeat; } sal_Bool IsShrink() const { return bShrink; } + void RepeatToFill( long colWidth ); long GetAscent() const { return nAscentPixel; } sal_Bool IsRotated() const { return bRotated; } @@ -206,7 +209,9 @@ ScDrawStringsVars::ScDrawStringsVars(ScOutputData* pData, sal_Bool bPTL) : bLineBreak ( false ), bRepeat ( false ), bShrink ( false ), - bPixelToLogic( bPTL ) + bPixelToLogic( bPTL ), + nPos( STRING_NOTFOUND ), + nChar( 0x0 ) { ScModule* pScMod = SC_MOD(); bCellContrast = pOutput->bUseStyleColor && @@ -502,9 +507,19 @@ sal_Bool ScDrawStringsVars::SetText( ScBaseCell* pCell ) *pOutput->pDoc->GetFormatTable(), pOutput->bShowNullValues, pOutput->bShowFormulas, - ftCheck ); + ftCheck, true ); aString = aOUString; - + if ( nFormat ) + { + nPos = aString.Search( 0x1B ); + if ( nPos != STRING_NOTFOUND ) + { + nPos = nPos - 1; + nChar = aString.GetChar( nPos ); + // delete placeholder and char to repeat + aString.Erase( nPos, 2 ); + } + } if (aString.Len() > DRAWTEXT_MAX) aString.Erase(DRAWTEXT_MAX); @@ -537,6 +552,27 @@ void ScDrawStringsVars::SetHashText() SetAutoText( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("###")) ); } +void ScDrawStringsVars::RepeatToFill( long colWidth ) +{ + if ( nPos == STRING_NOTFOUND || nPos >= aString.Len() ) + return; + + long charWidth = pOutput->pFmtDevice->GetTextWidth(String(nChar)); + if (bPixelToLogic) + colWidth = pOutput->pRefDevice->PixelToLogic(Size(colWidth,0)).Width(); + // Are there restrictions on the cell type we should filter out here ? + long aSpaceToFill = ( colWidth - aTextSize.Width() ); + + if ( aSpaceToFill <= charWidth ) + return; + + long nCharsToInsert = aSpaceToFill / charWidth; + for ( int i = 0; i < nCharsToInsert; ++i ) + aString.Insert( nChar, nPos ); + + TextChanged(); +} + void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) { // #i113045# do the single-character width calculations in logic units @@ -1618,6 +1654,7 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic ) bCellIsValue || bRepeat || bShrink, bBreak, false, aAreaParam ); + aVars.RepeatToFill( aAreaParam.mnColWidth - nTotalMargin ); if ( bShrink ) { if ( aVars.GetOrient() != SVX_ORIENTATION_STANDARD ) |