[Libreoffice-commits] core.git: editeng/source filter/source include/editeng oox/source sc/source sd/inc sd/source
Noel Grandin
noel.grandin at collabora.co.uk
Mon Sep 18 11:16:49 UTC 2017
editeng/source/items/flditem.cxx | 43 +++++++++-----------
editeng/source/uno/unofield.cxx | 7 +--
filter/source/msfilter/svdfppt.cxx | 16 +++----
filter/source/svg/svgexport.cxx | 74 +++++++++++++++++------------------
filter/source/svg/svgfilter.hxx | 5 +-
include/editeng/flditem.hxx | 29 +++++++------
oox/source/export/drawingml.cxx | 13 +++---
sc/source/ui/unoobj/fielduno.cxx | 2
sd/inc/sdpage.hxx | 4 +
sd/source/core/sdpage.cxx | 6 +-
sd/source/filter/eppt/eppt.cxx | 8 +--
sd/source/filter/ppt/pptin.cxx | 3 -
sd/source/ui/app/sdmod2.cxx | 3 -
sd/source/ui/app/sdpopup.cxx | 16 +++----
sd/source/ui/dlg/dlgfield.cxx | 18 ++++----
sd/source/ui/dlg/headerfooterdlg.cxx | 56 ++++++++++++++------------
sd/source/ui/unoidl/unomodel.cxx | 4 +
sd/source/ui/unoidl/unopage.cxx | 9 +++-
18 files changed, 171 insertions(+), 145 deletions(-)
New commits:
commit 7d14555ef7e867c5b1a0e195e3ef056885697c59
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Fri Sep 15 13:55:39 2017 +0200
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 at collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>
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
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 1678fbf0efec..f39a726413e0 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -6409,34 +6409,34 @@ PPTFieldEntry::~PPTFieldEntry()
void PPTFieldEntry::GetDateTime( const sal_uInt32 nVal, SvxDateFormat& eDateFormat, SvxTimeFormat& eTimeFormat )
{
- eDateFormat = SVXDATEFORMAT_APPDEFAULT;
+ eDateFormat = SvxDateFormat::AppDefault;
eTimeFormat = SvxTimeFormat::AppDefault;
// evaluate ID
switch( nVal )
{
case 0:
case 6:
- eDateFormat = SVXDATEFORMAT_A;
+ eDateFormat = SvxDateFormat::A;
break;
case 1:
- eDateFormat = SVXDATEFORMAT_F;
+ eDateFormat = SvxDateFormat::F;
break;
case 2:
case 3:
- eDateFormat = SVXDATEFORMAT_D;
+ eDateFormat = SvxDateFormat::D;
break;
case 4:
case 5:
- eDateFormat = SVXDATEFORMAT_C;
+ eDateFormat = SvxDateFormat::C;
break;
case 7:
- eDateFormat = SVXDATEFORMAT_A;
+ eDateFormat = SvxDateFormat::A;
SAL_FALLTHROUGH;
case 9:
eTimeFormat = SvxTimeFormat::HH24_MM;
break;
case 8:
- eDateFormat = SVXDATEFORMAT_A;
+ eDateFormat = SvxDateFormat::A;
SAL_FALLTHROUGH;
case 11:
eTimeFormat = SvxTimeFormat::HH12_MM;
@@ -6455,7 +6455,7 @@ void PPTFieldEntry::SetDateTime( sal_uInt32 nVal )
SvxDateFormat eDateFormat;
SvxTimeFormat eTimeFormat;
GetDateTime( nVal, eDateFormat, eTimeFormat );
- if ( eDateFormat != SVXDATEFORMAT_APPDEFAULT )
+ if ( eDateFormat != SvxDateFormat::AppDefault )
xField1.reset(new SvxFieldItem(SvxDateField( Date( Date::SYSTEM ), SvxDateType::Var, eDateFormat ), EE_FEATURE_FIELD));
if ( eTimeFormat != SvxTimeFormat::AppDefault )
{
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index c50cddde7d16..d2b42b94719a 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -221,29 +221,29 @@ public:
VariableTextField::elementExport( pSVGExport );
OUString sDateFormat, sTimeFormat;
SvxDateFormat eDateFormat = (SvxDateFormat)( format & 0x0f );
- if( eDateFormat )
+ if( eDateFormat != SvxDateFormat::AppDefault )
{
switch( eDateFormat )
{
- case SVXDATEFORMAT_STDSMALL:
- case SVXDATEFORMAT_A: // 13.02.96
+ case SvxDateFormat::StdSmall:
+ case SvxDateFormat::A: // 13.02.96
sDateFormat.clear();
break;
- case SVXDATEFORMAT_C: // 13.Feb 1996
+ case SvxDateFormat::C: // 13.Feb 1996
sDateFormat.clear();
break;
- case SVXDATEFORMAT_D: // 13.February 1996
+ case SvxDateFormat::D: // 13.February 1996
sDateFormat.clear();
break;
- case SVXDATEFORMAT_E: // Tue, 13.February 1996
+ case SvxDateFormat::E: // Tue, 13.February 1996
sDateFormat.clear();
break;
- case SVXDATEFORMAT_STDBIG:
- case SVXDATEFORMAT_F: // Tuesday, 13.February 1996
+ case SvxDateFormat::StdBig:
+ case SvxDateFormat::F: // Tuesday, 13.February 1996
sDateFormat.clear();
break;
// default case
- case SVXDATEFORMAT_B: // 13.02.1996
+ case SvxDateFormat::B: // 13.02.1996
default:
sDateFormat.clear();
break;
@@ -1359,7 +1359,7 @@ void SVGFilter::implGetPagePropSet( const Reference< XDrawPage > & rxPage )
mVisiblePagePropSet.bIsFooterFieldVisible = true;
mVisiblePagePropSet.bIsDateTimeFieldVisible = true;
mVisiblePagePropSet.bIsDateTimeFieldFixed = true;
- mVisiblePagePropSet.nDateTimeFormat = SVXDATEFORMAT_B;
+ mVisiblePagePropSet.nDateTimeFormat = SvxDateFormat::B;
mVisiblePagePropSet.nPageNumberingType = css::style::NumberingType::ARABIC;
// We collect info on master page elements visibility, and placeholder text shape content.
@@ -1377,7 +1377,9 @@ void SVGFilter::implGetPagePropSet( const Reference< XDrawPage > & rxPage )
implSafeGetPagePropSet( "IsDateTimeVisible", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bIsDateTimeFieldVisible;
implSafeGetPagePropSet( "IsDateTimeFixed", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.bIsDateTimeFieldFixed;
- implSafeGetPagePropSet( "DateTimeFormat", xPropSet, xPropSetInfo ) >>= mVisiblePagePropSet.nDateTimeFormat;
+ sal_Int32 nTmp;
+ if (implSafeGetPagePropSet( "DateTimeFormat", xPropSet, xPropSetInfo ) >>= nTmp)
+ mVisiblePagePropSet.nDateTimeFormat = static_cast<SvxDateFormat>(nTmp);
if( mVisiblePagePropSet.bIsPageNumberFieldVisible )
{
@@ -2161,7 +2163,7 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo, void )
}
if( bHasCharSetMap && ( pCharSetMap->find( aVariableDateTimeId ) != pCharSetMap->end() ) && !(*pCharSetMap)[ aVariableDateTimeId ].empty() )
{
- SvxDateFormat eDateFormat = SVXDATEFORMAT_B, eCurDateFormat;
+ SvxDateFormat eDateFormat = SvxDateFormat::B, eCurDateFormat;
const UCharSet & aCharSet = (*pCharSetMap)[ aVariableDateTimeId ];
UCharSet::const_iterator aChar = aCharSet.begin();
// we look for the most verbose date format
@@ -2170,29 +2172,29 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo, void )
eCurDateFormat = (SvxDateFormat)( (int)( *aChar ) & 0x0f );
switch( eDateFormat )
{
- case SVXDATEFORMAT_STDSMALL:
- case SVXDATEFORMAT_A: // 13.02.96
- case SVXDATEFORMAT_B: // 13.02.1996
+ case SvxDateFormat::StdSmall:
+ case SvxDateFormat::A: // 13.02.96
+ case SvxDateFormat::B: // 13.02.1996
switch( eCurDateFormat )
{
- case SVXDATEFORMAT_C: // 13.Feb 1996
- case SVXDATEFORMAT_D: // 13.February 1996
- case SVXDATEFORMAT_E: // Tue, 13.February 1996
- case SVXDATEFORMAT_STDBIG:
- case SVXDATEFORMAT_F: // Tuesday, 13.February 1996
+ case SvxDateFormat::C: // 13.Feb 1996
+ case SvxDateFormat::D: // 13.February 1996
+ case SvxDateFormat::E: // Tue, 13.February 1996
+ case SvxDateFormat::StdBig:
+ case SvxDateFormat::F: // Tuesday, 13.February 1996
eDateFormat = eCurDateFormat;
break;
default:
break;
}
break;
- case SVXDATEFORMAT_C: // 13.Feb 1996
- case SVXDATEFORMAT_D: // 13.February 1996
+ case SvxDateFormat::C: // 13.Feb 1996
+ case SvxDateFormat::D: // 13.February 1996
switch( eCurDateFormat )
{
- case SVXDATEFORMAT_E: // Tue, 13.February 1996
- case SVXDATEFORMAT_STDBIG:
- case SVXDATEFORMAT_F: // Tuesday, 13.February 1996
+ case SvxDateFormat::E: // Tue, 13.February 1996
+ case SvxDateFormat::StdBig:
+ case SvxDateFormat::F: // Tuesday, 13.February 1996
eDateFormat = eCurDateFormat;
break;
default:
@@ -2207,28 +2209,28 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo, void )
// They should be enough to cover every time format.
aRepresentation += "0123456789.:/-APM";
- if( eDateFormat )
+ if( eDateFormat != SvxDateFormat::AppDefault )
{
OUString sDate;
LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
SvNumberFormatter * pNumberFormatter = new SvNumberFormatter( ::comphelper::getProcessComponentContext(), LANGUAGE_SYSTEM );
- // We always collect the characters obtained by using the SVXDATEFORMAT_B (as: 13.02.1996)
+ // We always collect the characters obtained by using the SvxDateFormat::B (as: 13.02.1996)
// so we are sure to include any unusual day|month|year separator.
Date aDate( 1, 1, 1996 );
- sDate += SvxDateField::GetFormatted( aDate, SVXDATEFORMAT_B, *pNumberFormatter, eLang );
+ sDate += SvxDateField::GetFormatted( aDate, SvxDateFormat::B, *pNumberFormatter, eLang );
switch( eDateFormat )
{
- case SVXDATEFORMAT_E: // Tue, 13.February 1996
- case SVXDATEFORMAT_STDBIG:
- case SVXDATEFORMAT_F: // Tuesday, 13.February 1996
+ case SvxDateFormat::E: // Tue, 13.February 1996
+ case SvxDateFormat::StdBig:
+ case SvxDateFormat::F: // Tuesday, 13.February 1996
for( sal_uInt16 i = 1; i <= 7; ++i ) // we get all days in a week
{
aDate.SetDay( i );
sDate += SvxDateField::GetFormatted( aDate, eDateFormat, *pNumberFormatter, eLang );
}
SAL_FALLTHROUGH; // We need months too!
- case SVXDATEFORMAT_C: // 13.Feb 1996
- case SVXDATEFORMAT_D: // 13.February 1996
+ case SvxDateFormat::C: // 13.Feb 1996
+ case SvxDateFormat::D: // 13.February 1996
for( sal_uInt16 i = 1; i <= 12; ++i ) // we get all months in a year
{
aDate.SetMonth( i );
@@ -2236,9 +2238,9 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo, void )
}
break;
// coverity[dead_error_begin] - following conditions exist to avoid compiler warning
- case SVXDATEFORMAT_STDSMALL:
- case SVXDATEFORMAT_A: // 13.02.96
- case SVXDATEFORMAT_B: // 13.02.1996
+ case SvxDateFormat::StdSmall:
+ case SvxDateFormat::A: // 13.02.96
+ case SvxDateFormat::B: // 13.02.1996
default:
// nothing to do here, we always collect the characters needed for these cases.
break;
diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx
index 1920d063f103..34b7b20a47c1 100644
--- a/filter/source/svg/svgfilter.hxx
+++ b/filter/source/svg/svgfilter.hxx
@@ -38,6 +38,7 @@
#include <basegfx/polygon/b2dpolygonclipper.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <comphelper/processfactory.hxx>
+#include <editeng/flditem.hxx>
#include <unotools/tempfile.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <unotools/streamwrap.hxx>
@@ -132,7 +133,7 @@ struct PagePropertySet
bool bIsHeaderFieldVisible;
sal_Int32 nPageNumberingType;
bool bIsDateTimeFieldFixed;
- sal_Int32 nDateTimeFormat;
+ SvxDateFormat nDateTimeFormat;
PagePropertySet()
: bIsBackgroundVisible(false)
, bAreBackgroundObjectsVisible(false)
@@ -142,7 +143,7 @@ struct PagePropertySet
, bIsHeaderFieldVisible(false)
, nPageNumberingType(0)
, bIsDateTimeFieldFixed(false)
- , nDateTimeFormat(0)
+ , nDateTimeFormat(SvxDateFormat::AppDefault)
{
}
};
diff --git a/include/editeng/flditem.hxx b/include/editeng/flditem.hxx
index addb6974493e..06424ee34418 100644
--- a/include/editeng/flditem.hxx
+++ b/include/editeng/flditem.hxx
@@ -83,17 +83,18 @@ public:
enum class SvxDateType { Fix, Var };
-enum SvxDateFormat { SVXDATEFORMAT_APPDEFAULT = 0, // Set as in App
- SVXDATEFORMAT_SYSTEM, // Set as in System
- SVXDATEFORMAT_STDSMALL,
- SVXDATEFORMAT_STDBIG,
- SVXDATEFORMAT_A, // 13.02.96
- SVXDATEFORMAT_B, // 13.02.1996
- SVXDATEFORMAT_C, // 13.Feb 1996
- SVXDATEFORMAT_D, // 13.February 1996
- SVXDATEFORMAT_E, // Tue, 13.February 1996
- SVXDATEFORMAT_F // Tuesday, 13.February 1996
- };
+enum class SvxDateFormat {
+ AppDefault = 0, // Set as in App
+ System, // Set as in System
+ StdSmall,
+ StdBig,
+ A, // 13.02.96
+ B, // 13.02.1996
+ C, // 13.Feb 1996
+ D, // 13.February 1996
+ E, // Tue, 13.February 1996
+ F // Tuesday, 13.February 1996
+};
class EDITENG_DLLPUBLIC SvxDateField : public SvxFieldData
{
@@ -107,7 +108,7 @@ public:
SvxDateField();
explicit SvxDateField( const Date& rDate,
SvxDateType eType,
- SvxDateFormat eFormat = SVXDATEFORMAT_STDSMALL );
+ SvxDateFormat eFormat = SvxDateFormat::StdSmall );
sal_Int32 GetFixDate() const { return nFixDate; }
void SetFixDate( const Date& rDate ) { nFixDate = rDate.GetDate(); }
@@ -407,7 +408,9 @@ public:
SV_DECL_PERSIST1( SvxDateTimeField, css::text::textfield::Type::PRESENTATION_DATE_TIME )
SvxDateTimeField();
- static OUString GetFormatted( Date const & rDate, tools::Time const & rTime, int eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
+ static OUString GetFormatted( Date const & rDate, tools::Time const & rTime,
+ SvxDateFormat eDateFormat, SvxTimeFormat eTimeFormat,
+ SvNumberFormatter& rFormatter, LanguageType eLanguage );
virtual SvxFieldData* Clone() const override;
virtual bool operator==( const SvxFieldData& ) const override;
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 7ca7d765ec6a..1ce02a7e2b53 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1654,16 +1654,17 @@ OUString DrawingML::GetFieldValue( const css::uno::Reference< css::text::XTextRa
{
sal_Int32 nNumFmt = -1;
rXPropSet->getPropertyValue(UNO_TC_PROP_NUMFORMAT) >>= nNumFmt;
- switch(nNumFmt)
+ switch(static_cast<SvxDateFormat>(nNumFmt))
{
- case SVXDATEFORMAT_STDSMALL:
- case SVXDATEFORMAT_A: aFieldValue = "datetime"; // 13/02/96
+ case SvxDateFormat::StdSmall:
+ case SvxDateFormat::A: aFieldValue = "datetime"; // 13/02/96
break;
- case SVXDATEFORMAT_B: aFieldValue = "datetime1"; // 13/02/1996
+ case SvxDateFormat::B: aFieldValue = "datetime1"; // 13/02/1996
break;
- case SVXDATEFORMAT_STDBIG:
- case SVXDATEFORMAT_D: aFieldValue = "datetime3"; // 13 February 1996
+ case SvxDateFormat::StdBig:
+ case SvxDateFormat::D: aFieldValue = "datetime3"; // 13 February 1996
break;
+ default: break;
}
}
else if(aFieldKind == "ExtTime")
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index 257bf8fa31df..d87bd6f1aa8d 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -947,7 +947,7 @@ uno::Any ScEditFieldObj::getPropertyValueDateTime(const OUString& rName)
}
if (rName == SC_UNONAME_NUMFMT)
- return uno::makeAny<sal_Int32>(p->GetFormat());
+ return uno::makeAny<sal_Int32>(static_cast<sal_Int32>(p->GetFormat()));
}
break;
case text::textfield::Type::TIME:
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index 800cb24d7661..9e7c178437aa 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -28,6 +28,7 @@
#include <list>
#include <memory>
#include <vector>
+#include <editeng/flditem.hxx>
#include <svx/svdobj.hxx>
#include <svx/fmpage.hxx>
#include <xmloff/autolayout.hxx>
@@ -71,7 +72,8 @@ namespace sd {
bool mbDateTimeVisible;
bool mbDateTimeIsFixed;
OUString maDateTimeText;
- int meDateTimeFormat;
+ SvxDateFormat meDateFormat;
+ SvxTimeFormat meTimeFormat;
HeaderFooterSettings();
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 9ef9fee3c543..57f11cdebf51 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -3126,7 +3126,8 @@ HeaderFooterSettings::HeaderFooterSettings()
mbSlideNumberVisible = false;
mbDateTimeVisible = true;
mbDateTimeIsFixed = true;
- meDateTimeFormat = SVXDATEFORMAT_A;
+ meDateFormat = SvxDateFormat::A;
+ meTimeFormat = SvxTimeFormat::AppDefault;
}
bool HeaderFooterSettings::operator==( const HeaderFooterSettings& rSettings ) const
@@ -3138,7 +3139,8 @@ bool HeaderFooterSettings::operator==( const HeaderFooterSettings& rSettings ) c
(mbSlideNumberVisible == rSettings.mbSlideNumberVisible) &&
(mbDateTimeVisible == rSettings.mbDateTimeVisible) &&
(mbDateTimeIsFixed == rSettings.mbDateTimeIsFixed) &&
- (meDateTimeFormat == rSettings.meDateTimeFormat) &&
+ (meDateFormat == rSettings.meDateFormat) &&
+ (meTimeFormat == rSettings.meTimeFormat) &&
(maDateTimeText == rSettings.maDateTimeText);
}
diff --git a/sd/source/filter/eppt/eppt.cxx b/sd/source/filter/eppt/eppt.cxx
index 24fad7dd7bd8..2bd1fcb2e2ae 100644
--- a/sd/source/filter/eppt/eppt.cxx
+++ b/sd/source/filter/eppt/eppt.cxx
@@ -619,17 +619,17 @@ void PPTWriter::ImplCreateHeaderFooters( css::uno::Reference< css::beans::XPrope
SvxTimeFormat eTimeFormat = (SvxTimeFormat)( ( nFormat >> 4 ) & 0xf );
switch( eDateFormat )
{
- case SVXDATEFORMAT_F :
+ case SvxDateFormat::F :
nFormat = 1;
break;
- case SVXDATEFORMAT_D :
+ case SvxDateFormat::D :
nFormat = 2;
break;
- case SVXDATEFORMAT_C :
+ case SvxDateFormat::C :
nFormat = 4;
break;
default:
- case SVXDATEFORMAT_A :
+ case SvxDateFormat::A :
nFormat = 0;
}
switch( eTimeFormat )
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index fe102637b60e..263e27deb041 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -1460,7 +1460,8 @@ void ImplSdPPTImport::SetHeaderFooterPageSettings( SdPage* pPage, const PptSlide
SvxDateFormat eDateFormat;
SvxTimeFormat eTimeFormat;
PPTFieldEntry::GetDateTime( pHFE->nAtom & 0xff, eDateFormat, eTimeFormat );
- rHeaderFooterSettings.meDateTimeFormat = eDateFormat | ( static_cast<int>(eTimeFormat) << 4 );
+ rHeaderFooterSettings.meDateFormat = eDateFormat;
+ rHeaderFooterSettings.meTimeFormat = eTimeFormat;
}
break;
case 1 :
diff --git a/sd/source/ui/app/sdmod2.cxx b/sd/source/ui/app/sdmod2.cxx
index 89f0285abca0..f7c76b3e54b1 100644
--- a/sd/source/ui/app/sdmod2.cxx
+++ b/sd/source/ui/app/sdmod2.cxx
@@ -391,7 +391,8 @@ IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo, void)
Date aDate( Date::SYSTEM );
tools::Time aTime( tools::Time::SYSTEM );
LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
- aRepresentation = SvxDateTimeField::GetFormatted( aDate, aTime, (SvxDateFormat)rSettings.meDateTimeFormat, *GetNumberFormatter(), eLang );
+ aRepresentation = SvxDateTimeField::GetFormatted( aDate, aTime,
+ rSettings.meDateFormat, rSettings.meTimeFormat, *GetNumberFormatter(), eLang );
}
}
}
diff --git a/sd/source/ui/app/sdpopup.cxx b/sd/source/ui/app/sdpopup.cxx
index 2a9f8d9615bb..19d63c06b452 100644
--- a/sd/source/ui/app/sdpopup.cxx
+++ b/sd/source/ui/app/sdpopup.cxx
@@ -65,24 +65,24 @@ void SdFieldPopup::Fill( LanguageType eLanguage )
else
CheckItem( 2 );
- //SVXDATEFORMAT_APPDEFAULT, // is not used
- //SVXDATEFORMAT_SYSTEM, // is not used
+ //SvxDateFormat::AppDefault, // is not used
+ //SvxDateFormat::System, // is not used
InsertItem( nID++, SdResId( STR_STANDARD_SMALL ), nStyle );
InsertItem( nID++, SdResId( STR_STANDARD_BIG ), nStyle );
SvNumberFormatter* pNumberFormatter = SD_MOD()->GetNumberFormatter();
- aDateField.SetFormat( SVXDATEFORMAT_A ); // 13.02.96
+ aDateField.SetFormat( SvxDateFormat::A ); // 13.02.96
InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
- aDateField.SetFormat( SVXDATEFORMAT_B ); // 13.02.1996
+ aDateField.SetFormat( SvxDateFormat::B ); // 13.02.1996
InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
- aDateField.SetFormat( SVXDATEFORMAT_C ); // 13.Feb 1996
+ aDateField.SetFormat( SvxDateFormat::C ); // 13.Feb 1996
InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
- aDateField.SetFormat( SVXDATEFORMAT_D ); // 13.Februar 1996
+ aDateField.SetFormat( SvxDateFormat::D ); // 13.Februar 1996
InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
- aDateField.SetFormat( SVXDATEFORMAT_E ); // Die, 13.Februar 1996
+ aDateField.SetFormat( SvxDateFormat::E ); // Die, 13.Februar 1996
InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
- aDateField.SetFormat( SVXDATEFORMAT_F ); // Dienstag, 13.Februar 1996
+ aDateField.SetFormat( SvxDateFormat::F ); // Dienstag, 13.Februar 1996
InsertItem( nID++, aDateField.GetFormatted( *pNumberFormatter, eLanguage ), nStyle );
CheckItem( (sal_uInt16) ( pDateField->GetFormat() ) + 1 ); // - 2 + 3 !
diff --git a/sd/source/ui/dlg/dlgfield.cxx b/sd/source/ui/dlg/dlgfield.cxx
index 188dfbded6e9..726a852f1305 100644
--- a/sd/source/ui/dlg/dlgfield.cxx
+++ b/sd/source/ui/dlg/dlgfield.cxx
@@ -177,26 +177,26 @@ void SdModifyFieldDlg::FillFormatList()
const SvxDateField* pDateField = static_cast<const SvxDateField*>( pField );
SvxDateField aDateField( *pDateField );
- //SVXDATEFORMAT_APPDEFAULT, // not used
- //SVXDATEFORMAT_SYSTEM, // not used
+ //SvxDateFormat::AppDefault, // not used
+ //SvxDateFormat::System, // not used
m_pLbFormat->InsertEntry( SdResId( STR_STANDARD_SMALL ) );
m_pLbFormat->InsertEntry( SdResId( STR_STANDARD_BIG ) );
SvNumberFormatter* pNumberFormatter = SD_MOD()->GetNumberFormatter();
- aDateField.SetFormat( SVXDATEFORMAT_A ); // 13.02.96
+ aDateField.SetFormat( SvxDateFormat::A ); // 13.02.96
m_pLbFormat->InsertEntry( aDateField.GetFormatted( *pNumberFormatter, eLangType ) );
- aDateField.SetFormat( SVXDATEFORMAT_B ); // 13.02.1996
+ aDateField.SetFormat( SvxDateFormat::B ); // 13.02.1996
m_pLbFormat->InsertEntry( aDateField.GetFormatted( *pNumberFormatter, eLangType ) );
- aDateField.SetFormat( SVXDATEFORMAT_C ); // 13.Feb 1996
+ aDateField.SetFormat( SvxDateFormat::C ); // 13.Feb 1996
m_pLbFormat->InsertEntry( aDateField.GetFormatted( *pNumberFormatter, eLangType ) );
- aDateField.SetFormat( SVXDATEFORMAT_D ); // 13.Februar 1996
+ aDateField.SetFormat( SvxDateFormat::D ); // 13.Februar 1996
m_pLbFormat->InsertEntry( aDateField.GetFormatted( *pNumberFormatter, eLangType ) );
- aDateField.SetFormat( SVXDATEFORMAT_E ); // Die, 13.Februar 1996
+ aDateField.SetFormat( SvxDateFormat::E ); // Die, 13.Februar 1996
m_pLbFormat->InsertEntry( aDateField.GetFormatted( *pNumberFormatter, eLangType ) );
- aDateField.SetFormat( SVXDATEFORMAT_F ); // Dienstag, 13.Februar 1996
+ aDateField.SetFormat( SvxDateFormat::F ); // Dienstag, 13.Februar 1996
m_pLbFormat->InsertEntry( aDateField.GetFormatted( *pNumberFormatter, eLangType ) );
- m_pLbFormat->SelectEntryPos( (sal_uInt16) ( pDateField->GetFormat() - 2 ) );
+ m_pLbFormat->SelectEntryPos( static_cast<sal_uInt16>(pDateField->GetFormat()) - 2 );
}
else if( dynamic_cast< const SvxExtTimeField *>( pField ) != nullptr )
{
diff --git a/sd/source/ui/dlg/headerfooterdlg.cxx b/sd/source/ui/dlg/headerfooterdlg.cxx
index 922aa47c027f..2cc869c8e3ab 100644
--- a/sd/source/ui/dlg/headerfooterdlg.cxx
+++ b/sd/source/ui/dlg/headerfooterdlg.cxx
@@ -91,23 +91,27 @@ namespace sd
{
const int nDateTimeFormatsCount = 12;
-int const nDateTimeFormats[nDateTimeFormatsCount] =
+struct DateAndTimeFormat {
+ SvxDateFormat meDateFormat;
+ SvxTimeFormat meTimeFormat;
+};
+DateAndTimeFormat const nDateTimeFormats[nDateTimeFormatsCount] =
{
- SVXDATEFORMAT_A,
- SVXDATEFORMAT_B,
- SVXDATEFORMAT_C,
- SVXDATEFORMAT_D,
- SVXDATEFORMAT_E,
- SVXDATEFORMAT_F,
+ { SvxDateFormat::A, SvxTimeFormat::AppDefault },
+ { SvxDateFormat::B, SvxTimeFormat::AppDefault },
+ { SvxDateFormat::C, SvxTimeFormat::AppDefault },
+ { SvxDateFormat::D, SvxTimeFormat::AppDefault },
+ { SvxDateFormat::E, SvxTimeFormat::AppDefault },
+ { SvxDateFormat::F, SvxTimeFormat::AppDefault },
- SVXDATEFORMAT_A | (static_cast<int>(SvxTimeFormat::HH24_MM) << 4),
- SVXDATEFORMAT_A | (static_cast<int>(SvxTimeFormat::HH12_MM) << 4),
+ { SvxDateFormat::A, SvxTimeFormat::HH24_MM },
+ { SvxDateFormat::A, SvxTimeFormat::HH12_MM },
- static_cast<int>(SvxTimeFormat::HH24_MM) << 4,
- static_cast<int>(SvxTimeFormat::HH24_MM_SS) << 4,
+ { SvxDateFormat::AppDefault, SvxTimeFormat::HH24_MM },
+ { SvxDateFormat::AppDefault, SvxTimeFormat::HH24_MM_SS },
- static_cast<int>(SvxTimeFormat::HH12_MM) << 4,
- static_cast<int>(SvxTimeFormat::HH12_MM_SS) << 4
+ { SvxDateFormat::AppDefault, SvxTimeFormat::HH12_MM },
+ { SvxDateFormat::AppDefault, SvxTimeFormat::HH12_MM_SS },
};
class HeaderFooterTabPage : public TabPage
@@ -146,7 +150,7 @@ private:
DECL_LINK( UpdateOnClickHdl, Button*, void );
DECL_LINK( LanguageChangeHdl, ListBox&, void );
- void FillFormatList(int eFormat);
+ void FillFormatList(sal_Int32 nSelectedPos);
void GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet );
void GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet, SdPage* pPage );
@@ -439,7 +443,7 @@ HeaderFooterTabPage::HeaderFooterTabPage( vcl::Window* pWindow, SdDrawDocument*
meOldLanguage = MsLangId::getRealLanguage( meOldLanguage );
mpCBDateTimeLanguage->SelectLanguage( meOldLanguage );
- FillFormatList(SVXDATEFORMAT_A);
+ FillFormatList(0);
}
HeaderFooterTabPage::~HeaderFooterTabPage()
@@ -471,10 +475,10 @@ void HeaderFooterTabPage::dispose()
IMPL_LINK_NOARG(HeaderFooterTabPage, LanguageChangeHdl, ListBox&, void)
{
- FillFormatList( (int)reinterpret_cast<sal_IntPtr>(mpCBDateTimeFormat->GetSelectEntryData()) );
+ FillFormatList( mpCBDateTimeFormat->GetSelectEntryPos() );
}
-void HeaderFooterTabPage::FillFormatList( int eFormat )
+void HeaderFooterTabPage::FillFormatList( sal_Int32 nSelectedPos )
{
LanguageType eLanguage = mpCBDateTimeLanguage->GetSelectLanguage();
@@ -483,15 +487,14 @@ void HeaderFooterTabPage::FillFormatList( int eFormat )
Date aDate( Date::SYSTEM );
tools::Time aTime( tools::Time::SYSTEM );
- int nFormat;
- for( nFormat = 0; nFormat < nDateTimeFormatsCount; nFormat++ )
+ for( int nFormat = 0; nFormat < nDateTimeFormatsCount; nFormat++ )
{
OUString aStr( SvxDateTimeField::GetFormatted(
- aDate, aTime, nDateTimeFormats[nFormat],
+ aDate, aTime,
+ nDateTimeFormats[nFormat].meDateFormat, nDateTimeFormats[nFormat].meTimeFormat,
*(SD_MOD()->GetNumberFormatter()), eLanguage ) );
const sal_Int32 nEntry = mpCBDateTimeFormat->InsertEntry( aStr );
- mpCBDateTimeFormat->SetEntryData( nEntry, reinterpret_cast<void*>((sal_IntPtr)nDateTimeFormats[nFormat] ));
- if( nDateTimeFormats[nFormat] == eFormat )
+ if( nFormat == nSelectedPos )
{
mpCBDateTimeFormat->SelectEntryPos( nEntry );
mpCBDateTimeFormat->SetText( aStr );
@@ -520,8 +523,7 @@ void HeaderFooterTabPage::init( const HeaderFooterSettings& rSettings, bool bNot
for( sal_Int32 nPos = 0; nPos < mpCBDateTimeFormat->GetEntryCount(); nPos++ )
{
- int nFormat = (int)reinterpret_cast<sal_IntPtr>(mpCBDateTimeFormat->GetEntryData( nPos ));
- if( nFormat == rSettings.meDateTimeFormat )
+ if( nDateTimeFormats[nPos].meDateFormat == rSettings.meDateFormat && nDateTimeFormats[nPos].meTimeFormat == rSettings.meTimeFormat )
{
mpCBDateTimeFormat->SelectEntryPos( nPos );
mpCBDateTimeFormat->SetText( mpCBDateTimeFormat->GetEntry(nPos) );
@@ -544,7 +546,11 @@ void HeaderFooterTabPage::getData( HeaderFooterSettings& rSettings, bool& rNotOn
rSettings.maHeaderText = mpTBHeader->GetText();
if( mpCBDateTimeFormat->GetSelectEntryCount() == 1 )
- rSettings.meDateTimeFormat = (int)reinterpret_cast<sal_IntPtr>(mpCBDateTimeFormat->GetSelectEntryData());
+ {
+ sal_Int32 nPos = mpCBDateTimeFormat->GetSelectEntryPos();
+ rSettings.meDateFormat = nDateTimeFormats[nPos].meDateFormat;
+ rSettings.meTimeFormat = nDateTimeFormats[nPos].meTimeFormat;
+ }
LanguageType eLanguage = mpCBDateTimeLanguage->GetSelectLanguage();
if( eLanguage != meOldLanguage )
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 341a74dd8c62..cc129aa487f3 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -1590,7 +1590,9 @@ void ImplPDFExportComments( const uno::Reference< drawing::XDrawPage >& xPage, v
Date aDate( aDateTime.Day, aDateTime.Month, aDateTime.Year );
::tools::Time aTime( ::tools::Time::EMPTY );
- OUString aStr( SvxDateTimeField::GetFormatted( aDate, aTime, SVXDATEFORMAT_B, *(SD_MOD()->GetNumberFormatter()), eLanguage ) );
+ OUString aStr = SvxDateTimeField::GetFormatted( aDate, aTime,
+ SvxDateFormat::B, SvxTimeFormat::AppDefault,
+ *(SD_MOD()->GetNumberFormatter()), eLanguage );
vcl::PDFNote aNote;
OUString sTitle( xAnnotation->getAuthor() );
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index 84f7a8399f36..76167735cf7b 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -922,7 +922,8 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName
if( ! ( aValue >>= nValue ) )
throw lang::IllegalArgumentException();
- aHeaderFooterSettings.meDateTimeFormat = nValue;
+ aHeaderFooterSettings.meDateFormat = static_cast<SvxDateFormat>(nValue & 0x0f);
+ aHeaderFooterSettings.meTimeFormat = static_cast<SvxTimeFormat>((nValue >> 4) & 0x0f);
break;
}
}
@@ -1289,7 +1290,11 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
}
break;
case WID_PAGE_DATETIMEFORMAT:
- aAny <<= (sal_Int32)GetPage()->getHeaderFooterSettings().meDateTimeFormat;
+ {
+ auto const & rSettings = GetPage()->getHeaderFooterSettings();
+ sal_Int32 x = static_cast<sal_Int32>(rSettings.meDateFormat) & (static_cast<sal_Int32>(rSettings.meTimeFormat) << 4);
+ aAny <<= x;
+ }
break;
case WID_TRANSITION_TYPE:
More information about the Libreoffice-commits
mailing list