Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "scitems.hxx" // SearchItem
30 : :
31 : : #include "undoblk.hxx"
32 : : #include "document.hxx"
33 : : #include "docsh.hxx"
34 : : #include "tabvwsh.hxx"
35 : : #include "olinetab.hxx"
36 : : #include "globstr.hrc"
37 : : #include "global.hxx"
38 : : #include "target.hxx"
39 : :
40 : : #include "undoolk.hxx" //! GetUndo ins Document verschieben!
41 : :
42 : :
43 : : // STATIC DATA -----------------------------------------------------------
44 : :
45 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoWidthOrHeight, SfxUndoAction);
46 : :
47 : : // -----------------------------------------------------------------------
48 : :
49 : :
50 : :
51 : : //
52 : : // Spaltenbreiten oder Zeilenhoehen aendern
53 : : //
54 : :
55 : 6 : ScUndoWidthOrHeight::ScUndoWidthOrHeight( ScDocShell* pNewDocShell,
56 : : const ScMarkData& rMark,
57 : : SCCOLROW nNewStart, SCTAB nNewStartTab, SCCOLROW nNewEnd, SCTAB nNewEndTab,
58 : : ScDocument* pNewUndoDoc, SCCOLROW nNewCnt, SCCOLROW* pNewRanges,
59 : : ScOutlineTable* pNewUndoTab,
60 : : ScSizeMode eNewMode, sal_uInt16 nNewSizeTwips, sal_Bool bNewWidth ) :
61 : : ScSimpleUndo( pNewDocShell ),
62 : : aMarkData( rMark ),
63 : : nStart( nNewStart ),
64 : : nEnd( nNewEnd ),
65 : : nStartTab( nNewStartTab ),
66 : : nEndTab( nNewEndTab ),
67 : : pUndoDoc( pNewUndoDoc ),
68 : : pUndoTab( pNewUndoTab ),
69 : : nRangeCnt( nNewCnt ),
70 : : pRanges( pNewRanges ),
71 : : nNewSize( nNewSizeTwips ),
72 : : bWidth( bNewWidth ),
73 : : eMode( eNewMode ),
74 [ + - ]: 6 : pDrawUndo( NULL )
75 : : {
76 [ + - ]: 6 : pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
77 : 6 : }
78 : :
79 [ + - ]: 6 : ScUndoWidthOrHeight::~ScUndoWidthOrHeight()
80 : : {
81 [ + - ]: 6 : delete[] pRanges;
82 [ + - ][ + - ]: 6 : delete pUndoDoc;
83 [ - + ][ # # ]: 6 : delete pUndoTab;
84 [ + - ]: 6 : DeleteSdrUndoAction( pDrawUndo );
85 [ - + ]: 12 : }
86 : :
87 : 14 : rtl::OUString ScUndoWidthOrHeight::GetComment() const
88 : : {
89 : : // [ "optimale " ] "Spaltenbreite" | "Zeilenhoehe"
90 : : return ( bWidth ?
91 : : ( ( eMode == SC_SIZE_OPTIMAL )?
92 : : ScGlobal::GetRscString( STR_UNDO_OPTCOLWIDTH ) :
93 : : ScGlobal::GetRscString( STR_UNDO_COLWIDTH )
94 : : ) :
95 : : ( ( eMode == SC_SIZE_OPTIMAL )?
96 : : ScGlobal::GetRscString( STR_UNDO_OPTROWHEIGHT ) :
97 : : ScGlobal::GetRscString( STR_UNDO_ROWHEIGHT )
98 [ + + ][ + - ]: 14 : ) );
[ - + ]
99 : : }
100 : :
101 : 0 : void ScUndoWidthOrHeight::Undo()
102 : : {
103 [ # # ]: 0 : BeginUndo();
104 : :
105 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
106 : :
107 [ # # ]: 0 : SCCOLROW nPaintStart = nStart > 0 ? nStart-1 : static_cast<SCCOLROW>(0);
108 : :
109 [ # # ]: 0 : if (eMode==SC_SIZE_OPTIMAL)
110 : : {
111 [ # # ][ # # ]: 0 : if ( SetViewMarkData( aMarkData ) )
112 : 0 : nPaintStart = 0; // paint all, because of changed selection
113 : : }
114 : :
115 : : //! outlines from all tables?
116 [ # # ]: 0 : if (pUndoTab) // Outlines mit gespeichert?
117 [ # # ]: 0 : pDoc->SetOutlineTable( nStartTab, pUndoTab );
118 : :
119 [ # # ]: 0 : SCTAB nTabCount = pDoc->GetTableCount();
120 [ # # ][ # # ]: 0 : ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end();
121 [ # # ][ # # ]: 0 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ # # ][ # # ]
[ # # ][ # # ]
122 : : {
123 [ # # ]: 0 : if (bWidth) // Width
124 : : {
125 [ # # ]: 0 : pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, *itr,
126 [ # # ]: 0 : static_cast<SCCOL>(nEnd), MAXROW, *itr, IDF_NONE,
127 [ # # ]: 0 : false, pDoc );
128 [ # # ][ # # ]: 0 : pDoc->UpdatePageBreaks( *itr );
129 [ # # ]: 0 : pDocShell->PostPaint( static_cast<SCCOL>(nPaintStart), 0, *itr,
130 [ # # ][ # # ]: 0 : MAXCOL, MAXROW, *itr, PAINT_GRID | PAINT_TOP );
131 : : }
132 : : else // Height
133 : : {
134 [ # # ][ # # ]: 0 : pUndoDoc->CopyToDocument( 0, nStart, *itr, MAXCOL, nEnd, *itr, IDF_NONE, false, pDoc );
[ # # ]
135 [ # # ][ # # ]: 0 : pDoc->UpdatePageBreaks( *itr );
136 [ # # ][ # # ]: 0 : pDocShell->PostPaint( 0, nPaintStart, *itr, MAXCOL, MAXROW, *itr, PAINT_GRID | PAINT_LEFT );
[ # # ]
137 : : }
138 : : }
139 : :
140 [ # # ]: 0 : DoSdrUndoAction( pDrawUndo, pDoc );
141 : :
142 [ # # ]: 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
143 [ # # ]: 0 : if (pViewShell)
144 : : {
145 [ # # ]: 0 : pViewShell->UpdateScrollBars();
146 : :
147 : 0 : SCTAB nCurrentTab = pViewShell->GetViewData()->GetTabNo();
148 [ # # ][ # # ]: 0 : if ( nCurrentTab < nStartTab || nCurrentTab > nEndTab )
149 [ # # ]: 0 : pViewShell->SetTabNo( nStartTab );
150 : : }
151 : :
152 [ # # ]: 0 : EndUndo();
153 : 0 : }
154 : :
155 : 0 : void ScUndoWidthOrHeight::Redo()
156 : : {
157 : 0 : BeginRedo();
158 : :
159 : 0 : sal_Bool bPaintAll = false;
160 [ # # ]: 0 : if (eMode==SC_SIZE_OPTIMAL)
161 : : {
162 [ # # ]: 0 : if ( SetViewMarkData( aMarkData ) )
163 : 0 : bPaintAll = sal_True; // paint all, because of changed selection
164 : : }
165 : :
166 : 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
167 [ # # ]: 0 : if (pViewShell)
168 : : {
169 : 0 : SCTAB nTab = pViewShell->GetViewData()->GetTabNo();
170 [ # # ][ # # ]: 0 : if ( nTab < nStartTab || nTab > nEndTab )
171 : 0 : pViewShell->SetTabNo( nStartTab );
172 : :
173 : : // SetWidthOrHeight aendert aktuelle Tabelle !
174 : 0 : pViewShell->SetWidthOrHeight( bWidth, nRangeCnt, pRanges, eMode, nNewSize, false, true, &aMarkData );
175 : : }
176 : :
177 : : // paint grid if selection was changed directly at the MarkData
178 [ # # ]: 0 : if (bPaintAll)
179 : 0 : pDocShell->PostPaint( 0, 0, nStartTab, MAXCOL, MAXROW, nEndTab, PAINT_GRID );
180 : :
181 : 0 : EndRedo();
182 : 0 : }
183 : :
184 : 0 : void ScUndoWidthOrHeight::Repeat(SfxRepeatTarget& rTarget)
185 : : {
186 [ # # ]: 0 : if (rTarget.ISA(ScTabViewTarget))
187 : 0 : ((ScTabViewTarget&)rTarget).GetViewShell()->SetMarkedWidthOrHeight( bWidth, eMode, nNewSize, sal_True );
188 : 0 : }
189 : :
190 : 4 : sal_Bool ScUndoWidthOrHeight::CanRepeat(SfxRepeatTarget& rTarget) const
191 : : {
192 : 4 : return (rTarget.ISA(ScTabViewTarget));
193 : : }
194 : :
195 : :
196 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|