1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: undoblk2.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 // System - Includes -----------------------------------------------------
39 #include "scitems.hxx" // SearchItem
42 // INCLUDE ---------------------------------------------------------------
44 #include "undoblk.hxx"
45 #include "document.hxx"
47 #include "tabvwsh.hxx"
48 #include "olinetab.hxx"
49 #include "globstr.hrc"
53 #include "undoolk.hxx" //! GetUndo ins Document verschieben!
56 // STATIC DATA -----------------------------------------------------------
58 TYPEINIT1(ScUndoWidthOrHeight
, SfxUndoAction
);
60 // -----------------------------------------------------------------------
65 // Spaltenbreiten oder Zeilenhoehen aendern
68 ScUndoWidthOrHeight::ScUndoWidthOrHeight( ScDocShell
* pNewDocShell
,
69 const ScMarkData
& rMark
,
70 SCCOLROW nNewStart
, SCTAB nNewStartTab
, SCCOLROW nNewEnd
, SCTAB nNewEndTab
,
71 ScDocument
* pNewUndoDoc
, SCCOLROW nNewCnt
, SCCOLROW
* pNewRanges
,
72 ScOutlineTable
* pNewUndoTab
,
73 ScSizeMode eNewMode
, USHORT nNewSizeTwips
, BOOL bNewWidth
) :
74 ScSimpleUndo( pNewDocShell
),
78 nStartTab( nNewStartTab
),
79 nEndTab( nNewEndTab
),
80 pUndoDoc( pNewUndoDoc
),
81 pUndoTab( pNewUndoTab
),
83 pRanges( pNewRanges
),
84 nNewSize( nNewSizeTwips
),
89 pDrawUndo
= GetSdrUndoAction( pDocShell
->GetDocument() );
92 __EXPORT
ScUndoWidthOrHeight::~ScUndoWidthOrHeight()
97 DeleteSdrUndoAction( pDrawUndo
);
100 String __EXPORT
ScUndoWidthOrHeight::GetComment() const
102 // [ "optimale " ] "Spaltenbreite" | "Zeilenhoehe"
104 ( ( eMode
== SC_SIZE_OPTIMAL
)?
105 ScGlobal::GetRscString( STR_UNDO_OPTCOLWIDTH
) :
106 ScGlobal::GetRscString( STR_UNDO_COLWIDTH
)
108 ( ( eMode
== SC_SIZE_OPTIMAL
)?
109 ScGlobal::GetRscString( STR_UNDO_OPTROWHEIGHT
) :
110 ScGlobal::GetRscString( STR_UNDO_ROWHEIGHT
)
114 void __EXPORT
ScUndoWidthOrHeight::Undo()
118 ScDocument
* pDoc
= pDocShell
->GetDocument();
119 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
121 SCCOLROW nPaintStart
= nStart
> 0 ? nStart
-1 : static_cast<SCCOLROW
>(0);
123 if (eMode
==SC_SIZE_OPTIMAL
)
127 pViewShell
->SetMarkData( aMarkData
);
129 nPaintStart
= 0; // paint all, because of changed selection
133 //! outlines from all tables?
134 if (pUndoTab
) // Outlines mit gespeichert?
135 pDoc
->SetOutlineTable( nStartTab
, pUndoTab
);
137 SCTAB nTabCount
= pDoc
->GetTableCount();
139 for (nTab
=0; nTab
<nTabCount
; nTab
++)
140 if (aMarkData
.GetTableSelect(nTab
))
144 pUndoDoc
->CopyToDocument( static_cast<SCCOL
>(nStart
), 0, nTab
,
145 static_cast<SCCOL
>(nEnd
), MAXROW
, nTab
, IDF_NONE
,
147 pDoc
->UpdatePageBreaks( nTab
);
148 pDocShell
->PostPaint( static_cast<SCCOL
>(nPaintStart
), 0, nTab
,
149 MAXCOL
, MAXROW
, nTab
, PAINT_GRID
| PAINT_TOP
);
153 pUndoDoc
->CopyToDocument( 0, nStart
, nTab
, MAXCOL
, nEnd
, nTab
, IDF_NONE
, FALSE
, pDoc
);
154 pDoc
->UpdatePageBreaks( nTab
);
155 pDocShell
->PostPaint( 0, nPaintStart
, nTab
, MAXCOL
, MAXROW
, nTab
, PAINT_GRID
| PAINT_LEFT
);
159 DoSdrUndoAction( pDrawUndo
, pDoc
);
163 pViewShell
->UpdateScrollBars();
165 SCTAB nCurrentTab
= pViewShell
->GetViewData()->GetTabNo();
166 if ( nCurrentTab
< nStartTab
|| nCurrentTab
> nEndTab
)
167 pViewShell
->SetTabNo( nStartTab
);
173 void __EXPORT
ScUndoWidthOrHeight::Redo()
177 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
179 BOOL bPaintAll
= FALSE
;
180 if (eMode
==SC_SIZE_OPTIMAL
)
184 pViewShell
->SetMarkData( aMarkData
);
186 bPaintAll
= TRUE
; // paint all, because of changed selection
192 SCTAB nTab
= pViewShell
->GetViewData()->GetTabNo();
193 if ( nTab
< nStartTab
|| nTab
> nEndTab
)
194 pViewShell
->SetTabNo( nStartTab
);
197 // SetWidthOrHeight aendert aktuelle Tabelle !
198 pViewShell
->SetWidthOrHeight( bWidth
, nRangeCnt
, pRanges
, eMode
, nNewSize
, FALSE
, TRUE
, &aMarkData
);
200 // paint grid if selection was changed directly at the MarkData
202 pDocShell
->PostPaint( 0, 0, nStartTab
, MAXCOL
, MAXROW
, nEndTab
, PAINT_GRID
);
207 void __EXPORT
ScUndoWidthOrHeight::Repeat(SfxRepeatTarget
& rTarget
)
209 if (rTarget
.ISA(ScTabViewTarget
))
210 ((ScTabViewTarget
&)rTarget
).GetViewShell()->SetMarkedWidthOrHeight( bWidth
, eMode
, nNewSize
, TRUE
);
213 BOOL __EXPORT
ScUndoWidthOrHeight::CanRepeat(SfxRepeatTarget
& rTarget
) const
215 return (rTarget
.ISA(ScTabViewTarget
));