sc/inc/strings.hrc                            |   14 ++++
 sc/source/ui/condformat/condformateasydlg.cxx |   75 ++++++++++++++++++++------
 sc/source/ui/inc/condformateasydlg.hxx        |    1 
 sc/uiconfig/scalc/ui/conditionaleasydialog.ui |   28 ++++-----
 4 files changed, 87 insertions(+), 31 deletions(-)

New commits:
commit b2ae21c9da28d79839c48768e7ed0b2cf734cf30
Author:     codewithvk <vivek.jav...@collabora.com>
AuthorDate: Mon Mar 25 22:42:25 2024 +0530
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Wed Apr 3 06:08:49 2024 +0200

    Conditional Formatting: Adding More Specified Dialogues
    
    We have added additional single conditional dialogues to enhance the 
conditional formatting options for conditions such as duplicates, N elements, 
etc.
    
    Signed-off-by: codewithvk <vivek.jav...@collabora.com>
    Change-Id: I46d069f259d47739ad1bc859b19513f19d414eb7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165290
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    (cherry picked from commit abcb07e2baf2d59904b50e9c20f8a108ab9f17de)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165325

diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index 2c8bacfb4bea..c11b62fa7d9b 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -399,9 +399,21 @@
 #define STR_CONDITION_NOT_EQUAL                     
NC_("STR_CONDITION_NOT_EQUAL", "not equal to")
 
 #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")
 
diff --git a/sc/source/ui/condformat/condformateasydlg.cxx 
b/sc/source/ui/condformat/condformateasydlg.cxx
index 1fed832b9811..a6f4d2ae23b8 100644
--- a/sc/source/ui/condformat/condformateasydlg.cxx
+++ b/sc/source/ui/condformat/condformateasydlg.cxx
@@ -66,6 +66,7 @@ 
ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings,
     , mpDocument(&mpViewData->GetDocument())
     , mxNumberEntry(m_xBuilder->weld_entry("entryNumber"))
     , mxNumberEntry2(m_xBuilder->weld_entry("entryNumber2"))
+    , mxAllInputs(m_xBuilder->weld_container("allInputs"))
     , mxRangeEntry(new formula::RefEdit(m_xBuilder->weld_entry("entryRange")))
     , mxButtonRangeEdit(new 
formula::RefButton(m_xBuilder->weld_button("rbassign")))
     , mxStyles(m_xBuilder->weld_combo_box("themeCombo"))
@@ -116,26 +117,62 @@ 
ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings,
             SetDescription(ScResId(STR_CONDITION_BETWEEN));
             mxNumberEntry2->show();
             break;
-        // NotBetween
-        // Duplicate
-        // NotDuplicate
-        // Direct
-        // Top10
-        // Bottom10
-        // TopPercent
-        // BottomPercent
-        // AboveAverage
-        // BelowAverage
-        // AboveEqualAverage
-        // BelowEqualAverage
+        case ScConditionMode::NotBetween:
+            SetDescription(ScResId(STR_CONDITION_NOT_BETWEEN));
+            mxNumberEntry2->show();
+            break;
+        case ScConditionMode::Duplicate:
+            SetDescription(ScResId(STR_CONDITION_DUPLICATE));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::NotDuplicate:
+            SetDescription(ScResId(STR_CONDITION_NOT_DUPLICATE));
+            mxAllInputs->hide();
+            break;
+        // TODO: Direct
+        case ScConditionMode::Top10:
+            SetDescription(ScResId(STR_CONDITION_TOP_N_ELEMENTS));
+            break;
+        case ScConditionMode::Bottom10:
+            SetDescription(ScResId(STR_CONDITION_BOTTOM_N_ELEMENTS));
+            break;
+
+        case ScConditionMode::TopPercent:
+            SetDescription(ScResId(STR_CONDITION_TOP_N_PERCENT));
+            break;
+        case ScConditionMode::BottomPercent:
+            SetDescription(ScResId(STR_CONDITION_BOTTOM_N_PERCENT));
+            break;
+
+        case ScConditionMode::AboveAverage:
+            SetDescription(ScResId(STR_CONDITION_ABOVE_AVERAGE));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::BelowAverage:
+            SetDescription(ScResId(STR_CONDITION_BELOW_AVERAGE));
+            mxAllInputs->hide();
+            break;
+
+        case ScConditionMode::AboveEqualAverage:
+            SetDescription(ScResId(STR_CONDITION_ABOVE_OR_EQUAL_AVERAGE));
+            mxAllInputs->hide();
+            break;
+        case ScConditionMode::BelowEqualAverage:
+            SetDescription(ScResId(STR_CONDITION_BELOW_OR_EQUAL_AVERAGE));
+            mxAllInputs->hide();
+            break;
         case ScConditionMode::Error:
             SetDescription(ScResId(STR_CONDITION_ERROR));
             break;
         case ScConditionMode::NoError:
             SetDescription(ScResId(STR_CONDITION_NOERROR));
             break;
