diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-15 13:55:39 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-18 13:16:23 +0200 |
commit | 7d14555ef7e867c5b1a0e195e3ef056885697c59 (patch) | |
tree | af39963caf1328d41756e4463a2a39019448026d /editeng | |
parent | 0083b33650c2f584ceff6eeaf9ef6993bfe0ae9b (diff) |
convert SvxDateFormat to scoped enum
And simplify the code in sd/headerfooterdlg, no
need for the complex encoding of date and time when we
can just index into a static array.
Change-Id: I677400bf1f956c81eba665b71dbda9183b63f55c
Reviewed-on: https://gerrit.libreoffice.org/42346
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/items/flditem.cxx | 43 | ||||
-rw-r--r-- | editeng/source/uno/unofield.cxx | 7 |
2 files changed, 25 insertions, 25 deletions
diff --git a/editeng/source/items/flditem.cxx b/editeng/source/items/flditem.cxx index 50061b0d4bef..f69fcf4fbb12 100644 --- a/editeng/source/items/flditem.cxx +++ b/editeng/source/items/flditem.cxx @@ -71,7 +71,8 @@ SvxFieldData* SvxFieldData::Create(const uno::Reference<text::XTextContent>& xTe SvxDateField* pData = new SvxDateField(aDate, bIsFixed ? SvxDateType::Fix : SvxDateType::Var); sal_Int32 nNumFmt = -1; xPropSet->getPropertyValue(UNO_TC_PROP_NUMFORMAT) >>= nNumFmt; - if (nNumFmt >= SVXDATEFORMAT_APPDEFAULT && nNumFmt <= SVXDATEFORMAT_F) + if (static_cast<SvxDateFormat>(nNumFmt) >= SvxDateFormat::AppDefault && + static_cast<SvxDateFormat>(nNumFmt) <= SvxDateFormat::F) pData->SetFormat(static_cast<SvxDateFormat>(nNumFmt)); return pData; @@ -314,7 +315,7 @@ SvxDateField::SvxDateField() { nFixDate = Date( Date::SYSTEM ).GetDate(); eType = SvxDateType::Var; - eFormat = SVXDATEFORMAT_STDSMALL; + eFormat = SvxDateFormat::StdSmall; } @@ -358,50 +359,50 @@ OUString SvxDateField::GetFormatted( SvNumberFormatter& rFormatter, LanguageType OUString SvxDateField::GetFormatted( Date const & aDate, SvxDateFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLang ) { - if ( eFormat == SVXDATEFORMAT_SYSTEM ) + if ( eFormat == SvxDateFormat::System ) { - OSL_FAIL( "SVXDATEFORMAT_SYSTEM not implemented!" ); - eFormat = SVXDATEFORMAT_STDSMALL; + OSL_FAIL( "SvxDateFormat::System not implemented!" ); + eFormat = SvxDateFormat::StdSmall; } - else if ( eFormat == SVXDATEFORMAT_APPDEFAULT ) + else if ( eFormat == SvxDateFormat::AppDefault ) { - OSL_FAIL( "SVXDATEFORMAT_APPDEFAULT: take them from where? "); - eFormat = SVXDATEFORMAT_STDSMALL; + OSL_FAIL( "SvxDateFormat::AppDefault: take them from where? "); + eFormat = SvxDateFormat::StdSmall; } sal_uInt32 nFormatKey; switch( eFormat ) { - case SVXDATEFORMAT_STDSMALL: + case SvxDateFormat::StdSmall: // short nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYSTEM_SHORT, eLang ); break; - case SVXDATEFORMAT_STDBIG: + case SvxDateFormat::StdBig: // long nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYSTEM_LONG, eLang ); break; - case SVXDATEFORMAT_A: + case SvxDateFormat::A: // 13.02.96 nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DDMMYY, eLang ); break; - case SVXDATEFORMAT_B: + case SvxDateFormat::B: // 13.02.1996 nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DDMMYYYY, eLang ); break; - case SVXDATEFORMAT_C: + case SvxDateFormat::C: // 13. Feb 1996 nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DMMMYYYY, eLang ); break; - case SVXDATEFORMAT_D: + case SvxDateFormat::D: // 13. February 1996 nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DMMMMYYYY, eLang ); break; - case SVXDATEFORMAT_E: + case SvxDateFormat::E: // The, 13. February 1996 nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_NNDMMMMYYYY, eLang ); break; - case SVXDATEFORMAT_F: + case SvxDateFormat::F: // Tuesday, 13. February 1996 nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_NNNNDMMMMYYYY, eLang ); break; @@ -925,19 +926,17 @@ bool SvxDateTimeField::operator==( const SvxFieldData& rCmp ) const SvxDateTimeField::SvxDateTimeField() {} OUString SvxDateTimeField::GetFormatted( - Date const & rDate, tools::Time const & rTime, int eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage ) + Date const & rDate, tools::Time const & rTime, + SvxDateFormat eDateFormat, SvxTimeFormat eTimeFormat, + SvNumberFormatter& rFormatter, LanguageType eLanguage ) { OUString aRet; - SvxDateFormat eDateFormat = (SvxDateFormat)(eFormat & 0x0f); - - if(eDateFormat) + if(eDateFormat != SvxDateFormat::AppDefault) { aRet = SvxDateField::GetFormatted( rDate, eDateFormat, rFormatter, eLanguage ); } - SvxTimeFormat eTimeFormat = (SvxTimeFormat)((eFormat >> 4) & 0x0f); - if(eTimeFormat != SvxTimeFormat::AppDefault) { OUStringBuffer aBuf(aRet); diff --git a/editeng/source/uno/unofield.cxx b/editeng/source/uno/unofield.cxx index 194781fc9a95..5c57179ac3c9 100644 --- a/editeng/source/uno/unofield.cxx +++ b/editeng/source/uno/unofield.cxx @@ -251,7 +251,7 @@ SvxUnoTextField::SvxUnoTextField( sal_Int32 nServiceId ) throw() { case text::textfield::Type::DATE: mpImpl->mbBoolean2 = true; - mpImpl->mnInt32 = SVXDATEFORMAT_STDSMALL; + mpImpl->mnInt32 = static_cast<sal_Int32>(SvxDateFormat::StdSmall); mpImpl->mbBoolean1 = false; break; @@ -319,7 +319,7 @@ SvxUnoTextField::SvxUnoTextField( uno::Reference< text::XTextRange > const & xAn mpImpl->maDateTime = getDate( bFixed ? static_cast<const SvxDateField*>(pData)->GetFixDate() : Date( Date::SYSTEM ).GetDate() ); - mpImpl->mnInt32 = static_cast<const SvxDateField*>(pData)->GetFormat(); + mpImpl->mnInt32 = static_cast<sal_Int32>(static_cast<const SvxDateField*>(pData)->GetFormat()); mpImpl->mbBoolean1 = bFixed; } break; @@ -392,7 +392,8 @@ SvxFieldData* SvxUnoTextField::CreateFieldData() const throw() { Date aDate( setDate( mpImpl->maDateTime ) ); pData = new SvxDateField( aDate, mpImpl->mbBoolean1?SvxDateType::Fix:SvxDateType::Var ); - if( mpImpl->mnInt32 >= SVXDATEFORMAT_APPDEFAULT && mpImpl->mnInt32 <= SVXDATEFORMAT_F ) + if( mpImpl->mnInt32 >= static_cast<sal_Int32>(SvxDateFormat::AppDefault) && + mpImpl->mnInt32 <= static_cast<sal_Int32>(SvxDateFormat::F) ) static_cast<SvxDateField*>(pData)->SetFormat( (SvxDateFormat)mpImpl->mnInt32 ); } else |