sc/inc/conditio.hxx                            |   56 +++++++++++
 sc/inc/strings.hrc                             |   63 ++++++++-----
 sc/source/core/data/conditio.cxx               |   16 +++
 sc/source/ui/condformat/condformatdlgentry.cxx |   79 +++++++++++-----
 sc/source/ui/condformat/condformateasydlg.cxx  |  117 ++++++++++++++++++++++++-
 sc/source/ui/condformat/condformatmgr.cxx      |   84 +++++++++++++++++
 sc/source/ui/inc/condformatdlgentry.hxx        |    2 
 sc/source/ui/inc/condformatmgr.hxx             |    4 
 sc/uiconfig/scalc/ui/condformatmanager.ui      |   54 ++++++++++-
 sc/uiconfig/scalc/ui/conditionaleasydialog.ui  |    2 
 10 files changed, 418 insertions(+), 59 deletions(-)

New commits:
commit 723e035e1fbafdedf7ed64b8de4c14ef0ef038ea
Author:     Pranam Lashkari <lpra...@collabora.com>
AuthorDate: Wed Jun 26 00:13:54 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Thu Aug 15 12:42:24 2024 +0200

    tdf#162475 sc: added date condition option in conditional format manage 
dialog
    
    Change-Id: I453b4ef47bed1607f42fbb3e48303531c6f355a3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169323
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170911
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins

diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 24c42ffbe703..3d22a16c7d33 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -85,6 +85,20 @@ enum class ScConditionMode
     EndsWith,
     ContainsText,
     NotContainsText,
+    Formula,
+    Today,
+    Yesterday,
+    Tomorrow,
+    Last7days,
+    ThisWeek,
+    LastWeek,
+    NextWeek,
+    ThisMonth,
+    LastMonth,
+    NextMonth,
+    ThisYear,
+    LastYear,
+    NextYear,
     NONE
 };
 
