summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-09-13 08:14:47 +0200
committerIlmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>2024-09-14 08:03:59 +0200
commit2e6d189821f5def411647b6f3e21d0617ab299b6 (patch)
tree4814bc90a6880003d87748ffdc85c6d48499014e /sc
parent1b6dcded77c7eae7da916bf73aeec8cb1c5621c7 (diff)
tdf#162938: Revert "tdf#61313 Replace the static ">="...
... with a dropdown of different operators" Why was this patch submitted in the first place? It added a call to convertToOldCondFormat in testTdf101104, testComplexIconSetsXLSX and testTdf64401 to make those tests pass but the issue was already reproducible with those files This reverts commit fcc5770dd1e33dcb4f4f0c28683569af5d1d8368. Change-Id: Ifd8904de26d39d23e52ec2188d917bec34ad93b7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173310 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173327 Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/colorscale.hxx6
-rw-r--r--sc/inc/fillinfo.hxx1
-rw-r--r--sc/qa/unit/subsequent_filters_test4.cxx14
-rw-r--r--sc/qa/unit/ucalc_condformat.cxx9
-rw-r--r--sc/source/core/data/colorscale.cxx66
-rw-r--r--sc/source/ui/condformat/condformatdlgentry.cxx30
-rw-r--r--sc/uiconfig/scalc/ui/conditionaliconset.ui11
7 files changed, 41 insertions, 96 deletions
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 85b57bb6e7b9..bc3b646fe457 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -48,13 +48,11 @@ private:
ScConditionalFormat* mpFormat;
Color maColor;
ScColorScaleEntryType meType;
- ScConditionMode meMode;
void setListener();
public:
- SC_DLLPUBLIC ScColorScaleEntry(double nVal, const Color& rCol, ScColorScaleEntryType eType = COLORSCALE_VALUE,
- ScConditionMode eMode = ScConditionMode::Equal);
+ SC_DLLPUBLIC ScColorScaleEntry(double nVal, const Color& rCol, ScColorScaleEntryType eType = COLORSCALE_VALUE);
SC_DLLPUBLIC ScColorScaleEntry();
ScColorScaleEntry(const ScColorScaleEntry& rEntry);
ScColorScaleEntry(ScDocument* pDoc, const ScColorScaleEntry& rEntry);
@@ -76,9 +74,7 @@ public:
SC_DLLPUBLIC OUString GetFormula( formula::FormulaGrammar::Grammar eGrammar ) const;
ScColorScaleEntryType GetType() const { return meType;}
- ScConditionMode GetMode() const { return meMode; }
SC_DLLPUBLIC void SetType( ScColorScaleEntryType eType );
- SC_DLLPUBLIC void SetMode( ScConditionMode eMode ) { meMode = eMode; }
void SetRepaintCallback(ScConditionalFormat* pParent);
void SetRepaintCallback(const std::function<void()>& func);
diff --git a/sc/inc/fillinfo.hxx b/sc/inc/fillinfo.hxx
index e9c713373724..caecd6a7072b 100644
--- a/sc/inc/fillinfo.hxx
+++ b/sc/inc/fillinfo.hxx
@@ -92,7 +92,6 @@ struct ScIconSetInfo
{
sal_Int32 nIconIndex;
ScIconSetType eIconSetType;
- ScConditionMode eConditionMode;
tools::Long mnHeight = 0;
bool mbShowValue;
};
diff --git a/sc/qa/unit/subsequent_filters_test4.cxx b/sc/qa/unit/subsequent_filters_test4.cxx
index f8fe12e6a305..d016ebbb8b01 100644
--- a/sc/qa/unit/subsequent_filters_test4.cxx
+++ b/sc/qa/unit/subsequent_filters_test4.cxx
@@ -862,17 +862,6 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testCondFormatThemeColor3XLSX)
namespace
{
-// This function is used temporarily so we don't have to update test files.
-void convertToOldCondFormat(const ScIconSetFormat* pIconSet)
-{
- auto itr = pIconSet->begin();
- (*itr)->SetMode(ScConditionMode::Less);
- (*itr)->SetValue((*(itr + 1))->GetValue());
- (*itr)->SetType((*(++itr))->GetType());
- for (; itr != pIconSet->end(); ++itr)
- (*itr)->SetMode(ScConditionMode::EqGreater);
-}
-
void testComplexIconSetsXLSX_Impl(const ScDocument& rDoc, SCCOL nCol, ScIconSetType eType)
{
ScConditionalFormat* pFormat = rDoc.GetCondFormat(nCol, 1, 0);
@@ -895,7 +884,6 @@ void testCustomIconSetsXLSX_Impl(const ScDocument& rDoc, SCCOL nCol, SCROW nRow,
CPPUNIT_ASSERT(pEntry);
CPPUNIT_ASSERT_EQUAL(ScFormatEntry::Type::Iconset, pEntry->GetType());
const ScIconSetFormat* pIconSet = static_cast<const ScIconSetFormat*>(pEntry);
- convertToOldCondFormat(pIconSet);
std::unique_ptr<ScIconSetInfo> pInfo(pIconSet->GetIconSetInfo(ScAddress(nCol, nRow, 1)));
if (nIndex == -1)
CPPUNIT_ASSERT(!pInfo);
@@ -944,7 +932,6 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testTdf101104)
CPPUNIT_ASSERT(pEntry);
CPPUNIT_ASSERT_EQUAL(ScFormatEntry::Type::Iconset, pEntry->GetType());
const ScIconSetFormat* pIconSet = static_cast<const ScIconSetFormat*>(pEntry);
- convertToOldCondFormat(pIconSet);
for (size_t i = 1; i < 10; ++i)
{
@@ -971,7 +958,6 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testTdf64401)
CPPUNIT_ASSERT(pEntry);
CPPUNIT_ASSERT_EQUAL(ScFormatEntry::Type::Iconset, pEntry->GetType());
const ScIconSetFormat* pIconSet = static_cast<const ScIconSetFormat*>(pEntry);
- convertToOldCondFormat(pIconSet);
for (size_t i = 0; i < 10; ++i)
{
diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index 4ff4b69dfd82..66fcf6d1a679 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -731,9 +731,9 @@ CPPUNIT_TEST_FIXTURE(TestCondformat, testIconSet)
ScIconSetFormat* pEntry = new ScIconSetFormat(m_pDoc);
ScIconSetFormatData* pData = new ScIconSetFormatData;
- pData->m_Entries.emplace_back(new ScColorScaleEntry(0, COL_BLUE, COLORSCALE_VALUE, ScConditionMode::EqGreater));
- pData->m_Entries.emplace_back(new ScColorScaleEntry(1, COL_GREEN, COLORSCALE_VALUE, ScConditionMode::EqGreater));
- pData->m_Entries.emplace_back(new ScColorScaleEntry(2, COL_RED, COLORSCALE_VALUE, ScConditionMode::Equal));
+ pData->m_Entries.emplace_back(new ScColorScaleEntry(0, COL_BLUE));
+ pData->m_Entries.emplace_back(new ScColorScaleEntry(1, COL_GREEN));
+ pData->m_Entries.emplace_back(new ScColorScaleEntry(2, COL_RED));
pEntry->SetIconSetData(pData);
m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, 1);
@@ -742,10 +742,11 @@ CPPUNIT_TEST_FIXTURE(TestCondformat, testIconSet)
static struct {
double nVal; sal_Int32 nIndex;
} const aTests[] = {
+ { -1.0, 0 },
{ 0.0, 0 },
{ 1.0, 1 },
{ 2.0, 2 },
- { 3.0, 1 }
+ { 3.0, 2 }
};
for(size_t i = 0; i < SAL_N_ELEMENTS(aTests); ++i)
{
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 4df58b5269a6..b9033bf3af3a 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -154,17 +154,15 @@ bool ScFormulaListener::NeedsRepaint() const
ScColorScaleEntry::ScColorScaleEntry():
mnVal(0),
mpFormat(nullptr),
- meType(COLORSCALE_VALUE),
- meMode(ScConditionMode::Equal)
+ meType(COLORSCALE_VALUE)
{
}
-ScColorScaleEntry::ScColorScaleEntry(double nVal, const Color& rCol, ScColorScaleEntryType eType, ScConditionMode eMode):
+ScColorScaleEntry::ScColorScaleEntry(double nVal, const Color& rCol, ScColorScaleEntryType eType):
mnVal(nVal),
mpFormat(nullptr),
maColor(rCol),
- meType(eType),
- meMode(eMode)
+ meType(eType)
{
}
@@ -172,8 +170,7 @@ ScColorScaleEntry::ScColorScaleEntry(const ScColorScaleEntry& rEntry):
mnVal(rEntry.mnVal),
mpFormat(rEntry.mpFormat),
maColor(rEntry.maColor),
- meType(rEntry.meType),
- meMode(rEntry.meMode)
+ meType(rEntry.meType)
{
setListener();
if(rEntry.mpCell)
@@ -188,8 +185,7 @@ ScColorScaleEntry::ScColorScaleEntry(ScDocument* pDoc, const ScColorScaleEntry&
mnVal(rEntry.mnVal),
mpFormat(rEntry.mpFormat),
maColor(rEntry.maColor),
- meType(rEntry.meType),
- meMode(rEntry.meMode)
+ meType(rEntry.meType)
{
setListener();
if(rEntry.mpCell)
@@ -1070,30 +1066,6 @@ void ScDataBarFormat::EnsureSize()
}
}
-static bool Compare(double nVal1, double nVal2, const ScIconSetFormat::const_iterator& itr)
-{
- switch ((*itr)->GetMode())
- {
- case ScConditionMode::Equal:
- return nVal1 == nVal2;
- case ScConditionMode::Less:
- return nVal1 < nVal2;
- case ScConditionMode::Greater:
- return nVal1 > nVal2;
- case ScConditionMode::EqLess:
- return nVal1 <= nVal2;
- case ScConditionMode::EqGreater:
- return nVal1 >= nVal2;
- case ScConditionMode::NotEqual:
- return nVal1 != nVal2;
-
- default:
- break;
- }
-
- return false;
-}
-
ScIconSetFormatData::ScIconSetFormatData(ScIconSetFormatData const& rOther)
: eIconSetType(rOther.eIconSetType)
, mbShowValue(rOther.mbShowValue)
@@ -1159,32 +1131,27 @@ std::unique_ptr<ScIconSetInfo> ScIconSetFormat::GetIconSetInfo(const ScAddress&
// now we have for sure a value
double nVal = rCell.getValue();
- if (mpFormatData->m_Entries.size() < 1)
+ if (mpFormatData->m_Entries.size() < 2)
return nullptr;
double nMin = GetMinValue();
double nMax = GetMaxValue();
- sal_Int32 nIndex = -1;
- ScConditionMode eMode = ScConditionMode::EqGreater;
+ sal_Int32 nIndex = 0;
const_iterator itr = begin();
- double nValRef = 0;
+ ++itr;
+ double nValMax = CalcValue(nMin, nMax, itr);
- int i = 0;
- while(itr != end())
+ ++itr;
+ while(itr != end() && nVal >= nValMax)
{
- nValRef = CalcValue(nMin, nMax, itr);
- if (Compare(nVal, nValRef, itr))
- {
- nIndex = i;
- eMode = (*itr)->GetMode();
- }
- itr++;
- i++;
+ ++nIndex;
+ nValMax = CalcValue(nMin, nMax, itr);
+ ++itr;
}
- if (nIndex == -1)
- return nullptr;
+ if(nVal >= nValMax)
+ ++nIndex;
std::unique_ptr<ScIconSetInfo> pInfo(new ScIconSetInfo);
@@ -1217,7 +1184,6 @@ std::unique_ptr<ScIconSetInfo> ScIconSetFormat::GetIconSetInfo(const ScAddress&
}
pInfo->mbShowValue = mpFormatData->mbShowValue;
- pInfo->eConditionMode = eMode;
return pInfo;
}
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index 066958daa4b8..7f08fc60796d 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -1328,9 +1328,9 @@ protected:
private:
std::unique_ptr<weld::Container> mxGrid;
std::unique_ptr<weld::Image> mxImgIcon;
+ std::unique_ptr<weld::Label> mxFtEntry;
std::unique_ptr<weld::Entry> mxEdEntry;
std::unique_ptr<weld::ComboBox> mxLbEntryType;
- std::unique_ptr<weld::ComboBox> mxConditionMode;
weld::Container* mpContainer;
public:
@@ -1346,25 +1346,22 @@ public:
}
ScColorScaleEntry* CreateEntry(ScDocument& rDoc, const ScAddress& rPos) const;
+
+ void SetFirstEntry();
};
ScIconSetFrmtDataEntry::ScIconSetFrmtDataEntry(weld::Container* pParent, ScIconSetType eType, const ScDocument* pDoc, sal_Int32 i, const ScColorScaleEntry* pEntry)
: mxBuilder(Application::CreateBuilder(pParent, u"modules/scalc/ui/conditionaliconset.ui"_ustr))
, mxGrid(mxBuilder->weld_container(u"ConditionalIconSet"_ustr))
, mxImgIcon(mxBuilder->weld_image(u"icon"_ustr))
+ , mxFtEntry(mxBuilder->weld_label("label"))
, mxEdEntry(mxBuilder->weld_entry(u"entry"_ustr))
, mxLbEntryType(mxBuilder->weld_combo_box(u"listbox"_ustr))
- , mxConditionMode(mxBuilder->weld_combo_box(u"conditionMode"_ustr))
, mpContainer(pParent)
{
mxImgIcon->set_from_icon_name(ScIconSetFormat::getIconName(eType, i));
if(pEntry)
{
- if (pEntry->GetMode() >= ScConditionMode::Equal && pEntry->GetMode() <= ScConditionMode::NotEqual)
- mxConditionMode->set_active(static_cast<int>(pEntry->GetMode()));
- else
- assert(false && "ScIconSetFrmtDataEntry::ScIconSetFrmtDataEntry: Invalid condition mode");
-
switch(pEntry->GetType())
{
case COLORSCALE_VALUE:
@@ -1390,7 +1387,6 @@ ScIconSetFrmtDataEntry::ScIconSetFrmtDataEntry(weld::Container* pParent, ScIconS
else
{
mxLbEntryType->set_active(1);
- mxConditionMode->set_active(0);
}
}
@@ -1401,8 +1397,7 @@ ScIconSetFrmtDataEntry::~ScIconSetFrmtDataEntry()
ScColorScaleEntry* ScIconSetFrmtDataEntry::CreateEntry(ScDocument& rDoc, const ScAddress& rPos) const
{
- sal_Int32 nTypePos = mxLbEntryType->get_active();
- sal_Int32 nModePos = mxConditionMode->get_active();
+ sal_Int32 nPos = mxLbEntryType->get_active();
OUString aText = mxEdEntry->get_text();
ScColorScaleEntry* pEntry = new ScColorScaleEntry();
@@ -1412,7 +1407,7 @@ ScColorScaleEntry* ScIconSetFrmtDataEntry::CreateEntry(ScDocument& rDoc, const S
(void)pNumberFormatter->IsNumberFormat(aText, nIndex, nVal);
pEntry->SetValue(nVal);
- switch(nTypePos)
+ switch(nPos)
{
case 0:
pEntry->SetType(COLORSCALE_VALUE);
@@ -1431,11 +1426,18 @@ ScColorScaleEntry* ScIconSetFrmtDataEntry::CreateEntry(ScDocument& rDoc, const S
assert(false);
}
- pEntry->SetMode(static_cast<ScConditionMode>(nModePos));
-
return pEntry;
}
+void ScIconSetFrmtDataEntry::SetFirstEntry()
+{
+ mxEdEntry->hide();
+ mxLbEntryType->hide();
+ mxFtEntry->hide();
+ mxEdEntry->set_text("0");
+ mxLbEntryType->set_active(1);
+}
+
ScIconSetFrmtEntry::ScIconSetFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScIconSetFormat* pFormat)
: ScCondFrmtEntry(pParent, pDoc, rPos)
, mxLbColorFormat(mxBuilder->weld_combo_box(u"colorformat"_ustr))
@@ -1462,6 +1464,7 @@ ScIconSetFrmtEntry::ScIconSetFrmtEntry(ScCondFormatList* pParent, ScDocument* pD
mxIconParent.get(), eType, pDoc, i, pIconSetFormatData->m_Entries[i].get()));
maEntries[i]->set_grid_top_attach(i);
}
+ maEntries[0]->SetFirstEntry();
}
else
IconSetTypeHdl(*mxLbIconSetType);
@@ -1495,6 +1498,7 @@ IMPL_LINK_NOARG( ScIconSetFrmtEntry, IconSetTypeHdl, weld::ComboBox&, void )
maEntries[i]->set_grid_top_attach(i);
maEntries[i]->Show();
}
+ maEntries[0]->SetFirstEntry();
}
OUString ScIconSetFrmtEntry::GetExpressionString()
diff --git a/sc/uiconfig/scalc/ui/conditionaliconset.ui b/sc/uiconfig/scalc/ui/conditionaliconset.ui
index 342a4747c012..bf129a2c914c 100644
--- a/sc/uiconfig/scalc/ui/conditionaliconset.ui
+++ b/sc/uiconfig/scalc/ui/conditionaliconset.ui
@@ -16,17 +16,10 @@
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
- <object class="GtkComboBoxText" id="conditionMode">
+ <object class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <items>
- <item translatable="no" context="conditionaliconset|conditionMode"> = </item>
- <item translatable="no" context="conditionaliconset|conditionMode"> &lt; </item>
- <item translatable="no" context="conditionaliconset|conditionMode"> &gt; </item>
- <item translatable="no" context="conditionaliconset|conditionMode"> &lt;= </item>
- <item translatable="no" context="conditionaliconset|conditionMode"> &gt;= </item>
- <item translatable="no" context="conditionaliconset|conditionMode"> &lt;&gt; </item>
- </items>
+ <property name="label" translatable="yes" context="conditionaliconset|label"> &gt;= </property>
</object>
<packing>
<property name="left_attach">1</property>