[Libreoffice-commits] .: 4 commits - sc/inc sc/Library_sc.mk sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Tue May 8 20:04:12 PDT 2012
sc/Library_sc.mk | 1
sc/inc/colorscale.hxx | 91 ++++++++++++++
sc/inc/conditio.hxx | 24 ++-
sc/inc/document.hxx | 7 +
sc/inc/fillinfo.hxx | 3
sc/inc/scitems.hxx | 87 ++++++-------
sc/source/core/data/colorscale.cxx | 184 +++++++++++++++++++++++++++++
sc/source/core/data/conditio.cxx | 108 +++++++++--------
sc/source/core/data/docpool.cxx | 1
sc/source/core/data/documen2.cxx | 3
sc/source/core/data/documen4.cxx | 25 ++-
sc/source/core/data/fillinfo.cxx | 19 ++
sc/source/filter/excel/xecontent.cxx | 16 --
sc/source/filter/excel/xestyle.cxx | 9 -
sc/source/filter/inc/condformatbuffer.hxx | 26 +++-
sc/source/filter/inc/condformatcontext.hxx | 18 ++
sc/source/filter/oox/condformatbuffer.cxx | 76 +++++++++++
sc/source/filter/oox/condformatcontext.cxx | 59 ++++++++-
18 files changed, 630 insertions(+), 127 deletions(-)
New commits:
commit ca64be56cbb46ea313d1dc39b0d737d5b0640150
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed May 9 02:54:00 2012 +0200
import color scales from xlsx
Change-Id: I7db1f2ab6fa842ed9750e8240fa813ba1bbc59b2
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index a384739..df65333 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -34,7 +34,7 @@
class ScDocument;
-class ScColorScaleEntry
+class SC_DLLPUBLIC ScColorScaleEntry
{
private:
double mnVal;
@@ -47,7 +47,7 @@ public:
double GetValue() const;
};
-class ScColorScaleFormat
+class SC_DLLPUBLIC ScColorScaleFormat
{
private:
ScRangeList maRange;
@@ -56,6 +56,7 @@ private:
ColorScaleEntries maColorScales;
public:
Color* GetColor(const ScAddress& rAddr) const;
+ void AddEntry(ScColorScaleEntry* pEntry);
typedef ColorScaleEntries::iterator iterator;
typedef ColorScaleEntries::const_iterator const_iterator;
@@ -77,6 +78,7 @@ public:
typedef ColorScaleFormatContainer::const_iterator const_iterator;
ScColorScaleFormat* GetFormat(sal_uInt32 nFormat);
+ void AddFormat( ScColorScaleFormat* pFormat );
iterator begin();
const_iterator begin() const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index fbb06b9..c867461 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -54,6 +54,7 @@
#include <set>
#include <vector>
#include <boost/ptr_container/ptr_vector.hpp>
+#include <boost/scoped_ptr.hpp>
namespace editeng { class SvxBorderLine; }
@@ -95,6 +96,8 @@ class ScChartCollection;
class ScChartListenerCollection;
class ScConditionalFormat;
class ScConditionalFormatList;
+class ScColorScaleFormat;
+class ScColorScaleFormatList;
class ScDBCollection;
class ScDBData;
class ScDetOpData;
@@ -243,6 +246,7 @@ private:
ScDrawLayer* pDrawLayer; // SdrModel
rtl::Reference<XColorList> pColorList;
ScConditionalFormatList* pCondFormList; // conditional formats
+ boost::scoped_ptr<ScColorScaleFormatList> mpColorScaleList; //color scales
ScValidationDataList* pValidationList; // validity
SvNumberFormatterIndexTable* pFormatExchangeList; // for application of number formats
TableContainer maTabs;
@@ -1195,6 +1199,7 @@ public:
void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
SC_DLLPUBLIC sal_uLong AddCondFormat( const ScConditionalFormat& rNew );
+ SC_DLLPUBLIC sal_uLong AddColorScaleFormat( ScColorScaleFormat* pNew );
SC_DLLPUBLIC void FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges );
SC_DLLPUBLIC void FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges, SCTAB nTab );
void ConditionalChanged( sal_uLong nKey );
@@ -1207,6 +1212,8 @@ public:
{ return pCondFormList; }
void SetCondFormList(ScConditionalFormatList* pNew);
+ ScColorScaleFormatList* GetColorScaleList() const;
+
ScValidationDataList* GetValidationList() const
{ return pValidationList; }
diff --git a/sc/inc/fillinfo.hxx b/sc/inc/fillinfo.hxx
index f716662..167e24a 100644
--- a/sc/inc/fillinfo.hxx
+++ b/sc/inc/fillinfo.hxx
@@ -31,12 +31,14 @@
#include <svx/framelinkarray.hxx>
#include "global.hxx"
+#include <boost/shared_ptr.hpp>
class SfxItemSet;
class SvxBrushItem;
class SvxBoxItem;
class SvxLineItem;
class SvxShadowItem;
+class Color;
class ScBaseCell;
class ScPatternAttr;
@@ -67,6 +69,7 @@ struct CellInfo
const ScPatternAttr* pPatternAttr;
const SfxItemSet* pConditionSet;
+ boost::shared_ptr<Color> pColorScale;
const SvxBrushItem* pBackground;
diff --git a/sc/inc/scitems.hxx b/sc/inc/scitems.hxx
index e644854..57073f3 100644
--- a/sc/inc/scitems.hxx
+++ b/sc/inc/scitems.hxx
@@ -117,52 +117,53 @@
#define ATTR_SHADOW 152
#define ATTR_VALIDDATA 153
#define ATTR_CONDITIONAL 154
+#define ATTR_COLORSCALE 155
-#define ATTR_PATTERN_END 154 // end cell-attribute-pattern
+#define ATTR_PATTERN_END 155 // end cell-attribute-pattern
-#define ATTR_PATTERN 155
+#define ATTR_PATTERN 156
// page attributes
-#define ATTR_LRSPACE 156 // editor: PageDesc-TabPage
-#define ATTR_ULSPACE 157
-#define ATTR_PAGE 158
-#define ATTR_PAGE_PAPERTRAY 159
-#define ATTR_PAGE_PAPERBIN 160
-#define ATTR_PAGE_SIZE 161
-#define ATTR_PAGE_MAXSIZE 162
-#define ATTR_PAGE_HORCENTER 163
-#define ATTR_PAGE_VERCENTER 164
-
-#define ATTR_PAGE_ON 165 // editor: header/footer-page
-#define ATTR_PAGE_DYNAMIC 166
-#define ATTR_PAGE_SHARED 167
-
-#define ATTR_PAGE_NOTES 168 // editor: table
-#define ATTR_PAGE_GRID 169
-#define ATTR_PAGE_HEADERS 170
-#define ATTR_PAGE_CHARTS 171
-#define ATTR_PAGE_OBJECTS 172
-#define ATTR_PAGE_DRAWINGS 173
-#define ATTR_PAGE_TOPDOWN 174
-#define ATTR_PAGE_SCALE 175
-#define ATTR_PAGE_SCALETOPAGES 176
-#define ATTR_PAGE_FIRSTPAGENO 177
-
-#define ATTR_PAGE_PRINTAREA 178 // editor: print areas
-#define ATTR_PAGE_REPEATROW 179
-#define ATTR_PAGE_REPEATCOL 180
-#define ATTR_PAGE_PRINTTABLES 181
-
-#define ATTR_PAGE_HEADERLEFT 182 // contents of header/
-#define ATTR_PAGE_FOOTERLEFT 183 // footer (left)
-#define ATTR_PAGE_HEADERRIGHT 184 // contents of header/
-#define ATTR_PAGE_FOOTERRIGHT 185 // footer (right)
-#define ATTR_PAGE_HEADERSET 186 // the corresponding sets
-#define ATTR_PAGE_FOOTERSET 187
-
-#define ATTR_PAGE_FORMULAS 188
-#define ATTR_PAGE_NULLVALS 189
-
-#define ATTR_PAGE_SCALETO 190 // #i8868# scale printout to width/height
+#define ATTR_LRSPACE 157 // editor: PageDesc-TabPage
+#define ATTR_ULSPACE 158
+#define ATTR_PAGE 159
+#define ATTR_PAGE_PAPERTRAY 160
+#define ATTR_PAGE_PAPERBIN 161
+#define ATTR_PAGE_SIZE 162
+#define ATTR_PAGE_MAXSIZE 163
+#define ATTR_PAGE_HORCENTER 164
+#define ATTR_PAGE_VERCENTER 165
+
+#define ATTR_PAGE_ON 166 // editor: header/footer-page
+#define ATTR_PAGE_DYNAMIC 167
+#define ATTR_PAGE_SHARED 168
+
+#define ATTR_PAGE_NOTES 169 // editor: table
+#define ATTR_PAGE_GRID 170
+#define ATTR_PAGE_HEADERS 171
+#define ATTR_PAGE_CHARTS 172
+#define ATTR_PAGE_OBJECTS 173
+#define ATTR_PAGE_DRAWINGS 174
+#define ATTR_PAGE_TOPDOWN 175
+#define ATTR_PAGE_SCALE 176
+#define ATTR_PAGE_SCALETOPAGES 177
+#define ATTR_PAGE_FIRSTPAGENO 178
+
+#define ATTR_PAGE_PRINTAREA 179 // editor: print areas
+#define ATTR_PAGE_REPEATROW 180
+#define ATTR_PAGE_REPEATCOL 181
+#define ATTR_PAGE_PRINTTABLES 182
+
+#define ATTR_PAGE_HEADERLEFT 183 // contents of header/
+#define ATTR_PAGE_FOOTERLEFT 184 // footer (left)
+#define ATTR_PAGE_HEADERRIGHT 185 // contents of header/
+#define ATTR_PAGE_FOOTERRIGHT 186 // footer (right)
+#define ATTR_PAGE_HEADERSET 187 // the corresponding sets
+#define ATTR_PAGE_FOOTERSET 188
+
+#define ATTR_PAGE_FORMULAS 189
+#define ATTR_PAGE_NULLVALS 190
+
+#define ATTR_PAGE_SCALETO 191 // #i8868# scale printout to width/height
#define ATTR_ENDINDEX ATTR_PAGE_SCALETO // end of pool-range
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 11d388a..4e74d1e 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -54,6 +54,11 @@ const Color& ScColorScaleEntry::GetColor() const
return maColor;
}
+void ScColorScaleFormat::AddEntry( ScColorScaleEntry* pEntry )
+{
+ maColorScales.push_back( pEntry );
+}
+
namespace {
sal_uInt8 GetColorValue( double nVal, double nVal1, sal_uInt8 nColVal1, double nVal2, sal_uInt8 nColVal2 )
@@ -138,6 +143,11 @@ ScColorScaleFormat::const_iterator ScColorScaleFormat::end() const
return maColorScales.end();
}
+void ScColorScaleFormatList::AddFormat( ScColorScaleFormat* pFormat )
+{
+ maColorScaleFormats.push_back( pFormat );
+}
+
ScColorScaleFormat* ScColorScaleFormatList::GetFormat(sal_uInt32 nFormat)
{
if( nFormat >= size() )
diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx
index 36f0d3b..8e2dbf5 100644
--- a/sc/source/core/data/docpool.cxx
+++ b/sc/source/core/data/docpool.cxx
@@ -287,6 +287,7 @@ ScDocumentPool::ScDocumentPool( SfxItemPool* pSecPool, sal_Bool bLoadRefCounts )
ppPoolDefaults[ ATTR_SHADOW - ATTR_STARTINDEX ] = new SvxShadowItem( ATTR_SHADOW );
ppPoolDefaults[ ATTR_VALIDDATA - ATTR_STARTINDEX ] = new SfxUInt32Item( ATTR_VALIDDATA, 0 );
ppPoolDefaults[ ATTR_CONDITIONAL - ATTR_STARTINDEX ] = new SfxUInt32Item( ATTR_CONDITIONAL, 0 );
+ ppPoolDefaults[ ATTR_COLORSCALE - ATTR_STARTINDEX ] = new SfxUInt32Item( ATTR_COLORSCALE, 0 );
// GetRscString funktioniert erst nach ScGlobal::Init, zu erkennen am EmptyBrushItem
//! zusaetzliche Methode ScGlobal::IsInit() oder so...
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index b7011c1..a64162e 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -74,6 +74,7 @@
#include "chartlis.hxx"
#include "markdata.hxx"
#include "conditio.hxx"
+#include "colorscale.hxx"
#include "validat.hxx"
#include "progress.hxx"
#include "detdata.hxx"
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 31185cc..7df52cc 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -54,6 +54,7 @@
#include "paramisc.hxx"
#include "compiler.hxx"
#include "externalrefmgr.hxx"
+#include "colorscale.hxx"
using namespace formula;
@@ -627,6 +628,20 @@ sal_uLong ScDocument::AddCondFormat( const ScConditionalFormat& rNew )
return nNewKey;
}
+//takes ownership
+sal_uLong ScDocument::AddColorScaleFormat( ScColorScaleFormat* pNew )
+{
+ if(!pNew)
+ return 0;
+
+ if(!mpColorScaleList)
+ mpColorScaleList.reset(new ScColorScaleFormatList());
+
+ mpColorScaleList->AddFormat( pNew );
+
+ return mpColorScaleList->size()-1;
+}
+
sal_uLong ScDocument::AddValidationEntry( const ScValidationData& rNew )
{
if (rNew.IsEmpty())
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index 63c453e..8ad3dba 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -36,6 +36,7 @@
#include <editeng/bolnitem.hxx>
#include <editeng/editdata.hxx> // can be removed if table has a bLayoutRTL flag
#include <editeng/shaditem.hxx>
+#include <editeng/brshitem.hxx>
#include "fillinfo.hxx"
#include "document.hxx"
@@ -49,6 +50,7 @@
#include "poolhelp.hxx"
#include "docpool.hxx"
#include "conditio.hxx"
+#include "colorscale.hxx"
#include "stlpool.hxx"
// -----------------------------------------------------------------------
@@ -478,10 +480,17 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
sal_uLong nConditional = ((const SfxUInt32Item&)pPattern->
GetItem(ATTR_CONDITIONAL)).GetValue();
+ sal_uLong nColorScale = ((const SfxUInt32Item&)pPattern->
+ GetItem(ATTR_COLORSCALE)).GetValue();
+
const ScConditionalFormat* pCondForm = NULL;
if ( nConditional && pCondFormList )
pCondForm = pCondFormList->GetFormat( nConditional );
+ const ScColorScaleFormat* pColorScale = NULL;
+ if ( nColorScale && mpColorScaleList )
+ pColorScale = mpColorScaleList->GetFormat( nColorScale );
+
do
{
SCROW nLastHiddenRow = -1;
@@ -556,6 +565,11 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
// if style is not there, treat like no condition
}
}
+ if ( pColorScale )
+ {
+ Color* pColor = pColorScale->GetColor( ScAddress( nX, nCurRow, nTab ) );
+ pInfo->pColorScale.reset(pColor);
+ }
++nArrY;
}
@@ -673,6 +687,11 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
bAnyShadow = true;
}
}
+ if(pInfo->pColorScale)
+ {
+ pRowInfo[nArrY].bEmptyBack = false;
+ pInfo->pBackground = new SvxBrushItem(*pInfo->pColorScale, ATTR_BACKGROUND);
+ }
}
}
}
diff --git a/sc/source/filter/inc/condformatbuffer.hxx b/sc/source/filter/inc/condformatbuffer.hxx
index 3f21fcc..0da0ba0 100644
--- a/sc/source/filter/inc/condformatbuffer.hxx
+++ b/sc/source/filter/inc/condformatbuffer.hxx
@@ -32,14 +32,19 @@
#include <com/sun/star/sheet/ConditionOperator2.hpp>
#include "formulaparser.hxx"
#include "worksheethelper.hxx"
+#include <boost/scoped_ptr.hpp>
+#include <tools/color.hxx>
namespace com { namespace sun { namespace star {
namespace sheet { class XSheetConditionalEntries; }
} } }
+class ScColorScaleFormat;
namespace oox {
namespace xls {
+class CondFormat;
+
// ============================================================================
/** Model for a single rule in a conditional formatting. */
@@ -71,9 +76,25 @@ struct CondFormatRuleModel
void setBiff12TextType( sal_Int32 nOperator );
};
+class ColorScaleRule : public WorksheetHelper
+{
+public:
+ ColorScaleRule( const CondFormat& rFormat );
+
+ void importValue( const AttributeList& rAttribs );
+ void importColor( const AttributeList& rAttribs );
+
+ void AddEntries( ScColorScaleFormat* pFormat );
+
+private:
+ const CondFormat& mrCondFormat;
+ std::vector< ::Color > maColors;
+ std::vector< double > maValues;
+};
+
+
// ============================================================================
-class CondFormat;
/** Represents a single rule in a conditional formatting. */
class CondFormatRule : public WorksheetHelper
@@ -96,9 +117,12 @@ public:
/** Returns the priority of this rule. */
inline sal_Int32 getPriority() const { return maModel.mnPriority; }
+ ColorScaleRule* getColorScale();
+
private:
const CondFormat& mrCondFormat;
CondFormatRuleModel maModel;
+ boost::scoped_ptr<ColorScaleRule> mpColor;
};
typedef ::boost::shared_ptr< CondFormatRule > CondFormatRuleRef;
diff --git a/sc/source/filter/inc/condformatcontext.hxx b/sc/source/filter/inc/condformatcontext.hxx
index 1cfd42c..7af6258 100644
--- a/sc/source/filter/inc/condformatcontext.hxx
+++ b/sc/source/filter/inc/condformatcontext.hxx
@@ -36,6 +36,24 @@ namespace oox {
namespace xls {
// ============================================================================
+//
+class CondFormatContext;
+
+class ColorScaleContext : public WorksheetContextBase
+{
+public:
+ explicit ColorScaleContext( CondFormatContext& rFragment, CondFormatRuleRef xRule );
+
+ virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
+ virtual void onStartElement( const AttributeList& rAttribs );
+ virtual void onCharacters( const ::rtl::OUString& rChars );
+
+ virtual ::oox::core::ContextHandlerRef onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm );
+ virtual void onStartRecord( SequenceInputStream& rStrm );
+
+private:
+ CondFormatRuleRef mxRule;
+};
class CondFormatContext : public WorksheetContextBase
{
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index d4ea980..7292245 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -50,6 +50,10 @@
#include "addressconverter.hxx"
#include "biffinputstream.hxx"
#include "stylesbuffer.hxx"
+#include "colorscale.hxx"
+#include "document.hxx"
+
+#include <iostream>
namespace oox {
namespace xls {
@@ -133,6 +137,55 @@ void lclAppendProperty( ::std::vector< PropertyValue >& orProps, const OUString&
} // namespace
+ColorScaleRule::ColorScaleRule( const CondFormat& rFormat ):
+ WorksheetHelper( rFormat ),
+ mrCondFormat( rFormat )
+{
+}
+
+void ColorScaleRule::importValue( const AttributeList& rAttribs )
+{
+ rtl::OUString aType = rAttribs.getString( XML_type, rtl::OUString() );
+ if (aType == "num")
+ {
+ double nVal = rAttribs.getDouble( XML_val, 0.0 );
+ maValues.push_back(nVal);
+ std::cout << "ColorScaleRule::importValue: " << nVal << std::endl;
+ }
+}
+
+namespace {
+
+::Color RgbToRgbComponents( sal_Int32& nRgb )
+{
+ sal_Int32 ornR = (nRgb >> 16) & 0xFF;
+ sal_Int32 ornG = (nRgb >> 8) & 0xFF;
+ sal_Int32 ornB = nRgb & 0xFF;
+
+ return ::Color(ornR, ornG, ornB);
+}
+
+}
+
+void ColorScaleRule::importColor( const AttributeList& rAttribs )
+{
+ sal_Int32 nColor = rAttribs.getIntegerHex( XML_rgb, API_RGB_TRANSPARENT );
+
+ ::Color aColor = RgbToRgbComponents( nColor );
+ maColors.push_back(aColor);
+}
+
+void ColorScaleRule::AddEntries( ScColorScaleFormat* pFormat )
+{
+ //assume that both vectors contain the same entries
+ // TODO: check it
+ size_t n = std::min<size_t>(maColors.size(), maValues.size());
+ for(size_t i = 0; i < n; ++i)
+ {
+ pFormat->AddEntry( new ScColorScaleEntry(maValues[i], maColors[i]) );
+ }
+}
+
// ============================================================================
CondFormatRuleModel::CondFormatRuleModel() :
@@ -191,6 +244,12 @@ void CondFormatRule::importCfRule( const AttributeList& rAttribs )
maModel.mbPercent = rAttribs.getBool( XML_percent, false );
maModel.mbAboveAverage = rAttribs.getBool( XML_aboveAverage, true );
maModel.mbEqualAverage = rAttribs.getBool( XML_equalAverage, false );
+
+ if(maModel.mnType == XML_colorScale)
+ {
+ //import the remaining values
+
+ }
}
void CondFormatRule::appendFormula( const OUString& rFormula )
@@ -507,6 +566,8 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries >
if( maModel.mnStdDev == 0 )
aReplaceFormula = CREATE_OUSTRING( "#B#CAVERAGE(#R)" );
break;
+ case XML_colorScale:
+ break;
}
if( !aReplaceFormula.isEmpty() )
@@ -587,6 +648,21 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries >
{
}
}
+ else if( mpColor )
+ {
+ ScDocument& rDoc = getScDocument();
+ ScColorScaleFormat* pFormat = new ScColorScaleFormat();
+
+ mpColor->AddEntries( pFormat );
+ rDoc.AddColorScaleFormat(pFormat);
+ }
+}
+
+ColorScaleRule* CondFormatRule::getColorScale()
+{
+ if(!mpColor)
+ mpColor.reset( new ColorScaleRule(mrCondFormat) );
+ return mpColor.get();
}
// ============================================================================
diff --git a/sc/source/filter/oox/condformatcontext.cxx b/sc/source/filter/oox/condformatcontext.cxx
index 0ca3b7f..66b0f77 100644
--- a/sc/source/filter/oox/condformatcontext.cxx
+++ b/sc/source/filter/oox/condformatcontext.cxx
@@ -38,6 +38,56 @@ using ::rtl::OUString;
// ============================================================================
+ColorScaleContext::ColorScaleContext( CondFormatContext& rFragment, CondFormatRuleRef xRule ) :
+ WorksheetContextBase( rFragment ),
+ mxRule( xRule )
+{
+}
+
+ContextHandlerRef ColorScaleContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
+{
+ switch( getCurrentElement() )
+ {
+ case XLS_TOKEN( cfRule ):
+ return (nElement == XLS_TOKEN( colorScale )) ? this : 0;
+ case XLS_TOKEN( colorScale ):
+ if (nElement == XLS_TOKEN( cfvo ))
+ return this;
+ else if (nElement == XLS_TOKEN( color ))
+ return this;
+ else
+ return 0;
+ }
+ return 0;
+}
+
+void ColorScaleContext::onStartElement( const AttributeList& rAttribs )
+{
+ switch( getCurrentElement() )
+ {
+ case XLS_TOKEN( cfvo ):
+ mxRule->getColorScale()->importValue( rAttribs );
+ break;
+ case XLS_TOKEN( color ):
+ mxRule->getColorScale()->importColor( rAttribs );
+ break;
+ }
+}
+
+void ColorScaleContext::onCharacters( const OUString& rChars )
+{
+
+}
+
+ContextHandlerRef ColorScaleContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& )
+{
+ return 0;
+}
+
+void ColorScaleContext::onStartRecord( SequenceInputStream& rStrm )
+{
+}
+
CondFormatContext::CondFormatContext( WorksheetFragmentBase& rFragment ) :
WorksheetContextBase( rFragment )
{
@@ -50,7 +100,12 @@ ContextHandlerRef CondFormatContext::onCreateContext( sal_Int32 nElement, const
case XLS_TOKEN( conditionalFormatting ):
return (nElement == XLS_TOKEN( cfRule )) ? this : 0;
case XLS_TOKEN( cfRule ):
- return (nElement == XLS_TOKEN( formula )) ? this : 0;
+ if (nElement == XLS_TOKEN( formula ))
+ return this;
+ else if (nElement == XLS_TOKEN( colorScale ) )
+ return new ColorScaleContext( *this, mxRule );
+ else
+ return 0;
}
return 0;
}
@@ -70,8 +125,6 @@ void CondFormatContext::onStartElement( const AttributeList& rAttribs )
void CondFormatContext::onCharacters( const OUString& rChars )
{
- if( isCurrentElement( XLS_TOKEN( formula ) ) && mxCondFmt.get() && mxRule.get() )
- mxRule->appendFormula( rChars );
}
ContextHandlerRef CondFormatContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& )
commit 765c95e2bf85593d256683a15a55e097efb94b52
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue May 8 06:26:30 2012 +0200
add initial code for color scales
Change-Id: Iedb82a17fb7f7e3d16e86dc2a451c8aac4be9149
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index ba6c340..cbc337d 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -88,6 +88,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/data/column2 \
sc/source/core/data/column3 \
sc/source/core/data/compressedarray \
+ sc/source/core/data/colorscale \
sc/source/core/data/conditio \
sc/source/core/data/dbdocutl \
sc/source/core/data/dociter \
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
new file mode 100644
index 0000000..a384739
--- /dev/null
+++ b/sc/inc/colorscale.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard at googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <boost/ptr_container/ptr_vector.hpp>
+#include <tools/color.hxx>
+#include <rangelst.hxx>
+
+//TODO: merge this with conditio.hxx
+
+class ScDocument;
+
+class ScColorScaleEntry
+{
+private:
+ double mnVal;
+ Color maColor;
+public:
+ ScColorScaleEntry(double nVal, const Color& rCol);
+ ScColorScaleEntry(const ScColorScaleEntry& rEntry);
+
+ const Color& GetColor() const;
+ double GetValue() const;
+};
+
+class ScColorScaleFormat
+{
+private:
+ ScRangeList maRange;
+ ScDocument* mpDoc;
+ typedef boost::ptr_vector<ScColorScaleEntry> ColorScaleEntries;
+ ColorScaleEntries maColorScales;
+public:
+ Color* GetColor(const ScAddress& rAddr) const;
+
+ typedef ColorScaleEntries::iterator iterator;
+ typedef ColorScaleEntries::const_iterator const_iterator;
+ iterator begin();
+ const_iterator begin() const;
+ iterator end();
+ const_iterator end() const;
+};
+
+class ScColorScaleFormatList
+{
+private:
+ typedef boost::ptr_vector<ScColorScaleFormat> ColorScaleFormatContainer;
+ boost::ptr_vector<ScColorScaleFormat> maColorScaleFormats;
+public:
+ ScColorScaleFormatList() {};
+
+ typedef ColorScaleFormatContainer::iterator iterator;
+ typedef ColorScaleFormatContainer::const_iterator const_iterator;
+
+ ScColorScaleFormat* GetFormat(sal_uInt32 nFormat);
+
+ iterator begin();
+ const_iterator begin() const;
+ iterator end();
+ const_iterator end() const;
+
+ size_t size() const;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
new file mode 100644
index 0000000..11d388a
--- /dev/null
+++ b/sc/source/core/data/colorscale.cxx
@@ -0,0 +1,174 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard at googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "colorscale.hxx"
+#include "document.hxx"
+#include "cell.hxx"
+
+ScColorScaleEntry::ScColorScaleEntry(double nVal, const Color& rCol):
+ mnVal(nVal),
+ maColor(rCol)
+{
+
+}
+
+ScColorScaleEntry::ScColorScaleEntry(const ScColorScaleEntry& rEntry):
+ mnVal(rEntry.mnVal),
+ maColor(rEntry.maColor)
+{
+
+}
+
+double ScColorScaleEntry::GetValue() const
+{
+ return mnVal;
+}
+
+const Color& ScColorScaleEntry::GetColor() const
+{
+ return maColor;
+}
+
+namespace {
+
+sal_uInt8 GetColorValue( double nVal, double nVal1, sal_uInt8 nColVal1, double nVal2, sal_uInt8 nColVal2 )
+{
+ if (nVal <= nVal1)
+ return nColVal1;
+
+ if (nVal >= nVal2)
+ return nColVal2;
+
+ sal_uInt8 nColVal = static_cast<sal_uInt8>((nVal - nVal1)/(nVal2-nVal1)*(nColVal2-nColVal1))+nColVal1;
+ return nColVal;
+}
+
+Color CalcColor( double nVal, double nVal1, const Color& rCol1, double nVal2, const Color& rCol2)
+{
+ sal_uInt8 nColRed = GetColorValue(nVal, nVal1, rCol1.GetRed(), nVal2, rCol2.GetRed());
+ sal_uInt8 nColBlue = GetColorValue(nVal, nVal1, rCol1.GetBlue(), nVal2, rCol2.GetBlue());
+ sal_uInt8 nColGreen = GetColorValue(nVal, nVal1, rCol1.GetGreen(), nVal2, rCol2.GetGreen());
+
+ return Color(nColRed, nColGreen, nColBlue);
+}
+
+}
+
+Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const
+{
+ CellType eCellType = mpDoc->GetCellType(rAddr);
+ if(eCellType != CELLTYPE_VALUE && eCellType != CELLTYPE_FORMULA)
+ return NULL;
+
+ if (eCellType == CELLTYPE_FORMULA)
+ {
+ if(!static_cast<ScFormulaCell*>(mpDoc->GetCell(rAddr))->IsValue())
+ return NULL;
+ }
+
+ // now we have for sure a value
+ double nVal = mpDoc->GetValue(rAddr);
+
+ if (!maColorScales.size() < 2)
+ return NULL;
+
+ const_iterator itr = begin();
+ double nValMin = itr->GetValue();
+ Color rColMin = itr->GetColor();
+ ++itr;
+ double nValMax = itr->GetValue();
+ Color rColMax = itr->GetColor();
+
+ while(itr != end() && nVal > nValMin)
+ {
+ ++itr;
+ rColMin = rColMax;
+ nValMin = nValMax;
+ rColMax = itr->GetColor();
+ nValMax = itr->GetValue();
+ }
+
+ Color aColor = CalcColor(nVal, nValMin, rColMin, nValMax, rColMax);
+
+ return new Color(aColor);
+}
+
+ScColorScaleFormat::iterator ScColorScaleFormat::begin()
+{
+ return maColorScales.begin();
+}
+
+ScColorScaleFormat::const_iterator ScColorScaleFormat::begin() const
+{
+ return maColorScales.begin();
+}
+
+ScColorScaleFormat::iterator ScColorScaleFormat::end()
+{
+ return maColorScales.end();
+}
+
+ScColorScaleFormat::const_iterator ScColorScaleFormat::end() const
+{
+ return maColorScales.end();
+}
+
+ScColorScaleFormat* ScColorScaleFormatList::GetFormat(sal_uInt32 nFormat)
+{
+ if( nFormat >= size() )
+ return NULL;
+
+ return &maColorScaleFormats[nFormat];
+}
+
+ScColorScaleFormatList::iterator ScColorScaleFormatList::begin()
+{
+ return maColorScaleFormats.begin();
+}
+
+ScColorScaleFormatList::const_iterator ScColorScaleFormatList::begin() const
+{
+ return maColorScaleFormats.begin();
+}
+
+ScColorScaleFormatList::iterator ScColorScaleFormatList::end()
+{
+ return maColorScaleFormats.end();
+}
+
+ScColorScaleFormatList::const_iterator ScColorScaleFormatList::end() const
+{
+ return maColorScaleFormats.end();
+}
+
+size_t ScColorScaleFormatList::size() const
+{
+ return maColorScaleFormats.size();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit e6afb05329dfc5774c6955076717bff5a331ecc5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue May 8 04:49:50 2012 +0200
updateReference needs to deal with inserting/deleting several sheets
Change-Id: I1cbb247cb95e412c9e62b36510ad5e58a60ebfdc
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index ce70aa7..321edc4 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -468,7 +468,7 @@ void ScConditionEntry::SetFormula2( const ScTokenArray& rArray )
}
}
-void lcl_CondUpdateInsertTab( ScTokenArray& rCode, SCTAB nInsTab, SCTAB nPosTab, bool& rChanged )
+void lcl_CondUpdateInsertTab( ScTokenArray& rCode, SCTAB nInsTab, SCTAB nPosTab, bool& rChanged, SCTAB nTabs )
{
// Insert table: only update absolute table references.
// (Similar to ScCompiler::UpdateInsertTab with bIsName=true, result is the same as for named ranges)
@@ -481,7 +481,7 @@ void lcl_CondUpdateInsertTab( ScTokenArray& rCode, SCTAB nInsTab, SCTAB nPosTab,
ScSingleRefData& rRef1 = p->GetSingleRef();
if ( !rRef1.IsTabRel() && nInsTab <= rRef1.nTab )
{
- rRef1.nTab += 1;
+ rRef1.nTab += nTabs;
rRef1.nRelTab = rRef1.nTab - nPosTab;
rChanged = true;
}
@@ -490,7 +490,7 @@ void lcl_CondUpdateInsertTab( ScTokenArray& rCode, SCTAB nInsTab, SCTAB nPosTab,
ScSingleRefData& rRef2 = p->GetDoubleRef().Ref2;
if ( !rRef2.IsTabRel() && nInsTab <= rRef2.nTab )
{
- rRef2.nTab += 1;
+ rRef2.nTab += nTabs;
rRef2.nRelTab = rRef2.nTab - nPosTab;
rChanged = true;
}
@@ -502,8 +502,8 @@ void lcl_CondUpdateInsertTab( ScTokenArray& rCode, SCTAB nInsTab, SCTAB nPosTab,
void ScConditionEntry::UpdateReference( UpdateRefMode eUpdateRefMode,
const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
{
- bool bInsertTab = ( eUpdateRefMode == URM_INSDEL && nDz == 1 );
- bool bDeleteTab = ( eUpdateRefMode == URM_INSDEL && nDz == -1 );
+ bool bInsertTab = ( eUpdateRefMode == URM_INSDEL && nDz >= 1 );
+ bool bDeleteTab = ( eUpdateRefMode == URM_INSDEL && nDz <= -1 );
bool bChanged1 = false;
bool bChanged2 = false;
@@ -511,13 +511,13 @@ void ScConditionEntry::UpdateReference( UpdateRefMode eUpdateRefMode,
if (pFormula1)
{
if ( bInsertTab )
- lcl_CondUpdateInsertTab( *pFormula1, rRange.aStart.Tab(), aSrcPos.Tab(), bChanged1 );
+ lcl_CondUpdateInsertTab( *pFormula1, rRange.aStart.Tab(), aSrcPos.Tab(), bChanged1, nDz );
else
{
ScCompiler aComp( pDoc, aSrcPos, *pFormula1 );
aComp.SetGrammar(pDoc->GetGrammar());
if ( bDeleteTab )
- aComp.UpdateDeleteTab( rRange.aStart.Tab(), false, true, bChanged1 );
+ aComp.UpdateDeleteTab( rRange.aStart.Tab(), false, true, bChanged1, static_cast<SCTAB>(-1 * nDz) );
else
aComp.UpdateNameReference( eUpdateRefMode, rRange, nDx, nDy, nDz, bChanged1 );
}
@@ -528,13 +528,13 @@ void ScConditionEntry::UpdateReference( UpdateRefMode eUpdateRefMode,
if (pFormula2)
{
if ( bInsertTab )
- lcl_CondUpdateInsertTab( *pFormula2, rRange.aStart.Tab(), aSrcPos.Tab(), bChanged2 );
+ lcl_CondUpdateInsertTab( *pFormula2, rRange.aStart.Tab(), aSrcPos.Tab(), bChanged2, nDz );
else
{
ScCompiler aComp( pDoc, aSrcPos, *pFormula2);
aComp.SetGrammar(pDoc->GetGrammar());
if ( bDeleteTab )
- aComp.UpdateDeleteTab( rRange.aStart.Tab(), false, true, bChanged2 );
+ aComp.UpdateDeleteTab( rRange.aStart.Tab(), false, true, bChanged2, static_cast<SCTAB>(-1*nDz) );
else
aComp.UpdateNameReference( eUpdateRefMode, rRange, nDx, nDy, nDz, bChanged2 );
}
commit dd5086102184b31b6706991d40332986a6f045be
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue May 8 03:52:02 2012 +0200
DECL_PTRARR_SORT to ptr_set in conditio.[ch]xx
Change-Id: I I7de285ae784ae144a7d3190d4f99c1b38694da28
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index a60c836..f0acc90 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -36,6 +36,8 @@
#include "scdllapi.h"
#include "rangelst.hxx"
+#include <boost/ptr_container/ptr_set.hpp>
+
class ScBaseCell;
class ScFormulaCell;
class ScTokenArray;
@@ -261,13 +263,11 @@ public:
// List of areas and formats:
//
-typedef ScConditionalFormat* ScConditionalFormatPtr;
-
-SV_DECL_PTRARR_SORT(ScConditionalFormats_Impl, ScConditionalFormatPtr,
- SC_COND_GROW)
-
-class ScConditionalFormatList : public ScConditionalFormats_Impl
+class ScConditionalFormatList
{
+private:
+ boost::ptr_set<ScConditionalFormat> maConditionalFormats;
+ typedef boost::ptr_set<ScConditionalFormat> ConditionalFormatContainer;
public:
ScConditionalFormatList() {}
ScConditionalFormatList(const ScConditionalFormatList& rList);
@@ -275,7 +275,7 @@ public:
~ScConditionalFormatList() {}
void InsertNew( ScConditionalFormat* pNew )
- { if (!Insert(pNew)) delete pNew; }
+ { maConditionalFormats.insert(pNew); }
ScConditionalFormat* GetFormat( sal_uInt32 nKey );
@@ -289,6 +289,16 @@ public:
void SourceChanged( const ScAddress& rAddr );
bool operator==( const ScConditionalFormatList& r ) const; // for Ref-Undo
+
+ typedef ConditionalFormatContainer::iterator iterator;
+ typedef ConditionalFormatContainer::const_iterator const_iterator;
+
+ SC_DLLPUBLIC iterator begin();
+ SC_DLLPUBLIC const_iterator begin() const;
+ SC_DLLPUBLIC iterator end();
+ SC_DLLPUBLIC const_iterator end() const;
+
+ size_t size() const;
};
#endif
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 35bc83a..ce70aa7 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -49,10 +49,6 @@
using namespace formula;
//------------------------------------------------------------------------
-SV_IMPL_OP_PTRARR_SORT( ScConditionalFormats_Impl, ScConditionalFormatPtr );
-
-//------------------------------------------------------------------------
-
bool lcl_HasRelRef( ScDocument* pDoc, ScTokenArray* pFormula, sal_uInt16 nRecursion = 0 )
{
if (pFormula)
@@ -1579,15 +1575,12 @@ bool ScConditionalFormat::MarkUsedExternalReferences() const
//------------------------------------------------------------------------
-ScConditionalFormatList::ScConditionalFormatList(const ScConditionalFormatList& rList) :
- ScConditionalFormats_Impl()
+ScConditionalFormatList::ScConditionalFormatList(const ScConditionalFormatList& rList)
{
// fuer Ref-Undo - echte Kopie mit neuen Tokens!
- sal_uInt16 nCount = rList.Count();
-
- for (sal_uInt16 i=0; i<nCount; i++)
- InsertNew( rList[i]->Clone() );
+ for(const_iterator itr = rList.begin(); itr != rList.end(); ++itr)
+ InsertNew( itr->Clone() );
//! sortierte Eintraege aus rList schneller einfuegen ???
}
@@ -1597,10 +1590,8 @@ ScConditionalFormatList::ScConditionalFormatList(ScDocument* pNewDoc,
{
// fuer neues Dokument - echte Kopie mit neuen Tokens!
- sal_uInt16 nCount = rList.Count();
-
- for (sal_uInt16 i=0; i<nCount; i++)
- InsertNew( rList[i]->Clone(pNewDoc) );
+ for(const_iterator itr = rList.begin(); itr != rList.end(); ++itr)
+ InsertNew( itr->Clone(pNewDoc) );
//! sortierte Eintraege aus rList schneller einfuegen ???
}
@@ -1609,10 +1600,11 @@ bool ScConditionalFormatList::operator==( const ScConditionalFormatList& r ) con
{
// fuer Ref-Undo - interne Variablen werden nicht verglichen
- sal_uInt16 nCount = Count();
- bool bEqual = ( nCount == r.Count() );
- for (sal_uInt16 i=0; i<nCount && bEqual; i++) // Eintraege sind sortiert
- if ( !(*this)[i]->EqualEntries(*r[i]) ) // Eintraege unterschiedlich ?
+ sal_uInt16 nCount = size();
+ bool bEqual = ( nCount == r.size() );
+ const_iterator locIterator = begin();
+ for(const_iterator itr = r.begin(); itr != r.end() && bEqual; ++itr, ++locIterator)
+ if ( !locIterator->EqualEntries(*itr) ) // Eintraege unterschiedlich ?
bEqual = false;
return bEqual;
@@ -1622,10 +1614,9 @@ ScConditionalFormat* ScConditionalFormatList::GetFormat( sal_uInt32 nKey )
{
//! binaer suchen
- sal_uInt16 nCount = Count();
- for (sal_uInt16 i=0; i<nCount; i++)
- if ((*this)[i]->GetKey() == nKey)
- return (*this)[i];
+ for( iterator itr = begin(); itr != end(); ++itr)
+ if (itr->GetKey() == nKey)
+ return &(*itr);
OSL_FAIL("ScConditionalFormatList: Eintrag nicht gefunden");
return NULL;
@@ -1633,45 +1624,64 @@ ScConditionalFormat* ScConditionalFormatList::GetFormat( sal_uInt32 nKey )
void ScConditionalFormatList::CompileAll()
{
- sal_uInt16 nCount = Count();
- for (sal_uInt16 i=0; i<nCount; i++)
- (*this)[i]->CompileAll();
+ for( iterator itr = begin(); itr != end(); ++itr)
+ itr->CompileAll();
}
void ScConditionalFormatList::CompileXML()
{
- sal_uInt16 nCount = Count();
- for (sal_uInt16 i=0; i<nCount; i++)
- (*this)[i]->CompileXML();
+ for( iterator itr = begin(); itr != end(); ++itr)
+ itr->CompileXML();
}
void ScConditionalFormatList::UpdateReference( UpdateRefMode eUpdateRefMode,
const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
{
- sal_uInt16 nCount = Count();
- for (sal_uInt16 i=0; i<nCount; i++)
- (*this)[i]->UpdateReference( eUpdateRefMode, rRange, nDx, nDy, nDz );
+ for( iterator itr = begin(); itr != end(); ++itr)
+ itr->UpdateReference( eUpdateRefMode, rRange, nDx, nDy, nDz );
}
void ScConditionalFormatList::RenameCellStyle( const String& rOld, const String& rNew )
{
- sal_uLong nCount=Count();
- for (sal_uInt16 i=0; i<nCount; i++)
- (*this)[i]->RenameCellStyle(rOld,rNew);
+ for( iterator itr = begin(); itr != end(); ++itr)
+ itr->RenameCellStyle(rOld,rNew);
}
void ScConditionalFormatList::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos )
{
- sal_uInt16 nCount = Count();
- for (sal_uInt16 i=0; i<nCount; i++)
- (*this)[i]->UpdateMoveTab( nOldPos, nNewPos );
+ for( iterator itr = begin(); itr != end(); ++itr)
+ itr->UpdateMoveTab( nOldPos, nNewPos );
}
void ScConditionalFormatList::SourceChanged( const ScAddress& rAddr )
{
- sal_uInt16 nCount = Count();
- for (sal_uInt16 i=0; i<nCount; i++)
- (*this)[i]->SourceChanged( rAddr );
+ for( iterator itr = begin(); itr != end(); ++itr)
+ itr->SourceChanged( rAddr );
+}
+
+ScConditionalFormatList::iterator ScConditionalFormatList::begin()
+{
+ return maConditionalFormats.begin();
+}
+
+ScConditionalFormatList::const_iterator ScConditionalFormatList::begin() const
+{
+ return maConditionalFormats.begin();
+}
+
+ScConditionalFormatList::iterator ScConditionalFormatList::end()
+{
+ return maConditionalFormats.end();
+}
+
+ScConditionalFormatList::const_iterator ScConditionalFormatList::end() const
+{
+ return maConditionalFormats.end();
+}
+
+size_t ScConditionalFormatList::size() const
+{
+ return maConditionalFormats.size();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 8df1096..b7011c1 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -410,7 +410,6 @@ ScDocument::~ScDocument()
if (pCondFormList)
{
- pCondFormList->DeleteAndDestroy( 0, pCondFormList->Count() );
DELETEZ(pCondFormList);
}
if (pValidationList)
@@ -458,7 +457,6 @@ void ScDocument::InitClipPtrs( ScDocument* pSourceDoc )
if (pCondFormList)
{
- pCondFormList->DeleteAndDestroy( 0, pCondFormList->Count() );
DELETEZ(pCondFormList);
}
if (pValidationList)
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 4a73dca..31185cc 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -608,12 +608,11 @@ sal_uLong ScDocument::AddCondFormat( const ScConditionalFormat& rNew )
pCondFormList = new ScConditionalFormatList;
sal_uLong nMax = 0;
- sal_uInt16 nCount = pCondFormList->Count();
- for (sal_uInt16 i=0; i<nCount; i++)
+ for (ScConditionalFormatList::const_iterator itr = pCondFormList->begin();
+ itr != pCondFormList->end(); ++itr)
{
- const ScConditionalFormat* pForm = (*pCondFormList)[i];
- sal_uLong nKey = pForm->GetKey();
- if ( pForm->EqualEntries( rNew ) )
+ sal_uLong nKey = itr->GetKey();
+ if ( itr->EqualEntries( rNew ) )
return nKey;
if ( nKey > nMax )
nMax = nKey;
@@ -761,7 +760,6 @@ void ScDocument::SetCondFormList(ScConditionalFormatList* pNew)
{
if (pCondFormList)
{
- pCondFormList->DeleteAndDestroy( 0, pCondFormList->Count() );
delete pCondFormList;
}
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 8dfe1cb..fb974d9 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -936,18 +936,12 @@ XclExpCondFormatBuffer::XclExpCondFormatBuffer( const XclExpRoot& rRoot ) :
{
if( const ScConditionalFormatList* pCondFmtList = GetDoc().GetCondFormList() )
{
- if( const ScConditionalFormatPtr* ppCondFmt = pCondFmtList->GetData() )
+ for( ScConditionalFormatList::const_iterator itr = pCondFmtList->begin();
+ itr != pCondFmtList->end(); ++itr)
{
- const ScConditionalFormatPtr* ppCondEnd = ppCondFmt + pCondFmtList->Count();
- for( ; ppCondFmt < ppCondEnd; ++ppCondFmt )
- {
- if( *ppCondFmt )
- {
- XclExpCondfmtList::RecordRefType xCondfmtRec( new XclExpCondfmt( GetRoot(), **ppCondFmt ) );
- if( xCondfmtRec->IsValid() )
- maCondfmtList.AppendRecord( xCondfmtRec );
- }
- }
+ XclExpCondfmtList::RecordRefType xCondfmtRec( new XclExpCondfmt( GetRoot(), *itr ) );
+ if( xCondfmtRec->IsValid() )
+ maCondfmtList.AppendRecord( xCondfmtRec );
}
}
}
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index 7d98fcf..aaed2c9 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -2854,15 +2854,14 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot )
ScConditionalFormatList* pList = rRoot.GetDoc().GetCondFormList();
if (pList)
{
- sal_Int32 nFormatCount = pList->Count();
sal_Int32 nIndex = 0;
- for(sal_Int32 nItem = 0; nItem < nFormatCount; ++nItem)
+ for (ScConditionalFormatList::const_iterator itr = pList->begin();
+ itr != pList->end(); ++itr)
{
- ScConditionalFormat* pFormat = (*pList)[nItem];
- sal_Int32 nEntryCount = pFormat->Count();
+ sal_Int32 nEntryCount = itr->Count();
for (sal_Int32 nFormatEntry = 0; nFormatEntry < nEntryCount; ++nFormatEntry)
{
- const ScCondFormatEntry* pEntry = pFormat->GetEntry(nFormatEntry);
+ const ScCondFormatEntry* pEntry = itr->GetEntry(nFormatEntry);
if (!pEntry)
continue;
More information about the Libreoffice-commits
mailing list