@@ -169,6 +183,48 @@ inline std::basic_ostream<charT, traits> & operator 
<<(std::basic_ostream<charT,
     case ScConditionMode::NotContainsText:
         stream << "NOTCONTAINSTEXT";
         break;
+    case ScConditionMode::Formula:
+        stream << "FORMULA";
+        break;
+    case ScConditionMode::Today:
+        stream << "TODAY";
+        break;
+    case ScConditionMode::Yesterday:
+        stream << "YESTERDAY";
+        break;
+    case ScConditionMode::Tomorrow:
+        stream << "TOMORROW";
+        break;
+    case ScConditionMode::Last7days:
+        stream << "LAST7DAYS";
+        break;
+    case ScConditionMode::ThisWeek:
+        stream << "THISWEEK";
+        break;
+    case ScConditionMode::LastWeek:
+        stream << "LASTWEEK";
+        break;
+    case ScConditionMode::NextWeek:
+        stream << "NEXTWEEK";
+        break;
+    case ScConditionMode::ThisMonth:
+        stream << "THISMONTH";
+        break;
+    case ScConditionMode::LastMonth:
+        stream << "LASTMONTH";
+        break;
+    case ScConditionMode::NextMonth:
+        stream << "NEXTMONTH";
+        break;
+    case ScConditionMode::ThisYear:
+        stream << "THISYEAR";
+        break;
+    case ScConditionMode::LastYear:
+        stream << "LASTYEAR";
+        break;
+    case ScConditionMode::NextYear:
+        stream << "NEXTYEAR";
+        break;
     case ScConditionMode::NONE:
         stream << "NONE";
         break;
diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index e5725ef312fd..2277de7826d8 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -398,31 +398,46 @@
 #define STR_A11Y_DESC_ANNOT                         NC_("extended_tip|annot", 
"Specifies that a small rectangle in the top right corner of the cell indicates 
that a comment exists. The comment will be shown only when you enable tips 
under %PRODUCTNAME - General in the Options dialog box.")
 
 // Simple conditional formatting dialog
-#define STR_CONDITION_EQUAL                         NC_("STR_CONDITION_EQUAL", 
"equal to")
-#define STR_CONDITION_LESS                          NC_("STR_CONDITION_LESS", 
"less than")
-#define STR_CONDITION_GREATER                       
NC_("STR_CONDITION_GREATER", "greater than")
-#define STR_CONDITION_EQLESS                        
NC_("STR_CONDITION_EQLESS", "equal or less than")
-#define STR_CONDITION_EQGREATER                     
NC_("STR_CONDITION_EQGREATER", "equal or greater than")
-#define STR_CONDITION_NOT_EQUAL                     
NC_("STR_CONDITION_NOT_EQUAL", "not equal to")
+#define STR_CONDITION_EQUAL                         NC_("STR_CONDITION_EQUAL", 
"values equal to")
+#define STR_CONDITION_LESS                          NC_("STR_CONDITION_LESS", 
"values less than")
+#define STR_CONDITION_GREATER                       
NC_("STR_CONDITION_GREATER", "values greater than")
+#define STR_CONDITION_EQLESS                        
NC_("STR_CONDITION_EQLESS", "values equal or less than")
+#define STR_CONDITION_EQGREATER                     
NC_("STR_CONDITION_EQGREATER", "values equal or greater than")
+#define STR_CONDITION_NOT_EQUAL                     
NC_("STR_CONDITION_NOT_EQUAL", "values not equal to")
+
+#define STR_CONDITION_BETWEEN                       
NC_("STR_CONDITION_BETWEEN", "values between")
+#define STR_CONDITION_NOT_BETWEEN                   
NC_("STR_CONDITION_NOT_BETWEEN", "values not between")
+#define STR_CONDITION_DUPLICATE                     
NC_("STR_CONDITION_DUPLICATE", "values duplicate")
+#define STR_CONDITION_NOT_DUPLICATE                 
NC_("STR_CONDITION_NOT_DUPLICATE", "values not duplicate")
+#define STR_CONDITION_TOP_N_ELEMENTS                
NC_("STR_CONDITION_TOP_N_ELEMENTS", "values in top N elements")
+#define STR_CONDITION_BOTTOM_N_ELEMENTS             
NC_("STR_CONDITION_BOTTOM_N_ELEMENTS", "values in bottom N elements")
+#define STR_CONDITION_TOP_N_PERCENT                 
NC_("STR_CONDITION_TOP_N_PERCENT", "values in top N percent")
+#define STR_CONDITION_BOTTOM_N_PERCENT              
NC_("STR_CONDITION_BOTTOM_N_PERCENT", "values in bottom N percent")
+#define STR_CONDITION_ABOVE_AVERAGE                 
NC_("STR_CONDITION_ABOVE_AVERAGE", "values above average")
+#define STR_CONDITION_BELOW_AVERAGE                 
NC_("STR_CONDITION_BELOW_AVERAGE", "values below average")
+#define STR_CONDITION_ABOVE_OR_EQUAL_AVERAGE        
NC_("STR_CONDITION_ABOVE_OR_EQUAL_AVERAGE", "values above or equal average")
+#define STR_CONDITION_BELOW_OR_EQUAL_AVERAGE        
NC_("STR_CONDITION_BELOW_OR_EQUAL_AVERAGE", "values below or equal average")
+#define STR_CONDITION_ERROR                         NC_("STR_CONDITION_ERROR", 
"values have error")
+#define STR_CONDITION_NOERROR                       
NC_("STR_CONDITION_NOERROR", "values don't have error")
+#define STR_CONDITION_BEGINS_WITH                   
NC_("STR_CONDITION_BEGINS_WITH", "values begin with")
+#define STR_CONDITION_ENDS_WITH                     
NC_("STR_CONDITION_ENDS_WITH", "values end with")
+#define STR_CONDITION_CONTAINS_TEXT                 
NC_("STR_CONDITION_CONTAINS_TEXT", "values contain text")
+#define STR_CONDITION_NOT_CONTAINS_TEXT             
NC_("STR_CONDITION_NOT_CONTAINS_TEXT", "values don't contain text")
+#define STR_CONDITION_FORMULA                       
NC_("STR_CONDITION_FORMULA", "formula is")
+#define STR_CONDITION_TODAY                         NC_("STR_CONDITION_TODAY", 
"date is today")
+#define STR_CONDITION_YESTERDAY                     
NC_("STR_CONDITION_YESTERDAY", "date is yesterday")
+#define STR_CONDITION_TOMORROW                      
NC_("STR_CONDITION_TOMORROW", "date is tomorrow")
+#define STR_CONDITION_LAST7DAYS                     
NC_("STR_CONDITION_LAST7DAYS", "date is in last 7 days")
+#define STR_CONDITION_THISWEEK                      
NC_("STR_CONDITION_THISWEEK", "date is in this week")
+#define STR_CONDITION_LASTWEEK                      
NC_("STR_CONDITION_LASTWEEK", "date is in last week")
+#define STR_CONDITION_NEXTWEEK                      
NC_("STR_CONDITION_NEXTWEEK", "date is in next week")
+#define STR_CONDITION_THISMONTH                     
NC_("STR_CONDITION_THISMONTH", "date is in this month")
+#define STR_CONDITION_LASTMONTH                     
NC_("STR_CONDITION_LASTMONTH", "date is in last month")
+#define STR_CONDITION_NEXTMONTH                     
NC_("STR_CONDITION_NEXTMONTH", "date is in next month")
+#define STR_CONDITION_THISYEAR                     
NC_("STR_CONDITION_THISYEAR", "date is in this year")
+#define STR_CONDITION_LASTYEAR                     
NC_("STR_CONDITION_LASTYEAR", "date is in last year")
+#define STR_CONDITION_NEXTYEAR                     
NC_("STR_CONDITION_NEXTYEAR", "date is in next year")
 
