sc/inc/colorscale.hxx | 2 ++ sc/source/core/data/colorscale.cxx | 30 ++++++++++++++++++++++++++++++ sc/source/filter/excel/xecontent.cxx | 18 +----------------- sc/source/filter/excel/xeextlst.cxx | 20 ++------------------ sc/source/filter/xml/xmlexprt.cxx | 20 ++------------------ sc/source/ui/view/cellsh1.cxx | 6 +----- 6 files changed, 38 insertions(+), 58 deletions(-)
New commits: commit f8f395218b242367a23f82b9b362ad5f5b2f546e Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Fri Oct 12 10:31:42 2018 +0200 Commit: Jan Holesovsky <ke...@collabora.com> CommitDate: Mon Oct 15 16:09:44 2018 +0200 Conditional formatting: Use the nElements from g_IconSetMap. And also kill some copy'n'paste when at that. Change-Id: Ice38b738f31e486008fdae450c9534306f3a9613 Reviewed-on: https://gerrit.libreoffice.org/61705 Tested-by: Jenkins Reviewed-by: Jan Holesovsky <ke...@collabora.com> diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index 22ae90092a86..eb89d0cf2c34 100644 --- a/sc/inc/colorscale.hxx +++ b/sc/inc/colorscale.hxx @@ -379,6 +379,8 @@ public: virtual Type GetType() const override; static const ScIconSetMap g_IconSetMap[]; + static const char* getIconSetName( ScIconSetType eType ); + static sal_Int32 getIconSetElements( ScIconSetType eType ); static BitmapEx& getBitmap(sc::IconSetBitmapMap& rBitmapMap, ScIconSetType eType, sal_Int32 nIndex); typedef ScIconSetFormatData::Entries_t::iterator iterator; diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index b83caa0af361..84b73e269dd6 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -1351,6 +1351,36 @@ static const ScIconSetBitmapMap aBitmapMap[] = { { IconSet_5Boxes, a5Boxes } }; +const ScIconSetMap* findIconSetType(ScIconSetType eType) +{ + const ScIconSetMap* pMap = ScIconSetFormat::g_IconSetMap; + for (; pMap->pName; ++pMap) + { + if (pMap->eType == eType) + return pMap; + } + + return nullptr; +} + +} + +const char* ScIconSetFormat::getIconSetName( ScIconSetType eType ) +{ + const ScIconSetMap* pMap = findIconSetType(eType); + if (pMap) + return pMap->pName; + + return ""; +} + +sal_Int32 ScIconSetFormat::getIconSetElements( ScIconSetType eType ) +{ + const ScIconSetMap* pMap = findIconSetType(eType); + if (pMap) + return pMap->nElements; + + return 0; } BitmapEx& ScIconSetFormat::getBitmap(sc::IconSetBitmapMap & rIconSetBitmapMap, diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 06e3fd453559..a56f4d98bc23 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -1525,22 +1525,6 @@ XclExpIconSet::XclExpIconSet( const XclExpRoot& rRoot, const ScIconSetFormat& rF } } -namespace { - -const char* getIconSetName( ScIconSetType eType ) -{ - const ScIconSetMap* pMap = ScIconSetFormat::g_IconSetMap; - for(; pMap->pName; ++pMap) - { - if(pMap->eType == eType) - return pMap->pName; - } - - return ""; -} - -} - void XclExpIconSet::SaveXml( XclExpXmlStream& rStrm ) { sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); @@ -1550,7 +1534,7 @@ void XclExpIconSet::SaveXml( XclExpXmlStream& rStrm ) XML_priority, OString::number( mnPriority + 1 ).getStr(), FSEND ); - const char* pIconSetName = getIconSetName(mrFormat.GetIconSetData()->eIconSetType); + const char* pIconSetName = ScIconSetFormat::getIconSetName(mrFormat.GetIconSetData()->eIconSetType); rWorksheet->startElement( XML_iconSet, XML_iconSet, pIconSetName, XML_showValue, mrFormat.GetIconSetData()->mbShowValue ? nullptr : "0", diff --git a/sc/source/filter/excel/xeextlst.cxx b/sc/source/filter/excel/xeextlst.cxx index 9af26168c850..e4e040e6635e 100644 --- a/sc/source/filter/excel/xeextlst.cxx +++ b/sc/source/filter/excel/xeextlst.cxx @@ -20,22 +20,6 @@ using namespace ::oox; -namespace { - -const char* getIconSetName( ScIconSetType eType ) -{ - const ScIconSetMap* pMap = ScIconSetFormat::g_IconSetMap; - for(; pMap->pName; ++pMap) - { - if(pMap->eType == eType) - return pMap->pName; - } - - return ""; -} - -} - XclExpExt::XclExpExt( const XclExpRoot& rRoot ): XclExpRoot(rRoot) { @@ -74,7 +58,7 @@ XclExpExtIcon::XclExpExtIcon(const XclExpRoot& rRoot, const std::pair<ScIconSetT XclExpRoot(rRoot), nIndex(rCustomEntry.second) { - pIconSetName = getIconSetName(rCustomEntry.first); + pIconSetName = ScIconSetFormat::getIconSetName(rCustomEntry.first); } void XclExpExtIcon::SaveXml(XclExpXmlStream& rStrm) @@ -226,7 +210,7 @@ XclExpExtIconSet::XclExpExtIconSet(const XclExpRoot& rRoot, const ScIconSetForma mbCustom = rData.mbCustom; mbReverse = rData.mbReverse; mbShowValue = rData.mbShowValue; - mpIconSetName = getIconSetName(rData.eIconSetType); + mpIconSetName = ScIconSetFormat::getIconSetName(rData.eIconSetType); if (mbCustom) { diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 379efb569410..0112c308d71d 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -4520,22 +4520,6 @@ OUString getCondFormatEntryType(const ScColorScaleEntry& rEntry, bool bFirst = t return OUString(); } -OUString getIconSetName(ScIconSetType eType) -{ - const char* pName = nullptr; - const ScIconSetMap* pMap = ScIconSetFormat::g_IconSetMap; - for(;pMap->pName;++pMap) - { - if(pMap->eType == eType) - { - pName = pMap->pName; - break; - } - } - assert(pName); - return OUString::createFromAscii(pName); -} - OUString getDateStringForType(condformat::ScCondFormatDateType eType) { switch(eType) @@ -4825,7 +4809,7 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab) else if(pFormatEntry->GetType() == ScFormatEntry::Type::Iconset) { const ScIconSetFormat& rIconSet = static_cast<const ScIconSetFormat&>(*pFormatEntry); - OUString aIconSetName = getIconSetName(rIconSet.GetIconSetData()->eIconSetType); + OUString aIconSetName = OUString::createFromAscii(ScIconSetFormat::getIconSetName(rIconSet.GetIconSetData()->eIconSetType)); AddAttribute( XML_NAMESPACE_CALC_EXT, XML_ICON_SET_TYPE, aIconSetName ); if (rIconSet.GetIconSetData()->mbCustom) AddAttribute(XML_NAMESPACE_CALC_EXT, XML_CUSTOM, OUString::boolean(true)); @@ -4838,7 +4822,7 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab) it = rIconSet.GetIconSetData()->maCustomVector.begin(); it != rIconSet.GetIconSetData()->maCustomVector.end(); ++it) { - AddAttribute(XML_NAMESPACE_CALC_EXT, XML_CUSTOM_ICONSET_NAME, getIconSetName(it->first)); + AddAttribute(XML_NAMESPACE_CALC_EXT, XML_CUSTOM_ICONSET_NAME, OUString::createFromAscii(ScIconSetFormat::getIconSetName(it->first))); AddAttribute(XML_NAMESPACE_CALC_EXT, XML_CUSTOM_ICONSET_INDEX, OUString::number(it->second)); SvXMLElementExport aCustomIcon(*this, XML_NAMESPACE_CALC_EXT, XML_CUSTOM_ICONSET, true, true); } diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 2bba89765d86..c5060b3e5ecd 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -1994,11 +1994,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) pFormat->SetRange(aRangeList); ScIconSetType eIconSetType = limit_cast<ScIconSetType>(pParam->GetValue(), IconSet_3Arrows, IconSet_5Boxes); - int nSteps = 3; - if (eIconSetType >= IconSet_4Arrows && eIconSetType < IconSet_5Arrows) - nSteps = 4; - else if (eIconSetType >= IconSet_5Arrows) - nSteps = 5; + const int nSteps = ScIconSetFormat::getIconSetElements(eIconSetType); ScIconSetFormat* pEntry = new ScIconSetFormat(pDoc); ScIconSetFormatData* pIconSetFormatData = new ScIconSetFormatData(eIconSetType); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits