xref: /AOO41X/main/sc/source/ui/undo/undodat.cxx (revision b3f79822e811ac3493b185030a72c3c5a51f32d8)
1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <sfx2/app.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "undodat.hxx"
32cdf0e10cSrcweir #include "undoutil.hxx"
33cdf0e10cSrcweir #include "undoolk.hxx"
34cdf0e10cSrcweir #include "document.hxx"
35cdf0e10cSrcweir #include "docsh.hxx"
36cdf0e10cSrcweir #include "tabvwsh.hxx"
37cdf0e10cSrcweir #include "olinetab.hxx"
38cdf0e10cSrcweir #include "dbcolect.hxx"
39cdf0e10cSrcweir #include "rangenam.hxx"
40cdf0e10cSrcweir #include "pivot.hxx"
41cdf0e10cSrcweir #include "globstr.hrc"
42cdf0e10cSrcweir #include "global.hxx"
43cdf0e10cSrcweir #include "target.hxx"
44cdf0e10cSrcweir #include "chartarr.hxx"
45cdf0e10cSrcweir #include "dbdocfun.hxx"
46cdf0e10cSrcweir #include "olinefun.hxx"
47cdf0e10cSrcweir #include "dpobject.hxx"
48cdf0e10cSrcweir #include "attrib.hxx"
49cdf0e10cSrcweir #include "hints.hxx"
50cdf0e10cSrcweir #include "sc.hrc"
51cdf0e10cSrcweir 
52cdf0e10cSrcweir // -----------------------------------------------------------------------
53cdf0e10cSrcweir 
54cdf0e10cSrcweir TYPEINIT1(ScUndoDoOutline,          ScSimpleUndo);
55cdf0e10cSrcweir TYPEINIT1(ScUndoMakeOutline,        ScSimpleUndo);
56cdf0e10cSrcweir TYPEINIT1(ScUndoOutlineLevel,       ScSimpleUndo);
57cdf0e10cSrcweir TYPEINIT1(ScUndoOutlineBlock,       ScSimpleUndo);
58cdf0e10cSrcweir TYPEINIT1(ScUndoRemoveAllOutlines,  ScSimpleUndo);
59cdf0e10cSrcweir TYPEINIT1(ScUndoAutoOutline,        ScSimpleUndo);
60cdf0e10cSrcweir TYPEINIT1(ScUndoSubTotals,          ScDBFuncUndo);
61cdf0e10cSrcweir TYPEINIT1(ScUndoSort,               ScDBFuncUndo);
62cdf0e10cSrcweir TYPEINIT1(ScUndoQuery,              ScDBFuncUndo);
63cdf0e10cSrcweir TYPEINIT1(ScUndoAutoFilter,         ScDBFuncUndo);
64cdf0e10cSrcweir TYPEINIT1(ScUndoDBData,             ScSimpleUndo);
65cdf0e10cSrcweir TYPEINIT1(ScUndoImportData,         ScSimpleUndo);
66cdf0e10cSrcweir TYPEINIT1(ScUndoRepeatDB,           ScSimpleUndo);
67cdf0e10cSrcweir //UNUSED2008-05  TYPEINIT1(ScUndoPivot,              ScSimpleUndo);
68cdf0e10cSrcweir TYPEINIT1(ScUndoDataPilot,          ScSimpleUndo);
69cdf0e10cSrcweir TYPEINIT1(ScUndoConsolidate,        ScSimpleUndo);
70cdf0e10cSrcweir TYPEINIT1(ScUndoChartData,          ScSimpleUndo);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir // -----------------------------------------------------------------------
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 
75cdf0e10cSrcweir //
76cdf0e10cSrcweir //		Outline-Gruppen ein- oder ausblenden
77cdf0e10cSrcweir //
78cdf0e10cSrcweir 
ScUndoDoOutline(ScDocShell * pNewDocShell,SCCOLROW nNewStart,SCCOLROW nNewEnd,SCTAB nNewTab,ScDocument * pNewUndoDoc,sal_Bool bNewColumns,sal_uInt16 nNewLevel,sal_uInt16 nNewEntry,sal_Bool bNewShow)79cdf0e10cSrcweir ScUndoDoOutline::ScUndoDoOutline( ScDocShell* pNewDocShell,
80cdf0e10cSrcweir 							SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab,
81cdf0e10cSrcweir 							ScDocument* pNewUndoDoc, sal_Bool bNewColumns,
82cdf0e10cSrcweir 							sal_uInt16 nNewLevel, sal_uInt16 nNewEntry, sal_Bool bNewShow ) :
83cdf0e10cSrcweir 	ScSimpleUndo( pNewDocShell ),
84cdf0e10cSrcweir 	nStart( nNewStart ),
85cdf0e10cSrcweir 	nEnd( nNewEnd ),
86cdf0e10cSrcweir 	nTab( nNewTab ),
87cdf0e10cSrcweir 	pUndoDoc( pNewUndoDoc ),
88cdf0e10cSrcweir 	bColumns( bNewColumns ),
89cdf0e10cSrcweir 	nLevel( nNewLevel ),
90cdf0e10cSrcweir 	nEntry( nNewEntry ),
91cdf0e10cSrcweir 	bShow( bNewShow )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
~ScUndoDoOutline()95cdf0e10cSrcweir __EXPORT ScUndoDoOutline::~ScUndoDoOutline()
96cdf0e10cSrcweir {
97cdf0e10cSrcweir 	delete pUndoDoc;
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
GetComment() const100cdf0e10cSrcweir String __EXPORT ScUndoDoOutline::GetComment() const
101cdf0e10cSrcweir {	// Detail einblenden" "Detail ausblenden"
102cdf0e10cSrcweir 	return bShow ?
103cdf0e10cSrcweir 		ScGlobal::GetRscString( STR_UNDO_DOOUTLINE ) :
104cdf0e10cSrcweir 		ScGlobal::GetRscString( STR_UNDO_REDOOUTLINE );
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
Undo()107cdf0e10cSrcweir void __EXPORT ScUndoDoOutline::Undo()
108cdf0e10cSrcweir {
109cdf0e10cSrcweir 	BeginUndo();
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
112cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	//	Tabelle muss vorher umgeschaltet sein (#46952#) !!!
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
117cdf0e10cSrcweir 	if ( nVisTab != nTab )
118cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 	//	inverse Funktion ausfuehren
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	if (bShow)
123cdf0e10cSrcweir 		pViewShell->HideOutline( bColumns, nLevel, nEntry, sal_False, sal_False );
124cdf0e10cSrcweir 	else
125cdf0e10cSrcweir 		pViewShell->ShowOutline( bColumns, nLevel, nEntry, sal_False, sal_False );
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	//	Original Spalten-/Zeilenstatus
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	if (bColumns)
130cdf0e10cSrcweir         pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
131cdf0e10cSrcweir                 static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, sal_False, pDoc);
132cdf0e10cSrcweir 	else
133cdf0e10cSrcweir 		pUndoDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, sal_False, pDoc );
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	pViewShell->UpdateScrollBars();
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	EndUndo();
140cdf0e10cSrcweir }
141cdf0e10cSrcweir 
Redo()142cdf0e10cSrcweir void __EXPORT ScUndoDoOutline::Redo()
143cdf0e10cSrcweir {
144cdf0e10cSrcweir 	BeginRedo();
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	//	Tabelle muss vorher umgeschaltet sein (#46952#) !!!
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
151cdf0e10cSrcweir 	if ( nVisTab != nTab )
152cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	if (bShow)
155cdf0e10cSrcweir 		pViewShell->ShowOutline( bColumns, nLevel, nEntry, sal_False );
156cdf0e10cSrcweir 	else
157cdf0e10cSrcweir 		pViewShell->HideOutline( bColumns, nLevel, nEntry, sal_False );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	EndRedo();
160cdf0e10cSrcweir }
161cdf0e10cSrcweir 
Repeat(SfxRepeatTarget &)162cdf0e10cSrcweir void __EXPORT ScUndoDoOutline::Repeat(SfxRepeatTarget& /* rTarget */)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget &) const166cdf0e10cSrcweir sal_Bool __EXPORT ScUndoDoOutline::CanRepeat(SfxRepeatTarget& /* rTarget */) const
167cdf0e10cSrcweir {
168cdf0e10cSrcweir 	return sal_False;						// geht nicht
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir //
172cdf0e10cSrcweir //		Outline-Gruppen erzeugen oder loeschen
173cdf0e10cSrcweir //
174cdf0e10cSrcweir 
ScUndoMakeOutline(ScDocShell * pNewDocShell,SCCOL nStartX,SCROW nStartY,SCTAB nStartZ,SCCOL nEndX,SCROW nEndY,SCTAB nEndZ,ScOutlineTable * pNewUndoTab,sal_Bool bNewColumns,sal_Bool bNewMake)175cdf0e10cSrcweir ScUndoMakeOutline::ScUndoMakeOutline( ScDocShell* pNewDocShell,
176cdf0e10cSrcweir 							SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
177cdf0e10cSrcweir 							SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
178cdf0e10cSrcweir 							ScOutlineTable* pNewUndoTab, sal_Bool bNewColumns, sal_Bool bNewMake ) :
179cdf0e10cSrcweir 	ScSimpleUndo( pNewDocShell ),
180cdf0e10cSrcweir 	aBlockStart( nStartX, nStartY, nStartZ ),
181cdf0e10cSrcweir 	aBlockEnd( nEndX, nEndY, nEndZ ),
182cdf0e10cSrcweir 	pUndoTable( pNewUndoTab ),
183cdf0e10cSrcweir 	bColumns( bNewColumns ),
184cdf0e10cSrcweir 	bMake( bNewMake )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir }
187cdf0e10cSrcweir 
~ScUndoMakeOutline()188cdf0e10cSrcweir __EXPORT ScUndoMakeOutline::~ScUndoMakeOutline()
189cdf0e10cSrcweir {
190cdf0e10cSrcweir 	delete pUndoTable;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir 
GetComment() const193cdf0e10cSrcweir String __EXPORT ScUndoMakeOutline::GetComment() const
194cdf0e10cSrcweir {	// "Gruppierung" "Gruppierung aufheben"
195cdf0e10cSrcweir 	return bMake ?
196cdf0e10cSrcweir 		ScGlobal::GetRscString( STR_UNDO_MAKEOUTLINE ) :
197cdf0e10cSrcweir 		ScGlobal::GetRscString( STR_UNDO_REMAKEOUTLINE );
198cdf0e10cSrcweir }
199cdf0e10cSrcweir 
Undo()200cdf0e10cSrcweir void __EXPORT ScUndoMakeOutline::Undo()
201cdf0e10cSrcweir {
202cdf0e10cSrcweir 	BeginUndo();
203cdf0e10cSrcweir 
204cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
205cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
206cdf0e10cSrcweir 	SCTAB nTab = aBlockStart.Tab();
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 	ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd );
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 	pDoc->SetOutlineTable( nTab, pUndoTable );
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
213cdf0e10cSrcweir 	if ( nVisTab != nTab )
214cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 	pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 	EndUndo();
219cdf0e10cSrcweir }
220cdf0e10cSrcweir 
Redo()221cdf0e10cSrcweir void __EXPORT ScUndoMakeOutline::Redo()
222cdf0e10cSrcweir {
223cdf0e10cSrcweir 	BeginRedo();
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 	ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd );
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 	if (bMake)
230cdf0e10cSrcweir 		pViewShell->MakeOutline( bColumns, sal_False );
231cdf0e10cSrcweir 	else
232cdf0e10cSrcweir 		pViewShell->RemoveOutline( bColumns, sal_False );
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 	pDocShell->PostPaint(0,0,aBlockStart.Tab(),MAXCOL,MAXROW,aBlockEnd.Tab(),PAINT_GRID);
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 	EndRedo();
237cdf0e10cSrcweir }
238cdf0e10cSrcweir 
Repeat(SfxRepeatTarget & rTarget)239cdf0e10cSrcweir void __EXPORT ScUndoMakeOutline::Repeat(SfxRepeatTarget& rTarget)
240cdf0e10cSrcweir {
241cdf0e10cSrcweir 	if (rTarget.ISA(ScTabViewTarget))
242cdf0e10cSrcweir 	{
243cdf0e10cSrcweir 		ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 		if (bMake)
246cdf0e10cSrcweir 			rViewShell.MakeOutline( bColumns, sal_True );
247cdf0e10cSrcweir 		else
248cdf0e10cSrcweir 			rViewShell.RemoveOutline( bColumns, sal_True );
249cdf0e10cSrcweir 	}
250cdf0e10cSrcweir }
251cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget & rTarget) const252cdf0e10cSrcweir sal_Bool __EXPORT ScUndoMakeOutline::CanRepeat(SfxRepeatTarget& rTarget) const
253cdf0e10cSrcweir {
254cdf0e10cSrcweir 	return (rTarget.ISA(ScTabViewTarget));
255cdf0e10cSrcweir }
256cdf0e10cSrcweir 
257cdf0e10cSrcweir //
258cdf0e10cSrcweir //		Outline-Ebene auswaehlen
259cdf0e10cSrcweir //
260cdf0e10cSrcweir 
ScUndoOutlineLevel(ScDocShell * pNewDocShell,SCCOLROW nNewStart,SCCOLROW nNewEnd,SCTAB nNewTab,ScDocument * pNewUndoDoc,ScOutlineTable * pNewUndoTab,sal_Bool bNewColumns,sal_uInt16 nNewLevel)261cdf0e10cSrcweir ScUndoOutlineLevel::ScUndoOutlineLevel( ScDocShell* pNewDocShell,
262cdf0e10cSrcweir 						SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab,
263cdf0e10cSrcweir 						ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
264cdf0e10cSrcweir 						sal_Bool bNewColumns, sal_uInt16 nNewLevel ) :
265cdf0e10cSrcweir 	ScSimpleUndo( pNewDocShell ),
266cdf0e10cSrcweir 	nStart( nNewStart ),
267cdf0e10cSrcweir 	nEnd( nNewEnd ),
268cdf0e10cSrcweir 	nTab( nNewTab ),
269cdf0e10cSrcweir 	pUndoDoc( pNewUndoDoc ),
270cdf0e10cSrcweir 	pUndoTable( pNewUndoTab ),
271cdf0e10cSrcweir 	bColumns( bNewColumns ),
272cdf0e10cSrcweir 	nLevel( nNewLevel )
273cdf0e10cSrcweir {
274cdf0e10cSrcweir }
275cdf0e10cSrcweir 
~ScUndoOutlineLevel()276cdf0e10cSrcweir __EXPORT ScUndoOutlineLevel::~ScUndoOutlineLevel()
277cdf0e10cSrcweir {
278cdf0e10cSrcweir 	delete pUndoDoc;
279cdf0e10cSrcweir 	delete pUndoTable;
280cdf0e10cSrcweir }
281cdf0e10cSrcweir 
GetComment() const282cdf0e10cSrcweir String __EXPORT ScUndoOutlineLevel::GetComment() const
283cdf0e10cSrcweir {	// "Gliederungsebene auswaehlen";
284cdf0e10cSrcweir 	return ScGlobal::GetRscString( STR_UNDO_OUTLINELEVEL );
285cdf0e10cSrcweir }
286cdf0e10cSrcweir 
Undo()287cdf0e10cSrcweir void __EXPORT ScUndoOutlineLevel::Undo()
288cdf0e10cSrcweir {
289cdf0e10cSrcweir 	BeginUndo();
290cdf0e10cSrcweir 
291cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
292cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 	//	Original Outline-Table
295cdf0e10cSrcweir 
296cdf0e10cSrcweir 	pDoc->SetOutlineTable( nTab, pUndoTable );
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 	//	Original Spalten-/Zeilenstatus
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 	if (bColumns)
301cdf0e10cSrcweir         pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
302cdf0e10cSrcweir                 static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, sal_False, pDoc);
303cdf0e10cSrcweir 	else
304cdf0e10cSrcweir 		pUndoDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, sal_False, pDoc );
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 	pDoc->UpdatePageBreaks( nTab );
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 	pViewShell->UpdateScrollBars();
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
311cdf0e10cSrcweir 	if ( nVisTab != nTab )
312cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 	pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP);
315cdf0e10cSrcweir 
316cdf0e10cSrcweir 	EndUndo();
317cdf0e10cSrcweir }
318cdf0e10cSrcweir 
Redo()319cdf0e10cSrcweir void __EXPORT ScUndoOutlineLevel::Redo()
320cdf0e10cSrcweir {
321cdf0e10cSrcweir 	BeginRedo();
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
324cdf0e10cSrcweir 
325cdf0e10cSrcweir 	//	Tabelle muss vorher umgeschaltet sein (#46952#) !!!
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
328cdf0e10cSrcweir 	if ( nVisTab != nTab )
329cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 	pViewShell->SelectLevel( bColumns, nLevel, sal_False );
332cdf0e10cSrcweir 
333cdf0e10cSrcweir 	EndRedo();
334cdf0e10cSrcweir }
335cdf0e10cSrcweir 
Repeat(SfxRepeatTarget & rTarget)336cdf0e10cSrcweir void __EXPORT ScUndoOutlineLevel::Repeat(SfxRepeatTarget& rTarget)
337cdf0e10cSrcweir {
338cdf0e10cSrcweir 	if (rTarget.ISA(ScTabViewTarget))
339cdf0e10cSrcweir 		((ScTabViewTarget&)rTarget).GetViewShell()->SelectLevel( bColumns, nLevel, sal_True );
340cdf0e10cSrcweir }
341cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget & rTarget) const342cdf0e10cSrcweir sal_Bool __EXPORT ScUndoOutlineLevel::CanRepeat(SfxRepeatTarget& rTarget) const
343cdf0e10cSrcweir {
344cdf0e10cSrcweir 	return (rTarget.ISA(ScTabViewTarget));
345cdf0e10cSrcweir }
346cdf0e10cSrcweir 
347cdf0e10cSrcweir //
348cdf0e10cSrcweir //		Outline ueber Blockmarken ein- oder ausblenden
349cdf0e10cSrcweir //
350cdf0e10cSrcweir 
ScUndoOutlineBlock(ScDocShell * pNewDocShell,SCCOL nStartX,SCROW nStartY,SCTAB nStartZ,SCCOL nEndX,SCROW nEndY,SCTAB nEndZ,ScDocument * pNewUndoDoc,ScOutlineTable * pNewUndoTab,sal_Bool bNewShow)351cdf0e10cSrcweir ScUndoOutlineBlock::ScUndoOutlineBlock( ScDocShell* pNewDocShell,
352cdf0e10cSrcweir 						SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
353cdf0e10cSrcweir 						SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
354cdf0e10cSrcweir 						ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, sal_Bool bNewShow ) :
355cdf0e10cSrcweir 	ScSimpleUndo( pNewDocShell ),
356cdf0e10cSrcweir 	aBlockStart( nStartX, nStartY, nStartZ ),
357cdf0e10cSrcweir 	aBlockEnd( nEndX, nEndY, nEndZ ),
358cdf0e10cSrcweir 	pUndoDoc( pNewUndoDoc ),
359cdf0e10cSrcweir 	pUndoTable( pNewUndoTab ),
360cdf0e10cSrcweir 	bShow( bNewShow )
361cdf0e10cSrcweir {
362cdf0e10cSrcweir }
363cdf0e10cSrcweir 
~ScUndoOutlineBlock()364cdf0e10cSrcweir __EXPORT ScUndoOutlineBlock::~ScUndoOutlineBlock()
365cdf0e10cSrcweir {
366cdf0e10cSrcweir 	delete pUndoDoc;
367cdf0e10cSrcweir 	delete pUndoTable;
368cdf0e10cSrcweir }
369cdf0e10cSrcweir 
GetComment() const370cdf0e10cSrcweir String __EXPORT ScUndoOutlineBlock::GetComment() const
371cdf0e10cSrcweir {	// "Detail einblenden" "Detail ausblenden"
372cdf0e10cSrcweir 	return bShow ?
373cdf0e10cSrcweir 		ScGlobal::GetRscString( STR_UNDO_DOOUTLINEBLK ) :
374cdf0e10cSrcweir 		ScGlobal::GetRscString( STR_UNDO_REDOOUTLINEBLK );
375cdf0e10cSrcweir }
376cdf0e10cSrcweir 
Undo()377cdf0e10cSrcweir void __EXPORT ScUndoOutlineBlock::Undo()
378cdf0e10cSrcweir {
379cdf0e10cSrcweir 	BeginUndo();
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
382cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
383cdf0e10cSrcweir 	SCTAB nTab = aBlockStart.Tab();
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 	//	Original Outline-Table
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 	pDoc->SetOutlineTable( nTab, pUndoTable );
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 	//	Original Spalten-/Zeilenstatus
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 	SCCOLROW	nStartCol = aBlockStart.Col();
392cdf0e10cSrcweir 	SCCOLROW	nEndCol = aBlockEnd.Col();
393cdf0e10cSrcweir 	SCCOLROW	nStartRow = aBlockStart.Row();
394cdf0e10cSrcweir 	SCCOLROW	nEndRow = aBlockEnd.Row();
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 	if (!bShow)
397cdf0e10cSrcweir 	{								//	Groesse des ausgeblendeten Blocks
398cdf0e10cSrcweir 		sal_uInt16 nLevel;
399cdf0e10cSrcweir 		pUndoTable->GetColArray()->FindTouchedLevel( nStartCol, nEndCol, nLevel );
400cdf0e10cSrcweir 		pUndoTable->GetColArray()->ExtendBlock( nLevel, nStartCol, nEndCol );
401cdf0e10cSrcweir 		pUndoTable->GetRowArray()->FindTouchedLevel( nStartRow, nEndRow, nLevel );
402cdf0e10cSrcweir 		pUndoTable->GetRowArray()->ExtendBlock( nLevel, nStartRow, nEndRow );
403cdf0e10cSrcweir 	}
404cdf0e10cSrcweir 
405cdf0e10cSrcweir     pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStartCol), 0, nTab,
406cdf0e10cSrcweir             static_cast<SCCOL>(nEndCol), MAXROW, nTab, IDF_NONE, sal_False, pDoc );
407cdf0e10cSrcweir 	pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, sal_False, pDoc );
408cdf0e10cSrcweir 
409cdf0e10cSrcweir 	pDoc->UpdatePageBreaks( nTab );
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 	pViewShell->UpdateScrollBars();
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
414cdf0e10cSrcweir 	if ( nVisTab != nTab )
415cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 	pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP);
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 	EndUndo();
420cdf0e10cSrcweir }
421cdf0e10cSrcweir 
Redo()422cdf0e10cSrcweir void __EXPORT ScUndoOutlineBlock::Redo()
423cdf0e10cSrcweir {
424cdf0e10cSrcweir 	BeginRedo();
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 	ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd );
429cdf0e10cSrcweir 	if (bShow)
430cdf0e10cSrcweir 		pViewShell->ShowMarkedOutlines( sal_False );
431cdf0e10cSrcweir 	else
432cdf0e10cSrcweir 		pViewShell->HideMarkedOutlines( sal_False );
433cdf0e10cSrcweir 
434cdf0e10cSrcweir 	EndRedo();
435cdf0e10cSrcweir }
436cdf0e10cSrcweir 
Repeat(SfxRepeatTarget & rTarget)437cdf0e10cSrcweir void __EXPORT ScUndoOutlineBlock::Repeat(SfxRepeatTarget& rTarget)
438cdf0e10cSrcweir {
439cdf0e10cSrcweir 	if (rTarget.ISA(ScTabViewTarget))
440cdf0e10cSrcweir 	{
441cdf0e10cSrcweir 		ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 		if (bShow)
444cdf0e10cSrcweir 			rViewShell.ShowMarkedOutlines( sal_True );
445cdf0e10cSrcweir 		else
446cdf0e10cSrcweir 			rViewShell.HideMarkedOutlines( sal_True );
447cdf0e10cSrcweir 	}
448cdf0e10cSrcweir }
449cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget & rTarget) const450cdf0e10cSrcweir sal_Bool __EXPORT ScUndoOutlineBlock::CanRepeat(SfxRepeatTarget& rTarget) const
451cdf0e10cSrcweir {
452cdf0e10cSrcweir 	return (rTarget.ISA(ScTabViewTarget));
453cdf0e10cSrcweir }
454cdf0e10cSrcweir 
455cdf0e10cSrcweir //
456cdf0e10cSrcweir //		alle Outlines loeschen
457cdf0e10cSrcweir //
458cdf0e10cSrcweir 
ScUndoRemoveAllOutlines(ScDocShell * pNewDocShell,SCCOL nStartX,SCROW nStartY,SCTAB nStartZ,SCCOL nEndX,SCROW nEndY,SCTAB nEndZ,ScDocument * pNewUndoDoc,ScOutlineTable * pNewUndoTab)459cdf0e10cSrcweir ScUndoRemoveAllOutlines::ScUndoRemoveAllOutlines( ScDocShell* pNewDocShell,
460cdf0e10cSrcweir 									SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
461cdf0e10cSrcweir 									SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
462cdf0e10cSrcweir 									ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab ) :
463cdf0e10cSrcweir 	ScSimpleUndo( pNewDocShell ),
464cdf0e10cSrcweir 	aBlockStart( nStartX, nStartY, nStartZ ),
465cdf0e10cSrcweir 	aBlockEnd( nEndX, nEndY, nEndZ ),
466cdf0e10cSrcweir 	pUndoDoc( pNewUndoDoc ),
467cdf0e10cSrcweir 	pUndoTable( pNewUndoTab )
468cdf0e10cSrcweir {
469cdf0e10cSrcweir }
470cdf0e10cSrcweir 
~ScUndoRemoveAllOutlines()471cdf0e10cSrcweir __EXPORT ScUndoRemoveAllOutlines::~ScUndoRemoveAllOutlines()
472cdf0e10cSrcweir {
473cdf0e10cSrcweir 	delete pUndoDoc;
474cdf0e10cSrcweir 	delete pUndoTable;
475cdf0e10cSrcweir }
476cdf0e10cSrcweir 
GetComment() const477cdf0e10cSrcweir String __EXPORT ScUndoRemoveAllOutlines::GetComment() const
478cdf0e10cSrcweir {	// "Gliederung entfernen"
479cdf0e10cSrcweir 	return ScGlobal::GetRscString( STR_UNDO_REMOVEALLOTLNS );
480cdf0e10cSrcweir }
481cdf0e10cSrcweir 
Undo()482cdf0e10cSrcweir void __EXPORT ScUndoRemoveAllOutlines::Undo()
483cdf0e10cSrcweir {
484cdf0e10cSrcweir 	BeginUndo();
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
487cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
488cdf0e10cSrcweir 	SCTAB nTab = aBlockStart.Tab();
489cdf0e10cSrcweir 
490cdf0e10cSrcweir 	//	Original Outline-Table
491cdf0e10cSrcweir 
492cdf0e10cSrcweir 	pDoc->SetOutlineTable( nTab, pUndoTable );
493cdf0e10cSrcweir 
494cdf0e10cSrcweir 	//	Original Spalten-/Zeilenstatus
495cdf0e10cSrcweir 
496cdf0e10cSrcweir 	SCCOL	nStartCol = aBlockStart.Col();
497cdf0e10cSrcweir 	SCCOL	nEndCol = aBlockEnd.Col();
498cdf0e10cSrcweir 	SCROW	nStartRow = aBlockStart.Row();
499cdf0e10cSrcweir 	SCROW	nEndRow = aBlockEnd.Row();
500cdf0e10cSrcweir 
501cdf0e10cSrcweir 	pUndoDoc->CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, sal_False, pDoc );
502cdf0e10cSrcweir 	pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, sal_False, pDoc );
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 	pDoc->UpdatePageBreaks( nTab );
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 	pViewShell->UpdateScrollBars();
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
509cdf0e10cSrcweir 	if ( nVisTab != nTab )
510cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
511cdf0e10cSrcweir 
512cdf0e10cSrcweir 	pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 	EndUndo();
515cdf0e10cSrcweir }
516cdf0e10cSrcweir 
Redo()517cdf0e10cSrcweir void __EXPORT ScUndoRemoveAllOutlines::Redo()
518cdf0e10cSrcweir {
519cdf0e10cSrcweir 	BeginRedo();
520cdf0e10cSrcweir 
521cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
522cdf0e10cSrcweir 
523cdf0e10cSrcweir 	//	Tabelle muss vorher umgeschaltet sein (#46952#) !!!
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 	SCTAB nTab = aBlockStart.Tab();
526cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
527cdf0e10cSrcweir 	if ( nVisTab != nTab )
528cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
529cdf0e10cSrcweir 
530cdf0e10cSrcweir 	pViewShell->RemoveAllOutlines( sal_False );
531cdf0e10cSrcweir 
532cdf0e10cSrcweir 	EndRedo();
533cdf0e10cSrcweir }
534cdf0e10cSrcweir 
Repeat(SfxRepeatTarget & rTarget)535cdf0e10cSrcweir void __EXPORT ScUndoRemoveAllOutlines::Repeat(SfxRepeatTarget& rTarget)
536cdf0e10cSrcweir {
537cdf0e10cSrcweir 	if (rTarget.ISA(ScTabViewTarget))
538cdf0e10cSrcweir 		((ScTabViewTarget&)rTarget).GetViewShell()->RemoveAllOutlines( sal_True );
539cdf0e10cSrcweir }
540cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget & rTarget) const541cdf0e10cSrcweir sal_Bool __EXPORT ScUndoRemoveAllOutlines::CanRepeat(SfxRepeatTarget& rTarget) const
542cdf0e10cSrcweir {
543cdf0e10cSrcweir 	return (rTarget.ISA(ScTabViewTarget));
544cdf0e10cSrcweir }
545cdf0e10cSrcweir 
546cdf0e10cSrcweir //
547cdf0e10cSrcweir //		Auto-Outline
548cdf0e10cSrcweir //
549cdf0e10cSrcweir 
ScUndoAutoOutline(ScDocShell * pNewDocShell,SCCOL nStartX,SCROW nStartY,SCTAB nStartZ,SCCOL nEndX,SCROW nEndY,SCTAB nEndZ,ScDocument * pNewUndoDoc,ScOutlineTable * pNewUndoTab)550cdf0e10cSrcweir ScUndoAutoOutline::ScUndoAutoOutline( ScDocShell* pNewDocShell,
551cdf0e10cSrcweir 									SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
552cdf0e10cSrcweir 									SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
553cdf0e10cSrcweir 									ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab ) :
554cdf0e10cSrcweir 	ScSimpleUndo( pNewDocShell ),
555cdf0e10cSrcweir 	aBlockStart( nStartX, nStartY, nStartZ ),
556cdf0e10cSrcweir 	aBlockEnd( nEndX, nEndY, nEndZ ),
557cdf0e10cSrcweir 	pUndoDoc( pNewUndoDoc ),
558cdf0e10cSrcweir 	pUndoTable( pNewUndoTab )
559cdf0e10cSrcweir {
560cdf0e10cSrcweir }
561cdf0e10cSrcweir 
~ScUndoAutoOutline()562cdf0e10cSrcweir __EXPORT ScUndoAutoOutline::~ScUndoAutoOutline()
563cdf0e10cSrcweir {
564cdf0e10cSrcweir 	delete pUndoDoc;
565cdf0e10cSrcweir 	delete pUndoTable;
566cdf0e10cSrcweir }
567cdf0e10cSrcweir 
GetComment() const568cdf0e10cSrcweir String __EXPORT ScUndoAutoOutline::GetComment() const
569cdf0e10cSrcweir {	// "Auto-Gliederung"
570cdf0e10cSrcweir 	return ScGlobal::GetRscString( STR_UNDO_AUTOOUTLINE );
571cdf0e10cSrcweir }
572cdf0e10cSrcweir 
Undo()573cdf0e10cSrcweir void __EXPORT ScUndoAutoOutline::Undo()
574cdf0e10cSrcweir {
575cdf0e10cSrcweir 	BeginUndo();
576cdf0e10cSrcweir 
577cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
578cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
579cdf0e10cSrcweir 	SCTAB nTab = aBlockStart.Tab();
580cdf0e10cSrcweir 
581cdf0e10cSrcweir 	//	Original Outline-Table
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 	pDoc->SetOutlineTable( nTab, pUndoTable );
584cdf0e10cSrcweir 
585cdf0e10cSrcweir 	//	Original Spalten-/Zeilenstatus
586cdf0e10cSrcweir 
587cdf0e10cSrcweir 	if (pUndoDoc && pUndoTable)
588cdf0e10cSrcweir 	{
589cdf0e10cSrcweir 		SCCOLROW nStartCol;
590cdf0e10cSrcweir 		SCCOLROW nStartRow;
591cdf0e10cSrcweir 		SCCOLROW nEndCol;
592cdf0e10cSrcweir 		SCCOLROW nEndRow;
593cdf0e10cSrcweir 		pUndoTable->GetColArray()->GetRange( nStartCol, nEndCol );
594cdf0e10cSrcweir 		pUndoTable->GetRowArray()->GetRange( nStartRow, nEndRow );
595cdf0e10cSrcweir 
596cdf0e10cSrcweir         pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStartCol), 0, nTab,
597cdf0e10cSrcweir                 static_cast<SCCOL>(nEndCol), MAXROW, nTab, IDF_NONE, sal_False,
598cdf0e10cSrcweir                 pDoc);
599cdf0e10cSrcweir 		pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, sal_False, pDoc );
600cdf0e10cSrcweir 
601cdf0e10cSrcweir 		pViewShell->UpdateScrollBars();
602cdf0e10cSrcweir 	}
603cdf0e10cSrcweir 
604cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
605cdf0e10cSrcweir 	if ( nVisTab != nTab )
606cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
607cdf0e10cSrcweir 
608cdf0e10cSrcweir 	pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
609cdf0e10cSrcweir 
610cdf0e10cSrcweir 	EndUndo();
611cdf0e10cSrcweir }
612cdf0e10cSrcweir 
Redo()613cdf0e10cSrcweir void __EXPORT ScUndoAutoOutline::Redo()
614cdf0e10cSrcweir {
615cdf0e10cSrcweir 	BeginRedo();
616cdf0e10cSrcweir 
617cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
618cdf0e10cSrcweir 
619cdf0e10cSrcweir 	SCTAB nTab = aBlockStart.Tab();
620cdf0e10cSrcweir 	if (pViewShell)
621cdf0e10cSrcweir 	{
622cdf0e10cSrcweir 		//	Tabelle muss vorher umgeschaltet sein (#46952#) !!!
623cdf0e10cSrcweir 
624cdf0e10cSrcweir 		SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
625cdf0e10cSrcweir 		if ( nVisTab != nTab )
626cdf0e10cSrcweir 			pViewShell->SetTabNo( nTab );
627cdf0e10cSrcweir 	}
628cdf0e10cSrcweir 
629cdf0e10cSrcweir 	ScRange aRange( aBlockStart.Col(), aBlockStart.Row(), nTab,
630cdf0e10cSrcweir 					aBlockEnd.Col(),   aBlockEnd.Row(),   nTab );
631cdf0e10cSrcweir 	ScOutlineDocFunc aFunc( *pDocShell );
632cdf0e10cSrcweir 	aFunc.AutoOutline( aRange, sal_False, sal_False );
633cdf0e10cSrcweir 
634cdf0e10cSrcweir 	//	auf der View markieren
635cdf0e10cSrcweir 	//	Wenn's beim Aufruf eine Mehrfachselektion war, ist es jetzt der
636cdf0e10cSrcweir 	//	umschliessende Bereich...
637cdf0e10cSrcweir 
638cdf0e10cSrcweir 	if (pViewShell)
639cdf0e10cSrcweir 		pViewShell->MarkRange( aRange );
640cdf0e10cSrcweir 
641cdf0e10cSrcweir 	EndRedo();
642cdf0e10cSrcweir }
643cdf0e10cSrcweir 
Repeat(SfxRepeatTarget & rTarget)644cdf0e10cSrcweir void __EXPORT ScUndoAutoOutline::Repeat(SfxRepeatTarget& rTarget)
645cdf0e10cSrcweir {
646cdf0e10cSrcweir 	if (rTarget.ISA(ScTabViewTarget))
647cdf0e10cSrcweir 		((ScTabViewTarget&)rTarget).GetViewShell()->AutoOutline( sal_True );
648cdf0e10cSrcweir }
649cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget & rTarget) const650cdf0e10cSrcweir sal_Bool __EXPORT ScUndoAutoOutline::CanRepeat(SfxRepeatTarget& rTarget) const
651cdf0e10cSrcweir {
652cdf0e10cSrcweir 	return (rTarget.ISA(ScTabViewTarget));
653cdf0e10cSrcweir }
654cdf0e10cSrcweir 
655cdf0e10cSrcweir //
656cdf0e10cSrcweir //		Zwischenergebnisse
657cdf0e10cSrcweir //
658cdf0e10cSrcweir 
ScUndoSubTotals(ScDocShell * pNewDocShell,SCTAB nNewTab,const ScSubTotalParam & rNewParam,SCROW nNewEndY,ScDocument * pNewUndoDoc,ScOutlineTable * pNewUndoTab,ScRangeName * pNewUndoRange,ScDBCollection * pNewUndoDB)659cdf0e10cSrcweir ScUndoSubTotals::ScUndoSubTotals( ScDocShell* pNewDocShell, SCTAB nNewTab,
660cdf0e10cSrcweir 								const ScSubTotalParam& rNewParam, SCROW nNewEndY,
661cdf0e10cSrcweir 								ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
662cdf0e10cSrcweir 								ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB ) :
663cdf0e10cSrcweir 	ScDBFuncUndo( pNewDocShell, ScRange( rNewParam.nCol1, rNewParam.nRow1, nNewTab,
664cdf0e10cSrcweir 	                                     rNewParam.nCol2, rNewParam.nRow2, nNewTab ) ),
665cdf0e10cSrcweir 	nTab( nNewTab ),
666cdf0e10cSrcweir 	aParam( rNewParam ),
667cdf0e10cSrcweir 	nNewEndRow( nNewEndY ),
668cdf0e10cSrcweir 	pUndoDoc( pNewUndoDoc ),
669cdf0e10cSrcweir 	pUndoTable( pNewUndoTab ),
670cdf0e10cSrcweir 	pUndoRange( pNewUndoRange ),
671cdf0e10cSrcweir 	pUndoDB( pNewUndoDB )
672cdf0e10cSrcweir {
673cdf0e10cSrcweir }
674cdf0e10cSrcweir 
~ScUndoSubTotals()675cdf0e10cSrcweir __EXPORT ScUndoSubTotals::~ScUndoSubTotals()
676cdf0e10cSrcweir {
677cdf0e10cSrcweir 	delete pUndoDoc;
678cdf0e10cSrcweir 	delete pUndoTable;
679cdf0e10cSrcweir 	delete pUndoRange;
680cdf0e10cSrcweir 	delete pUndoDB;
681cdf0e10cSrcweir }
682cdf0e10cSrcweir 
GetComment() const683cdf0e10cSrcweir String __EXPORT ScUndoSubTotals::GetComment() const
684cdf0e10cSrcweir {	// "Teilergebnisse"
685cdf0e10cSrcweir 	return ScGlobal::GetRscString( STR_UNDO_SUBTOTALS );
686cdf0e10cSrcweir }
687cdf0e10cSrcweir 
Undo()688cdf0e10cSrcweir void __EXPORT ScUndoSubTotals::Undo()
689cdf0e10cSrcweir {
690cdf0e10cSrcweir 	BeginUndo();
691cdf0e10cSrcweir 
692cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
693cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
694cdf0e10cSrcweir 
695cdf0e10cSrcweir 	//	um einzelnen DB-Bereich anzupassen
696cdf0e10cSrcweir /*	ScDBData* pOldDBData = ScUndoUtil::GetOldDBData( pUndoDBData, pDoc, nTab,
697cdf0e10cSrcweir 										aParam.nCol1, aParam.nRow1, aParam.nCol2, nNewEndRow );
698cdf0e10cSrcweir */
699cdf0e10cSrcweir 
700cdf0e10cSrcweir 	if (nNewEndRow > aParam.nRow2)
701cdf0e10cSrcweir 	{
702cdf0e10cSrcweir 		pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, aParam.nRow2+1, static_cast<SCSIZE>(nNewEndRow-aParam.nRow2) );
703cdf0e10cSrcweir 	}
704cdf0e10cSrcweir 	else if (nNewEndRow < aParam.nRow2)
705cdf0e10cSrcweir 	{
706cdf0e10cSrcweir 		pDoc->InsertRow( 0,nTab, MAXCOL,nTab, nNewEndRow+1, static_cast<SCSIZE>(aParam.nRow2-nNewEndRow) );
707cdf0e10cSrcweir 	}
708cdf0e10cSrcweir 
709cdf0e10cSrcweir 
710cdf0e10cSrcweir 	//	Original Outline-Table
711cdf0e10cSrcweir 
712cdf0e10cSrcweir 	pDoc->SetOutlineTable( nTab, pUndoTable );
713cdf0e10cSrcweir 
714cdf0e10cSrcweir 	//	Original Spalten-/Zeilenstatus
715cdf0e10cSrcweir 
716cdf0e10cSrcweir 	if (pUndoDoc && pUndoTable)
717cdf0e10cSrcweir 	{
718cdf0e10cSrcweir 		SCCOLROW nStartCol;
719cdf0e10cSrcweir 		SCCOLROW nStartRow;
720cdf0e10cSrcweir 		SCCOLROW nEndCol;
721cdf0e10cSrcweir 		SCCOLROW nEndRow;
722cdf0e10cSrcweir 		pUndoTable->GetColArray()->GetRange( nStartCol, nEndCol );
723cdf0e10cSrcweir 		pUndoTable->GetRowArray()->GetRange( nStartRow, nEndRow );
724cdf0e10cSrcweir 
725cdf0e10cSrcweir         pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStartCol), 0, nTab,
726cdf0e10cSrcweir                 static_cast<SCCOL>(nEndCol), MAXROW, nTab, IDF_NONE, sal_False,
727cdf0e10cSrcweir                 pDoc);
728cdf0e10cSrcweir 		pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, sal_False, pDoc );
729cdf0e10cSrcweir 
730cdf0e10cSrcweir 		pViewShell->UpdateScrollBars();
731cdf0e10cSrcweir 	}
732cdf0e10cSrcweir 
733cdf0e10cSrcweir 	//	Original-Daten & Referenzen
734cdf0e10cSrcweir 
735cdf0e10cSrcweir 	ScUndoUtil::MarkSimpleBlock( pDocShell, 0, aParam.nRow1+1, nTab,
736cdf0e10cSrcweir 											MAXCOL, aParam.nRow2, nTab );
737cdf0e10cSrcweir 
738cdf0e10cSrcweir 	pDoc->DeleteAreaTab( 0,aParam.nRow1+1, MAXCOL,aParam.nRow2, nTab, IDF_ALL );
739cdf0e10cSrcweir 
740cdf0e10cSrcweir 	pUndoDoc->CopyToDocument( 0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab,
741cdf0e10cSrcweir 															IDF_NONE, sal_False, pDoc );	// Flags
742cdf0e10cSrcweir 	pUndoDoc->UndoToDocument( 0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab,
743cdf0e10cSrcweir 															IDF_ALL, sal_False, pDoc );
744cdf0e10cSrcweir 
745cdf0e10cSrcweir 	ScUndoUtil::MarkSimpleBlock( pDocShell, aParam.nCol1,aParam.nRow1,nTab,
746cdf0e10cSrcweir 											aParam.nCol2,aParam.nRow2,nTab );
747cdf0e10cSrcweir 
748cdf0e10cSrcweir /*	if (pUndoDBData)
749cdf0e10cSrcweir 		*pOldDBData = *pUndoDBData;
750cdf0e10cSrcweir */
751cdf0e10cSrcweir 	if (pUndoRange)
752cdf0e10cSrcweir 		pDoc->SetRangeName( new ScRangeName( *pUndoRange ) );
753cdf0e10cSrcweir 	if (pUndoDB)
754cdf0e10cSrcweir 		pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ), sal_True );
755cdf0e10cSrcweir 
756cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
757cdf0e10cSrcweir 	if ( nVisTab != nTab )
758cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
759cdf0e10cSrcweir 
760cdf0e10cSrcweir 	pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
761cdf0e10cSrcweir 	pDocShell->PostDataChanged();
762cdf0e10cSrcweir 
763cdf0e10cSrcweir 	EndUndo();
764cdf0e10cSrcweir }
765cdf0e10cSrcweir 
Redo()766cdf0e10cSrcweir void __EXPORT ScUndoSubTotals::Redo()
767cdf0e10cSrcweir {
768cdf0e10cSrcweir 	BeginRedo();
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
771cdf0e10cSrcweir 
772cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
773cdf0e10cSrcweir 	if ( nVisTab != nTab )
774cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
775cdf0e10cSrcweir 
776cdf0e10cSrcweir 	ScUndoUtil::MarkSimpleBlock( pDocShell, aParam.nCol1,aParam.nRow1,nTab,
777cdf0e10cSrcweir 											aParam.nCol2,aParam.nRow2,nTab );
778cdf0e10cSrcweir 	pViewShell->DoSubTotals( aParam, sal_False );
779cdf0e10cSrcweir 
780cdf0e10cSrcweir 	EndRedo();
781cdf0e10cSrcweir }
782cdf0e10cSrcweir 
Repeat(SfxRepeatTarget &)783cdf0e10cSrcweir void __EXPORT ScUndoSubTotals::Repeat(SfxRepeatTarget& /* rTarget */)
784cdf0e10cSrcweir {
785cdf0e10cSrcweir }
786cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget &) const787cdf0e10cSrcweir sal_Bool __EXPORT ScUndoSubTotals::CanRepeat(SfxRepeatTarget& /* rTarget */) const
788cdf0e10cSrcweir {
789cdf0e10cSrcweir 	return sal_False;						// geht nicht wegen Spaltennummern
790cdf0e10cSrcweir }
791cdf0e10cSrcweir 
792cdf0e10cSrcweir //
793cdf0e10cSrcweir //		Sortieren
794cdf0e10cSrcweir //
795cdf0e10cSrcweir 
ScUndoSort(ScDocShell * pNewDocShell,SCTAB nNewTab,const ScSortParam & rParam,sal_Bool bQuery,ScDocument * pNewUndoDoc,ScDBCollection * pNewUndoDB,const ScRange * pDest)796cdf0e10cSrcweir ScUndoSort::ScUndoSort( ScDocShell* pNewDocShell,
797cdf0e10cSrcweir 						SCTAB nNewTab, const ScSortParam& rParam,
798cdf0e10cSrcweir 						sal_Bool bQuery, ScDocument* pNewUndoDoc, ScDBCollection* pNewUndoDB,
799cdf0e10cSrcweir 						const ScRange* pDest ) :
800cdf0e10cSrcweir 	ScDBFuncUndo( pNewDocShell, ScRange( rParam.nCol1, rParam.nRow1, nNewTab,
801cdf0e10cSrcweir 	                                     rParam.nCol2, rParam.nRow2, nNewTab ) ),
802cdf0e10cSrcweir 	nTab( nNewTab ),
803cdf0e10cSrcweir 	aSortParam( rParam ),
804cdf0e10cSrcweir 	bRepeatQuery( bQuery ),
805cdf0e10cSrcweir 	pUndoDoc( pNewUndoDoc ),
806cdf0e10cSrcweir 	pUndoDB( pNewUndoDB ),
807cdf0e10cSrcweir 	bDestArea( sal_False )
808cdf0e10cSrcweir {
809cdf0e10cSrcweir 	if ( pDest )
810cdf0e10cSrcweir 	{
811cdf0e10cSrcweir 		bDestArea = sal_True;
812cdf0e10cSrcweir 		aDestRange = *pDest;
813cdf0e10cSrcweir 	}
814cdf0e10cSrcweir }
815cdf0e10cSrcweir 
~ScUndoSort()816cdf0e10cSrcweir __EXPORT ScUndoSort::~ScUndoSort()
817cdf0e10cSrcweir {
818cdf0e10cSrcweir 	delete pUndoDoc;
819cdf0e10cSrcweir 	delete pUndoDB;
820cdf0e10cSrcweir }
821cdf0e10cSrcweir 
GetComment() const822cdf0e10cSrcweir String __EXPORT ScUndoSort::GetComment() const
823cdf0e10cSrcweir {
824cdf0e10cSrcweir 	return ScGlobal::GetRscString( STR_UNDO_SORT );
825cdf0e10cSrcweir }
826cdf0e10cSrcweir 
Undo()827cdf0e10cSrcweir void __EXPORT ScUndoSort::Undo()
828cdf0e10cSrcweir {
829cdf0e10cSrcweir 	BeginUndo();
830cdf0e10cSrcweir 
831cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
832cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
833cdf0e10cSrcweir 
834cdf0e10cSrcweir 	SCCOL nStartCol = aSortParam.nCol1;
835cdf0e10cSrcweir 	SCROW nStartRow = aSortParam.nRow1;
836cdf0e10cSrcweir 	SCCOL nEndCol	 = aSortParam.nCol2;
837cdf0e10cSrcweir 	SCROW nEndRow	 = aSortParam.nRow2;
838cdf0e10cSrcweir 	SCTAB nSortTab  = nTab;
839cdf0e10cSrcweir 	if ( !aSortParam.bInplace )
840cdf0e10cSrcweir 	{
841cdf0e10cSrcweir 		nStartCol = aSortParam.nDestCol;
842cdf0e10cSrcweir 		nStartRow = aSortParam.nDestRow;
843cdf0e10cSrcweir 		nEndCol   = nStartCol + ( aSortParam.nCol2 - aSortParam.nCol1 );
844cdf0e10cSrcweir 		nEndRow   = nStartRow + ( aSortParam.nRow2 - aSortParam.nRow1 );
845cdf0e10cSrcweir 		nSortTab  = aSortParam.nDestTab;
846cdf0e10cSrcweir 	}
847cdf0e10cSrcweir 
848cdf0e10cSrcweir 	ScUndoUtil::MarkSimpleBlock( pDocShell, nStartCol, nStartRow, nSortTab,
849cdf0e10cSrcweir 								 nEndCol, nEndRow, nSortTab );
850cdf0e10cSrcweir 
851cdf0e10cSrcweir     // do not delete/copy note captions, they are handled in drawing undo (ScDBFuncUndo::mpDrawUndo)
852cdf0e10cSrcweir     pDoc->DeleteAreaTab( nStartCol,nStartRow, nEndCol,nEndRow, nSortTab, IDF_ALL|IDF_NOCAPTIONS );
853cdf0e10cSrcweir 	pUndoDoc->CopyToDocument( nStartCol, nStartRow, nSortTab, nEndCol, nEndRow, nSortTab,
854cdf0e10cSrcweir                                 IDF_ALL|IDF_NOCAPTIONS, sal_False, pDoc );
855cdf0e10cSrcweir 
856cdf0e10cSrcweir 	if (bDestArea)
857cdf0e10cSrcweir 	{
858cdf0e10cSrcweir         // do not delete/copy note captions, they are handled in drawing undo (ScDBFuncUndo::mpDrawUndo)
859cdf0e10cSrcweir         pDoc->DeleteAreaTab( aDestRange, IDF_ALL|IDF_NOCAPTIONS );
860cdf0e10cSrcweir         pUndoDoc->CopyToDocument( aDestRange, IDF_ALL|IDF_NOCAPTIONS, sal_False, pDoc );
861cdf0e10cSrcweir 	}
862cdf0e10cSrcweir 
863cdf0e10cSrcweir 	//	Zeilenhoehen immer (wegen automatischer Anpassung)
864cdf0e10cSrcweir 	//!	auf ScBlockUndo umstellen
865cdf0e10cSrcweir //	if (bRepeatQuery)
866cdf0e10cSrcweir 		pUndoDoc->CopyToDocument( 0, nStartRow, nSortTab, MAXCOL, nEndRow, nSortTab,
867cdf0e10cSrcweir 								IDF_NONE, sal_False, pDoc );
868cdf0e10cSrcweir 
869cdf0e10cSrcweir 	if (pUndoDB)
870cdf0e10cSrcweir 		pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ), sal_True );
871cdf0e10cSrcweir 
872cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
873cdf0e10cSrcweir 	if ( nVisTab != nSortTab )
874cdf0e10cSrcweir 		pViewShell->SetTabNo( nSortTab );
875cdf0e10cSrcweir 
876cdf0e10cSrcweir 	pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
877cdf0e10cSrcweir 	pDocShell->PostDataChanged();
878cdf0e10cSrcweir 
879cdf0e10cSrcweir 	EndUndo();
880cdf0e10cSrcweir }
881cdf0e10cSrcweir 
Redo()882cdf0e10cSrcweir void __EXPORT ScUndoSort::Redo()
883cdf0e10cSrcweir {
884cdf0e10cSrcweir 	BeginRedo();
885cdf0e10cSrcweir 
886cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
887cdf0e10cSrcweir 
888cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
889cdf0e10cSrcweir 	if ( nVisTab != nTab )
890cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
891cdf0e10cSrcweir 
892cdf0e10cSrcweir //	pViewShell->DoneBlockMode();
893cdf0e10cSrcweir //	pViewShell->InitOwnBlockMode();
894cdf0e10cSrcweir //	pViewShell->GetViewData()->GetMarkData() = aMarkData;	// CopyMarksTo
895cdf0e10cSrcweir 
896cdf0e10cSrcweir 	pViewShell->MarkRange( ScRange( aSortParam.nCol1, aSortParam.nRow1, nTab,
897cdf0e10cSrcweir 									  aSortParam.nCol2, aSortParam.nRow2, nTab ) );
898cdf0e10cSrcweir 
899cdf0e10cSrcweir 	pViewShell->Sort( aSortParam, sal_False );
900cdf0e10cSrcweir 
901cdf0e10cSrcweir 	//	Quellbereich painten wegen Markierung
902cdf0e10cSrcweir 	if ( !aSortParam.bInplace )
903cdf0e10cSrcweir 		pDocShell->PostPaint( aSortParam.nCol1, aSortParam.nRow1, nTab,
904cdf0e10cSrcweir 							  aSortParam.nCol2, aSortParam.nRow2, nTab, PAINT_GRID );
905cdf0e10cSrcweir 
906cdf0e10cSrcweir 	EndRedo();
907cdf0e10cSrcweir }
908cdf0e10cSrcweir 
Repeat(SfxRepeatTarget &)909cdf0e10cSrcweir void __EXPORT ScUndoSort::Repeat(SfxRepeatTarget& /* rTarget */)
910cdf0e10cSrcweir {
911cdf0e10cSrcweir }
912cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget &) const913cdf0e10cSrcweir sal_Bool __EXPORT ScUndoSort::CanRepeat(SfxRepeatTarget& /* rTarget */) const
914cdf0e10cSrcweir {
915cdf0e10cSrcweir 	return sal_False;						// geht nicht wegen Spaltennummern
916cdf0e10cSrcweir }
917cdf0e10cSrcweir 
918cdf0e10cSrcweir //
919cdf0e10cSrcweir //		Filtern
920cdf0e10cSrcweir //
921cdf0e10cSrcweir 
ScUndoQuery(ScDocShell * pNewDocShell,SCTAB nNewTab,const ScQueryParam & rParam,ScDocument * pNewUndoDoc,ScDBCollection * pNewUndoDB,const ScRange * pOld,sal_Bool bSize,const ScRange * pAdvSrc)922cdf0e10cSrcweir ScUndoQuery::ScUndoQuery( ScDocShell* pNewDocShell, SCTAB nNewTab, const ScQueryParam& rParam,
923cdf0e10cSrcweir 							ScDocument* pNewUndoDoc, ScDBCollection* pNewUndoDB,
924cdf0e10cSrcweir 							const ScRange* pOld, sal_Bool bSize, const ScRange* pAdvSrc ) :
925cdf0e10cSrcweir 	ScDBFuncUndo( pNewDocShell, ScRange( rParam.nCol1, rParam.nRow1, nNewTab,
926cdf0e10cSrcweir 	                                     rParam.nCol2, rParam.nRow2, nNewTab ) ),
927cdf0e10cSrcweir 	pDrawUndo( NULL ),
928cdf0e10cSrcweir 	nTab( nNewTab ),
929cdf0e10cSrcweir 	aQueryParam( rParam ),
930cdf0e10cSrcweir 	pUndoDoc( pNewUndoDoc ),
931cdf0e10cSrcweir //	pUndoDBData( pNewData )
932cdf0e10cSrcweir 	pUndoDB( pNewUndoDB ),
933cdf0e10cSrcweir 	bIsAdvanced( sal_False ),
934cdf0e10cSrcweir 	bDestArea( sal_False ),
935cdf0e10cSrcweir 	bDoSize( bSize )
936cdf0e10cSrcweir {
937cdf0e10cSrcweir 	if ( pOld )
938cdf0e10cSrcweir 	{
939cdf0e10cSrcweir 		bDestArea = sal_True;
940cdf0e10cSrcweir 		aOldDest = *pOld;
941cdf0e10cSrcweir 	}
942cdf0e10cSrcweir 	if ( pAdvSrc )
943cdf0e10cSrcweir 	{
944cdf0e10cSrcweir 		bIsAdvanced = sal_True;
945cdf0e10cSrcweir 		aAdvSource = *pAdvSrc;
946cdf0e10cSrcweir 	}
947cdf0e10cSrcweir 
948cdf0e10cSrcweir     pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
949cdf0e10cSrcweir }
950cdf0e10cSrcweir 
~ScUndoQuery()951cdf0e10cSrcweir __EXPORT ScUndoQuery::~ScUndoQuery()
952cdf0e10cSrcweir {
953cdf0e10cSrcweir 	delete pUndoDoc;
954cdf0e10cSrcweir //	delete pUndoDBData;
955cdf0e10cSrcweir 	delete pUndoDB;
956cdf0e10cSrcweir     DeleteSdrUndoAction( pDrawUndo );
957cdf0e10cSrcweir }
958cdf0e10cSrcweir 
GetComment() const959cdf0e10cSrcweir String __EXPORT ScUndoQuery::GetComment() const
960cdf0e10cSrcweir {	// "Filtern";
961cdf0e10cSrcweir 	return ScGlobal::GetRscString( STR_UNDO_QUERY );
962cdf0e10cSrcweir }
963cdf0e10cSrcweir 
Undo()964cdf0e10cSrcweir void __EXPORT ScUndoQuery::Undo()
965cdf0e10cSrcweir {
966cdf0e10cSrcweir 	BeginUndo();
967cdf0e10cSrcweir 
968cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
969cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
970cdf0e10cSrcweir 
971cdf0e10cSrcweir 	sal_Bool bCopy = !aQueryParam.bInplace;
972cdf0e10cSrcweir 	SCCOL nDestEndCol = 0;
973cdf0e10cSrcweir 	SCROW nDestEndRow = 0;
974cdf0e10cSrcweir 	if (bCopy)
975cdf0e10cSrcweir 	{
976cdf0e10cSrcweir 		nDestEndCol = aQueryParam.nDestCol + ( aQueryParam.nCol2-aQueryParam.nCol1 );
977cdf0e10cSrcweir 		nDestEndRow = aQueryParam.nDestRow + ( aQueryParam.nRow2-aQueryParam.nRow1 );
978cdf0e10cSrcweir 
979cdf0e10cSrcweir 		ScDBData* pData = pDoc->GetDBAtCursor( aQueryParam.nDestCol, aQueryParam.nDestRow,
980cdf0e10cSrcweir 												aQueryParam.nDestTab, sal_True );
981cdf0e10cSrcweir 		if (pData)
982cdf0e10cSrcweir 		{
983cdf0e10cSrcweir 			ScRange aNewDest;
984cdf0e10cSrcweir 			pData->GetArea( aNewDest );
985cdf0e10cSrcweir 			nDestEndCol = aNewDest.aEnd.Col();
986cdf0e10cSrcweir 			nDestEndRow = aNewDest.aEnd.Row();
987cdf0e10cSrcweir 		}
988cdf0e10cSrcweir 
989cdf0e10cSrcweir 		if ( bDoSize && bDestArea )
990cdf0e10cSrcweir 		{
991cdf0e10cSrcweir 			//	aDestRange ist der alte Bereich
992cdf0e10cSrcweir 			pDoc->FitBlock( ScRange(
993cdf0e10cSrcweir 								aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab,
994cdf0e10cSrcweir 								nDestEndCol, nDestEndRow, aQueryParam.nDestTab ),
995cdf0e10cSrcweir 							aOldDest );
996cdf0e10cSrcweir 		}
997cdf0e10cSrcweir 
998cdf0e10cSrcweir 		ScUndoUtil::MarkSimpleBlock( pDocShell,
999cdf0e10cSrcweir 									aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab,
1000cdf0e10cSrcweir 									nDestEndCol, nDestEndRow, aQueryParam.nDestTab );
1001cdf0e10cSrcweir 		pDoc->DeleteAreaTab( aQueryParam.nDestCol, aQueryParam.nDestRow,
1002cdf0e10cSrcweir 							nDestEndCol, nDestEndRow, aQueryParam.nDestTab, IDF_ALL );
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir 		pViewShell->DoneBlockMode();
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir 		pUndoDoc->CopyToDocument( aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab,
1007cdf0e10cSrcweir 									nDestEndCol, nDestEndRow, aQueryParam.nDestTab,
1008cdf0e10cSrcweir 									IDF_ALL, sal_False, pDoc );
1009cdf0e10cSrcweir 		//	Attribute werden immer mitkopiert (#49287#)
1010cdf0e10cSrcweir 
1011cdf0e10cSrcweir 		//	Rest von altem Bereich
1012cdf0e10cSrcweir 		if ( bDestArea && !bDoSize )
1013cdf0e10cSrcweir 		{
1014cdf0e10cSrcweir 			pDoc->DeleteAreaTab( aOldDest, IDF_ALL );
1015cdf0e10cSrcweir 			pUndoDoc->CopyToDocument( aOldDest, IDF_ALL, sal_False, pDoc );
1016cdf0e10cSrcweir 		}
1017cdf0e10cSrcweir 	}
1018cdf0e10cSrcweir 	else
1019cdf0e10cSrcweir 		pUndoDoc->CopyToDocument( 0, aQueryParam.nRow1, nTab, MAXCOL, aQueryParam.nRow2, nTab,
1020cdf0e10cSrcweir 										IDF_NONE, sal_False, pDoc );
1021cdf0e10cSrcweir 
1022cdf0e10cSrcweir 	if (pUndoDB)
1023cdf0e10cSrcweir 		pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ), sal_True );
1024cdf0e10cSrcweir 
1025cdf0e10cSrcweir 	if (!bCopy)
1026cdf0e10cSrcweir     {
1027cdf0e10cSrcweir         pDoc->InvalidatePageBreaks(nTab);
1028cdf0e10cSrcweir 		pDoc->UpdatePageBreaks( nTab );
1029cdf0e10cSrcweir     }
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir     ScRange aDirtyRange( 0 , aQueryParam.nRow1, nTab,
1032cdf0e10cSrcweir         MAXCOL, aQueryParam.nRow2, nTab );
1033cdf0e10cSrcweir     pDoc->SetDirty( aDirtyRange );
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir     DoSdrUndoAction( pDrawUndo, pDoc );
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
1038cdf0e10cSrcweir 	if ( nVisTab != nTab )
1039cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir 		//	Paint
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir 	if (bCopy)
1044cdf0e10cSrcweir 	{
1045cdf0e10cSrcweir 		SCCOL nEndX = nDestEndCol;
1046cdf0e10cSrcweir 		SCROW nEndY = nDestEndRow;
1047cdf0e10cSrcweir 		if (bDestArea)
1048cdf0e10cSrcweir 		{
1049cdf0e10cSrcweir 			if ( aOldDest.aEnd.Col() > nEndX )
1050cdf0e10cSrcweir 				nEndX = aOldDest.aEnd.Col();
1051cdf0e10cSrcweir 			if ( aOldDest.aEnd.Row() > nEndY )
1052cdf0e10cSrcweir 				nEndY = aOldDest.aEnd.Row();
1053cdf0e10cSrcweir 		}
1054cdf0e10cSrcweir 		if (bDoSize)
1055cdf0e10cSrcweir 			nEndY = MAXROW;
1056cdf0e10cSrcweir 		pDocShell->PostPaint( aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab,
1057cdf0e10cSrcweir 									nEndX, nEndY, aQueryParam.nDestTab, PAINT_GRID );
1058cdf0e10cSrcweir 	}
1059cdf0e10cSrcweir 	else
1060cdf0e10cSrcweir 		pDocShell->PostPaint( 0, aQueryParam.nRow1, nTab, MAXCOL, MAXROW, nTab,
1061cdf0e10cSrcweir 													PAINT_GRID | PAINT_LEFT );
1062cdf0e10cSrcweir 	pDocShell->PostDataChanged();
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir 	EndUndo();
1065cdf0e10cSrcweir }
1066cdf0e10cSrcweir 
Redo()1067cdf0e10cSrcweir void __EXPORT ScUndoQuery::Redo()
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir 	BeginRedo();
1070cdf0e10cSrcweir 
1071cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
1074cdf0e10cSrcweir 	if ( nVisTab != nTab )
1075cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir 	if ( bIsAdvanced )
1078cdf0e10cSrcweir 		pViewShell->Query( aQueryParam, &aAdvSource, sal_False );
1079cdf0e10cSrcweir 	else
1080cdf0e10cSrcweir 		pViewShell->Query( aQueryParam, NULL, sal_False );
1081cdf0e10cSrcweir 
1082cdf0e10cSrcweir 	EndRedo();
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir 
Repeat(SfxRepeatTarget &)1085cdf0e10cSrcweir void __EXPORT ScUndoQuery::Repeat(SfxRepeatTarget& /* rTarget */)
1086cdf0e10cSrcweir {
1087cdf0e10cSrcweir }
1088cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget &) const1089cdf0e10cSrcweir sal_Bool __EXPORT ScUndoQuery::CanRepeat(SfxRepeatTarget& /* rTarget */) const
1090cdf0e10cSrcweir {
1091cdf0e10cSrcweir 	return sal_False;						// geht nicht wegen Spaltennummern
1092cdf0e10cSrcweir }
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir //
1095cdf0e10cSrcweir //      Show or hide AutoFilter buttons (doesn't include filter settings)
1096cdf0e10cSrcweir //
1097cdf0e10cSrcweir 
ScUndoAutoFilter(ScDocShell * pNewDocShell,const ScRange & rRange,const String & rName,sal_Bool bSet)1098cdf0e10cSrcweir ScUndoAutoFilter::ScUndoAutoFilter( ScDocShell* pNewDocShell, const ScRange& rRange,
1099cdf0e10cSrcweir                                     const String& rName, sal_Bool bSet ) :
1100cdf0e10cSrcweir     ScDBFuncUndo( pNewDocShell, rRange ),
1101cdf0e10cSrcweir     aDBName( rName ),
1102cdf0e10cSrcweir     bFilterSet( bSet )
1103cdf0e10cSrcweir {
1104cdf0e10cSrcweir }
1105cdf0e10cSrcweir 
~ScUndoAutoFilter()1106cdf0e10cSrcweir ScUndoAutoFilter::~ScUndoAutoFilter()
1107cdf0e10cSrcweir {
1108cdf0e10cSrcweir }
1109cdf0e10cSrcweir 
GetComment() const1110cdf0e10cSrcweir String ScUndoAutoFilter::GetComment() const
1111cdf0e10cSrcweir {
1112cdf0e10cSrcweir     return ScGlobal::GetRscString( STR_UNDO_QUERY );    // same as ScUndoQuery
1113cdf0e10cSrcweir }
1114cdf0e10cSrcweir 
DoChange(sal_Bool bUndo)1115cdf0e10cSrcweir void ScUndoAutoFilter::DoChange( sal_Bool bUndo )
1116cdf0e10cSrcweir {
1117cdf0e10cSrcweir     sal_Bool bNewFilter = bUndo ? !bFilterSet : bFilterSet;
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir     sal_uInt16 nIndex;
1120cdf0e10cSrcweir     ScDocument* pDoc = pDocShell->GetDocument();
1121cdf0e10cSrcweir     ScDBCollection* pColl = pDoc->GetDBCollection();
1122cdf0e10cSrcweir     if ( pColl->SearchName( aDBName, nIndex ) )
1123cdf0e10cSrcweir     {
1124cdf0e10cSrcweir         ScDBData* pDBData = (*pColl)[nIndex];
1125cdf0e10cSrcweir         pDBData->SetAutoFilter( bNewFilter );
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir         SCCOL nRangeX1;
1128cdf0e10cSrcweir         SCROW nRangeY1;
1129cdf0e10cSrcweir         SCCOL nRangeX2;
1130cdf0e10cSrcweir         SCROW nRangeY2;
1131cdf0e10cSrcweir         SCTAB nRangeTab;
1132cdf0e10cSrcweir         pDBData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
1133cdf0e10cSrcweir 
1134cdf0e10cSrcweir         if ( bNewFilter )
1135cdf0e10cSrcweir             pDoc->ApplyFlagsTab( nRangeX1, nRangeY1, nRangeX2, nRangeY1, nRangeTab, SC_MF_AUTO );
1136cdf0e10cSrcweir         else
1137cdf0e10cSrcweir             pDoc->RemoveFlagsTab( nRangeX1, nRangeY1, nRangeX2, nRangeY1, nRangeTab, SC_MF_AUTO );
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir         pDocShell->PostPaint( nRangeX1, nRangeY1, nRangeTab, nRangeX2, nRangeY1, nRangeTab, PAINT_GRID );
1140cdf0e10cSrcweir     }
1141cdf0e10cSrcweir }
1142cdf0e10cSrcweir 
Undo()1143cdf0e10cSrcweir void ScUndoAutoFilter::Undo()
1144cdf0e10cSrcweir {
1145cdf0e10cSrcweir     BeginUndo();
1146cdf0e10cSrcweir     DoChange( sal_True );
1147cdf0e10cSrcweir     EndUndo();
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir 
Redo()1150cdf0e10cSrcweir void ScUndoAutoFilter::Redo()
1151cdf0e10cSrcweir {
1152cdf0e10cSrcweir     BeginRedo();
1153cdf0e10cSrcweir     DoChange( sal_False );
1154cdf0e10cSrcweir     EndRedo();
1155cdf0e10cSrcweir }
1156cdf0e10cSrcweir 
Repeat(SfxRepeatTarget &)1157cdf0e10cSrcweir void ScUndoAutoFilter::Repeat(SfxRepeatTarget& /* rTarget */)
1158cdf0e10cSrcweir {
1159cdf0e10cSrcweir }
1160cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget &) const1161cdf0e10cSrcweir sal_Bool ScUndoAutoFilter::CanRepeat(SfxRepeatTarget& /* rTarget */) const
1162cdf0e10cSrcweir {
1163cdf0e10cSrcweir     return sal_False;
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir 
1166cdf0e10cSrcweir //
1167cdf0e10cSrcweir //		Datenbankbereiche aendern (Dialog)
1168cdf0e10cSrcweir //
1169cdf0e10cSrcweir 
ScUndoDBData(ScDocShell * pNewDocShell,ScDBCollection * pNewUndoColl,ScDBCollection * pNewRedoColl)1170cdf0e10cSrcweir ScUndoDBData::ScUndoDBData( ScDocShell* pNewDocShell,
1171cdf0e10cSrcweir 							ScDBCollection* pNewUndoColl, ScDBCollection* pNewRedoColl ) :
1172cdf0e10cSrcweir 	ScSimpleUndo( pNewDocShell ),
1173cdf0e10cSrcweir 	pUndoColl( pNewUndoColl ),
1174cdf0e10cSrcweir 	pRedoColl( pNewRedoColl )
1175cdf0e10cSrcweir {
1176cdf0e10cSrcweir }
1177cdf0e10cSrcweir 
~ScUndoDBData()1178cdf0e10cSrcweir __EXPORT ScUndoDBData::~ScUndoDBData()
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir 	delete pUndoColl;
1181cdf0e10cSrcweir 	delete pRedoColl;
1182cdf0e10cSrcweir }
1183cdf0e10cSrcweir 
GetComment() const1184cdf0e10cSrcweir String __EXPORT ScUndoDBData::GetComment() const
1185cdf0e10cSrcweir {	// "Datenbankbereiche aendern";
1186cdf0e10cSrcweir 	return ScGlobal::GetRscString( STR_UNDO_DBDATA );
1187cdf0e10cSrcweir }
1188cdf0e10cSrcweir 
Undo()1189cdf0e10cSrcweir void __EXPORT ScUndoDBData::Undo()
1190cdf0e10cSrcweir {
1191cdf0e10cSrcweir 	BeginUndo();
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
1194cdf0e10cSrcweir 
1195cdf0e10cSrcweir 	sal_Bool bOldAutoCalc = pDoc->GetAutoCalc();
1196cdf0e10cSrcweir 	pDoc->SetAutoCalc( sal_False );			// unnoetige Berechnungen vermeiden
1197cdf0e10cSrcweir 	pDoc->CompileDBFormula( sal_True );		// CreateFormulaString
1198cdf0e10cSrcweir 	pDoc->SetDBCollection( new ScDBCollection(*pUndoColl), sal_True );
1199cdf0e10cSrcweir 	pDoc->CompileDBFormula( sal_False );	// CompileFormulaString
1200cdf0e10cSrcweir 	pDoc->SetAutoCalc( bOldAutoCalc );
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir 	SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir 	EndUndo();
1205cdf0e10cSrcweir }
1206cdf0e10cSrcweir 
Redo()1207cdf0e10cSrcweir void __EXPORT ScUndoDBData::Redo()
1208cdf0e10cSrcweir {
1209cdf0e10cSrcweir 	BeginRedo();
1210cdf0e10cSrcweir 
1211cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir 	sal_Bool bOldAutoCalc = pDoc->GetAutoCalc();
1214cdf0e10cSrcweir 	pDoc->SetAutoCalc( sal_False );			// unnoetige Berechnungen vermeiden
1215cdf0e10cSrcweir 	pDoc->CompileDBFormula( sal_True );		// CreateFormulaString
1216cdf0e10cSrcweir 	pDoc->SetDBCollection( new ScDBCollection(*pRedoColl), sal_True );
1217cdf0e10cSrcweir 	pDoc->CompileDBFormula( sal_False );	// CompileFormulaString
1218cdf0e10cSrcweir 	pDoc->SetAutoCalc( bOldAutoCalc );
1219cdf0e10cSrcweir 
1220cdf0e10cSrcweir 	SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir 	EndRedo();
1223cdf0e10cSrcweir }
1224cdf0e10cSrcweir 
Repeat(SfxRepeatTarget &)1225cdf0e10cSrcweir void __EXPORT ScUndoDBData::Repeat(SfxRepeatTarget& /* rTarget */)
1226cdf0e10cSrcweir {
1227cdf0e10cSrcweir }
1228cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget &) const1229cdf0e10cSrcweir sal_Bool __EXPORT ScUndoDBData::CanRepeat(SfxRepeatTarget& /* rTarget */) const
1230cdf0e10cSrcweir {
1231cdf0e10cSrcweir 	return sal_False;						// geht nicht
1232cdf0e10cSrcweir }
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir //
1235cdf0e10cSrcweir //		Import
1236cdf0e10cSrcweir //
1237cdf0e10cSrcweir 
ScUndoImportData(ScDocShell * pNewDocShell,SCTAB nNewTab,const ScImportParam & rParam,SCCOL nNewEndX,SCROW nNewEndY,SCCOL nNewFormula,ScDocument * pNewUndoDoc,ScDocument * pNewRedoDoc,ScDBData * pNewUndoData,ScDBData * pNewRedoData)1238cdf0e10cSrcweir ScUndoImportData::ScUndoImportData( ScDocShell* pNewDocShell, SCTAB nNewTab,
1239cdf0e10cSrcweir 								const ScImportParam& rParam, SCCOL nNewEndX, SCROW nNewEndY,
1240cdf0e10cSrcweir 								SCCOL nNewFormula,
1241cdf0e10cSrcweir 								ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
1242cdf0e10cSrcweir 								ScDBData* pNewUndoData, ScDBData* pNewRedoData ) :
1243cdf0e10cSrcweir 	ScSimpleUndo( pNewDocShell ),
1244cdf0e10cSrcweir 	nTab( nNewTab ),
1245cdf0e10cSrcweir 	aImportParam( rParam ),
1246cdf0e10cSrcweir 	nEndCol( nNewEndX ),
1247cdf0e10cSrcweir 	nEndRow( nNewEndY ),
1248cdf0e10cSrcweir 	pUndoDoc( pNewUndoDoc ),
1249cdf0e10cSrcweir 	pRedoDoc( pNewRedoDoc ),
1250cdf0e10cSrcweir 	pUndoDBData( pNewUndoData ),
1251cdf0e10cSrcweir 	pRedoDBData( pNewRedoData ),
1252cdf0e10cSrcweir 	nFormulaCols( nNewFormula ),
1253cdf0e10cSrcweir 	bRedoFilled( sal_False )
1254cdf0e10cSrcweir {
1255cdf0e10cSrcweir 	// redo doc doesn't contain imported data (but everything else)
1256cdf0e10cSrcweir }
1257cdf0e10cSrcweir 
~ScUndoImportData()1258cdf0e10cSrcweir __EXPORT ScUndoImportData::~ScUndoImportData()
1259cdf0e10cSrcweir {
1260cdf0e10cSrcweir 	delete pUndoDoc;
1261cdf0e10cSrcweir 	delete pRedoDoc;
1262cdf0e10cSrcweir 	delete pUndoDBData;
1263cdf0e10cSrcweir 	delete pRedoDBData;
1264cdf0e10cSrcweir }
1265cdf0e10cSrcweir 
GetComment() const1266cdf0e10cSrcweir String __EXPORT ScUndoImportData::GetComment() const
1267cdf0e10cSrcweir {	// "Importieren";
1268cdf0e10cSrcweir 	return ScGlobal::GetRscString( STR_UNDO_IMPORTDATA );
1269cdf0e10cSrcweir }
1270cdf0e10cSrcweir 
Undo()1271cdf0e10cSrcweir void __EXPORT ScUndoImportData::Undo()
1272cdf0e10cSrcweir {
1273cdf0e10cSrcweir 	BeginUndo();
1274cdf0e10cSrcweir 
1275cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
1276cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1277cdf0e10cSrcweir 
1278cdf0e10cSrcweir 	ScUndoUtil::MarkSimpleBlock( pDocShell, aImportParam.nCol1,aImportParam.nRow1,nTab,
1279cdf0e10cSrcweir 														nEndCol,nEndRow,nTab );
1280cdf0e10cSrcweir 
1281cdf0e10cSrcweir 	SCTAB nTable;
1282cdf0e10cSrcweir 	SCCOL nCol1, nCol2;
1283cdf0e10cSrcweir 	SCROW nRow1, nRow2;
1284cdf0e10cSrcweir 	ScDBData* pCurrentData = NULL;
1285cdf0e10cSrcweir 	if (pUndoDBData && pRedoDBData)
1286cdf0e10cSrcweir 	{
1287cdf0e10cSrcweir 		pRedoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
1288cdf0e10cSrcweir 		pCurrentData = ScUndoUtil::GetOldDBData( pRedoDBData, pDoc, nTab,
1289cdf0e10cSrcweir 													nCol1, nRow1, nCol2, nRow2 );
1290cdf0e10cSrcweir 
1291cdf0e10cSrcweir 		if ( !bRedoFilled )
1292cdf0e10cSrcweir 		{
1293cdf0e10cSrcweir 			//	read redo data from document at first undo
1294cdf0e10cSrcweir 			//	imported data is deleted later anyway,
1295cdf0e10cSrcweir 			//	so now delete each column after copying to save memory (#41216#)
1296cdf0e10cSrcweir 
1297cdf0e10cSrcweir 			sal_Bool bOldAutoCalc = pDoc->GetAutoCalc();
1298cdf0e10cSrcweir 			pDoc->SetAutoCalc( sal_False );				// outside of the loop
1299cdf0e10cSrcweir 			for (SCCOL nCopyCol = nCol1; nCopyCol <= nCol2; nCopyCol++)
1300cdf0e10cSrcweir 			{
1301cdf0e10cSrcweir 				pDoc->CopyToDocument( nCopyCol,nRow1,nTab, nCopyCol,nRow2,nTab,
1302cdf0e10cSrcweir                                         IDF_CONTENTS & ~IDF_NOTE, sal_False, pRedoDoc );
1303cdf0e10cSrcweir                 pDoc->DeleteAreaTab( nCopyCol,nRow1, nCopyCol,nRow2, nTab, IDF_CONTENTS & ~IDF_NOTE );
1304cdf0e10cSrcweir 				pDoc->DoColResize( nTab, nCopyCol, nCopyCol, 0 );
1305cdf0e10cSrcweir 			}
1306cdf0e10cSrcweir 			pDoc->SetAutoCalc( bOldAutoCalc );
1307cdf0e10cSrcweir 			bRedoFilled = sal_True;
1308cdf0e10cSrcweir 		}
1309cdf0e10cSrcweir 	}
1310cdf0e10cSrcweir 	sal_Bool bMoveCells = pUndoDBData && pRedoDBData &&
1311cdf0e10cSrcweir 						pRedoDBData->IsDoSize();		// in alt und neu gleich
1312cdf0e10cSrcweir 	if (bMoveCells)
1313cdf0e10cSrcweir 	{
1314cdf0e10cSrcweir 		//	Undo: erst die neuen Daten loeschen, dann FitBlock rueckwaerts
1315cdf0e10cSrcweir 
1316cdf0e10cSrcweir 		ScRange aOld, aNew;
1317cdf0e10cSrcweir 		pUndoDBData->GetArea( aOld );
1318cdf0e10cSrcweir 		pRedoDBData->GetArea( aNew );
1319cdf0e10cSrcweir 
1320cdf0e10cSrcweir 		pDoc->DeleteAreaTab( aNew.aStart.Col(), aNew.aStart.Row(),
1321cdf0e10cSrcweir                                 aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, IDF_ALL & ~IDF_NOTE );
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir 		aOld.aEnd.SetCol( aOld.aEnd.Col() + nFormulaCols );		// FitBlock auch fuer Formeln
1324cdf0e10cSrcweir 		aNew.aEnd.SetCol( aNew.aEnd.Col() + nFormulaCols );
1325cdf0e10cSrcweir 		pDoc->FitBlock( aNew, aOld, sal_False );					// rueckwaerts
1326cdf0e10cSrcweir 	}
1327cdf0e10cSrcweir 	else
1328cdf0e10cSrcweir 		pDoc->DeleteAreaTab( aImportParam.nCol1,aImportParam.nRow1,
1329cdf0e10cSrcweir                                 nEndCol,nEndRow, nTab, IDF_ALL & ~IDF_NOTE );
1330cdf0e10cSrcweir 
1331cdf0e10cSrcweir 	pUndoDoc->CopyToDocument( aImportParam.nCol1,aImportParam.nRow1,nTab,
1332cdf0e10cSrcweir 								nEndCol+nFormulaCols,nEndRow,nTab,
1333cdf0e10cSrcweir                                 IDF_ALL & ~IDF_NOTE, sal_False, pDoc );
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir 	if (pCurrentData)
1336cdf0e10cSrcweir 	{
1337cdf0e10cSrcweir 		*pCurrentData = *pUndoDBData;
1338cdf0e10cSrcweir 
1339cdf0e10cSrcweir 		pUndoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
1340cdf0e10cSrcweir 		ScUndoUtil::MarkSimpleBlock( pDocShell, nCol1, nRow1, nTable, nCol2, nRow2, nTable );
1341cdf0e10cSrcweir 	}
1342cdf0e10cSrcweir 
1343cdf0e10cSrcweir // erack! it's broadcasted
1344cdf0e10cSrcweir //	pDoc->SetDirty();
1345cdf0e10cSrcweir 
1346cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
1347cdf0e10cSrcweir 	if ( nVisTab != nTab )
1348cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
1349cdf0e10cSrcweir 
1350cdf0e10cSrcweir 	if (bMoveCells)
1351cdf0e10cSrcweir 		pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
1352cdf0e10cSrcweir 	else
1353cdf0e10cSrcweir 		pDocShell->PostPaint( aImportParam.nCol1,aImportParam.nRow1,nTab,
1354cdf0e10cSrcweir 								nEndCol,nEndRow,nTab, PAINT_GRID );
1355cdf0e10cSrcweir 	pDocShell->PostDataChanged();
1356cdf0e10cSrcweir 
1357cdf0e10cSrcweir 	EndUndo();
1358cdf0e10cSrcweir }
1359cdf0e10cSrcweir 
Redo()1360cdf0e10cSrcweir void __EXPORT ScUndoImportData::Redo()
1361cdf0e10cSrcweir {
1362cdf0e10cSrcweir 	BeginRedo();
1363cdf0e10cSrcweir 
1364cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
1365cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir 	ScUndoUtil::MarkSimpleBlock( pDocShell, aImportParam.nCol1,aImportParam.nRow1,nTab,
1368cdf0e10cSrcweir 														nEndCol,nEndRow,nTab );
1369cdf0e10cSrcweir 
1370cdf0e10cSrcweir 	SCTAB nTable;
1371cdf0e10cSrcweir 	SCCOL nCol1, nCol2;
1372cdf0e10cSrcweir 	SCROW nRow1, nRow2;
1373cdf0e10cSrcweir 	ScDBData* pCurrentData = NULL;
1374cdf0e10cSrcweir 	if (pUndoDBData && pRedoDBData)
1375cdf0e10cSrcweir 	{
1376cdf0e10cSrcweir 		pUndoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
1377cdf0e10cSrcweir 		pCurrentData = ScUndoUtil::GetOldDBData( pUndoDBData, pDoc, nTab,
1378cdf0e10cSrcweir 													nCol1, nRow1, nCol2, nRow2 );
1379cdf0e10cSrcweir 	}
1380cdf0e10cSrcweir 	sal_Bool bMoveCells = pUndoDBData && pRedoDBData &&
1381cdf0e10cSrcweir 						pRedoDBData->IsDoSize();		// in alt und neu gleich
1382cdf0e10cSrcweir 	if (bMoveCells)
1383cdf0e10cSrcweir 	{
1384cdf0e10cSrcweir 		//	Redo: FitBlock, dann Daten loeschen (noetig fuer CopyToDocument)
1385cdf0e10cSrcweir 
1386cdf0e10cSrcweir 		ScRange aOld, aNew;
1387cdf0e10cSrcweir 		pUndoDBData->GetArea( aOld );
1388cdf0e10cSrcweir 		pRedoDBData->GetArea( aNew );
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir 		aOld.aEnd.SetCol( aOld.aEnd.Col() + nFormulaCols );		// FitBlock auch fuer Formeln
1391cdf0e10cSrcweir 		aNew.aEnd.SetCol( aNew.aEnd.Col() + nFormulaCols );
1392cdf0e10cSrcweir 		pDoc->FitBlock( aOld, aNew );
1393cdf0e10cSrcweir 
1394cdf0e10cSrcweir 		pDoc->DeleteAreaTab( aNew.aStart.Col(), aNew.aStart.Row(),
1395cdf0e10cSrcweir                                 aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, IDF_ALL & ~IDF_NOTE );
1396cdf0e10cSrcweir 
1397cdf0e10cSrcweir         pRedoDoc->CopyToDocument( aNew, IDF_ALL & ~IDF_NOTE, sal_False, pDoc );        // incl. Formeln
1398cdf0e10cSrcweir 	}
1399cdf0e10cSrcweir 	else
1400cdf0e10cSrcweir 	{
1401cdf0e10cSrcweir 		pDoc->DeleteAreaTab( aImportParam.nCol1,aImportParam.nRow1,
1402cdf0e10cSrcweir                                 nEndCol,nEndRow, nTab, IDF_ALL & ~IDF_NOTE );
1403cdf0e10cSrcweir 		pRedoDoc->CopyToDocument( aImportParam.nCol1,aImportParam.nRow1,nTab,
1404cdf0e10cSrcweir                                 nEndCol,nEndRow,nTab, IDF_ALL & ~IDF_NOTE, sal_False, pDoc );
1405cdf0e10cSrcweir 	}
1406cdf0e10cSrcweir 
1407cdf0e10cSrcweir 	if (pCurrentData)
1408cdf0e10cSrcweir 	{
1409cdf0e10cSrcweir 		*pCurrentData = *pRedoDBData;
1410cdf0e10cSrcweir 
1411cdf0e10cSrcweir 		pRedoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
1412cdf0e10cSrcweir 		ScUndoUtil::MarkSimpleBlock( pDocShell, nCol1, nRow1, nTable, nCol2, nRow2, nTable );
1413cdf0e10cSrcweir 	}
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir // erack! it's broadcasted
1416cdf0e10cSrcweir //	pDoc->SetDirty();
1417cdf0e10cSrcweir 
1418cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
1419cdf0e10cSrcweir 	if ( nVisTab != nTab )
1420cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
1421cdf0e10cSrcweir 
1422cdf0e10cSrcweir 	if (bMoveCells)
1423cdf0e10cSrcweir 		pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
1424cdf0e10cSrcweir 	else
1425cdf0e10cSrcweir 		pDocShell->PostPaint( aImportParam.nCol1,aImportParam.nRow1,nTab,
1426cdf0e10cSrcweir 								nEndCol,nEndRow,nTab, PAINT_GRID );
1427cdf0e10cSrcweir 	pDocShell->PostDataChanged();
1428cdf0e10cSrcweir 
1429cdf0e10cSrcweir 	EndRedo();
1430cdf0e10cSrcweir }
1431cdf0e10cSrcweir 
Repeat(SfxRepeatTarget & rTarget)1432cdf0e10cSrcweir void __EXPORT ScUndoImportData::Repeat(SfxRepeatTarget& rTarget)
1433cdf0e10cSrcweir {
1434cdf0e10cSrcweir 	if (rTarget.ISA(ScTabViewTarget))
1435cdf0e10cSrcweir 	{
1436cdf0e10cSrcweir 		ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
1437cdf0e10cSrcweir 
1438cdf0e10cSrcweir 		SCTAB nDummy;
1439cdf0e10cSrcweir 		ScImportParam aNewParam(aImportParam);
1440cdf0e10cSrcweir 		ScDBData* pDBData = rViewShell.GetDBData();
1441cdf0e10cSrcweir 		pDBData->GetArea( nDummy, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 );
1442cdf0e10cSrcweir 
1443cdf0e10cSrcweir 		rViewShell.ImportData( aNewParam );
1444cdf0e10cSrcweir 	}
1445cdf0e10cSrcweir }
1446cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget & rTarget) const1447cdf0e10cSrcweir sal_Bool __EXPORT ScUndoImportData::CanRepeat(SfxRepeatTarget& rTarget) const
1448cdf0e10cSrcweir {
1449cdf0e10cSrcweir 	//	Repeat nur fuer Import per DB-Bereich, dann ist pUndoDBData gesetzt
1450cdf0e10cSrcweir 
1451cdf0e10cSrcweir 	if (pUndoDBData)
1452cdf0e10cSrcweir 		return (rTarget.ISA(ScTabViewTarget));
1453cdf0e10cSrcweir 	else
1454cdf0e10cSrcweir 		return sal_False;		// Adressbuch
1455cdf0e10cSrcweir }
1456cdf0e10cSrcweir 
1457cdf0e10cSrcweir //
1458cdf0e10cSrcweir //		Operationen wiederholen
1459cdf0e10cSrcweir //
1460cdf0e10cSrcweir 
ScUndoRepeatDB(ScDocShell * pNewDocShell,SCTAB nNewTab,SCCOL nStartX,SCROW nStartY,SCCOL nEndX,SCROW nEndY,SCROW nResultEndRow,SCCOL nCurX,SCROW nCurY,ScDocument * pNewUndoDoc,ScOutlineTable * pNewUndoTab,ScRangeName * pNewUndoRange,ScDBCollection * pNewUndoDB,const ScRange * pOldQ,const ScRange * pNewQ)1461cdf0e10cSrcweir ScUndoRepeatDB::ScUndoRepeatDB( ScDocShell* pNewDocShell, SCTAB nNewTab,
1462cdf0e10cSrcweir 								SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY,
1463cdf0e10cSrcweir 								SCROW nResultEndRow, SCCOL nCurX, SCROW nCurY,
1464cdf0e10cSrcweir 								ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
1465cdf0e10cSrcweir 								ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB,
1466cdf0e10cSrcweir 								const ScRange* pOldQ, const ScRange* pNewQ ) :
1467cdf0e10cSrcweir 	ScSimpleUndo( pNewDocShell ),
1468cdf0e10cSrcweir 	aBlockStart( nStartX,nStartY,nNewTab ),
1469cdf0e10cSrcweir 	aBlockEnd( nEndX,nEndY,nNewTab ),
1470cdf0e10cSrcweir 	nNewEndRow( nResultEndRow ),
1471cdf0e10cSrcweir 	aCursorPos( nCurX,nCurY,nNewTab ),
1472cdf0e10cSrcweir 	pUndoDoc( pNewUndoDoc ),
1473cdf0e10cSrcweir 	pUndoTable( pNewUndoTab ),
1474cdf0e10cSrcweir 	pUndoRange( pNewUndoRange ),
1475cdf0e10cSrcweir 	pUndoDB( pNewUndoDB ),
1476cdf0e10cSrcweir 	bQuerySize( sal_False )
1477cdf0e10cSrcweir {
1478cdf0e10cSrcweir 	if ( pOldQ && pNewQ )
1479cdf0e10cSrcweir 	{
1480cdf0e10cSrcweir 		aOldQuery = *pOldQ;
1481cdf0e10cSrcweir 		aNewQuery = *pNewQ;
1482cdf0e10cSrcweir 		bQuerySize = sal_True;;
1483cdf0e10cSrcweir 	}
1484cdf0e10cSrcweir }
1485cdf0e10cSrcweir 
~ScUndoRepeatDB()1486cdf0e10cSrcweir __EXPORT ScUndoRepeatDB::~ScUndoRepeatDB()
1487cdf0e10cSrcweir {
1488cdf0e10cSrcweir 	delete pUndoDoc;
1489cdf0e10cSrcweir 	delete pUndoTable;
1490cdf0e10cSrcweir 	delete pUndoRange;
1491cdf0e10cSrcweir 	delete pUndoDB;
1492cdf0e10cSrcweir }
1493cdf0e10cSrcweir 
GetComment() const1494cdf0e10cSrcweir String __EXPORT ScUndoRepeatDB::GetComment() const
1495cdf0e10cSrcweir {	// "Wiederholen";       //! bessere Beschreibung!
1496cdf0e10cSrcweir 	return ScGlobal::GetRscString( STR_UNDO_REPEATDB );
1497cdf0e10cSrcweir }
1498cdf0e10cSrcweir 
Undo()1499cdf0e10cSrcweir void __EXPORT ScUndoRepeatDB::Undo()
1500cdf0e10cSrcweir {
1501cdf0e10cSrcweir 	BeginUndo();
1502cdf0e10cSrcweir 
1503cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
1504cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1505cdf0e10cSrcweir 	SCTAB nTab = aBlockStart.Tab();
1506cdf0e10cSrcweir 
1507cdf0e10cSrcweir 	if (bQuerySize)
1508cdf0e10cSrcweir 	{
1509cdf0e10cSrcweir 		pDoc->FitBlock( aNewQuery, aOldQuery, sal_False );
1510cdf0e10cSrcweir 
1511cdf0e10cSrcweir 		if ( aNewQuery.aEnd.Col() == aOldQuery.aEnd.Col() )
1512cdf0e10cSrcweir 		{
1513cdf0e10cSrcweir 			SCCOL nFormulaCols = 0;
1514cdf0e10cSrcweir 			SCCOL nCol = aOldQuery.aEnd.Col() + 1;
1515cdf0e10cSrcweir 			SCROW nRow = aOldQuery.aStart.Row() + 1;		//! Header testen
1516cdf0e10cSrcweir 			while ( nCol <= MAXCOL &&
1517cdf0e10cSrcweir 					pDoc->GetCellType(ScAddress( nCol, nRow, nTab )) == CELLTYPE_FORMULA )
1518cdf0e10cSrcweir 				++nCol, ++nFormulaCols;
1519cdf0e10cSrcweir 
1520cdf0e10cSrcweir 			if ( nFormulaCols > 0 )
1521cdf0e10cSrcweir 			{
1522cdf0e10cSrcweir 				ScRange aOldForm = aOldQuery;
1523cdf0e10cSrcweir 				aOldForm.aStart.SetCol( aOldQuery.aEnd.Col() + 1 );
1524cdf0e10cSrcweir 				aOldForm.aEnd.SetCol( aOldQuery.aEnd.Col() + nFormulaCols );
1525cdf0e10cSrcweir 				ScRange aNewForm = aOldForm;
1526cdf0e10cSrcweir 				aNewForm.aEnd.SetRow( aNewQuery.aEnd.Row() );
1527cdf0e10cSrcweir 				pDoc->FitBlock( aNewForm, aOldForm, sal_False );
1528cdf0e10cSrcweir 			}
1529cdf0e10cSrcweir 		}
1530cdf0e10cSrcweir 	}
1531cdf0e10cSrcweir 
1532cdf0e10cSrcweir 	//!		Daten von Filter in anderen Bereich fehlen noch	!!!!!!!!!!!!!!!!!
1533cdf0e10cSrcweir 
1534cdf0e10cSrcweir 	if (nNewEndRow > aBlockEnd.Row())
1535cdf0e10cSrcweir 	{
1536cdf0e10cSrcweir 		pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, aBlockEnd.Row()+1, static_cast<SCSIZE>(nNewEndRow-aBlockEnd.Row()) );
1537cdf0e10cSrcweir 	}
1538cdf0e10cSrcweir 	else if (nNewEndRow < aBlockEnd.Row())
1539cdf0e10cSrcweir 	{
1540cdf0e10cSrcweir 		pDoc->InsertRow( 0,nTab, MAXCOL,nTab, nNewEndRow+1, static_cast<SCSIZE>(nNewEndRow-aBlockEnd.Row()) );
1541cdf0e10cSrcweir 	}
1542cdf0e10cSrcweir 
1543cdf0e10cSrcweir 	//	Original Outline-Table
1544cdf0e10cSrcweir 
1545cdf0e10cSrcweir 	pDoc->SetOutlineTable( nTab, pUndoTable );
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir 	//	Original Spalten-/Zeilenstatus
1548cdf0e10cSrcweir 
1549cdf0e10cSrcweir 	if (pUndoDoc && pUndoTable)
1550cdf0e10cSrcweir 	{
1551cdf0e10cSrcweir 		SCCOLROW nStartCol;
1552cdf0e10cSrcweir 		SCCOLROW nStartRow;
1553cdf0e10cSrcweir 		SCCOLROW nEndCol;
1554cdf0e10cSrcweir 		SCCOLROW nEndRow;
1555cdf0e10cSrcweir 		pUndoTable->GetColArray()->GetRange( nStartCol, nEndCol );
1556cdf0e10cSrcweir 		pUndoTable->GetRowArray()->GetRange( nStartRow, nEndRow );
1557cdf0e10cSrcweir 
1558cdf0e10cSrcweir         pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStartCol), 0, nTab,
1559cdf0e10cSrcweir                 static_cast<SCCOL>(nEndCol), MAXROW, nTab, IDF_NONE, sal_False,
1560cdf0e10cSrcweir                 pDoc );
1561cdf0e10cSrcweir 		pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, sal_False, pDoc );
1562cdf0e10cSrcweir 
1563cdf0e10cSrcweir 		pViewShell->UpdateScrollBars();
1564cdf0e10cSrcweir 	}
1565cdf0e10cSrcweir 
1566cdf0e10cSrcweir 	//	Original-Daten & Referenzen
1567cdf0e10cSrcweir 
1568cdf0e10cSrcweir 	ScUndoUtil::MarkSimpleBlock( pDocShell, 0, aBlockStart.Row(), nTab,
1569cdf0e10cSrcweir 											MAXCOL, aBlockEnd.Row(), nTab );
1570cdf0e10cSrcweir 	pDoc->DeleteAreaTab( 0, aBlockStart.Row(),
1571cdf0e10cSrcweir 							MAXCOL, aBlockEnd.Row(), nTab, IDF_ALL );
1572cdf0e10cSrcweir 
1573cdf0e10cSrcweir 	pUndoDoc->CopyToDocument( 0, aBlockStart.Row(), nTab, MAXCOL, aBlockEnd.Row(), nTab,
1574cdf0e10cSrcweir 															IDF_NONE, sal_False, pDoc );			// Flags
1575cdf0e10cSrcweir 	pUndoDoc->UndoToDocument( 0, aBlockStart.Row(), nTab, MAXCOL, aBlockEnd.Row(), nTab,
1576cdf0e10cSrcweir 															IDF_ALL, sal_False, pDoc );
1577cdf0e10cSrcweir 
1578cdf0e10cSrcweir 	ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart.Col(),aBlockStart.Row(),nTab,
1579cdf0e10cSrcweir 											aBlockEnd.Col(),aBlockEnd.Row(),nTab );
1580cdf0e10cSrcweir 
1581cdf0e10cSrcweir 	if (pUndoRange)
1582cdf0e10cSrcweir 		pDoc->SetRangeName( new ScRangeName( *pUndoRange ) );
1583cdf0e10cSrcweir 	if (pUndoDB)
1584cdf0e10cSrcweir 		pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ), sal_True );
1585cdf0e10cSrcweir 
1586cdf0e10cSrcweir // erack! it's broadcasted
1587cdf0e10cSrcweir //	pDoc->SetDirty();
1588cdf0e10cSrcweir 
1589cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
1590cdf0e10cSrcweir 	if ( nVisTab != nTab )
1591cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir 	pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
1594cdf0e10cSrcweir 	pDocShell->PostDataChanged();
1595cdf0e10cSrcweir 
1596cdf0e10cSrcweir 	EndUndo();
1597cdf0e10cSrcweir }
1598cdf0e10cSrcweir 
Redo()1599cdf0e10cSrcweir void __EXPORT ScUndoRepeatDB::Redo()
1600cdf0e10cSrcweir {
1601cdf0e10cSrcweir 	BeginRedo();
1602cdf0e10cSrcweir 
1603cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1604cdf0e10cSrcweir 	SCTAB nTab = aBlockStart.Tab();
1605cdf0e10cSrcweir 
1606cdf0e10cSrcweir 	SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
1607cdf0e10cSrcweir 	if ( nVisTab != nTab )
1608cdf0e10cSrcweir 		pViewShell->SetTabNo( nTab );
1609cdf0e10cSrcweir 
1610cdf0e10cSrcweir 	ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart.Col(),aBlockStart.Row(),nTab,
1611cdf0e10cSrcweir 											aBlockEnd.Col(),aBlockEnd.Row(),nTab );
1612cdf0e10cSrcweir 	pViewShell->SetCursor( aCursorPos.Col(), aCursorPos.Row() );
1613cdf0e10cSrcweir 
1614cdf0e10cSrcweir 	pViewShell->RepeatDB( sal_False );
1615cdf0e10cSrcweir 
1616cdf0e10cSrcweir 	EndRedo();
1617cdf0e10cSrcweir }
1618cdf0e10cSrcweir 
Repeat(SfxRepeatTarget & rTarget)1619cdf0e10cSrcweir void __EXPORT ScUndoRepeatDB::Repeat(SfxRepeatTarget& rTarget)
1620cdf0e10cSrcweir {
1621cdf0e10cSrcweir 	if (rTarget.ISA(ScTabViewTarget))
1622cdf0e10cSrcweir 		((ScTabViewTarget&)rTarget).GetViewShell()->RepeatDB( sal_True );
1623cdf0e10cSrcweir }
1624cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget & rTarget) const1625cdf0e10cSrcweir sal_Bool __EXPORT ScUndoRepeatDB::CanRepeat(SfxRepeatTarget& rTarget) const
1626cdf0e10cSrcweir {
1627cdf0e10cSrcweir 	return (rTarget.ISA(ScTabViewTarget));
1628cdf0e10cSrcweir }
1629cdf0e10cSrcweir 
1630cdf0e10cSrcweir //UNUSED2008-05  //
1631cdf0e10cSrcweir //UNUSED2008-05  //		Pivot-Tabellen
1632cdf0e10cSrcweir //UNUSED2008-05  //
1633cdf0e10cSrcweir //UNUSED2008-05
1634cdf0e10cSrcweir //UNUSED2008-05  ScUndoPivot::ScUndoPivot( ScDocShell* pNewDocShell,
1635cdf0e10cSrcweir //UNUSED2008-05                              const ScArea& rOld, const ScArea& rNew,
1636cdf0e10cSrcweir //UNUSED2008-05                              ScDocument* pOldDoc, ScDocument* pNewDoc,
1637cdf0e10cSrcweir //UNUSED2008-05                              const ScPivot* pOldPivot, const ScPivot* pNewPivot ) :
1638cdf0e10cSrcweir //UNUSED2008-05      ScSimpleUndo( pNewDocShell ),
1639cdf0e10cSrcweir //UNUSED2008-05      aOldArea( rOld ),
1640cdf0e10cSrcweir //UNUSED2008-05      aNewArea( rNew ),
1641cdf0e10cSrcweir //UNUSED2008-05      pOldUndoDoc( pOldDoc ),
1642cdf0e10cSrcweir //UNUSED2008-05      pNewUndoDoc( pNewDoc )
1643cdf0e10cSrcweir //UNUSED2008-05  {
1644cdf0e10cSrcweir //UNUSED2008-05      if (pNewPivot)
1645cdf0e10cSrcweir //UNUSED2008-05      {
1646cdf0e10cSrcweir //UNUSED2008-05          pNewPivot->GetParam( aNewParam, aNewQuery, aNewSrc );
1647cdf0e10cSrcweir //UNUSED2008-05          aNewName = pNewPivot->GetName();
1648cdf0e10cSrcweir //UNUSED2008-05          aNewTag = pNewPivot->GetTag();
1649cdf0e10cSrcweir //UNUSED2008-05      }
1650cdf0e10cSrcweir //UNUSED2008-05      if (pOldPivot)
1651cdf0e10cSrcweir //UNUSED2008-05      {
1652cdf0e10cSrcweir //UNUSED2008-05          pOldPivot->GetParam( aOldParam, aOldQuery, aOldSrc );
1653cdf0e10cSrcweir //UNUSED2008-05          aOldName = pOldPivot->GetName();
1654cdf0e10cSrcweir //UNUSED2008-05          aOldTag = pOldPivot->GetTag();
1655cdf0e10cSrcweir //UNUSED2008-05      }
1656cdf0e10cSrcweir //UNUSED2008-05  }
1657cdf0e10cSrcweir //UNUSED2008-05
1658cdf0e10cSrcweir //UNUSED2008-05  __EXPORT ScUndoPivot::~ScUndoPivot()
1659cdf0e10cSrcweir //UNUSED2008-05  {
1660cdf0e10cSrcweir //UNUSED2008-05      delete pOldUndoDoc;
1661cdf0e10cSrcweir //UNUSED2008-05      delete pNewUndoDoc;
1662cdf0e10cSrcweir //UNUSED2008-05  }
1663cdf0e10cSrcweir //UNUSED2008-05
1664cdf0e10cSrcweir //UNUSED2008-05  String __EXPORT ScUndoPivot::GetComment() const
1665cdf0e10cSrcweir //UNUSED2008-05  {
1666cdf0e10cSrcweir //UNUSED2008-05      sal_uInt16 nIndex;
1667cdf0e10cSrcweir //UNUSED2008-05      if ( pOldUndoDoc && pNewUndoDoc )
1668cdf0e10cSrcweir //UNUSED2008-05          nIndex = STR_UNDO_PIVOT_MODIFY;
1669cdf0e10cSrcweir //UNUSED2008-05      else if ( pNewUndoDoc )
1670cdf0e10cSrcweir //UNUSED2008-05          nIndex = STR_UNDO_PIVOT_NEW;
1671cdf0e10cSrcweir //UNUSED2008-05      else
1672cdf0e10cSrcweir //UNUSED2008-05          nIndex = STR_UNDO_PIVOT_DELETE;
1673cdf0e10cSrcweir //UNUSED2008-05
1674cdf0e10cSrcweir //UNUSED2008-05      return ScGlobal::GetRscString( nIndex );
1675cdf0e10cSrcweir //UNUSED2008-05  }
1676cdf0e10cSrcweir //UNUSED2008-05
1677cdf0e10cSrcweir //UNUSED2008-05  void __EXPORT ScUndoPivot::Undo()
1678cdf0e10cSrcweir //UNUSED2008-05  {
1679cdf0e10cSrcweir //UNUSED2008-05      BeginUndo();
1680cdf0e10cSrcweir //UNUSED2008-05
1681cdf0e10cSrcweir //UNUSED2008-05      ScDocument* pDoc = pDocShell->GetDocument();
1682cdf0e10cSrcweir //UNUSED2008-05
1683cdf0e10cSrcweir //UNUSED2008-05      if (pNewUndoDoc)
1684cdf0e10cSrcweir //UNUSED2008-05      {
1685cdf0e10cSrcweir //UNUSED2008-05          pDoc->DeleteAreaTab( aNewArea.nColStart,aNewArea.nRowStart,
1686cdf0e10cSrcweir //UNUSED2008-05                              aNewArea.nColEnd,aNewArea.nRowEnd, aNewArea.nTab, IDF_ALL );
1687cdf0e10cSrcweir //UNUSED2008-05          pNewUndoDoc->CopyToDocument( aNewArea.nColStart, aNewArea.nRowStart, aNewArea.nTab,
1688cdf0e10cSrcweir //UNUSED2008-05                                  aNewArea.nColEnd, aNewArea.nRowEnd, aNewArea.nTab,
1689cdf0e10cSrcweir //UNUSED2008-05                                  IDF_ALL, sal_False, pDoc );
1690cdf0e10cSrcweir //UNUSED2008-05      }
1691cdf0e10cSrcweir //UNUSED2008-05      if (pOldUndoDoc)
1692cdf0e10cSrcweir //UNUSED2008-05      {
1693cdf0e10cSrcweir //UNUSED2008-05          pDoc->DeleteAreaTab( aOldArea.nColStart,aOldArea.nRowStart,
1694cdf0e10cSrcweir //UNUSED2008-05                              aOldArea.nColEnd,aOldArea.nRowEnd, aOldArea.nTab, IDF_ALL );
1695cdf0e10cSrcweir //UNUSED2008-05          pOldUndoDoc->CopyToDocument( aOldArea.nColStart, aOldArea.nRowStart, aOldArea.nTab,
1696cdf0e10cSrcweir //UNUSED2008-05                                  aOldArea.nColEnd, aOldArea.nRowEnd, aOldArea.nTab,
1697cdf0e10cSrcweir //UNUSED2008-05                                  IDF_ALL, sal_False, pDoc );
1698cdf0e10cSrcweir //UNUSED2008-05      }
1699cdf0e10cSrcweir //UNUSED2008-05
1700cdf0e10cSrcweir //UNUSED2008-05      ScPivotCollection* pPivotCollection = pDoc->GetPivotCollection();
1701cdf0e10cSrcweir //UNUSED2008-05      if ( pNewUndoDoc )
1702cdf0e10cSrcweir //UNUSED2008-05      {
1703cdf0e10cSrcweir //UNUSED2008-05          ScPivot* pNewPivot = pPivotCollection->GetPivotAtCursor(
1704cdf0e10cSrcweir //UNUSED2008-05                                  aNewParam.nCol, aNewParam.nRow, aNewParam.nTab );
1705cdf0e10cSrcweir //UNUSED2008-05          if (pNewPivot)
1706cdf0e10cSrcweir //UNUSED2008-05              pPivotCollection->Free( pNewPivot );
1707cdf0e10cSrcweir //UNUSED2008-05      }
1708cdf0e10cSrcweir //UNUSED2008-05      if ( pOldUndoDoc )
1709cdf0e10cSrcweir //UNUSED2008-05      {
1710cdf0e10cSrcweir //UNUSED2008-05          ScPivot* pOldPivot = new ScPivot( pDoc );
1711cdf0e10cSrcweir //UNUSED2008-05          pOldPivot->SetParam( aOldParam, aOldQuery, aOldSrc );
1712cdf0e10cSrcweir //UNUSED2008-05          pOldPivot->SetName( aOldName );
1713cdf0e10cSrcweir //UNUSED2008-05          pOldPivot->SetTag( aOldTag );
1714cdf0e10cSrcweir //UNUSED2008-05          if (pOldPivot->CreateData())                            // Felder berechnen
1715cdf0e10cSrcweir //UNUSED2008-05              pOldPivot->ReleaseData();
1716cdf0e10cSrcweir //UNUSED2008-05          pPivotCollection->Insert( pOldPivot );
1717cdf0e10cSrcweir //UNUSED2008-05      }
1718cdf0e10cSrcweir //UNUSED2008-05
1719cdf0e10cSrcweir //UNUSED2008-05  // erack! it's broadcasted
1720cdf0e10cSrcweir //UNUSED2008-05  //	pDoc->SetDirty();
1721cdf0e10cSrcweir //UNUSED2008-05      if (pNewUndoDoc)
1722cdf0e10cSrcweir //UNUSED2008-05          pDocShell->PostPaint( aNewArea.nColStart, aNewArea.nRowStart, aNewArea.nTab,
1723cdf0e10cSrcweir //UNUSED2008-05                                  aNewArea.nColEnd, aNewArea.nRowEnd, aNewArea.nTab,
1724cdf0e10cSrcweir //UNUSED2008-05                                  PAINT_GRID, SC_PF_LINES );
1725cdf0e10cSrcweir //UNUSED2008-05      if (pOldUndoDoc)
1726cdf0e10cSrcweir //UNUSED2008-05          pDocShell->PostPaint( aOldArea.nColStart, aOldArea.nRowStart, aOldArea.nTab,
1727cdf0e10cSrcweir //UNUSED2008-05                                  aOldArea.nColEnd, aOldArea.nRowEnd, aOldArea.nTab,
1728cdf0e10cSrcweir //UNUSED2008-05                                  PAINT_GRID, SC_PF_LINES );
1729cdf0e10cSrcweir //UNUSED2008-05      pDocShell->PostDataChanged();
1730cdf0e10cSrcweir //UNUSED2008-05
1731cdf0e10cSrcweir //UNUSED2008-05      ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1732cdf0e10cSrcweir //UNUSED2008-05      if (pViewShell)
1733cdf0e10cSrcweir //UNUSED2008-05      {
1734cdf0e10cSrcweir //UNUSED2008-05          SCTAB nTab = pViewShell->GetViewData()->GetTabNo();
1735cdf0e10cSrcweir //UNUSED2008-05          if ( pOldUndoDoc )
1736cdf0e10cSrcweir //UNUSED2008-05          {
1737cdf0e10cSrcweir //UNUSED2008-05              if ( nTab != aOldArea.nTab )
1738cdf0e10cSrcweir //UNUSED2008-05                  pViewShell->SetTabNo( aOldArea.nTab );
1739cdf0e10cSrcweir //UNUSED2008-05          }
1740cdf0e10cSrcweir //UNUSED2008-05          else if ( pNewUndoDoc )
1741cdf0e10cSrcweir //UNUSED2008-05          {
1742cdf0e10cSrcweir //UNUSED2008-05              if ( nTab != aNewArea.nTab )
1743cdf0e10cSrcweir //UNUSED2008-05                  pViewShell->SetTabNo( aNewArea.nTab );
1744cdf0e10cSrcweir //UNUSED2008-05          }
1745cdf0e10cSrcweir //UNUSED2008-05      }
1746cdf0e10cSrcweir //UNUSED2008-05
1747cdf0e10cSrcweir //UNUSED2008-05      EndUndo();
1748cdf0e10cSrcweir //UNUSED2008-05  }
1749cdf0e10cSrcweir //UNUSED2008-05
1750cdf0e10cSrcweir //UNUSED2008-05  void __EXPORT ScUndoPivot::Redo()
1751cdf0e10cSrcweir //UNUSED2008-05  {
1752cdf0e10cSrcweir //UNUSED2008-05      BeginRedo();
1753cdf0e10cSrcweir //UNUSED2008-05
1754cdf0e10cSrcweir //UNUSED2008-05      ScDocument* pDoc = pDocShell->GetDocument();
1755cdf0e10cSrcweir //UNUSED2008-05      ScPivotCollection* pPivotCollection = pDoc->GetPivotCollection();
1756cdf0e10cSrcweir //UNUSED2008-05      ScPivot* pOldPivot = pPivotCollection->GetPivotAtCursor(
1757cdf0e10cSrcweir //UNUSED2008-05                                              aOldParam.nCol, aOldParam.nRow, aOldParam.nTab );
1758cdf0e10cSrcweir //UNUSED2008-05
1759cdf0e10cSrcweir //UNUSED2008-05      ScPivot* pNewPivot = NULL;
1760cdf0e10cSrcweir //UNUSED2008-05      if (pNewUndoDoc)
1761cdf0e10cSrcweir //UNUSED2008-05      {
1762cdf0e10cSrcweir //UNUSED2008-05          pNewPivot = new ScPivot( pDoc );
1763cdf0e10cSrcweir //UNUSED2008-05          pNewPivot->SetParam( aNewParam, aNewQuery, aNewSrc );
1764cdf0e10cSrcweir //UNUSED2008-05          pNewPivot->SetName( aNewName );
1765cdf0e10cSrcweir //UNUSED2008-05          pNewPivot->SetTag( aNewTag );
1766cdf0e10cSrcweir //UNUSED2008-05      }
1767cdf0e10cSrcweir //UNUSED2008-05
1768cdf0e10cSrcweir //UNUSED2008-05      pDocShell->PivotUpdate( pOldPivot, pNewPivot, sal_False );
1769cdf0e10cSrcweir //UNUSED2008-05
1770cdf0e10cSrcweir //UNUSED2008-05      EndRedo();
1771cdf0e10cSrcweir //UNUSED2008-05  }
1772cdf0e10cSrcweir //UNUSED2008-05
1773cdf0e10cSrcweir //UNUSED2008-05  void __EXPORT ScUndoPivot::Repeat(SfxRepeatTarget& rTarget)
1774cdf0e10cSrcweir //UNUSED2008-05  {
1775cdf0e10cSrcweir //UNUSED2008-05      //  Wiederholen: nur loeschen
1776cdf0e10cSrcweir //UNUSED2008-05
1777cdf0e10cSrcweir //UNUSED2008-05      if ( pOldUndoDoc && !pNewUndoDoc && rTarget.ISA(ScTabViewTarget) )
1778cdf0e10cSrcweir //UNUSED2008-05          ((ScTabViewTarget&)rTarget).GetViewShell()->DeletePivotTable();
1779cdf0e10cSrcweir //UNUSED2008-05  }
1780cdf0e10cSrcweir //UNUSED2008-05
1781cdf0e10cSrcweir //UNUSED2008-05  sal_Bool __EXPORT ScUndoPivot::CanRepeat(SfxRepeatTarget& rTarget) const
1782cdf0e10cSrcweir //UNUSED2008-05  {
1783cdf0e10cSrcweir //UNUSED2008-05      //  Wiederholen: nur loeschen
1784cdf0e10cSrcweir //UNUSED2008-05
1785cdf0e10cSrcweir //UNUSED2008-05      return ( pOldUndoDoc && !pNewUndoDoc && rTarget.ISA(ScTabViewTarget) );
1786cdf0e10cSrcweir //UNUSED2008-05  }
1787cdf0e10cSrcweir 
1788cdf0e10cSrcweir //
1789cdf0e10cSrcweir //		data pilot
1790cdf0e10cSrcweir //
1791cdf0e10cSrcweir 
ScUndoDataPilot(ScDocShell * pNewDocShell,ScDocument * pOldDoc,ScDocument * pNewDoc,const ScDPObject * pOldObj,const ScDPObject * pNewObj,sal_Bool bMove)1792cdf0e10cSrcweir ScUndoDataPilot::ScUndoDataPilot( ScDocShell* pNewDocShell,
1793cdf0e10cSrcweir 							ScDocument* pOldDoc, ScDocument* pNewDoc,
1794cdf0e10cSrcweir 							const ScDPObject* pOldObj, const ScDPObject* pNewObj, sal_Bool bMove ) :
1795cdf0e10cSrcweir 	ScSimpleUndo( pNewDocShell ),
1796cdf0e10cSrcweir 	pOldUndoDoc( pOldDoc ),
1797cdf0e10cSrcweir 	pNewUndoDoc( pNewDoc ),
1798cdf0e10cSrcweir 	pOldDPObject( NULL ),
1799cdf0e10cSrcweir 	pNewDPObject( NULL ),
1800cdf0e10cSrcweir 	bAllowMove( bMove )
1801cdf0e10cSrcweir {
1802cdf0e10cSrcweir 	if (pOldObj)
1803cdf0e10cSrcweir 		pOldDPObject = new ScDPObject( *pOldObj );
1804cdf0e10cSrcweir 	if (pNewObj)
1805cdf0e10cSrcweir 		pNewDPObject = new ScDPObject( *pNewObj );
1806cdf0e10cSrcweir }
1807cdf0e10cSrcweir 
~ScUndoDataPilot()1808cdf0e10cSrcweir __EXPORT ScUndoDataPilot::~ScUndoDataPilot()
1809cdf0e10cSrcweir {
1810cdf0e10cSrcweir 	delete pOldDPObject;
1811cdf0e10cSrcweir 	delete pNewDPObject;
1812cdf0e10cSrcweir 	delete pOldUndoDoc;
1813cdf0e10cSrcweir 	delete pNewUndoDoc;
1814cdf0e10cSrcweir }
1815cdf0e10cSrcweir 
GetComment() const1816cdf0e10cSrcweir String __EXPORT ScUndoDataPilot::GetComment() const
1817cdf0e10cSrcweir {
1818cdf0e10cSrcweir 	sal_uInt16 nIndex;
1819cdf0e10cSrcweir 	if ( pOldUndoDoc && pNewUndoDoc )
1820cdf0e10cSrcweir 		nIndex = STR_UNDO_PIVOT_MODIFY;
1821cdf0e10cSrcweir 	else if ( pNewUndoDoc )
1822cdf0e10cSrcweir 		nIndex = STR_UNDO_PIVOT_NEW;
1823cdf0e10cSrcweir 	else
1824cdf0e10cSrcweir 		nIndex = STR_UNDO_PIVOT_DELETE;
1825cdf0e10cSrcweir 
1826cdf0e10cSrcweir 	return ScGlobal::GetRscString( nIndex );
1827cdf0e10cSrcweir }
1828cdf0e10cSrcweir 
Undo()1829cdf0e10cSrcweir void __EXPORT ScUndoDataPilot::Undo()
1830cdf0e10cSrcweir {
1831cdf0e10cSrcweir 	BeginUndo();
1832cdf0e10cSrcweir 
1833cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
1834cdf0e10cSrcweir 
1835cdf0e10cSrcweir 	ScRange aOldRange;
1836cdf0e10cSrcweir 	ScRange aNewRange;
1837cdf0e10cSrcweir 
1838cdf0e10cSrcweir 	if ( pNewDPObject && pNewUndoDoc )
1839cdf0e10cSrcweir 	{
1840cdf0e10cSrcweir 		aNewRange = pNewDPObject->GetOutRange();
1841cdf0e10cSrcweir 		pDoc->DeleteAreaTab( aNewRange, IDF_ALL );
1842cdf0e10cSrcweir 		pNewUndoDoc->CopyToDocument( aNewRange, IDF_ALL, sal_False, pDoc );
1843cdf0e10cSrcweir 	}
1844cdf0e10cSrcweir 	if ( pOldDPObject && pOldUndoDoc )
1845cdf0e10cSrcweir 	{
1846cdf0e10cSrcweir 		aOldRange = pOldDPObject->GetOutRange();
1847cdf0e10cSrcweir 		pDoc->DeleteAreaTab( aOldRange, IDF_ALL );
1848cdf0e10cSrcweir 		pOldUndoDoc->CopyToDocument( aOldRange, IDF_ALL, sal_False, pDoc );
1849cdf0e10cSrcweir 	}
1850cdf0e10cSrcweir 
1851cdf0e10cSrcweir 	//	update objects in collection
1852cdf0e10cSrcweir 
1853cdf0e10cSrcweir 	if ( pNewDPObject )
1854cdf0e10cSrcweir 	{
1855cdf0e10cSrcweir 		//	find updated object
1856cdf0e10cSrcweir 		//!	find by name!
1857cdf0e10cSrcweir 
1858cdf0e10cSrcweir 		ScDPObject* pDocObj = pDoc->GetDPAtCursor(
1859cdf0e10cSrcweir 							aNewRange.aStart.Col(), aNewRange.aStart.Row(), aNewRange.aStart.Tab() );
1860cdf0e10cSrcweir 		DBG_ASSERT(pDocObj, "DPObject not found");
1861cdf0e10cSrcweir 		if (pDocObj)
1862cdf0e10cSrcweir 		{
1863cdf0e10cSrcweir 			if ( pOldDPObject )
1864cdf0e10cSrcweir 			{
1865cdf0e10cSrcweir 				//	restore old settings
1866cdf0e10cSrcweir 				pOldDPObject->WriteSourceDataTo( *pDocObj );
1867cdf0e10cSrcweir 				ScDPSaveData* pData = pOldDPObject->GetSaveData();
1868cdf0e10cSrcweir 				if (pData)
1869cdf0e10cSrcweir 					pDocObj->SetSaveData(*pData);
1870cdf0e10cSrcweir 				pDocObj->SetOutRange( pOldDPObject->GetOutRange() );
1871cdf0e10cSrcweir 				pOldDPObject->WriteTempDataTo( *pDocObj );
1872cdf0e10cSrcweir 			}
1873cdf0e10cSrcweir 			else
1874cdf0e10cSrcweir 			{
1875cdf0e10cSrcweir 				//	delete inserted object
1876cdf0e10cSrcweir                 pDoc->GetDPCollection()->FreeTable(pDocObj);
1877cdf0e10cSrcweir 			}
1878cdf0e10cSrcweir 		}
1879cdf0e10cSrcweir 	}
1880cdf0e10cSrcweir 	else if ( pOldDPObject )
1881cdf0e10cSrcweir 	{
1882cdf0e10cSrcweir 		//	re-insert deleted object
1883cdf0e10cSrcweir 
1884cdf0e10cSrcweir 		ScDPObject* pDestObj = new ScDPObject( *pOldDPObject );
1885cdf0e10cSrcweir 		pDestObj->SetAlive(sal_True);
1886cdf0e10cSrcweir 		if ( !pDoc->GetDPCollection()->InsertNewTable(pDestObj) )
1887cdf0e10cSrcweir 		{
1888cdf0e10cSrcweir 			DBG_ERROR("cannot insert DPObject");
1889cdf0e10cSrcweir 			DELETEZ( pDestObj );
1890cdf0e10cSrcweir 		}
1891cdf0e10cSrcweir 	}
1892cdf0e10cSrcweir 
1893cdf0e10cSrcweir 	if (pNewUndoDoc)
1894cdf0e10cSrcweir 		pDocShell->PostPaint( aNewRange, PAINT_GRID, SC_PF_LINES );
1895cdf0e10cSrcweir 	if (pOldUndoDoc)
1896cdf0e10cSrcweir 		pDocShell->PostPaint( aOldRange, PAINT_GRID, SC_PF_LINES );
1897cdf0e10cSrcweir 	pDocShell->PostDataChanged();
1898cdf0e10cSrcweir 
1899cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1900cdf0e10cSrcweir 	if (pViewShell)
1901cdf0e10cSrcweir 	{
1902cdf0e10cSrcweir 		//!	set current sheet
1903cdf0e10cSrcweir 	}
1904cdf0e10cSrcweir 
1905cdf0e10cSrcweir     if (pNewDPObject)
1906cdf0e10cSrcweir     {
1907cdf0e10cSrcweir         // notify API objects
1908cdf0e10cSrcweir         pDoc->BroadcastUno( ScDataPilotModifiedHint( pNewDPObject->GetName() ) );
1909cdf0e10cSrcweir     }
1910cdf0e10cSrcweir 
1911cdf0e10cSrcweir 	EndUndo();
1912cdf0e10cSrcweir }
1913cdf0e10cSrcweir 
Redo()1914cdf0e10cSrcweir void __EXPORT ScUndoDataPilot::Redo()
1915cdf0e10cSrcweir {
1916cdf0e10cSrcweir 	BeginRedo();
1917cdf0e10cSrcweir 
1918cdf0e10cSrcweir 	//!	copy output data instead of repeating the change,
1919cdf0e10cSrcweir 	//!	in case external data have changed!
1920cdf0e10cSrcweir 
1921cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
1922cdf0e10cSrcweir 
1923cdf0e10cSrcweir 	ScDPObject* pSourceObj = NULL;
1924cdf0e10cSrcweir 	if ( pOldDPObject )
1925cdf0e10cSrcweir 	{
1926cdf0e10cSrcweir 		//	find object to modify
1927cdf0e10cSrcweir 		//!	find by name!
1928cdf0e10cSrcweir 
1929cdf0e10cSrcweir 		ScRange aOldRange = pOldDPObject->GetOutRange();
1930cdf0e10cSrcweir 		pSourceObj = pDoc->GetDPAtCursor(
1931cdf0e10cSrcweir 						aOldRange.aStart.Col(), aOldRange.aStart.Row(), aOldRange.aStart.Tab() );
1932cdf0e10cSrcweir 		DBG_ASSERT(pSourceObj, "DPObject not found");
1933cdf0e10cSrcweir 	}
1934cdf0e10cSrcweir 
1935cdf0e10cSrcweir 	ScDBDocFunc aFunc( *pDocShell );
1936cdf0e10cSrcweir 	aFunc.DataPilotUpdate( pSourceObj, pNewDPObject, sal_False, sal_False, bAllowMove );	// no new undo action
1937cdf0e10cSrcweir 
1938cdf0e10cSrcweir 	EndRedo();
1939cdf0e10cSrcweir }
1940cdf0e10cSrcweir 
Repeat(SfxRepeatTarget &)1941cdf0e10cSrcweir void __EXPORT ScUndoDataPilot::Repeat(SfxRepeatTarget& /* rTarget */)
1942cdf0e10cSrcweir {
1943cdf0e10cSrcweir 	//!	allow deletion
1944cdf0e10cSrcweir }
1945cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget &) const1946cdf0e10cSrcweir sal_Bool __EXPORT ScUndoDataPilot::CanRepeat(SfxRepeatTarget& /* rTarget */) const
1947cdf0e10cSrcweir {
1948cdf0e10cSrcweir 	//!	allow deletion
1949cdf0e10cSrcweir 	return sal_False;
1950cdf0e10cSrcweir }
1951cdf0e10cSrcweir 
1952cdf0e10cSrcweir 
1953cdf0e10cSrcweir //
1954cdf0e10cSrcweir //		Konsolidieren
1955cdf0e10cSrcweir //
1956cdf0e10cSrcweir 
ScUndoConsolidate(ScDocShell * pNewDocShell,const ScArea & rArea,const ScConsolidateParam & rPar,ScDocument * pNewUndoDoc,sal_Bool bReference,SCROW nInsCount,ScOutlineTable * pTab,ScDBData * pData)1957cdf0e10cSrcweir ScUndoConsolidate::ScUndoConsolidate( ScDocShell* pNewDocShell, const ScArea& rArea,
1958cdf0e10cSrcweir 					const ScConsolidateParam& rPar, ScDocument* pNewUndoDoc,
1959cdf0e10cSrcweir 					sal_Bool bReference, SCROW nInsCount, ScOutlineTable* pTab,
1960cdf0e10cSrcweir 					ScDBData* pData ) :
1961cdf0e10cSrcweir 	ScSimpleUndo( pNewDocShell ),
1962cdf0e10cSrcweir 	aDestArea( rArea ),
1963cdf0e10cSrcweir 	pUndoDoc( pNewUndoDoc ),
1964cdf0e10cSrcweir 	aParam( rPar ),
1965cdf0e10cSrcweir 	bInsRef( bReference ),
1966cdf0e10cSrcweir 	nInsertCount( nInsCount ),
1967cdf0e10cSrcweir 	pUndoTab( pTab ),
1968cdf0e10cSrcweir 	pUndoData( pData )
1969cdf0e10cSrcweir {
1970cdf0e10cSrcweir }
1971cdf0e10cSrcweir 
~ScUndoConsolidate()1972cdf0e10cSrcweir __EXPORT ScUndoConsolidate::~ScUndoConsolidate()
1973cdf0e10cSrcweir {
1974cdf0e10cSrcweir 	delete pUndoDoc;
1975cdf0e10cSrcweir 	delete pUndoTab;
1976cdf0e10cSrcweir 	delete pUndoData;
1977cdf0e10cSrcweir }
1978cdf0e10cSrcweir 
GetComment() const1979cdf0e10cSrcweir String __EXPORT ScUndoConsolidate::GetComment() const
1980cdf0e10cSrcweir {
1981cdf0e10cSrcweir 	return ScGlobal::GetRscString( STR_UNDO_CONSOLIDATE );
1982cdf0e10cSrcweir }
1983cdf0e10cSrcweir 
Undo()1984cdf0e10cSrcweir void __EXPORT ScUndoConsolidate::Undo()
1985cdf0e10cSrcweir {
1986cdf0e10cSrcweir 	BeginUndo();
1987cdf0e10cSrcweir 
1988cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
1989cdf0e10cSrcweir 	SCTAB nTab = aDestArea.nTab;
1990cdf0e10cSrcweir 
1991cdf0e10cSrcweir 	ScRange aOldRange;
1992cdf0e10cSrcweir 	if (pUndoData)
1993cdf0e10cSrcweir 		pUndoData->GetArea(aOldRange);
1994cdf0e10cSrcweir 
1995cdf0e10cSrcweir 	if (bInsRef)
1996cdf0e10cSrcweir 	{
1997cdf0e10cSrcweir 		//	Zeilen loeschen
1998cdf0e10cSrcweir 		pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, aDestArea.nRowStart, nInsertCount );
1999cdf0e10cSrcweir 
2000cdf0e10cSrcweir 		//	Outlines
2001cdf0e10cSrcweir 		pDoc->SetOutlineTable( nTab, pUndoTab );
2002cdf0e10cSrcweir 
2003cdf0e10cSrcweir 		//	Zeilenstatus
2004cdf0e10cSrcweir 		pUndoDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, sal_False, pDoc );
2005cdf0e10cSrcweir 
2006cdf0e10cSrcweir 		//	Daten & Referenzen
2007cdf0e10cSrcweir 		pDoc->DeleteAreaTab( 0,aDestArea.nRowStart, MAXCOL,aDestArea.nRowEnd, nTab, IDF_ALL );
2008cdf0e10cSrcweir 		pUndoDoc->UndoToDocument( 0, aDestArea.nRowStart, nTab,
2009cdf0e10cSrcweir 									MAXCOL, aDestArea.nRowEnd, nTab,
2010cdf0e10cSrcweir 									IDF_ALL, sal_False, pDoc );
2011cdf0e10cSrcweir 
2012cdf0e10cSrcweir 		//	Original-Bereich
2013cdf0e10cSrcweir 		if (pUndoData)
2014cdf0e10cSrcweir 		{
2015cdf0e10cSrcweir 			pDoc->DeleteAreaTab(aOldRange, IDF_ALL);
2016cdf0e10cSrcweir 			pUndoDoc->CopyToDocument(aOldRange, IDF_ALL, sal_False, pDoc);
2017cdf0e10cSrcweir 		}
2018cdf0e10cSrcweir 
2019cdf0e10cSrcweir 		pDocShell->PostPaint( 0,aDestArea.nRowStart,nTab, MAXCOL,MAXROW,nTab,
2020cdf0e10cSrcweir 								PAINT_GRID | PAINT_LEFT | PAINT_SIZE );
2021cdf0e10cSrcweir 	}
2022cdf0e10cSrcweir 	else
2023cdf0e10cSrcweir 	{
2024cdf0e10cSrcweir 		pDoc->DeleteAreaTab( aDestArea.nColStart,aDestArea.nRowStart,
2025cdf0e10cSrcweir 								aDestArea.nColEnd,aDestArea.nRowEnd, nTab, IDF_ALL );
2026cdf0e10cSrcweir 		pUndoDoc->CopyToDocument( aDestArea.nColStart, aDestArea.nRowStart, nTab,
2027cdf0e10cSrcweir 									aDestArea.nColEnd, aDestArea.nRowEnd, nTab,
2028cdf0e10cSrcweir 									IDF_ALL, sal_False, pDoc );
2029cdf0e10cSrcweir 
2030cdf0e10cSrcweir 		//	Original-Bereich
2031cdf0e10cSrcweir 		if (pUndoData)
2032cdf0e10cSrcweir 		{
2033cdf0e10cSrcweir 			pDoc->DeleteAreaTab(aOldRange, IDF_ALL);
2034cdf0e10cSrcweir 			pUndoDoc->CopyToDocument(aOldRange, IDF_ALL, sal_False, pDoc);
2035cdf0e10cSrcweir 		}
2036cdf0e10cSrcweir 
2037cdf0e10cSrcweir 		SCCOL nEndX = aDestArea.nColEnd;
2038cdf0e10cSrcweir 		SCROW nEndY = aDestArea.nRowEnd;
2039cdf0e10cSrcweir 		if ( pUndoData )
2040cdf0e10cSrcweir 		{
2041cdf0e10cSrcweir 			if ( aOldRange.aEnd.Col() > nEndX )
2042cdf0e10cSrcweir 				nEndX = aOldRange.aEnd.Col();
2043cdf0e10cSrcweir 			if ( aOldRange.aEnd.Row() > nEndY )
2044cdf0e10cSrcweir 				nEndY = aOldRange.aEnd.Row();
2045cdf0e10cSrcweir 		}
2046cdf0e10cSrcweir 		pDocShell->PostPaint( aDestArea.nColStart, aDestArea.nRowStart, nTab,
2047cdf0e10cSrcweir 									nEndX, nEndY, nTab, PAINT_GRID );
2048cdf0e10cSrcweir 	}
2049cdf0e10cSrcweir 
2050cdf0e10cSrcweir 	//	DB-Bereich wieder anpassen
2051cdf0e10cSrcweir 	if (pUndoData)
2052cdf0e10cSrcweir 	{
2053cdf0e10cSrcweir 		ScDBCollection*	pColl = pDoc->GetDBCollection();
2054cdf0e10cSrcweir 		if (pColl)
2055cdf0e10cSrcweir 		{
2056cdf0e10cSrcweir 			sal_uInt16 nIndex;
2057cdf0e10cSrcweir 			if (pColl->SearchName( pUndoData->GetName(), nIndex ))
2058cdf0e10cSrcweir 			{
2059cdf0e10cSrcweir 				ScDBData* pDocData = (*pColl)[nIndex];
2060cdf0e10cSrcweir 				if (pDocData)
2061cdf0e10cSrcweir 					*pDocData = *pUndoData;
2062cdf0e10cSrcweir 			}
2063cdf0e10cSrcweir 			else
2064cdf0e10cSrcweir 			{
2065cdf0e10cSrcweir 				DBG_ERROR("alte DB-Daten nicht gefunden");
2066cdf0e10cSrcweir 			}
2067cdf0e10cSrcweir 		}
2068cdf0e10cSrcweir 	}
2069cdf0e10cSrcweir 
2070cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
2071cdf0e10cSrcweir 	if (pViewShell)
2072cdf0e10cSrcweir 	{
2073cdf0e10cSrcweir 		SCTAB nViewTab = pViewShell->GetViewData()->GetTabNo();
2074cdf0e10cSrcweir 		if ( nViewTab != nTab )
2075cdf0e10cSrcweir 			pViewShell->SetTabNo( nTab );
2076cdf0e10cSrcweir 	}
2077cdf0e10cSrcweir 
2078cdf0e10cSrcweir 	EndUndo();
2079cdf0e10cSrcweir }
2080cdf0e10cSrcweir 
Redo()2081cdf0e10cSrcweir void __EXPORT ScUndoConsolidate::Redo()
2082cdf0e10cSrcweir {
2083cdf0e10cSrcweir 	BeginRedo();
2084cdf0e10cSrcweir 
2085cdf0e10cSrcweir 	pDocShell->DoConsolidate( aParam, sal_False );
2086cdf0e10cSrcweir 
2087cdf0e10cSrcweir 	ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
2088cdf0e10cSrcweir 	if (pViewShell)
2089cdf0e10cSrcweir 	{
2090cdf0e10cSrcweir 		SCTAB nViewTab = pViewShell->GetViewData()->GetTabNo();
2091cdf0e10cSrcweir 		if ( nViewTab != aParam.nTab )
2092cdf0e10cSrcweir 			pViewShell->SetTabNo( aParam.nTab );
2093cdf0e10cSrcweir 	}
2094cdf0e10cSrcweir 
2095cdf0e10cSrcweir 	EndRedo();
2096cdf0e10cSrcweir }
2097cdf0e10cSrcweir 
Repeat(SfxRepeatTarget &)2098cdf0e10cSrcweir void __EXPORT ScUndoConsolidate::Repeat(SfxRepeatTarget& /* rTarget */)
2099cdf0e10cSrcweir {
2100cdf0e10cSrcweir }
2101cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget &) const2102cdf0e10cSrcweir sal_Bool __EXPORT ScUndoConsolidate::CanRepeat(SfxRepeatTarget& /* rTarget */) const
2103cdf0e10cSrcweir {
2104cdf0e10cSrcweir 	return sal_False;
2105cdf0e10cSrcweir }
2106cdf0e10cSrcweir 
2107cdf0e10cSrcweir 
2108cdf0e10cSrcweir //
2109cdf0e10cSrcweir //		Quell-Daten von Chart aendern
2110cdf0e10cSrcweir //
2111cdf0e10cSrcweir 
Init()2112cdf0e10cSrcweir void ScUndoChartData::Init()
2113cdf0e10cSrcweir {
2114cdf0e10cSrcweir 	ScDocument* pDoc = pDocShell->GetDocument();
2115cdf0e10cSrcweir     aOldRangeListRef = new ScRangeList;
2116cdf0e10cSrcweir     pDoc->GetOldChartParameters( aChartName, *aOldRangeListRef, bOldColHeaders, bOldRowHeaders );
2117cdf0e10cSrcweir }
2118cdf0e10cSrcweir 
ScUndoChartData(ScDocShell * pNewDocShell,const String & rName,const ScRange & rNew,sal_Bool bColHdr,sal_Bool bRowHdr,sal_Bool bAdd)2119cdf0e10cSrcweir ScUndoChartData::ScUndoChartData( ScDocShell* pNewDocShell, const String& rName,
2120cdf0e10cSrcweir 									const ScRange& rNew, sal_Bool bColHdr, sal_Bool bRowHdr,
2121cdf0e10cSrcweir 									sal_Bool bAdd ) :
2122cdf0e10cSrcweir 	ScSimpleUndo( pNewDocShell ),
2123cdf0e10cSrcweir 	aChartName( rName ),
2124cdf0e10cSrcweir 	bNewColHeaders( bColHdr ),
2125cdf0e10cSrcweir 	bNewRowHeaders( bRowHdr ),
2126cdf0e10cSrcweir 	bAddRange( bAdd )
2127cdf0e10cSrcweir {
2128cdf0e10cSrcweir 	aNewRangeListRef = new ScRangeList;
2129cdf0e10cSrcweir 	aNewRangeListRef->Append( rNew );
2130cdf0e10cSrcweir 
2131cdf0e10cSrcweir 	Init();
2132cdf0e10cSrcweir }
2133cdf0e10cSrcweir 
ScUndoChartData(ScDocShell * pNewDocShell,const String & rName,const ScRangeListRef & rNew,sal_Bool bColHdr,sal_Bool bRowHdr,sal_Bool bAdd)2134cdf0e10cSrcweir ScUndoChartData::ScUndoChartData( ScDocShell* pNewDocShell, const String& rName,
2135cdf0e10cSrcweir 									const ScRangeListRef& rNew, sal_Bool bColHdr, sal_Bool bRowHdr,
2136cdf0e10cSrcweir 									sal_Bool bAdd ) :
2137cdf0e10cSrcweir 	ScSimpleUndo( pNewDocShell ),
2138cdf0e10cSrcweir 	aChartName( rName ),
2139cdf0e10cSrcweir 	aNewRangeListRef( rNew ),
2140cdf0e10cSrcweir 	bNewColHeaders( bColHdr ),
2141cdf0e10cSrcweir 	bNewRowHeaders( bRowHdr ),
2142cdf0e10cSrcweir 	bAddRange( bAdd )
2143cdf0e10cSrcweir {
2144cdf0e10cSrcweir 	Init();
2145cdf0e10cSrcweir }
2146cdf0e10cSrcweir 
~ScUndoChartData()2147cdf0e10cSrcweir __EXPORT ScUndoChartData::~ScUndoChartData()
2148cdf0e10cSrcweir {
2149cdf0e10cSrcweir }
2150cdf0e10cSrcweir 
GetComment() const2151cdf0e10cSrcweir String __EXPORT ScUndoChartData::GetComment() const
2152cdf0e10cSrcweir {
2153cdf0e10cSrcweir 	return ScGlobal::GetRscString( STR_UNDO_CHARTDATA );
2154cdf0e10cSrcweir }
2155cdf0e10cSrcweir 
Undo()2156cdf0e10cSrcweir void __EXPORT ScUndoChartData::Undo()
2157cdf0e10cSrcweir {
2158cdf0e10cSrcweir 	BeginUndo();
2159cdf0e10cSrcweir 
2160cdf0e10cSrcweir 	pDocShell->GetDocument()->UpdateChartArea( aChartName, aOldRangeListRef,
2161cdf0e10cSrcweir 								bOldColHeaders, bOldRowHeaders, sal_False );
2162cdf0e10cSrcweir 
2163cdf0e10cSrcweir 	EndUndo();
2164cdf0e10cSrcweir }
2165cdf0e10cSrcweir 
Redo()2166cdf0e10cSrcweir void __EXPORT ScUndoChartData::Redo()
2167cdf0e10cSrcweir {
2168cdf0e10cSrcweir 	BeginRedo();
2169cdf0e10cSrcweir 
2170cdf0e10cSrcweir 	pDocShell->GetDocument()->UpdateChartArea( aChartName, aNewRangeListRef,
2171cdf0e10cSrcweir 								bNewColHeaders, bNewRowHeaders, bAddRange );
2172cdf0e10cSrcweir 
2173cdf0e10cSrcweir 	EndRedo();
2174cdf0e10cSrcweir }
2175cdf0e10cSrcweir 
Repeat(SfxRepeatTarget &)2176cdf0e10cSrcweir void __EXPORT ScUndoChartData::Repeat(SfxRepeatTarget& /* rTarget */)
2177cdf0e10cSrcweir {
2178cdf0e10cSrcweir }
2179cdf0e10cSrcweir 
CanRepeat(SfxRepeatTarget &) const2180cdf0e10cSrcweir sal_Bool __EXPORT ScUndoChartData::CanRepeat(SfxRepeatTarget& /* rTarget */) const
2181cdf0e10cSrcweir {
2182cdf0e10cSrcweir 	return sal_False;
2183cdf0e10cSrcweir }
2184cdf0e10cSrcweir 
2185cdf0e10cSrcweir 
2186cdf0e10cSrcweir 
2187cdf0e10cSrcweir 
2188cdf0e10cSrcweir 
2189cdf0e10cSrcweir 
2190