-#define STR_CONDITION_BETWEEN                       
NC_("STR_CONDITION_BETWEEN", "between")
-#define STR_CONDITION_NOT_BETWEEN                   
NC_("STR_CONDITION_NOT_BETWEEN", "not between")
-#define STR_CONDITION_DUPLICATE                     
NC_("STR_CONDITION_DUPLICATE", "duplicate")
-#define STR_CONDITION_NOT_DUPLICATE                 
NC_("STR_CONDITION_NOT_DUPLICATE", "not duplicate")
-#define STR_CONDITION_TOP_N_ELEMENTS                
NC_("STR_CONDITION_TOP_N_ELEMENTS", "in top N elements")
-#define STR_CONDITION_BOTTOM_N_ELEMENTS             
NC_("STR_CONDITION_BOTTOM_N_ELEMENTS", "in bottom N elements")
-#define STR_CONDITION_TOP_N_PERCENT                 
NC_("STR_CONDITION_TOP_N_PERCENT", "in top N percent")
-#define STR_CONDITION_BOTTOM_N_PERCENT              
NC_("STR_CONDITION_BOTTOM_N_PERCENT", "in bottom N percent")
-#define STR_CONDITION_ABOVE_AVERAGE                 
NC_("STR_CONDITION_ABOVE_AVERAGE", "above average")
-#define STR_CONDITION_BELOW_AVERAGE                 
NC_("STR_CONDITION_BELOW_AVERAGE", "below average")
-#define STR_CONDITION_ABOVE_OR_EQUAL_AVERAGE        
NC_("STR_CONDITION_ABOVE_OR_EQUAL_AVERAGE", "above or equal average")
-#define STR_CONDITION_BELOW_OR_EQUAL_AVERAGE        
NC_("STR_CONDITION_BELOW_OR_EQUAL_AVERAGE", "below or equal average")
-#define STR_CONDITION_ERROR                         NC_("STR_CONDITION_ERROR", 
"with error ")
-#define STR_CONDITION_NOERROR                       
NC_("STR_CONDITION_NOERROR", "without error ")
-#define STR_CONDITION_BEGINS_WITH                   
NC_("STR_CONDITION_BEGINS_WITH", "begins with")
-#define STR_CONDITION_ENDS_WITH                     
NC_("STR_CONDITION_ENDS_WITH", "ends with")
-#define STR_CONDITION_CONTAINS_TEXT                 
NC_("STR_CONDITION_CONTAINS_TEXT", "containing text")
-#define STR_CONDITION_NOT_CONTAINS_TEXT             
NC_("STR_CONDITION_NOT_CONTAINS_TEXT", "not containing text")
 
 #define STR_CONTENT_WITH_UNKNOWN_ENCRYPTION 
NC_("STR_CONTENT_WITH_UNKNOWN_ENCRYPTION", "Document contains DRM content that 
is encrypted with an unknown encryption method. Only the un-encrypted content 
will be shown.")
 
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 87c0834d69f0..3c54b590d4e0 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1139,6 +1139,22 @@ bool ScConditionEntry::IsValid( double nArg, const 
ScAddress& rPos ) const
             if( eOp == ScConditionMode::NotContainsText )
                 bValid = !bValid;
             break;
+        case ScConditionMode::Formula:
+        case ScConditionMode::Today:
+        case ScConditionMode::Yesterday:
+        case ScConditionMode::Tomorrow:
+        case ScConditionMode::Last7days:
+        case ScConditionMode::ThisWeek:
+        case ScConditionMode::LastWeek:
+        case ScConditionMode::NextWeek:
+        case ScConditionMode::ThisMonth:
+        case ScConditionMode::LastMonth:
+        case ScConditionMode::NextMonth:
+        case ScConditionMode::ThisYear:
+        case ScConditionMode::LastYear:
+        case ScConditionMode::NextYear:
+            bValid = true;
+            break;
         default:
             SAL_WARN("sc", "unknown operation at ScConditionEntry");
             break;
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx 
b/sc/source/ui/condformat/condformatdlgentry.cxx
index 066958daa4b8..72b4025a46c7 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -128,32 +128,45 @@ void FillStyleListBox( const ScDocument* pDoc, 
weld::ComboBox& rLbStyle )
 
 }
 
