summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cui/source/inc/numfmt.hxx3
-rw-r--r--cui/source/tabpages/numfmt.cxx51
-rw-r--r--svl/inc/svl/zforlist.hxx3
-rw-r--r--svl/source/numbers/zforlist.cxx11
-rw-r--r--svx/inc/svx/numfmtsh.hxx4
-rw-r--r--svx/source/items/numfmtsh.cxx12
6 files changed, 69 insertions, 15 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;
diff --git a/svl/inc/svl/zforlist.hxx b/svl/inc/svl/zforlist.hxx
index 7ac39d6d66d7..983cf83089f9 100644
--- a/svl/inc/svl/zforlist.hxx
+++ b/svl/inc/svl/zforlist.hxx
@@ -513,7 +513,8 @@ public:
*/
bool GetPreviewString( const String& sFormatString, double fPreviewNumber,
String& sOutString, Color** ppColor,
- LanguageType eLnge = LANGUAGE_DONTKNOW );
+ LanguageType eLnge = LANGUAGE_DONTKNOW,
+ bool bUseStarFormat = false );
/** Same as <method>GetPreviewString</method> but the format code string
may be either language/country eLnge or en_US english US */
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index cbaed9420b1d..2dbed7993c03 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -1510,7 +1510,8 @@ bool SvNumberFormatter::GetPreviewString(const String& sFormatString,
double fPreviewNumber,
String& sOutString,
Color** ppColor,
- LanguageType eLnge)
+ LanguageType eLnge,
+ bool bUseStarFormat )
{
if (sFormatString.Len() == 0) // no empty string
return false;
@@ -1532,9 +1533,15 @@ bool SvNumberFormatter::GetPreviewString(const String& sFormatString,
sal_uInt32 CLOffset = ImpGenerateCL(eLnge); // create new standard formats if necessary
nKey = ImpIsEntry(p_Entry->GetFormatstring(),CLOffset, eLnge);
if (nKey != NUMBERFORMAT_ENTRY_NOT_FOUND) // already present
- GetOutputString(fPreviewNumber,nKey,sOutString,ppColor);
+ GetOutputString(fPreviewNumber,nKey,sOutString,ppColor, bUseStarFormat);
else
+ {
+ if ( bUseStarFormat )
+ p_Entry->SetStarFormatSupport( true );
p_Entry->GetOutputString(fPreviewNumber,sOutString, ppColor);
+ if ( bUseStarFormat )
+ p_Entry->SetStarFormatSupport( false );
+ }
delete p_Entry;
return true;
}
diff --git a/svx/inc/svx/numfmtsh.hxx b/svx/inc/svx/numfmtsh.hxx
index d131e9fb7511..ad640d52f14c 100644
--- a/svx/inc/svx/numfmtsh.hxx
+++ b/svx/inc/svx/numfmtsh.hxx
@@ -185,6 +185,8 @@ public:
bool IsInTable(sal_uInt16 nPos, bool bTmpBanking,
::rtl::OUString const& rFmtString);
+ void SetUseStarFormat( bool bUse ) { bUseStarFormat = bUse; }
+ bool IsUseStarFormat( void ) { return bUseStarFormat; }
private:
static const double DEFAULT_NUMVALUE;
@@ -206,7 +208,7 @@ private:
bool bBankingSymbol;
sal_uInt16 nCurCurrencyEntryPos;
std::vector<String*> aCurrencyFormatList;
-
+ bool bUseStarFormat;
#ifdef _SVX_NUMFMTSH_CXX
SVX_DLLPRIVATE short FillEntryList_Impl( std::vector<String*>& rList );
SVX_DLLPRIVATE void FillEListWithStd_Impl( std::vector<String*>& rList,sal_uInt16 aPrivCat, short &Pos);
diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx
index 896d88e953b9..48ca710362ea 100644
--- a/svx/source/items/numfmtsh.cxx
+++ b/svx/source/items/numfmtsh.cxx
@@ -84,7 +84,8 @@ SvxNumberFormatShell::SvxNumberFormatShell( SvNumberFormatter* pNumFormatter,
nCurFormatKey ( nFormatKey ),
pCurCurrencyEntry(NULL),
bBankingSymbol (false),
- nCurCurrencyEntryPos((sal_uInt16) SELPOS_NONE)
+ nCurCurrencyEntryPos((sal_uInt16) SELPOS_NONE),
+ bUseStarFormat (false)
{
nValNum = DEFAULT_NUMVALUE;
@@ -115,7 +116,8 @@ SvxNumberFormatShell::SvxNumberFormatShell( SvNumberFormatter* pNumFormatter,
nCurFormatKey ( nFormatKey ),
pCurCurrencyEntry(NULL),
bBankingSymbol (false),
- nCurCurrencyEntryPos((sal_uInt16) SELPOS_NONE)
+ nCurCurrencyEntryPos((sal_uInt16) SELPOS_NONE),
+ bUseStarFormat (false)
{
// #50441# When used in Writer, the SvxNumberInfoItem contains the
// original string in addition to the value
@@ -439,7 +441,7 @@ void SvxNumberFormatShell::MakePreviewString( const String& rFormatStr,
// real preview - not implemented in NumberFormatter for text formats
pFormatter->GetPreviewString( rFormatStr, nValNum, rPreviewStr,
- &rpFontColor, eCurLanguage );
+ &rpFontColor, eCurLanguage, bUseStarFormat );
}
else
{
@@ -453,7 +455,7 @@ void SvxNumberFormatShell::MakePreviewString( const String& rFormatStr,
rPreviewStr, &rpFontColor );
else
pFormatter->GetOutputString( nValNum, nExistingFormat,
- rPreviewStr, &rpFontColor );
+ rPreviewStr, &rpFontColor, bUseStarFormat );
}
}
@@ -1152,7 +1154,7 @@ void SvxNumberFormatShell::GetPreviewString_Impl( String& rString, Color*& rpCol
if ( bUseText )
pFormatter->GetOutputString( aValStr, nCurFormatKey, rString, &rpColor );
else
- pFormatter->GetOutputString( nValNum, nCurFormatKey, rString, &rpColor );
+ pFormatter->GetOutputString( nValNum, nCurFormatKey, rString, &rpColor, bUseStarFormat );
}
// -----------------------------------------------------------------------