Bugzilla – Attachment 110355 Details for
Bug 42897
FORMATTING: Conditional formatting displays wrong cell background.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for equal to value vs. equal to formula
equal_value_formula.patch (text/plain), 11.73 KB, created by
Renato Ferreira
on 2014-12-02 12:45:30 UTC
(
hide
)
Description:
Patch for equal to value vs. equal to formula
Filename:
MIME Type:
Creator:
Renato Ferreira
Created:
2014-12-02 12:45:30 UTC
Size:
11.73 KB
patch
obsolete
>diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx >index 743c950..5e51537 100644 >--- a/sc/inc/conditio.hxx >+++ b/sc/inc/conditio.hxx >@@ -55,6 +55,7 @@ struct RefUpdateMoveTabContext; > enum ScConditionMode > { > SC_COND_EQUAL, >+ SC_COND_EQUAL_VALUE, // may be selected in conditional formatting, gets fixed to SC_COND_EQUAL > SC_COND_LESS, > SC_COND_GREATER, > SC_COND_EQLESS, >diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx >index 10fd33f..dfd162d 100644 >--- a/sc/source/ui/condformat/condformatdlgentry.cxx >+++ b/sc/source/ui/condformat/condformatdlgentry.cxx >@@ -164,6 +164,23 @@ void FillStyleListBox( ScDocument* pDoc, ListBox& rLbStyle ) > > } > >+/** >+ Returns whether the string starts and ends in double quotes. >+ >+ @return true if the first and last characters are double quotes, >+ false otherwise >+ */ >+bool lcl_isQuoted( const OUString &rExpr ) >+{ >+ sal_Int32 aLen = rExpr.getLength(); >+ if (aLen < 2) >+ { >+ return false; >+ } >+ return rExpr.getStr()[0] == '\"' && >+ rExpr.getStr()[aLen - 1] == '\"'; >+} >+ > ScConditionFrmtEntry::ScConditionFrmtEntry( vcl::Window* pParent, ScDocument* pDoc, ScCondFormatDlg* pDialogParent, > const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry ): > ScCondFrmtEntry( pParent, pDoc, rPos ), >@@ -188,96 +205,111 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( vcl::Window* pParent, ScDocument* pD > OUString aStyleName = pFormatEntry->GetStyle(); > maLbStyle.SelectEntry(aStyleName); > StyleSelectHdl(NULL); >+ >+ // If comparing to string, display as "equal to value" unquoted instead > ScConditionMode eMode = pFormatEntry->GetOperation(); >- maEdVal1.SetText(pFormatEntry->GetExpression(maPos, 0)); >+ OUString aExpr1 = pFormatEntry->GetExpression(maPos, 0); >+ if (eMode == SC_COND_EQUAL && lcl_isQuoted(aExpr1)) >+ { >+ maEdVal1.SetText(aExpr1.copy(1, aExpr1.getLength() - 2)); >+ eMode = SC_COND_EQUAL_VALUE; >+ } >+ else >+ { >+ maEdVal1.SetText(aExpr1); >+ } >+ > maEdVal2.Hide(); > switch(eMode) > { > case SC_COND_EQUAL: > maLbCondType.SelectEntryPos(0); > break; >- case SC_COND_LESS: >+ case SC_COND_EQUAL_VALUE: > maLbCondType.SelectEntryPos(1); > break; >- case SC_COND_GREATER: >+ case SC_COND_LESS: > maLbCondType.SelectEntryPos(2); > break; >- case SC_COND_EQLESS: >+ case SC_COND_GREATER: > maLbCondType.SelectEntryPos(3); > break; >- case SC_COND_EQGREATER: >+ case SC_COND_EQLESS: > maLbCondType.SelectEntryPos(4); > break; >- case SC_COND_NOTEQUAL: >+ case SC_COND_EQGREATER: > maLbCondType.SelectEntryPos(5); > break; >+ case SC_COND_NOTEQUAL: >+ maLbCondType.SelectEntryPos(6); >+ break; > case SC_COND_BETWEEN: > maEdVal2.Show(); > maEdVal2.SetText(pFormatEntry->GetExpression(maPos, 1)); >- maLbCondType.SelectEntryPos(6); >+ maLbCondType.SelectEntryPos(7); > break; > case SC_COND_NOTBETWEEN: > maEdVal2.Show(); > maEdVal2.SetText(pFormatEntry->GetExpression(maPos, 1)); >- maLbCondType.SelectEntryPos(7); >+ maLbCondType.SelectEntryPos(8); > break; > case SC_COND_DUPLICATE: >- maLbCondType.SelectEntryPos(8); >+ maLbCondType.SelectEntryPos(9); > break; > case SC_COND_NOTDUPLICATE: >- maLbCondType.SelectEntryPos(9); >+ maLbCondType.SelectEntryPos(10); > break; > case SC_COND_DIRECT: > assert(false); > //maLbType.SelectEntryPos(2); > break; > case SC_COND_TOP10: >- maLbCondType.SelectEntryPos(10); >+ maLbCondType.SelectEntryPos(11); > break; > case SC_COND_BOTTOM10: >- maLbCondType.SelectEntryPos(11); >+ maLbCondType.SelectEntryPos(12); > break; > case SC_COND_TOP_PERCENT: >- maLbCondType.SelectEntryPos(12); >+ maLbCondType.SelectEntryPos(13); > break; > case SC_COND_BOTTOM_PERCENT: >- maLbCondType.SelectEntryPos(13); >+ maLbCondType.SelectEntryPos(14); > break; > case SC_COND_ABOVE_AVERAGE: > maEdVal1.Hide(); >- maLbCondType.SelectEntryPos(14); >+ maLbCondType.SelectEntryPos(15); > break; > case SC_COND_BELOW_AVERAGE: > maEdVal1.Hide(); >- maLbCondType.SelectEntryPos(15); >+ maLbCondType.SelectEntryPos(16); > break; > case SC_COND_ABOVE_EQUAL_AVERAGE: > maEdVal1.Hide(); >- maLbCondType.SelectEntryPos(16); >+ maLbCondType.SelectEntryPos(17); > break; > case SC_COND_BELOW_EQUAL_AVERAGE: > maEdVal1.Hide(); >- maLbCondType.SelectEntryPos(17); >+ maLbCondType.SelectEntryPos(18); > break; > case SC_COND_ERROR: > maEdVal1.Hide(); >- maLbCondType.SelectEntryPos(18); >+ maLbCondType.SelectEntryPos(19); > break; > case SC_COND_NOERROR: > maEdVal1.Hide(); >- maLbCondType.SelectEntryPos(19); >+ maLbCondType.SelectEntryPos(20); > break; > case SC_COND_BEGINS_WITH: >- maLbCondType.SelectEntryPos(20); >+ maLbCondType.SelectEntryPos(21); > break; > case SC_COND_ENDS_WITH: >- maLbCondType.SelectEntryPos(21); >+ maLbCondType.SelectEntryPos(22); > break; > case SC_COND_CONTAINS_TEXT: >- maLbCondType.SelectEntryPos(22); >+ maLbCondType.SelectEntryPos(23); > break; > case SC_COND_NOT_CONTAINS_TEXT: >- maLbCondType.SelectEntryPos(23); >+ maLbCondType.SelectEntryPos(24); > break; > case SC_COND_NONE: > break; >@@ -321,78 +353,81 @@ ScFormatEntry* ScConditionFrmtEntry::createConditionEntry() const > eMode = SC_COND_EQUAL; > break; > case 1: >- eMode = SC_COND_LESS; >+ eMode = SC_COND_EQUAL_VALUE; > break; > case 2: >- eMode = SC_COND_GREATER; >+ eMode = SC_COND_LESS; > break; > case 3: >- eMode = SC_COND_EQLESS; >+ eMode = SC_COND_GREATER; > break; > case 4: >- eMode = SC_COND_EQGREATER; >+ eMode = SC_COND_EQLESS; > break; > case 5: >- eMode = SC_COND_NOTEQUAL; >+ eMode = SC_COND_EQGREATER; > break; > case 6: >+ eMode = SC_COND_NOTEQUAL; >+ break; >+ case 7: > aExpr2 = maEdVal2.GetText(); > eMode = SC_COND_BETWEEN; > if(aExpr2.isEmpty()) > return NULL; > break; >- case 7: >+ case 8: > eMode = SC_COND_NOTBETWEEN; > aExpr2 = maEdVal2.GetText(); > if(aExpr2.isEmpty()) > return NULL; > break; >- case 8: >+ case 9: > eMode = SC_COND_DUPLICATE; > break; >- case 9: >+ case 10: > eMode = SC_COND_NOTDUPLICATE; > break; >- case 10: >+ case 11: > eMode = SC_COND_TOP10; > break; >- case 11: >+ case 12: > eMode = SC_COND_BOTTOM10; > break; >- case 12: >+ case 13: > eMode = SC_COND_TOP_PERCENT; > break; >- case 13: >+ case 14: > eMode = SC_COND_BOTTOM_PERCENT; > break; >- case 14: >+ case 15: > eMode = SC_COND_ABOVE_AVERAGE; > break; >- case 15: >+ case 16: > eMode = SC_COND_BELOW_AVERAGE; > break; >- case 16: >+ case 17: > eMode = SC_COND_ABOVE_EQUAL_AVERAGE; > break; >- case 17: >+ case 18: > eMode = SC_COND_BELOW_EQUAL_AVERAGE; > break; >- case 18: >+ case 19: > eMode = SC_COND_ERROR; > break; >- case 19: >+ case 20: > eMode = SC_COND_NOERROR; > break; >- case 20: >+ case 21: > eMode = SC_COND_BEGINS_WITH; > break; >- case 21: >+ case 22: > eMode = SC_COND_ENDS_WITH; > break; >- case 22: >+ case 23: > eMode = SC_COND_CONTAINS_TEXT; > break; >- case 23: >+ case 24: > eMode = SC_COND_NOT_CONTAINS_TEXT; > break; > default: >@@ -401,6 +436,21 @@ ScFormatEntry* ScConditionFrmtEntry::createConditionEntry() const > } > > OUString aExpr1 = maEdVal1.GetText(); >+ ScCompiler aComp( mpDoc, maPos ); >+ aComp.SetGrammar( mpDoc->GetGrammar() ); >+ boost::scoped_ptr<ScTokenArray> pCode( aComp.CompileString(aExpr1) ); >+ >+ // If "equal to value", anything but a number is taken as text >+ if (eMode == SC_COND_EQUAL_VALUE) >+ { >+ eMode = SC_COND_EQUAL; // Always use the regular condition code >+ if (pCode->GetCodeError() || >+ (pCode->First()->GetType() != formula::svDouble && >+ pCode->First()->GetType() != formula::svString)) >+ { >+ aExpr1 = "\"" + aExpr1 + "\""; >+ } >+ } > > ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aExpr1, aExpr2, mpDoc, maPos, maLbStyle.GetSelectEntry()); > >@@ -421,8 +471,10 @@ void ScConditionFrmtEntry::SetActive() > { > maLbCondType.Show(); > maEdVal1.Show(); >- if(maLbCondType.GetSelectEntryPos() == 6 || maLbCondType.GetSelectEntryPos() == 7) >+ if (maLbCondType.GetSelectEntryPos() == 7 || maLbCondType.GetSelectEntryPos() == 8) >+ { > maEdVal2.Show(); >+ } > maFtStyle.Show(); > maLbStyle.Show(); > maWdPreview.Show(); >@@ -1048,18 +1100,18 @@ IMPL_LINK( ScColorScale3FrmtEntry, EntryTypeHdl, ListBox*, pBox ) > IMPL_LINK_NOARG( ScConditionFrmtEntry, ConditionTypeSelectHdl ) > { > sal_Int32 nSelectPos = maLbCondType.GetSelectEntryPos(); >- if(nSelectPos == 6 || nSelectPos == 7) >+ if(nSelectPos == 7 || nSelectPos == 8) > { > maEdVal1.Show(); > maEdVal2.Show(); > } >- else if(nSelectPos == 8 || nSelectPos == 9) >+ else if(nSelectPos == 9 || nSelectPos == 10) > { > maEdVal2.Hide(); > maEdVal1.Hide(); > } >- else if(nSelectPos <= 5 || (nSelectPos >= 10 && nSelectPos <= 13) >- || nSelectPos >= 18) >+ else if(nSelectPos <= 6 || (nSelectPos >= 11 && nSelectPos <= 14) >+ || nSelectPos >= 19) > { > maEdVal1.Show(); > maEdVal2.Hide(); >diff --git a/sc/source/ui/src/condformatdlg.src b/sc/source/ui/src/condformatdlg.src >index 4fe90cd..c273152 100644 >--- a/sc/source/ui/src/condformatdlg.src >+++ b/sc/source/ui/src/condformatdlg.src >@@ -56,7 +56,8 @@ Control RID_COND_ENTRY > DDExtraWidth = TRUE; > StringList [ en-US ] = > { >- "equal to"; >+ "equal to formula"; >+ "equal to value"; > "less than"; > "greater than"; > "less than or equal to";
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 42897
:
53498
|
109934
| 110355