summaryrefslogtreecommitdiff
path: root/sc/source/ui/docshell
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-04-23 05:23:50 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-04-24 23:39:56 +0200
commitf2431c944376433219eb7eb704e9b21589f201f5 (patch)
treeda6cf07070e1116a4ed1a0259b8a2f096987eebc /sc/source/ui/docshell
parent96475ada3fcf026ae7833824a056b642c1bd1864 (diff)
add undo action for conditional formatting, cp#1000050, fdo#77381
Change-Id: I11db1e5824077135c4352ae43cc0e8d139244268
Diffstat (limited to 'sc/source/ui/docshell')
-rw-r--r--sc/source/ui/docshell/docfunc.cxx40
1 files changed, 38 insertions, 2 deletions
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 5950a9ddd111..9a9daa3f42d7 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5302,6 +5302,31 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFor
if(pDoc->IsTabProtected(nTab))
return;
+ bool bUndo = pDoc->IsUndoEnabled();
+ ScDocument* pUndoDoc = NULL;
+ ScRange aCombinedRange = rRanges.Combine();
+ ScRange aCompleteRange;
+ if(bUndo)
+ {
+ pUndoDoc = new ScDocument(SCDOCMODE_UNDO);
+ pUndoDoc->InitUndo( pDoc, nTab, nTab );
+
+ if(pFormat)
+ {
+ aCompleteRange = aCombinedRange;
+ }
+ if(nOldFormat)
+ {
+ ScConditionalFormat* pOldFormat = pDoc->GetCondFormList(nTab)->GetFormat(nOldFormat);
+ if(pOldFormat)
+ aCompleteRange.ExtendTo(pOldFormat->GetRange().Combine());
+ }
+
+ pDoc->CopyToDocument( aCompleteRange.aStart.Col(),aCompleteRange.aStart.Row(),nTab,
+ aCompleteRange.aEnd.Col(),aCompleteRange.aEnd.Row(),nTab,
+ IDF_ALL, false, pUndoDoc );
+ }
+
boost::scoped_ptr<ScRange> pRepaintRange;
if(nOldFormat)
{
@@ -5318,9 +5343,9 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFor
if(pFormat)
{
if(pRepaintRange)
- pRepaintRange->ExtendTo(rRanges.Combine());
+ pRepaintRange->ExtendTo(aCombinedRange);
else
- pRepaintRange.reset(new ScRange(rRanges.Combine()));
+ pRepaintRange.reset(new ScRange(aCombinedRange));
sal_uLong nIndex = pDoc->AddCondFormat(pFormat, nTab);
@@ -5328,6 +5353,17 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFor
pDoc->SetStreamValid(nTab, false);
}
+ if(bUndo)
+ {
+ ScDocument* pRedoDoc = new ScDocument(SCDOCMODE_UNDO);
+ pRedoDoc->InitUndo( pDoc, nTab, nTab );
+ pDoc->CopyToDocument( aCompleteRange.aStart.Col(),aCompleteRange.aStart.Row(),nTab,
+ aCompleteRange.aEnd.Col(),aCompleteRange.aEnd.Row(),nTab,
+ IDF_ALL, false, pRedoDoc );
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoConditionalFormat(&rDocShell, pUndoDoc, pRedoDoc, aCompleteRange));
+ }
+
if(pRepaintRange)
rDocShell.PostPaint(*pRepaintRange, PAINT_GRID);