[Libreoffice-commits] .: 2 commits - cui/source svl/inc svl/source svx/inc svx/source xmloff/inc xmloff/source
Noel Power
noelp at kemper.freedesktop.org
Fri Aug 3 06:25:55 PDT 2012
cui/source/inc/numfmt.hxx | 3 +-
cui/source/tabpages/numfmt.cxx | 51 +++++++++++++++++++++++++++++++++++----
svl/inc/svl/zforlist.hxx | 3 +-
svl/source/numbers/zforlist.cxx | 11 ++++++--
svx/inc/svx/numfmtsh.hxx | 4 ++-
svx/source/items/numfmtsh.cxx | 12 +++++----
xmloff/inc/xmloff/xmlnumfe.hxx | 1
xmloff/inc/xmloff/xmltoken.hxx | 1
xmloff/source/core/xmltoken.cxx | 1
xmloff/source/style/xmlnumfe.cxx | 16 ++++++++++++
xmloff/source/style/xmlnumfi.cxx | 10 +++++++
11 files changed, 98 insertions(+), 15 deletions(-)
New commits:
commit 52dff376587c2e072048d9b99748cd46336a48ba
Author: Noel Power <noel.power at novell.com>
Date: Fri Aug 3 14:24:00 2012 +0100
enable preview for 'special' '*' formats
Change-Id: I2f94c3d8d827ecabc6dd5e685bb40954fe2427c4
diff --git a/cui/source/inc/numfmt.hxx b/cui/source/inc/numfmt.hxx
index 3a9e027..c2bde83 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 94ed697..c603726 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 7ac39d6..983cf83 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 cbaed94..2dbed79 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 d131e9f..ad640d5 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 896d88e..48ca710 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 );
}
// -----------------------------------------------------------------------
commit cc51389c07f880d513f94b9c4c1bad449435b406
Author: Noel Power <noel.power at novell.com>
Date: Fri Aug 3 13:06:25 2012 +0100
support new xml number:fill-character elem for number-style namespace
Change-Id: I7d3ca1f121396dfc017bb1ee73651f9017e58ba3
diff --git a/xmloff/inc/xmloff/xmlnumfe.hxx b/xmloff/inc/xmloff/xmlnumfe.hxx
index 7dcef8f..d3bac9b 100644
--- a/xmloff/inc/xmloff/xmlnumfe.hxx
+++ b/xmloff/inc/xmloff/xmlnumfe.hxx
@@ -86,6 +86,7 @@ private:
SAL_DLLPRIVATE void WriteMapElement_Impl( sal_Int32 nOp, double fLimit,
sal_Int32 nKey, sal_Int32 nPart );
+ SAL_DLLPRIVATE void WriteRepeatedElement_Impl( sal_Unicode ch );
SAL_DLLPRIVATE sal_Bool WriteTextWithCurrency_Impl( const ::rtl::OUString& rString,
const ::com::sun::star::lang::Locale& rLocale );
SAL_DLLPRIVATE void ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt32 nKey,
diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx
index c4113ca..4ade928 100644
--- a/xmloff/inc/xmloff/xmltoken.hxx
+++ b/xmloff/inc/xmloff/xmltoken.hxx
@@ -744,6 +744,7 @@ namespace xmloff { namespace token {
XML_FIELD_NUMBER,
XML_FILE_NAME,
XML_FILL,
+ XML_FILL_CHARACTER,
XML_FILL_COLOR,
XML_FILL_GRADIENT_NAME,
XML_FILL_HATCH_NAME,
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index f7d8f28..cbbd48b 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -748,6 +748,7 @@ namespace xmloff { namespace token {
TOKEN( "field-number", XML_FIELD_NUMBER ),
TOKEN( "file-name", XML_FILE_NAME ),
TOKEN( "fill", XML_FILL ),
+ TOKEN( "fill-character", XML_FILL_CHARACTER ),
TOKEN( "fill-color", XML_FILL_COLOR ),
TOKEN( "fill-gradient-name", XML_FILL_GRADIENT_NAME ),
TOKEN( "fill-hatch-name", XML_FILL_HATCH_NAME ),
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index 9ff20ea..d11e5ee 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -533,6 +533,14 @@ void SvXMLNumFmtExport::WriteMinutesElement_Impl( sal_Bool bLong )
sal_True, sal_False );
}
+void SvXMLNumFmtExport::WriteRepeatedElement_Impl( sal_Unicode nChar )
+{
+ FinishTextElement_Impl();
+ SvXMLElementExport aElem( rExport, XML_NAMESPACE_NUMBER, XML_FILL_CHARACTER,
+ sal_True, sal_False );
+ rExport.Characters( OUString::valueOf( nChar ) );
+}
+
void SvXMLNumFmtExport::WriteSecondsElement_Impl( sal_Bool bLong, sal_uInt16 nDecimals )
{
FinishTextElement_Impl();
@@ -1563,6 +1571,14 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
WriteAMPMElement_Impl(); // short/long?
bAnyContent = sal_True;
break;
+ case NF_SYMBOLTYPE_STAR :
+ // export only if ODF 1.2 extensions are enabled
+ if( SvtSaveOptions().GetODFDefaultVersion() > SvtSaveOptions::ODFVER_012 )
+ {
+ if ( pElemStr && pElemStr->Len() > 1 )
+ WriteRepeatedElement_Impl( pElemStr->GetChar( 1 ) );
+ }
+ break;
}
nPrevType = nElemType;
++nPos;
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index 7221f2a..6d4994a 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -248,6 +248,7 @@ public:
enum SvXMLStyleTokens
{
XML_TOK_STYLE_TEXT,
+ XML_TOK_STYLE_FILL_CHARACTER,
XML_TOK_STYLE_NUMBER,
XML_TOK_STYLE_SCIENTIFIC_NUMBER,
XML_TOK_STYLE_FRACTION,
@@ -518,6 +519,7 @@ const SvXMLTokenMap& SvXMLNumImpData::GetStyleElemTokenMap()
{
// elements in a style
{ XML_NAMESPACE_NUMBER, XML_TEXT, XML_TOK_STYLE_TEXT },
+ { XML_NAMESPACE_NUMBER, XML_FILL_CHARACTER, XML_TOK_STYLE_FILL_CHARACTER },
{ XML_NAMESPACE_NUMBER, XML_NUMBER, XML_TOK_STYLE_NUMBER },
{ XML_NAMESPACE_NUMBER, XML_SCIENTIFIC_NUMBER, XML_TOK_STYLE_SCIENTIFIC_NUMBER },
{ XML_NAMESPACE_NUMBER, XML_FRACTION, XML_TOK_STYLE_FRACTION },
@@ -1100,6 +1102,13 @@ void SvXMLNumFmtElementContext::EndElement()
case XML_TOK_STYLE_TEXT_CONTENT:
rParent.AddToCode( OUString::valueOf((sal_Unicode)'@') );
break;
+ case XML_TOK_STYLE_FILL_CHARACTER:
+ if ( aContent.getLength() )
+ {
+ rParent.AddToCode( OUString::valueOf((sal_Unicode)'*') );
+ rParent.AddToCode( OUString::valueOf( aContent[0] ) );
+ }
+ break;
case XML_TOK_STYLE_BOOLEAN:
// ignored - only default boolean format is supported
break;
@@ -1432,6 +1441,7 @@ SvXMLImportContext* SvXMLNumFormatContext::CreateChildContext(
switch (nToken)
{
case XML_TOK_STYLE_TEXT:
+ case XML_TOK_STYLE_FILL_CHARACTER:
case XML_TOK_STYLE_NUMBER:
case XML_TOK_STYLE_SCIENTIFIC_NUMBER:
case XML_TOK_STYLE_FRACTION:
More information about the Libreoffice-commits
mailing list