[Libreoffice-commits] .: 7 commits - sc/inc sc/source test/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sat Nov 3 16:29:43 PDT 2012
sc/inc/conditio.hxx | 8 +++-
sc/inc/globstr.hrc | 6 ++-
sc/source/core/data/conditio.cxx | 47 ++++++++++++++++++++++---
sc/source/filter/excel/xecontent.cxx | 4 ++
sc/source/filter/oox/condformatbuffer.cxx | 14 +++++--
sc/source/ui/condformat/condformatdlgentry.cxx | 21 ++++++++++-
sc/source/ui/condformat/condformathelper.cxx | 4 ++
sc/source/ui/src/condformatdlg.src | 2 +
sc/source/ui/src/globstr.src | 8 ++++
test/source/sheet/xcellrangesquery.cxx | 14 +++----
10 files changed, 108 insertions(+), 20 deletions(-)
New commits:
commit aca832667b04186caee31ce551318bd833c5d950
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Nov 4 00:25:34 2012 +0100
fix the remaining UI places that needed update for new cond formats
Change-Id: I9df9a2adadf2e4181e1f601259eadf6bbc6007ca
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index 1f4a1f0..180b1fc 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -219,6 +219,14 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c
maEdVal1.Hide();
maLbCondType.SelectEntryPos(15);
break;
+ case SC_COND_ERROR:
+ maEdVal1.Hide();
+ maLbCondType.SelectEntryPos(16);
+ break;
+ case SC_COND_NOERROR:
+ maEdVal1.Hide();
+ maLbCondType.SelectEntryPos(17);
+ break;
case SC_COND_NONE:
break;
}
@@ -317,6 +325,12 @@ ScFormatEntry* ScConditionFrmtEntry::createConditionEntry() const
case 15:
eMode = SC_COND_BELOW_AVERAGE;
break;
+ case 16:
+ eMode = SC_COND_ERROR;
+ break;
+ case 17:
+ eMode = SC_COND_NOERROR;
+ break;
default:
assert(false); // this cannot happen
return NULL;
@@ -963,11 +977,16 @@ IMPL_LINK_NOARG( ScConditionFrmtEntry, ConditionTypeSelectHdl )
maEdVal2.Hide();
maEdVal1.Hide();
}
- else
+ else if(nSelectPos < 6 || (nSelectPos >= 10 && nSelectPos <= 13))
{
maEdVal1.Show();
maEdVal2.Hide();
}
+ else
+ {
+ maEdVal1.Hide();
+ maEdVal2.Hide();
+ }
return 0;
}
diff --git a/sc/source/ui/src/condformatdlg.src b/sc/source/ui/src/condformatdlg.src
index 51c791a..e0e0306 100644
--- a/sc/source/ui/src/condformatdlg.src
+++ b/sc/source/ui/src/condformatdlg.src
@@ -147,6 +147,8 @@ Control RID_COND_ENTRY
"bottom 10 percent";
"above average";
"below average";
+ "Error";
+ "No Error";
};
};
Edit ED_VAL1
commit 13b44426ce1035b2a64ef2b51b9ecaa246e8666d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Nov 4 00:24:35 2012 +0100
fix ooxml (no) error cond format import
Change-Id: Icb04a12a9db082e1cc64565cb8d31b50963b799e
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index b37fc07..eb0f1dc 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -823,7 +823,15 @@ void CondFormatRule::finalizeImport()
CellAddress aBaseAddr = mrCondFormat.getRanges().getBaseAddress();
ScAddress aPos;
ScUnoConversion::FillScAddress( aPos, aBaseAddr );
- if( (eOperator != SC_COND_NONE) && !maModel.maFormulas.empty() )
+
+ if( eOperator == SC_COND_ERROR || eOperator == SC_COND_NOERROR )
+ {
+ ScDocument& rDoc = getScDocument();
+ OUString aStyleName = getStyles().createDxfStyle( maModel.mnDxfId );
+ ScCondFormatEntry* pNewEntry = new ScCondFormatEntry( eOperator, NULL, NULL, &rDoc, aPos, aStyleName );
+ mpFormat->AddEntry(pNewEntry);
+ }
+ else if( (eOperator != SC_COND_NONE) && !maModel.maFormulas.empty() )
{
ScDocument& rDoc = getScDocument();
boost::scoped_ptr<ScTokenArray> pTokenArray2;
@@ -861,13 +869,6 @@ void CondFormatRule::finalizeImport()
ScCondFormatEntry* pNewEntry = new ScCondFormatEntry( eOperator, &aTokenArrayEqual, &aTokenArrayDev, &rDoc, aPos, aStyleName );
mpFormat->AddEntry(pNewEntry);
}
- else if( eOperator == SC_COND_ERROR || eOperator == SC_COND_NOERROR )
- {
- ScDocument& rDoc = getScDocument();
- OUString aStyleName = getStyles().createDxfStyle( maModel.mnDxfId );
- ScCondFormatEntry* pNewEntry = new ScCondFormatEntry( eOperator, NULL, NULL, &rDoc, aPos, aStyleName );
- mpFormat->AddEntry(pNewEntry);
- }
else if( eOperator == SC_COND_DUPLICATE || eOperator == SC_COND_NOTDUPLICATE )
{
ScDocument& rDoc = getScDocument();
commit 3a6b23a36bbc0fdbfc8cc609c6344dd98e3d3fe5
Author: Marcos Paulo de Souza <marcos.souza.org at gmail.com>
Date: Thu Nov 1 20:30:34 2012 -0200
Fix copy&paste in test
Also, change CPPUNIT_ASSERT_MESSAGE to CPPUNIT_ASSERT_EuAL_MESSAGE_EQUAL,
as suggested by Markus Mohrhard.
Change-Id: I1333e125dafaa98dafc493bd25eb20f0b09c792e
Suggested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
Signeg-off-by: Marcos Paulo de Souza <marcos.souza.org at gmail.com>
diff --git a/test/source/sheet/xcellrangesquery.cxx b/test/source/sheet/xcellrangesquery.cxx
index b1f55e0..c2d1a07 100644
--- a/test/source/sheet/xcellrangesquery.cxx
+++ b/test/source/sheet/xcellrangesquery.cxx
@@ -48,7 +48,7 @@ void XCellRangesQuery::testQueryColumnDifference()
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryColumnDifferences(table::CellAddress(0, 1, 1));
rtl::OUString aResult = xRanges->getRangeAddressesAsString();
std::cout << "testQueryColumnDifference: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- CPPUNIT_ASSERT_MESSAGE("testQueryColumnDifference", aResult == aExpected);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryColumnDifference", aResult, aExpected);
}
void XCellRangesQuery::testQueryContentDifference()
@@ -58,7 +58,7 @@ void XCellRangesQuery::testQueryContentDifference()
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryContentCells(sheet::CellFlags::VALUE);
rtl::OUString aResult = xRanges->getRangeAddressesAsString();
std::cout << "testQueryContentDifference: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- CPPUNIT_ASSERT_MESSAGE("testQueryContentDifference", aResult == aExpected);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryContentDifference", aResult, aExpected);
}
void XCellRangesQuery::testQueryEmptyCells()
@@ -68,7 +68,7 @@ void XCellRangesQuery::testQueryEmptyCells()
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryEmptyCells();
rtl::OUString aResult = xRanges->getRangeAddressesAsString();
std::cout << "testQueryEmptyCells: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- CPPUNIT_ASSERT_MESSAGE("testQueryEmptyCells", aResult == aExpected);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryEmptyCells", aResult, aExpected);
}
void XCellRangesQuery::testQueryFormulaCells()
@@ -78,7 +78,7 @@ void XCellRangesQuery::testQueryFormulaCells()
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryFormulaCells(sheet::CellFlags::FORMULA);
rtl::OUString aResult = xRanges->getRangeAddressesAsString();
std::cout << "testQueryFormulaCells: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryFormulaCells", aResult, aExpected);
}
void XCellRangesQuery::testQueryIntersection()
@@ -88,7 +88,7 @@ void XCellRangesQuery::testQueryIntersection()
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryIntersection(table::CellRangeAddress(0,3,3,7,7));
rtl::OUString aResult = xRanges->getRangeAddressesAsString();
std::cout << "testQueryIntersection: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryIntersection", aResult, aExpected);
}
void XCellRangesQuery::testQueryRowDifference()
@@ -98,7 +98,7 @@ void XCellRangesQuery::testQueryRowDifference()
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryRowDifferences(table::CellAddress(0,1,1));
rtl::OUString aResult = xRanges->getRangeAddressesAsString();
std::cout << "testQueryRowDifference: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryRowDifference", aResult, aExpected);
}
void XCellRangesQuery::testQueryVisibleCells()
@@ -108,7 +108,7 @@ void XCellRangesQuery::testQueryVisibleCells()
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryVisibleCells();
rtl::OUString aResult = xRanges->getRangeAddressesAsString();
std::cout << "testQueryVisibleCells: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryVisibleCells", aResult, aExpected);
}
}
commit 951910adf41d88bf12f916f5c5afcb48cc6be4f9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Nov 3 22:48:03 2012 +0100
add strings for (no) error cond formats
Change-Id: I0479fe508b02590da80a7fda5e4f4374da2e0294
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 2f2fb63..5e27e71 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -606,9 +606,11 @@
#define STR_COND_BOTTOM_PERCENT 481
#define STR_COND_ABOVE_AVERAGE 482
#define STR_COND_BELOW_AVERAGE 483
+#define STR_COND_ERROR 484
+#define STR_COND_NOERROR 485
-#define STR_ERR_CONDFORMAT_PROTECTED 484
+#define STR_ERR_CONDFORMAT_PROTECTED 486
-#define STR_COUNT 485
+#define STR_COUNT 487
#endif
diff --git a/sc/source/ui/condformat/condformathelper.cxx b/sc/source/ui/condformat/condformathelper.cxx
index c6b3ecd..3d8b5ee 100644
--- a/sc/source/ui/condformat/condformathelper.cxx
+++ b/sc/source/ui/condformat/condformathelper.cxx
@@ -72,6 +72,10 @@ rtl::OUString getExpression(sal_Int32 nIndex)
return ScGlobal::GetRscString(STR_COND_ABOVE_AVERAGE);
case 16:
return ScGlobal::GetRscString(STR_COND_BELOW_AVERAGE);
+ case 17:
+ return ScGlobal::GetRscString(STR_COND_ERROR);
+ case 18:
+ return ScGlobal::GetRscString(STR_COND_NOERROR);
}
return rtl::OUString();
}
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index bbb89a9..2212b42 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -1923,6 +1923,14 @@ Resource RID_GLOBSTR
{
Text [ en-US ] = "Below Average";
};
+ String STR_COND_ERROR
+ {
+ Text [ en-US ] = "an Error code";
+ };
+ String STR_COND_NOERROR
+ {
+ Text [ en-US ] = "not an Error code";
+ };
String STR_ERR_CONDFORMAT_PROTECTED
{
Text [ en-US ] = "Conditional Formats can not be created, deleted or changed in protected sheets!";
commit 97b6b6f4d0e6293759a02db089c9210b8c7287c1
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Nov 3 21:56:47 2012 +0100
add (no) error cond format export to ooxml
Change-Id: I11537a22f72130d796887581611449c849ab0876
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 9672dc4..ffca41e 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -848,6 +848,10 @@ const char* GetTypeString(ScConditionMode eMode)
return "uniqueValues";
case SC_COND_DUPLICATE:
return "duplicateValues";
+ case SC_COND_ERROR:
+ return "containsErrors";
+ case SC_COND_NOERROR:
+ return "notContainsErrors";
default:
return "cellIs";
}
commit 52a6d6f5c9af1e5ad0a884eb221a5429a954d887
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Nov 3 21:56:05 2012 +0100
add (no) error cond format import from ooxml
Change-Id: I668a9b843cf281a167ca87d24b717c782bbc1e1b
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index 9068ec1..b37fc07 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -735,10 +735,10 @@ void CondFormatRule::finalizeImport()
aReplaceFormula = "LEN(TRIM(#B))>0";
break;
case XML_containsErrors:
- aReplaceFormula = "ISERROR(#B)";
+ eOperator = SC_COND_ERROR;
break;
case XML_notContainsErrors:
- aReplaceFormula = "NOT(ISERROR(#B))";
+ eOperator = SC_COND_NOERROR;
break;
case XML_top10:
if(maModel.mbPercent)
@@ -861,6 +861,13 @@ void CondFormatRule::finalizeImport()
ScCondFormatEntry* pNewEntry = new ScCondFormatEntry( eOperator, &aTokenArrayEqual, &aTokenArrayDev, &rDoc, aPos, aStyleName );
mpFormat->AddEntry(pNewEntry);
}
+ else if( eOperator == SC_COND_ERROR || eOperator == SC_COND_NOERROR )
+ {
+ ScDocument& rDoc = getScDocument();
+ OUString aStyleName = getStyles().createDxfStyle( maModel.mnDxfId );
+ ScCondFormatEntry* pNewEntry = new ScCondFormatEntry( eOperator, NULL, NULL, &rDoc, aPos, aStyleName );
+ mpFormat->AddEntry(pNewEntry);
+ }
else if( eOperator == SC_COND_DUPLICATE || eOperator == SC_COND_NOTDUPLICATE )
{
ScDocument& rDoc = getScDocument();
commit 947003702ecdf8d093f37a43f669a6b7aee95bbf
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Nov 3 21:55:22 2012 +0100
add error and not error condition
Change-Id: Iaf087a470fa7353877ac726af907e6d4a31cba99
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index f765639..72f1fc8 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -76,6 +76,8 @@ enum ScConditionMode
SC_COND_BOTTOM_PERCENT,
SC_COND_ABOVE_AVERAGE,
SC_COND_BELOW_AVERAGE,
+ SC_COND_ERROR,
+ SC_COND_NOERROR,
SC_COND_NONE
};
@@ -183,8 +185,8 @@ class SC_DLLPUBLIC ScConditionEntry : public ScFormatEntry
bool bTextToReal );
void Interpret( const ScAddress& rPos );
- bool IsValid( double nArg ) const;
- bool IsValidStr( const String& rArg ) const;
+ bool IsValid( double nArg, const ScAddress& rPos ) const;
+ bool IsValidStr( const String& rArg, const ScAddress& rPos ) const;
public:
ScConditionEntry( ScConditionMode eOper,
@@ -262,6 +264,8 @@ private:
bool IsAboveAverage( double nArg ) const;
bool IsBelowAverage( double nArg ) const;
+ bool IsError( const ScAddress& rPos ) const;
+
void FillCache() const;
struct ScConditionEntryCache
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 3557e06..f660b3b 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -969,7 +969,32 @@ bool ScConditionEntry::IsAboveAverage( double nArg ) const
return (nArg > nSum/mpCache->nValueItems);
}
-bool ScConditionEntry::IsValid( double nArg ) const
+bool ScConditionEntry::IsError( const ScAddress& rPos ) const
+{
+ ScBaseCell* pCell = mpDoc->GetCell(rPos);
+ if(!pCell)
+ return false;
+
+ switch(pCell->GetCellType())
+ {
+ case CELLTYPE_VALUE:
+ return false;
+ case CELLTYPE_FORMULA:
+ {
+ ScFormulaCell* pFormulaCell = static_cast<ScFormulaCell*>(pCell);
+ if(pFormulaCell->GetErrCode())
+ return true;
+ }
+ case CELLTYPE_STRING:
+ case CELLTYPE_EDIT:
+ return false;
+ default:
+ break;
+ }
+ return false;
+}
+
+bool ScConditionEntry::IsValid( double nArg, const ScAddress& rPos ) const
{
// Interpret muss schon gerufen sein
@@ -1057,6 +1082,12 @@ bool ScConditionEntry::IsValid( double nArg ) const
case SC_COND_BELOW_AVERAGE:
bValid = IsBelowAverage( nArg );
break;
+ case SC_COND_ERROR:
+ case SC_COND_NOERROR:
+ bValid = IsError( rPos );
+ if( eOp == SC_COND_NOERROR )
+ bValid = !bValid;
+ break;
default:
OSL_FAIL("unbekannte Operation bei ScConditionEntry");
break;
@@ -1064,7 +1095,7 @@ bool ScConditionEntry::IsValid( double nArg ) const
return bValid;
}
-bool ScConditionEntry::IsValidStr( const String& rArg ) const
+bool ScConditionEntry::IsValidStr( const String& rArg, const ScAddress& rPos ) const
{
bool bValid = false;
// Interpret muss schon gerufen sein
@@ -1085,7 +1116,7 @@ bool ScConditionEntry::IsValidStr( const String& rArg ) const
// Wenn Bedingung Zahl enthaelt, immer FALSE, ausser bei "ungleich"
- if ( !bIsStr1 )
+ if ( !bIsStr1 && (eOp != SC_COND_ERROR && eOp != SC_COND_NOERROR) )
return ( eOp == SC_COND_NOTEQUAL );
if ( eOp == SC_COND_BETWEEN || eOp == SC_COND_NOTBETWEEN )
if ( !bIsStr2 )
@@ -1119,6 +1150,12 @@ bool ScConditionEntry::IsValidStr( const String& rArg ) const
case SC_COND_ABOVE_AVERAGE:
case SC_COND_BELOW_AVERAGE:
return false;
+ case SC_COND_ERROR:
+ case SC_COND_NOERROR:
+ bValid = IsError( rPos );
+ if(eOp == SC_COND_NOERROR)
+ bValid = !bValid;
+ break;
default:
{
sal_Int32 nCompare = ScGlobal::GetCollator()->compareString(
@@ -1165,9 +1202,9 @@ bool ScConditionEntry::IsCellValid( ScBaseCell* pCell, const ScAddress& rPos ) c
rtl::OUString aArgStr;
bool bVal = lcl_GetCellContent( pCell, bIsStr1, nArg, aArgStr );
if (bVal)
- return IsValid( nArg );
+ return IsValid( nArg, rPos );
else
- return IsValidStr( aArgStr );
+ return IsValidStr( aArgStr, rPos );
}
String ScConditionEntry::GetExpression( const ScAddress& rCursor, sal_uInt16 nIndex,
More information about the Libreoffice-commits
mailing list