diff options
Diffstat (limited to 'sc/source/ui/unoobj/cellsuno.cxx')
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 23 |
1 files changed, 19 insertions, 4 deletions
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 ); + } } } } |