[Libreoffice-commits] .: 21 commits - sc/inc sc/source xmloff/inc xmloff/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Nov 2 06:59:48 PDT 2012
sc/inc/conditio.hxx | 30 +++-
sc/inc/globstr.hrc | 10 +
sc/source/core/data/conditio.cxx | 165 +++++++++++++++++++++++--
sc/source/core/data/fillinfo.cxx | 3
sc/source/filter/excel/xecontent.cxx | 22 ++-
sc/source/filter/inc/condformatbuffer.hxx | 1
sc/source/filter/oox/condformatbuffer.cxx | 87 +++++++++++--
sc/source/filter/xml/xmlcondformat.cxx | 129 +++++++++++++------
sc/source/filter/xml/xmlcondformat.hxx | 48 ++++---
sc/source/filter/xml/xmlexprt.cxx | 43 ++++++
sc/source/filter/xml/xmlimprt.cxx | 31 +++-
sc/source/filter/xml/xmlimprt.hxx | 19 ++
sc/source/ui/condformat/condformatdlgentry.cxx | 37 +++++
sc/source/ui/condformat/condformathelper.cxx | 14 ++
sc/source/ui/src/condformatdlg.src | 6
sc/source/ui/src/globstr.src | 24 +++
xmloff/inc/xmloff/xmltoken.hxx | 3
xmloff/source/core/xmltoken.cxx | 3
18 files changed, 569 insertions(+), 106 deletions(-)
New commits:
commit c0350ca23c3c87e29aab5be0ebb8b44db6834977
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 2 14:54:23 2012 +0100
fix unique/duplicate cond format export to ooxml
Change-Id: Ie1ac8d8df351d149851cff8b7344335b30d46b83
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 6c317e9..e278a09 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -844,6 +844,10 @@ const char* GetTypeString(ScConditionMode eMode)
case SC_COND_ABOVE_AVERAGE:
case SC_COND_BELOW_AVERAGE:
return "aboveAverage";
+ case SC_COND_NOTDUPLICATE:
+ return "uniqueValues";
+ case SC_COND_DUPLICATE:
+ return "duplicateValues";
default:
return "cellIs";
}
commit 1c07b0b6c32d2caacdaa11e47350b1c4f854a0b1
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 2 14:44:16 2012 +0100
fix duplicate/unique cond format import from ooxml
Change-Id: I3ceecd5f066fedf67f97c8c122b03d3d0f2fbb0a
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index 7798817..9068ec1 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -667,7 +667,9 @@ void CondFormatRule::finalizeImport()
break;
case XML_duplicateValues:
eOperator = static_cast<ScConditionMode>(CondFormatBuffer::convertToInternalOperator( XML_duplicateValues ));
- aReplaceFormula = " ";
+ break;
+ case XML_uniqueValues:
+ eOperator = static_cast<ScConditionMode>(CondFormatBuffer::convertToInternalOperator( XML_uniqueValues ));
break;
case XML_expression:
eOperator = SC_COND_DIRECT;
@@ -815,8 +817,7 @@ void CondFormatRule::finalizeImport()
// set the replacement formula
maModel.maFormulas.clear();
appendFormula( aReplaceFormula );
- if( eOperator != SC_COND_DUPLICATE )
- eOperator = SC_COND_DIRECT;
+ eOperator = SC_COND_DIRECT;
}
CellAddress aBaseAddr = mrCondFormat.getRanges().getBaseAddress();
@@ -860,6 +861,13 @@ void CondFormatRule::finalizeImport()
ScCondFormatEntry* pNewEntry = new ScCondFormatEntry( eOperator, &aTokenArrayEqual, &aTokenArrayDev, &rDoc, aPos, aStyleName );
mpFormat->AddEntry(pNewEntry);
}
+ else if( eOperator == SC_COND_DUPLICATE || eOperator == SC_COND_NOTDUPLICATE )
+ {
+ ScDocument& rDoc = getScDocument();
+ OUString aStyleName = getStyles().createDxfStyle( maModel.mnDxfId );
+ ScCondFormatEntry* pNewEntry = new ScCondFormatEntry( eOperator, NULL, NULL, &rDoc, aPos, aStyleName );
+ mpFormat->AddEntry(pNewEntry);
+ }
else if( mpColor )
{
ScDocument& rDoc = getScDocument();
@@ -1041,6 +1049,7 @@ sal_Int32 CondFormatBuffer::convertToInternalOperator( sal_Int32 nToken )
case XML_notBetween: return SC_COND_NOTBETWEEN;
case XML_notEqual: return SC_COND_NOTEQUAL;
case XML_duplicateValues: return SC_COND_DUPLICATE;
+ case XML_uniqueValues: return SC_COND_NOTDUPLICATE;
}
return ConditionOperator2::NONE;
}
commit 7cc964a33e2b5c230c46ae279ea9af9f46bdc89a
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 2 14:31:57 2012 +0100
start exporting the new cond formats to ooxml
Change-Id: I8dbc07719263b17f2066c2dfd6e0bfef70630d53
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 91bd918..6c317e9 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -832,9 +832,21 @@ const char* GetOperatorString(ScConditionMode eMode, bool& bFrmla2)
const char* GetTypeString(ScConditionMode eMode)
{
- if (eMode == SC_COND_DIRECT)
- return "expression";
- return "cellIs";
+ switch(eMode)
+ {
+ case SC_COND_DIRECT:
+ return "expression";
+ case SC_COND_TOP10:
+ case SC_COND_TOP_PERCENT:
+ case SC_COND_BOTTOM10:
+ case SC_COND_BOTTOM_PERCENT:
+ return "top10";
+ case SC_COND_ABOVE_AVERAGE:
+ case SC_COND_BELOW_AVERAGE:
+ return "aboveAverage";
+ default:
+ return "cellIs";
+ }
}
}
commit 95cf9d5a48232e45cded632ef440420db1c26866
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 2 14:31:01 2012 +0100
warn when trying to export a conditional format that is not supported
Change-Id: I617613e745c16558fd2ef97d4d072f00d59b8c5d
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index fda1912..069b238 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3910,6 +3910,8 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
break;
case SC_COND_NONE:
continue;
+ default:
+ SAL_WARN("sc", "unimplemented conditional format export");
}
rtl::OUString sStyle = pEntry->GetStyle();
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_APPLY_STYLE_NAME, sStyle);
commit f4cac2d83bec0d3dc6aa8227db2c29ed9b658581
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 2 14:18:08 2012 +0100
also add the new conditional formats to the manage cond format dlg
Change-Id: I4275ca59917d7dc5cd36f948ab28e564bb9bfb56
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 9887d8e..2f2fb63 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -600,9 +600,15 @@
#define STR_COND_NOTBETWEEN 475
#define STR_COND_UNIQUE 476
#define STR_COND_DUPLICATE 477
+#define STR_COND_TOP10 478
+#define STR_COND_BOTTOM10 479
+#define STR_COND_TOP_PERCENT 480
+#define STR_COND_BOTTOM_PERCENT 481
+#define STR_COND_ABOVE_AVERAGE 482
+#define STR_COND_BELOW_AVERAGE 483
-#define STR_ERR_CONDFORMAT_PROTECTED 478
+#define STR_ERR_CONDFORMAT_PROTECTED 484
-#define STR_COUNT 479
+#define STR_COUNT 485
#endif
diff --git a/sc/source/ui/condformat/condformathelper.cxx b/sc/source/ui/condformat/condformathelper.cxx
index 2180d51..c6b3ecd 100644
--- a/sc/source/ui/condformat/condformathelper.cxx
+++ b/sc/source/ui/condformat/condformathelper.cxx
@@ -58,6 +58,20 @@ rtl::OUString getExpression(sal_Int32 nIndex)
return ScGlobal::GetRscString(STR_COND_DUPLICATE);
case 9:
return ScGlobal::GetRscString(STR_COND_UNIQUE);
+ case 10:
+ assert(false);
+ case 11:
+ return ScGlobal::GetRscString(STR_COND_TOP10);
+ case 12:
+ return ScGlobal::GetRscString(STR_COND_BOTTOM10);
+ case 13:
+ return ScGlobal::GetRscString(STR_COND_TOP_PERCENT);
+ case 14:
+ return ScGlobal::GetRscString(STR_COND_BOTTOM_PERCENT);
+ case 15:
+ return ScGlobal::GetRscString(STR_COND_ABOVE_AVERAGE);
+ case 16:
+ return ScGlobal::GetRscString(STR_COND_BELOW_AVERAGE);
}
return rtl::OUString();
}
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index 5091477..bbb89a9 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -1899,6 +1899,30 @@ Resource RID_GLOBSTR
{
Text [ en-US ] = "Formula is";
};
+ String STR_COND_TOP10
+ {
+ Text [ en-US ] = "Top Elements";
+ };
+ String STR_COND_BOTTOM10
+ {
+ Text [ en-US ] = "Bottom Elements";
+ };
+ String STR_COND_TOP_PERCENT
+ {
+ Text [ en-US ] = "Top Percent";
+ };
+ String STR_COND_BOTTOM_PERCENT
+ {
+ Text [ en-US ] = "Bottom Percent";
+ };
+ String STR_COND_ABOVE_AVERAGE
+ {
+ Text [ en-US ] = "Above Average";
+ };
+ String STR_COND_BELOW_AVERAGE
+ {
+ Text [ en-US ] = "Below Average";
+ };
String STR_ERR_CONDFORMAT_PROTECTED
{
Text [ en-US ] = "Conditional Formats can not be created, deleted or changed in protected sheets!";
commit bc55b6e101a03d091d5061aae6fcc8bb26950da1
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 2 12:20:33 2012 +0100
add the new conditional formats to the dialog
Change-Id: Ia8c98626cf077abcf705e3d8e37478a32673622e
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index 97debc7..77f51d0 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -196,6 +196,24 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c
assert(false);
//maLbType.SelectEntryPos(2);
break;
+ case SC_COND_TOP10:
+ maLbCondType.SelectEntryPos(10);
+ break;
+ case SC_COND_BOTTOM10:
+ maLbCondType.SelectEntryPos(11);
+ break;
+ case SC_COND_TOP_PERCENT:
+ maLbCondType.SelectEntryPos(12);
+ break;
+ case SC_COND_BOTTOM_PERCENT:
+ maLbCondType.SelectEntryPos(13);
+ break;
+ case SC_COND_ABOVE_AVERAGE:
+ maLbCondType.SelectEntryPos(14);
+ break;
+ case SC_COND_BELOW_AVERAGE:
+ maLbCondType.SelectEntryPos(15);
+ break;
case SC_COND_NONE:
break;
}
@@ -276,6 +294,24 @@ ScFormatEntry* ScConditionFrmtEntry::createConditionEntry() const
case 9:
eMode = SC_COND_NOTDUPLICATE;
break;
+ case 10:
+ eMode = SC_COND_TOP10;
+ break;
+ case 11:
+ eMode = SC_COND_BOTTOM10;
+ break;
+ case 12:
+ eMode = SC_COND_TOP_PERCENT;
+ break;
+ case 13:
+ eMode = SC_COND_BOTTOM_PERCENT;
+ break;
+ case 14:
+ eMode = SC_COND_ABOVE_AVERAGE;
+ break;
+ case 15:
+ eMode = SC_COND_BELOW_AVERAGE;
+ break;
default:
assert(false); // this cannot happen
return NULL;
diff --git a/sc/source/ui/src/condformatdlg.src b/sc/source/ui/src/condformatdlg.src
index 5bd45a0..51c791a 100644
--- a/sc/source/ui/src/condformatdlg.src
+++ b/sc/source/ui/src/condformatdlg.src
@@ -141,6 +141,12 @@ Control RID_COND_ENTRY
"not between";
"duplicate";
"not duplicate";
+ "top 10 elements";
+ "bottom 10 elements";
+ "top 10 percent";
+ "bottom 10 percent";
+ "above average";
+ "below average";
};
};
Edit ED_VAL1
commit 931d715de533f0b4712eb2d7420359548b6f7c64
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 2 12:05:30 2012 +0100
this case should never happen, use assert to be sure
Change-Id: I4e8b3de643e32dffa1aea9e512b2945e34dac95a
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index 75fec8c..97debc7 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -193,6 +193,7 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c
maLbCondType.SelectEntryPos(9);
break;
case SC_COND_DIRECT:
+ assert(false);
//maLbType.SelectEntryPos(2);
break;
case SC_COND_NONE:
commit 2a38429ce0b3ef389bd58590eb42e6edf6bdddef
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 2 12:04:56 2012 +0100
we don't need to pass this parameter
Change-Id: Ia330894b43c94d1dee09e7013999d22114ca52ac
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index cebb8f4..f765639 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -254,15 +254,15 @@ protected:
private:
- bool IsDuplicate(double nArg, const rtl::OUString& rStr, const ScRangeList& rRanges) const;
- bool IsTopNElement( double nArg, const ScRangeList& rRanges ) const;
- bool IsTopNPercent( double nArg, const ScRangeList& rRanges ) const;
- bool IsBottomNElement( double nArg, const ScRangeList& rRanges ) const;
- bool IsBottomNPercent( double nArg, const ScRangeList& rRanges ) const;
- bool IsAboveAverage( double nArg, const ScRangeList& rRanges ) const;
- bool IsBelowAverage( double nArg, const ScRangeList& rRanges ) const;
-
- void FillCache(const ScRangeList& rRanges) const;
+ bool IsDuplicate(double nArg, const rtl::OUString& rStr) const;
+ bool IsTopNElement( double nArg ) const;
+ bool IsTopNPercent( double nArg ) const;
+ bool IsBottomNElement( double nArg ) const;
+ bool IsBottomNPercent( double nArg ) const;
+ bool IsAboveAverage( double nArg ) const;
+ bool IsBelowAverage( double nArg ) const;
+
+ void FillCache() const;
struct ScConditionEntryCache
{
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index c0403f1..3557e06 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -768,10 +768,11 @@ static bool lcl_GetCellContent( ScBaseCell* pCell, bool bIsStr1, double& rArg, r
return bVal;
}
-void ScConditionEntry::FillCache( const ScRangeList& rRanges ) const
+void ScConditionEntry::FillCache() const
{
if(!mpCache)
{
+ const ScRangeList& rRanges = pCondFormat->GetRange();
mpCache.reset(new ScConditionEntryCache);
size_t nListCount = rRanges.size();
for( size_t i = 0; i < nListCount; i++ )
@@ -822,9 +823,9 @@ void ScConditionEntry::FillCache( const ScRangeList& rRanges ) const
}
}
-bool ScConditionEntry::IsDuplicate( double nArg, const rtl::OUString& rStr, const ScRangeList& rRanges ) const
+bool ScConditionEntry::IsDuplicate( double nArg, const rtl::OUString& rStr ) const
{
- FillCache( rRanges );
+ FillCache();
if(rStr.isEmpty())
{
@@ -854,9 +855,9 @@ bool ScConditionEntry::IsDuplicate( double nArg, const rtl::OUString& rStr, cons
}
}
-bool ScConditionEntry::IsTopNElement( double nArg, const ScRangeList& rRanges ) const
+bool ScConditionEntry::IsTopNElement( double nArg ) const
{
- FillCache( rRanges );
+ FillCache();
if(mpCache->nValueItems <= nVal1)
return true;
@@ -875,9 +876,9 @@ bool ScConditionEntry::IsTopNElement( double nArg, const ScRangeList& rRanges )
return true;
}
-bool ScConditionEntry::IsBottomNElement( double nArg, const ScRangeList& rRanges ) const
+bool ScConditionEntry::IsBottomNElement( double nArg ) const
{
- FillCache( rRanges );
+ FillCache();
if(mpCache->nValueItems <= nVal1)
return true;
@@ -896,9 +897,9 @@ bool ScConditionEntry::IsBottomNElement( double nArg, const ScRangeList& rRanges
return true;
}
-bool ScConditionEntry::IsTopNPercent( double nArg, const ScRangeList& rRanges ) const
+bool ScConditionEntry::IsTopNPercent( double nArg ) const
{
- FillCache( rRanges );
+ FillCache();
size_t nCells = 0;
size_t nLimitCells = static_cast<size_t>(mpCache->nValueItems*nVal1/100);
@@ -915,9 +916,9 @@ bool ScConditionEntry::IsTopNPercent( double nArg, const ScRangeList& rRanges )
return true;
}
-bool ScConditionEntry::IsBottomNPercent( double nArg, const ScRangeList& rRanges ) const
+bool ScConditionEntry::IsBottomNPercent( double nArg ) const
{
- FillCache( rRanges );
+ FillCache();
size_t nCells = 0;
size_t nLimitCells = static_cast<size_t>(mpCache->nValueItems*nVal1/100);
@@ -934,9 +935,9 @@ bool ScConditionEntry::IsBottomNPercent( double nArg, const ScRangeList& rRanges
return true;
}
-bool ScConditionEntry::IsBelowAverage( double nArg, const ScRangeList& rRanges ) const
+bool ScConditionEntry::IsBelowAverage( double nArg ) const
{
- FillCache( rRanges );
+ FillCache();
double nSum = 0;
for(ScConditionEntryCache::ValueCacheType::const_iterator itr = mpCache->maValues.begin(),
@@ -951,9 +952,9 @@ bool ScConditionEntry::IsBelowAverage( double nArg, const ScRangeList& rRanges )
return (nArg < nSum/mpCache->nValueItems);
}
-bool ScConditionEntry::IsAboveAverage( double nArg, const ScRangeList& rRanges ) const
+bool ScConditionEntry::IsAboveAverage( double nArg ) const
{
- FillCache( rRanges );
+ FillCache();
double nSum = 0;
for(ScConditionEntryCache::ValueCacheType::const_iterator itr = mpCache->maValues.begin(),
@@ -1030,8 +1031,7 @@ bool ScConditionEntry::IsValid( double nArg ) const
case SC_COND_NOTDUPLICATE:
if( pCondFormat )
{
- const ScRangeList& aRanges = pCondFormat->GetRange();
- bValid = IsDuplicate( nArg, rtl::OUString(), aRanges );
+ bValid = IsDuplicate( nArg, rtl::OUString() );
if( eOp == SC_COND_NOTDUPLICATE )
bValid = !bValid;
}
@@ -1040,22 +1040,22 @@ bool ScConditionEntry::IsValid( double nArg ) const
bValid = !::rtl::math::approxEqual( nComp1, 0.0 );
break;
case SC_COND_TOP10:
- bValid = IsTopNElement( nArg, pCondFormat->GetRange() );
+ bValid = IsTopNElement( nArg );
break;
case SC_COND_BOTTOM10:
- bValid = IsBottomNElement( nArg, pCondFormat->GetRange() );
+ bValid = IsBottomNElement( nArg );
break;
case SC_COND_TOP_PERCENT:
- bValid = IsTopNPercent( nArg, pCondFormat->GetRange() );
+ bValid = IsTopNPercent( nArg );
break;
case SC_COND_BOTTOM_PERCENT:
- bValid = IsBottomNPercent( nArg, pCondFormat->GetRange() );
+ bValid = IsBottomNPercent( nArg );
break;
case SC_COND_ABOVE_AVERAGE:
- bValid = IsAboveAverage( nArg, pCondFormat->GetRange() );
+ bValid = IsAboveAverage( nArg );
break;
case SC_COND_BELOW_AVERAGE:
- bValid = IsBelowAverage( nArg, pCondFormat->GetRange() );
+ bValid = IsBelowAverage( nArg );
break;
default:
OSL_FAIL("unbekannte Operation bei ScConditionEntry");
@@ -1076,8 +1076,7 @@ bool ScConditionEntry::IsValidStr( const String& rArg ) const
{
if( pCondFormat && rArg.Len() )
{
- const ScRangeList& aRanges = pCondFormat->GetRange();
- bValid = IsDuplicate( 0.0, rArg, aRanges );
+ bValid = IsDuplicate( 0.0, rArg );
if( eOp == SC_COND_NOTDUPLICATE )
bValid = !bValid;
return bValid;
commit 6e78db23c1194a371961e2136a62fb149a8a764d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 2 01:55:26 2012 +0100
implement the above/below average import from ooxml
Change-Id: I75421cd66469d73a2614a6528801f9d1e17a0901
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index a8800a6..7798817 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -755,8 +755,10 @@ void CondFormatRule::finalizeImport()
}
break;
case XML_aboveAverage:
- if( maModel.mnStdDev == 0 )
- aReplaceFormula = "#B#CAVERAGE(#R)";
+ if(maModel.mbAboveAverage)
+ eOperator = SC_COND_ABOVE_AVERAGE;
+ else
+ eOperator = SC_COND_BELOW_AVERAGE;
break;
case XML_colorScale:
break;
@@ -837,8 +839,8 @@ void CondFormatRule::finalizeImport()
&aTokenArray, pTokenArray2.get(), &rDoc, aPos, aStyleName);
mpFormat->AddEntry(pNewEntry);
}
- else if ( eOperator == SC_COND_TOP10 || SC_COND_BOTTOM10 ||
- SC_COND_TOP_PERCENT || SC_COND_BOTTOM_PERCENT )
+ else if ( eOperator == SC_COND_TOP10 || eOperator == SC_COND_BOTTOM10 ||
+ eOperator == SC_COND_TOP_PERCENT || eOperator == SC_COND_BOTTOM_PERCENT )
{
ScDocument& rDoc = getScDocument();
ScTokenArray aTokenArray;
@@ -847,6 +849,17 @@ void CondFormatRule::finalizeImport()
ScCondFormatEntry* pNewEntry = new ScCondFormatEntry( eOperator, &aTokenArray, NULL, &rDoc, aPos, aStyleName );
mpFormat->AddEntry(pNewEntry);
}
+ else if( eOperator == SC_COND_ABOVE_AVERAGE || eOperator == SC_COND_BELOW_AVERAGE )
+ {
+ ScDocument& rDoc = getScDocument();
+ ScTokenArray aTokenArrayEqual;
+ aTokenArrayEqual.AddDouble( maModel.mbEqualAverage );
+ ScTokenArray aTokenArrayDev;
+ aTokenArrayDev.AddDouble( maModel.mnStdDev );
+ OUString aStyleName = getStyles().createDxfStyle( maModel.mnDxfId );
+ ScCondFormatEntry* pNewEntry = new ScCondFormatEntry( eOperator, &aTokenArrayEqual, &aTokenArrayDev, &rDoc, aPos, aStyleName );
+ mpFormat->AddEntry(pNewEntry);
+ }
else if( mpColor )
{
ScDocument& rDoc = getScDocument();
commit 44990c104508c889e459ea6fea3cc13da2fc34a7
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 2 01:47:49 2012 +0100
implement above/below average conditional format
Change-Id: I9ea745818552a8e2553b0de17f2e83d8b8da3d3b
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 51b3dba..cebb8f4 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -74,6 +74,8 @@ enum ScConditionMode
SC_COND_BOTTOM10,
SC_COND_TOP_PERCENT,
SC_COND_BOTTOM_PERCENT,
+ SC_COND_ABOVE_AVERAGE,
+ SC_COND_BELOW_AVERAGE,
SC_COND_NONE
};
@@ -257,6 +259,8 @@ private:
bool IsTopNPercent( double nArg, const ScRangeList& rRanges ) const;
bool IsBottomNElement( double nArg, const ScRangeList& rRanges ) const;
bool IsBottomNPercent( double nArg, const ScRangeList& rRanges ) const;
+ bool IsAboveAverage( double nArg, const ScRangeList& rRanges ) const;
+ bool IsBelowAverage( double nArg, const ScRangeList& rRanges ) const;
void FillCache(const ScRangeList& rRanges) const;
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 6e7724c..c0403f1 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -934,6 +934,40 @@ bool ScConditionEntry::IsBottomNPercent( double nArg, const ScRangeList& rRanges
return true;
}
+bool ScConditionEntry::IsBelowAverage( double nArg, const ScRangeList& rRanges ) const
+{
+ FillCache( rRanges );
+
+ double nSum = 0;
+ for(ScConditionEntryCache::ValueCacheType::const_iterator itr = mpCache->maValues.begin(),
+ itrEnd = mpCache->maValues.end(); itr != itrEnd; ++itr)
+ {
+ nSum += itr->first * itr->second;
+ }
+
+ if(nVal1)
+ return (nArg <= nSum/mpCache->nValueItems);
+ else
+ return (nArg < nSum/mpCache->nValueItems);
+}
+
+bool ScConditionEntry::IsAboveAverage( double nArg, const ScRangeList& rRanges ) const
+{
+ FillCache( rRanges );
+
+ double nSum = 0;
+ for(ScConditionEntryCache::ValueCacheType::const_iterator itr = mpCache->maValues.begin(),
+ itrEnd = mpCache->maValues.end(); itr != itrEnd; ++itr)
+ {
+ nSum += itr->first * itr->second;
+ }
+
+ if(nVal1)
+ return (nArg >= nSum/mpCache->nValueItems);
+ else
+ return (nArg > nSum/mpCache->nValueItems);
+}
+
bool ScConditionEntry::IsValid( double nArg ) const
{
// Interpret muss schon gerufen sein
@@ -1017,6 +1051,12 @@ bool ScConditionEntry::IsValid( double nArg ) const
case SC_COND_BOTTOM_PERCENT:
bValid = IsBottomNPercent( nArg, pCondFormat->GetRange() );
break;
+ case SC_COND_ABOVE_AVERAGE:
+ bValid = IsAboveAverage( nArg, pCondFormat->GetRange() );
+ break;
+ case SC_COND_BELOW_AVERAGE:
+ bValid = IsBelowAverage( nArg, pCondFormat->GetRange() );
+ break;
default:
OSL_FAIL("unbekannte Operation bei ScConditionEntry");
break;
@@ -1077,6 +1117,8 @@ bool ScConditionEntry::IsValidStr( const String& rArg ) const
case SC_COND_BOTTOM_PERCENT:
case SC_COND_TOP10:
case SC_COND_BOTTOM10:
+ case SC_COND_ABOVE_AVERAGE:
+ case SC_COND_BELOW_AVERAGE:
return false;
default:
{
commit f1fdd5adb63f84fe7c65374b1a7cf9bd96e7d6b6
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 2 00:30:25 2012 +0100
implement ooxml import for new conditional formats
Change-Id: Ia854ef42c23ac8dd4f6d4afa180ecc57b741a3b8
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index c145210..a8800a6 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -739,10 +739,20 @@ void CondFormatRule::finalizeImport()
aReplaceFormula = "NOT(ISERROR(#B))";
break;
case XML_top10:
- if( maModel.mbPercent )
- aReplaceFormula = "RANK(#B,#R,#M)/COUNT(#R)<=#K%";
+ if(maModel.mbPercent)
+ {
+ if(maModel.mbBottom)
+ eOperator = SC_COND_BOTTOM_PERCENT;
+ else
+ eOperator = SC_COND_TOP_PERCENT;
+ }
else
- aReplaceFormula = "RANK(#B,#R,#M)<=#K";
+ {
+ if(maModel.mbBottom)
+ eOperator = SC_COND_BOTTOM10;
+ else
+ eOperator = SC_COND_TOP10;
+ }
break;
case XML_aboveAverage:
if( maModel.mnStdDev == 0 )
@@ -827,6 +837,16 @@ void CondFormatRule::finalizeImport()
&aTokenArray, pTokenArray2.get(), &rDoc, aPos, aStyleName);
mpFormat->AddEntry(pNewEntry);
}
+ else if ( eOperator == SC_COND_TOP10 || SC_COND_BOTTOM10 ||
+ SC_COND_TOP_PERCENT || SC_COND_BOTTOM_PERCENT )
+ {
+ ScDocument& rDoc = getScDocument();
+ ScTokenArray aTokenArray;
+ aTokenArray.AddDouble( maModel.mnRank );
+ OUString aStyleName = getStyles().createDxfStyle( maModel.mnDxfId );
+ ScCondFormatEntry* pNewEntry = new ScCondFormatEntry( eOperator, &aTokenArray, NULL, &rDoc, aPos, aStyleName );
+ mpFormat->AddEntry(pNewEntry);
+ }
else if( mpColor )
{
ScDocument& rDoc = getScDocument();
commit 5d0ae90546d46a39bb42ea60e3f835ca68e6abdb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 2 00:07:06 2012 +0100
implement top/bottom n percent
Change-Id: I463cd96831cd47b4e2ed878761e7196098a2e163
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index ee2d9c9..51b3dba 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -72,6 +72,8 @@ enum ScConditionMode
SC_COND_DIRECT,
SC_COND_TOP10,
SC_COND_BOTTOM10,
+ SC_COND_TOP_PERCENT,
+ SC_COND_BOTTOM_PERCENT,
SC_COND_NONE
};
@@ -253,6 +255,8 @@ private:
bool IsDuplicate(double nArg, const rtl::OUString& rStr, const ScRangeList& rRanges) const;
bool IsTopNElement( double nArg, const ScRangeList& rRanges ) const;
bool IsTopNPercent( double nArg, const ScRangeList& rRanges ) const;
+ bool IsBottomNElement( double nArg, const ScRangeList& rRanges ) const;
+ bool IsBottomNPercent( double nArg, const ScRangeList& rRanges ) const;
void FillCache(const ScRangeList& rRanges) const;
@@ -265,6 +269,9 @@ private:
// cache them for easier access
size_t nValueItems;
+
+ ScConditionEntryCache():
+ nValueItems(0) {}
};
mutable boost::scoped_ptr<ScConditionEntryCache> mpCache;
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 13abd3a..6e7724c 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -865,10 +865,10 @@ bool ScConditionEntry::IsTopNElement( double nArg, const ScRangeList& rRanges )
for(ScConditionEntryCache::ValueCacheType::const_reverse_iterator itr = mpCache->maValues.rbegin(),
itrEnd = mpCache->maValues.rend(); itr != itrEnd; ++itr)
{
- if(nCells >= nVal1)
- return false;
if(itr->first <= nArg)
return true;
+ if(nCells >= nVal1)
+ return false;
nCells += itr->second;
}
@@ -886,10 +886,48 @@ bool ScConditionEntry::IsBottomNElement( double nArg, const ScRangeList& rRanges
for(ScConditionEntryCache::ValueCacheType::const_iterator itr = mpCache->maValues.begin(),
itrEnd = mpCache->maValues.end(); itr != itrEnd; ++itr)
{
+ if(itr->first >= nArg)
+ return true;
if(nCells >= nVal1)
return false;
+ nCells += itr->second;
+ }
+
+ return true;
+}
+
+bool ScConditionEntry::IsTopNPercent( double nArg, const ScRangeList& rRanges ) const
+{
+ FillCache( rRanges );
+
+ size_t nCells = 0;
+ size_t nLimitCells = static_cast<size_t>(mpCache->nValueItems*nVal1/100);
+ for(ScConditionEntryCache::ValueCacheType::const_reverse_iterator itr = mpCache->maValues.rbegin(),
+ itrEnd = mpCache->maValues.rend(); itr != itrEnd; ++itr)
+ {
+ if(itr->first <= nArg)
+ return true;
+ if(nCells >= nLimitCells)
+ return false;
+ nCells += itr->second;
+ }
+
+ return true;
+}
+
+bool ScConditionEntry::IsBottomNPercent( double nArg, const ScRangeList& rRanges ) const
+{
+ FillCache( rRanges );
+
+ size_t nCells = 0;
+ size_t nLimitCells = static_cast<size_t>(mpCache->nValueItems*nVal1/100);
+ for(ScConditionEntryCache::ValueCacheType::const_iterator itr = mpCache->maValues.begin(),
+ itrEnd = mpCache->maValues.end(); itr != itrEnd; ++itr)
+ {
if(itr->first >= nArg)
return true;
+ if(nCells >= nLimitCells)
+ return false;
nCells += itr->second;
}
@@ -973,6 +1011,12 @@ bool ScConditionEntry::IsValid( double nArg ) const
case SC_COND_BOTTOM10:
bValid = IsBottomNElement( nArg, pCondFormat->GetRange() );
break;
+ case SC_COND_TOP_PERCENT:
+ bValid = IsTopNPercent( nArg, pCondFormat->GetRange() );
+ break;
+ case SC_COND_BOTTOM_PERCENT:
+ bValid = IsBottomNPercent( nArg, pCondFormat->GetRange() );
+ break;
default:
OSL_FAIL("unbekannte Operation bei ScConditionEntry");
break;
@@ -1029,6 +1073,8 @@ bool ScConditionEntry::IsValidStr( const String& rArg ) const
bValid = (ScGlobal::GetCollator()->compareString(
rArg, aUpVal1 ) != COMPARE_EQUAL);
break;
+ case SC_COND_TOP_PERCENT:
+ case SC_COND_BOTTOM_PERCENT:
case SC_COND_TOP10:
case SC_COND_BOTTOM10:
return false;
commit 442cd0fa1e33fd6128d311ca4f76da4247fd35ba
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Nov 1 22:53:04 2012 +0100
only get cond format data for visible cells
Change-Id: I99cea6cd34f0493869b68f237ad2f7d3b6945fa2
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index f665bea..6606fc2 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -534,6 +534,9 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
for(std::vector<sal_uInt32>::const_iterator itr = rCondFormats.begin();
itr != rCondFormats.end() && !bFound; ++itr)
{
+ if(!pInfo->pCell)
+ continue;
+
ScConditionalFormat* pCondForm = pCondFormList->GetFormat(*itr);
if(!pCondForm)
continue;
commit 8b9a263a55859a46d301b7ae9574fe0bb5050c55
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Nov 1 22:50:55 2012 +0100
change ooxml cond format import from API to calc core enums
Change-Id: I59b6df511ddab6cb2cb29b8b8b1c635a188594a1
diff --git a/sc/source/filter/inc/condformatbuffer.hxx b/sc/source/filter/inc/condformatbuffer.hxx
index 9dfe34e..568f09d 100644
--- a/sc/source/filter/inc/condformatbuffer.hxx
+++ b/sc/source/filter/inc/condformatbuffer.hxx
@@ -254,6 +254,7 @@ public:
/** Converts an OOXML condition operator token to the API constant. */
static sal_Int32 convertToApiOperator( sal_Int32 nToken );
+ static sal_Int32 convertToInternalOperator( sal_Int32 nToken );
private:
CondFormatRef createCondFormat();
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index aa93f42..c145210 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -639,7 +639,7 @@ void CondFormatRule::importCfRule( SequenceInputStream& rStrm )
void CondFormatRule::finalizeImport()
{
- sal_Int32 eOperator = ::com::sun::star::sheet::ConditionOperator2::NONE;
+ ScConditionMode eOperator = SC_COND_NONE;
/* Replacement formula for unsupported rule types (text comparison rules,
time period rules, cell type rules). The replacement formulas below may
@@ -663,14 +663,14 @@ void CondFormatRule::finalizeImport()
switch( maModel.mnType )
{
case XML_cellIs:
- eOperator = CondFormatBuffer::convertToApiOperator( maModel.mnOperator );
+ eOperator = static_cast<ScConditionMode>(CondFormatBuffer::convertToInternalOperator( maModel.mnOperator ));
break;
case XML_duplicateValues:
- eOperator = CondFormatBuffer::convertToApiOperator( XML_duplicateValues );
+ eOperator = static_cast<ScConditionMode>(CondFormatBuffer::convertToInternalOperator( XML_duplicateValues ));
aReplaceFormula = " ";
break;
case XML_expression:
- eOperator = ::com::sun::star::sheet::ConditionOperator2::FORMULA;
+ eOperator = SC_COND_DIRECT;
break;
case XML_containsText:
OSL_ENSURE( maModel.mnOperator == XML_containsText, "CondFormatRule::finalizeImport - unexpected operator" );
@@ -803,14 +803,14 @@ void CondFormatRule::finalizeImport()
// set the replacement formula
maModel.maFormulas.clear();
appendFormula( aReplaceFormula );
- if( eOperator != ::com::sun::star::sheet::ConditionOperator2::DUPLICATE )
- eOperator = ::com::sun::star::sheet::ConditionOperator2::FORMULA;
+ if( eOperator != SC_COND_DUPLICATE )
+ eOperator = SC_COND_DIRECT;
}
CellAddress aBaseAddr = mrCondFormat.getRanges().getBaseAddress();
ScAddress aPos;
ScUnoConversion::FillScAddress( aPos, aBaseAddr );
- if( (eOperator != ::com::sun::star::sheet::ConditionOperator2::NONE) && !maModel.maFormulas.empty() )
+ if( (eOperator != SC_COND_NONE) && !maModel.maFormulas.empty() )
{
ScDocument& rDoc = getScDocument();
boost::scoped_ptr<ScTokenArray> pTokenArray2;
@@ -823,7 +823,7 @@ void CondFormatRule::finalizeImport()
ScTokenArray aTokenArray;
OUString aStyleName = getStyles().createDxfStyle( maModel.mnDxfId );
ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, maModel.maFormulas[ 0 ] );
- ScCondFormatEntry* pNewEntry = new ScCondFormatEntry(ScCondFormatEntry::GetModeFromApi(eOperator),
+ ScCondFormatEntry* pNewEntry = new ScCondFormatEntry(eOperator,
&aTokenArray, pTokenArray2.get(), &rDoc, aPos, aStyleName);
mpFormat->AddEntry(pNewEntry);
}
@@ -995,6 +995,23 @@ sal_Int32 CondFormatBuffer::convertToApiOperator( sal_Int32 nToken )
return ConditionOperator2::NONE;
}
+sal_Int32 CondFormatBuffer::convertToInternalOperator( sal_Int32 nToken )
+{
+ switch( nToken )
+ {
+ case XML_between: return SC_COND_BETWEEN;
+ case XML_equal: return SC_COND_EQUAL;
+ case XML_greaterThan: return SC_COND_GREATER;
+ case XML_greaterThanOrEqual: return SC_COND_EQGREATER;
+ case XML_lessThan: return SC_COND_LESS;
+ case XML_lessThanOrEqual: return SC_COND_EQLESS;
+ case XML_notBetween: return SC_COND_NOTBETWEEN;
+ case XML_notEqual: return SC_COND_NOTEQUAL;
+ case XML_duplicateValues: return SC_COND_DUPLICATE;
+ }
+ return ConditionOperator2::NONE;
+}
+
// private --------------------------------------------------------------------
CondFormatRef CondFormatBuffer::createCondFormat()
commit 6a62cc8538777d75c53dcf34cc617120b5e04ada
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Nov 1 22:48:13 2012 +0100
implement top/ bottom n elements conditional format
Change-Id: Ie6aebf91689b6e260225548802d699cf70dadb94
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index e1f4e67..ee2d9c9 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -70,6 +70,8 @@ enum ScConditionMode
SC_COND_DUPLICATE,
SC_COND_NOTDUPLICATE,
SC_COND_DIRECT,
+ SC_COND_TOP10,
+ SC_COND_BOTTOM10,
SC_COND_NONE
};
@@ -249,6 +251,8 @@ protected:
private:
bool IsDuplicate(double nArg, const rtl::OUString& rStr, const ScRangeList& rRanges) const;
+ bool IsTopNElement( double nArg, const ScRangeList& rRanges ) const;
+ bool IsTopNPercent( double nArg, const ScRangeList& rRanges ) const;
void FillCache(const ScRangeList& rRanges) const;
@@ -258,6 +262,9 @@ private:
StringCacheType maStrings;
typedef std::map<double, sal_Int32, approx_less> ValueCacheType;
ValueCacheType maValues;
+
+ // cache them for easier access
+ size_t nValueItems;
};
mutable boost::scoped_ptr<ScConditionEntryCache> mpCache;
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 6143647..13abd3a 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -814,6 +814,8 @@ void ScConditionEntry::FillCache( const ScRangeList& rRanges ) const
std::pair<ScConditionEntryCache::ValueCacheType::iterator, bool> aResult = mpCache->maValues.insert(std::pair<double, sal_Int32>(nVal, (sal_Int32)1));
if(!aResult.second)
aResult.first->second++;
+
+ ++(mpCache->nValueItems);
}
}
}
@@ -852,6 +854,48 @@ bool ScConditionEntry::IsDuplicate( double nArg, const rtl::OUString& rStr, cons
}
}
+bool ScConditionEntry::IsTopNElement( double nArg, const ScRangeList& rRanges ) const
+{
+ FillCache( rRanges );
+
+ if(mpCache->nValueItems <= nVal1)
+ return true;
+
+ size_t nCells = 0;
+ for(ScConditionEntryCache::ValueCacheType::const_reverse_iterator itr = mpCache->maValues.rbegin(),
+ itrEnd = mpCache->maValues.rend(); itr != itrEnd; ++itr)
+ {
+ if(nCells >= nVal1)
+ return false;
+ if(itr->first <= nArg)
+ return true;
+ nCells += itr->second;
+ }
+
+ return true;
+}
+
+bool ScConditionEntry::IsBottomNElement( double nArg, const ScRangeList& rRanges ) const
+{
+ FillCache( rRanges );
+
+ if(mpCache->nValueItems <= nVal1)
+ return true;
+
+ size_t nCells = 0;
+ for(ScConditionEntryCache::ValueCacheType::const_iterator itr = mpCache->maValues.begin(),
+ itrEnd = mpCache->maValues.end(); itr != itrEnd; ++itr)
+ {
+ if(nCells >= nVal1)
+ return false;
+ if(itr->first >= nArg)
+ return true;
+ nCells += itr->second;
+ }
+
+ return true;
+}
+
bool ScConditionEntry::IsValid( double nArg ) const
{
// Interpret muss schon gerufen sein
@@ -923,6 +967,12 @@ bool ScConditionEntry::IsValid( double nArg ) const
case SC_COND_DIRECT:
bValid = !::rtl::math::approxEqual( nComp1, 0.0 );
break;
+ case SC_COND_TOP10:
+ bValid = IsTopNElement( nArg, pCondFormat->GetRange() );
+ break;
+ case SC_COND_BOTTOM10:
+ bValid = IsBottomNElement( nArg, pCondFormat->GetRange() );
+ break;
default:
OSL_FAIL("unbekannte Operation bei ScConditionEntry");
break;
@@ -979,6 +1029,9 @@ bool ScConditionEntry::IsValidStr( const String& rArg ) const
bValid = (ScGlobal::GetCollator()->compareString(
rArg, aUpVal1 ) != COMPARE_EQUAL);
break;
+ case SC_COND_TOP10:
+ case SC_COND_BOTTOM10:
+ return false;
default:
{
sal_Int32 nCompare = ScGlobal::GetCollator()->compareString(
commit ea10345008871e54d2c8057850230a3dfb4e5c52
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Nov 1 16:22:34 2012 +0100
irename this variable
Change-Id: Id311b06a6e94ef5c47d718a300ae308b11265b8b
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 02bed6b..0fed4f5 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -752,7 +752,7 @@ const SvXMLTokenMap& ScXMLImport::GetIconSetAttrMap()
const SvXMLTokenMap& ScXMLImport::GetDataBarEntryAttrMap()
{
- if( !pDataBarEntryAttrMap )
+ if( !pFormattingEntryAttrMap )
{
static SvXMLTokenMapEntry aDataBarAttrEntryTokenMap[] =
{
@@ -761,10 +761,10 @@ const SvXMLTokenMap& ScXMLImport::GetDataBarEntryAttrMap()
XML_TOKEN_MAP_END
};
- pDataBarEntryAttrMap = new SvXMLTokenMap( aDataBarAttrEntryTokenMap );
+ pFormattingEntryAttrMap = new SvXMLTokenMap( aDataBarAttrEntryTokenMap );
}
- return *pDataBarEntryAttrMap;
+ return *pFormattingEntryAttrMap;
}
const SvXMLTokenMap& ScXMLImport::GetLabelRangesElemTokenMap()
@@ -1891,7 +1891,7 @@ ScXMLImport::ScXMLImport(
pColorScaleEntryAttrTokenMap( 0 ),
pDataBarTokenMap( 0 ),
pDataBarAttrMap( 0 ),
- pDataBarEntryAttrMap( 0 ),
+ pFormattingEntryAttrMap( 0 ),
pIconSetAttrMap( 0 ),
pLabelRangesElemTokenMap( 0 ),
pLabelRangeAttrTokenMap( 0 ),
@@ -2029,7 +2029,7 @@ ScXMLImport::~ScXMLImport() throw()
delete pColorScaleEntryAttrTokenMap;
delete pDataBarTokenMap;
delete pDataBarAttrMap;
- delete pDataBarEntryAttrMap;
+ delete pFormattingEntryAttrMap;
delete pLabelRangesElemTokenMap;
delete pLabelRangeAttrTokenMap;
delete pTableElemTokenMap;
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 9102430..1f6a5d9 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -784,7 +784,7 @@ class ScXMLImport: public SvXMLImport
SvXMLTokenMap *pColorScaleEntryAttrTokenMap;
SvXMLTokenMap *pDataBarTokenMap;
SvXMLTokenMap *pDataBarAttrMap;
- SvXMLTokenMap *pDataBarEntryAttrMap;
+ SvXMLTokenMap *pFormattingEntryAttrMap;
SvXMLTokenMap *pIconSetAttrMap;
SvXMLTokenMap *pLabelRangesElemTokenMap;
SvXMLTokenMap *pLabelRangeAttrTokenMap;
commit e4dcc3117ded80834610639162257ca2466fd14d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Nov 1 15:19:46 2012 +0100
remove empty methods
Change-Id: I0af7aa408d4089015257430d3001f0bfcd77c955
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
index 0be6a44..fa2d2f9 100644
--- a/sc/source/filter/xml/xmlcondformat.cxx
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -65,10 +65,6 @@ SvXMLImportContext* ScXMLConditionalFormatsContext::CreateChildContext( sal_uInt
return pContext;
}
-void ScXMLConditionalFormatsContext::EndElement()
-{
-}
-
ScXMLConditionalFormatContext::ScXMLConditionalFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList):
SvXMLImportContext( rImport, nPrfx, rLName )
@@ -171,11 +167,6 @@ SvXMLImportContext* ScXMLColorScaleFormatContext::CreateChildContext( sal_uInt16
return pContext;
}
-void ScXMLColorScaleFormatContext::EndElement()
-{
-
-}
-
ScXMLDataBarFormatContext::ScXMLDataBarFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
ScConditionalFormat* pFormat):
@@ -301,10 +292,6 @@ SvXMLImportContext* ScXMLDataBarFormatContext::CreateChildContext( sal_uInt16 nP
return pContext;
}
-void ScXMLDataBarFormatContext::EndElement()
-{
-}
-
ScXMLIconSetFormatContext::ScXMLIconSetFormatContext(ScXMLImport& rImport, sal_uInt16 nPrfx,
const ::rtl::OUString& rLName,
const ::com::sun::star::uno::Reference<
@@ -577,10 +564,6 @@ ScXMLColorScaleFormatEntryContext::ScXMLColorScaleFormatEntryContext( ScXMLImpor
pFormat->AddEntry(mpFormatEntry);
}
-void ScXMLColorScaleFormatEntryContext::EndElement()
-{
-}
-
ScXMLFormattingEntryContext::ScXMLFormattingEntryContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
ScColorScaleEntry*& pColorScaleEntry):
diff --git a/sc/source/filter/xml/xmlcondformat.hxx b/sc/source/filter/xml/xmlcondformat.hxx
index 0a685d1..45513ce 100644
--- a/sc/source/filter/xml/xmlcondformat.hxx
+++ b/sc/source/filter/xml/xmlcondformat.hxx
@@ -51,8 +51,6 @@ public:
const ::rtl::OUString& rLocalName,
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList>& xAttrList );
-
- virtual void EndElement();
};
class ScXMLConditionalFormatContext : public SvXMLImportContext
@@ -73,7 +71,6 @@ public:
::com::sun::star::xml::sax::XAttributeList>& xAttrList );
virtual void EndElement();
-
private:
ScConditionalFormat* mpFormat;
@@ -97,9 +94,6 @@ public:
const ::rtl::OUString& rLocalName,
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList>& xAttrList );
-
- virtual void EndElement();
-
private:
ScColorScaleFormat* pColorScaleFormat;
@@ -123,9 +117,6 @@ public:
const ::rtl::OUString& rLocalName,
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList>& xAttrList );
-
- virtual void EndElement();
-
private:
ScDataBarFormat* mpDataBarFormat;
@@ -168,9 +159,6 @@ public:
ScColorScaleFormat* pFormat);
virtual ~ScXMLColorScaleFormatEntryContext() {}
-
- virtual void EndElement();
-
private:
ScColorScaleEntry* mpFormatEntry;
commit 5787bb3ffda46341475a0096da07d32e0b81f50f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Nov 1 15:16:35 2012 +0100
rename the class to reflect new useage
Change-Id: I8ec856467287daf6ee383f9d73980d556da665e9
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
index ef2b590..0be6a44 100644
--- a/sc/source/filter/xml/xmlcondformat.cxx
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -283,7 +283,7 @@ SvXMLImportContext* ScXMLDataBarFormatContext::CreateChildContext( sal_uInt16 nP
case XML_TOK_DATABAR_DATABARENTRY:
{
ScColorScaleEntry* pEntry;
- pContext = new ScXMLDataBarFormatEntryContext( GetScImport(), nPrefix, rLocalName, xAttrList, pEntry );
+ pContext = new ScXMLFormattingEntryContext( GetScImport(), nPrefix, rLocalName, xAttrList, pEntry );
if(mpFormatData->mpLowerLimit)
{
mpFormatData->mpUpperLimit.reset(pEntry);
@@ -367,7 +367,7 @@ SvXMLImportContext* ScXMLIconSetFormatContext::CreateChildContext( sal_uInt16 nP
case XML_TOK_FORMATTING_ENTRY:
{
ScColorScaleEntry* pEntry;
- pContext = new ScXMLDataBarFormatEntryContext( GetScImport(), nPrefix, rLocalName, xAttrList, pEntry );
+ pContext = new ScXMLFormattingEntryContext( GetScImport(), nPrefix, rLocalName, xAttrList, pEntry );
mpFormatData->maEntries.push_back(pEntry);
}
break;
@@ -581,7 +581,7 @@ void ScXMLColorScaleFormatEntryContext::EndElement()
{
}
-ScXMLDataBarFormatEntryContext::ScXMLDataBarFormatEntryContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ScXMLFormattingEntryContext::ScXMLFormattingEntryContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
ScColorScaleEntry*& pColorScaleEntry):
SvXMLImportContext( rImport, nPrfx, rLName )
diff --git a/sc/source/filter/xml/xmlcondformat.hxx b/sc/source/filter/xml/xmlcondformat.hxx
index 9e7eba6..0a685d1 100644
--- a/sc/source/filter/xml/xmlcondformat.hxx
+++ b/sc/source/filter/xml/xmlcondformat.hxx
@@ -176,18 +176,18 @@ private:
ScColorScaleEntry* mpFormatEntry;
};
-class ScXMLDataBarFormatEntryContext : public SvXMLImportContext
+class ScXMLFormattingEntryContext : public SvXMLImportContext
{
const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
public:
- ScXMLDataBarFormatEntryContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ ScXMLFormattingEntryContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
const ::rtl::OUString& rLName,
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList>& xAttrList,
ScColorScaleEntry*& pData);
- virtual ~ScXMLDataBarFormatEntryContext() {}
+ virtual ~ScXMLFormattingEntryContext() {}
};
class ScXMLCondContext : public SvXMLImportContext
commit 3247394f9244212aadff733692e2c9ba76fc30e5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Nov 1 03:05:09 2012 +0100
implement icon set import/export from odf
Change-Id: I7fb265194811ef8ba0b7aed04d4bd28181612ebc
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
index 9733bd2..ef2b590 100644
--- a/sc/source/filter/xml/xmlcondformat.cxx
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -121,6 +121,9 @@ SvXMLImportContext* ScXMLConditionalFormatContext::CreateChildContext( sal_uInt1
case XML_TOK_CONDFORMAT_DATABAR:
pContext = new ScXMLDataBarFormatContext( GetScImport(), nPrefix, rLocalName, xAttrList, mpFormat );
break;
+ case XML_TOK_CONDFORMAT_ICONSET:
+ pContext = new ScXMLIconSetFormatContext( GetScImport(), nPrefix, rLocalName, xAttrList, mpFormat );
+ break;
default:
break;
}
@@ -271,14 +274,26 @@ SvXMLImportContext* ScXMLDataBarFormatContext::CreateChildContext( sal_uInt16 nP
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList>& xAttrList )
{
- const SvXMLTokenMap& rTokenMap = GetScImport().GetDataBarTokenMap();
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetFormattingTokenMap();
sal_uInt16 nToken = rTokenMap.Get(nPrefix, rLocalName);
SvXMLImportContext* pContext = NULL;
switch (nToken)
{
+ case XML_TOK_FORMATTING_ENTRY:
case XML_TOK_DATABAR_DATABARENTRY:
- pContext = new ScXMLDataBarFormatEntryContext( GetScImport(), nPrefix, rLocalName, xAttrList, mpFormatData );
- break;
+ {
+ ScColorScaleEntry* pEntry;
+ pContext = new ScXMLDataBarFormatEntryContext( GetScImport(), nPrefix, rLocalName, xAttrList, pEntry );
+ if(mpFormatData->mpLowerLimit)
+ {
+ mpFormatData->mpUpperLimit.reset(pEntry);
+ }
+ else
+ {
+ mpFormatData->mpLowerLimit.reset(pEntry);
+ }
+ }
+ break;
default:
break;
}
@@ -290,6 +305,79 @@ void ScXMLDataBarFormatContext::EndElement()
{
}
+ScXMLIconSetFormatContext::ScXMLIconSetFormatContext(ScXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScConditionalFormat* pFormat):
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+ rtl::OUString aIconSetType;
+ sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetIconSetAttrMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName ));
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_ICONSET_TYPE:
+ aIconSetType = sValue;
+ break;
+ default:
+ break;
+ }
+ }
+
+ ScIconSetMap* pMap = ScIconSetFormat::getIconSetMap();
+ ScIconSetType eType = IconSet_3Arrows;
+ for(; pMap->pName; ++pMap)
+ {
+ rtl::OUString aName = rtl::OUString::createFromAscii(pMap->pName);
+ if(aName ==aIconSetType)
+ {
+ eType = pMap->eType;
+ break;
+ }
+ }
+
+ ScIconSetFormat* pIconSetFormat = new ScIconSetFormat(GetScImport().GetDocument());
+ ScIconSetFormatData* pIconSetFormatData = new ScIconSetFormatData;
+ pIconSetFormatData->eIconSetType = eType;
+ pIconSetFormat->SetIconSetData(pIconSetFormatData);
+ pFormat->AddEntry(pIconSetFormat);
+
+ mpFormatData = pIconSetFormatData;
+}
+
+SvXMLImportContext* ScXMLIconSetFormatContext::CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
+{
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetFormattingTokenMap();
+ sal_uInt16 nToken = rTokenMap.Get(nPrefix, rLocalName);
+ SvXMLImportContext* pContext = NULL;
+ switch (nToken)
+ {
+ case XML_TOK_FORMATTING_ENTRY:
+ {
+ ScColorScaleEntry* pEntry;
+ pContext = new ScXMLDataBarFormatEntryContext( GetScImport(), nPrefix, rLocalName, xAttrList, pEntry );
+ mpFormatData->maEntries.push_back(pEntry);
+ }
+ break;
+ default:
+ break;
+ }
+
+ return pContext;
+}
+
namespace {
void GetConditionData(const rtl::OUString& rValue, ScConditionMode& eMode, rtl::OUString& rExpr1, rtl::OUString& rExpr2)
@@ -411,11 +499,6 @@ ScXMLCondContext::ScXMLCondContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
pFormat->AddEntry(pFormatEntry);
}
-void ScXMLCondContext::EndElement()
-{
-
-}
-
namespace {
void setColorEntryType(const rtl::OUString& rType, ScColorScaleEntry* pEntry, const rtl::OUString rFormula,
@@ -500,7 +583,7 @@ void ScXMLColorScaleFormatEntryContext::EndElement()
ScXMLDataBarFormatEntryContext::ScXMLDataBarFormatEntryContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
- ScDataBarFormatData* pData):
+ ScColorScaleEntry*& pColorScaleEntry):
SvXMLImportContext( rImport, nPrfx, rLName )
{
rtl::OUString sVal;
@@ -533,19 +616,8 @@ ScXMLDataBarFormatEntryContext::ScXMLDataBarFormatEntryContext( ScXMLImport& rIm
if(!sVal.isEmpty())
sax::Converter::convertDouble(nVal, sVal);
- ScColorScaleEntry* pEntry = new ScColorScaleEntry(nVal, Color());
- setColorEntryType(sType, pEntry, sVal, GetScImport());
- if(pData->mpLowerLimit)
- {
- pData->mpUpperLimit.reset(pEntry);
- }
- else
- {
- pData->mpLowerLimit.reset(pEntry);
- }
+ pColorScaleEntry = new ScColorScaleEntry(nVal, Color());
+ setColorEntryType(sType, pColorScaleEntry, sVal, GetScImport());
}
-void ScXMLDataBarFormatEntryContext::EndElement()
-{
-}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/xmlcondformat.hxx b/sc/source/filter/xml/xmlcondformat.hxx
index a31bdff..9e7eba6 100644
--- a/sc/source/filter/xml/xmlcondformat.hxx
+++ b/sc/source/filter/xml/xmlcondformat.hxx
@@ -35,6 +35,7 @@ class ScColorScaleEntry;
class ScDataBarFormat;
struct ScDataBarFormatData;
class ScConditionalFormat;
+struct ScIconSetFormatData;
class ScXMLConditionalFormatsContext : public SvXMLImportContext
{
@@ -132,6 +133,29 @@ private:
};
+class ScXMLIconSetFormatContext : public SvXMLImportContext
+{
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+
+ ScIconSetFormatData* mpFormatData;
+public:
+
+ ScXMLIconSetFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScConditionalFormat* pFormat);
+
+ virtual ~ScXMLIconSetFormatContext() {}
+
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+};
+
class ScXMLColorScaleFormatEntryContext : public SvXMLImportContext
{
const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
@@ -161,11 +185,9 @@ public:
const ::rtl::OUString& rLName,
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList>& xAttrList,
- ScDataBarFormatData* pData);
+ ScColorScaleEntry*& pData);
virtual ~ScXMLDataBarFormatEntryContext() {}
-
- virtual void EndElement();
};
class ScXMLCondContext : public SvXMLImportContext
@@ -180,8 +202,6 @@ public:
ScConditionalFormat* pFormat);
virtual ~ScXMLCondContext() {}
-
- virtual void EndElement();
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 46d35bf..fda1912 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3810,6 +3810,22 @@ rtl::OUString getCondFormatEntryType(const ScColorScaleEntry& rEntry, bool bFirs
return rtl::OUString();
}
+rtl::OUString getIconSetName(ScIconSetType eType)
+{
+ const char* pName = NULL;
+ ScIconSetMap* pMap = ScIconSetFormat::getIconSetMap();
+ for(;pMap->pName;++pMap)
+ {
+ if(pMap->eType == eType)
+ {
+ pName = pMap->pName;
+ break;
+ }
+ }
+ assert(pName);
+ return rtl::OUString::createFromAscii(pName);
+}
+
}
void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
@@ -3980,7 +3996,7 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
else
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, rtl::OUString::valueOf(pFormatData->mpLowerLimit->GetValue()));
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, getCondFormatEntryType(*pFormatData->mpLowerLimit, true));
- SvXMLElementExport aElementDataBarEntryLower(*this, XML_NAMESPACE_CALC_EXT, XML_DATA_BAR_ENTRY, true, true);
+ SvXMLElementExport aElementDataBarEntryLower(*this, XML_NAMESPACE_CALC_EXT, XML_FORMATTING_ENTRY, true, true);
}
{
@@ -3992,7 +4008,28 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
else
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, rtl::OUString::valueOf(pFormatData->mpUpperLimit->GetValue()));
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, getCondFormatEntryType(*pFormatData->mpUpperLimit, false));
- SvXMLElementExport aElementDataBarEntryUpper(*this, XML_NAMESPACE_CALC_EXT, XML_DATA_BAR_ENTRY, true, true);
+ SvXMLElementExport aElementDataBarEntryUpper(*this, XML_NAMESPACE_CALC_EXT, XML_FORMATTING_ENTRY, true, true);
+ }
+ }
+ else if(pFormatEntry->GetType() == condformat::ICONSET)
+ {
+ const ScIconSetFormat& mrIconSet = static_cast<const ScIconSetFormat&>(*pFormatEntry);
+ rtl::OUString aIconSetName = getIconSetName(mrIconSet.GetIconSetData()->eIconSetType);
+ AddAttribute( XML_NAMESPACE_CALC_EXT, XML_ICON_SET_TYPE, aIconSetName );
+ SvXMLElementExport aElementColorScale(*this, XML_NAMESPACE_CALC_EXT, XML_ICON_SET, true, true);
+ for(ScIconSetFormat::const_iterator it = mrIconSet.begin();
+ it != mrIconSet.end(); ++it)
+ {
+ if(it->GetType() == COLORSCALE_FORMULA)
+ {
+ rtl::OUString sFormula = it->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
+ AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, sFormula);
+ }
+ else
+ AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, rtl::OUString::valueOf(it->GetValue()));
+
+ AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, getCondFormatEntryType(*it));
+ SvXMLElementExport aElementColorScaleEntry(*this, XML_NAMESPACE_CALC_EXT, XML_FORMATTING_ENTRY, true, true);
}
}
}
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 872c967..02bed6b 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -618,6 +618,7 @@ const SvXMLTokenMap& ScXMLImport::GetCondFormatTokenMap()
{ XML_NAMESPACE_CALC_EXT, XML_COLOR_SCALE, XML_TOK_CONDFORMAT_COLORSCALE },
{ XML_NAMESPACE_CALC_EXT, XML_DATA_BAR, XML_TOK_CONDFORMAT_DATABAR },
{ XML_NAMESPACE_CALC_EXT, XML_CONDITION, XML_TOK_CONDFORMAT_CONDITION },
+ { XML_NAMESPACE_CALC_EXT, XML_ICON_SET, XML_TOK_CONDFORMAT_ICONSET },
XML_TOKEN_MAP_END
};
@@ -695,13 +696,14 @@ const SvXMLTokenMap& ScXMLImport::GetColorScaleEntryAttrMap()
return *pColorScaleEntryAttrTokenMap;
}
-const SvXMLTokenMap& ScXMLImport::GetDataBarTokenMap()
+const SvXMLTokenMap& ScXMLImport::GetFormattingTokenMap()
{
if( !pDataBarTokenMap )
{
static SvXMLTokenMapEntry aDataBarElemTokenMap[] =
{
{ XML_NAMESPACE_CALC_EXT, XML_DATA_BAR_ENTRY, XML_TOK_DATABAR_DATABARENTRY },
+ { XML_NAMESPACE_CALC_EXT, XML_FORMATTING_ENTRY, XML_TOK_FORMATTING_ENTRY },
XML_TOKEN_MAP_END
};
@@ -732,6 +734,22 @@ const SvXMLTokenMap& ScXMLImport::GetDataBarAttrMap()
return *pDataBarAttrMap;
}
+const SvXMLTokenMap& ScXMLImport::GetIconSetAttrMap()
+{
+ if( !pIconSetAttrMap )
+ {
+ static SvXMLTokenMapEntry aIconSetAttrTokenMap[] =
+ {
+ { XML_NAMESPACE_CALC_EXT, XML_ICON_SET_TYPE, XML_TOK_ICONSET_TYPE },
+ XML_TOKEN_MAP_END
+ };
+
+ pIconSetAttrMap = new SvXMLTokenMap( aIconSetAttrTokenMap );
+ }
+
+ return *pIconSetAttrMap;
+}
+
const SvXMLTokenMap& ScXMLImport::GetDataBarEntryAttrMap()
{
if( !pDataBarEntryAttrMap )
@@ -1874,6 +1892,7 @@ ScXMLImport::ScXMLImport(
pDataBarTokenMap( 0 ),
pDataBarAttrMap( 0 ),
pDataBarEntryAttrMap( 0 ),
+ pIconSetAttrMap( 0 ),
pLabelRangesElemTokenMap( 0 ),
pLabelRangeAttrTokenMap( 0 ),
pTableElemTokenMap( 0 ),
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index f3706d9..9102430 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -159,7 +159,8 @@ enum ScXMLCondFormatTokens
{
XML_TOK_CONDFORMAT_COLORSCALE,
XML_TOK_CONDFORMAT_DATABAR,
- XML_TOK_CONDFORMAT_CONDITION
+ XML_TOK_CONDFORMAT_CONDITION,
+ XML_TOK_CONDFORMAT_ICONSET
};
enum ScXMLCondFormatAttrTokens
@@ -186,9 +187,10 @@ enum ScXMLColorScaleEntryAttrTokens
XML_TOK_COLORSCALEENTRY_COLOR
};
-enum ScXMLDataBarFormatTokens
+enum ScXMLFormattingFormatTokens
{
- XML_TOK_DATABAR_DATABARENTRY
+ XML_TOK_DATABAR_DATABARENTRY,
+ XML_TOK_FORMATTING_ENTRY
};
enum ScXMLDataBarAttrTokens
@@ -207,6 +209,11 @@ enum ScXMLDataBarEntryAttrTokens
XML_TOK_DATABARENTRY_VALUE
};
+enum ScXMLIconSetAttrTokens
+{
+ XML_TOK_ICONSET_TYPE
+};
+
enum ScXMLLabelRangesElemTokens
{
XML_TOK_LABEL_RANGE_ELEM
@@ -778,6 +785,7 @@ class ScXMLImport: public SvXMLImport
SvXMLTokenMap *pDataBarTokenMap;
SvXMLTokenMap *pDataBarAttrMap;
SvXMLTokenMap *pDataBarEntryAttrMap;
+ SvXMLTokenMap *pIconSetAttrMap;
SvXMLTokenMap *pLabelRangesElemTokenMap;
SvXMLTokenMap *pLabelRangeAttrTokenMap;
SvXMLTokenMap *pTableElemTokenMap;
@@ -938,9 +946,10 @@ public:
const SvXMLTokenMap& GetConditionAttrMap();
const SvXMLTokenMap& GetColorScaleTokenMap();
const SvXMLTokenMap& GetColorScaleEntryAttrMap();
- const SvXMLTokenMap& GetDataBarTokenMap();
+ const SvXMLTokenMap& GetFormattingTokenMap();
const SvXMLTokenMap& GetDataBarAttrMap();
const SvXMLTokenMap& GetDataBarEntryAttrMap();
+ const SvXMLTokenMap& GetIconSetAttrMap();
const SvXMLTokenMap& GetLabelRangesElemTokenMap();
const SvXMLTokenMap& GetLabelRangeAttrTokenMap();
const SvXMLTokenMap& GetTableElemTokenMap();
diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx
index 4ade928..f97d1e3 100644
--- a/xmloff/inc/xmloff/xmltoken.hxx
+++ b/xmloff/inc/xmloff/xmltoken.hxx
@@ -852,6 +852,7 @@ namespace xmloff { namespace token {
XML_FOREIGN_OBJECT,
XML_FORMAT_CHANGE,
XML_FORMAT_SOURCE,
+ XML_FORMATTING_ENTRY,
XML_FORMS,
XML_FORMULA,
XML_FORMULA_HIDDEN,
@@ -971,6 +972,8 @@ namespace xmloff { namespace token {
XML_HYPHENATION_REMAIN_CHAR_COUNT,
XML_I,
XML_ICON,
+ XML_ICON_SET,
+ XML_ICON_SET_TYPE,
XML_ID,
XML_IDENT,
XML_IDENTIFIER,
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index cbbd48b..be8d9ce 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -856,6 +856,7 @@ namespace xmloff { namespace token {
TOKEN( "foreign-object", XML_FOREIGN_OBJECT ),
TOKEN( "format-change", XML_FORMAT_CHANGE ),
TOKEN( "format-source", XML_FORMAT_SOURCE ),
+ TOKEN( "formatting-entry", XML_FORMATTING_ENTRY ),
TOKEN( "forms", XML_FORMS ),
TOKEN( "formula", XML_FORMULA ),
TOKEN( "formula-hidden", XML_FORMULA_HIDDEN ),
@@ -976,6 +977,8 @@ namespace xmloff { namespace token {
TOKEN( "hyphenation-remain-char-count", XML_HYPHENATION_REMAIN_CHAR_COUNT ),
TOKEN( "i", XML_I ),
TOKEN( "icon", XML_ICON ),
+ TOKEN( "icon-set", XML_ICON_SET ),
+ TOKEN( "icon-set-type", XML_ICON_SET_TYPE ),
TOKEN( "id", XML_ID ),
TOKEN( "ident", XML_IDENT ),
TOKEN( "identifier", XML_IDENTIFIER ),
commit f73571b5897a53be28ee61d1d1693a5d64065f85
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Oct 31 21:46:06 2012 +0100
extract filling the cache for conditional formats
Change-Id: I90c4f7ac5c462a507cf0d44b7837facdd2bc3643
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 641da85..e1f4e67 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -177,8 +177,8 @@ class SC_DLLPUBLIC ScConditionEntry : public ScFormatEntry
bool bTextToReal );
void Interpret( const ScAddress& rPos );
- bool IsValid( double nArg, const ScAddress& rAddr ) const;
- bool IsValidStr( const String& rArg, const ScAddress& rAddr ) const;
+ bool IsValid( double nArg ) const;
+ bool IsValidStr( const String& rArg ) const;
public:
ScConditionEntry( ScConditionMode eOper,
@@ -248,7 +248,9 @@ protected:
private:
- bool IsDuplicate(double nArg, const rtl::OUString& rStr, const ScAddress& rAddr, const ScRangeList& rRanges) const;
+ bool IsDuplicate(double nArg, const rtl::OUString& rStr, const ScRangeList& rRanges) const;
+
+ void FillCache(const ScRangeList& rRanges) const;
struct ScConditionEntryCache
{
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 324bcf9..6143647 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -768,7 +768,7 @@ static bool lcl_GetCellContent( ScBaseCell* pCell, bool bIsStr1, double& rArg, r
return bVal;
}
-bool ScConditionEntry::IsDuplicate( double nArg, const rtl::OUString& rStr, const ScAddress& rAddr, const ScRangeList& rRanges ) const
+void ScConditionEntry::FillCache( const ScRangeList& rRanges ) const
{
if(!mpCache)
{
@@ -798,7 +798,7 @@ bool ScConditionEntry::IsDuplicate( double nArg, const rtl::OUString& rStr, cons
double nVal = 0.0;
ScBaseCell *pCell = NULL;
- mpDoc->GetCell( c, r, rAddr.Tab(), pCell );
+ mpDoc->GetCell( c, r, nTab, pCell );
if( !pCell )
continue;
@@ -818,6 +818,11 @@ bool ScConditionEntry::IsDuplicate( double nArg, const rtl::OUString& rStr, cons
}
}
}
+}
+
+bool ScConditionEntry::IsDuplicate( double nArg, const rtl::OUString& rStr, const ScRangeList& rRanges ) const
+{
+ FillCache( rRanges );
if(rStr.isEmpty())
{
@@ -847,7 +852,7 @@ bool ScConditionEntry::IsDuplicate( double nArg, const rtl::OUString& rStr, cons
}
}
-bool ScConditionEntry::IsValid( double nArg, const ScAddress& rAddr ) const
+bool ScConditionEntry::IsValid( double nArg ) const
{
// Interpret muss schon gerufen sein
@@ -910,7 +915,7 @@ bool ScConditionEntry::IsValid( double nArg, const ScAddress& rAddr ) const
if( pCondFormat )
{
const ScRangeList& aRanges = pCondFormat->GetRange();
- bValid = IsDuplicate( nArg, rtl::OUString(), rAddr, aRanges );
+ bValid = IsDuplicate( nArg, rtl::OUString(), aRanges );
if( eOp == SC_COND_NOTDUPLICATE )
bValid = !bValid;
}
@@ -925,7 +930,7 @@ bool ScConditionEntry::IsValid( double nArg, const ScAddress& rAddr ) const
return bValid;
}
-bool ScConditionEntry::IsValidStr( const String& rArg, const ScAddress& rAddr ) const
+bool ScConditionEntry::IsValidStr( const String& rArg ) const
{
bool bValid = false;
// Interpret muss schon gerufen sein
@@ -938,7 +943,7 @@ bool ScConditionEntry::IsValidStr( const String& rArg, const ScAddress& rAddr )
if( pCondFormat && rArg.Len() )
{
const ScRangeList& aRanges = pCondFormat->GetRange();
- bValid = IsDuplicate( 0.0, rArg, rAddr, aRanges );
+ bValid = IsDuplicate( 0.0, rArg, aRanges );
if( eOp == SC_COND_NOTDUPLICATE )
bValid = !bValid;
return bValid;
@@ -1020,9 +1025,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, rPos );
+ return IsValid( nArg );
else
- return IsValidStr( aArgStr, rPos );
+ return IsValidStr( aArgStr );
}
String ScConditionEntry::GetExpression( const ScAddress& rCursor, sal_uInt16 nIndex,
commit 2829bc140b0da4d2d2a2e9d4381a774180ffe5c7
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Oct 31 00:39:01 2012 +0100
remove misleading comment
Change-Id: Ie169423e88539fb6557a36ac3db44386ceb77bbe
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index a18235b..641da85 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -57,10 +57,6 @@ class ScTokenArray;
#define DUMP_FORMAT_INFO 1
-
-// ordering of ScConditionMode and ScQueryOp is equal,
-// to facilitate the merging of both in the future
-
enum ScConditionMode
{
SC_COND_EQUAL, //done
More information about the Libreoffice-commits
mailing list