-        // BeginsWith
-        // EndsWith
+        case ScConditionMode::BeginsWith:
+            SetDescription(ScResId(STR_CONDITION_BEGINS_WITH));
+            break;
+        case ScConditionMode::EndsWith:
+            SetDescription(ScResId(STR_CONDITION_ENDS_WITH));
+            break;
         case ScConditionMode::ContainsText:
             SetDescription(ScResId(STR_CONDITION_CONTAINS_TEXT));
             break;
@@ -209,8 +246,14 @@ IMPL_LINK(ConditionalFormatEasyDialog, ButtonPressed, 
weld::Button&, rButton, vo
     {
         std::unique_ptr<ScConditionalFormat> pFormat(new 
ScConditionalFormat(0, mpDocument));
 
-        OUString sExpression1 = mxNumberEntry->get_text();
-        OUString sExpression2 = mxNumberEntry2->get_text();
+        OUString sExpression1
+            = (mxNumberEntry->get_visible() == true && 
mxAllInputs->get_visible() == true
+                   ? mxNumberEntry->get_text()
+                   : "");
+        OUString sExpression2
+            = (mxNumberEntry2->get_visible() == true && 
mxAllInputs->get_visible() == true
+                   ? mxNumberEntry2->get_text()
+                   : "");
 
         switch (meMode)
         {
diff --git a/sc/source/ui/inc/condformateasydlg.hxx 
b/sc/source/ui/inc/condformateasydlg.hxx
index 6d6af1041b49..d891aa69e83c 100644
--- a/sc/source/ui/inc/condformateasydlg.hxx
+++ b/sc/source/ui/inc/condformateasydlg.hxx
@@ -44,6 +44,7 @@ private:
 
     std::unique_ptr<weld::Entry> mxNumberEntry;
     std::unique_ptr<weld::Entry> mxNumberEntry2;
+    std::unique_ptr<weld::Container> mxAllInputs;
     std::unique_ptr<formula::RefEdit> mxRangeEntry;
     std::unique_ptr<formula::RefButton> mxButtonRangeEdit;
     std::unique_ptr<weld::ComboBox> mxStyles;
diff --git a/sc/uiconfig/scalc/ui/conditionaleasydialog.ui 
b/sc/uiconfig/scalc/ui/conditionaleasydialog.ui
index 6a5fbb7bf5d7..218709502822 100644
--- a/sc/uiconfig/scalc/ui/conditionaleasydialog.ui
+++ b/sc/uiconfig/scalc/ui/conditionaleasydialog.ui
@@ -85,7 +85,7 @@
                     <property name="margin-bottom">6</property>
                     <property name="spacing">12</property>
                     <child>
-                      <object class="GtkBox">
+                      <object class="GtkBox" id="allInputs">
                         <property name="visible">True</property>
                         <property name="can-focus">False</property>
                         <property name="spacing">12</property>
@@ -117,18 +117,6 @@
                             <property name="position">1</property>
                           </packing>
                         </child>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkBox">
-                        <property name="visible">True</property>
-                        <property name="can-focus">False</property>
-                        <property name="spacing">12</property>
                         <child>
                           <object class="GtkLabel" id="with">
                             <property name="visible">True</property>
@@ -141,9 +129,21 @@
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">True</property>
-                            <property name="position">0</property>
+                            <property name="position">2</property>
                           </packing>
                         </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox">
+                        <property name="visible">True</property>
+                        <property name="can-focus">False</property>
+                        <property name="spacing">12</property>
                         <child>
                           <object class="GtkComboBoxText" id="themeCombo">
                             <property name="visible">True</property>

Reply via email to