summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-12-23 20:39:53 +0100
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2015-01-07 08:54:46 +0100
commit67c989adc57eb279c478f59869499439ec65665f (patch)
tree3557e8d525a5b85ac35b4f46b7651ba72f9adb1b
parent57fa90ba145455a48247b0fef110aa8f87a86a5d (diff)
fdo#82014: Remove old conditional formats when setting new one by UNO API
Change-Id: I76488045eba281227124041da505e38c4c3d31c1
-rw-r--r--sc/inc/attarray.hxx1
-rw-r--r--sc/source/core/data/attarray.cxx8
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx23
3 files changed, 25 insertions, 7 deletions
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index 26d55e16295e..21a8eb6a18b0 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -132,6 +132,7 @@ public:
const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
void AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
+ /// if nIndex == 0, remove all conditional format data
void RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
void ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich );
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 0f7683cb746e..1e360ab49fcd 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -308,15 +308,17 @@ void ScAttrArray::RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 n
{
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())
+ if(itr != aCondFormatData.end() || nIndex == 0)
{
ScCondFormatItem aItem;
- aCondFormatData.erase(itr);
+ if (nIndex == 0)
+ aCondFormatData.clear();
+ else
+ aCondFormatData.erase(itr);
aItem.SetCondFormatData( aCondFormatData );
aPattern.GetItemSet().Put( aItem );
SetPatternArea( nTempStartRow, nTempEndRow, &aPattern, true );
}
-
}
}
else
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 6ec3abeecb8e..5228babdefe7 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -2392,11 +2392,26 @@ void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pE
formula::FormulaGrammar::GRAM_UNSPECIFIED :
formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
- ScConditionalFormat* pNew = new ScConditionalFormat( 0, &rDoc ); // Index wird beim Einfuegen gesetzt
- pFormat->FillFormat( *pNew, &rDoc, eGrammar );
- pNew->AddRange( aRanges );
SCTAB nTab = aRanges.front()->aStart.Tab();
- pDocShell->GetDocFunc().ReplaceConditionalFormat( 0, pNew, nTab, aRanges );
+ // To remove conditional formats for all cells in aRanges we need to:
+ // Remove conditional format data from cells' attributes
+ rDoc.RemoveCondFormatData( aRanges, nTab, 0 );
+ // And also remove ranges from conditional formats list
+ for (size_t i = 0; i < aRanges.size(); ++i)
+ {
+ rDoc.GetCondFormList( aRanges[i]->aStart.Tab() )->DeleteArea(
+ aRanges[i]->aStart.Col(), aRanges[i]->aStart.Row(),
+ aRanges[i]->aEnd.Col(), aRanges[i]->aEnd.Row() );
+ }
+
+ // Then we can apply new conditional format if there is one
+ if (pFormat->getCount())
+ {
+ ScConditionalFormat* pNew = new ScConditionalFormat( 0, &rDoc ); // Index wird beim Einfuegen gesetzt
+ pFormat->FillFormat( *pNew, &rDoc, eGrammar );
+ pNew->AddRange( aRanges );
+ pDocShell->GetDocFunc().ReplaceConditionalFormat( 0, pNew, nTab, aRanges );
+ }
}
}
}