-const ScConditionMode 
ScConditionFrmtEntry::mpEntryToCond[ScConditionFrmtEntry::NUM_COND_ENTRIES] = {
-    ScConditionMode::Equal,
-    ScConditionMode::Less,
-    ScConditionMode::Greater,
-    ScConditionMode::EqLess,
-    ScConditionMode::EqGreater,
-    ScConditionMode::NotEqual,
-    ScConditionMode::Between,
-    ScConditionMode::NotBetween,
-    ScConditionMode::Duplicate,
-    ScConditionMode::NotDuplicate,
-    ScConditionMode::Top10,
-    ScConditionMode::Bottom10,
-    ScConditionMode::TopPercent,
-    ScConditionMode::BottomPercent,
-    ScConditionMode::AboveAverage,
-    ScConditionMode::BelowAverage,
-    ScConditionMode::AboveEqualAverage,
-    ScConditionMode::BelowEqualAverage,
-    ScConditionMode::Error,
-    ScConditionMode::NoError,
-    ScConditionMode::BeginsWith,
-    ScConditionMode::EndsWith,
-    ScConditionMode::ContainsText,
-    ScConditionMode::NotContainsText
-};
+const ScConditionMode 
ScConditionFrmtEntry::mpEntryToCond[ScConditionFrmtEntry::NUM_COND_ENTRIES]
+    = { ScConditionMode::Equal,
+        ScConditionMode::Less,
+        ScConditionMode::Greater,
+        ScConditionMode::EqLess,
+        ScConditionMode::EqGreater,
+        ScConditionMode::NotEqual,
+        ScConditionMode::Between,
+        ScConditionMode::NotBetween,
+        ScConditionMode::Duplicate,
+        ScConditionMode::NotDuplicate,
+        ScConditionMode::Top10,
+        ScConditionMode::Bottom10,
+        ScConditionMode::TopPercent,
+        ScConditionMode::BottomPercent,
+        ScConditionMode::AboveAverage,
+        ScConditionMode::BelowAverage,
+        ScConditionMode::AboveEqualAverage,
+        ScConditionMode::BelowEqualAverage,
+        ScConditionMode::Error,
+        ScConditionMode::NoError,
+        ScConditionMode::BeginsWith,
+        ScConditionMode::EndsWith,
+        ScConditionMode::ContainsText,
+        ScConditionMode::NotContainsText,
+        ScConditionMode::Formula,
+        ScConditionMode::Today,
+        ScConditionMode::Yesterday,
+        ScConditionMode::Tomorrow,
+        ScConditionMode::Last7days,
+        ScConditionMode::ThisWeek,
+        ScConditionMode::LastWeek,
+        ScConditionMode::NextWeek,
+        ScConditionMode::ThisMonth,
+        ScConditionMode::LastMonth,
+        ScConditionMode::NextMonth,
+        ScConditionMode::ThisYear,
+        ScConditionMode::LastYear,
+        ScConditionMode::NextYear };
 
 ScConditionFrmtEntry::ScConditionFrmtEntry(ScCondFormatList* pParent, 
ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
         const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry)
@@ -357,6 +370,20 @@ sal_Int32 ScConditionFrmtEntry::GetNumberEditFields( 
ScConditionMode eMode )
         case ScConditionMode::BelowEqualAverage:
         case ScConditionMode::Duplicate:
         case ScConditionMode::NotDuplicate:
+        case ScConditionMode::Formula:
+        case ScConditionMode::Today:
+        case ScConditionMode::Yesterday:
+        case ScConditionMode::Tomorrow:
+        case ScConditionMode::Last7days:
+        case ScConditionMode::ThisWeek:
+        case ScConditionMode::LastWeek:
+        case ScConditionMode::NextWeek:
+        case ScConditionMode::ThisMonth:
+        case ScConditionMode::LastMonth:
+        case ScConditionMode::NextMonth:
+        case ScConditionMode::ThisYear:
+        case ScConditionMode::LastYear:
+        case ScConditionMode::NextYear:
             return 0;
         case ScConditionMode::Between:
         case ScConditionMode::NotBetween:
