diff options
-rw-r--r-- | sc/inc/attarray.hxx | 1 | ||||
-rw-r--r-- | sc/inc/column.hxx | 1 | ||||
-rw-r--r-- | sc/inc/document.hxx | 1 | ||||
-rw-r--r-- | sc/inc/table.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/attarray.cxx | 51 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 5 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 11 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 17 | ||||
-rw-r--r-- | sc/source/ui/docshell/docfunc.cxx | 7 |
9 files changed, 92 insertions, 3 deletions
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx index ded335eac829..167404967933 100644 --- a/sc/inc/attarray.hxx +++ b/sc/inc/attarray.hxx @@ -139,6 +139,7 @@ public: const ::editeng::SvxBorderLine* pLine, bool bColorOnly ); void AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ); + void RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ); void ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich ); void ChangeIndent( SCROW nStartRow, SCROW nEndRow, bool bIncrement ); diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 388b121646a6..3206637e7cfe 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -318,6 +318,7 @@ public: void ApplySelectionLineStyle( const ScMarkData& rMark, const ::editeng::SvxBorderLine* pLine, bool bColorOnly ); void AddCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ); + void RemoveCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ); const ScStyleSheet* GetStyle( SCROW nRow ) const; const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const; diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 51a549390524..f02f02821580 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1156,6 +1156,7 @@ public: const ScPatternAttr* GetSelectionPattern( const ScMarkData& rMark, bool bDeep = true ); ScPatternAttr* CreateSelectionPattern( const ScMarkData& rMark, bool bDeep = true ); SC_DLLPUBLIC void AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex ); + void RemoveCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex ); SC_DLLPUBLIC ScConditionalFormat* GetCondFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; SC_DLLPUBLIC const SfxItemSet* GetCondResult( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index e4d7ba0a2876..c630cb743574 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -544,6 +544,7 @@ public: void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange, const ScPatternAttr& rPattern, short nNewType ); void AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex ); + void RemoveCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex ); void ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet& rStyle ); void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScStyleSheet& rStyle ); diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index 1b16d0bcca4f..b7b2260e62bf 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -322,6 +322,57 @@ void ScAttrArray::AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nInd } +void ScAttrArray::RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ) +{ + if(!VALIDROW(nStartRow) || !VALIDROW(nEndRow)) + return; + + if(nEndRow < nStartRow) + return; + + SCROW nTempStartRow = nStartRow; + SCROW nTempEndRow = nEndRow; + + do + { + const ScPatternAttr* pPattern = GetPattern(nTempStartRow); + + ScPatternAttr aPattern( pDocument->GetPool() ); + if(pPattern) + { + SCROW nPatternStartRow; + SCROW nPatternEndRow; + GetPatternRange( nPatternStartRow, nPatternEndRow, nTempStartRow ); + + nTempEndRow = std::min<SCROW>( nPatternEndRow, nEndRow ); + const SfxPoolItem* pItem = NULL; + pPattern->GetItemSet().GetItemState( ATTR_CONDITIONAL, true, &pItem ); + if(pItem) + { + std::vector< sal_uInt32 > aCondFormatData = static_cast<const ScCondFormatItem*>(pItem)->GetCondFormatData(); + std::vector<sal_uInt32>::iterator itr = std::find(aCondFormatData.begin(), aCondFormatData.end(), nIndex); + if(itr != aCondFormatData.end()) + { + ScCondFormatItem aItem; + aCondFormatData.erase(itr); + aItem.SetCondFormatData( aCondFormatData ); + aPattern.GetItemSet().Put( aItem ); + SetPatternArea( nTempStartRow, nTempEndRow, &aPattern, true ); + } + + } + } + else + { + return; + } + + nTempStartRow = nTempEndRow + 1; + } + while(nTempEndRow < nEndRow); + +} + //------------------------------------------------------------------------ void ScAttrArray::SetPattern( SCROW nRow, const ScPatternAttr* pPattern, bool bPutToPool ) diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 446ddc140916..683f99dbc549 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -503,6 +503,11 @@ void ScColumn::AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex pAttrArray->AddCondFormat( nStartRow, nEndRow, nIndex ); } +void ScColumn::RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ) +{ + pAttrArray->RemoveCondFormat( nStartRow, nEndRow, nIndex ); +} + void ScColumn::ApplyStyle( SCROW nRow, const ScStyleSheet& rStyle ) { diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 14b6983d2990..30e12298e6b3 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -4222,6 +4222,17 @@ void ScDocument::AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_u maTabs[nTab]->AddCondFormatData(rRange, nIndex); } +void ScDocument::RemoveCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex ) +{ + if(!(static_cast<size_t>(nTab) < maTabs.size())) + return; + + if(!maTabs[nTab]) + return; + + maTabs[nTab]->RemoveCondFormatData(rRange, nIndex); +} + void ScDocument::ApplyStyle( SCCOL nCol, SCROW nRow, SCTAB nTab, const ScStyleSheet& rStyle) { diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index dbd65eb8d926..69c7d00ab0b8 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -2164,6 +2164,23 @@ void ScTable::AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex ) } } +void ScTable::RemoveCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex ) +{ + size_t n = rRange.size(); + for(size_t i = 0; i < n; ++i) + { + const ScRange* pRange = rRange[i]; + SCCOL nColStart = pRange->aStart.Col(); + SCCOL nColEnd = pRange->aEnd.Col(); + SCROW nRowStart = pRange->aStart.Row(); + SCROW nRowEnd = pRange->aEnd.Row(); + for(SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol) + { + aCol[nCol].RemoveCondFormat(nRowStart, nRowEnd, nIndex); + } + } +} + void ScTable::ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet& rStyle ) diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index c68b03d0feb0..99a65a2d30c7 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -5061,9 +5061,10 @@ sal_Bool ScDocFunc::InsertAreaLink( const String& rFile, const String& rFilter, namespace { -void RemoveCondFormatAttributes(ScDocument* pDoc, const ScConditionalFormat* pFormat) +void RemoveCondFormatAttributes(ScDocument* pDoc, const ScConditionalFormat* pFormat, SCTAB nTab) { const ScRangeList& rRangeList = pFormat->GetRange(); + pDoc->RemoveCondFormatData( rRangeList, nTab, pFormat->GetKey() ); } void SetConditionalFormatAttributes(ScDocument* pDoc, const ScRangeList& rRanges, sal_uLong nIndex, SCTAB nTab) @@ -5087,7 +5088,7 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFor pRepaintRange.reset(new ScRange( pOldFormat->GetRange().Combine() )); if(pOldFormat) { - RemoveCondFormatAttributes(pDoc, pOldFormat); + RemoveCondFormatAttributes(pDoc, pOldFormat, nTab); } pDoc->DeleteConditionalFormat(nOldFormat, nTab); @@ -5124,7 +5125,7 @@ void ScDocFunc::SetConditionalFormatList( ScConditionalFormatList* pList, SCTAB ScConditionalFormatList* pOldList = pDoc->GetCondFormList(nTab); for(ScConditionalFormatList::const_iterator itr = pOldList->begin(), itrEnd = pOldList->end(); itr != itrEnd; ++itr) { - RemoveCondFormatAttributes(pDoc, &(*itr)); + RemoveCondFormatAttributes(pDoc, &(*itr), nTab); } // then set new entries |