Kaydet (Commit) 67c989ad authored tarafından Matúš Kukan's avatar Matúš Kukan Kaydeden (comit) Markus Mohrhard

fdo#82014: Remove old conditional formats when setting new one by UNO API

Change-Id: I76488045eba281227124041da505e38c4c3d31c1
üst 57fa90ba
......@@ -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 );
......
......@@ -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
......
......@@ -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 );
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment