tdf#157930 Add Contains Text rule to easy conditional format dialog

Contains Text is another commonly used conditional formatting rule
that could be of use here

Change-Id: I67a3f711c57f9917be26fa21badd2f5a0d133747
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158657
Tested-by: Jenkins
Reviewed-by: Paris Oplopoios <parisoplop@gmail.com>
This commit is contained in:
offtkp 2023-10-30 14:28:12 +02:00 committed by Paris Oplopoios
parent d590f094cc
commit c8da023efe
3 changed files with 35 additions and 5 deletions

View file

@ -666,7 +666,7 @@
</node>
<node oor:name=".uno:ConditionalFormatEasy?FormatRule:short=1" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Conditional Formatting: Condition Less Than</value>
<value xml:lang="en-US">Conditional Formatting: Less Than</value>
</prop>
<prop oor:name="ContextLabel" oor:type="xs:string">
<value xml:lang="en-US">Less than...</value>
@ -677,7 +677,7 @@
</node>
<node oor:name=".uno:ConditionalFormatEasy?FormatRule:short=0" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Conditional Formatting: Condition Equals</value>
<value xml:lang="en-US">Conditional Formatting: Equals</value>
</prop>
<prop oor:name="ContextLabel" oor:type="xs:string">
<value xml:lang="en-US">Equals...</value>
@ -697,6 +697,17 @@
<value>1</value>
</prop>
</node>
<node oor:name=".uno:ConditionalFormatEasy?FormatRule:short=23" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Conditional Formatting: Contains Text</value>
</prop>
<prop oor:name="ContextLabel" oor:type="xs:string">
<value xml:lang="en-US">Containing text...</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
</prop>
</node>
<node oor:name=".uno:ConditionalFormatDialog" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Conditional Formatting: More Rules</value>

View file

@ -208,9 +208,27 @@ IMPL_LINK(ConditionalFormatEasyDialog, ButtonPressed, weld::Button&, rButton, vo
if (&rButton == mxButtonOk.get())
{
std::unique_ptr<ScConditionalFormat> pFormat(new ScConditionalFormat(0, mpDocument));
OUString sExpression1 = mxNumberEntry->get_text();
OUString sExpression2 = mxNumberEntry2->get_text();
switch (meMode)
{
case ScConditionMode::ContainsText:
case ScConditionMode::NotContainsText:
case ScConditionMode::BeginsWith:
case ScConditionMode::EndsWith:
sExpression1 = "\"" + sExpression1 + "\"";
sExpression2 = "\"" + sExpression2 + "\"";
break;
default:
break;
}
ScFormatEntry* pEntry
= new ScCondFormatEntry(meMode, mxNumberEntry->get_text(), mxNumberEntry2->get_text(),
*mpDocument, maPosition, mxStyles->get_active_text());
= new ScCondFormatEntry(meMode, sExpression1, sExpression2, *mpDocument, maPosition,
mxStyles->get_active_text());
ScRangeList aRange;
ScRefFlags nFlags
= aRange.Parse(mxRangeEntry->GetText(), mpViewData->GetDocument(),
@ -229,4 +247,4 @@ IMPL_LINK(ConditionalFormatEasyDialog, ButtonPressed, weld::Button&, rButton, vo
m_xDialog->response(RET_CANCEL);
}
} // namespace sc
} // namespace sc

View file

@ -12,6 +12,7 @@
<menu:menuitem menu:id=".uno:ConditionalFormatEasy?FormatRule:short=1"/>
<menu:menuitem menu:id=".uno:ConditionalFormatEasy?FormatRule:short=0"/>
<menu:menuitem menu:id=".uno:ConditionalFormatEasy?FormatRule:short=6"/>
<menu:menuitem menu:id=".uno:ConditionalFormatEasy?FormatRule:short=23"/>
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:ConditionalFormatDialog"/>
</menu:menupopup>