diff --git a/sc/source/ui/condformat/condformateasydlg.cxx 
b/sc/source/ui/condformat/condformateasydlg.cxx
index cbab60c26ee4..dc80a085536e 100644
--- a/sc/source/ui/condformat/condformateasydlg.cxx
+++ b/sc/source/ui/condformat/condformateasydlg.cxx
@@ -31,6 +31,41 @@ void UpdateStyleList(const ScDocument* pDocument, 
weld::ComboBox& rCombo)
     FillStyleListBox(pDocument, rCombo);
     rCombo.set_active_text(sSelectedStyle);
 }
+
+condformat::ScCondFormatDateType GetScCondFormatDateType(ScConditionMode mode)
+{
+    switch (mode)
+    {
+        case ScConditionMode::Today:
+            return condformat::ScCondFormatDateType::TODAY;
+        case ScConditionMode::Yesterday:
+            return condformat::ScCondFormatDateType::YESTERDAY;
+        case ScConditionMode::Tomorrow:
+            return condformat::ScCondFormatDateType::TOMORROW;
+        case ScConditionMode::Last7days:
+            return condformat::ScCondFormatDateType::LAST7DAYS;
+        case ScConditionMode::ThisWeek:
+            return condformat::ScCondFormatDateType::THISWEEK;
+        case ScConditionMode::LastWeek:
+            return condformat::ScCondFormatDateType::LASTWEEK;
+        case ScConditionMode::NextWeek:
+            return condformat::ScCondFormatDateType::NEXTWEEK;
+        case ScConditionMode::ThisMonth:
+            return condformat::ScCondFormatDateType::THISMONTH;
+        case ScConditionMode::LastMonth:
+            return condformat::ScCondFormatDateType::LASTMONTH;
+        case ScConditionMode::NextMonth:
+            return condformat::ScCondFormatDateType::NEXTMONTH;
+        case ScConditionMode::ThisYear:
+            return condformat::ScCondFormatDateType::THISYEAR;
+        case ScConditionMode::LastYear:
+            return condformat::ScCondFormatDateType::LASTYEAR;
+        case ScConditionMode::NextYear:
+            return condformat::ScCondFormatDateType::NEXTYEAR;
+        default:
+            return condformat::ScCondFormatDateType::TODAY;
+    }
+}
 }
 
 namespace sc
@@ -162,6 +197,62 @@ 
ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings,
         case ScConditionMode::NotContainsText:
             SetDescription(ScResId(STR_CONDITION_NOT_CONTAINS_TEXT));
             break;
+        case ScConditionMode::Formula:
+            SetDescription(ScResId(STR_CONDITION_FORMULA));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::Today:
+            SetDescription(ScResId(STR_CONDITION_TODAY));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::Yesterday:
+            SetDescription(ScResId(STR_CONDITION_YESTERDAY));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::Tomorrow:
+            SetDescription(ScResId(STR_CONDITION_TOMORROW));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::Last7days:
+            SetDescription(ScResId(STR_CONDITION_LAST7DAYS));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::ThisWeek:
+            SetDescription(ScResId(STR_CONDITION_THISWEEK));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::LastWeek:
+            SetDescription(ScResId(STR_CONDITION_LASTWEEK));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::NextWeek:
+            SetDescription(ScResId(STR_CONDITION_NEXTWEEK));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::ThisMonth:
+            SetDescription(ScResId(STR_CONDITION_THISMONTH));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::LastMonth:
+            SetDescription(ScResId(STR_CONDITION_LASTMONTH));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::NextMonth:
+            SetDescription(ScResId(STR_CONDITION_NEXTMONTH));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::ThisYear:
+            SetDescription(ScResId(STR_CONDITION_THISYEAR));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::LastYear:
+            SetDescription(ScResId(STR_CONDITION_LASTYEAR));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::NextYear:
+            SetDescription(ScResId(STR_CONDITION_NEXTYEAR));
+            mxAllInputs->hide();
+            break;
         default:
             SAL_WARN("sc",
                      
"ConditionalFormatEasyDialog::ConditionalFormatEasyDialog: invalid format");
@@ -259,9 +350,29 @@ IMPL_LINK(ConditionalFormatEasyDialog, ButtonPressed, 
weld::Button&, rButton, vo
                 break;
         }
 
