diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-05-08 17:05:37 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-05-08 17:06:16 -0400 |
commit | 7f3f6e4709c13b15fd122d9c2bd5e474c26ca4fb (patch) | |
tree | 31f4898cdcd7abbbba4fd7c91ee9b7995199450b | |
parent | 3c648396567a2832c757d8d37432803a3f8e1818 (diff) |
Use the field type value for branching instead of ISA macro.
Change-Id: Ie5bc60875fef3e9b6f6f46942b2124bc42978290
-rw-r--r-- | sc/source/core/tool/editutil.cxx | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx index 5724202375c8..54ab2f635cec 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; |