diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-06-04 10:24:45 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-06-11 08:01:24 +0200 |
commit | caad0f6c79909f2fb4865ac8395fc1798b8be7a6 (patch) | |
tree | 3e88a00425eadfebb08ca673d929ea60a4c6a0c7 /sc | |
parent | integrate color formats into conditional formats (diff) | |
download | core-caad0f6c79909f2fb4865ac8395fc1798b8be7a6.tar.gz core-caad0f6c79909f2fb4865ac8395fc1798b8be7a6.zip |
adjust import/export code to merged conditional formats
Change-Id: Ib9cd4e09e55ff2413db8e1daf45624d695e3113d
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/colorscale.hxx | 53 | ||||
-rw-r--r-- | sc/inc/conditio.hxx | 6 | ||||
-rw-r--r-- | sc/inc/document.hxx | 9 | ||||
-rw-r--r-- | sc/inc/table.hxx | 9 | ||||
-rw-r--r-- | sc/source/core/data/colorscale.cxx | 172 | ||||
-rw-r--r-- | sc/source/core/data/conditio.cxx | 95 | ||||
-rw-r--r-- | sc/source/core/data/documen4.cxx | 35 | ||||
-rw-r--r-- | sc/source/core/data/documen7.cxx | 17 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 31 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/xicontent.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/oox/condformatbuffer.cxx | 52 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcondformat.cxx | 43 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcondformat.hxx | 6 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun2.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/viewfunc.cxx | 8 |
18 files changed, 161 insertions, 404 deletions
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index 32be4a60ffed..fd2322b6fafc 100644 --- a/sc/inc/colorscale.hxx +++ b/sc/inc/colorscale.hxx @@ -99,6 +99,22 @@ struct ScDataBarFormatData meAxisPosition(databar::AUTOMATIC), mbOnlyBar(false){} + ScDataBarFormatData(const ScDataBarFormatData& r): + maPositiveColor(r.maPositiveColor), + mbGradient(r.mbGradient), + mbNeg(r.mbNeg), + meAxisPosition(r.meAxisPosition), + mbOnlyBar(r.mbOnlyBar) + { + if(r.mpNegativeColor) + mpNegativeColor.reset(new Color(*r.mpNegativeColor)); + + if(r.mpLowerLimit) + mpLowerLimit.reset( new ScColorScaleEntry(*r.mpLowerLimit)); + if(r.mpUpperLimit) + mpUpperLimit.reset( new ScColorScaleEntry(*r.mpUpperLimit)); + } + /** * Color for all Positive Values and if mbNeg == false also for negative ones */ @@ -145,7 +161,6 @@ class SC_DLLPUBLIC ScColorFormat : public ScFormatEntry { public: ScColorFormat(ScDocument* pDoc); - ScColorFormat(ScDocument* pDoc, const ScColorFormat& rFormat); virtual ~ScColorFormat(); void SetRange(const ScRangeList& rList); @@ -157,7 +172,6 @@ public: protected: void getValues( std::vector<double>& rValues ) const; - ScRangeList maRanges; ScConditionalFormat* mpParent; }; @@ -221,39 +235,4 @@ private: boost::scoped_ptr<ScDataBarFormatData> mpFormatData; }; -class SC_DLLPUBLIC ScColorFormatList -{ -private: - typedef boost::ptr_vector<ScColorFormat> ColorFormatContainer; - ColorFormatContainer maColorScaleFormats; -public: - ScColorFormatList() {} - ScColorFormatList(const ScColorFormatList& rList); - - typedef ColorFormatContainer::iterator iterator; - typedef ColorFormatContainer::const_iterator const_iterator; - - ScColorFormat* GetFormat(sal_uInt32 nFormat); - void AddFormat( ScColorFormat* pFormat ); - - void DataChanged(const ScRange& rRange); - void UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab); - void UpdateReference( UpdateRefMode eUpdateRefMode, - const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz ); - - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; - - size_t size() const; -}; - -// see http://www.boost.org/doc/libs/1_49_0/libs/ptr_container/doc/tutorial.html#cloneability -//for MSVC we need: -inline ScFormatEntry* new_clone( const ScColorFormat& rFormat ) -{ - return rFormat.Clone(); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx index b11261868ed4..6874c7815645 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -259,7 +259,7 @@ class SC_DLLPUBLIC ScConditionalFormat typedef boost::ptr_vector<ScFormatEntry> CondFormatContainer; CondFormatContainer maEntries; bool bIsUsed; // temporary at Save - ScRangeListRef pRanges; // Ranges for conditional format + ScRangeList maRanges; // Ranges for conditional format public: ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocument); @@ -270,8 +270,8 @@ public: ScConditionalFormat* Clone(ScDocument* pNewDoc = NULL) const; void AddEntry( ScFormatEntry* pNew ); - void AddRangeInfo( const ScRangeListRef& rRanges ); - const ScRangeListRef& GetRangeInfo() const { return pRanges; } + void AddRange( const ScRangeList& rRanges ); + const ScRangeList& GetRange() const { return maRanges; } bool IsEmpty() const { return maEntries.empty(); } size_t size() const { return maEntries.size(); } diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 90d2f768b1ec..cc2780f694aa 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -97,7 +97,6 @@ class ScChartListenerCollection; class ScConditionalFormat; class ScConditionalFormatList; class ScColorFormat; -class ScColorFormatList; class ScDBCollection; class ScDBData; class ScDetOpData; @@ -1165,7 +1164,7 @@ public: const ScPatternAttr* GetSelectionPattern( const ScMarkData& rMark, bool bDeep = true ); ScPatternAttr* CreateSelectionPattern( const ScMarkData& rMark, bool bDeep = true ); - const ScConditionalFormat* GetCondFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + SC_DLLPUBLIC ScConditionalFormat* GetCondFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; SC_DLLPUBLIC const SfxItemSet* GetCondResult( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; const SfxPoolItem* GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const; @@ -1196,8 +1195,7 @@ public: void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark ); void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark ); - SC_DLLPUBLIC sal_uLong AddCondFormat( const ScConditionalFormat& rNew, SCTAB nTab ); - SC_DLLPUBLIC sal_uLong AddColorFormat( ScColorFormat* pNew, SCTAB nTab ); + SC_DLLPUBLIC sal_uLong AddCondFormat( ScConditionalFormat* pNew, SCTAB nTab ); SC_DLLPUBLIC void FindConditionalFormat( sal_uLong nKey, SCTAB nTab, ScRangeList& rRanges ); SC_DLLPUBLIC void FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges, SCTAB nTab ); void ConditionalChanged( sal_uLong nKey, SCTAB nTab ); @@ -1208,9 +1206,6 @@ public: SC_DLLPUBLIC ScConditionalFormatList* GetCondFormList( SCTAB nTab ) const; - SC_DLLPUBLIC const ScColorFormatList* GetColorScaleList(SCTAB nTab) const; - SC_DLLPUBLIC ScColorFormatList* GetColorScaleList(SCTAB nTab); - ScValidationDataList* GetValidationList() const { return pValidationList; } diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 3e3572095832..4c5d69759eed 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -73,8 +73,6 @@ class ScProgress; class ScRangeList; class ScSheetEvents; class ScSortInfoArray; -class ScColorFormatList; -class ScColorFormat; class ScConditionalFormat; class ScConditionalFormatList; class ScStyleSheet; @@ -174,7 +172,6 @@ private: mutable ScRangeName* mpRangeName; boost::scoped_ptr<ScConditionalFormatList> mpCondFormatList; - boost::scoped_ptr<ScColorFormatList> mpColorFormatList; ScNotes maNotes; @@ -800,11 +797,7 @@ public: ScConditionalFormatList* GetCondFormList(); const ScConditionalFormatList* GetCondFormList() const; - sal_uLong AddCondFormat( const ScConditionalFormat& rNew ); - sal_uLong AddColorFormat( ScColorFormat* pNew ); - ScColorFormatList* GetColorFormatList(); - const ScColorFormatList* GetColorFormatList() const; - + sal_uLong AddCondFormat( ScConditionalFormat* pNew ); private: void FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index e1c19c0e2851..e16cc228deaf 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -140,12 +140,6 @@ ScColorFormat::ScColorFormat(ScDocument* pDoc): { } -ScColorFormat::ScColorFormat(ScDocument* pDoc, const ScColorFormat& rFormat): - ScFormatEntry(pDoc), - maRanges(rFormat.maRanges) -{ -} - ScColorFormat::~ScColorFormat() { } @@ -161,7 +155,7 @@ ScColorScaleFormat::ScColorScaleFormat(ScDocument* pDoc): } ScColorScaleFormat::ScColorScaleFormat(ScDocument* pDoc, const ScColorScaleFormat& rFormat): - ScColorFormat(pDoc, rFormat) + ScColorFormat(pDoc) { for(const_iterator itr = rFormat.begin(); itr != rFormat.end(); ++itr) { @@ -333,7 +327,7 @@ double ScColorScaleFormat::GetMinValue() const return itr->GetValue(); else { - return getMinValue(maRanges, mpDoc); + return getMinValue(GetRange(), mpDoc); } } @@ -345,7 +339,7 @@ double ScColorScaleFormat::GetMaxValue() const return itr->GetValue(); else { - return getMaxValue(maRanges, mpDoc); + return getMaxValue(GetRange(), mpDoc); } } @@ -355,22 +349,18 @@ void ScColorScaleFormat::calcMinMax(double& rMin, double& rMax) const rMax = GetMaxValue(); } -void ScColorFormat::SetRange(const ScRangeList& rList) -{ - maRanges = rList; -} - const ScRangeList& ScColorFormat::GetRange() const { - return maRanges; + return mpParent->GetRange(); } void ScColorFormat::getValues(std::vector<double>& rValues) const { - size_t n = maRanges.size(); + size_t n = GetRange().size(); + const ScRangeList& aRanges = GetRange(); for(size_t i = 0; i < n; ++i) { - const ScRange* pRange = maRanges[i]; + const ScRange* pRange = aRanges[i]; SCTAB nTab = pRange->aStart.Tab(); for(SCCOL nCol = pRange->aStart.Col(); nCol <= pRange->aEnd.Col(); ++nCol) { @@ -517,57 +507,9 @@ Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const return new Color(aColor); } -namespace { - -SCTAB UpdateMoveTabRangeList( ScRangeList& rList, SCTAB nOldTab, SCTAB nNewTab ) -{ - size_t n = rList.size(); - SCTAB nMinTab = std::min<SCTAB>(nOldTab, nNewTab); - SCTAB nMaxTab = std::max<SCTAB>(nOldTab, nNewTab); - SCTAB nThisTab = -1; - for(size_t i = 0; i < n; ++i) - { - ScRange* pRange = rList[i]; - SCTAB nTab = pRange->aStart.Tab(); - if(nTab < nMinTab || nTab > nMaxTab) - { - nThisTab = nTab; - continue; - } - - if(nTab == nOldTab) - { - pRange->aStart.SetTab(nNewTab); - pRange->aEnd.SetTab(nNewTab); - nThisTab = nNewTab; - continue; - } - - if(nNewTab < nOldTab) - { - pRange->aStart.IncTab(); - pRange->aEnd.IncTab(); - nThisTab = nTab + 1; - } - else - { - pRange->aStart.IncTab(-1); - pRange->aEnd.IncTab(-1); - nThisTab = nTab - 1; - } - } - - if(nThisTab == -1) - nThisTab = 0; - - return nThisTab; -} - -} - void ScColorScaleFormat::UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab) { - SCTAB nThisTab = UpdateMoveTabRangeList(maRanges, nOldTab, nNewTab); + SCTAB nThisTab = GetRange().front()->aStart.Tab(); for(iterator itr = begin(); itr != end(); ++itr) { itr->UpdateMoveTab(nOldTab, nNewTab, nThisTab); @@ -577,8 +519,6 @@ void ScColorScaleFormat::UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab) void ScColorScaleFormat::UpdateReference( UpdateRefMode eUpdateRefMode, const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz ) { - maRanges.UpdateReference( eUpdateRefMode, mpDoc, rRange, nDx, nDy, nDz ); - for(iterator itr = begin(); itr != end(); ++itr) { itr->UpdateReference(eUpdateRefMode, rRange, nDx, nDy, nDz); @@ -602,7 +542,7 @@ bool ScColorScaleFormat::CheckEntriesForRel(const ScRange& rRange) const // TODO: check also if the changed value is the new min/max // or has been the old min/max value - bNeedUpdate = bNeedUpdate && maRanges.Intersects(rRange); + bNeedUpdate = bNeedUpdate && GetRange().Intersects(rRange); return bNeedUpdate; } @@ -611,10 +551,10 @@ void ScColorScaleFormat::DataChanged(const ScRange& rRange) bool bNeedUpdate = CheckEntriesForRel(rRange); if(bNeedUpdate) { - size_t n = maRanges.size(); + size_t n = GetRange().size(); for(size_t i = 0; i < n; ++i) { - ScRange* pRange = maRanges[i]; + const ScRange* pRange = GetRange()[i]; mpDoc->RepaintRange(*pRange); } } @@ -651,7 +591,8 @@ ScDataBarFormat::ScDataBarFormat(ScDocument* pDoc): } ScDataBarFormat::ScDataBarFormat(ScDocument* pDoc, const ScDataBarFormat& rFormat): - ScColorFormat(pDoc, rFormat) + ScColorFormat(pDoc), + mpFormatData(new ScDataBarFormatData(*rFormat.mpFormatData)) { } @@ -678,8 +619,6 @@ condformat::ScFormatEntryType ScDataBarFormat::GetType() const void ScDataBarFormat::UpdateReference( UpdateRefMode eRefMode, const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz ) { - maRanges.UpdateReference( eRefMode, mpDoc, rRange, nDx, nDy, nDz ); - mpFormatData->mpUpperLimit->UpdateReference( eRefMode, rRange, nDx, nDy, nDz ); mpFormatData->mpLowerLimit->UpdateReference( eRefMode, rRange, nDx, nDy, nDz ); } @@ -709,14 +648,14 @@ void ScDataBarFormat::DataChanged(const ScRange& rRange) bNeedUpdate = NeedUpdate(mpFormatData->mpUpperLimit.get()); bNeedUpdate &= NeedUpdate(mpFormatData->mpLowerLimit.get()); - bNeedUpdate &= maRanges.Intersects(rRange); + bNeedUpdate &= GetRange().Intersects(rRange); if(bNeedUpdate) { - size_t n = maRanges.size(); + size_t n = GetRange().size(); for(size_t i = 0; i < n; ++i) { - ScRange* pRange = maRanges[i]; + const ScRange* pRange = GetRange()[i]; mpDoc->RepaintRange(*pRange); } } @@ -724,7 +663,7 @@ void ScDataBarFormat::DataChanged(const ScRange& rRange) void ScDataBarFormat::UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab) { - SCTAB nThisTab = UpdateMoveTabRangeList(maRanges, nOldTab, nNewTab); + SCTAB nThisTab = GetRange().front()->aStart.Tab(); mpFormatData->mpUpperLimit->UpdateMoveTab(nOldTab, nNewTab, nThisTab); mpFormatData->mpLowerLimit->UpdateMoveTab(nOldTab, nNewTab, nThisTab); } @@ -777,8 +716,8 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const // now we have for sure a value // - double nValMin = getMinValue(maRanges, mpDoc); - double nValMax = getMaxValue(maRanges, mpDoc); + double nValMin = getMinValue(GetRange(), mpDoc); + double nValMax = getMaxValue(GetRange(), mpDoc); double nMin = getMin(nValMin, nValMax); double nMax = getMax(nValMin, nValMax); @@ -873,77 +812,4 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const return pInfo; } -//----------------------------------------------------------------- - -ScColorFormatList::ScColorFormatList(ScDocument* pDoc, const ScColorFormatList& rList) -{ - for(const_iterator itr = rList.begin(); itr != rList.end(); ++itr) - { - } -} - -void ScColorFormatList::AddFormat( ScColorFormat* pFormat ) -{ - maColorScaleFormats.push_back( pFormat ); -} - -// attention nFormat is 1 based, 0 is reserved for no format -ScColorFormat* ScColorFormatList::GetFormat(sal_uInt32 nFormat) -{ - if( nFormat > size() || !nFormat ) - return NULL; - - return &maColorScaleFormats[nFormat-1]; -} - -ScColorFormatList::iterator ScColorFormatList::begin() -{ - return maColorScaleFormats.begin(); -} - -ScColorFormatList::const_iterator ScColorFormatList::begin() const -{ - return maColorScaleFormats.begin(); -} - -ScColorFormatList::iterator ScColorFormatList::end() -{ - return maColorScaleFormats.end(); -} - -ScColorFormatList::const_iterator ScColorFormatList::end() const -{ - return maColorScaleFormats.end(); -} - -size_t ScColorFormatList::size() const -{ - return maColorScaleFormats.size(); -} - -void ScColorFormatList::DataChanged(const ScRange& rRange) -{ - for(iterator itr = begin(); itr != end(); ++itr) - { - itr->DataChanged(rRange); - } -} - -void ScColorFormatList::UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab) -{ - for(iterator itr = begin(); itr != end(); ++itr) - { - itr->UpdateMoveTab(nOldTab, nNewTab); - } -} - -void ScColorFormatList::UpdateReference( UpdateRefMode eUpdateRefMode, - const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz ) -{ - for(iterator itr = begin(); itr != end(); ++itr) - { - itr->UpdateReference( eUpdateRefMode, rRange, nDx, nDy, nDz ); - } -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 03ddbe3c9b67..a4cd9ac0b9d8 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -740,12 +740,12 @@ static bool lcl_GetCellContent( ScBaseCell* pCell, bool bIsStr1, double& rArg, S return bVal; } -static bool lcl_IsDuplicate( ScDocument *pDoc, double nArg, const String& rStr, const ScAddress& rAddr, const ScRangeListRef& rRanges ) +static bool lcl_IsDuplicate( ScDocument *pDoc, double nArg, const String& rStr, const ScAddress& rAddr, const ScRangeList& rRanges ) { - size_t nListCount = rRanges->size(); + size_t nListCount = rRanges.size(); for( size_t i = 0; i < nListCount; i++ ) { - const ScRange *aRange = (*rRanges)[i]; + const ScRange *aRange = rRanges[i]; SCROW nRow = aRange->aEnd.Row(); SCCOL nCol = aRange->aEnd.Col(); for( SCROW r = aRange->aStart.Row(); r <= nRow; r++ ) @@ -839,8 +839,8 @@ bool ScConditionEntry::IsValid( double nArg, const ScAddress& rAddr ) const case SC_COND_NOTDUPLICATE: if( pCondFormat ) { - ScRangeListRef pRanges = pCondFormat->GetRangeInfo(); - bValid = lcl_IsDuplicate( mpDoc, nArg, String(), rAddr, pRanges ); + const ScRangeList& aRanges = pCondFormat->GetRange(); + bValid = lcl_IsDuplicate( mpDoc, nArg, String(), rAddr, aRanges ); if( eOp == SC_COND_NOTDUPLICATE ) bValid = !bValid; } @@ -867,8 +867,8 @@ bool ScConditionEntry::IsValidStr( const String& rArg, const ScAddress& rAddr ) { if( pCondFormat && rArg.Len() ) { - ScRangeListRef pRanges = pCondFormat->GetRangeInfo(); - bValid = lcl_IsDuplicate( mpDoc, 0.0, rArg, rAddr, pRanges ); + const ScRangeList& aRanges = pCondFormat->GetRange(); + bValid = lcl_IsDuplicate( mpDoc, 0.0, rArg, rAddr, aRanges ); if( eOp == SC_COND_NOTDUPLICATE ) bValid = !bValid; return bValid; @@ -1265,8 +1265,7 @@ ScFormatEntry* ScCondFormatEntry::Clone( ScDocument* pDoc ) const ScConditionalFormat::ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocument) : pDoc( pDocument ), pAreas( NULL ), - nKey( nNewKey ), - pRanges( NULL ) + nKey( nNewKey ) { } @@ -1274,7 +1273,7 @@ ScConditionalFormat::ScConditionalFormat(const ScConditionalFormat& r) : pDoc( r.pDoc ), pAreas( NULL ), nKey( r.nKey ), - pRanges( NULL ) + maRanges( r.maRanges ) { for (CondFormatContainer::const_iterator itr = r.maEntries.begin(); itr != r.maEntries.end(); ++itr) { @@ -1282,9 +1281,6 @@ ScConditionalFormat::ScConditionalFormat(const ScConditionalFormat& r) : maEntries.push_back( pNewEntry ); pNewEntry->SetParent(this); } - - if (r.pRanges) - pRanges = new ScRangeList( *r.pRanges ); } ScConditionalFormat* ScConditionalFormat::Clone(ScDocument* pNewDoc) const @@ -1302,7 +1298,7 @@ ScConditionalFormat* ScConditionalFormat::Clone(ScDocument* pNewDoc) const pNew->maEntries.push_back( pNewEntry ); pNewEntry->SetParent(pNew); } - pNew->AddRangeInfo( pRanges ); + pNew->AddRange( maRanges ); return pNew; } @@ -1320,23 +1316,12 @@ bool ScConditionalFormat::EqualEntries( const ScConditionalFormat& r ) const return false; */ - if (pRanges) - { - if (r.pRanges) - return *pRanges == *r.pRanges; - else - return false; - } - - // pRanges is NULL, which means r.pRanges must be NULL. - return r.pRanges.Is() == false; + return maRanges == r.maRanges; } -void ScConditionalFormat::AddRangeInfo( const ScRangeListRef& rRanges ) +void ScConditionalFormat::AddRange( const ScRangeList& rRanges ) { - if( !rRanges.Is() ) - return; - pRanges = new ScRangeList( *rRanges ); + maRanges = rRanges; } void ScConditionalFormat::AddEntry( ScFormatEntry* pNew ) @@ -1565,8 +1550,7 @@ void ScConditionalFormat::CompileXML() void ScConditionalFormat::UpdateReference( UpdateRefMode eUpdateRefMode, const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz ) { - if(pRanges) - pRanges->UpdateReference( eUpdateRefMode, pDoc, rRange, nDx, nDy, nDz ); + maRanges.UpdateReference( eUpdateRefMode, pDoc, rRange, nDx, nDy, nDz ); for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) itr->UpdateReference(eUpdateRefMode, rRange, nDx, nDy, nDz); @@ -1587,37 +1571,34 @@ void ScConditionalFormat::RenameCellStyle(const String& rOld, const String& rNew void ScConditionalFormat::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos ) { - if(pRanges) + size_t n = maRanges.size(); + SCTAB nMinTab = std::min<SCTAB>(nOldPos, nNewPos); + SCTAB nMaxTab = std::max<SCTAB>(nOldPos, nNewPos); + for(size_t i = 0; i < n; ++i) { - size_t n = pRanges->size(); - SCTAB nMinTab = std::min<SCTAB>(nOldPos, nNewPos); - SCTAB nMaxTab = std::max<SCTAB>(nOldPos, nNewPos); - for(size_t i = 0; i < n; ++i) + ScRange* pRange = maRanges[i]; + SCTAB nTab = pRange->aStart.Tab(); + if(nTab < nMinTab || nTab > nMaxTab) { - ScRange* pRange = (*pRanges)[i]; - SCTAB nTab = pRange->aStart.Tab(); - if(nTab < nMinTab || nTab > nMaxTab) - { - continue; - } + continue; + } - if(nTab == nOldPos) - { - pRange->aStart.SetTab(nNewPos); - pRange->aEnd.SetTab(nNewPos); - continue; - } + if(nTab == nOldPos) + { + pRange->aStart.SetTab(nNewPos); + pRange->aEnd.SetTab(nNewPos); + continue; + } - if(nNewPos < nOldPos) - { - pRange->aStart.IncTab(); - pRange->aEnd.IncTab(); - } - else - { - pRange->aStart.IncTab(-1); - pRange->aEnd.IncTab(-1); - } + if(nNewPos < nOldPos) + { + pRange->aStart.IncTab(); + pRange->aEnd.IncTab(); + } + else + { + pRange->aStart.IncTab(-1); + pRange->aEnd.IncTab(-1); } } diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index 9af43298258a..8ec16e0f66ca 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -592,42 +592,13 @@ double ScDocument::RoundValueAsShown( double fVal, sal_uLong nFormat ) // bedingte Formate und Gueltigkeitsbereiche // -sal_uLong ScDocument::AddCondFormat( const ScConditionalFormat& rNew, SCTAB nTab ) -{ - if (rNew.IsEmpty()) - return 0; // leer ist immer 0 - - if(VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]) - return maTabs[nTab]->AddCondFormat( rNew ); - - return 0; -} - -const ScColorFormatList* ScDocument::GetColorScaleList(SCTAB nTab) const -{ - if(VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]) - return maTabs[nTab]->GetColorFormatList(); - - return NULL; -} - -ScColorFormatList* ScDocument::GetColorScaleList( SCTAB nTab ) -{ - if(VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]) - return maTabs[nTab]->GetColorFormatList(); - - return NULL; -} - -//takes ownership -// returns a 1-based index, 0 is reserved for no entry -sal_uLong ScDocument::AddColorFormat( ScColorFormat* pNew, SCTAB nTab ) +sal_uLong ScDocument::AddCondFormat( ScConditionalFormat* pNew, SCTAB nTab ) { if(!pNew) return 0; if(VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]) - return maTabs[nTab]->AddColorFormat(pNew); + return maTabs[nTab]->AddCondFormat( pNew ); return 0; } @@ -715,7 +686,7 @@ const SfxItemSet* ScDocument::GetCondResult( SCCOL nCol, SCROW nRow, SCTAB nTab return NULL; } -const ScConditionalFormat* ScDocument::GetCondFormat( +ScConditionalFormat* ScDocument::GetCondFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const { sal_uLong nIndex = ((const SfxUInt32Item*)GetAttr(nCol,nRow,nTab,ATTR_CONDITIONAL))->GetValue(); diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx index 281de3a3b441..9e921500ef32 100644 --- a/sc/source/core/data/documen7.cxx +++ b/sc/source/core/data/documen7.cxx @@ -115,9 +115,6 @@ void ScDocument::Broadcast( const ScHint& rHint ) if ( pCondFormList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) pCondFormList->SourceChanged( rHint.GetAddress() ); - ScColorFormatList* pColorFormatList = GetColorScaleList(nTab); - if( pColorFormatList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) - pColorFormatList->DataChanged( rHint.GetAddress() ); } if ( rHint.GetAddress() != BCA_BRDCST_ALWAYS ) @@ -148,10 +145,6 @@ void ScDocument::AreaBroadcast( const ScHint& rHint ) ScConditionalFormatList* pCondFormList = GetCondFormList(nTab); if ( pCondFormList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) pCondFormList->SourceChanged( rHint.GetAddress() ); - - ScColorFormatList* pColorFormatList = GetColorScaleList(nTab); - if( pColorFormatList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) - pColorFormatList->DataChanged( rHint.GetAddress() ); } } @@ -176,7 +169,6 @@ void ScDocument::AreaBroadcastInRange( const ScRange& rRange, const ScHint& rHin continue; ScConditionalFormatList* pCondFormList = (*itr)->GetCondFormList(); - if ( pCondFormList ) { SCCOL nCol1; @@ -202,11 +194,6 @@ void ScDocument::AreaBroadcastInRange( const ScRange& rRange, const ScHint& rHin } } - ScColorFormatList* pColorFormatList = (*itr)->GetColorFormatList(); - if(pColorFormatList) - { - pColorFormatList->DataChanged(rRange); - } } } @@ -491,10 +478,6 @@ void ScDocument::TrackFormulas( sal_uLong nHintId ) ScConditionalFormatList* pCondFormList = (*itr)->GetCondFormList(); if ( pCondFormList ) pCondFormList->SourceChanged( pTrack->aPos ); - - ScColorFormatList* pColorFormatList = (*itr)->GetColorFormatList(); - if( pColorFormatList ) - pColorFormatList->DataChanged( pTrack->aPos ); } // for "calculate" event, keep track of which sheets are affected by tracked formulas if ( bCalcEvent ) diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 429ca0f16b57..b1acdf6d7622 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1505,8 +1505,6 @@ void ScTable::UpdateInsertTab(SCTAB nTable, SCTAB nNewSheets) if(mpCondFormatList) mpCondFormatList->UpdateReference( URM_INSDEL, ScRange(0,0, nTable, MAXCOL, MAXROW, nTable+nNewSheets-1),0,0, nNewSheets); - if(mpColorFormatList) - mpColorFormatList->UpdateReference( URM_INSDEL, ScRange(0,0, nTable, MAXCOL, MAXROW, nTable+nNewSheets-1),0,0, nNewSheets); } void ScTable::UpdateDeleteTab( SCTAB nTable, bool bIsMove, ScTable* pRefUndo, SCTAB nSheets ) @@ -1542,8 +1540,6 @@ void ScTable::UpdateDeleteTab( SCTAB nTable, bool bIsMove, ScTable* pRefUndo, SC if(mpCondFormatList) mpCondFormatList->UpdateReference( URM_INSDEL, ScRange(0,0, nTable, MAXCOL, MAXROW, nTable+nSheets-1),0,0, -1*nSheets); - if(mpColorFormatList) - mpColorFormatList->UpdateReference( URM_INSDEL, ScRange(0,0, nTable, MAXCOL, MAXROW, nTable+nSheets-1),0,0, -1*nSheets); } void ScTable::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo, @@ -1567,8 +1563,6 @@ void ScTable::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo, if(mpCondFormatList) mpCondFormatList->UpdateMoveTab(nOldPos, nNewPos); - if(mpColorFormatList) - mpColorFormatList->UpdateMoveTab(nOldPos, nNewPos); } void ScTable::UpdateCompile( bool bForceIfNameInUse ) @@ -2002,7 +1996,7 @@ ScDBData* ScTable::GetAnonymousDBData() return pDBDataNoName; } -sal_uLong ScTable::AddCondFormat( const ScConditionalFormat& rNew ) +sal_uLong ScTable::AddCondFormat( ScConditionalFormat* pNew ) { if(!mpCondFormatList) mpCondFormatList.reset(new ScConditionalFormatList()); @@ -2016,21 +2010,15 @@ sal_uLong ScTable::AddCondFormat( const ScConditionalFormat& rNew ) nMax = nKey; } - ScConditionalFormat* pNewFormat = rNew.Clone(pDocument); - pNewFormat->SetKey(nMax+1); - mpCondFormatList->InsertNew(pNewFormat); + pNew->SetKey(nMax+1); + mpCondFormatList->InsertNew(pNew); return nMax + 1; } -ScColorFormatList* ScTable::GetColorFormatList() +void ScTable::SetCondFormList( ScConditionalFormatList* pNew ) { - return mpColorFormatList.get(); -} - -const ScColorFormatList* ScTable::GetColorFormatList() const -{ - return mpColorFormatList.get(); + mpCondFormatList.reset( pNew ); } ScConditionalFormatList* ScTable::GetCondFormList() @@ -2046,13 +2034,4 @@ const ScConditionalFormatList* ScTable::GetCondFormList() const return mpCondFormatList.get(); } -sal_uLong ScTable::AddColorFormat( ScColorFormat* pNew ) -{ - if(!mpColorFormatList) - mpColorFormatList.reset(new ScColorFormatList()); - - mpColorFormatList->AddFormat( pNew ); - return mpColorFormatList->size(); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 9551c9205236..b56222595354 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -682,7 +682,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO ScConditionalFormat* pFormat = mpCondFormatList->GetFormat( nNewKey ); pFormat->UpdateReference(URM_MOVE, ScRange(nCol1 - nDx, nRow1 - nDy, pTable->nTab, nCol2 - nDx, nRow2 - nDy, pTable->nTab), nDx, nDy, pTable->nTab - nTab); - pFormat->AddRangeInfo(new ScRangeList(itr->second)); + pFormat->AddRange(itr->second); ScPatternAttr aPattern( pDocument->GetPool() ); aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nNewKey ) ); diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx index 5c739b4f8738..a6bb268877df 100644 --- a/sc/source/filter/excel/xicontent.cxx +++ b/sc/source/filter/excel/xicontent.cxx @@ -648,7 +648,7 @@ void XclImpCondFormat::Apply() { ScDocument& rDoc = GetDoc(); - sal_uLong nKey = rDoc.AddCondFormat( *mxScCondFmt, maRanges.front()->aStart.Tab() ); + sal_uLong nKey = rDoc.AddCondFormat( mxScCondFmt->Clone(), maRanges.front()->aStart.Tab() ); ScPatternAttr aPattern( rDoc.GetPool() ); aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nKey ) ); diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx index 2c3042474624..49d7a5064875 100644 --- a/sc/source/filter/oox/condformatbuffer.cxx +++ b/sc/source/filter/oox/condformatbuffer.cxx @@ -807,59 +807,81 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries > else if( mpColor ) { ScDocument& rDoc = getScDocument(); - ScColorScaleFormat* pFormat = new ScColorScaleFormat(&rDoc); + ScColorScaleFormat* pFormatEntry = new ScColorScaleFormat(&rDoc); + + const ApiCellRangeList& rRanges = mrCondFormat.getRanges(); + ScRange aRange; + ScUnoConversion::FillScRange(aRange, *rRanges.begin()); + + ScConditionalFormat* pFormat = rDoc.GetCondFormat( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aStart.Tab() ); + if(!pFormat) + { + pFormat = new ScConditionalFormat(0, &rDoc); + pFormat->AddEntry(pFormatEntry); + rDoc.AddCondFormat(pFormat, aRange.aStart.Tab()); + } + else + pFormat->AddEntry(pFormatEntry); - sal_Int32 nIndex = rDoc.AddColorFormat(pFormat, getSheetIndex()); + + sal_Int32 nIndex = pFormat->GetKey(); ScRangeList aList; // apply attributes to cells // - const ApiCellRangeList& rRanges = mrCondFormat.getRanges(); for( ApiCellRangeList::const_iterator itr = rRanges.begin(); itr != rRanges.end(); ++itr) { - ScRange aRange; ScUnoConversion::FillScRange(aRange, *itr); ScPatternAttr aPattern( rDoc.GetPool() ); - aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_COLORSCALE, nIndex ) ); + aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) ); ScMarkData aMarkData; aMarkData.SetMarkArea(aRange); rDoc.ApplySelectionPattern( aPattern , aMarkData); aList.Append(aRange); } - pFormat->SetRange(aList); if(aList.size()) - mpColor->AddEntries( pFormat, &rDoc, aList.front()->aStart ); + mpColor->AddEntries( pFormatEntry, &rDoc, aList.front()->aStart ); else - mpColor->AddEntries( pFormat, &rDoc, ScAddress() ); + mpColor->AddEntries( pFormatEntry, &rDoc, ScAddress() ); + pFormat->AddRange(aList); } else if (mpDataBar) { ScRangeList aList; ScDocument& rDoc = getScDocument(); - ScDataBarFormat* pFormat = new ScDataBarFormat(&rDoc); + ScDataBarFormat* pFormatEntry = new ScDataBarFormat(&rDoc); + const ApiCellRangeList& rRanges = mrCondFormat.getRanges(); + ScRange aRange; + ScUnoConversion::FillScRange(aRange, *rRanges.begin()); - sal_Int32 nIndex = rDoc.AddColorFormat(pFormat, getSheetIndex()); + ScConditionalFormat* pFormat = rDoc.GetCondFormat( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aStart.Tab() ); + if(!pFormat) + { + pFormat = new ScConditionalFormat(0, &rDoc); + sal_Int32 nKey = rDoc.AddCondFormat(pFormat, aRange.aStart.Tab()); + pFormat->SetKey(nKey); + } + pFormat->AddEntry(pFormatEntry); + sal_Int32 nIndex = pFormat->GetKey(); // apply attributes to cells // - const ApiCellRangeList& rRanges = mrCondFormat.getRanges(); for( ApiCellRangeList::const_iterator itr = rRanges.begin(); itr != rRanges.end(); ++itr) { - ScRange aRange; ScUnoConversion::FillScRange(aRange, *itr); ScPatternAttr aPattern( rDoc.GetPool() ); - aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_COLORSCALE, nIndex ) ); + aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) ); ScMarkData aMarkData; aMarkData.SetMarkArea(aRange); rDoc.ApplySelectionPattern( aPattern , aMarkData); aList.Append(aRange); } - pFormat->SetRange(aList); + mpDataBar->SetData( pFormatEntry, &rDoc, aList.front()->aStart ); - mpDataBar->SetData( pFormat, &rDoc, aList.front()->aStart ); + pFormat->AddRange(aList); } } diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx index d705394bc611..673ee00b9597 100644 --- a/sc/source/filter/xml/xmlcondformat.cxx +++ b/sc/source/filter/xml/xmlcondformat.cxx @@ -30,6 +30,7 @@ #include <xmloff/nmspmap.hxx> #include "colorscale.hxx" +#include "conditio.hxx" #include "document.hxx" #include <sax/tools/converter.hxx> #include "rangelst.hxx" @@ -46,6 +47,7 @@ ScXMLConditionalFormatsContext::ScXMLConditionalFormatsContext( ScXMLImport& rIm const ::rtl::OUString& rLName): SvXMLImportContext( rImport, nPrfx, rLName ) { + GetScImport().GetDocument()->SetCondFormList(new ScConditionalFormatList(), GetScImport().GetTables().GetCurrentSheet()); } SvXMLImportContext* ScXMLConditionalFormatsContext::CreateChildContext( sal_uInt16 nPrefix, @@ -99,6 +101,8 @@ ScXMLConditionalFormatContext::ScXMLConditionalFormatContext( ScXMLImport& rImpo ScRangeStringConverter::GetRangeListFromString(maRange, sRange, GetScImport().GetDocument(), formula::FormulaGrammar::CONV_ODF); + mpFormat = new ScConditionalFormat(0, GetScImport().GetDocument()); + mpFormat->AddRange(maRange); } SvXMLImportContext* ScXMLConditionalFormatContext::CreateChildContext( sal_uInt16 nPrefix, @@ -112,10 +116,10 @@ SvXMLImportContext* ScXMLConditionalFormatContext::CreateChildContext( sal_uInt1 switch (nToken) { case XML_TOK_CONDFORMAT_COLORSCALE: - pContext = new ScXMLColorScaleFormatContext( GetScImport(), nPrefix, rLocalName, maRange ); + pContext = new ScXMLColorScaleFormatContext( GetScImport(), nPrefix, rLocalName, mpFormat ); break; case XML_TOK_CONDFORMAT_DATABAR: - pContext = new ScXMLDataBarFormatContext( GetScImport(), nPrefix, rLocalName, xAttrList, maRange ); + pContext = new ScXMLDataBarFormatContext( GetScImport(), nPrefix, rLocalName, xAttrList, mpFormat ); break; default: break; @@ -126,15 +130,25 @@ SvXMLImportContext* ScXMLConditionalFormatContext::CreateChildContext( sal_uInt1 void ScXMLConditionalFormatContext::EndElement() { + ScDocument* pDoc = GetScImport().GetDocument(); + + sal_uLong nIndex = pDoc->AddCondFormat(mpFormat, GetScImport().GetTables().GetCurrentSheet()); + mpFormat->SetKey(nIndex); + + ScPatternAttr aPattern( pDoc->GetPool() ); + aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) ); + ScMarkData aMarkData; + aMarkData.MarkFromRangeList(mpFormat->GetRange(), true); + pDoc->ApplySelectionPattern( aPattern , aMarkData); } ScXMLColorScaleFormatContext::ScXMLColorScaleFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx, - const ::rtl::OUString& rLName, const ScRangeList& rRange): + const ::rtl::OUString& rLName, ScConditionalFormat* pFormat): SvXMLImportContext( rImport, nPrfx, rLName ), pColorScaleFormat(NULL) { pColorScaleFormat = new ScColorScaleFormat(GetScImport().GetDocument()); - pColorScaleFormat->SetRange(rRange); + pFormat->AddEntry(pColorScaleFormat); } SvXMLImportContext* ScXMLColorScaleFormatContext::CreateChildContext( sal_uInt16 nPrefix, @@ -159,20 +173,12 @@ SvXMLImportContext* ScXMLColorScaleFormatContext::CreateChildContext( sal_uInt16 void ScXMLColorScaleFormatContext::EndElement() { - ScDocument* pDoc = GetScImport().GetDocument(); - sal_uLong nIndex = pDoc->AddColorFormat(pColorScaleFormat, GetScImport().GetTables().GetCurrentSheet()); - - ScPatternAttr aPattern( pDoc->GetPool() ); - aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_COLORSCALE, nIndex ) ); - ScMarkData aMarkData; - aMarkData.MarkFromRangeList(pColorScaleFormat->GetRange(), true); - pDoc->ApplySelectionPattern( aPattern , aMarkData); } ScXMLDataBarFormatContext::ScXMLDataBarFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList, - const ScRangeList& rRange): + ScConditionalFormat* pFormat): SvXMLImportContext( rImport, nPrfx, rLName ), mpDataBarFormat(NULL), mpFormatData(NULL) @@ -249,7 +255,7 @@ ScXMLDataBarFormatContext::ScXMLDataBarFormatContext( ScXMLImport& rImport, sal_ mpFormatData->mbOnlyBar = !bShowValue; } - mpDataBarFormat->SetRange(rRange); + pFormat->AddEntry(mpDataBarFormat); } SvXMLImportContext* ScXMLDataBarFormatContext::CreateChildContext( sal_uInt16 nPrefix, @@ -274,15 +280,6 @@ SvXMLImportContext* ScXMLDataBarFormatContext::CreateChildContext( sal_uInt16 nP void ScXMLDataBarFormatContext::EndElement() { - ScDocument* pDoc = GetScImport().GetDocument(); - - sal_uLong nIndex = pDoc->AddColorFormat(mpDataBarFormat, GetScImport().GetTables().GetCurrentSheet()); - - ScPatternAttr aPattern( pDoc->GetPool() ); - aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_COLORSCALE, nIndex ) ); - ScMarkData aMarkData; - aMarkData.MarkFromRangeList(mpDataBarFormat->GetRange(), true); - pDoc->ApplySelectionPattern( aPattern , aMarkData); } namespace { diff --git a/sc/source/filter/xml/xmlcondformat.hxx b/sc/source/filter/xml/xmlcondformat.hxx index 42e5d0a665d1..80926ccb3b37 100644 --- a/sc/source/filter/xml/xmlcondformat.hxx +++ b/sc/source/filter/xml/xmlcondformat.hxx @@ -34,6 +34,7 @@ class ScColorScaleFormat; class ScColorScaleEntry; class ScDataBarFormat; struct ScDataBarFormatData; +class ScConditionalFormat; class ScXMLConditionalFormatsContext : public SvXMLImportContext { @@ -74,6 +75,7 @@ public: private: + ScConditionalFormat* mpFormat; ScRangeList maRange; }; @@ -85,7 +87,7 @@ private: public: ScXMLColorScaleFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx, - const ::rtl::OUString& rLName, const ScRangeList& rRange); + const ::rtl::OUString& rLName, ScConditionalFormat* pFormat); virtual ~ScXMLColorScaleFormatContext() {} @@ -111,7 +113,7 @@ public: const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList, - const ScRangeList& rRange); + ScConditionalFormat* pFormat); virtual ~ScXMLDataBarFormatContext() {} diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index ff5cd3de9bbe..bbca0dfca020 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -3817,17 +3817,9 @@ rtl::OUString getCondFormatEntryType(const ScColorScaleEntry& rEntry) void ScXMLExport::ExportConditionalFormat(SCTAB nTab) { ScConditionalFormatList* pCondFormatList = pDoc->GetCondFormList(nTab); - ScColorFormatList* pColorFormatList = pDoc->GetColorScaleList(nTab); - if(pCondFormatList || pColorFormatList) + if(pCondFormatList) { - bool bExport = false; if(pCondFormatList && pCondFormatList->size()) - bExport = true; - - if(pColorFormatList && pColorFormatList->size()) - bExport = true; - - if(!bExport) return; SvXMLElementExport aElementCondFormats(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITIONAL_FORMATS, true, true); @@ -3838,8 +3830,8 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab) itr != pCondFormatList->end(); ++itr) { rtl::OUString sRanges; - const ScRangeList* pRangeList = itr->GetRangeInfo(); - ScRangeStringConverter::GetStringFromRangeList( sRanges, pRangeList, pDoc, formula::FormulaGrammar::CONV_ODF ); + const ScRangeList& rRangeList = itr->GetRange(); + ScRangeStringConverter::GetStringFromRangeList( sRanges, &rRangeList, pDoc, formula::FormulaGrammar::CONV_ODF ); AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TARGET_RANGE_ADDRESS, sRanges); SvXMLElementExport aElementCondFormat(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITIONAL_FORMAT, true, true); size_t nEntries = itr->size(); diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 6a50811fafab..d33d8e47f5c0 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -2414,11 +2414,10 @@ void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pE formula::FormulaGrammar::GRAM_UNSPECIFIED : formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML)); - ScConditionalFormat aNew( 0, pDoc ); // Index wird beim Einfuegen gesetzt - pFormat->FillFormat( aNew, pDoc, eGrammar ); - ScRangeListRef pRanges = new ScRangeList( aRanges ); - aNew.AddRangeInfo( pRanges ); - sal_uLong nIndex = pDoc->AddCondFormat( aNew, aRanges.front()->aStart.Tab() ); + ScConditionalFormat* pNew = new ScConditionalFormat( 0, pDoc ); // Index wird beim Einfuegen gesetzt + pFormat->FillFormat( *pNew, pDoc, eGrammar ); + pNew->AddRange( aRanges ); + sal_uLong nIndex = pDoc->AddCondFormat( pNew, aRanges.front()->aStart.Tab() ); ScPatternAttr aPattern( pDoc->GetPool() ); aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) ); diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 8b7358c65e8b..8f83dbeafa30 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -3077,7 +3077,7 @@ void ScViewFunc::SetSelectionFrameLines( const SvxBorderLine* pLine, void ScViewFunc::SetConditionalFormat( const ScConditionalFormat& rNew ) { ScDocument* pDoc = GetViewData()->GetDocument(); - sal_uLong nIndex = pDoc->AddCondFormat(rNew, GetViewData()->GetTabNo()); // for it there is no Undo + sal_uLong nIndex = pDoc->AddCondFormat(rNew.Clone(), GetViewData()->GetTabNo()); // for it there is no Undo SfxUInt32Item aItem( ATTR_CONDITIONAL, nIndex ); ApplyAttr( aItem ); // with Paint and Undo... diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 0335455cc020..48c9a68344e9 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -88,13 +88,11 @@ static void lcl_PostRepaintCondFormat( const ScConditionalFormat *pCondFmt, ScDo { if( pCondFmt ) { - const ScRangeListRef& xRanges = pCondFmt->GetRangeInfo(); - if (!xRanges) - return; + const ScRangeList& rRanges = pCondFmt->GetRange(); - size_t nCount = xRanges->size(); + size_t nCount = rRanges.size(); for( size_t n = 0 ; n < nCount; n++ ) - pDocSh->PostPaint( *((*xRanges)[n]), PAINT_ALL ); + pDocSh->PostPaint( *(rRanges[n]), PAINT_ALL ); } } |