-        ScFormatEntry* pEntry
-            = new ScCondFormatEntry(meMode, sExpression1, sExpression2, 
*mpDocument, maPosition,
-                                    mxStyles->get_active_text());
+        ScFormatEntry* pEntry;
+        if (meMode < ScConditionMode::Formula)
+        {
+            pEntry = new ScCondFormatEntry(meMode, sExpression1, sExpression2, 
*mpDocument,
+                                           maPosition, 
mxStyles->get_active_text());
+        }
+        else if (meMode >= ScConditionMode::Today && meMode < 
ScConditionMode::NONE)
+        {
+            ScCondDateFormatEntry entry(mpDocument);
+            entry.SetDateType(GetScCondFormatDateType(meMode));
+            entry.SetStyleName(mxStyles->get_active_text());
+            pEntry = new ScCondDateFormatEntry(mpDocument, entry);
+        }
+        else if (meMode == ScConditionMode::Formula)
+        {
+            pEntry = new ScCondFormatEntry(ScConditionMode::Direct, "", 
OUString(), *mpDocument,
+                                           maPosition, 
mxStyles->get_active_text());
+        }
+        else
+        {
+            DBG_ASSERT(false, "Invalid conidtion type selected.");
+            return;
+        }
 
         ScRangeList aRange;
         ScRefFlags nFlags
diff --git a/sc/source/ui/condformat/condformatmgr.cxx 
b/sc/source/ui/condformat/condformatmgr.cxx
index 16456d7fd7b6..f5441f4edf08 100644
--- a/sc/source/ui/condformat/condformatmgr.cxx
+++ b/sc/source/ui/condformat/condformatmgr.cxx
@@ -21,6 +21,7 @@
 #include <svl/eitem.hxx>
 #include <svl/intitem.hxx>
 #include <unotools/viewoptions.hxx>
+#include <iostream>
 
 ScCondFormatManagerWindow::ScCondFormatManagerWindow(weld::TreeView& rTreeView,
     ScDocument& rDoc, ScConditionalFormatList* pFormatList)
