[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sc/inc sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Nov 5 11:21:51 UTC 2018
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 261a97037396868b5f9943728d849e48192c7e3e
Author: Jan Holesovsky <kendy at collabora.com>
AuthorDate: Fri Oct 12 10:31:42 2018 +0200
Commit: Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Mon Nov 5 12:20:58 2018 +0100
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/61722
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 0adde0e30585..2cf9d06d5969 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -378,6 +378,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 fedbb4230dc8..3ddbe280443e 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -1295,6 +1295,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 b79815d67781..e40a02a64cf3 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -1450,22 +1450,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();
@@ -1475,7 +1459,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 52d90b14867e..31814141ef89 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 55959b50b030..b873793373c4 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -4203,22 +4203,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)
@@ -4508,7 +4492,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));
@@ -4521,7 +4505,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 622db89acb67..abed90879ea8 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2048,11 +2048,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);
More information about the Libreoffice-commits
mailing list