[Libreoffice-commits] .: sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Tue May 8 14:05:50 PDT 2012
sc/source/core/tool/editutil.cxx | 43 ++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 20 deletions(-)
New commits:
commit 7f3f6e4709c13b15fd122d9c2bd5e474c26ca4fb
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue May 8 17:05:37 2012 -0400
Use the field type value for branching instead of ISA macro.
Change-Id: Ie5bc60875fef3e9b6f6f46942b2124bc42978290
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index 5724202..54ab2f6 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -653,22 +653,29 @@ String ScHeaderEditEngine::CalcFieldValue( const SvxFieldItem& rField,
sal_uInt16 /* nPara */, sal_uInt16 /* nPos */,
Color*& /* rTxtColor */, Color*& /* rFldColor */ )
{
- String aRet;
const SvxFieldData* pFieldData = rField.GetField();
- if ( pFieldData )
+ if (!pFieldData)
+ return rtl::OUString("?");
+
+ rtl::OUString aRet;
+ sal_Int32 nClsId = pFieldData->GetClassId();
+ switch (nClsId)
{
- TypeId aType = pFieldData->Type();
- if (aType == TYPE(SvxPageField))
+ case text::textfield::Type::PAGE:
aRet = lcl_GetNumStr( aData.nPageNo,aData.eNumType );
- else if (aType == TYPE(SvxPagesField))
+ break;
+ case text::textfield::Type::PAGES:
aRet = lcl_GetNumStr( aData.nTotalPages,aData.eNumType );
- else if (aType == TYPE(SvxTimeField))
+ break;
+ case text::textfield::Type::TIME:
aRet = ScGlobal::pLocaleData->getTime(aData.aTime);
- else if (aType == TYPE(SvxFileField))
+ break;
+ case text::textfield::Type::FILE:
aRet = aData.aTitle;
- else if (aType == TYPE(SvxExtFileField))
+ break;
+ case text::textfield::Type::EXTENDED_FILE:
{
- switch ( ((const SvxExtFileField*)pFieldData)->GetFormat() )
+ switch (static_cast<const SvxExtFileField*>(pFieldData)->GetFormat())
{
case SVXFILEFORMAT_FULLPATH :
aRet = aData.aLongDocName;
@@ -677,19 +684,15 @@ String ScHeaderEditEngine::CalcFieldValue( const SvxFieldItem& rField,
aRet = aData.aShortDocName;
}
}
- else if (aType == TYPE(SvxTableField))
+ break;
+ case text::textfield::Type::TABLE:
aRet = aData.aTabName;
- else if (aType == TYPE(SvxDateField))
+ break;
+ case text::textfield::Type::DATE:
aRet = ScGlobal::pLocaleData->getDate(aData.aDate);
- else
- {
- aRet = '?';
- }
- }
- else
- {
- OSL_FAIL("FieldData ist 0");
- aRet = '?';
+ break;
+ default:
+ aRet = "?";
}
return aRet;
More information about the Libreoffice-commits
mailing list