@@ -98,6 +99,8 @@ ScCondFormatManagerDlg::ScCondFormatManagerDlg(weld::Window* 
pParent, ScDocument
     , m_xFormatList( pFormatList ? new ScConditionalFormatList(*pFormatList) : 
nullptr)
     , m_xConditionalType(m_xBuilder->weld_combo_box("type"))
     , m_xConditionalCellValue(m_xBuilder->weld_combo_box("typeis"))
+    , m_xConditionalFormula(m_xBuilder->weld_entry("formula"))
+    , m_xConditionalDate(m_xBuilder->weld_combo_box("datetype"))
     , m_xBtnAdd(m_xBuilder->weld_button(u"add"_ustr))
     , m_xBtnRemove(m_xBuilder->weld_button(u"remove"_ustr))
     , m_xBtnEdit(m_xBuilder->weld_button(u"edit"_ustr))
@@ -108,6 +111,8 @@ 
ScCondFormatManagerDlg::ScCondFormatManagerDlg(weld::Window* pParent, ScDocument
     m_xBtnEdit->connect_clicked(LINK(this, ScCondFormatManagerDlg, 
EditBtnClickHdl));
     m_xBtnAdd->connect_clicked(LINK(this, ScCondFormatManagerDlg, AddBtnHdl));
     m_xTreeView->connect_row_activated(LINK(this, ScCondFormatManagerDlg, 
EditBtnHdl));
+    m_xTreeView->connect_changed(LINK(this, ScCondFormatManagerDlg, 
EntryFocus));
+    m_xConditionalType->connect_changed(LINK(this, ScCondFormatManagerDlg, 
ComboHdl));
 
     SvtViewOptions aDlgOpt(EViewType::Dialog, u"CondFormatDialog"_ustr);
     if (aDlgOpt.Exists())
@@ -148,13 +153,29 @@ void ScCondFormatManagerDlg::ShowEasyConditionalDialog()
         return;
 
     auto id = m_xConditionalType->get_active();
+    SfxBoolItem IsManaged(FN_PARAM_2, true);
     switch (id)
     {
         case 0: // Cell value
         {
             SfxInt16Item FormatRule(FN_PARAM_1,
                                     
m_xConditionalCellValue->get_active_id().toUInt32());
-            SfxBoolItem IsManaged(FN_PARAM_2, true);
+            SfxViewShell::Current()->GetDispatcher()->ExecuteList(
+                SID_EASY_CONDITIONAL_FORMAT_DIALOG, SfxCallMode::ASYNCHRON,
+                { &FormatRule, &IsManaged });
+        }
+        break;
+        case 1: // Formula
+        {
+            SfxInt16Item FormatRule(FN_PARAM_1, 
static_cast<sal_Int16>(ScConditionMode::Formula));
+            SfxViewShell::Current()->GetDispatcher()->ExecuteList(
+                SID_EASY_CONDITIONAL_FORMAT_DIALOG, SfxCallMode::ASYNCHRON,
+                { &FormatRule, &IsManaged });
+        }
+        break;
+        case 2: // Date
+        {
+            SfxInt16Item FormatRule(FN_PARAM_1, 
m_xConditionalDate->get_active_id().toUInt32());
             SfxViewShell::Current()->GetDispatcher()->ExecuteList(
                 SID_EASY_CONDITIONAL_FORMAT_DIALOG, SfxCallMode::ASYNCHRON,
                 { &FormatRule, &IsManaged });
@@ -196,6 +217,67 @@ IMPL_LINK_NOARG(ScCondFormatManagerDlg, AddBtnHdl, 
weld::Button&, void)
     m_xDialog->response( DLG_RET_ADD );
 }
 
+IMPL_LINK_NOARG(ScCondFormatManagerDlg, ComboHdl, weld::ComboBox&, void)
+{
+    auto id = m_xConditionalType->get_active();
+    switch (id)
+    {
+        case 0:
+        {
+            m_xConditionalCellValue->set_visible(true);
+            m_xConditionalFormula->set_visible(false);
+            m_xConditionalDate->set_visible(false);
+        }
+        break;
+        case 1:
+        {
+            m_xConditionalCellValue->set_visible(false);
+            m_xConditionalFormula->set_visible(true);
+            m_xConditionalDate->set_visible(false);
+        }
+        break;
+        case 2:
+        {
+            m_xConditionalCellValue->set_visible(false);
+            m_xConditionalFormula->set_visible(false);
+            m_xConditionalDate->set_visible(true);
+        }
+        break;
+        default:
+            break;
+    }
+}
+
+IMPL_LINK_NOARG(ScCondFormatManagerDlg, EntryFocus, weld::TreeView&, void)
+{
+    ScConditionalFormat* conditionFrmt = m_xCtrlManager->GetSelection();
+
+    if (!conditionFrmt)
+        return;
+
+    const ScFormatEntry* entry = conditionFrmt->GetEntry(0);
+    if (!entry)
+        return;
+    auto type = entry->GetType();
+
+    if (type == ScFormatEntry::Type::Condition)
+    {
+        const ScCondFormatEntry* conditionEntry = dynamic_cast<const 
ScCondFormatEntry*>(entry);
+        auto conditionType = conditionEntry->GetOperation();
+        m_xConditionalType->set_active(0);
+        this->ComboHdl(*m_xConditionalType);
+        m_xConditionalCellValue->set_active(static_cast<int>(conditionType));
+    }
+    else if (type == ScFormatEntry::Type::Date)
+    {
+        const ScCondDateFormatEntry* dateEntry = dynamic_cast<const 
ScCondDateFormatEntry*>(entry);
+        auto dateType = dateEntry->GetDateType();
+        m_xConditionalType->set_active(2);
+        this->ComboHdl(*m_xConditionalType);
+        m_xConditionalDate->set_active(dateType);
+    }
+}
+
 void ScCondFormatManagerDlg::SetModified()
 {
     m_bModified = true;
diff --git a/sc/source/ui/inc/condformatdlgentry.hxx 
b/sc/source/ui/inc/condformatdlgentry.hxx
index 6725ef94c940..6f024643d4b3 100644
--- a/sc/source/ui/inc/condformatdlgentry.hxx
+++ b/sc/source/ui/inc/condformatdlgentry.hxx
@@ -103,7 +103,7 @@ class ScConditionFrmtEntry : public ScCondFrmtEntry, public 
SfxListener
     std::unique_ptr<weld::CustomWeld> mxWdPreview;
     bool mbIsInStyleCreate;
 
-    static const sal_Int32 NUM_COND_ENTRIES = 24;
+    static const sal_Int32 NUM_COND_ENTRIES = 38;
     // Lookup table from positions in maLbCondType to the condition mode enum
     static const ScConditionMode mpEntryToCond[NUM_COND_ENTRIES];
 
diff --git a/sc/source/ui/inc/condformatmgr.hxx 
b/sc/source/ui/inc/condformatmgr.hxx
index 51a251416b27..7361fb6830c7 100644
--- a/sc/source/ui/inc/condformatmgr.hxx
+++ b/sc/source/ui/inc/condformatmgr.hxx
@@ -52,6 +52,8 @@ private:
 
     std::unique_ptr<weld::ComboBox> m_xConditionalType;
     std::unique_ptr<weld::ComboBox> m_xConditionalCellValue;
+    std::unique_ptr<weld::Entry> m_xConditionalFormula;
+    std::unique_ptr<weld::ComboBox> m_xConditionalDate;
     std::unique_ptr<weld::Button> m_xBtnAdd;
     std::unique_ptr<weld::Button> m_xBtnRemove;
     std::unique_ptr<weld::Button> m_xBtnEdit;
@@ -64,6 +66,8 @@ private:
     DECL_LINK(EditBtnClickHdl, weld::Button&, void);
     DECL_LINK(AddBtnHdl, weld::Button&, void);
     DECL_LINK(EditBtnHdl, weld::TreeView&, bool);
+    DECL_LINK(ComboHdl, weld::ComboBox&, void);
+    DECL_LINK(EntryFocus, weld::TreeView&, void);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/uiconfig/scalc/ui/condformatmanager.ui 
b/sc/uiconfig/scalc/ui/condformatmanager.ui
index 74ea3d33bda9..b0ce20a5d756 100644
--- a/sc/uiconfig/scalc/ui/condformatmanager.ui
+++ b/sc/uiconfig/scalc/ui/condformatmanager.ui
@@ -224,6 +224,54 @@
                         <property name="position">1</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkEntry" id="formula">
+                        <property name="can-focus">True</property>
+                        <property name="no-show-all">True</property>
+                        <property name="hexpand">True</property>
+                        <property name="visibility">False</property>
+                        <property name="truncate-multiline">True</property>
+                        <child internal-child="accessible">
+                          <object class="AtkObject" id="formula-atkobject">
+                            <property name="AtkObject::accessible-description" 
translatable="yes" context="condformatmanager|extended_tip|formula">Here you 
can add formula for conditional formatting.</property>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkComboBoxText" id="datetype">
+                        <property name="can-focus">False</property>
+                        <property name="can_focus">False</property>
+                        <property name="visible">False</property>
+                        <property name="no_show_all">True</property>
+                        <property name="active">0</property>
+                        <items>
+                          <item translatable="yes" 
context="condformatmanager|datetype" id="26">Today</item>
+                          <item translatable="yes" 
context="condformatmanager|datetype" id="27">Yesterday</item>
+                          <item translatable="yes" 
context="condformatmanager|datetype" id="28">Tomorrow</item>
+                          <item translatable="yes" 
context="condformatmanager|datetype" id="29">Last 7 days</item>
+                          <item translatable="yes" 
context="condformatmanager|datetype" id="30">This week</item>
+                          <item translatable="yes" 
context="condformatmanager|datetype" id="31">Last week</item>
+                          <item translatable="yes" 
context="condformatmanager|datetype" id="32">Next week</item>
+                          <item translatable="yes" 
context="condformatmanager|datetype" id="33">This month</item>
+                          <item translatable="yes" 
context="condformatmanager|datetype" id="34">Last month</item>
+                          <item translatable="yes" 
context="condformatmanager|datetype" id="35">Next month</item>
+                          <item translatable="yes" 
context="condformatmanager|datetype" id="36">This year</item>
+                          <item translatable="yes" 
context="condformatmanager|datetype" id="37">Last year</item>
+                          <item translatable="yes" 
context="condformatmanager|datetype" id="38">Next year</item>
+                        </items>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">3</property>
+                      </packing>
+                    </child>
                     <child>
                       <object class="GtkButton" id="add">
                         <property name="label" translatable="yes" 
context="condformatmanager|add">Add</property>
@@ -239,7 +287,7 @@
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">True</property>
-                        <property name="position">2</property>
+                        <property name="position"></property>
                       </packing>
                     </child>
                     <child>
@@ -257,7 +305,7 @@
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">True</property>
-                        <property name="position">3</property>
+                        <property name="position">5</property>
                       </packing>
                     </child>
                     <child>
@@ -275,7 +323,7 @@
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">True</property>
-                        <property name="position">4</property>
+                        <property name="position">6</property>
                       </packing>
                     </child>
                   </object>
diff --git a/sc/uiconfig/scalc/ui/conditionaleasydialog.ui 
b/sc/uiconfig/scalc/ui/conditionaleasydialog.ui
index e9bf10716207..3939d49f613b 100644
--- a/sc/uiconfig/scalc/ui/conditionaleasydialog.ui
+++ b/sc/uiconfig/scalc/ui/conditionaleasydialog.ui
@@ -204,7 +204,7 @@
                   <object class="GtkLabel" id="description">
                     <property name="visible">True</property>
                     <property name="can-focus">False</property>
-                    <property name="label" translatable="yes" 
context="conditionaleasydialog|label">Conditional formatting rule: %1</property>
+                    <property name="label" translatable="yes" 
context="conditionaleasydialog|label">Highlight cells if %1</property>
                     <accessibility>
                       <relation type="label-for" target="entryNumber"/>
                       <relation type="label-for" target="entryNumber2"/>

Reply via email to