diff options
author | Noel Power <noel.power@novell.com> | 2012-08-03 14:24:00 +0100 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2012-08-03 14:25:47 +0100 |
commit | 52dff376587c2e072048d9b99748cd46336a48ba (patch) | |
tree | 75a0c652eee2dfcc7d027b516b7e7b9c3333dcfd /cui | |
parent | cc51389c07f880d513f94b9c4c1bad449435b406 (diff) |
enable preview for 'special' '*' formats
Change-Id: I2f94c3d8d827ecabc6dd5e685bb40954fe2427c4
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/inc/numfmt.hxx | 3 | ||||
-rw-r--r-- | cui/source/tabpages/numfmt.cxx | 51 |
2 files changed, 48 insertions, 6 deletions
diff --git a/cui/source/inc/numfmt.hxx b/cui/source/inc/numfmt.hxx index 3a9e0272ca3a..c2bde83c3ddb 100644 --- a/cui/source/inc/numfmt.hxx +++ b/cui/source/inc/numfmt.hxx @@ -55,7 +55,8 @@ class SvxNumberPreviewImpl : public Window private: String aPrevStr; Color aPrevCol; - + sal_Int32 mnPos; + sal_Unicode mnChar; void InitSettings( sal_Bool bForeground, sal_Bool bBackground ); protected: diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx index 94ed697894b4..c603726d5e31 100644 --- a/cui/source/tabpages/numfmt.cxx +++ b/cui/source/tabpages/numfmt.cxx @@ -50,6 +50,11 @@ #include <sfx2/basedlgs.hxx> #include "svx/flagsdef.hxx" #include <vector> +#include <com/sun/star/lang/XServiceInfo.hpp> + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::lang::XServiceInfo; +using ::com::sun::star::uno::UNO_QUERY; #define NUMKEY_UNDEFINED SAL_MAX_UINT32 @@ -81,8 +86,9 @@ static sal_uInt16 pRanges[] = SvxNumberPreviewImpl::SvxNumberPreviewImpl( Window* pParent, const ResId& rResId ) : - Window( pParent, rResId ) - + Window( pParent, rResId ), + mnPos( STRING_NOTFOUND ), + mnChar( 0x0 ) { Font aFont( GetFont() ); aFont.SetTransparent( sal_True ); @@ -121,7 +127,16 @@ SvxNumberPreviewImpl::~SvxNumberPreviewImpl() void SvxNumberPreviewImpl::NotifyChange( const String& rPrevStr, const Color* pColor ) { + // detect and strip out '*' related placeholders aPrevStr = rPrevStr; + mnPos = aPrevStr.Search( 0x1B ); + if ( mnPos != STRING_NOTFOUND ) + { + --mnPos; + mnChar = aPrevStr.GetChar( mnPos ); + // delete placeholder and char to repeat + aPrevStr.Erase( mnPos, 2 ); + } svtools::ColorConfig aColorConfig; Color aWindowTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ); aPrevCol = pColor ? *pColor : aWindowTextColor; @@ -144,12 +159,26 @@ void SvxNumberPreviewImpl::Paint( const Rectangle& ) { Font aDrawFont = GetFont(); Size aSzWnd = GetOutputSizePixel(); - Point aPosText = Point( (aSzWnd.Width() - GetTextWidth( aPrevStr )) /2, - (aSzWnd.Height() - GetTextHeight())/2 ); + String aTmpStr( aPrevStr ); + long nLeadSpace = (aSzWnd.Width() - GetTextWidth( aTmpStr )) /2; aDrawFont.SetColor( aPrevCol ); SetFont( aDrawFont ); - DrawText( aPosText, aPrevStr ); + + if ( mnPos != STRING_NOTFOUND ) + { + long nCharWidth = GetTextWidth( rtl::OUString::valueOf( mnChar ) ); + int nNumCharsToInsert = nLeadSpace / nCharWidth; + + if ( nNumCharsToInsert ) + { + for ( int i = 0; i < nNumCharsToInsert; ++i ) + aTmpStr.Insert( mnChar, mnPos ); + } + } + Point aPosText = Point( ( mnPos != STRING_NOTFOUND ) ? 0 : nLeadSpace, + (aSzWnd.Height() - GetTextHeight())/2 ); + DrawText( aPosText, aTmpStr ); } // ----------------------------------------------------------------------- @@ -522,6 +551,18 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet& rSet ) nValDouble, &aValString ); + + bool bUseStarFormat = false; + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + if ( pDocSh ) + { + // is this a calc document + Reference< XServiceInfo > xSI( pDocSh->GetModel(), UNO_QUERY ); + if ( xSI.is() ) + bUseStarFormat = xSI->supportsService( rtl::OUString( "com.sun.star.sheet.SpreadsheetDocument" ) ); + } + pNumFmtShell->SetUseStarFormat( bUseStarFormat ); + FillCurrencyBox(); String aPrevString; |