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"
30 : :
31 : : #include <sfx2/app.hxx>
32 : : #include <editeng/editobj.hxx>
33 : : #include <sfx2/linkmgr.hxx>
34 : : #include <sfx2/bindings.hxx>
35 : : #include <vcl/msgbox.hxx>
36 : : #include <vcl/virdev.hxx>
37 : : #include <vcl/waitobj.hxx>
38 : : #include <svl/PasswordHelper.hxx>
39 : :
40 : : #include <com/sun/star/container/XNameContainer.hpp>
41 : : #include <com/sun/star/script/ModuleType.hpp>
42 : : #include <com/sun/star/script/XLibraryContainer.hpp>
43 : : #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
44 : :
45 : : #include "docfunc.hxx"
46 : :
47 : : #include "sc.hrc"
48 : :
49 : : #include "arealink.hxx"
50 : : #include "attrib.hxx"
51 : : #include "dociter.hxx"
52 : : #include "autoform.hxx"
53 : : #include "cell.hxx"
54 : : #include "cellmergeoption.hxx"
55 : : #include "detdata.hxx"
56 : : #include "detfunc.hxx"
57 : : #include "docpool.hxx"
58 : : #include "docsh.hxx"
59 : : #include "drwlayer.hxx"
60 : : #include "editutil.hxx"
61 : : #include "globstr.hrc"
62 : : #include "globalnames.hxx"
63 : : #include "olinetab.hxx"
64 : : #include "patattr.hxx"
65 : : #include "rangenam.hxx"
66 : : #include "rangeutl.hxx"
67 : : #include "refundo.hxx"
68 : : #include "scresid.hxx"
69 : : #include "stlpool.hxx"
70 : : #include "stlsheet.hxx"
71 : : #include "tablink.hxx"
72 : : #include "tabvwsh.hxx"
73 : : #include "uiitems.hxx"
74 : : #include "undoblk.hxx"
75 : : #include "undocell.hxx"
76 : : #include "undodraw.hxx"
77 : : #include "undotab.hxx"
78 : : #include "waitoff.hxx"
79 : : #include "sizedev.hxx"
80 : : #include "scmod.hxx"
81 : : #include "inputhdl.hxx"
82 : : #include "inputwin.hxx"
83 : : #include "editable.hxx"
84 : : #include "compiler.hxx"
85 : : #include "scui_def.hxx"
86 : : #include "tabprotection.hxx"
87 : : #include "clipparam.hxx"
88 : : #include "externalrefmgr.hxx"
89 : : #include "undorangename.hxx"
90 : : #include "progress.hxx"
91 : :
92 : : #include <memory>
93 : : #include <basic/basmgr.hxx>
94 : : #include <boost/scoped_ptr.hpp>
95 : : #include <set>
96 : : #include <vector>
97 : :
98 : : using namespace com::sun::star;
99 : : using ::com::sun::star::uno::Sequence;
100 : : using ::std::vector;
101 : :
102 : :
103 : : // STATIC DATA -----------------------------------------------------------
104 : :
105 : : //========================================================================
106 : :
107 : 58 : IMPL_LINK( ScDocFunc, NotifyDrawUndo, SdrUndoAction*, pUndoAction )
108 : : {
109 : : // #i101118# if drawing layer collects the undo actions, add it there
110 : 58 : ScDrawLayer* pDrawLayer = rDocShell.GetDocument()->GetDrawLayer();
111 [ - + ][ - + ]: 58 : if( pDrawLayer && pDrawLayer->IsRecording() )
[ + - ]
112 : 0 : pDrawLayer->AddCalcUndo( pUndoAction );
113 : : else
114 [ + - ]: 58 : rDocShell.GetUndoManager()->AddUndoAction( new ScUndoDraw( pUndoAction, &rDocShell ) );
115 : 58 : rDocShell.SetDrawModified();
116 : :
117 : : // the affected sheet isn't known, so all stream positions are invalidated
118 : 58 : ScDocument* pDoc = rDocShell.GetDocument();
119 : 58 : SCTAB nTabCount = pDoc->GetTableCount();
120 [ + + ]: 192 : for (SCTAB nTab=0; nTab<nTabCount; nTab++)
121 [ - + ]: 134 : if (pDoc->IsStreamValid(nTab))
122 : 0 : pDoc->SetStreamValid(nTab, false);
123 : :
124 : 58 : return 0;
125 : : }
126 : :
127 : : //------------------------------------------------------------------------
128 : :
129 : : // Zeile ueber dem Range painten (fuer Linien nach AdjustRowHeight)
130 : :
131 : 39 : void lcl_PaintAbove( ScDocShell& rDocShell, const ScRange& rRange )
132 : : {
133 : 39 : SCROW nRow = rRange.aStart.Row();
134 [ + + ]: 39 : if ( nRow > 0 )
135 : : {
136 : 1 : SCTAB nTab = rRange.aStart.Tab(); //! alle?
137 : 1 : --nRow;
138 [ + - ][ + - ]: 1 : rDocShell.PostPaint( ScRange(0,nRow,nTab, MAXCOL,nRow,nTab), PAINT_GRID );
[ + - ]
139 : : }
140 : 39 : }
141 : :
142 : : //------------------------------------------------------------------------
143 : :
144 : 2013 : sal_Bool ScDocFunc::AdjustRowHeight( const ScRange& rRange, sal_Bool bPaint )
145 : : {
146 : 2013 : ScDocument* pDoc = rDocShell.GetDocument();
147 [ + + ]: 2013 : if ( pDoc->IsImportingXML() )
148 : : {
149 : : // for XML import, all row heights are updated together after importing
150 : 1101 : return false;
151 : : }
152 [ + + ]: 912 : if ( !pDoc->IsAdjustHeightEnabled() )
153 : : {
154 : 66 : return false;
155 : : }
156 : :
157 : 846 : SCTAB nTab = rRange.aStart.Tab();
158 : 846 : SCROW nStartRow = rRange.aStart.Row();
159 : 846 : SCROW nEndRow = rRange.aEnd.Row();
160 : :
161 [ + - ]: 846 : ScSizeDeviceProvider aProv( &rDocShell );
162 [ + - ]: 846 : Fraction aOne(1,1);
163 : :
164 : : sal_Bool bChanged = pDoc->SetOptimalHeight( nStartRow, nEndRow, nTab, 0, aProv.GetDevice(),
165 [ + - ]: 846 : aProv.GetPPTX(), aProv.GetPPTY(), aOne, aOne, false );
166 : :
167 [ + + ][ + + ]: 846 : if ( bPaint && bChanged )
168 : : rDocShell.PostPaint(ScRange(0, nStartRow, nTab, MAXCOL, MAXROW, nTab),
169 [ + - ][ + - ]: 91 : PAINT_GRID | PAINT_LEFT);
[ + - ]
170 : :
171 [ + - ]: 2013 : return bChanged;
172 : : }
173 : :
174 : :
175 : : //------------------------------------------------------------------------
176 : :
177 : 1 : sal_Bool ScDocFunc::DetectiveAddPred(const ScAddress& rPos)
178 : : {
179 [ + - ]: 1 : ScDocShellModificator aModificator( rDocShell );
180 : :
181 [ + - ]: 1 : rDocShell.MakeDrawLayer();
182 : 1 : ScDocument* pDoc = rDocShell.GetDocument();
183 : 1 : bool bUndo (pDoc->IsUndoEnabled());
184 [ + - ]: 1 : ScDrawLayer* pModel = pDoc->GetDrawLayer();
185 : 1 : SCCOL nCol = rPos.Col();
186 : 1 : SCROW nRow = rPos.Row();
187 : 1 : SCTAB nTab = rPos.Tab();
188 : :
189 [ + - ]: 1 : if (bUndo)
190 [ + - ]: 1 : pModel->BeginCalcUndo();
191 [ + - ]: 1 : sal_Bool bDone = ScDetectiveFunc( pDoc,nTab ).ShowPred( nCol, nRow );
192 : 1 : SdrUndoGroup* pUndo = NULL;
193 [ + - ]: 1 : if (bUndo)
194 [ + - ]: 1 : pUndo = pModel->GetCalcUndo();
195 [ + - ]: 1 : if (bDone)
196 : : {
197 : 1 : ScDetOpData aOperation( ScAddress(nCol,nRow,nTab), SCDETOP_ADDPRED );
198 [ + - ]: 1 : pDoc->AddDetectiveOperation( aOperation );
199 [ + - ]: 1 : if (bUndo)
200 : : {
201 [ + - ]: 1 : rDocShell.GetUndoManager()->AddUndoAction(
202 [ + - ][ + - ]: 1 : new ScUndoDetective( &rDocShell, pUndo, &aOperation ) );
[ + - ]
203 : : }
204 [ + - ]: 1 : aModificator.SetDocumentModified();
205 [ + - ]: 1 : SfxBindings* pBindings = rDocShell.GetViewBindings();
206 [ + - ]: 1 : if (pBindings)
207 [ + - ]: 1 : pBindings->Invalidate( SID_DETECTIVE_REFRESH );
208 : : }
209 : : else
210 [ # # ][ # # ]: 0 : delete pUndo;
211 : :
212 [ + - ]: 1 : return bDone;
213 : : }
214 : :
215 : 0 : sal_Bool ScDocFunc::DetectiveDelPred(const ScAddress& rPos)
216 : : {
217 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
218 : :
219 : 0 : bool bUndo(pDoc->IsUndoEnabled());
220 [ # # ]: 0 : ScDrawLayer* pModel = pDoc->GetDrawLayer();
221 [ # # ]: 0 : if (!pModel)
222 : 0 : return false;
223 : :
224 [ # # ]: 0 : ScDocShellModificator aModificator( rDocShell );
225 : :
226 : 0 : SCCOL nCol = rPos.Col();
227 : 0 : SCROW nRow = rPos.Row();
228 : 0 : SCTAB nTab = rPos.Tab();
229 : :
230 [ # # ]: 0 : if (bUndo)
231 [ # # ]: 0 : pModel->BeginCalcUndo();
232 [ # # ]: 0 : sal_Bool bDone = ScDetectiveFunc( pDoc,nTab ).DeletePred( nCol, nRow );
233 : 0 : SdrUndoGroup* pUndo = NULL;
234 [ # # ]: 0 : if (bUndo)
235 [ # # ]: 0 : pUndo = pModel->GetCalcUndo();
236 [ # # ]: 0 : if (bDone)
237 : : {
238 : 0 : ScDetOpData aOperation( ScAddress(nCol,nRow,nTab), SCDETOP_DELPRED );
239 [ # # ]: 0 : pDoc->AddDetectiveOperation( aOperation );
240 [ # # ]: 0 : if (bUndo)
241 : : {
242 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
243 [ # # ][ # # ]: 0 : new ScUndoDetective( &rDocShell, pUndo, &aOperation ) );
[ # # ]
244 : : }
245 [ # # ]: 0 : aModificator.SetDocumentModified();
246 [ # # ]: 0 : SfxBindings* pBindings = rDocShell.GetViewBindings();
247 [ # # ]: 0 : if (pBindings)
248 [ # # ]: 0 : pBindings->Invalidate( SID_DETECTIVE_REFRESH );
249 : : }
250 : : else
251 [ # # ][ # # ]: 0 : delete pUndo;
252 : :
253 [ # # ]: 0 : return bDone;
254 : : }
255 : :
256 : 0 : sal_Bool ScDocFunc::DetectiveAddSucc(const ScAddress& rPos)
257 : : {
258 [ # # ]: 0 : ScDocShellModificator aModificator( rDocShell );
259 : :
260 [ # # ]: 0 : rDocShell.MakeDrawLayer();
261 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
262 : :
263 : 0 : bool bUndo(pDoc->IsUndoEnabled());
264 [ # # ]: 0 : ScDrawLayer* pModel = pDoc->GetDrawLayer();
265 : 0 : SCCOL nCol = rPos.Col();
266 : 0 : SCROW nRow = rPos.Row();
267 : 0 : SCTAB nTab = rPos.Tab();
268 : :
269 [ # # ]: 0 : if (bUndo)
270 [ # # ]: 0 : pModel->BeginCalcUndo();
271 [ # # ]: 0 : sal_Bool bDone = ScDetectiveFunc( pDoc,nTab ).ShowSucc( nCol, nRow );
272 : 0 : SdrUndoGroup* pUndo = NULL;
273 [ # # ]: 0 : if (bUndo)
274 [ # # ]: 0 : pUndo = pModel->GetCalcUndo();
275 [ # # ]: 0 : if (bDone)
276 : : {
277 : 0 : ScDetOpData aOperation( ScAddress(nCol,nRow,nTab), SCDETOP_ADDSUCC );
278 [ # # ]: 0 : pDoc->AddDetectiveOperation( aOperation );
279 [ # # ]: 0 : if (bUndo)
280 : : {
281 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
282 [ # # ][ # # ]: 0 : new ScUndoDetective( &rDocShell, pUndo, &aOperation ) );
[ # # ]
283 : : }
284 [ # # ]: 0 : aModificator.SetDocumentModified();
285 [ # # ]: 0 : SfxBindings* pBindings = rDocShell.GetViewBindings();
286 [ # # ]: 0 : if (pBindings)
287 [ # # ]: 0 : pBindings->Invalidate( SID_DETECTIVE_REFRESH );
288 : : }
289 : : else
290 [ # # ][ # # ]: 0 : delete pUndo;
291 : :
292 [ # # ]: 0 : return bDone;
293 : : }
294 : :
295 : 0 : sal_Bool ScDocFunc::DetectiveDelSucc(const ScAddress& rPos)
296 : : {
297 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
298 : :
299 : 0 : bool bUndo (pDoc->IsUndoEnabled());
300 [ # # ]: 0 : ScDrawLayer* pModel = pDoc->GetDrawLayer();
301 [ # # ]: 0 : if (!pModel)
302 : 0 : return false;
303 : :
304 [ # # ]: 0 : ScDocShellModificator aModificator( rDocShell );
305 : :
306 : 0 : SCCOL nCol = rPos.Col();
307 : 0 : SCROW nRow = rPos.Row();
308 : 0 : SCTAB nTab = rPos.Tab();
309 : :
310 [ # # ]: 0 : if (bUndo)
311 [ # # ]: 0 : pModel->BeginCalcUndo();
312 [ # # ]: 0 : sal_Bool bDone = ScDetectiveFunc( pDoc,nTab ).DeleteSucc( nCol, nRow );
313 : 0 : SdrUndoGroup* pUndo = NULL;
314 [ # # ]: 0 : if (bUndo)
315 [ # # ]: 0 : pUndo = pModel->GetCalcUndo();
316 [ # # ]: 0 : if (bDone)
317 : : {
318 : 0 : ScDetOpData aOperation( ScAddress(nCol,nRow,nTab), SCDETOP_DELSUCC );
319 [ # # ]: 0 : pDoc->AddDetectiveOperation( aOperation );
320 [ # # ]: 0 : if (bUndo)
321 : : {
322 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
323 [ # # ][ # # ]: 0 : new ScUndoDetective( &rDocShell, pUndo, &aOperation ) );
[ # # ]
324 : : }
325 [ # # ]: 0 : aModificator.SetDocumentModified();
326 [ # # ]: 0 : SfxBindings* pBindings = rDocShell.GetViewBindings();
327 [ # # ]: 0 : if (pBindings)
328 [ # # ]: 0 : pBindings->Invalidate( SID_DETECTIVE_REFRESH );
329 : : }
330 : : else
331 [ # # ][ # # ]: 0 : delete pUndo;
332 : :
333 [ # # ]: 0 : return bDone;
334 : : }
335 : :
336 : 0 : sal_Bool ScDocFunc::DetectiveAddError(const ScAddress& rPos)
337 : : {
338 [ # # ]: 0 : ScDocShellModificator aModificator( rDocShell );
339 : :
340 [ # # ]: 0 : rDocShell.MakeDrawLayer();
341 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
342 : :
343 : 0 : bool bUndo (pDoc->IsUndoEnabled());
344 [ # # ]: 0 : ScDrawLayer* pModel = pDoc->GetDrawLayer();
345 : 0 : SCCOL nCol = rPos.Col();
346 : 0 : SCROW nRow = rPos.Row();
347 : 0 : SCTAB nTab = rPos.Tab();
348 : :
349 [ # # ]: 0 : if (bUndo)
350 [ # # ]: 0 : pModel->BeginCalcUndo();
351 [ # # ]: 0 : sal_Bool bDone = ScDetectiveFunc( pDoc,nTab ).ShowError( nCol, nRow );
352 : 0 : SdrUndoGroup* pUndo = NULL;
353 [ # # ]: 0 : if (bUndo)
354 [ # # ]: 0 : pUndo = pModel->GetCalcUndo();
355 [ # # ]: 0 : if (bDone)
356 : : {
357 : 0 : ScDetOpData aOperation( ScAddress(nCol,nRow,nTab), SCDETOP_ADDERROR );
358 [ # # ]: 0 : pDoc->AddDetectiveOperation( aOperation );
359 [ # # ]: 0 : if (bUndo)
360 : : {
361 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
362 [ # # ][ # # ]: 0 : new ScUndoDetective( &rDocShell, pUndo, &aOperation ) );
[ # # ]
363 : : }
364 [ # # ]: 0 : aModificator.SetDocumentModified();
365 [ # # ]: 0 : SfxBindings* pBindings = rDocShell.GetViewBindings();
366 [ # # ]: 0 : if (pBindings)
367 [ # # ]: 0 : pBindings->Invalidate( SID_DETECTIVE_REFRESH );
368 : : }
369 : : else
370 [ # # ][ # # ]: 0 : delete pUndo;
371 : :
372 [ # # ]: 0 : return bDone;
373 : : }
374 : :
375 : 0 : sal_Bool ScDocFunc::DetectiveMarkInvalid(SCTAB nTab)
376 : : {
377 [ # # ]: 0 : ScDocShellModificator aModificator( rDocShell );
378 : :
379 [ # # ]: 0 : rDocShell.MakeDrawLayer();
380 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
381 : :
382 : 0 : bool bUndo (pDoc->IsUndoEnabled());
383 [ # # ]: 0 : ScDrawLayer* pModel = pDoc->GetDrawLayer();
384 : :
385 [ # # ]: 0 : Window* pWaitWin = rDocShell.GetActiveDialogParent();
386 [ # # ]: 0 : if (pWaitWin)
387 [ # # ]: 0 : pWaitWin->EnterWait();
388 [ # # ]: 0 : if (bUndo)
389 [ # # ]: 0 : pModel->BeginCalcUndo();
390 : : sal_Bool bOverflow;
391 [ # # ]: 0 : sal_Bool bDone = ScDetectiveFunc( pDoc,nTab ).MarkInvalid( bOverflow );
392 : 0 : SdrUndoGroup* pUndo = NULL;
393 [ # # ]: 0 : if (bUndo)
394 [ # # ]: 0 : pUndo = pModel->GetCalcUndo();
395 [ # # ]: 0 : if (pWaitWin)
396 [ # # ]: 0 : pWaitWin->LeaveWait();
397 [ # # ]: 0 : if (bDone)
398 : : {
399 [ # # ][ # # ]: 0 : if (pUndo && bUndo)
400 : : {
401 [ # # ][ # # ]: 0 : pUndo->SetComment( ScGlobal::GetRscString( STR_UNDO_DETINVALID ) );
402 [ # # ][ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction( pUndo );
403 : : }
404 [ # # ]: 0 : aModificator.SetDocumentModified();
405 [ # # ]: 0 : if ( bOverflow )
406 : : {
407 : : InfoBox( NULL,
408 [ # # ][ # # ]: 0 : ScGlobal::GetRscString( STR_DETINVALID_OVERFLOW ) ).Execute();
[ # # ][ # # ]
409 : : }
410 : : }
411 : : else
412 [ # # ][ # # ]: 0 : delete pUndo;
413 : :
414 [ # # ]: 0 : return bDone;
415 : : }
416 : :
417 : 0 : sal_Bool ScDocFunc::DetectiveDelAll(SCTAB nTab)
418 : : {
419 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
420 : :
421 : 0 : bool bUndo (pDoc->IsUndoEnabled());
422 [ # # ]: 0 : ScDrawLayer* pModel = pDoc->GetDrawLayer();
423 [ # # ]: 0 : if (!pModel)
424 : 0 : return false;
425 : :
426 [ # # ]: 0 : ScDocShellModificator aModificator( rDocShell );
427 : :
428 [ # # ]: 0 : if (bUndo)
429 [ # # ]: 0 : pModel->BeginCalcUndo();
430 [ # # ]: 0 : sal_Bool bDone = ScDetectiveFunc( pDoc,nTab ).DeleteAll( SC_DET_DETECTIVE );
431 : 0 : SdrUndoGroup* pUndo = NULL;
432 [ # # ]: 0 : if (bUndo)
433 [ # # ]: 0 : pUndo = pModel->GetCalcUndo();
434 [ # # ]: 0 : if (bDone)
435 : : {
436 : 0 : ScDetOpList* pOldList = pDoc->GetDetOpList();
437 : 0 : ScDetOpList* pUndoList = NULL;
438 [ # # ]: 0 : if (bUndo)
439 [ # # ][ # # ]: 0 : pUndoList = pOldList ? new ScDetOpList(*pOldList) : NULL;
[ # # ]
440 : :
441 [ # # ]: 0 : pDoc->ClearDetectiveOperations();
442 : :
443 [ # # ]: 0 : if (bUndo)
444 : : {
445 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
446 [ # # ][ # # ]: 0 : new ScUndoDetective( &rDocShell, pUndo, NULL, pUndoList ) );
[ # # ]
447 : : }
448 [ # # ]: 0 : aModificator.SetDocumentModified();
449 [ # # ]: 0 : SfxBindings* pBindings = rDocShell.GetViewBindings();
450 [ # # ]: 0 : if (pBindings)
451 [ # # ]: 0 : pBindings->Invalidate( SID_DETECTIVE_REFRESH );
452 : : }
453 : : else
454 [ # # ][ # # ]: 0 : delete pUndo;
455 : :
456 [ # # ]: 0 : return bDone;
457 : : }
458 : :
459 : 130 : sal_Bool ScDocFunc::DetectiveRefresh( sal_Bool bAutomatic )
460 : : {
461 : 130 : sal_Bool bDone = false;
462 : 130 : ScDocument* pDoc = rDocShell.GetDocument();
463 : :
464 : 130 : bool bUndo (pDoc->IsUndoEnabled());
465 : 130 : ScDetOpList* pList = pDoc->GetDetOpList();
466 [ + - ][ + + ]: 130 : if ( pList && pList->Count() )
[ + + ]
467 : : {
468 : 12 : rDocShell.MakeDrawLayer();
469 : 12 : ScDrawLayer* pModel = pDoc->GetDrawLayer();
470 [ + - ]: 12 : if (bUndo)
471 : 12 : pModel->BeginCalcUndo();
472 : :
473 : : // Loeschen auf allen Tabellen
474 : :
475 : 12 : SCTAB nTabCount = pDoc->GetTableCount();
476 [ + + ]: 36 : for (SCTAB nTab=0; nTab<nTabCount; nTab++)
477 [ + - ]: 24 : ScDetectiveFunc( pDoc,nTab ).DeleteAll( SC_DET_ARROWS ); // don't remove circles
478 : :
479 : : // Wiederholen
480 : :
481 : 12 : size_t nCount = pList->Count();
482 [ + + ]: 24 : for (size_t i=0; i < nCount; ++i)
483 : : {
484 : 12 : const ScDetOpData* pData = pList->GetObject(i);
485 [ + - ]: 12 : if (pData)
486 : : {
487 : 12 : ScAddress aPos = pData->GetPos();
488 : 12 : ScDetectiveFunc aFunc( pDoc, aPos.Tab() );
489 : 12 : SCCOL nCol = aPos.Col();
490 : 12 : SCROW nRow = aPos.Row();
491 [ - - + - : 12 : switch (pData->GetOperation())
- - ]
492 : : {
493 : : case SCDETOP_ADDSUCC:
494 [ # # ]: 0 : aFunc.ShowSucc( nCol, nRow );
495 : 0 : break;
496 : : case SCDETOP_DELSUCC:
497 [ # # ]: 0 : aFunc.DeleteSucc( nCol, nRow );
498 : 0 : break;
499 : : case SCDETOP_ADDPRED:
500 [ + - ]: 12 : aFunc.ShowPred( nCol, nRow );
501 : 12 : break;
502 : : case SCDETOP_DELPRED:
503 [ # # ]: 0 : aFunc.DeletePred( nCol, nRow );
504 : 0 : break;
505 : : case SCDETOP_ADDERROR:
506 [ # # ]: 0 : aFunc.ShowError( nCol, nRow );
507 : 12 : break;
508 : : default:
509 : : OSL_FAIL("falsche Op bei DetectiveRefresh");
510 : : }
511 : : }
512 : : }
513 : :
514 [ + - ]: 12 : if (bUndo)
515 : : {
516 : 12 : SdrUndoGroup* pUndo = pModel->GetCalcUndo();
517 [ + - ]: 12 : if (pUndo)
518 : : {
519 : 12 : pUndo->SetComment( ScGlobal::GetRscString( STR_UNDO_DETREFRESH ) );
520 : : // wenn automatisch, an letzte Aktion anhaengen
521 : 12 : rDocShell.GetUndoManager()->AddUndoAction(
522 [ + - ]: 12 : new ScUndoDraw( pUndo, &rDocShell ),
523 : 24 : bAutomatic );
524 : : }
525 : : }
526 : 12 : rDocShell.SetDrawModified();
527 : 12 : bDone = sal_True;
528 : : }
529 : 130 : return bDone;
530 : : }
531 : :
532 : 9 : static void lcl_collectAllPredOrSuccRanges(
533 : : const ScRangeList& rSrcRanges, vector<ScTokenRef>& rRefTokens, ScDocShell& rDocShell,
534 : : bool bPred)
535 : : {
536 : 9 : ScDocument* pDoc = rDocShell.GetDocument();
537 [ + - ]: 9 : vector<ScTokenRef> aRefTokens;
538 [ + - ]: 9 : ScRangeList aSrcRanges(rSrcRanges);
539 [ + - ][ - + ]: 9 : if (aSrcRanges.empty())
540 : 9 : return;
541 [ + - ]: 9 : ScRange* p = aSrcRanges.front();
542 : 9 : ScDetectiveFunc aDetFunc(pDoc, p->aStart.Tab());
543 [ + - ]: 9 : ScRangeList aDestRanges;
544 [ + - ][ + + ]: 18 : for (size_t i = 0, n = aSrcRanges.size(); i < n; ++i)
545 : : {
546 [ + - ]: 9 : p = aSrcRanges[i];
547 [ + + ]: 9 : if (bPred)
548 : : {
549 : : aDetFunc.GetAllPreds(
550 [ + - ]: 6 : p->aStart.Col(), p->aStart.Row(), p->aEnd.Col(), p->aEnd.Row(), aRefTokens);
551 : : }
552 : : else
553 : : {
554 : : aDetFunc.GetAllSuccs(
555 [ + - ]: 3 : p->aStart.Col(), p->aStart.Row(), p->aEnd.Col(), p->aEnd.Row(), aRefTokens);
556 : : }
557 : : }
558 [ + - ][ + - ]: 9 : rRefTokens.swap(aRefTokens);
[ - + ][ + - ]
559 : : }
560 : :
561 : 6 : void ScDocFunc::DetectiveCollectAllPreds(const ScRangeList& rSrcRanges, vector<ScTokenRef>& rRefTokens)
562 : : {
563 : 6 : lcl_collectAllPredOrSuccRanges(rSrcRanges, rRefTokens, rDocShell, true);
564 : 6 : }
565 : :
566 : 3 : void ScDocFunc::DetectiveCollectAllSuccs(const ScRangeList& rSrcRanges, vector<ScTokenRef>& rRefTokens)
567 : : {
568 : 3 : lcl_collectAllPredOrSuccRanges(rSrcRanges, rRefTokens, rDocShell, false);
569 : 3 : }
570 : :
571 : : //------------------------------------------------------------------------
572 : :
573 : 8 : sal_Bool ScDocFunc::DeleteContents( const ScMarkData& rMark, sal_uInt16 nFlags,
574 : : sal_Bool bRecord, sal_Bool bApi )
575 : : {
576 [ + - ]: 8 : ScDocShellModificator aModificator( rDocShell );
577 : :
578 [ + + ][ - + ]: 8 : if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
[ - + ]
579 : : {
580 : : OSL_FAIL("ScDocFunc::DeleteContents ohne Markierung");
581 : 0 : return false;
582 : : }
583 : :
584 : 8 : ScDocument* pDoc = rDocShell.GetDocument();
585 : :
586 [ - + ][ - + ]: 8 : if (bRecord && !pDoc->IsUndoEnabled())
[ + - ]
587 : 0 : bRecord = false;
588 : :
589 [ + - ]: 8 : ScEditableTester aTester( pDoc, rMark );
590 [ - + ]: 8 : if (!aTester.IsEditable())
591 : : {
592 [ # # ]: 0 : if (!bApi)
593 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
594 : 0 : return false;
595 : : }
596 : :
597 : 8 : ScRange aMarkRange;
598 : 8 : sal_Bool bSimple = false;
599 : :
600 [ + - ]: 8 : ScMarkData aMultiMark = rMark;
601 : 8 : aMultiMark.SetMarking(false); // fuer MarkToMulti
602 : :
603 : 8 : ScDocument* pUndoDoc = NULL;
604 [ + + ][ + - ]: 8 : sal_Bool bMulti = !bSimple && aMultiMark.IsMultiMarked();
605 [ + - ]: 8 : if (!bSimple)
606 : : {
607 [ + - ]: 8 : aMultiMark.MarkToMulti();
608 [ + - ]: 8 : aMultiMark.GetMultiMarkArea( aMarkRange );
609 : : }
610 : 8 : ScRange aExtendedRange(aMarkRange);
611 [ + - ]: 8 : if (!bSimple)
612 : : {
613 [ + - ][ - + ]: 8 : if ( pDoc->ExtendMerge( aExtendedRange, sal_True ) )
614 : 0 : bMulti = false;
615 : : }
616 : :
617 : : // keine Objekte auf geschuetzten Tabellen
618 : 8 : sal_Bool bObjects = false;
619 [ + + ]: 8 : if ( nFlags & IDF_OBJECTS )
620 : : {
621 : 1 : bObjects = sal_True;
622 [ + - ]: 1 : SCTAB nTabCount = pDoc->GetTableCount();
623 [ + - ][ + - ]: 1 : ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
624 [ + - ][ + - ]: 2 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ + + ][ + - ]
[ + - ][ + + ]
625 [ + - ][ + - ]: 1 : if (pDoc->IsTabProtected(*itr))
[ - + ]
626 : 0 : bObjects = false;
627 : : }
628 : :
629 : 8 : sal_uInt16 nExtFlags = 0; // extra flags are needed only if attributes are deleted
630 [ + + ]: 8 : if ( nFlags & IDF_ATTRIB )
631 [ + - ]: 3 : rDocShell.UpdatePaintExt( nExtFlags, aMarkRange );
632 : :
633 : : // Reihenfolge:
634 : : // 1) BeginDrawUndo
635 : : // 2) Objekte loeschen (DrawUndo wird gefuellt)
636 : : // 3) Inhalte fuer Undo kopieren und Undo-Aktion anlegen
637 : : // 4) Inhalte loeschen
638 : :
639 [ + + ][ + + ]: 8 : bool bDrawUndo = bObjects || (nFlags & IDF_NOTE);
640 [ + - ][ + + ]: 8 : if (bRecord && bDrawUndo)
641 [ + - ]: 3 : pDoc->BeginDrawUndo();
642 : :
643 [ + + ]: 8 : if (bObjects)
644 : : {
645 [ - + ]: 1 : if (bMulti)
646 [ # # ]: 0 : pDoc->DeleteObjectsInSelection( aMultiMark );
647 : : else
648 : 1 : pDoc->DeleteObjectsInArea( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(),
649 : 1 : aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(),
650 [ + - ]: 3 : aMultiMark );
651 : : }
652 : :
653 [ + - ]: 8 : if ( bRecord )
654 : : {
655 [ + - ][ + - ]: 8 : pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
656 [ + - ]: 8 : pUndoDoc->InitUndo( pDoc, aMarkRange.aStart.Tab(), aMarkRange.aEnd.Tab() );
657 : :
658 : : // bei "Format/Standard" alle Attribute kopieren, weil CopyToDocument
659 : : // nur mit IDF_HARDATTR zu langsam ist:
660 : 8 : sal_uInt16 nUndoDocFlags = nFlags;
661 [ + + ]: 8 : if (nFlags & IDF_ATTRIB)
662 : 3 : nUndoDocFlags |= IDF_ATTRIB;
663 [ - + ]: 8 : if (nFlags & IDF_EDITATTR) // Edit-Engine-Attribute
664 : 0 : nUndoDocFlags |= IDF_STRING; // -> Zellen werden geaendert
665 [ + + ]: 8 : if (nFlags & IDF_NOTE)
666 : 3 : nUndoDocFlags |= IDF_CONTENTS; // copy all cells with their notes
667 : : // note captions are handled in drawing undo
668 : 8 : nUndoDocFlags |= IDF_NOCAPTIONS;
669 [ + - ]: 8 : pDoc->CopyToDocument( aExtendedRange, nUndoDocFlags, bMulti, pUndoDoc, &aMultiMark );
670 : : }
671 : :
672 : : //! HideAllCursors(); // falls Zusammenfassung aufgehoben wird
673 [ - + ]: 8 : if (bSimple)
674 : 0 : pDoc->DeleteArea( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(),
675 : 0 : aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(),
676 [ # # ]: 0 : aMultiMark, nFlags );
677 : : else
678 : : {
679 [ + - ]: 8 : pDoc->DeleteSelection( nFlags, aMultiMark );
680 : : }
681 : :
682 : : // add undo action after drawing undo is complete (objects and note captions)
683 [ + - ]: 8 : if( bRecord )
684 [ + - ]: 8 : rDocShell.GetUndoManager()->AddUndoAction(
685 : : new ScUndoDeleteContents( &rDocShell, aMultiMark, aExtendedRange,
686 [ + - ][ + - ]: 8 : pUndoDoc, bMulti, nFlags, bDrawUndo ) );
[ + - ]
687 : :
688 [ + - ][ + + ]: 8 : if (!AdjustRowHeight( aExtendedRange ))
689 [ + - ][ + - ]: 2 : rDocShell.PostPaint( aExtendedRange, PAINT_GRID, nExtFlags );
[ + - ]
690 [ - + ]: 6 : else if (nExtFlags & SC_PF_LINES)
691 [ # # ]: 0 : lcl_PaintAbove( rDocShell, aExtendedRange ); // fuer Linien ueber dem Bereich
692 : :
693 [ + - ]: 8 : aModificator.SetDocumentModified();
694 : :
695 [ + - ][ + - ]: 8 : return sal_True;
696 : : }
697 : :
698 : : //------------------------------------------------------------------------
699 : :
700 : 0 : sal_Bool ScDocFunc::TransliterateText( const ScMarkData& rMark, sal_Int32 nType,
701 : : sal_Bool bRecord, sal_Bool bApi )
702 : : {
703 [ # # ]: 0 : ScDocShellModificator aModificator( rDocShell );
704 : :
705 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
706 [ # # ][ # # ]: 0 : if (bRecord && !pDoc->IsUndoEnabled())
[ # # ]
707 : 0 : bRecord = false;
708 : :
709 [ # # ]: 0 : ScEditableTester aTester( pDoc, rMark );
710 [ # # ]: 0 : if (!aTester.IsEditable())
711 : : {
712 [ # # ]: 0 : if (!bApi)
713 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
714 : 0 : return false;
715 : : }
716 : :
717 : 0 : ScRange aMarkRange;
718 [ # # ]: 0 : ScMarkData aMultiMark = rMark;
719 : 0 : aMultiMark.SetMarking(false); // for MarkToMulti
720 [ # # ]: 0 : aMultiMark.MarkToMulti();
721 [ # # ]: 0 : aMultiMark.GetMultiMarkArea( aMarkRange );
722 : :
723 [ # # ]: 0 : if (bRecord)
724 : : {
725 : 0 : SCTAB nStartTab = aMarkRange.aStart.Tab();
726 [ # # ]: 0 : SCTAB nTabCount = pDoc->GetTableCount();
727 : :
728 [ # # ][ # # ]: 0 : ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
729 [ # # ]: 0 : pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab );
730 [ # # ][ # # ]: 0 : ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
731 [ # # ][ # # ]: 0 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ # # ][ # # ]
[ # # ][ # # ]
732 [ # # ][ # # ]: 0 : if (*itr != nStartTab)
733 [ # # ][ # # ]: 0 : pUndoDoc->AddUndoTab( *itr, *itr );
[ # # ]
734 : :
735 : 0 : ScRange aCopyRange = aMarkRange;
736 : 0 : aCopyRange.aStart.SetTab(0);
737 : 0 : aCopyRange.aEnd.SetTab(nTabCount-1);
738 [ # # ]: 0 : pDoc->CopyToDocument( aCopyRange, IDF_CONTENTS, sal_True, pUndoDoc, &aMultiMark );
739 : :
740 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
741 [ # # ][ # # ]: 0 : new ScUndoTransliterate( &rDocShell, aMultiMark, pUndoDoc, nType ) );
[ # # ]
742 : : }
743 : :
744 [ # # ]: 0 : pDoc->TransliterateText( aMultiMark, nType );
745 : :
746 [ # # ][ # # ]: 0 : if (!AdjustRowHeight( aMarkRange ))
747 [ # # ][ # # ]: 0 : rDocShell.PostPaint( aMarkRange, PAINT_GRID );
[ # # ]
748 : :
749 [ # # ]: 0 : aModificator.SetDocumentModified();
750 : :
751 [ # # ][ # # ]: 0 : return sal_True;
752 : : }
753 : :
754 : : //------------------------------------------------------------------------
755 : :
756 : 21 : sal_Bool ScDocFunc::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, const String& rText, sal_Bool bApi )
757 : : {
758 [ + - ]: 21 : ScDocShellModificator aModificator( rDocShell );
759 : 21 : ScDocument* pDoc = rDocShell.GetDocument();
760 : :
761 : 21 : bool bUndo(pDoc->IsUndoEnabled());
762 [ + - ]: 21 : ScEditableTester aTester( pDoc, rPos.Tab(), rPos.Col(),rPos.Row(), rPos.Col(),rPos.Row() );
763 [ - + ]: 21 : if (!aTester.IsEditable())
764 : : {
765 [ # # ]: 0 : if (!bApi)
766 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
767 : 0 : return false;
768 : : }
769 : :
770 : 21 : SCTAB* pTabs = NULL;
771 : 21 : ScBaseCell** ppOldCells = NULL;
772 : 21 : sal_Bool* pHasFormat = NULL;
773 : 21 : sal_uLong* pOldFormats = NULL;
774 [ + - ]: 21 : ScBaseCell* pDocCell = pDoc->GetCell( rPos );
775 [ + + ][ + + ]: 21 : sal_Bool bEditDeleted = (pDocCell && pDocCell->GetCellType() == CELLTYPE_EDIT);
776 [ + - ]: 21 : if (bUndo)
777 : : {
778 [ + - ]: 21 : pTabs = new SCTAB[1];
779 : 21 : pTabs[0] = rPos.Tab();
780 [ + - ]: 21 : ppOldCells = new ScBaseCell*[1];
781 [ + + ][ + - ]: 21 : ppOldCells[0] = pDocCell ? pDocCell->Clone( *pDoc ) : 0;
782 : :
783 [ + - ]: 21 : pHasFormat = new sal_Bool[1];
784 [ + - ]: 21 : pOldFormats = new sal_uLong[1];
785 : : const SfxPoolItem* pItem;
786 [ + - ]: 21 : const ScPatternAttr* pPattern = pDoc->GetPattern( rPos.Col(),rPos.Row(),rPos.Tab() );
787 [ - + ]: 42 : if ( SFX_ITEM_SET == pPattern->GetItemSet().GetItemState(
788 [ + - ]: 21 : ATTR_VALUE_FORMAT,false,&pItem) )
789 : : {
790 : 0 : pHasFormat[0] = sal_True;
791 : 0 : pOldFormats[0] = ((const SfxUInt32Item*)pItem)->GetValue();
792 : : }
793 : : else
794 : 21 : pHasFormat[0] = false;
795 : : }
796 : :
797 [ + - ][ + - ]: 21 : o_rbNumFmtSet = pDoc->SetString( rPos.Col(), rPos.Row(), rPos.Tab(), rText );
798 : :
799 [ + - ]: 21 : if (bUndo)
800 : : {
801 : : // wegen ChangeTracking darf UndoAction erst nach SetString angelegt werden
802 [ + - ]: 42 : rDocShell.GetUndoManager()->AddUndoAction(new ScUndoEnterData( &rDocShell, rPos.Col(),rPos.Row(),rPos.Tab(), 1,pTabs,
803 [ + - ][ + - ]: 42 : ppOldCells, pHasFormat, pOldFormats, rText, NULL ) );
[ + - ]
804 : : }
805 : :
806 [ + + ][ + - ]: 21 : if ( bEditDeleted || pDoc->HasAttrib( ScRange(rPos), HASATTR_NEEDHEIGHT ) )
[ - + ][ + + ]
[ + + # # ]
807 [ + - ]: 2 : AdjustRowHeight( ScRange(rPos) );
808 : :
809 [ + - ]: 21 : rDocShell.PostPaintCell( rPos );
810 [ + - ]: 21 : aModificator.SetDocumentModified();
811 : :
812 : : // notify input handler here the same way as in PutCell
813 [ + - ]: 21 : if (bApi)
814 [ + - ]: 21 : NotifyInputHandler( rPos );
815 : :
816 [ + - ]: 21 : return sal_True;
817 : : }
818 : :
819 : 2733 : sal_Bool ScDocFunc::PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bool bApi )
820 : : {
821 [ + - ]: 2733 : ScDocShellModificator aModificator( rDocShell );
822 : 2733 : ScDocument* pDoc = rDocShell.GetDocument();
823 : 2733 : bool bUndo (pDoc->IsUndoEnabled());
824 : 2733 : sal_Bool bXMLLoading(pDoc->IsImportingXML());
825 : :
826 : : // #i925#; it is not neccessary to test whether the cell is editable on loading a XML document
827 [ + + ]: 2733 : if (!bXMLLoading)
828 : : {
829 [ + - ]: 2694 : ScEditableTester aTester( pDoc, rPos.Tab(), rPos.Col(),rPos.Row(), rPos.Col(),rPos.Row() );
830 [ - + ]: 2694 : if (!aTester.IsEditable())
831 : : {
832 [ # # ]: 0 : if (!bApi)
833 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
834 [ # # ]: 0 : pNewCell->Delete();
835 : 2694 : return false;
836 [ + - ]: 2694 : }
837 : : }
838 : :
839 : 2733 : sal_Bool bEditCell = ( pNewCell->GetCellType() == CELLTYPE_EDIT );
840 [ + - ]: 2733 : ScBaseCell* pDocCell = pDoc->GetCell( rPos );
841 [ + + ][ + + ]: 2733 : sal_Bool bEditDeleted = (pDocCell && pDocCell->GetCellType() == CELLTYPE_EDIT);
842 : : sal_Bool bHeight = ( bEditDeleted || bEditCell ||
843 [ + + ][ + + ]: 2733 : pDoc->HasAttrib( ScRange(rPos), HASATTR_NEEDHEIGHT ) );
[ + - ][ - + ]
[ + + ][ # # ]
844 : :
845 [ + + ][ + + ]: 2733 : ScBaseCell* pUndoCell = (bUndo && pDocCell) ? pDocCell->Clone( *pDoc, rPos ) : 0;
[ + - ]
846 [ + + ][ + - ]: 2733 : ScBaseCell* pRedoCell = (bUndo && pNewCell) ? pNewCell->Clone( *pDoc, rPos ) : 0;
[ + - ]
847 : :
848 [ + - ]: 2733 : pDoc->PutCell( rPos, pNewCell );
849 : :
850 : : // This "interpret once" block was moved from ScViewFunc::EnterData() where
851 : : // it was never executed from API, so don't do it here. For performance
852 : : // reasons API calls may disable calculation while operating and
853 : : // recalculate once when done.
854 [ + + ][ - + ]: 2733 : if ( !bXMLLoading && !bApi && pNewCell->GetCellType() == CELLTYPE_FORMULA && !pDoc->GetAutoCalc() )
[ # # ][ # # ]
[ - + ]
855 : : {
856 [ # # ]: 0 : ScFormulaCell *pFormCell = static_cast<ScFormulaCell *>( pNewCell );
857 : : // calculate just the cell once and set Dirty again
858 [ # # ]: 0 : pFormCell->Interpret();
859 [ # # ]: 0 : pFormCell->SetDirtyVar();
860 [ # # ]: 0 : pDoc->PutInFormulaTree( pFormCell );
861 : : }
862 : :
863 : : // wegen ChangeTracking darf UndoAction erst nach PutCell angelegt werden
864 [ + + ]: 2733 : if (bUndo)
865 [ + - ]: 2694 : rDocShell.GetUndoManager()->AddUndoAction(
866 [ + - ][ + - ]: 2694 : new ScUndoPutCell( &rDocShell, rPos, pUndoCell, pRedoCell, bHeight ) );
[ + - ]
867 : :
868 [ + + ]: 2733 : if (bHeight)
869 [ + - ]: 221 : AdjustRowHeight( ScRange(rPos) );
870 : :
871 [ + + ]: 2733 : if (!bXMLLoading)
872 [ + - ]: 2694 : rDocShell.PostPaintCell( rPos );
873 : :
874 [ + - ]: 2733 : aModificator.SetDocumentModified();
875 : :
876 : : // #i925#; it is not neccessary to notify on loading a XML document
877 : : // #103934#; notify editline and cell in edit mode
878 [ + - ][ + + ]: 2733 : if (bApi && !bXMLLoading)
879 [ + - ]: 2694 : NotifyInputHandler( rPos );
880 : :
881 [ + - ]: 2733 : return sal_True;
882 : : }
883 : :
884 : 2715 : void ScDocFunc::NotifyInputHandler( const ScAddress& rPos )
885 : : {
886 : 2715 : ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
887 [ + + ][ + + ]: 2715 : if ( pViewSh && pViewSh->GetViewData()->GetDocShell() == &rDocShell )
[ + + ]
888 : : {
889 : 2687 : ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
890 [ + + ][ + + ]: 2687 : if ( pInputHdl && pInputHdl->GetCursorPos() == rPos )
[ + - ]
891 : : {
892 : 79 : sal_Bool bIsEditMode(pInputHdl->IsEditMode());
893 : :
894 : : // set modified if in editmode, because so the string is not set in the InputWindow like in the cell
895 : : // (the cell shows the same like the InputWindow)
896 [ - + ]: 79 : if (bIsEditMode)
897 : 0 : pInputHdl->SetModified();
898 : 79 : pViewSh->UpdateInputHandler(false, !bIsEditMode);
899 : : }
900 : : }
901 : 2715 : }
902 : :
903 : 176 : struct ScMyRememberItem
904 : : {
905 : : sal_uInt16 nIndex;
906 : : SfxItemSet aItemSet;
907 : :
908 : 176 : ScMyRememberItem(const SfxItemSet& rItemSet, sal_uInt16 nTempIndex) :
909 : 176 : nIndex(nTempIndex), aItemSet(rItemSet) {}
910 : : };
911 : :
912 : : typedef ::std::list<ScMyRememberItem*> ScMyRememberItemList;
913 : :
914 : 262 : sal_Bool ScDocFunc::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, sal_Bool bInterpret, sal_Bool bApi )
915 : : {
916 : : // PutData ruft PutCell oder SetNormalString
917 : :
918 : 262 : sal_Bool bRet = false;
919 : 262 : ScDocument* pDoc = rDocShell.GetDocument();
920 [ + - ]: 262 : ScEditAttrTester aTester( &rEngine );
921 : 262 : sal_Bool bEditCell = aTester.NeedsObject();
922 [ + + ]: 262 : if ( bEditCell )
923 : : {
924 : : // #i61702# With bLoseContent set, the content of rEngine isn't restored
925 : : // (used in loading XML, where after the removeActionLock call the API obejct's
926 : : // EditEngine isn't accessed again.
927 : 200 : sal_Bool bLoseContent = pDoc->IsImportingXML();
928 : :
929 [ + - ]: 200 : sal_Bool bUpdateMode(rEngine.GetUpdateMode());
930 [ + + ]: 200 : if (bUpdateMode)
931 [ + - ]: 185 : rEngine.SetUpdateMode(false);
932 : :
933 [ + - ]: 200 : ScMyRememberItemList aRememberItems;
934 : 200 : ScMyRememberItem* pRememberItem = NULL;
935 : :
936 : : // All paragraph attributes must be removed before calling CreateTextObject,
937 : : // not only alignment, so the object doesn't contain the cell attributes as
938 : : // paragraph attributes. Before remove the attributes store they in a list to
939 : : // set they back to the EditEngine.
940 [ + - ]: 200 : sal_uInt16 nCount = rEngine.GetParagraphCount();
941 [ + + ]: 433 : for (sal_uInt16 i=0; i<nCount; i++)
942 : : {
943 [ + - ]: 233 : const SfxItemSet& rOld = rEngine.GetParaAttribs( i );
944 [ + + ]: 233 : if ( rOld.Count() )
945 : : {
946 [ + + ]: 215 : if ( !bLoseContent )
947 : : {
948 [ + - ][ + - ]: 176 : pRememberItem = new ScMyRememberItem(rEngine.GetParaAttribs(i), i);
[ + - ]
949 [ + - ]: 176 : aRememberItems.push_back(pRememberItem);
950 : : }
951 [ + - ][ + - ]: 215 : rEngine.SetParaAttribs( i, SfxItemSet( *rOld.GetPool(), rOld.GetRanges() ) );
[ + - ]
952 : : }
953 : : }
954 : :
955 [ + - ]: 200 : EditTextObject* pNewData = rEngine.CreateTextObject();
956 : : bRet = PutCell( rPos,
957 [ + - ]: 200 : new ScEditCell( pNewData, pDoc, rEngine.GetEditTextObjectPool() ),
958 [ + - ][ + - ]: 400 : bApi );
[ + - ]
959 [ + - ][ + - ]: 200 : delete pNewData;
960 : :
961 : : // Set the paragraph attributes back to the EditEngine.
962 [ + + ]: 200 : if (!aRememberItems.empty())
963 : : {
964 : : // ScMyRememberItem* pRememberItem = NULL;
965 : 173 : ScMyRememberItemList::iterator aItr = aRememberItems.begin();
966 [ + + ]: 349 : while (aItr != aRememberItems.end())
967 : : {
968 : 176 : pRememberItem = *aItr;
969 [ + - ]: 176 : rEngine.SetParaAttribs(pRememberItem->nIndex, pRememberItem->aItemSet);
970 [ + - ][ + - ]: 176 : delete pRememberItem;
971 [ + - ]: 176 : aItr = aRememberItems.erase(aItr);
972 : : }
973 : : }
974 : :
975 : : // #i61702# if the content isn't accessed, there's no need to set the UpdateMode again
976 [ + + ][ + + ]: 200 : if ( bUpdateMode && !bLoseContent )
977 [ + - ]: 200 : rEngine.SetUpdateMode(sal_True);
978 : : }
979 : : else
980 : : {
981 [ + - ]: 62 : String aText = rEngine.GetText();
982 [ + - ][ + + ]: 62 : if ( bInterpret || !aText.Len() )
[ + + ]
983 : : {
984 : 1 : bool bNumFmtSet = false;
985 [ + - ]: 1 : bRet = SetNormalString( bNumFmtSet, rPos, aText, bApi );
986 : : }
987 : : else
988 [ + - ][ + - ]: 62 : bRet = PutCell( rPos, new ScStringCell( aText ), bApi );
[ + - ][ + - ]
[ + - ]
989 : : }
990 : :
991 [ + - ][ + + ]: 262 : if ( bRet && aTester.NeedsCellAttr() )
[ + + ]
992 : : {
993 : 165 : const SfxItemSet& rEditAttr = aTester.GetAttribs();
994 [ + - ][ + - ]: 165 : ScPatternAttr aPattern( pDoc->GetPool() );
995 [ + - ]: 165 : aPattern.GetFromEditItemSet( &rEditAttr );
996 [ + - ][ + - ]: 165 : aPattern.DeleteUnchanged( pDoc->GetPattern( rPos.Col(), rPos.Row(), rPos.Tab() ) );
997 [ + - ]: 165 : aPattern.GetItemSet().ClearItem( ATTR_HOR_JUSTIFY ); // wasn't removed above if no edit object
998 [ + + ]: 165 : if ( aPattern.GetItemSet().Count() > 0 )
999 : : {
1000 [ + - ]: 113 : ScMarkData aMark;
1001 [ + - ]: 113 : aMark.SelectTable( rPos.Tab(), sal_True );
1002 [ + - ]: 113 : aMark.SetMarkArea( ScRange( rPos ) );
1003 [ + - ][ + - ]: 113 : ApplyAttributes( aMark, aPattern, sal_True, bApi );
1004 [ + - ]: 165 : }
1005 : : }
1006 : :
1007 [ + - ]: 262 : return bRet;
1008 : : }
1009 : :
1010 : :
1011 : 0 : ScTokenArray* lcl_ScDocFunc_CreateTokenArrayXML( const String& rText, const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar )
1012 : : {
1013 [ # # ]: 0 : ScTokenArray* pCode = new ScTokenArray;
1014 : 0 : pCode->AddStringXML( rText );
1015 [ # # ][ # # ]: 0 : if( (eGrammar == formula::FormulaGrammar::GRAM_EXTERNAL) && (rFormulaNmsp.Len() > 0) )
[ # # ]
1016 : 0 : pCode->AddStringXML( rFormulaNmsp );
1017 : 0 : return pCode;
1018 : : }
1019 : :
1020 : :
1021 : 1009 : ScBaseCell* ScDocFunc::InterpretEnglishString( const ScAddress& rPos,
1022 : : const String& rText, const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar, short* pRetFormatType )
1023 : : {
1024 : 1009 : ScDocument* pDoc = rDocShell.GetDocument();
1025 : 1009 : ScBaseCell* pNewCell = NULL;
1026 : :
1027 [ + + ][ + + ]: 1009 : if ( rText.Len() > 1 && rText.GetChar(0) == '=' )
[ + + ]
1028 : : {
1029 : : ScTokenArray* pCode;
1030 [ - + ]: 68 : if ( pDoc->IsImportingXML() )
1031 : : { // temporary formula string as string tokens
1032 : 0 : pCode = lcl_ScDocFunc_CreateTokenArrayXML( rText, rFormulaNmsp, eGrammar );
1033 : 0 : pDoc->IncXMLImportedFormulaCount( rText.Len() );
1034 : : }
1035 : : else
1036 : : {
1037 [ + - ]: 68 : ScCompiler aComp( pDoc, rPos );
1038 [ + - ]: 68 : aComp.SetGrammar(eGrammar);
1039 [ + - ][ + - ]: 68 : pCode = aComp.CompileString( rText );
1040 : : }
1041 [ + - ][ + - ]: 68 : pNewCell = new ScFormulaCell( pDoc, rPos, pCode, eGrammar, MM_NONE );
1042 [ + - ]: 68 : delete pCode; // Zell-ctor hat das TokenArray kopiert
1043 : : }
1044 [ + + ][ - + ]: 941 : else if ( rText.Len() > 1 && rText.GetChar(0) == '\'' )
[ - + ]
1045 : : {
1046 : : // for bEnglish, "'" at the beginning is always interpreted as text
1047 : : // marker and stripped
1048 [ # # ][ # # ]: 0 : pNewCell = ScBaseCell::CreateTextCell( rText.Copy( 1 ), pDoc );
1049 : : }
1050 : : else // (nur) auf englisches Zahlformat testen
1051 : : {
1052 [ + - ]: 941 : SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
1053 [ + - ]: 941 : sal_uInt32 nEnglish = pFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US);
1054 : : double fVal;
1055 [ + - ][ + + ]: 941 : if ( pFormatter->IsNumberFormat( rText, nEnglish, fVal ) )
1056 : : {
1057 [ + - ][ + - ]: 2 : pNewCell = new ScValueCell( fVal );
1058 : : // return the format type from the English format, so a localized format can be created
1059 [ - + ]: 2 : if ( pRetFormatType )
1060 [ # # ]: 0 : *pRetFormatType = pFormatter->GetType( nEnglish );
1061 : : }
1062 [ + + ]: 939 : else if ( rText.Len() )
1063 [ + - ][ + - ]: 941 : pNewCell = ScBaseCell::CreateTextCell( rText, pDoc );
1064 : :
1065 : : // das (englische) Zahlformat wird nicht gesetzt
1066 : : //! passendes lokales Format suchen und setzen???
1067 : : }
1068 : :
1069 : 1009 : return pNewCell;
1070 : : }
1071 : :
1072 : :
1073 : 971 : sal_Bool ScDocFunc::SetCellText( const ScAddress& rPos, const String& rText,
1074 : : sal_Bool bInterpret, sal_Bool bEnglish, sal_Bool bApi,
1075 : : const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar )
1076 : : {
1077 : : // SetCellText ruft PutCell oder SetNormalString
1078 : :
1079 : 971 : ScDocument* pDoc = rDocShell.GetDocument();
1080 : 971 : ScBaseCell* pNewCell = NULL;
1081 [ + + ]: 971 : if ( bInterpret )
1082 : : {
1083 [ + + ]: 937 : if ( bEnglish )
1084 : : {
1085 : 935 : ::boost::scoped_ptr<ScExternalRefManager::ApiGuard> pExtRefGuard;
1086 [ + - ]: 935 : if (bApi)
1087 [ + - ][ + - ]: 935 : pExtRefGuard.reset(new ScExternalRefManager::ApiGuard(pDoc));
[ + - ]
1088 : :
1089 : : // code moved to own method InterpretEnglishString because it is also used in
1090 : : // ScCellRangeObj::setFormulaArray
1091 : :
1092 [ + - ][ + - ]: 935 : pNewCell = InterpretEnglishString( rPos, rText, rFormulaNmsp, eGrammar );
1093 : : }
1094 : : // sonst Null behalten -> SetString mit lokalen Formeln/Zahlformat
1095 : : }
1096 [ + + ]: 34 : else if ( rText.Len() )
1097 : : {
1098 : : OSL_ENSURE( rFormulaNmsp.Len() == 0, "ScDocFunc::SetCellText - formula namespace, but do not interpret?" );
1099 [ + - ]: 18 : pNewCell = ScBaseCell::CreateTextCell( rText, pDoc ); // immer Text
1100 : : }
1101 : :
1102 [ + + ]: 971 : if (pNewCell)
1103 : 951 : return PutCell( rPos, pNewCell, bApi );
1104 : : else
1105 : : {
1106 : 20 : bool bNumFmtSet = false;
1107 [ + - ]: 971 : return SetNormalString( bNumFmtSet, rPos, rText, bApi );
1108 : : }
1109 : : }
1110 : :
1111 : : //------------------------------------------------------------------------
1112 : :
1113 : 3 : bool ScDocFunc::ShowNote( const ScAddress& rPos, bool bShow )
1114 : : {
1115 : 3 : ScDocument& rDoc = *rDocShell.GetDocument();
1116 : 3 : ScPostIt* pNote = rDoc.GetNotes( rPos.Tab() )->findByAddress( rPos );
1117 [ + - ][ + - ]: 3 : if( !pNote || (bShow == pNote->IsCaptionShown()) ) return false;
[ + - ]
1118 : :
1119 : : // move the caption to internal or hidden layer and create undo action
1120 : 0 : pNote->ShowCaption( rPos, bShow );
1121 [ # # ]: 0 : if( rDoc.IsUndoEnabled() )
1122 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction( new ScUndoShowHideNote( rDocShell, rPos, bShow ) );
1123 : :
1124 [ # # ]: 0 : if (rDoc.IsStreamValid(rPos.Tab()))
1125 : 0 : rDoc.SetStreamValid(rPos.Tab(), false);
1126 : :
1127 : 0 : rDocShell.SetDocumentModified();
1128 : :
1129 : 3 : return true;
1130 : : }
1131 : :
1132 : : //------------------------------------------------------------------------
1133 : :
1134 : 0 : bool ScDocFunc::SetNoteText( const ScAddress& rPos, const String& rText, sal_Bool bApi )
1135 : : {
1136 [ # # ]: 0 : ScDocShellModificator aModificator( rDocShell );
1137 : :
1138 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
1139 [ # # ]: 0 : ScEditableTester aTester( pDoc, rPos.Tab(), rPos.Col(),rPos.Row(), rPos.Col(),rPos.Row() );
1140 [ # # ]: 0 : if (!aTester.IsEditable())
1141 : : {
1142 [ # # ]: 0 : if (!bApi)
1143 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
1144 : 0 : return false;
1145 : : }
1146 : :
1147 [ # # ][ # # ]: 0 : String aNewText = convertLineEnd(rText, GetSystemLineEnd()); //! ist das noetig ???
[ # # ]
1148 : :
1149 [ # # ][ # # ]: 0 : if( ScPostIt* pNote = (aNewText.Len() > 0) ? pDoc->GetNotes(rPos.Tab())->GetOrCreateNote( rPos ) : pDoc->GetNotes( rPos.Tab() )->findByAddress(rPos) )
[ # # ][ # # ]
[ # # ][ # # ]
1150 [ # # ][ # # ]: 0 : pNote->SetText( rPos, aNewText );
1151 : :
1152 : : //! Undo !!!
1153 : :
1154 [ # # ][ # # ]: 0 : if (pDoc->IsStreamValid(rPos.Tab()))
1155 [ # # ]: 0 : pDoc->SetStreamValid(rPos.Tab(), false);
1156 : :
1157 [ # # ]: 0 : rDocShell.PostPaintCell( rPos );
1158 [ # # ]: 0 : aModificator.SetDocumentModified();
1159 : :
1160 [ # # ][ # # ]: 0 : return true;
1161 : : }
1162 : :
1163 : : //------------------------------------------------------------------------
1164 : :
1165 : 5 : bool ScDocFunc::ReplaceNote( const ScAddress& rPos, const String& rNoteText, const String* pAuthor, const String* pDate, sal_Bool bApi )
1166 : : {
1167 : 5 : bool bDone = false;
1168 : :
1169 [ + - ]: 5 : ScDocShellModificator aModificator( rDocShell );
1170 : 5 : ScDocument& rDoc = *rDocShell.GetDocument();
1171 [ + - ]: 5 : ScEditableTester aTester( &rDoc, rPos.Tab(), rPos.Col(),rPos.Row(), rPos.Col(),rPos.Row() );
1172 [ + - ]: 5 : if (aTester.IsEditable())
1173 : : {
1174 [ + - ]: 5 : ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
1175 [ + - ][ + + ]: 5 : ::svl::IUndoManager* pUndoMgr = (pDrawLayer && rDoc.IsUndoEnabled()) ? rDocShell.GetUndoManager() : 0;
[ + - ]
1176 : :
1177 [ + - ]: 5 : ScNoteData aOldData;
1178 [ + - ][ + - ]: 5 : ScPostIt* pOldNote = rDoc.GetNotes(rPos.Tab())->ReleaseNote( rPos );
1179 [ - + ]: 5 : if( pOldNote )
1180 : : {
1181 : : // ensure existing caption object before draw undo tracking starts
1182 [ # # ]: 0 : pOldNote->GetOrCreateCaption( rPos );
1183 : : // rescue note data for undo
1184 [ # # ]: 0 : aOldData = pOldNote->GetNoteData();
1185 : : }
1186 : :
1187 : : // collect drawing undo actions for deleting/inserting caption obejcts
1188 [ + + ]: 5 : if( pUndoMgr )
1189 [ + - ]: 2 : pDrawLayer->BeginCalcUndo();
1190 : :
1191 : : // delete the note (creates drawing undo action for the caption object)
1192 [ - + ][ # # ]: 5 : delete pOldNote;
1193 : :
1194 : : // create new note (creates drawing undo action for the new caption object)
1195 [ + - ]: 5 : ScNoteData aNewData;
1196 [ + - ][ + - ]: 5 : if( ScPostIt* pNewNote = ScNoteUtil::CreateNoteFromString( rDoc, rPos, rNoteText, false, true ) )
[ + - ]
1197 : : {
1198 [ - + ][ # # ]: 5 : if( pAuthor ) pNewNote->SetAuthor( *pAuthor );
1199 [ - + ][ # # ]: 5 : if( pDate ) pNewNote->SetDate( *pDate );
1200 : : // rescue note data for undo
1201 [ + - ]: 5 : aNewData = pNewNote->GetNoteData();
1202 : : }
1203 : :
1204 : : // create the undo action
1205 [ + + ][ + - ]: 5 : if( pUndoMgr && (aOldData.mpCaption || aNewData.mpCaption) )
[ + - ]
1206 [ + - ][ + - ]: 2 : pUndoMgr->AddUndoAction( new ScUndoReplaceNote( rDocShell, rPos, aOldData, aNewData, pDrawLayer->GetCalcUndo() ) );
[ + - ][ + - ]
1207 : :
1208 : : // repaint cell (to make note marker visible)
1209 [ + - ]: 5 : rDocShell.PostPaintCell( rPos );
1210 : :
1211 [ + - ][ - + ]: 5 : if (rDoc.IsStreamValid(rPos.Tab()))
1212 [ # # ]: 0 : rDoc.SetStreamValid(rPos.Tab(), false);
1213 : :
1214 [ + - ]: 5 : aModificator.SetDocumentModified();
1215 [ + - ][ + - ]: 5 : bDone = true;
1216 : : }
1217 [ # # ]: 0 : else if (!bApi)
1218 : : {
1219 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
1220 : : }
1221 : :
1222 [ + - ]: 5 : return bDone;
1223 : : }
1224 : :
1225 : : //------------------------------------------------------------------------
1226 : :
1227 : 1052 : sal_Bool ScDocFunc::ApplyAttributes( const ScMarkData& rMark, const ScPatternAttr& rPattern,
1228 : : sal_Bool bRecord, sal_Bool bApi )
1229 : : {
1230 : 1052 : ScDocument* pDoc = rDocShell.GetDocument();
1231 [ + + ][ + + ]: 1052 : if ( bRecord && !pDoc->IsUndoEnabled() )
[ + - ]
1232 : 446 : bRecord = false;
1233 : :
1234 : 1052 : bool bImportingXML = pDoc->IsImportingXML();
1235 : : // Cell formats can still be set if the range isn't editable only because of matrix formulas.
1236 : : // #i62483# When loading XML, the check can be skipped altogether.
1237 : : bool bOnlyNotBecauseOfMatrix;
1238 [ + - ][ - + ]: 1052 : if ( !bImportingXML && !pDoc->IsSelectionEditable( rMark, &bOnlyNotBecauseOfMatrix )
[ # # ][ - + ]
[ + + ]
1239 : 0 : && !bOnlyNotBecauseOfMatrix )
1240 : : {
1241 [ # # ]: 0 : if (!bApi)
1242 [ # # ]: 0 : rDocShell.ErrorMessage(STR_PROTECTIONERR);
1243 : 0 : return false;
1244 : : }
1245 : :
1246 [ + - ]: 1052 : ScDocShellModificator aModificator( rDocShell );
1247 : :
1248 : : //! Umrandung
1249 : :
1250 : 1052 : ScRange aMultiRange;
1251 : 1052 : sal_Bool bMulti = rMark.IsMultiMarked();
1252 [ + + ]: 1052 : if ( bMulti )
1253 [ + - ]: 81 : rMark.GetMultiMarkArea( aMultiRange );
1254 : : else
1255 [ + - ]: 971 : rMark.GetMarkArea( aMultiRange );
1256 : :
1257 [ + + ]: 1052 : if ( bRecord )
1258 : : {
1259 [ + - ][ + - ]: 606 : ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1260 [ + - ]: 606 : pUndoDoc->InitUndo( pDoc, aMultiRange.aStart.Tab(), aMultiRange.aEnd.Tab() );
1261 [ + - ]: 606 : pDoc->CopyToDocument( aMultiRange, IDF_ATTRIB, bMulti, pUndoDoc, &rMark );
1262 : :
1263 [ + - ]: 606 : rDocShell.GetUndoManager()->AddUndoAction(
1264 : : new ScUndoSelectionAttr(
1265 : : &rDocShell, rMark,
1266 : 1212 : aMultiRange.aStart.Col(), aMultiRange.aStart.Row(), aMultiRange.aStart.Tab(),
1267 : 1212 : aMultiRange.aEnd.Col(), aMultiRange.aEnd.Row(), aMultiRange.aEnd.Tab(),
1268 [ + - ][ + - ]: 1818 : pUndoDoc, bMulti, &rPattern ) );
[ + - ]
1269 : : }
1270 : :
1271 : : // While loading XML it is not neccessary to ask HasAttrib. It needs too much time.
1272 : 1052 : sal_uInt16 nExtFlags = 0;
1273 [ + + ]: 1052 : if ( !bImportingXML )
1274 [ + - ]: 666 : rDocShell.UpdatePaintExt( nExtFlags, aMultiRange ); // content before the change
1275 [ + - ]: 1052 : pDoc->ApplySelectionPattern( rPattern, rMark );
1276 [ + + ]: 1052 : if ( !bImportingXML )
1277 [ + - ]: 666 : rDocShell.UpdatePaintExt( nExtFlags, aMultiRange ); // content after the change
1278 : :
1279 [ + - ][ + + ]: 1052 : if (!AdjustRowHeight( aMultiRange ))
1280 [ + - ][ + - ]: 1003 : rDocShell.PostPaint( aMultiRange, PAINT_GRID, nExtFlags );
[ + - ]
1281 [ + + ]: 49 : else if (nExtFlags & SC_PF_LINES)
1282 [ + - ]: 39 : lcl_PaintAbove( rDocShell, aMultiRange ); // fuer Linien ueber dem Bereich
1283 : :
1284 [ + - ]: 1052 : aModificator.SetDocumentModified();
1285 : :
1286 [ + - ]: 1052 : return sal_True;
1287 : : }
1288 : :
1289 : :
1290 : 813 : sal_Bool ScDocFunc::ApplyStyle( const ScMarkData& rMark, const String& rStyleName,
1291 : : sal_Bool bRecord, sal_Bool bApi )
1292 : : {
1293 : 813 : ScDocument* pDoc = rDocShell.GetDocument();
1294 [ + + ][ + + ]: 813 : if ( bRecord && !pDoc->IsUndoEnabled() )
[ + - ]
1295 : 808 : bRecord = false;
1296 : :
1297 : 813 : bool bImportingXML = pDoc->IsImportingXML();
1298 : : // Cell formats can still be set if the range isn't editable only because of matrix formulas.
1299 : : // #i62483# When loading XML, the check can be skipped altogether.
1300 : : bool bOnlyNotBecauseOfMatrix;
1301 [ + - ][ - + ]: 813 : if ( !bImportingXML && !pDoc->IsSelectionEditable( rMark, &bOnlyNotBecauseOfMatrix )
[ # # ][ - + ]
[ + + ]
1302 : 0 : && !bOnlyNotBecauseOfMatrix )
1303 : : {
1304 [ # # ]: 0 : if (!bApi)
1305 [ # # ]: 0 : rDocShell.ErrorMessage(STR_PROTECTIONERR);
1306 : 0 : return false;
1307 : : }
1308 : :
1309 [ + - ]: 813 : ScStyleSheet* pStyleSheet = (ScStyleSheet*) pDoc->GetStyleSheetPool()->Find(
1310 [ + - ]: 813 : rStyleName, SFX_STYLE_FAMILY_PARA );
1311 [ + + ]: 813 : if (!pStyleSheet)
1312 : 125 : return false;
1313 : :
1314 [ + - ]: 688 : ScDocShellModificator aModificator( rDocShell );
1315 : :
1316 : 688 : ScRange aMultiRange;
1317 : 688 : sal_Bool bMulti = rMark.IsMultiMarked();
1318 [ + + ]: 688 : if ( bMulti )
1319 [ + - ]: 196 : rMark.GetMultiMarkArea( aMultiRange );
1320 : : else
1321 [ + - ]: 492 : rMark.GetMarkArea( aMultiRange );
1322 : :
1323 [ - + ]: 688 : if ( bRecord )
1324 : : {
1325 [ # # ][ # # ]: 0 : ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1326 : 0 : SCTAB nStartTab = aMultiRange.aStart.Tab();
1327 [ # # ]: 0 : SCTAB nTabCount = pDoc->GetTableCount();
1328 [ # # ]: 0 : pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab );
1329 [ # # ][ # # ]: 0 : ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
1330 [ # # ][ # # ]: 0 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ # # ][ # # ]
[ # # ][ # # ]
1331 [ # # ][ # # ]: 0 : if (*itr != nStartTab)
1332 [ # # ][ # # ]: 0 : pUndoDoc->AddUndoTab( *itr, *itr );
[ # # ]
1333 : :
1334 : 0 : ScRange aCopyRange = aMultiRange;
1335 : 0 : aCopyRange.aStart.SetTab(0);
1336 : 0 : aCopyRange.aEnd.SetTab(nTabCount-1);
1337 [ # # ]: 0 : pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, bMulti, pUndoDoc, &rMark );
1338 : :
1339 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
1340 : : new ScUndoSelectionStyle(
1341 [ # # ][ # # ]: 0 : &rDocShell, rMark, aMultiRange, rStyleName, pUndoDoc ) );
[ # # ]
1342 : :
1343 : : }
1344 : :
1345 [ + - ]: 688 : pDoc->ApplySelectionStyle( (ScStyleSheet&)*pStyleSheet, rMark );
1346 : :
1347 : 688 : sal_uInt16 nExtFlags = 0;
1348 [ + - ][ + - ]: 688 : if (!AdjustRowHeight( aMultiRange ))
1349 [ + - ][ + - ]: 688 : rDocShell.PostPaint( aMultiRange, PAINT_GRID, nExtFlags );
[ + - ]
1350 [ # # ]: 0 : else if (nExtFlags & SC_PF_LINES)
1351 [ # # ]: 0 : lcl_PaintAbove( rDocShell, aMultiRange ); // fuer Linien ueber dem Bereich
1352 : :
1353 [ + - ]: 688 : aModificator.SetDocumentModified();
1354 : :
1355 [ + - ]: 813 : return sal_True;
1356 : : }
1357 : :
1358 : : //------------------------------------------------------------------------
1359 : :
1360 : 7 : sal_Bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark, InsCellCmd eCmd,
1361 : : sal_Bool bRecord, sal_Bool bApi, sal_Bool bPartOfPaste )
1362 : : {
1363 [ + - ]: 7 : ScDocShellModificator aModificator( rDocShell );
1364 : :
1365 : 7 : SCCOL nStartCol = rRange.aStart.Col();
1366 : 7 : SCROW nStartRow = rRange.aStart.Row();
1367 : 7 : SCTAB nStartTab = rRange.aStart.Tab();
1368 : 7 : SCCOL nEndCol = rRange.aEnd.Col();
1369 : 7 : SCROW nEndRow = rRange.aEnd.Row();
1370 : 7 : SCTAB nEndTab = rRange.aEnd.Tab();
1371 : :
1372 [ - + ][ - + ]: 7 : if ( !ValidRow(nStartRow) || !ValidRow(nEndRow) )
[ + - ]
1373 : : {
1374 : : OSL_FAIL("invalid row in InsertCells");
1375 : 0 : return false;
1376 : : }
1377 : :
1378 : 7 : ScDocument* pDoc = rDocShell.GetDocument();
1379 [ + - ]: 7 : SCTAB nTabCount = pDoc->GetTableCount();
1380 : 7 : SCCOL nPaintStartX = nStartCol;
1381 : 7 : SCROW nPaintStartY = nStartRow;
1382 : 7 : SCCOL nPaintEndX = nEndCol;
1383 : 7 : SCROW nPaintEndY = nEndRow;
1384 : 7 : sal_uInt16 nPaintFlags = PAINT_GRID;
1385 : : sal_Bool bSuccess;
1386 : : SCTAB i;
1387 : :
1388 [ + - ]: 7 : ScTabViewShell* pViewSh = rDocShell.GetBestViewShell(); //preserve current cursor position
1389 : 7 : SCCOL nCursorCol = 0;
1390 : 7 : SCROW nCursorRow = 0;
1391 [ + + ]: 7 : if( pViewSh )
1392 : : {
1393 : 4 : nCursorCol = pViewSh->GetViewData()->GetCurX();
1394 : 4 : nCursorRow = pViewSh->GetViewData()->GetCurY();
1395 : : }
1396 : :
1397 [ + - ][ - + ]: 7 : if (bRecord && !pDoc->IsUndoEnabled())
[ - + ]
1398 : 0 : bRecord = false;
1399 : :
1400 [ + - ]: 7 : ScMarkData aMark;
1401 [ + + ]: 7 : if (pTabMark)
1402 [ + - ]: 3 : aMark = *pTabMark;
1403 : : else
1404 : : {
1405 : 4 : SCTAB nCount = 0;
1406 [ + - ]: 4 : for( i=0; i<nTabCount; i++ )
1407 : : {
1408 [ + - ][ + - ]: 4 : if( !pDoc->IsScenario(i) )
1409 : : {
1410 : 4 : nCount++;
1411 [ + - ]: 4 : if( nCount == nEndTab+1 )
1412 : : {
1413 [ + - ]: 4 : aMark.SelectTable( i, sal_True );
1414 : 4 : break;
1415 : : }
1416 : : }
1417 : : }
1418 : : }
1419 : :
1420 [ + - ]: 7 : ScMarkData aFullMark( aMark ); // including scenario sheets
1421 [ + - ][ + - ]: 7 : ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
1422 [ + - ][ + - ]: 14 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ + + ][ + - ]
[ + - ][ + + ]
1423 [ + - ][ - + ]: 7 : for( SCTAB j = *itr+1; j<nTabCount && pDoc->IsScenario(j); j++ )
[ # # ][ # # ]
[ - + ]
1424 [ # # ]: 0 : aFullMark.SelectTable( j, true );
1425 : :
1426 [ + - ]: 7 : SCTAB nSelCount = aMark.GetSelectCount();
1427 : :
1428 : : // zugehoerige Szenarien auch anpassen
1429 : : // Test zusammengefasste
1430 : :
1431 : 7 : SCCOL nMergeTestStartX = nStartCol;
1432 : 7 : SCROW nMergeTestStartY = nStartRow;
1433 : 7 : SCCOL nMergeTestEndX = nEndCol;
1434 : 7 : SCROW nMergeTestEndY = nEndRow;
1435 : :
1436 : 7 : ScRange aExtendMergeRange( rRange );
1437 : :
1438 [ # # ][ # # ]: 7 : if( rRange.aStart == rRange.aEnd && pDoc->HasAttrib(rRange, HASATTR_MERGED) )
[ - + ][ - + ]
1439 : : {
1440 [ # # ]: 0 : pDoc->ExtendMerge( aExtendMergeRange );
1441 [ # # ]: 0 : pDoc->ExtendOverlapped( aExtendMergeRange );
1442 : 0 : nMergeTestEndX = aExtendMergeRange.aEnd.Col();
1443 : 0 : nMergeTestEndY = aExtendMergeRange.aEnd.Row();
1444 : 0 : nPaintEndX = nMergeTestEndX;
1445 : 0 : nPaintEndY = nMergeTestEndY;
1446 : : }
1447 : :
1448 [ + + ]: 7 : if ( eCmd == INS_INSROWS )
1449 : : {
1450 : 4 : nMergeTestStartX = 0;
1451 : 4 : nMergeTestEndX = MAXCOL;
1452 : : }
1453 [ + + ]: 7 : if ( eCmd == INS_INSCOLS )
1454 : : {
1455 : 3 : nMergeTestStartY = 0;
1456 : 3 : nMergeTestEndY = MAXROW;
1457 : : }
1458 [ - + ]: 7 : if ( eCmd == INS_CELLSDOWN )
1459 : 0 : nMergeTestEndY = MAXROW;
1460 [ - + ]: 7 : if ( eCmd == INS_CELLSRIGHT )
1461 : 0 : nMergeTestEndX = MAXCOL;
1462 : :
1463 : 7 : sal_Bool bNeedRefresh = false;
1464 : :
1465 [ + + ]: 7 : SCCOL nEditTestEndX = (eCmd==INS_INSCOLS) ? MAXCOL : nMergeTestEndX;
1466 [ + + ]: 7 : SCROW nEditTestEndY = (eCmd==INS_INSROWS) ? MAXROW : nMergeTestEndY;
1467 [ + - ]: 7 : ScEditableTester aTester( pDoc, nMergeTestStartX, nMergeTestStartY, nEditTestEndX, nEditTestEndY, aMark );
1468 [ - + ]: 7 : if (!aTester.IsEditable())
1469 : : {
1470 [ # # ]: 0 : if (!bApi)
1471 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
1472 : 0 : return false;
1473 : : }
1474 : :
1475 [ + - ][ + - ]: 7 : WaitObject aWait( rDocShell.GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference
1476 : :
1477 : 7 : ScDocument* pRefUndoDoc = NULL;
1478 : 7 : ScRefUndoData* pUndoData = NULL;
1479 [ + - ]: 7 : if ( bRecord )
1480 : : {
1481 [ + - ][ + - ]: 7 : pRefUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1482 [ + - ]: 7 : pRefUndoDoc->InitUndo( pDoc, 0, nTabCount-1, false, false );
1483 : :
1484 : : // pRefUndoDoc is filled in InsertCol / InsertRow
1485 : :
1486 [ + - ][ + - ]: 7 : pUndoData = new ScRefUndoData( pDoc );
1487 : :
1488 [ + - ]: 7 : pDoc->BeginDrawUndo();
1489 : : }
1490 : :
1491 : : // #i8302 : we unmerge overwhelming ranges, before insertion all the actions are put in the same ListAction
1492 : : // the patch comes from mloiseleur and maoyg
1493 : 7 : sal_Bool bInsertMerge = false;
1494 [ + - ]: 7 : std::vector<ScRange> qIncreaseRange;
1495 [ + - ][ + - ]: 7 : String aUndo = ScGlobal::GetRscString( STR_UNDO_INSERTCELLS );
1496 [ + - ]: 7 : if (bRecord)
1497 [ + - ][ + - ]: 7 : rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo );
1498 : :
1499 [ + - ]: 7 : itr = aMark.begin();
1500 [ + - ][ + - ]: 14 : for (; itr != itrEnd && nTabCount; ++itr)
[ + + ][ + - ]
[ + + ]
1501 : : {
1502 [ + - ]: 7 : i = *itr;
1503 [ + - ][ + + ]: 7 : if( pDoc->HasAttrib( nMergeTestStartX, nMergeTestStartY, i, nMergeTestEndX, nMergeTestEndY, i, HASATTR_MERGED | HASATTR_OVERLAPPED ) )
1504 : : {
1505 [ - + ]: 3 : if (eCmd==INS_CELLSRIGHT)
1506 : 0 : bNeedRefresh = sal_True;
1507 : :
1508 : 3 : SCCOL nMergeStartX = nMergeTestStartX;
1509 : 3 : SCROW nMergeStartY = nMergeTestStartY;
1510 : 3 : SCCOL nMergeEndX = nMergeTestEndX;
1511 : 3 : SCROW nMergeEndY = nMergeTestEndY;
1512 : :
1513 [ + - ]: 3 : pDoc->ExtendMerge( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, i );
1514 [ + - ]: 3 : pDoc->ExtendOverlapped( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, i );
1515 : :
1516 [ - + ][ # # ]: 3 : if(( eCmd == INS_CELLSDOWN && ( nMergeStartX != nMergeTestStartX || nMergeEndX != nMergeTestEndX )) ||
[ # # ][ - + ]
[ # # ][ # # ]
1517 : : (eCmd == INS_CELLSRIGHT && ( nMergeStartY != nMergeTestStartY || nMergeEndY != nMergeTestEndY )) )
1518 : : {
1519 [ # # ]: 0 : if (!bApi)
1520 [ # # ]: 0 : rDocShell.ErrorMessage(STR_MSSG_INSERTCELLS_0);
1521 [ # # ][ # # ]: 0 : rDocShell.GetUndoManager()->LeaveListAction();
1522 : 0 : return false;
1523 : : }
1524 : :
1525 : 3 : SCCOL nTestCol = -1;
1526 : 3 : SCROW nTestRow1 = -1;
1527 : 3 : SCROW nTestRow2 = -1;
1528 : :
1529 [ + - ]: 3 : ScDocAttrIterator aTestIter( pDoc, i, nMergeTestStartX, nMergeTestStartY, nMergeTestEndX, nMergeTestEndY );
1530 : 3 : ScRange aExtendRange( nMergeTestStartX, nMergeTestStartY, i, nMergeTestEndX, nMergeTestEndY, i );
1531 : 3 : const ScPatternAttr* pPattern = NULL;
1532 : 3 : const ScMergeAttr* pMergeFlag = NULL;
1533 : 3 : const ScMergeFlagAttr* pMergeFlagAttr = NULL;
1534 [ + - ][ + + ]: 3075 : while ( ( pPattern = aTestIter.GetNext( nTestCol, nTestRow1, nTestRow2 ) ) != NULL )
1535 : : {
1536 [ + - ]: 3072 : pMergeFlag = (const ScMergeAttr*) &pPattern->GetItem(ATTR_MERGE);
1537 [ + - ]: 3072 : pMergeFlagAttr = (const ScMergeFlagAttr*) &pPattern->GetItem(ATTR_MERGE_FLAG);
1538 : 3072 : sal_Int16 nNewFlags = pMergeFlagAttr->GetValue() & ( SC_MF_HOR | SC_MF_VER );
1539 [ + - ][ + - ]: 3072 : if( ( pMergeFlag && pMergeFlag->IsMerged() ) || nNewFlags == SC_MF_HOR || nNewFlags == SC_MF_VER )
[ + + ][ + + ]
[ + - ]
1540 : : {
1541 : 3 : ScRange aRange( nTestCol, nTestRow1, i );
1542 [ + - ]: 3 : pDoc->ExtendOverlapped(aRange);
1543 [ + - ]: 3 : pDoc->ExtendMerge(aRange, sal_True);
1544 : :
1545 [ - + ][ # # ]: 3 : if( nTestRow1 < nTestRow2 && nNewFlags == SC_MF_HOR )
1546 : : {
1547 [ # # ]: 0 : for( SCROW nTestRow = nTestRow1; nTestRow <= nTestRow2; nTestRow++ )
1548 : : {
1549 : 0 : ScRange aTestRange( nTestCol, nTestRow, i );
1550 [ # # ]: 0 : pDoc->ExtendOverlapped( aTestRange );
1551 [ # # ]: 0 : pDoc->ExtendMerge( aTestRange, sal_True);
1552 : 0 : ScRange aMergeRange( aTestRange.aStart.Col(),aTestRange.aStart.Row(), i );
1553 [ # # ]: 0 : if( !aExtendRange.In( aMergeRange ) )
1554 : : {
1555 [ # # ]: 0 : qIncreaseRange.push_back( aTestRange );
1556 : 0 : bInsertMerge = sal_True;
1557 : : }
1558 : 0 : }
1559 : : }
1560 : : else
1561 : : {
1562 : 3 : ScRange aMergeRange( aRange.aStart.Col(),aRange.aStart.Row(), i );
1563 [ + - ]: 3 : if( !aExtendRange.In( aMergeRange ) )
1564 : : {
1565 [ + - ]: 3 : qIncreaseRange.push_back( aRange );
1566 : : }
1567 : 3 : bInsertMerge = sal_True;
1568 : : }
1569 : : }
1570 : : }
1571 : :
1572 [ + - ]: 3 : if( bInsertMerge )
1573 : : {
1574 [ - + ][ # # ]: 3 : if( eCmd == INS_INSROWS || eCmd == INS_CELLSDOWN )
1575 : : {
1576 : 3 : nStartRow = aExtendMergeRange.aStart.Row();
1577 : 3 : nEndRow = aExtendMergeRange.aEnd.Row();
1578 : :
1579 [ - + ]: 6 : if( eCmd == INS_CELLSDOWN )
1580 : 0 : nEndCol = nMergeTestEndX;
1581 : : else
1582 : : {
1583 : 3 : nStartCol = 0;
1584 : 3 : nEndCol = MAXCOL;
1585 : : }
1586 : : }
1587 [ # # ][ # # ]: 0 : else if( eCmd == INS_CELLSRIGHT || eCmd == INS_INSCOLS )
1588 : : {
1589 : :
1590 : 0 : nStartCol = aExtendMergeRange.aStart.Col();
1591 : 0 : nEndCol = aExtendMergeRange.aEnd.Col();
1592 [ # # ]: 0 : if( eCmd == INS_CELLSRIGHT )
1593 : : {
1594 : 0 : nEndRow = nMergeTestEndY;
1595 : : }
1596 : : else
1597 : : {
1598 : 0 : nStartRow = 0;
1599 : 0 : nEndRow = MAXROW;
1600 : : }
1601 : : }
1602 : :
1603 [ + - ]: 3 : if( !qIncreaseRange.empty() )
1604 : : {
1605 [ + - ][ + - ]: 6 : for( ::std::vector<ScRange>::const_iterator iIter( qIncreaseRange.begin()); iIter != qIncreaseRange.end(); ++iIter )
[ + + ]
1606 : : {
1607 : 3 : ScRange aRange( *iIter );
1608 [ + - ][ + - ]: 3 : if( pDoc->HasAttrib( aRange, HASATTR_OVERLAPPED | HASATTR_MERGED ) )
1609 : : {
1610 [ + - ]: 3 : UnmergeCells( aRange, sal_True );
1611 : : }
1612 : : }
1613 : : }
1614 : : }
1615 : : else
1616 : : {
1617 [ # # ]: 0 : if (!bApi)
1618 [ # # ]: 0 : rDocShell.ErrorMessage(STR_MSSG_INSERTCELLS_0);
1619 [ # # ][ # # ]: 0 : rDocShell.GetUndoManager()->LeaveListAction();
1620 : 3 : return false;
1621 [ + - ][ + - ]: 3 : }
1622 : : }
1623 : : }
1624 : :
1625 [ - + - + : 7 : switch (eCmd)
- ]
1626 : : {
1627 : : case INS_CELLSDOWN:
1628 [ # # ]: 0 : bSuccess = pDoc->InsertRow( nStartCol, 0, nEndCol, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc, &aFullMark );
1629 : 0 : nPaintEndY = MAXROW;
1630 : 0 : break;
1631 : : case INS_INSROWS:
1632 [ + - ]: 4 : bSuccess = pDoc->InsertRow( 0, 0, MAXCOL, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc, &aFullMark );
1633 : 4 : nPaintStartX = 0;
1634 : 4 : nPaintEndX = MAXCOL;
1635 : 4 : nPaintEndY = MAXROW;
1636 : 4 : nPaintFlags |= PAINT_LEFT;
1637 : 4 : break;
1638 : : case INS_CELLSRIGHT:
1639 [ # # ]: 0 : bSuccess = pDoc->InsertCol( nStartRow, 0, nEndRow, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc, &aFullMark );
1640 : 0 : nPaintEndX = MAXCOL;
1641 : 0 : break;
1642 : : case INS_INSCOLS:
1643 [ + - ]: 3 : bSuccess = pDoc->InsertCol( 0, 0, MAXROW, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc, &aFullMark );
1644 : 3 : nPaintStartY = 0;
1645 : 3 : nPaintEndY = MAXROW;
1646 : 3 : nPaintEndX = MAXCOL;
1647 : 3 : nPaintFlags |= PAINT_TOP;
1648 : 3 : break;
1649 : : default:
1650 : : OSL_FAIL("Falscher Code beim Einfuegen");
1651 : 0 : bSuccess = false;
1652 : 0 : break;
1653 : : }
1654 : :
1655 [ + - ]: 7 : if ( bSuccess )
1656 : : {
1657 : 7 : SCTAB* pTabs = NULL;
1658 : 7 : SCTAB* pScenarios = NULL;
1659 : 7 : SCTAB nUndoPos = 0;
1660 : :
1661 [ + - ]: 7 : if ( bRecord )
1662 : : {
1663 [ + - ]: 7 : pTabs = new SCTAB[nSelCount];
1664 [ + - ]: 7 : pScenarios = new SCTAB[nSelCount];
1665 : 7 : nUndoPos = 0;
1666 [ + - ]: 7 : itr = aMark.begin();
1667 [ + - ][ + - ]: 14 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ + + ][ + - ]
[ + - ][ + + ]
1668 : : {
1669 : 7 : SCTAB nCount = 0;
1670 [ + - ][ - + ]: 7 : for( SCTAB j=*itr+1; j<nTabCount && pDoc->IsScenario(j); j++ )
[ # # ][ # # ]
[ - + ]
1671 : 0 : nCount ++;
1672 : :
1673 : 7 : pScenarios[nUndoPos] = nCount;
1674 [ + - ]: 7 : pTabs[nUndoPos] = *itr;
1675 : 7 : nUndoPos ++;
1676 : : }
1677 : :
1678 [ + + ]: 7 : if( !bInsertMerge )
1679 : : {
1680 [ + - ][ + - ]: 4 : rDocShell.GetUndoManager()->LeaveListAction();
1681 : : }
1682 : :
1683 [ + - ]: 7 : rDocShell.GetUndoManager()->AddUndoAction( new ScUndoInsertCells(
1684 : : &rDocShell, ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab ),
1685 [ + - ][ + - ]: 7 : nUndoPos, pTabs, pScenarios, eCmd, pRefUndoDoc, pUndoData, bPartOfPaste ) );
[ + - ]
1686 : : }
1687 : :
1688 : : // #i8302 : we remerge growing ranges, with the new part inserted
1689 : :
1690 [ + + ]: 10 : while( !qIncreaseRange.empty() )
1691 : : {
1692 [ + - ]: 3 : ScRange aRange = qIncreaseRange.back();
1693 [ + - ][ + - ]: 3 : if( !pDoc->HasAttrib( aRange, HASATTR_OVERLAPPED | HASATTR_MERGED ) )
1694 : : {
1695 [ + - - ]: 3 : switch (eCmd)
1696 : : {
1697 : : case INS_CELLSDOWN:
1698 : : case INS_INSROWS:
1699 [ + - ]: 3 : aRange.aEnd.IncRow(static_cast<SCsCOL>(nEndRow-nStartRow+1));
1700 : 3 : break;
1701 : : case INS_CELLSRIGHT:
1702 : : case INS_INSCOLS:
1703 [ # # ]: 0 : aRange.aEnd.IncCol(static_cast<SCsCOL>(nEndCol-nStartCol+1));
1704 : 0 : break;
1705 : : default:
1706 : 0 : break;
1707 : : }
1708 : : ScCellMergeOption aMergeOption(
1709 : 3 : aRange.aStart.Col(), aRange.aStart.Row(),
1710 [ + - ]: 6 : aRange.aEnd.Col(), aRange.aEnd.Row() );
1711 [ + - ]: 3 : aMergeOption.maTabs.insert(aRange.aStart.Tab());
1712 [ + - ]: 3 : MergeCells(aMergeOption, false, true, true);
1713 : : }
1714 [ + - ]: 3 : qIncreaseRange.pop_back();
1715 : : }
1716 : :
1717 [ + + ]: 7 : if( bInsertMerge )
1718 [ + - ][ + - ]: 3 : rDocShell.GetUndoManager()->LeaveListAction();
1719 : :
1720 [ + - ]: 7 : itr = aMark.begin();
1721 [ + - ][ + - ]: 14 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ + + ][ + - ]
[ + - ][ + + ]
1722 : : {
1723 [ + - ]: 7 : i = *itr;
1724 [ - + ]: 7 : if (bNeedRefresh)
1725 [ # # ]: 0 : pDoc->ExtendMerge( nMergeTestStartX, nMergeTestStartY, nMergeTestEndX, nMergeTestEndY, i, sal_True );
1726 : : else
1727 [ + - ]: 7 : pDoc->RefreshAutoFilter( nMergeTestStartX, nMergeTestStartY, nMergeTestEndX, nMergeTestEndY, i );
1728 : :
1729 [ + + ][ + - ]: 7 : if ( eCmd == INS_INSROWS || eCmd == INS_INSCOLS )
1730 [ + - ]: 7 : pDoc->UpdatePageBreaks( i );
1731 : :
1732 : 7 : sal_uInt16 nExtFlags = 0;
1733 [ + - ]: 7 : rDocShell.UpdatePaintExt( nExtFlags, nPaintStartX, nPaintStartY, i, nPaintEndX, nPaintEndY, i );
1734 : :
1735 : 7 : SCTAB nScenarioCount = 0;
1736 : :
1737 [ - + ][ # # ]: 7 : for( SCTAB j = i+1; j<nTabCount && pDoc->IsScenario(j); j++ )
[ # # ][ - + ]
1738 : 0 : nScenarioCount ++;
1739 : :
1740 [ + + ][ # # ]: 11 : sal_Bool bAdjusted = ( eCmd == INS_INSROWS ) ? AdjustRowHeight(ScRange(0, nStartRow, i, MAXCOL, nEndRow, i+nScenarioCount )) :
1741 [ + + + - ]: 11 : AdjustRowHeight(ScRange(0, nPaintStartY, i, MAXCOL, nPaintEndY, i+nScenarioCount ));
[ + - ][ + + ]
[ # # ]
1742 [ + + ]: 7 : if (bAdjusted)
1743 : : {
1744 : : // paint only what is not done by AdjustRowHeight
1745 [ + + ]: 2 : if (nPaintFlags & PAINT_TOP)
1746 [ + - ]: 1 : rDocShell.PostPaint( nPaintStartX, nPaintStartY, i, nPaintEndX, nPaintEndY, i+nScenarioCount, PAINT_TOP );
1747 : : }
1748 : : else
1749 [ + - ]: 5 : rDocShell.PostPaint( nPaintStartX, nPaintStartY, i, nPaintEndX, nPaintEndY, i+nScenarioCount, nPaintFlags, nExtFlags );
1750 : : }
1751 : : }
1752 : : else
1753 : : {
1754 [ # # ]: 0 : if( bInsertMerge )
1755 : : {
1756 [ # # ]: 0 : while( !qIncreaseRange.empty() )
1757 : : {
1758 [ # # ]: 0 : ScRange aRange = qIncreaseRange.back();
1759 : : ScCellMergeOption aMergeOption(
1760 : 0 : aRange.aStart.Col(), aRange.aStart.Row(),
1761 [ # # ]: 0 : aRange.aEnd.Col(), aRange.aEnd.Row() );
1762 [ # # ]: 0 : MergeCells(aMergeOption, false, true, true);
1763 [ # # ]: 0 : qIncreaseRange.pop_back();
1764 : 0 : }
1765 : :
1766 [ # # ]: 0 : if( pViewSh )
1767 : : {
1768 [ # # ]: 0 : pViewSh->MarkRange( rRange, false );
1769 [ # # ]: 0 : pViewSh->SetCursor( nCursorCol, nCursorRow );
1770 : : }
1771 : : }
1772 : :
1773 [ # # ][ # # ]: 0 : rDocShell.GetUndoManager()->LeaveListAction();
1774 [ # # ][ # # ]: 0 : rDocShell.GetUndoManager()->RemoveLastUndoAction();
1775 : :
1776 [ # # ][ # # ]: 0 : delete pRefUndoDoc;
1777 [ # # ][ # # ]: 0 : delete pUndoData;
1778 [ # # ]: 0 : if (!bApi)
1779 [ # # ]: 0 : rDocShell.ErrorMessage(STR_INSERT_FULL); // Spalte/Zeile voll
1780 : : }
1781 : :
1782 [ + - ]: 7 : aModificator.SetDocumentModified();
1783 : :
1784 [ + - ][ + - ]: 7 : SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
[ + - ][ + - ]
1785 [ + - ][ + - ]: 7 : return bSuccess;
[ + - ][ + - ]
[ + - ]
1786 : : }
1787 : :
1788 : 4 : sal_Bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark, DelCellCmd eCmd,
1789 : : sal_Bool bRecord, sal_Bool bApi )
1790 : : {
1791 [ + - ]: 4 : ScDocShellModificator aModificator( rDocShell );
1792 : :
1793 : 4 : SCCOL nStartCol = rRange.aStart.Col();
1794 : 4 : SCROW nStartRow = rRange.aStart.Row();
1795 : 4 : SCTAB nStartTab = rRange.aStart.Tab();
1796 : 4 : SCCOL nEndCol = rRange.aEnd.Col();
1797 : 4 : SCROW nEndRow = rRange.aEnd.Row();
1798 : 4 : SCTAB nEndTab = rRange.aEnd.Tab();
1799 : :
1800 [ - + ][ - + ]: 4 : if ( !ValidRow(nStartRow) || !ValidRow(nEndRow) )
[ + - ]
1801 : : {
1802 : : OSL_FAIL("invalid row in DeleteCells");
1803 : 0 : return false;
1804 : : }
1805 : :
1806 : 4 : ScDocument* pDoc = rDocShell.GetDocument();
1807 [ + - ]: 4 : SCTAB nTabCount = pDoc->GetTableCount();
1808 : 4 : SCCOL nPaintStartX = nStartCol;
1809 : 4 : SCROW nPaintStartY = nStartRow;
1810 : 4 : SCCOL nPaintEndX = nEndCol;
1811 : 4 : SCROW nPaintEndY = nEndRow;
1812 : 4 : sal_uInt16 nPaintFlags = PAINT_GRID;
1813 : :
1814 [ + - ][ - + ]: 4 : if (bRecord && !pDoc->IsUndoEnabled())
[ - + ]
1815 : 0 : bRecord = false;
1816 : :
1817 [ + - ]: 4 : ScMarkData aMark;
1818 [ - + ]: 4 : if (pTabMark)
1819 [ # # ]: 0 : aMark = *pTabMark;
1820 : : else
1821 : : {
1822 : 4 : SCTAB nCount = 0;
1823 [ + - ]: 4 : for(SCTAB i=0; i<nTabCount; i++ )
1824 : : {
1825 [ + - ][ + - ]: 4 : if( !pDoc->IsScenario(i) )
1826 : : {
1827 : 4 : nCount++;
1828 [ + - ]: 4 : if( nCount == nEndTab+1 )
1829 : : {
1830 [ + - ]: 4 : aMark.SelectTable( i, sal_True );
1831 : 4 : break;
1832 : : }
1833 : : }
1834 : : }
1835 : : }
1836 : :
1837 [ + - ]: 4 : ScMarkData aFullMark( aMark ); // including scenario sheets
1838 [ + - ][ + - ]: 4 : ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
1839 [ + - ][ + - ]: 8 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ + + ][ + - ]
[ + - ][ + + ]
1840 [ + - ][ - + ]: 4 : for( SCTAB j = *itr+1; j<nTabCount && pDoc->IsScenario(j); j++ )
[ # # ][ # # ]
[ - + ]
1841 [ # # ]: 0 : aFullMark.SelectTable( j, sal_True );
1842 : :
1843 [ + - ]: 4 : SCTAB nSelCount = aMark.GetSelectCount();
1844 : :
1845 : 4 : SCCOL nUndoStartX = nStartCol;
1846 : 4 : SCROW nUndoStartY = nStartRow;
1847 : 4 : SCCOL nUndoEndX = nEndCol;
1848 : 4 : SCROW nUndoEndY = nEndRow;
1849 : :
1850 : 4 : ScRange aExtendMergeRange( rRange );
1851 : :
1852 [ # # ][ # # ]: 4 : if( rRange.aStart == rRange.aEnd && pDoc->HasAttrib(rRange, HASATTR_MERGED) )
[ - + ][ - + ]
1853 : : {
1854 [ # # ]: 0 : pDoc->ExtendMerge( aExtendMergeRange );
1855 [ # # ]: 0 : pDoc->ExtendOverlapped( aExtendMergeRange );
1856 : 0 : nUndoEndX = aExtendMergeRange.aEnd.Col();
1857 : 0 : nUndoEndY = aExtendMergeRange.aEnd.Row();
1858 : 0 : nPaintEndX = nUndoEndX;
1859 : 0 : nPaintEndY = nUndoEndY;
1860 : : }
1861 : :
1862 [ + + ]: 4 : if (eCmd==DEL_DELROWS)
1863 : : {
1864 : 1 : nUndoStartX = 0;
1865 : 1 : nUndoEndX = MAXCOL;
1866 : : }
1867 [ + + ]: 4 : if (eCmd==DEL_DELCOLS)
1868 : : {
1869 : 3 : nUndoStartY = 0;
1870 : 3 : nUndoEndY = MAXROW;
1871 : : }
1872 : : // Test Zellschutz
1873 : :
1874 : 4 : SCCOL nEditTestEndX = nUndoEndX;
1875 [ + + ][ - + ]: 4 : if ( eCmd==DEL_DELCOLS || eCmd==DEL_CELLSLEFT )
1876 : 3 : nEditTestEndX = MAXCOL;
1877 : 4 : SCROW nEditTestEndY = nUndoEndY;
1878 [ + + ][ - + ]: 4 : if ( eCmd==DEL_DELROWS || eCmd==DEL_CELLSUP )
1879 : 1 : nEditTestEndY = MAXROW;
1880 [ + - ]: 4 : ScEditableTester aTester( pDoc, nUndoStartX, nUndoStartY, nEditTestEndX, nEditTestEndY, aMark );
1881 [ - + ]: 4 : if (!aTester.IsEditable())
1882 : : {
1883 [ # # ]: 0 : if (!bApi)
1884 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
1885 : 0 : return false;
1886 : : }
1887 : :
1888 : : // Test zusammengefasste
1889 : :
1890 [ + - ]: 4 : SCCOL nMergeTestEndX = (eCmd==DEL_CELLSLEFT) ? MAXCOL : nUndoEndX;
1891 [ + - ]: 4 : SCROW nMergeTestEndY = (eCmd==DEL_CELLSUP) ? MAXROW : nUndoEndY;
1892 : 4 : SCCOL nExtendStartCol = nUndoStartX;
1893 : 4 : SCROW nExtendStartRow = nUndoStartY;
1894 : 4 : sal_Bool bNeedRefresh = false;
1895 : :
1896 : : //Issue 8302 want to be able to insert into the middle of merged cells
1897 : : //the patch comes from maoyg
1898 [ + - ]: 4 : ::std::vector<ScRange> qDecreaseRange;
1899 : 4 : sal_Bool bDeletingMerge = false;
1900 [ + - ][ + - ]: 4 : String aUndo = ScGlobal::GetRscString( STR_UNDO_DELETECELLS );
1901 [ + - ]: 4 : if (bRecord)
1902 [ + - ][ + - ]: 4 : rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo );
1903 : :
1904 [ + - ]: 4 : itr = aMark.begin();
1905 [ + - ][ + - ]: 8 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ + + ][ + - ]
[ + - ][ + + ]
1906 : : {
1907 [ + - ]: 4 : SCTAB i = *itr;
1908 [ + - ][ - + ]: 4 : if ( pDoc->HasAttrib( nUndoStartX, nUndoStartY, i, nMergeTestEndX, nMergeTestEndY, i, HASATTR_MERGED | HASATTR_OVERLAPPED ))
1909 : : {
1910 : 0 : SCCOL nMergeStartX = nUndoStartX;
1911 : 0 : SCROW nMergeStartY = nUndoStartY;
1912 : 0 : SCCOL nMergeEndX = nMergeTestEndX;
1913 : 0 : SCROW nMergeEndY = nMergeTestEndY;
1914 : :
1915 [ # # ]: 0 : pDoc->ExtendMerge( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, i );
1916 [ # # ]: 0 : pDoc->ExtendOverlapped( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, i );
1917 [ # # ][ # # ]: 0 : if( ( eCmd == DEL_CELLSUP && ( nMergeStartX != nUndoStartX || nMergeEndX != nMergeTestEndX))||
[ # # ][ # # ]
[ # # ][ # # ]
1918 : : ( eCmd == DEL_CELLSLEFT && ( nMergeStartY != nUndoStartY || nMergeEndY != nMergeTestEndY)))
1919 : : {
1920 [ # # ]: 0 : if (!bApi)
1921 [ # # ]: 0 : rDocShell.ErrorMessage(STR_MSSG_DELETECELLS_0);
1922 [ # # ][ # # ]: 0 : rDocShell.GetUndoManager()->LeaveListAction();
1923 : 0 : return false;
1924 : : }
1925 : :
1926 : 0 : nExtendStartCol = nMergeStartX;
1927 : 0 : nExtendStartRow = nMergeStartY;
1928 : 0 : SCCOL nTestCol = -1;
1929 : 0 : SCROW nTestRow1 = -1;
1930 : 0 : SCROW nTestRow2 = -1;
1931 : :
1932 [ # # ]: 0 : ScDocAttrIterator aTestIter( pDoc, i, nUndoStartX, nUndoStartY, nMergeTestEndX, nMergeTestEndY );
1933 : 0 : ScRange aExtendRange( nUndoStartX, nUndoStartY, i, nMergeTestEndX, nMergeTestEndY, i );
1934 : 0 : const ScPatternAttr* pPattern = NULL;
1935 : 0 : const ScMergeAttr* pMergeFlag = NULL;
1936 : 0 : const ScMergeFlagAttr* pMergeFlagAttr = NULL;
1937 [ # # ][ # # ]: 0 : while ( ( pPattern = aTestIter.GetNext( nTestCol, nTestRow1, nTestRow2 ) ) != NULL )
1938 : : {
1939 [ # # ]: 0 : pMergeFlag = (const ScMergeAttr*) &pPattern->GetItem( ATTR_MERGE );
1940 [ # # ]: 0 : pMergeFlagAttr = (const ScMergeFlagAttr*) &pPattern->GetItem( ATTR_MERGE_FLAG );
1941 : 0 : sal_Int16 nNewFlags = pMergeFlagAttr->GetValue() & ( SC_MF_HOR | SC_MF_VER );
1942 [ # # ][ # # ]: 0 : if( ( pMergeFlag && pMergeFlag->IsMerged() ) || nNewFlags == SC_MF_HOR || nNewFlags == SC_MF_VER )
[ # # ][ # # ]
[ # # ]
1943 : : {
1944 : 0 : ScRange aRange( nTestCol, nTestRow1, i );
1945 [ # # ]: 0 : pDoc->ExtendOverlapped( aRange );
1946 [ # # ]: 0 : pDoc->ExtendMerge( aRange, sal_True );
1947 : :
1948 [ # # ][ # # ]: 0 : if( nTestRow1 < nTestRow2 && nNewFlags == SC_MF_HOR )
1949 : : {
1950 [ # # ]: 0 : for( SCROW nTestRow = nTestRow1; nTestRow <= nTestRow2; nTestRow++ )
1951 : : {
1952 : 0 : ScRange aTestRange( nTestCol, nTestRow, i );
1953 [ # # ]: 0 : pDoc->ExtendOverlapped( aTestRange );
1954 [ # # ]: 0 : pDoc->ExtendMerge( aTestRange, sal_True );
1955 : 0 : ScRange aMergeRange( aTestRange.aStart.Col(),aTestRange.aStart.Row(), i );
1956 [ # # ]: 0 : if( !aExtendRange.In( aMergeRange ) )
1957 : : {
1958 [ # # ]: 0 : qDecreaseRange.push_back( aTestRange );
1959 : 0 : bDeletingMerge = sal_True;
1960 : : }
1961 : 0 : }
1962 : : }
1963 : : else
1964 : : {
1965 : 0 : ScRange aMergeRange( aRange.aStart.Col(),aRange.aStart.Row(), i );
1966 [ # # ]: 0 : if( !aExtendRange.In( aMergeRange ) )
1967 : : {
1968 [ # # ]: 0 : qDecreaseRange.push_back( aRange );
1969 : : }
1970 : 0 : bDeletingMerge = sal_True;
1971 : : }
1972 : : }
1973 : : }
1974 : :
1975 [ # # ]: 0 : if( bDeletingMerge )
1976 : : {
1977 : :
1978 [ # # ][ # # ]: 0 : if( eCmd == DEL_DELROWS || eCmd == DEL_CELLSUP )
1979 : : {
1980 : 0 : nStartRow = aExtendMergeRange.aStart.Row();
1981 : 0 : nEndRow = aExtendMergeRange.aEnd.Row();
1982 : 0 : bNeedRefresh = sal_True;
1983 : :
1984 [ # # ]: 0 : if( eCmd == DEL_CELLSUP )
1985 : : {
1986 : 0 : nEndCol = aExtendMergeRange.aEnd.Col();
1987 : : }
1988 : : else
1989 : : {
1990 : 0 : nStartCol = 0;
1991 : 0 : nEndCol = MAXCOL;
1992 : : }
1993 : : }
1994 [ # # ][ # # ]: 0 : else if( eCmd == DEL_CELLSLEFT || eCmd == DEL_DELCOLS )
1995 : : {
1996 : :
1997 : 0 : nStartCol = aExtendMergeRange.aStart.Col();
1998 : 0 : nEndCol = aExtendMergeRange.aEnd.Col();
1999 [ # # ]: 0 : if( eCmd == DEL_CELLSLEFT )
2000 : : {
2001 : 0 : nEndRow = aExtendMergeRange.aEnd.Row();
2002 : 0 : bNeedRefresh = sal_True;
2003 : : }
2004 : : else
2005 : : {
2006 : 0 : nStartRow = 0;
2007 : 0 : nEndRow = MAXROW;
2008 : : }
2009 : : }
2010 : :
2011 [ # # ]: 0 : if( !qDecreaseRange.empty() )
2012 : : {
2013 [ # # ][ # # ]: 0 : for( ::std::vector<ScRange>::const_iterator iIter( qDecreaseRange.begin()); iIter != qDecreaseRange.end(); ++iIter )
[ # # ]
2014 : : {
2015 : 0 : ScRange aRange( *iIter );
2016 [ # # ][ # # ]: 0 : if( pDoc->HasAttrib( aRange, HASATTR_OVERLAPPED | HASATTR_MERGED ) )
2017 : : {
2018 [ # # ]: 0 : UnmergeCells( aRange, sal_True );
2019 : : }
2020 : : }
2021 : : }
2022 : : }
2023 : : else
2024 : : {
2025 [ # # ]: 0 : if (!bApi)
2026 [ # # ]: 0 : rDocShell.ErrorMessage(STR_MSSG_DELETECELLS_0);
2027 [ # # ][ # # ]: 0 : rDocShell.GetUndoManager()->LeaveListAction();
2028 : 0 : return false;
2029 [ # # ][ # # ]: 0 : }
2030 : : }
2031 : : }
2032 : :
2033 : : //
2034 : : // ausfuehren
2035 : : //
2036 : :
2037 [ + - ][ + - ]: 4 : WaitObject aWait( rDocShell.GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference
2038 : :
2039 : 4 : ScDocument* pUndoDoc = NULL;
2040 : 4 : ScDocument* pRefUndoDoc = NULL;
2041 : 4 : ScRefUndoData* pUndoData = NULL;
2042 [ + - ]: 4 : if ( bRecord )
2043 : : {
2044 : : // With the fix for #101329#, UpdateRef always puts cells into pRefUndoDoc at their old position,
2045 : : // so it's no longer necessary to copy more than the deleted range into pUndoDoc.
2046 : :
2047 [ + - ][ + - ]: 4 : pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
2048 [ + - ]: 4 : pUndoDoc->InitUndo( pDoc, 0, nTabCount-1, (eCmd==DEL_DELCOLS), (eCmd==DEL_DELROWS) );
2049 [ + - ]: 4 : itr = aMark.begin();
2050 [ + - ][ + - ]: 8 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ + + ][ + - ]
[ + - ][ + + ]
2051 : : {
2052 : 4 : SCTAB nScenarioCount = 0;
2053 : :
2054 [ + - ][ - + ]: 4 : for( SCTAB j = *itr+1; j<nTabCount && pDoc->IsScenario(j); j++ )
[ # # ][ # # ]
[ - + ]
2055 : 0 : nScenarioCount ++;
2056 : :
2057 [ + - ][ + - ]: 4 : pDoc->CopyToDocument( nUndoStartX, nUndoStartY, *itr, nUndoEndX, nUndoEndY, *itr+nScenarioCount,
2058 [ + - ]: 4 : IDF_ALL | IDF_NOCAPTIONS, false, pUndoDoc );
2059 : : }
2060 : :
2061 [ + - ][ + - ]: 4 : pRefUndoDoc = new ScDocument( SCDOCMODE_UNDO );
2062 [ + - ]: 4 : pRefUndoDoc->InitUndo( pDoc, 0, nTabCount-1, false, false );
2063 : :
2064 [ + - ][ + - ]: 4 : pUndoData = new ScRefUndoData( pDoc );
2065 : :
2066 [ + - ]: 4 : pDoc->BeginDrawUndo();
2067 : : }
2068 : :
2069 : 4 : sal_uInt16 nExtFlags = 0;
2070 [ + - ]: 4 : itr = aMark.begin();
2071 [ + - ][ + - ]: 8 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ + + ][ + - ]
[ + - ][ + + ]
2072 : : {
2073 [ + - ][ + - ]: 4 : rDocShell.UpdatePaintExt( nExtFlags, nStartCol, nStartRow, *itr, nEndCol, nEndRow, *itr );
[ + - ]
2074 : : }
2075 : :
2076 : 4 : bool bUndoOutline = false;
2077 [ - + - + : 4 : switch (eCmd)
- ]
2078 : : {
2079 : : case DEL_CELLSUP:
2080 [ # # ]: 0 : pDoc->DeleteRow( nStartCol, 0, nEndCol, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc, NULL, &aFullMark );
2081 : 0 : nPaintEndY = MAXROW;
2082 : 0 : break;
2083 : : case DEL_DELROWS:
2084 [ + - ]: 1 : pDoc->DeleteRow( 0, 0, MAXCOL, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc, &bUndoOutline, &aFullMark );
2085 : 1 : nPaintStartX = 0;
2086 : 1 : nPaintEndX = MAXCOL;
2087 : 1 : nPaintEndY = MAXROW;
2088 : 1 : nPaintFlags |= PAINT_LEFT;
2089 : 1 : break;
2090 : : case DEL_CELLSLEFT:
2091 [ # # ]: 0 : pDoc->DeleteCol( nStartRow, 0, nEndRow, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc, NULL, &aFullMark );
2092 : 0 : nPaintEndX = MAXCOL;
2093 : 0 : break;
2094 : : case DEL_DELCOLS:
2095 [ + - ]: 3 : pDoc->DeleteCol( 0, 0, MAXROW, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc, &bUndoOutline, &aFullMark );
2096 : 3 : nPaintStartY = 0;
2097 : 3 : nPaintEndY = MAXROW;
2098 : 3 : nPaintEndX = MAXCOL;
2099 : 3 : nPaintFlags |= PAINT_TOP;
2100 : 3 : break;
2101 : : default:
2102 : : OSL_FAIL("Falscher Code beim Loeschen");
2103 : 0 : break;
2104 : : }
2105 : :
2106 : : //! Test, ob Outline in Groesse geaendert
2107 : :
2108 [ + - ]: 4 : if ( bRecord )
2109 : : {
2110 [ + - ][ + - ]: 4 : itr = aFullMark.begin(), itrEnd = aFullMark.end();
2111 [ + - ][ + - ]: 8 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ + + ][ + - ]
[ + - ][ + + ]
2112 [ + - ][ + - ]: 4 : pRefUndoDoc->DeleteAreaTab(nUndoStartX,nUndoStartY,nUndoEndX,nUndoEndY, *itr, IDF_ALL);
2113 : :
2114 : : // alle Tabellen anlegen, damit Formeln kopiert werden koennen:
2115 [ + - ]: 4 : pUndoDoc->AddUndoTab( 0, nTabCount-1, false, false );
2116 : :
2117 : : // kopieren mit bColRowFlags=sal_False (#54194#)
2118 [ + - ]: 4 : pRefUndoDoc->CopyToDocument(0,0,0,MAXCOL,MAXROW,MAXTAB,IDF_FORMULA,false,pUndoDoc,NULL,false);
2119 [ + - ][ + - ]: 4 : delete pRefUndoDoc;
2120 : :
2121 [ + - ]: 4 : SCTAB* pTabs = new SCTAB[nSelCount];
2122 [ + - ]: 4 : SCTAB* pScenarios = new SCTAB[nSelCount];
2123 : 4 : SCTAB nUndoPos = 0;
2124 : :
2125 [ + - ][ + - ]: 4 : itr = aMark.begin(), itrEnd = aMark.end();
2126 [ + - ][ + - ]: 8 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ + + ][ + - ]
[ + - ][ + + ]
2127 : : {
2128 : 4 : SCTAB nCount = 0;
2129 [ + - ][ - + ]: 4 : for( SCTAB j=*itr+1; j<nTabCount && pDoc->IsScenario(j); j++ )
[ # # ][ # # ]
[ - + ]
2130 : 0 : nCount ++;
2131 : :
2132 : 4 : pScenarios[nUndoPos] = nCount;
2133 [ + - ]: 4 : pTabs[nUndoPos] = *itr;
2134 : 4 : nUndoPos ++;
2135 : : }
2136 : :
2137 [ + - ]: 4 : if( !bDeletingMerge )
2138 : : {
2139 [ + - ][ + - ]: 4 : rDocShell.GetUndoManager()->LeaveListAction();
2140 : : }
2141 : :
2142 [ + - ]: 4 : rDocShell.GetUndoManager()->AddUndoAction( new ScUndoDeleteCells(
2143 : : &rDocShell, ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab ),nUndoPos, pTabs, pScenarios,
2144 [ + - ][ + - ]: 4 : eCmd, pUndoDoc, pUndoData ) );
[ + - ]
2145 : : }
2146 : :
2147 : : // #i8302 want to be able to insert into the middle of merged cells
2148 : : // the patch comes from maoyg
2149 : :
2150 [ - + ]: 4 : while( !qDecreaseRange.empty() )
2151 : : {
2152 [ # # ]: 0 : ScRange aRange = qDecreaseRange.back();
2153 : :
2154 : 0 : long nDecreaseRowCount = 0;
2155 : 0 : long nDecreaseColCount = 0;
2156 [ # # ][ # # ]: 0 : if( eCmd == DEL_CELLSUP || eCmd == DEL_DELROWS )
2157 : : {
2158 [ # # ][ # # ]: 0 : if( nStartRow >= aRange.aStart.Row() && nStartRow <= aRange.aEnd.Row() && nEndRow>= aRange.aStart.Row() && nEndRow <= aRange.aEnd.Row() )
[ # # ][ # # ]
[ # # ]
2159 : 0 : nDecreaseRowCount = nEndRow-nStartRow+1;
2160 [ # # ][ # # ]: 0 : else if( nStartRow >= aRange.aStart.Row() && nStartRow <= aRange.aEnd.Row() && nEndRow >= aRange.aStart.Row() && nEndRow >= aRange.aEnd.Row() )
[ # # ][ # # ]
[ # # ]
2161 : 0 : nDecreaseRowCount = aRange.aEnd.Row()-nStartRow+1;
2162 [ # # ][ # # ]: 0 : else if( nStartRow >= aRange.aStart.Row() && nStartRow >= aRange.aEnd.Row() && nEndRow>= aRange.aStart.Row() && nEndRow <= aRange.aEnd.Row() )
[ # # ][ # # ]
[ # # ]
2163 : 0 : nDecreaseRowCount = aRange.aEnd.Row()-nEndRow+1;
2164 : : }
2165 [ # # ][ # # ]: 0 : else if( eCmd == DEL_CELLSLEFT || eCmd == DEL_DELCOLS )
2166 : : {
2167 [ # # ][ # # ]: 0 : if( nStartCol >= aRange.aStart.Col() && nStartCol <= aRange.aEnd.Col() && nEndCol>= aRange.aStart.Col() && nEndCol <= aRange.aEnd.Col() )
[ # # ][ # # ]
[ # # ]
2168 : 0 : nDecreaseColCount = nEndCol-nStartCol+1;
2169 [ # # ][ # # ]: 0 : else if( nStartCol >= aRange.aStart.Col() && nStartCol <= aRange.aEnd.Col() && nEndCol >= aRange.aStart.Col() && nEndCol >= aRange.aEnd.Col() )
[ # # ][ # # ]
[ # # ]
2170 : 0 : nDecreaseColCount = aRange.aEnd.Col()-nStartCol+1;
2171 [ # # ][ # # ]: 0 : else if( nStartCol >= aRange.aStart.Col() && nStartCol >= aRange.aEnd.Col() && nEndCol>= aRange.aStart.Col() && nEndCol <= aRange.aEnd.Col() )
[ # # ][ # # ]
[ # # ]
2172 : 0 : nDecreaseColCount = aRange.aEnd.Col()-nEndCol+1;
2173 : : }
2174 : :
2175 [ # # # ]: 0 : switch (eCmd)
2176 : : {
2177 : : case DEL_CELLSUP:
2178 : : case DEL_DELROWS:
2179 : 0 : aRange.aEnd.SetRow(static_cast<SCsCOL>( aRange.aEnd.Row()-nDecreaseRowCount));
2180 : 0 : break;
2181 : : case DEL_CELLSLEFT:
2182 : : case DEL_DELCOLS:
2183 : 0 : aRange.aEnd.SetCol(static_cast<SCsCOL>( aRange.aEnd.Col()-nDecreaseColCount));
2184 : 0 : break;
2185 : : default:
2186 : 0 : break;
2187 : : }
2188 : :
2189 [ # # ][ # # ]: 0 : if( !pDoc->HasAttrib( aRange, HASATTR_OVERLAPPED | HASATTR_MERGED ) )
2190 : : {
2191 [ # # ]: 0 : ScCellMergeOption aMergeOption(aRange);
2192 [ # # ]: 0 : MergeCells( aMergeOption, false, true, true );
2193 : : }
2194 [ # # ]: 0 : qDecreaseRange.pop_back();
2195 : : }
2196 : :
2197 [ - + ]: 4 : if( bDeletingMerge )
2198 [ # # ][ # # ]: 0 : rDocShell.GetUndoManager()->LeaveListAction();
2199 : :
2200 [ - + ]: 4 : if ( bNeedRefresh )
2201 : : {
2202 : : // #i51445# old merge flag attributes must be deleted also for single cells,
2203 : : // not only for whole columns/rows
2204 : :
2205 [ # # ][ # # ]: 0 : if ( eCmd==DEL_DELCOLS || eCmd==DEL_CELLSLEFT )
2206 : 0 : nMergeTestEndX = MAXCOL;
2207 [ # # ][ # # ]: 0 : if ( eCmd==DEL_DELROWS || eCmd==DEL_CELLSUP )
2208 : 0 : nMergeTestEndY = MAXROW;
2209 [ # # ][ # # ]: 0 : ScPatternAttr aPattern( pDoc->GetPool() );
2210 [ # # ][ # # ]: 0 : aPattern.GetItemSet().Put( ScMergeFlagAttr() );
[ # # ]
2211 : :
2212 [ # # ]: 0 : pDoc->ApplyPatternArea( nExtendStartCol, nExtendStartRow, nMergeTestEndX, nMergeTestEndY, aMark, aPattern );
2213 : :
2214 [ # # ][ # # ]: 0 : itr = aMark.begin(), itrEnd = aMark.end();
2215 [ # # ][ # # ]: 0 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ # # ][ # # ]
[ # # ][ # # ]
2216 : : {
2217 : 0 : SCTAB nScenarioCount = 0;
2218 : :
2219 [ # # ][ # # ]: 0 : for( SCTAB j = *itr+1; j<nTabCount && pDoc->IsScenario(j); j++ )
[ # # ][ # # ]
[ # # ]
2220 : 0 : nScenarioCount ++;
2221 : :
2222 [ # # ][ # # ]: 0 : ScRange aMergedRange( nExtendStartCol, nExtendStartRow, *itr, nMergeTestEndX, nMergeTestEndY, *itr+nScenarioCount );
2223 [ # # ]: 0 : pDoc->ExtendMerge( aMergedRange, sal_True );
2224 [ # # ]: 0 : }
2225 : : }
2226 : :
2227 [ + - ][ + - ]: 4 : itr = aMark.begin(), itrEnd = aMark.end();
2228 [ + - ][ + - ]: 8 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ + + ][ + - ]
[ + - ][ + + ]
2229 : : {
2230 [ + + ][ + - ]: 4 : if ( eCmd == DEL_DELCOLS || eCmd == DEL_DELROWS )
2231 [ + - ][ + - ]: 4 : pDoc->UpdatePageBreaks( *itr );
2232 : :
2233 [ + - ][ + - ]: 4 : rDocShell.UpdatePaintExt( nExtFlags, nPaintStartX, nPaintStartY, *itr, nPaintEndX, nPaintEndY, *itr );
[ + - ]
2234 : :
2235 : 4 : SCTAB nScenarioCount = 0;
2236 : :
2237 [ + - ][ - + ]: 4 : for( SCTAB j = *itr+1; j<nTabCount && pDoc->IsScenario(j); j++ )
[ # # ][ # # ]
[ - + ]
2238 : 0 : nScenarioCount ++;
2239 : :
2240 : : // ganze Zeilen loeschen: nichts anpassen
2241 [ + + ][ + - ]: 4 : if ( eCmd == DEL_DELROWS || !AdjustRowHeight(ScRange( 0, nPaintStartY, *itr, MAXCOL, nPaintEndY, *itr+nScenarioCount )) )
[ + - ][ + - ]
[ + - ][ + + ]
[ + - # # ]
2242 [ + - ][ + - ]: 4 : rDocShell.PostPaint( nPaintStartX, nPaintStartY, *itr, nPaintEndX, nPaintEndY, *itr+nScenarioCount, nPaintFlags, nExtFlags );
[ + - ]
2243 : : else
2244 : : {
2245 : : // paint only what is not done by AdjustRowHeight
2246 [ # # ]: 0 : if (nExtFlags & SC_PF_LINES)
2247 [ # # ][ # # ]: 0 : lcl_PaintAbove( rDocShell, ScRange( nPaintStartX, nPaintStartY, *itr, nPaintEndX, nPaintEndY, *itr+nScenarioCount) );
[ # # ]
2248 [ # # ]: 0 : if (nPaintFlags & PAINT_TOP)
2249 [ # # ][ # # ]: 0 : rDocShell.PostPaint( nPaintStartX, nPaintStartY, *itr, nPaintEndX, nPaintEndY, *itr+nScenarioCount, PAINT_TOP );
[ # # ]
2250 : : }
2251 : : }
2252 [ + - ]: 4 : aModificator.SetDocumentModified();
2253 : :
2254 [ + - ][ + - ]: 4 : SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
[ + - ][ + - ]
2255 : :
2256 [ + - ][ + - ]: 4 : return sal_True;
[ + - ][ + - ]
[ + - ]
2257 : : }
2258 : :
2259 : 3 : sal_Bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
2260 : : sal_Bool bCut, sal_Bool bRecord, sal_Bool bPaint, sal_Bool bApi )
2261 : : {
2262 [ + - ]: 3 : ScDocShellModificator aModificator( rDocShell );
2263 : :
2264 : 3 : SCCOL nStartCol = rSource.aStart.Col();
2265 : 3 : SCROW nStartRow = rSource.aStart.Row();
2266 : 3 : SCTAB nStartTab = rSource.aStart.Tab();
2267 : 3 : SCCOL nEndCol = rSource.aEnd.Col();
2268 : 3 : SCROW nEndRow = rSource.aEnd.Row();
2269 : 3 : SCTAB nEndTab = rSource.aEnd.Tab();
2270 : 3 : SCCOL nDestCol = rDestPos.Col();
2271 : 3 : SCROW nDestRow = rDestPos.Row();
2272 : 3 : SCTAB nDestTab = rDestPos.Tab();
2273 : :
2274 [ + - ][ - + ]: 3 : if ( !ValidRow(nStartRow) || !ValidRow(nEndRow) || !ValidRow(nDestRow) )
[ - + ][ + - ]
2275 : : {
2276 : : OSL_FAIL("invalid row in MoveBlock");
2277 : 0 : return false;
2278 : : }
2279 : :
2280 : : // zugehoerige Szenarien auch anpassen - nur wenn innerhalb einer Tabelle verschoben wird!
2281 : 3 : sal_Bool bScenariosAdded = false;
2282 : 3 : ScDocument* pDoc = rDocShell.GetDocument();
2283 [ # # ][ - + ]: 3 : if (bRecord && !pDoc->IsUndoEnabled())
[ - + ]
2284 : 0 : bRecord = false;
2285 : :
2286 [ + - ]: 3 : SCTAB nTabCount = pDoc->GetTableCount();
2287 [ + - ][ + - ]: 3 : if ( nDestTab == nStartTab && !pDoc->IsScenario(nEndTab) )
[ + - ][ + - ]
2288 [ + - ][ + - ]: 3 : while ( nEndTab+1 < nTabCount && pDoc->IsScenario(nEndTab+1) )
[ - + ][ - + ]
2289 : : {
2290 : 0 : ++nEndTab;
2291 : 0 : bScenariosAdded = sal_True;
2292 : : }
2293 : :
2294 : 3 : SCTAB nSrcTabCount = nEndTab-nStartTab+1;
2295 : 3 : SCTAB nDestEndTab = nDestTab+nSrcTabCount-1;
2296 : : SCTAB nTab;
2297 : :
2298 [ + - ][ + - ]: 3 : ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
2299 : :
2300 [ + - ]: 3 : ScMarkData aSourceMark;
2301 [ + + ]: 6 : for (nTab=nStartTab; nTab<=nEndTab; nTab++)
2302 [ + - ]: 3 : aSourceMark.SelectTable( nTab, sal_True ); // Source selektieren
2303 [ + - ]: 3 : aSourceMark.SetMarkArea( rSource );
2304 : :
2305 : 3 : ScDocShellRef aDragShellRef;
2306 [ - + ][ + - ]: 3 : if ( pDoc->HasOLEObjectsInArea( rSource ) )
2307 : : {
2308 [ # # ][ # # ]: 0 : aDragShellRef = new ScDocShell; // DocShell needs a Ref immediately
[ # # ]
2309 [ # # ]: 0 : aDragShellRef->DoInitNew(NULL);
2310 : : }
2311 [ + - ]: 3 : ScDrawLayer::SetGlobalDrawPersist(aDragShellRef);
2312 : :
2313 [ + - ]: 3 : ScClipParam aClipParam(ScRange(nStartCol, nStartRow, 0, nEndCol, nEndRow, 0), bCut);
2314 [ + - ]: 3 : pDoc->CopyToClip(aClipParam, pClipDoc, &aSourceMark, false, bScenariosAdded, true);
2315 : :
2316 [ + - ]: 3 : ScDrawLayer::SetGlobalDrawPersist(NULL);
2317 : :
2318 : 3 : SCCOL nOldEndCol = nEndCol;
2319 : 3 : SCROW nOldEndRow = nEndRow;
2320 : 3 : sal_Bool bClipOver = false;
2321 [ + + ]: 6 : for (nTab=nStartTab; nTab<=nEndTab; nTab++)
2322 : : {
2323 : 3 : SCCOL nTmpEndCol = nOldEndCol;
2324 : 3 : SCROW nTmpEndRow = nOldEndRow;
2325 [ + - ][ - + ]: 3 : if (pDoc->ExtendMerge( nStartCol, nStartRow, nTmpEndCol, nTmpEndRow, nTab ))
2326 : 0 : bClipOver = sal_True;
2327 [ - + ]: 3 : if ( nTmpEndCol > nEndCol ) nEndCol = nTmpEndCol;
2328 [ - + ]: 3 : if ( nTmpEndRow > nEndRow ) nEndRow = nTmpEndRow;
2329 : : }
2330 : :
2331 : 3 : SCCOL nDestEndCol = nDestCol + ( nOldEndCol-nStartCol );
2332 : 3 : SCROW nDestEndRow = nDestRow + ( nOldEndRow-nStartRow );
2333 : :
2334 : 3 : SCCOL nUndoEndCol = nDestCol + ( nEndCol-nStartCol ); // erweitert im Zielblock
2335 : 3 : SCROW nUndoEndRow = nDestRow + ( nEndRow-nStartRow );
2336 : :
2337 : 3 : sal_Bool bIncludeFiltered = bCut;
2338 [ + - ]: 3 : if ( !bIncludeFiltered )
2339 : : {
2340 : : // adjust sizes to include only non-filtered rows
2341 : :
2342 : : SCCOL nClipX;
2343 : : SCROW nClipY;
2344 [ + - ]: 3 : pClipDoc->GetClipArea( nClipX, nClipY, false );
2345 : 3 : SCROW nUndoAdd = nUndoEndRow - nDestEndRow;
2346 : 3 : nDestEndRow = nDestRow + nClipY;
2347 : 3 : nUndoEndRow = nDestEndRow + nUndoAdd;
2348 : : }
2349 : :
2350 [ + - ][ - + ]: 3 : if (!ValidCol(nUndoEndCol) || !ValidRow(nUndoEndRow))
[ - + ]
2351 : : {
2352 [ # # ]: 0 : if (!bApi)
2353 [ # # ]: 0 : rDocShell.ErrorMessage(STR_PASTE_FULL);
2354 [ # # ][ # # ]: 0 : delete pClipDoc;
2355 : 0 : return false;
2356 : : }
2357 : :
2358 : : // Test auf Zellschutz
2359 : :
2360 [ + - ]: 3 : ScEditableTester aTester;
2361 [ + + ]: 6 : for (nTab=nDestTab; nTab<=nDestEndTab; nTab++)
2362 [ + - ]: 3 : aTester.TestBlock( pDoc, nTab, nDestCol,nDestRow, nUndoEndCol,nUndoEndRow );
2363 [ - + ]: 3 : if (bCut)
2364 [ # # ]: 0 : for (nTab=nStartTab; nTab<=nEndTab; nTab++)
2365 [ # # ]: 0 : aTester.TestBlock( pDoc, nTab, nStartCol,nStartRow, nEndCol,nEndRow );
2366 : :
2367 [ - + ]: 3 : if (!aTester.IsEditable())
2368 : : {
2369 [ # # ]: 0 : if (!bApi)
2370 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
2371 [ # # ][ # # ]: 0 : delete pClipDoc;
2372 : 0 : return false;
2373 : : }
2374 : :
2375 : : // Test auf zusammengefasste - beim Verschieben erst nach dem Loeschen
2376 : :
2377 [ - + ][ # # ]: 3 : if (bClipOver && !bCut)
2378 [ # # ][ # # ]: 0 : if (pDoc->HasAttrib( nDestCol,nDestRow,nDestTab, nUndoEndCol,nUndoEndRow,nDestEndTab,
2379 : 0 : HASATTR_MERGED | HASATTR_OVERLAPPED ))
2380 : : { // "Zusammenfassen nicht verschachteln !"
2381 [ # # ]: 0 : if (!bApi)
2382 [ # # ]: 0 : rDocShell.ErrorMessage(STR_MSSG_MOVEBLOCKTO_0);
2383 [ # # ][ # # ]: 0 : delete pClipDoc;
2384 : 0 : return false;
2385 : : }
2386 : :
2387 : : // Are there borders in the cells? (for painting)
2388 : :
2389 : 3 : sal_uInt16 nSourceExt = 0;
2390 [ + - ]: 3 : rDocShell.UpdatePaintExt( nSourceExt, nStartCol,nStartRow,nStartTab, nEndCol,nEndRow,nEndTab );
2391 : 3 : sal_uInt16 nDestExt = 0;
2392 [ + - ]: 3 : rDocShell.UpdatePaintExt( nDestExt, nDestCol,nDestRow,nDestTab, nDestEndCol,nDestEndRow,nDestEndTab );
2393 : :
2394 : : //
2395 : : // ausfuehren
2396 : : //
2397 : :
2398 : 3 : ScDocument* pUndoDoc = NULL;
2399 : 3 : ScDocument* pRefUndoDoc = NULL;
2400 : 3 : ScRefUndoData* pUndoData = NULL;
2401 [ - + ]: 3 : if (bRecord)
2402 : : {
2403 [ # # ][ # # ]: 0 : sal_Bool bWholeCols = ( nStartRow == 0 && nEndRow == MAXROW );
2404 [ # # ][ # # ]: 0 : sal_Bool bWholeRows = ( nStartCol == 0 && nEndCol == MAXCOL );
2405 : 0 : sal_uInt16 nUndoFlags = (IDF_ALL & ~IDF_OBJECTS) | IDF_NOCAPTIONS;
2406 : :
2407 [ # # ][ # # ]: 0 : pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
2408 [ # # ]: 0 : pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab, bWholeCols, bWholeRows );
2409 : :
2410 [ # # ]: 0 : if (bCut)
2411 : : {
2412 : : pDoc->CopyToDocument( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab,
2413 [ # # ]: 0 : nUndoFlags, false, pUndoDoc );
2414 [ # # ][ # # ]: 0 : pRefUndoDoc = new ScDocument( SCDOCMODE_UNDO );
2415 [ # # ]: 0 : pRefUndoDoc->InitUndo( pDoc, 0, nTabCount-1, false, false );
2416 : : }
2417 : :
2418 [ # # ]: 0 : if ( nDestTab != nStartTab )
2419 [ # # ]: 0 : pUndoDoc->AddUndoTab( nDestTab, nDestEndTab, bWholeCols, bWholeRows );
2420 : : pDoc->CopyToDocument( nDestCol, nDestRow, nDestTab,
2421 : : nDestEndCol, nDestEndRow, nDestEndTab,
2422 [ # # ]: 0 : nUndoFlags, false, pUndoDoc );
2423 : :
2424 [ # # ][ # # ]: 0 : pUndoData = new ScRefUndoData( pDoc );
2425 : :
2426 [ # # ]: 0 : pDoc->BeginDrawUndo();
2427 : : }
2428 : :
2429 : 3 : sal_Bool bSourceHeight = false; // Hoehen angepasst?
2430 [ - + ]: 3 : if (bCut)
2431 : : {
2432 [ # # ]: 0 : ScMarkData aDelMark; // only for tables
2433 [ # # ]: 0 : for (nTab=nStartTab; nTab<=nEndTab; nTab++)
2434 : : {
2435 [ # # ]: 0 : pDoc->DeleteAreaTab( nStartCol,nStartRow, nOldEndCol,nOldEndRow, nTab, IDF_ALL );
2436 [ # # ]: 0 : aDelMark.SelectTable( nTab, sal_True );
2437 : : }
2438 [ # # ]: 0 : pDoc->DeleteObjectsInArea( nStartCol,nStartRow, nOldEndCol,nOldEndRow, aDelMark );
2439 : :
2440 : : // Test auf zusammengefasste
2441 : :
2442 [ # # ]: 0 : if (bClipOver)
2443 [ # # ][ # # ]: 0 : if (pDoc->HasAttrib( nDestCol,nDestRow,nDestTab,
2444 : : nUndoEndCol,nUndoEndRow,nDestEndTab,
2445 : 0 : HASATTR_MERGED | HASATTR_OVERLAPPED ))
2446 : : {
2447 [ # # ]: 0 : pDoc->CopyFromClip( rSource, aSourceMark, IDF_ALL, pRefUndoDoc, pClipDoc );
2448 [ # # ]: 0 : for (nTab=nStartTab; nTab<=nEndTab; nTab++)
2449 : : {
2450 : 0 : SCCOL nTmpEndCol = nEndCol;
2451 : 0 : SCROW nTmpEndRow = nEndRow;
2452 [ # # ]: 0 : pDoc->ExtendMerge( nStartCol, nStartRow, nTmpEndCol, nTmpEndRow, nTab, sal_True );
2453 : : }
2454 : :
2455 : : // Fehlermeldung erst nach dem Wiederherstellen des Inhalts
2456 [ # # ]: 0 : if (!bApi) // "Zusammenfassen nicht verschachteln !"
2457 [ # # ]: 0 : rDocShell.ErrorMessage(STR_MSSG_MOVEBLOCKTO_0);
2458 : :
2459 [ # # ][ # # ]: 0 : delete pUndoDoc;
2460 [ # # ][ # # ]: 0 : delete pRefUndoDoc;
2461 [ # # ][ # # ]: 0 : delete pUndoData;
2462 [ # # ][ # # ]: 0 : delete pClipDoc;
2463 : 0 : return false;
2464 : : }
2465 : :
2466 [ # # ][ # # ]: 0 : bSourceHeight = AdjustRowHeight( rSource, false );
[ # # ]
2467 : : }
2468 : :
2469 : 3 : ScRange aPasteDest( nDestCol, nDestRow, nDestTab, nDestEndCol, nDestEndRow, nDestEndTab );
2470 : :
2471 [ + - ]: 3 : ScMarkData aDestMark;
2472 [ + + ]: 6 : for (nTab=nDestTab; nTab<=nDestEndTab; nTab++)
2473 [ + - ]: 3 : aDestMark.SelectTable( nTab, sal_True ); // Destination selektieren
2474 [ + - ]: 3 : aDestMark.SetMarkArea( aPasteDest );
2475 : :
2476 : : /* Do not copy cell notes and drawing objects here. While pasting, the
2477 : : function ScDocument::UpdateReference() is called which calls
2478 : : ScDrawLayer::MoveCells() which may move away inserted objects to wrong
2479 : : positions (e.g. if source and destination range overlaps). Cell notes
2480 : : and drawing objects are pasted below after doing all adjusting. */
2481 : : pDoc->CopyFromClip( aPasteDest, aDestMark, IDF_ALL & ~(IDF_NOTE | IDF_OBJECTS),
2482 [ + - ]: 3 : pRefUndoDoc, pClipDoc, sal_True, false, bIncludeFiltered );
2483 : :
2484 : : // skipped rows and merged cells don't mix
2485 [ + - ][ + - ]: 3 : if ( !bIncludeFiltered && pClipDoc->HasClipFilteredRows() )
[ - + ][ - + ]
2486 [ # # ]: 0 : UnmergeCells( aPasteDest, false );
2487 : :
2488 [ + - ]: 3 : VirtualDevice aVirtDev;
2489 : : sal_Bool bDestHeight = AdjustRowHeight(
2490 : : ScRange( 0,nDestRow,nDestTab, MAXCOL,nDestEndRow,nDestEndTab ),
2491 [ + - ]: 3 : false );
2492 : :
2493 : : /* Paste cell notes and drawing objects after adjusting formula references
2494 : : and row heights. There are no cell notes or drawing objects, if the
2495 : : clipdoc does not contain a drawing layer.
2496 : : #i102056# Passing IDF_NOTE only would overwrite cell contents with
2497 : : empty note cells, therefore the special modifier IDF_ADDNOTES is passed
2498 : : here too which changes the behaviour of ScColumn::CopyFromClip() to not
2499 : : touch existing cells. */
2500 [ + - ][ - + ]: 3 : if ( pClipDoc->GetDrawLayer() )
2501 : : pDoc->CopyFromClip( aPasteDest, aDestMark, IDF_NOTE | IDF_ADDNOTES | IDF_OBJECTS,
2502 [ # # ]: 0 : pRefUndoDoc, pClipDoc, sal_True, false, bIncludeFiltered );
2503 : :
2504 [ - + ]: 3 : if (bRecord)
2505 : : {
2506 [ # # ]: 0 : if (pRefUndoDoc)
2507 : : {
2508 : : // alle Tabellen anlegen, damit Formeln kopiert werden koennen:
2509 [ # # ]: 0 : pUndoDoc->AddUndoTab( 0, nTabCount-1, false, false );
2510 : :
2511 [ # # ]: 0 : pRefUndoDoc->DeleteArea( nDestCol, nDestRow, nDestEndCol, nDestEndRow, aSourceMark, IDF_ALL );
2512 : : // kopieren mit bColRowFlags=sal_False (#54194#)
2513 : : pRefUndoDoc->CopyToDocument( 0, 0, 0, MAXCOL, MAXROW, MAXTAB,
2514 [ # # ]: 0 : IDF_FORMULA, false, pUndoDoc, NULL, false );
2515 [ # # ][ # # ]: 0 : delete pRefUndoDoc;
2516 : : }
2517 : :
2518 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
2519 : : new ScUndoDragDrop( &rDocShell, ScRange(
2520 : : nStartCol, nStartRow, nStartTab,
2521 : : nOldEndCol, nOldEndRow, nEndTab ),
2522 : : ScAddress( nDestCol, nDestRow, nDestTab ),
2523 [ # # ][ # # ]: 0 : bCut, pUndoDoc, pUndoData, bScenariosAdded ) );
[ # # ]
2524 : : }
2525 : :
2526 : 3 : SCCOL nDestPaintEndCol = nDestEndCol;
2527 : 3 : SCROW nDestPaintEndRow = nDestEndRow;
2528 [ + + ]: 6 : for (nTab=nDestTab; nTab<=nDestEndTab; nTab++)
2529 : : {
2530 : 3 : SCCOL nTmpEndCol = nDestEndCol;
2531 : 3 : SCROW nTmpEndRow = nDestEndRow;
2532 [ + - ]: 3 : pDoc->ExtendMerge( nDestCol, nDestRow, nTmpEndCol, nTmpEndRow, nTab, sal_True );
2533 [ - + ]: 3 : if (nTmpEndCol > nDestPaintEndCol) nDestPaintEndCol = nTmpEndCol;
2534 [ - + ]: 3 : if (nTmpEndRow > nDestPaintEndRow) nDestPaintEndRow = nTmpEndRow;
2535 : : }
2536 : :
2537 [ - + ]: 3 : if (bCut)
2538 [ # # ]: 0 : for (nTab=nStartTab; nTab<=nEndTab; nTab++)
2539 [ # # ]: 0 : pDoc->RefreshAutoFilter( nStartCol, nStartRow, nEndCol, nEndRow, nTab );
2540 : :
2541 [ - + ]: 3 : if (bPaint)
2542 : : {
2543 : : // Zielbereich:
2544 : :
2545 : 0 : SCCOL nPaintStartX = nDestCol;
2546 : 0 : SCROW nPaintStartY = nDestRow;
2547 : 0 : SCCOL nPaintEndX = nDestPaintEndCol;
2548 : 0 : SCROW nPaintEndY = nDestPaintEndRow;
2549 : 0 : sal_uInt16 nFlags = PAINT_GRID;
2550 : :
2551 [ # # ][ # # ]: 0 : if ( nStartRow==0 && nEndRow==MAXROW ) // Breiten mitkopiert?
2552 : : {
2553 : 0 : nPaintEndX = MAXCOL;
2554 : 0 : nPaintStartY = 0;
2555 : 0 : nPaintEndY = MAXROW;
2556 : 0 : nFlags |= PAINT_TOP;
2557 : : }
2558 [ # # ][ # # ]: 0 : if ( bDestHeight || ( nStartCol == 0 && nEndCol == MAXCOL ) )
[ # # ]
2559 : : {
2560 : 0 : nPaintEndY = MAXROW;
2561 : 0 : nPaintStartX = 0;
2562 : 0 : nPaintEndX = MAXCOL;
2563 : 0 : nFlags |= PAINT_LEFT;
2564 : : }
2565 [ # # ]: 0 : if ( bScenariosAdded )
2566 : : {
2567 : 0 : nPaintStartX = 0;
2568 : 0 : nPaintStartY = 0;
2569 : 0 : nPaintEndX = MAXCOL;
2570 : 0 : nPaintEndY = MAXROW;
2571 : : }
2572 : :
2573 : : rDocShell.PostPaint( nPaintStartX,nPaintStartY,nDestTab,
2574 [ # # ]: 0 : nPaintEndX,nPaintEndY,nDestEndTab, nFlags, nSourceExt | nDestExt );
2575 : :
2576 [ # # ]: 0 : if ( bCut )
2577 : : {
2578 : : // Quellbereich:
2579 : :
2580 : 0 : nPaintStartX = nStartCol;
2581 : 0 : nPaintStartY = nStartRow;
2582 : 0 : nPaintEndX = nEndCol;
2583 : 0 : nPaintEndY = nEndRow;
2584 : 0 : nFlags = PAINT_GRID;
2585 : :
2586 [ # # ]: 0 : if ( bSourceHeight )
2587 : : {
2588 : 0 : nPaintEndY = MAXROW;
2589 : 0 : nPaintStartX = 0;
2590 : 0 : nPaintEndX = MAXCOL;
2591 : 0 : nFlags |= PAINT_LEFT;
2592 : : }
2593 [ # # ]: 0 : if ( bScenariosAdded )
2594 : : {
2595 : 0 : nPaintStartX = 0;
2596 : 0 : nPaintStartY = 0;
2597 : 0 : nPaintEndX = MAXCOL;
2598 : 0 : nPaintEndY = MAXROW;
2599 : : }
2600 : :
2601 : : rDocShell.PostPaint( nPaintStartX,nPaintStartY,nStartTab,
2602 [ # # ]: 0 : nPaintEndX,nPaintEndY,nEndTab, nFlags, nSourceExt );
2603 : : }
2604 : : }
2605 : :
2606 [ + - ]: 3 : aModificator.SetDocumentModified();
2607 : :
2608 [ + - ][ + - ]: 3 : SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
[ + - ][ + - ]
2609 : :
2610 [ + - ][ + - ]: 3 : delete pClipDoc;
2611 [ + - ][ + - ]: 3 : return sal_True;
[ + - ][ + - ]
[ + - ][ + - ]
2612 : : }
2613 : :
2614 : : //------------------------------------------------------------------------
2615 : 0 : uno::Reference< uno::XInterface > GetDocModuleObject( SfxObjectShell& rDocSh, String& sCodeName )
2616 : : {
2617 [ # # ][ # # ]: 0 : uno::Reference< lang::XMultiServiceFactory> xSF(rDocSh.GetModel(), uno::UNO_QUERY);
2618 : 0 : uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess;
2619 : 0 : uno::Reference< uno::XInterface > xDocModuleApiObject;
2620 [ # # ]: 0 : if ( xSF.is() )
2621 : : {
2622 [ # # ][ # # ]: 0 : xVBACodeNamedObjectAccess.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY );
[ # # ][ # # ]
2623 [ # # ][ # # ]: 0 : xDocModuleApiObject.set( xVBACodeNamedObjectAccess->getByName( sCodeName ), uno::UNO_QUERY );
[ # # ][ # # ]
2624 : : }
2625 : 0 : return xDocModuleApiObject;
2626 : :
2627 : : }
2628 : :
2629 : 0 : script::ModuleInfo lcl_InitModuleInfo( SfxObjectShell& rDocSh, String& sModule )
2630 : : {
2631 : 0 : script::ModuleInfo sModuleInfo;
2632 : 0 : sModuleInfo.ModuleType = script::ModuleType::DOCUMENT;
2633 [ # # ][ # # ]: 0 : sModuleInfo.ModuleObject = GetDocModuleObject( rDocSh, sModule );
2634 : 0 : return sModuleInfo;
2635 : : }
2636 : :
2637 : 0 : void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, const rtl::OUString& sModuleName, const rtl::OUString& sSource )
2638 : : {
2639 : 0 : SfxObjectShell& rDocSh = *rDoc.GetDocumentShell();
2640 [ # # ]: 0 : uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.GetBasicContainer();
2641 : : OSL_ENSURE( xLibContainer.is(), "No BasicContainer!" );
2642 : :
2643 : 0 : uno::Reference< container::XNameContainer > xLib;
2644 [ # # ]: 0 : if( xLibContainer.is() )
2645 : : {
2646 [ # # ]: 0 : String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
2647 [ # # ][ # # ]: 0 : if ( rDocSh.GetBasicManager() && rDocSh.GetBasicManager()->GetName().Len() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
2648 [ # # ][ # # ]: 0 : aLibName = rDocSh.GetBasicManager()->GetName();
[ # # ][ # # ]
2649 [ # # ][ # # ]: 0 : uno::Any aLibAny = xLibContainer->getByName( aLibName );
[ # # ]
2650 [ # # ][ # # ]: 0 : aLibAny >>= xLib;
2651 : : }
2652 [ # # ]: 0 : if( xLib.is() )
2653 : : {
2654 : : // if the Module with codename exists then find a new name
2655 : 0 : sal_Int32 nNum = 0;
2656 [ # # ]: 0 : String genModuleName;
2657 [ # # ]: 0 : if ( !sModuleName.isEmpty() )
2658 [ # # ]: 0 : genModuleName = sModuleName;
2659 : : else
2660 : : {
2661 [ # # ]: 0 : genModuleName = rtl::OUString( "Sheet1" );
2662 : 0 : nNum = 1;
2663 : : }
2664 [ # # ][ # # ]: 0 : while( xLib->hasByName( genModuleName ) )
[ # # ][ # # ]
2665 [ # # ][ # # ]: 0 : genModuleName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Sheet")) + rtl::OUString::valueOf( ++nNum );
2666 : :
2667 : 0 : uno::Any aSourceAny;
2668 : 0 : rtl::OUString sTmpSource = sSource;
2669 [ # # ]: 0 : if ( sTmpSource.isEmpty() )
2670 [ # # ]: 0 : sTmpSource = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" ));
2671 [ # # ]: 0 : aSourceAny <<= sTmpSource;
2672 [ # # ]: 0 : uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY );
2673 [ # # ]: 0 : if ( xVBAModuleInfo.is() )
2674 : : {
2675 [ # # ][ # # ]: 0 : rDoc.SetCodeName( nTab, genModuleName );
2676 [ # # ]: 0 : script::ModuleInfo sModuleInfo = lcl_InitModuleInfo( rDocSh, genModuleName );
2677 [ # # ][ # # ]: 0 : xVBAModuleInfo->insertModuleInfo( genModuleName, sModuleInfo );
[ # # ]
2678 [ # # ][ # # ]: 0 : xLib->insertByName( genModuleName, aSourceAny );
[ # # ][ # # ]
2679 [ # # ]: 0 : }
2680 : :
2681 : 0 : }
2682 : 0 : }
2683 : :
2684 : 0 : void VBA_DeleteModule( ScDocShell& rDocSh, const rtl::OUString& sModuleName )
2685 : : {
2686 [ # # ]: 0 : uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.GetBasicContainer();
2687 : : OSL_ENSURE( xLibContainer.is(), "No BasicContainer!" );
2688 : :
2689 : 0 : uno::Reference< container::XNameContainer > xLib;
2690 [ # # ]: 0 : if( xLibContainer.is() )
2691 : : {
2692 [ # # ]: 0 : String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
2693 [ # # ][ # # ]: 0 : if ( rDocSh.GetBasicManager() && rDocSh.GetBasicManager()->GetName().Len() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
2694 [ # # ][ # # ]: 0 : aLibName = rDocSh.GetBasicManager()->GetName();
[ # # ][ # # ]
2695 [ # # ][ # # ]: 0 : uno::Any aLibAny = xLibContainer->getByName( aLibName );
[ # # ]
2696 [ # # ][ # # ]: 0 : aLibAny >>= xLib;
2697 : : }
2698 [ # # ]: 0 : if( xLib.is() )
2699 : : {
2700 [ # # ]: 0 : uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY );
2701 [ # # ][ # # ]: 0 : if( xLib->hasByName( sModuleName ) )
[ # # ]
2702 [ # # ][ # # ]: 0 : xLib->removeByName( sModuleName );
2703 [ # # ][ # # ]: 0 : if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo(sModuleName) )
[ # # ][ # # ]
[ # # ]
2704 [ # # ][ # # ]: 0 : xVBAModuleInfo->removeModuleInfo( sModuleName );
2705 : :
2706 : 0 : }
2707 : 0 : }
2708 : :
2709 : :
2710 : 77 : sal_Bool ScDocFunc::InsertTable( SCTAB nTab, const String& rName, sal_Bool bRecord, sal_Bool bApi )
2711 : : {
2712 : 77 : sal_Bool bSuccess = false;
2713 [ + - ][ + - ]: 77 : WaitObject aWait( rDocShell.GetActiveDialogParent() );
2714 : :
2715 [ + - ]: 77 : ScDocShellModificator aModificator( rDocShell );
2716 : :
2717 : 77 : ScDocument* pDoc = rDocShell.GetDocument();
2718 : :
2719 : :
2720 : : // Strange loop, also basic is loaded too early ( InsertTable )
2721 : : // is called via the xml import for sheets in described in odf
2722 : 77 : sal_Bool bInsertDocModule = false;
2723 : :
2724 [ + - ]: 77 : if( !rDocShell.GetDocument()->IsImportingXML() )
2725 : : {
2726 [ + - ][ + - ]: 77 : bInsertDocModule = pDoc ? pDoc->IsInVBAMode() : false;
2727 : : }
2728 [ + - ][ + - ]: 77 : if ( bInsertDocModule || ( bRecord && !pDoc->IsUndoEnabled() ) )
[ + + ][ + + ]
2729 : 36 : bRecord = false;
2730 : :
2731 [ + + ]: 77 : if (bRecord)
2732 [ + - ]: 41 : pDoc->BeginDrawUndo(); // InsertTab erzeugt ein SdrUndoNewPage
2733 : :
2734 [ + - ]: 77 : SCTAB nTabCount = pDoc->GetTableCount();
2735 : 77 : sal_Bool bAppend = ( nTab >= nTabCount );
2736 [ + + ]: 77 : if ( bAppend )
2737 : 46 : nTab = nTabCount; // wichtig fuer Undo
2738 : :
2739 [ + - ][ + - ]: 77 : if (pDoc->InsertTab( nTab, rName ))
[ + - ]
2740 : : {
2741 [ + + ]: 77 : if (bRecord)
2742 [ + - ]: 41 : rDocShell.GetUndoManager()->AddUndoAction(
2743 [ + - ][ + - ]: 41 : new ScUndoInsertTab( &rDocShell, nTab, bAppend, rName));
[ + - ]
2744 : : // Views updaten:
2745 : : // Only insert vba modules if vba mode ( and not currently importing XML )
2746 [ - + ]: 77 : if( bInsertDocModule )
2747 : : {
2748 : 0 : rtl::OUString sSource, sCodeName;
2749 [ # # ]: 0 : VBA_InsertModule( *pDoc, nTab, sCodeName, sSource );
2750 : : }
2751 [ + - ][ + - ]: 77 : rDocShell.Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab ) );
[ + - ]
2752 : :
2753 [ + - ]: 77 : rDocShell.PostPaintExtras();
2754 [ + - ]: 77 : aModificator.SetDocumentModified();
2755 [ + - ][ + - ]: 77 : SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
[ + - ][ + - ]
2756 : 77 : bSuccess = sal_True;
2757 : : }
2758 [ # # ]: 0 : else if (!bApi)
2759 [ # # ]: 0 : rDocShell.ErrorMessage(STR_TABINSERT_ERROR);
2760 : :
2761 [ + - ][ + - ]: 77 : return bSuccess;
2762 : : }
2763 : :
2764 : 19 : sal_Bool ScDocFunc::DeleteTable( SCTAB nTab, sal_Bool bRecord, sal_Bool /* bApi */ )
2765 : : {
2766 [ + - ][ + - ]: 19 : WaitObject aWait( rDocShell.GetActiveDialogParent() );
2767 : :
2768 [ + - ]: 19 : ScDocShellModificator aModificator( rDocShell );
2769 : :
2770 : 19 : sal_Bool bSuccess = false;
2771 : 19 : ScDocument* pDoc = rDocShell.GetDocument();
2772 [ + - ][ + - ]: 19 : sal_Bool bVbaEnabled = pDoc ? pDoc->IsInVBAMode() : false;
2773 [ + - ][ - + ]: 19 : if (bRecord && !pDoc->IsUndoEnabled())
[ - + ]
2774 : 0 : bRecord = false;
2775 [ - + ]: 19 : if ( bVbaEnabled )
2776 : 0 : bRecord = false;
2777 [ + - ]: 19 : sal_Bool bWasLinked = pDoc->IsLinked(nTab);
2778 : 19 : ScDocument* pUndoDoc = NULL;
2779 : 19 : ScRefUndoData* pUndoData = NULL;
2780 [ + - ]: 19 : if (bRecord)
2781 : : {
2782 [ + - ][ + - ]: 19 : pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
2783 [ + - ]: 19 : SCTAB nCount = pDoc->GetTableCount();
2784 : :
2785 [ + - ]: 19 : pUndoDoc->InitUndo( pDoc, nTab, nTab, sal_True, sal_True ); // nur nTab mit Flags
2786 [ + - ]: 19 : pUndoDoc->AddUndoTab( 0, nCount-1 ); // alle Tabs fuer Referenzen
2787 : :
2788 [ + - ]: 19 : pDoc->CopyToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, IDF_ALL,false, pUndoDoc );
2789 : 19 : rtl::OUString aOldName;
2790 [ + - ]: 19 : pDoc->GetName( nTab, aOldName );
2791 [ + - ]: 19 : pUndoDoc->RenameTab( nTab, aOldName, false );
2792 [ - + ]: 19 : if (bWasLinked)
2793 [ # # ]: 0 : pUndoDoc->SetLink( nTab, pDoc->GetLinkMode(nTab), pDoc->GetLinkDoc(nTab),
2794 : : pDoc->GetLinkFlt(nTab), pDoc->GetLinkOpt(nTab),
2795 : : pDoc->GetLinkTab(nTab),
2796 [ # # ][ # # ]: 0 : pDoc->GetLinkRefreshDelay(nTab) );
[ # # ][ # # ]
[ # # ][ # # ]
2797 : :
2798 [ + - ][ - + ]: 19 : if ( pDoc->IsScenario(nTab) )
2799 : : {
2800 [ # # ]: 0 : pUndoDoc->SetScenario( nTab, sal_True );
2801 : 0 : rtl::OUString aComment;
2802 : 0 : Color aColor;
2803 : : sal_uInt16 nScenFlags;
2804 [ # # ]: 0 : pDoc->GetScenarioData( nTab, aComment, aColor, nScenFlags );
2805 [ # # ]: 0 : pUndoDoc->SetScenarioData( nTab, aComment, aColor, nScenFlags );
2806 [ # # ]: 0 : sal_Bool bActive = pDoc->IsActiveScenario( nTab );
2807 [ # # ]: 0 : pUndoDoc->SetActiveScenario( nTab, bActive );
2808 : : }
2809 [ + - ][ + - ]: 19 : pUndoDoc->SetVisible( nTab, pDoc->IsVisible( nTab ) );
2810 [ + - ][ + - ]: 19 : pUndoDoc->SetTabBgColor( nTab, pDoc->GetTabBgColor(nTab) );
2811 [ + - ][ + - ]: 19 : pUndoDoc->SetSheetEvents( nTab, pDoc->GetSheetEvents( nTab ) );
2812 : :
2813 : : // Drawing-Layer muss sein Undo selbst in der Hand behalten !!!
2814 [ + - ]: 19 : pDoc->BeginDrawUndo(); // DeleteTab erzeugt ein SdrUndoDelPage
2815 : :
2816 [ + - ][ + - ]: 19 : pUndoData = new ScRefUndoData( pDoc );
2817 : : }
2818 : :
2819 [ + - ][ + - ]: 19 : if (pDoc->DeleteTab( nTab, pUndoDoc ))
2820 : : {
2821 [ + - ]: 19 : if (bRecord)
2822 : : {
2823 [ + - ]: 19 : vector<SCTAB> theTabs;
2824 [ + - ]: 19 : theTabs.push_back(nTab);
2825 [ + - ]: 19 : rDocShell.GetUndoManager()->AddUndoAction(
2826 [ + - ][ + - ]: 19 : new ScUndoDeleteTab( &rDocShell, theTabs, pUndoDoc, pUndoData ));
[ + - ]
2827 : : }
2828 : : // Views updaten:
2829 [ - + ]: 19 : if( bVbaEnabled )
2830 : : {
2831 : 0 : rtl::OUString sCodeName;
2832 [ # # ][ # # ]: 0 : if( pDoc->GetCodeName( nTab, sCodeName ) )
2833 : : {
2834 [ # # ]: 0 : VBA_DeleteModule( rDocShell, sCodeName );
2835 : 0 : }
2836 : : }
2837 [ + - ][ + - ]: 19 : rDocShell.Broadcast( ScTablesHint( SC_TAB_DELETED, nTab ) );
[ + - ]
2838 : :
2839 [ - + ]: 19 : if (bWasLinked)
2840 : : {
2841 [ # # ]: 0 : rDocShell.UpdateLinks(); // Link-Manager updaten
2842 [ # # ]: 0 : SfxBindings* pBindings = rDocShell.GetViewBindings();
2843 [ # # ]: 0 : if (pBindings)
2844 [ # # ]: 0 : pBindings->Invalidate(SID_LINKS);
2845 : : }
2846 : :
2847 [ + - ]: 19 : rDocShell.PostPaintExtras();
2848 [ + - ]: 19 : aModificator.SetDocumentModified();
2849 : :
2850 [ + - ]: 19 : SfxApplication* pSfxApp = SFX_APP(); // Navigator
2851 [ + - ][ + - ]: 19 : pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
[ + - ]
2852 [ + - ][ + - ]: 19 : pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
[ + - ]
2853 [ + - ][ + - ]: 19 : pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
[ + - ]
2854 : :
2855 : 19 : bSuccess = sal_True;
2856 : : }
2857 : : else
2858 : : {
2859 [ # # ][ # # ]: 0 : delete pUndoDoc;
2860 [ # # ][ # # ]: 0 : delete pUndoData;
2861 : : }
2862 [ + - ][ + - ]: 19 : return bSuccess;
2863 : : }
2864 : :
2865 : 312 : sal_Bool ScDocFunc::SetTableVisible( SCTAB nTab, bool bVisible, sal_Bool bApi )
2866 : : {
2867 : 312 : ScDocument* pDoc = rDocShell.GetDocument();
2868 : 312 : bool bUndo(pDoc->IsUndoEnabled());
2869 [ + + ][ + - ]: 312 : if ( pDoc->IsVisible( nTab ) == bVisible )
2870 : 308 : return sal_True; // nichts zu tun - ok
2871 : :
2872 [ + - ][ - + ]: 4 : if ( !pDoc->IsDocEditable() )
2873 : : {
2874 [ # # ]: 0 : if (!bApi)
2875 [ # # ]: 0 : rDocShell.ErrorMessage(STR_PROTECTIONERR);
2876 : 0 : return false;
2877 : : }
2878 : :
2879 [ + - ]: 4 : ScDocShellModificator aModificator( rDocShell );
2880 : :
2881 [ + + ][ + - ]: 4 : if ( !bVisible && !pDoc->IsImportingXML() ) // #i57869# allow hiding in any order for loading
[ + + ]
2882 : : {
2883 : : // nicht alle Tabellen ausblenden
2884 : :
2885 : 2 : sal_uInt16 nVisCount = 0;
2886 [ + - ]: 2 : SCTAB nCount = pDoc->GetTableCount();
2887 [ + + ]: 6 : for (SCTAB i=0; i<nCount; i++)
2888 [ + - ][ + - ]: 4 : if (pDoc->IsVisible(i))
2889 : 4 : ++nVisCount;
2890 : :
2891 [ - + ]: 2 : if (nVisCount <= 1)
2892 : : {
2893 [ # # ]: 0 : if (!bApi)
2894 [ # # ]: 0 : rDocShell.ErrorMessage(STR_PROTECTIONERR); //! eigene Meldung?
2895 : 0 : return false;
2896 : : }
2897 : : }
2898 : :
2899 [ + - ]: 4 : pDoc->SetVisible( nTab, bVisible );
2900 [ + - ]: 4 : if (bUndo)
2901 [ + - ][ + - ]: 4 : rDocShell.GetUndoManager()->AddUndoAction( new ScUndoShowHideTab( &rDocShell, nTab, bVisible ) );
[ + - ][ + - ]
2902 : :
2903 : : // Views updaten:
2904 [ + + ]: 4 : if (!bVisible)
2905 [ + - ][ + - ]: 2 : rDocShell.Broadcast( ScTablesHint( SC_TAB_HIDDEN, nTab ) );
[ + - ]
2906 : :
2907 [ + - ][ + - ]: 4 : SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
[ + - ][ + - ]
2908 [ + - ]: 4 : rDocShell.PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB, PAINT_EXTRAS);
2909 [ + - ]: 4 : aModificator.SetDocumentModified();
2910 : :
2911 [ + - ]: 312 : return sal_True;
2912 : : }
2913 : :
2914 : 217 : sal_Bool ScDocFunc::SetLayoutRTL( SCTAB nTab, bool bRTL, sal_Bool /* bApi */ )
2915 : : {
2916 : 217 : ScDocument* pDoc = rDocShell.GetDocument();
2917 : 217 : bool bUndo(pDoc->IsUndoEnabled());
2918 [ + + ][ + - ]: 217 : if ( pDoc->IsLayoutRTL( nTab ) == bRTL )
2919 : 209 : return sal_True; // nothing to do - ok
2920 : :
2921 : : //! protection (sheet or document?)
2922 : :
2923 [ + - ]: 8 : ScDocShellModificator aModificator( rDocShell );
2924 : :
2925 [ + - ]: 8 : pDoc->SetLayoutRTL( nTab, bRTL );
2926 : :
2927 [ + - ]: 8 : if (bUndo)
2928 : : {
2929 [ + - ][ + - ]: 8 : rDocShell.GetUndoManager()->AddUndoAction( new ScUndoLayoutRTL( &rDocShell, nTab, bRTL ) );
[ + - ][ + - ]
2930 : : }
2931 : :
2932 [ + - ]: 8 : rDocShell.PostPaint( 0,0,0,MAXCOL,MAXROW,MAXTAB, PAINT_ALL );
2933 [ + - ]: 8 : aModificator.SetDocumentModified();
2934 : :
2935 [ + - ]: 8 : SfxBindings* pBindings = rDocShell.GetViewBindings();
2936 [ + - ]: 8 : if (pBindings)
2937 : : {
2938 [ + - ]: 8 : pBindings->Invalidate( FID_TAB_RTL );
2939 [ + - ]: 8 : pBindings->Invalidate( SID_ATTR_SIZE );
2940 : : }
2941 : :
2942 [ + - ]: 217 : return sal_True;
2943 : : }
2944 : :
2945 : 11 : sal_Bool ScDocFunc::RenameTable( SCTAB nTab, const String& rName, sal_Bool bRecord, sal_Bool bApi )
2946 : : {
2947 : 11 : ScDocument* pDoc = rDocShell.GetDocument();
2948 [ - + ][ - + ]: 11 : if (bRecord && !pDoc->IsUndoEnabled())
[ + + ]
2949 : 0 : bRecord = false;
2950 [ + - ][ + + ]: 11 : if ( !pDoc->IsDocEditable() )
2951 : : {
2952 [ - + ]: 9 : if (!bApi)
2953 [ # # ]: 0 : rDocShell.ErrorMessage(STR_PROTECTIONERR);
2954 : 9 : return false;
2955 : : }
2956 : :
2957 [ + - ]: 2 : ScDocShellModificator aModificator( rDocShell );
2958 : :
2959 : 2 : sal_Bool bSuccess = false;
2960 : 2 : rtl::OUString sOldName;
2961 [ + - ]: 2 : pDoc->GetName(nTab, sOldName);
2962 [ + - ][ + - ]: 2 : if (pDoc->RenameTab( nTab, rName ))
[ + - ]
2963 : : {
2964 [ + - ]: 2 : if (bRecord)
2965 : : {
2966 [ + - ]: 2 : rDocShell.GetUndoManager()->AddUndoAction(
2967 [ + - ][ + - ]: 2 : new ScUndoRenameTab( &rDocShell, nTab, sOldName, rName));
[ + - ][ + - ]
[ + - ]
2968 : : }
2969 [ + - ]: 2 : rDocShell.PostPaintExtras();
2970 [ + - ]: 2 : aModificator.SetDocumentModified();
2971 [ + - ][ + - ]: 2 : SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
[ + - ][ + - ]
2972 : :
2973 : 2 : bSuccess = sal_True;
2974 : : }
2975 [ + - ]: 11 : return bSuccess;
2976 : : }
2977 : :
2978 : 6 : bool ScDocFunc::SetTabBgColor( SCTAB nTab, const Color& rColor, bool bRecord, bool bApi )
2979 : : {
2980 : :
2981 : 6 : ScDocument* pDoc = rDocShell.GetDocument();
2982 [ # # ][ - + ]: 6 : if (bRecord && !pDoc->IsUndoEnabled())
[ - + ]
2983 : 0 : bRecord = false;
2984 [ + - ][ - + ]: 6 : if ( !pDoc->IsDocEditable() || pDoc->IsTabProtected(nTab) )
[ # # ][ # # ]
[ + - ]
2985 : : {
2986 [ - + ]: 6 : if (!bApi)
2987 [ # # ]: 0 : rDocShell.ErrorMessage(STR_PROTECTIONERR); //TODO Check to see what this string is...
2988 : 6 : return false;
2989 : : }
2990 : :
2991 : 0 : Color aOldTabBgColor;
2992 [ # # ]: 0 : aOldTabBgColor = pDoc->GetTabBgColor(nTab);
2993 : :
2994 : 0 : bool bSuccess = false;
2995 [ # # ]: 0 : pDoc->SetTabBgColor(nTab, rColor);
2996 [ # # ][ # # ]: 0 : if ( pDoc->GetTabBgColor(nTab) == rColor)
2997 : 0 : bSuccess = true;
2998 [ # # ]: 0 : if (bSuccess)
2999 : : {
3000 [ # # ]: 0 : if (bRecord)
3001 : : {
3002 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
3003 [ # # ][ # # ]: 0 : new ScUndoTabColor( &rDocShell, nTab, aOldTabBgColor, rColor));
[ # # ]
3004 : : }
3005 [ # # ]: 0 : rDocShell.PostPaintExtras();
3006 [ # # ]: 0 : ScDocShellModificator aModificator( rDocShell );
3007 [ # # ]: 0 : aModificator.SetDocumentModified();
3008 [ # # ][ # # ]: 0 : SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
[ # # ][ # # ]
3009 : :
3010 [ # # ]: 0 : bSuccess = true;
3011 : : }
3012 : 6 : return bSuccess;
3013 : : }
3014 : :
3015 : 0 : bool ScDocFunc::SetTabBgColor(
3016 : : ScUndoTabColorInfo::List& rUndoTabColorList, bool bRecord, bool bApi )
3017 : : {
3018 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
3019 [ # # ][ # # ]: 0 : if (bRecord && !pDoc->IsUndoEnabled())
[ # # ]
3020 : 0 : bRecord = false;
3021 : :
3022 [ # # ][ # # ]: 0 : if ( !pDoc->IsDocEditable() )
3023 : : {
3024 [ # # ]: 0 : if (!bApi)
3025 [ # # ]: 0 : rDocShell.ErrorMessage(STR_PROTECTIONERR); //TODO Get a better String Error...
3026 : 0 : return false;
3027 : : }
3028 : :
3029 : : sal_uInt16 nTab;
3030 : 0 : Color aNewTabBgColor;
3031 : 0 : bool bSuccess = true;
3032 : 0 : size_t nTabProtectCount = 0;
3033 : 0 : size_t nTabListCount = rUndoTabColorList.size();
3034 [ # # ]: 0 : for ( size_t i = 0; i < nTabListCount; ++i )
3035 : : {
3036 : 0 : ScUndoTabColorInfo& rInfo = rUndoTabColorList[i];
3037 : 0 : nTab = rInfo.mnTabId;
3038 [ # # ][ # # ]: 0 : if ( !pDoc->IsTabProtected(nTab) )
3039 : : {
3040 : 0 : aNewTabBgColor = rInfo.maNewTabBgColor;
3041 [ # # ]: 0 : rInfo.maOldTabBgColor = pDoc->GetTabBgColor(nTab);
3042 [ # # ]: 0 : pDoc->SetTabBgColor(nTab, aNewTabBgColor);
3043 [ # # ][ # # ]: 0 : if ( pDoc->GetTabBgColor(nTab) != aNewTabBgColor)
3044 : : {
3045 : 0 : bSuccess = false;
3046 : 0 : break;
3047 : : }
3048 : : }
3049 : : else
3050 : : {
3051 : 0 : nTabProtectCount++;
3052 : : }
3053 : : }
3054 : :
3055 [ # # ]: 0 : if ( nTabProtectCount == nTabListCount )
3056 : : {
3057 [ # # ]: 0 : if (!bApi)
3058 [ # # ]: 0 : rDocShell.ErrorMessage(STR_PROTECTIONERR); //TODO Get a better String Error...
3059 : 0 : return false;
3060 : : }
3061 : :
3062 [ # # ]: 0 : if (bSuccess)
3063 : : {
3064 [ # # ]: 0 : if (bRecord)
3065 : : {
3066 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
3067 [ # # ][ # # ]: 0 : new ScUndoTabColor( &rDocShell, rUndoTabColorList));
[ # # ]
3068 : : }
3069 [ # # ]: 0 : rDocShell.PostPaintExtras();
3070 [ # # ]: 0 : ScDocShellModificator aModificator( rDocShell );
3071 [ # # ][ # # ]: 0 : aModificator.SetDocumentModified();
3072 : : }
3073 : 0 : return bSuccess;
3074 : : }
3075 : :
3076 : : //------------------------------------------------------------------------
3077 : :
3078 : : //! SetWidthOrHeight - noch doppelt zu ViewFunc !!!!!!
3079 : : //! Probleme:
3080 : : //! - Optimale Hoehe fuer Edit-Zellen ist unterschiedlich zwischen Drucker und Bildschirm
3081 : : //! - Optimale Breite braucht Selektion, um evtl. nur selektierte Zellen zu beruecksichtigen
3082 : :
3083 : 4 : sal_uInt16 lcl_GetOptimalColWidth( ScDocShell& rDocShell, SCCOL nCol, SCTAB nTab, sal_Bool bFormula )
3084 : : {
3085 : 4 : sal_uInt16 nTwips = 0;
3086 : :
3087 [ + - ]: 4 : ScSizeDeviceProvider aProv(&rDocShell);
3088 : 4 : OutputDevice* pDev = aProv.GetDevice(); // has pixel MapMode
3089 : 4 : double nPPTX = aProv.GetPPTX();
3090 : 4 : double nPPTY = aProv.GetPPTY();
3091 : :
3092 : 4 : ScDocument* pDoc = rDocShell.GetDocument();
3093 [ + - ]: 4 : Fraction aOne(1,1);
3094 : : nTwips = pDoc->GetOptimalColWidth( nCol, nTab, pDev, nPPTX, nPPTY, aOne, aOne,
3095 [ + - ]: 4 : bFormula, NULL );
3096 : :
3097 [ + - ]: 4 : return nTwips;
3098 : : }
3099 : :
3100 : 948 : sal_Bool ScDocFunc::SetWidthOrHeight( sal_Bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRanges, SCTAB nTab,
3101 : : ScSizeMode eMode, sal_uInt16 nSizeTwips,
3102 : : sal_Bool bRecord, sal_Bool bApi )
3103 : : {
3104 [ + - ]: 948 : ScDocShellModificator aModificator( rDocShell );
3105 : :
3106 [ - + ]: 948 : if (!nRangeCnt)
3107 : 0 : return sal_True;
3108 : :
3109 : 948 : ScDocument* pDoc = rDocShell.GetDocument();
3110 [ + + ][ + + ]: 948 : if ( bRecord && !pDoc->IsUndoEnabled() )
[ + - ]
3111 : 942 : bRecord = false;
3112 : :
3113 : : // import into read-only document is possible
3114 [ + + ][ + - ]: 948 : if ( !pDoc->IsChangeReadOnlyEnabled() && !rDocShell.IsEditable() )
[ - + ][ - + ]
3115 : : {
3116 [ # # ]: 0 : if (!bApi)
3117 [ # # ]: 0 : rDocShell.ErrorMessage(STR_PROTECTIONERR); //! eigene Meldung?
3118 : 0 : return false;
3119 : : }
3120 : :
3121 : 948 : sal_Bool bSuccess = false;
3122 : 948 : SCCOLROW nStart = pRanges[0];
3123 : 948 : SCCOLROW nEnd = pRanges[2*nRangeCnt-1];
3124 : :
3125 : 948 : sal_Bool bFormula = false;
3126 : : if ( eMode == SC_SIZE_OPTIMAL )
3127 : : {
3128 : : //! Option "Formeln anzeigen" - woher nehmen?
3129 : : }
3130 : :
3131 : 948 : ScDocument* pUndoDoc = NULL;
3132 : 948 : ScOutlineTable* pUndoTab = NULL;
3133 : 948 : SCCOLROW* pUndoRanges = NULL;
3134 : :
3135 [ + + ]: 948 : if ( bRecord )
3136 : : {
3137 [ + - ]: 6 : pDoc->BeginDrawUndo(); // Drawing Updates
3138 : :
3139 [ + - ][ + - ]: 6 : pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
3140 [ + + ]: 6 : if (bWidth)
3141 : : {
3142 [ + - ]: 4 : pUndoDoc->InitUndo( pDoc, nTab, nTab, sal_True, false );
3143 [ + - ]: 4 : pDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab, static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, false, pUndoDoc );
3144 : : }
3145 : : else
3146 : : {
3147 [ + - ]: 2 : pUndoDoc->InitUndo( pDoc, nTab, nTab, false, sal_True );
3148 [ + - ]: 2 : pDoc->CopyToDocument( 0, static_cast<SCROW>(nStart), nTab, MAXCOL, static_cast<SCROW>(nEnd), nTab, IDF_NONE, false, pUndoDoc );
3149 : : }
3150 : :
3151 [ + - ]: 6 : pUndoRanges = new SCCOLROW[ 2*nRangeCnt ];
3152 : 6 : memmove( pUndoRanges, pRanges, 2*nRangeCnt*sizeof(SCCOLROW) );
3153 : :
3154 [ + - ]: 6 : ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
3155 [ - + ]: 6 : if (pTable)
3156 [ # # ][ # # ]: 0 : pUndoTab = new ScOutlineTable( *pTable );
3157 : : }
3158 : :
3159 [ + + ][ + + ]: 948 : sal_Bool bShow = nSizeTwips > 0 || eMode != SC_SIZE_DIRECT;
3160 : 948 : sal_Bool bOutline = false;
3161 : :
3162 [ + - ]: 948 : pDoc->InitializeNoteCaptions(nTab);
3163 [ + + ]: 1896 : for (SCCOLROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
3164 : : {
3165 : 948 : SCCOLROW nStartNo = *(pRanges++);
3166 : 948 : SCCOLROW nEndNo = *(pRanges++);
3167 : :
3168 [ + + ]: 948 : if ( !bWidth ) // Hoehen immer blockweise
3169 : : {
3170 [ + - ][ - + ]: 199 : if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT )
3171 : : {
3172 : 0 : sal_Bool bAll = ( eMode==SC_SIZE_OPTIMAL );
3173 [ # # ]: 0 : if (!bAll)
3174 : : {
3175 : : // fuer alle eingeblendeten CR_MANUALSIZE loeschen,
3176 : : // dann SetOptimalHeight mit bShrink = FALSE
3177 [ # # ]: 0 : for (SCROW nRow=nStartNo; nRow<=nEndNo; nRow++)
3178 : : {
3179 [ # # ]: 0 : sal_uInt8 nOld = pDoc->GetRowFlags(nRow,nTab);
3180 : 0 : SCROW nLastRow = -1;
3181 [ # # ]: 0 : bool bHidden = pDoc->RowHidden(nRow, nTab, NULL, &nLastRow);
3182 [ # # ][ # # ]: 0 : if ( !bHidden && ( nOld & CR_MANUALSIZE ) )
3183 [ # # ]: 0 : pDoc->SetRowFlags( nRow, nTab, nOld & ~CR_MANUALSIZE );
3184 : : }
3185 : : }
3186 : :
3187 [ # # ]: 0 : ScSizeDeviceProvider aProv( &rDocShell );
3188 [ # # ]: 0 : Fraction aOne(1,1);
3189 : : pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, 0, aProv.GetDevice(),
3190 [ # # ]: 0 : aProv.GetPPTX(), aProv.GetPPTY(), aOne, aOne, bAll );
3191 : :
3192 [ # # ]: 0 : if (bAll)
3193 [ # # ][ # # ]: 0 : pDoc->ShowRows( nStartNo, nEndNo, nTab, sal_True );
3194 : :
3195 : : // Manual-Flag wird bei bAll=sal_True schon in SetOptimalHeight gesetzt
3196 : : // (an bei Extra-Height, sonst aus).
3197 : : }
3198 [ + + ][ + + ]: 199 : else if ( eMode==SC_SIZE_DIRECT || eMode==SC_SIZE_ORIGINAL )
3199 : : {
3200 [ + + ]: 198 : if (nSizeTwips)
3201 : : {
3202 [ + - ]: 165 : pDoc->SetRowHeightRange( nStartNo, nEndNo, nTab, nSizeTwips );
3203 [ + - ]: 165 : pDoc->SetManualHeight( nStartNo, nEndNo, nTab, sal_True ); // height was set manually
3204 : : }
3205 [ + + ]: 231 : if ( eMode != SC_SIZE_ORIGINAL )
3206 [ + - ]: 33 : pDoc->ShowRows( nStartNo, nEndNo, nTab, nSizeTwips != 0 );
3207 : : }
3208 [ + - ]: 1 : else if ( eMode==SC_SIZE_SHOW )
3209 : : {
3210 [ + - ]: 199 : pDoc->ShowRows( nStartNo, nEndNo, nTab, sal_True );
3211 : : }
3212 : : }
3213 : : else // Spaltenbreiten
3214 : : {
3215 [ + + ]: 67063 : for (SCCOL nCol=static_cast<SCCOL>(nStartNo); nCol<=static_cast<SCCOL>(nEndNo); nCol++)
3216 : : {
3217 [ - + ][ # # ]: 66314 : if ( eMode != SC_SIZE_VISOPT || !pDoc->ColHidden(nCol, nTab) )
[ # # ][ + - ]
3218 : : {
3219 : 66314 : sal_uInt16 nThisSize = nSizeTwips;
3220 : :
3221 [ + + ][ - + ]: 66314 : if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT )
3222 : : nThisSize = nSizeTwips +
3223 [ + - ]: 4 : lcl_GetOptimalColWidth( rDocShell, nCol, nTab, bFormula );
3224 [ + + ]: 66314 : if ( nThisSize )
3225 [ + - ]: 63879 : pDoc->SetColWidth( nCol, nTab, nThisSize );
3226 : :
3227 [ + + ]: 66314 : if ( eMode != SC_SIZE_ORIGINAL )
3228 [ + - ]: 2439 : pDoc->ShowCol( nCol, nTab, bShow );
3229 : : }
3230 : : }
3231 : : }
3232 : :
3233 : : // adjust outlines
3234 : :
3235 [ + + ]: 948 : if ( eMode != SC_SIZE_ORIGINAL )
3236 : : {
3237 [ + + ]: 367 : if (bWidth)
3238 : : bOutline = bOutline || pDoc->UpdateOutlineCol(
3239 : : static_cast<SCCOL>(nStartNo),
3240 [ + - ][ + - ]: 333 : static_cast<SCCOL>(nEndNo), nTab, bShow );
[ - + ]
3241 : : else
3242 : : bOutline = bOutline || pDoc->UpdateOutlineRow(
3243 : : static_cast<SCROW>(nStartNo),
3244 [ + - ][ + - ]: 34 : static_cast<SCROW>(nEndNo), nTab, bShow );
[ - + ]
3245 : : }
3246 : : }
3247 [ + - ]: 948 : pDoc->SetDrawPageSize(nTab);
3248 : :
3249 [ + - ]: 948 : if (!bOutline)
3250 [ - + ][ # # ]: 948 : DELETEZ(pUndoTab);
3251 : :
3252 [ + + ]: 948 : if (bRecord)
3253 : : {
3254 [ + - ]: 6 : ScMarkData aMark;
3255 [ + - ]: 6 : aMark.SelectOneTable( nTab );
3256 [ + - ]: 6 : rDocShell.GetUndoManager()->AddUndoAction(
3257 : : new ScUndoWidthOrHeight( &rDocShell, aMark,
3258 : : nStart, nTab, nEnd, nTab,
3259 : : pUndoDoc, nRangeCnt, pUndoRanges,
3260 [ + - ][ + - ]: 6 : pUndoTab, eMode, nSizeTwips, bWidth ) );
[ + - ][ + - ]
3261 : : }
3262 : :
3263 [ + - ]: 948 : pDoc->UpdatePageBreaks( nTab );
3264 : :
3265 [ + - ]: 948 : rDocShell.PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_ALL);
3266 [ + - ]: 948 : aModificator.SetDocumentModified();
3267 : :
3268 [ + - ]: 948 : return bSuccess;
3269 : : }
3270 : :
3271 : :
3272 : 0 : sal_Bool ScDocFunc::InsertPageBreak( sal_Bool bColumn, const ScAddress& rPos,
3273 : : sal_Bool bRecord, sal_Bool bSetModified, sal_Bool /* bApi */ )
3274 : : {
3275 [ # # ]: 0 : ScDocShellModificator aModificator( rDocShell );
3276 : :
3277 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
3278 [ # # ][ # # ]: 0 : if (bRecord && !pDoc->IsUndoEnabled())
[ # # ]
3279 : 0 : bRecord = false;
3280 : 0 : SCTAB nTab = rPos.Tab();
3281 [ # # ]: 0 : SfxBindings* pBindings = rDocShell.GetViewBindings();
3282 : :
3283 : 0 : SCCOLROW nPos = bColumn ? static_cast<SCCOLROW>(rPos.Col()) :
3284 [ # # ]: 0 : static_cast<SCCOLROW>(rPos.Row());
3285 [ # # ]: 0 : if (nPos == 0)
3286 : 0 : return false; // erste Spalte / Zeile
3287 : :
3288 : : ScBreakType nBreak = bColumn ?
3289 : 0 : pDoc->HasColBreak(static_cast<SCCOL>(nPos), nTab) :
3290 [ # # ][ # # ]: 0 : pDoc->HasRowBreak(static_cast<SCROW>(nPos), nTab);
[ # # ]
3291 [ # # ]: 0 : if (nBreak & BREAK_MANUAL)
3292 : 0 : return true;
3293 : :
3294 [ # # ]: 0 : if (bRecord)
3295 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
3296 [ # # ][ # # ]: 0 : new ScUndoPageBreak( &rDocShell, rPos.Col(), rPos.Row(), nTab, bColumn, sal_True ) );
[ # # ]
3297 : :
3298 [ # # ]: 0 : if (bColumn)
3299 [ # # ]: 0 : pDoc->SetColBreak(static_cast<SCCOL>(nPos), nTab, false, true);
3300 : : else
3301 [ # # ]: 0 : pDoc->SetRowBreak(static_cast<SCROW>(nPos), nTab, false, true);
3302 : :
3303 [ # # ]: 0 : pDoc->InvalidatePageBreaks(nTab);
3304 [ # # ]: 0 : pDoc->UpdatePageBreaks( nTab );
3305 : :
3306 [ # # ][ # # ]: 0 : if (pDoc->IsStreamValid(nTab))
3307 [ # # ]: 0 : pDoc->SetStreamValid(nTab, false);
3308 : :
3309 [ # # ]: 0 : if (bColumn)
3310 : : {
3311 [ # # ]: 0 : rDocShell.PostPaint( static_cast<SCCOL>(nPos)-1, 0, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID );
3312 [ # # ]: 0 : if (pBindings)
3313 : : {
3314 [ # # ]: 0 : pBindings->Invalidate( FID_INS_COLBRK );
3315 [ # # ]: 0 : pBindings->Invalidate( FID_DEL_COLBRK );
3316 : : }
3317 : : }
3318 : : else
3319 : : {
3320 [ # # ]: 0 : rDocShell.PostPaint( 0, static_cast<SCROW>(nPos)-1, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID );
3321 [ # # ]: 0 : if (pBindings)
3322 : : {
3323 [ # # ]: 0 : pBindings->Invalidate( FID_INS_ROWBRK );
3324 [ # # ]: 0 : pBindings->Invalidate( FID_DEL_ROWBRK );
3325 : : }
3326 : : }
3327 [ # # ]: 0 : if (pBindings)
3328 [ # # ]: 0 : pBindings->Invalidate( FID_DEL_MANUALBREAKS );
3329 : :
3330 [ # # ]: 0 : if (bSetModified)
3331 [ # # ]: 0 : aModificator.SetDocumentModified();
3332 : :
3333 [ # # ]: 0 : return sal_True;
3334 : : }
3335 : :
3336 : 2435 : sal_Bool ScDocFunc::RemovePageBreak( sal_Bool bColumn, const ScAddress& rPos,
3337 : : sal_Bool bRecord, sal_Bool bSetModified, sal_Bool /* bApi */ )
3338 : : {
3339 [ + - ]: 2435 : ScDocShellModificator aModificator( rDocShell );
3340 : :
3341 : 2435 : ScDocument* pDoc = rDocShell.GetDocument();
3342 [ + - ][ + - ]: 2435 : if (bRecord && !pDoc->IsUndoEnabled())
[ + - ]
3343 : 2435 : bRecord = false;
3344 : 2435 : SCTAB nTab = rPos.Tab();
3345 [ + - ]: 2435 : SfxBindings* pBindings = rDocShell.GetViewBindings();
3346 : :
3347 : 2435 : SCCOLROW nPos = bColumn ? static_cast<SCCOLROW>(rPos.Col()) :
3348 [ + - ]: 4870 : static_cast<SCCOLROW>(rPos.Row());
3349 : :
3350 : : ScBreakType nBreak;
3351 [ + - ]: 2435 : if (bColumn)
3352 [ + - ]: 2435 : nBreak = pDoc->HasColBreak(static_cast<SCCOL>(nPos), nTab);
3353 : : else
3354 [ # # ]: 0 : nBreak = pDoc->HasRowBreak(static_cast<SCROW>(nPos), nTab);
3355 [ + - ]: 2435 : if ((nBreak & BREAK_MANUAL) == 0)
3356 : : // There is no manual break.
3357 : 2435 : return false;
3358 : :
3359 [ # # ]: 0 : if (bRecord)
3360 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
3361 [ # # ][ # # ]: 0 : new ScUndoPageBreak( &rDocShell, rPos.Col(), rPos.Row(), nTab, bColumn, false ) );
[ # # ]
3362 : :
3363 [ # # ]: 0 : if (bColumn)
3364 [ # # ]: 0 : pDoc->RemoveColBreak(static_cast<SCCOL>(nPos), nTab, false, true);
3365 : : else
3366 [ # # ]: 0 : pDoc->RemoveRowBreak(static_cast<SCROW>(nPos), nTab, false, true);
3367 : :
3368 [ # # ]: 0 : pDoc->UpdatePageBreaks( nTab );
3369 : :
3370 [ # # ][ # # ]: 0 : if (pDoc->IsStreamValid(nTab))
3371 [ # # ]: 0 : pDoc->SetStreamValid(nTab, false);
3372 : :
3373 [ # # ]: 0 : if (bColumn)
3374 : : {
3375 [ # # ]: 0 : rDocShell.PostPaint( static_cast<SCCOL>(nPos)-1, 0, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID );
3376 [ # # ]: 0 : if (pBindings)
3377 : : {
3378 [ # # ]: 0 : pBindings->Invalidate( FID_INS_COLBRK );
3379 [ # # ]: 0 : pBindings->Invalidate( FID_DEL_COLBRK );
3380 : : }
3381 : : }
3382 : : else
3383 : : {
3384 [ # # ]: 0 : rDocShell.PostPaint( 0, nPos-1, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID );
3385 [ # # ]: 0 : if (pBindings)
3386 : : {
3387 [ # # ]: 0 : pBindings->Invalidate( FID_INS_ROWBRK );
3388 [ # # ]: 0 : pBindings->Invalidate( FID_DEL_ROWBRK );
3389 : : }
3390 : : }
3391 [ # # ]: 0 : if (pBindings)
3392 [ # # ]: 0 : pBindings->Invalidate( FID_DEL_MANUALBREAKS );
3393 : :
3394 [ # # ]: 0 : if (bSetModified)
3395 [ # # ]: 0 : aModificator.SetDocumentModified();
3396 : :
3397 [ + - ]: 2435 : return sal_True;
3398 : : }
3399 : :
3400 : : //------------------------------------------------------------------------
3401 : :
3402 : 0 : void ScDocFunc::ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect )
3403 : : {
3404 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
3405 : :
3406 [ # # ]: 0 : pDoc->SetTabProtection(nTab, &rProtect);
3407 [ # # ]: 0 : if (pDoc->IsUndoEnabled())
3408 : : {
3409 [ # # ]: 0 : ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
3410 : : OSL_ENSURE(pProtect, "ScDocFunc::Unprotect: ScTableProtection pointer is NULL!");
3411 [ # # ]: 0 : if (pProtect)
3412 : : {
3413 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
3414 [ # # ][ # # ]: 0 : ::std::auto_ptr<ScTableProtection> p(new ScTableProtection(*pProtect));
3415 : : SAL_WNODEPRECATED_DECLARATIONS_POP
3416 [ # # ]: 0 : p->setProtected(true); // just in case ...
3417 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
3418 [ # # ][ # # ]: 0 : new ScUndoTabProtect(&rDocShell, nTab, p) );
[ # # ][ # # ]
[ # # ]
3419 : :
3420 : : // ownership of auto_ptr now transferred to ScUndoTabProtect.
3421 : : }
3422 : : }
3423 : :
3424 [ # # ]: 0 : rDocShell.PostPaintGridAll();
3425 [ # # ]: 0 : ScDocShellModificator aModificator(rDocShell);
3426 [ # # ][ # # ]: 0 : aModificator.SetDocumentModified();
3427 : 0 : }
3428 : :
3429 : 1 : sal_Bool ScDocFunc::Protect( SCTAB nTab, const String& rPassword, sal_Bool /*bApi*/ )
3430 : : {
3431 : 1 : ScDocument* pDoc = rDocShell.GetDocument();
3432 [ + - ]: 1 : if (nTab == TABLEID_DOC)
3433 : : {
3434 : : // document protection
3435 [ + - ]: 1 : ScDocProtection aProtection;
3436 [ + - ]: 1 : aProtection.setProtected(true);
3437 [ + - ]: 1 : aProtection.setPassword(rPassword);
3438 [ + - ]: 1 : pDoc->SetDocProtection(&aProtection);
3439 [ + - ]: 1 : if (pDoc->IsUndoEnabled())
3440 : : {
3441 [ + - ]: 1 : ScDocProtection* pProtect = pDoc->GetDocProtection();
3442 : : OSL_ENSURE(pProtect, "ScDocFunc::Unprotect: ScDocProtection pointer is NULL!");
3443 [ + - ]: 1 : if (pProtect)
3444 : : {
3445 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
3446 [ + - ][ + - ]: 1 : ::std::auto_ptr<ScDocProtection> p(new ScDocProtection(*pProtect));
3447 : : SAL_WNODEPRECATED_DECLARATIONS_POP
3448 [ + - ]: 1 : p->setProtected(true); // just in case ...
3449 [ + - ]: 1 : rDocShell.GetUndoManager()->AddUndoAction(
3450 [ + - ][ + - ]: 1 : new ScUndoDocProtect(&rDocShell, p) );
[ + - ][ + - ]
[ + - ]
3451 : : // ownership of auto_ptr is transferred to ScUndoDocProtect.
3452 : : }
3453 [ + - ]: 1 : }
3454 : : }
3455 : : else
3456 : : {
3457 : : // sheet protection
3458 : :
3459 [ # # ]: 0 : ScTableProtection aProtection;
3460 [ # # ]: 0 : aProtection.setProtected(true);
3461 [ # # ]: 0 : aProtection.setPassword(rPassword);
3462 [ # # ]: 0 : pDoc->SetTabProtection(nTab, &aProtection);
3463 [ # # ]: 0 : if (pDoc->IsUndoEnabled())
3464 : : {
3465 [ # # ]: 0 : ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
3466 : : OSL_ENSURE(pProtect, "ScDocFunc::Unprotect: ScTableProtection pointer is NULL!");
3467 [ # # ]: 0 : if (pProtect)
3468 : : {
3469 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
3470 [ # # ][ # # ]: 0 : ::std::auto_ptr<ScTableProtection> p(new ScTableProtection(*pProtect));
3471 : : SAL_WNODEPRECATED_DECLARATIONS_POP
3472 [ # # ]: 0 : p->setProtected(true); // just in case ...
3473 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
3474 [ # # ][ # # ]: 0 : new ScUndoTabProtect(&rDocShell, nTab, p) );
[ # # ][ # # ]
[ # # ]
3475 : : // ownership of auto_ptr now transferred to ScUndoTabProtect.
3476 : : }
3477 [ # # ]: 0 : }
3478 : : }
3479 : :
3480 [ + - ]: 1 : rDocShell.PostPaintGridAll();
3481 [ + - ]: 1 : ScDocShellModificator aModificator( rDocShell );
3482 [ + - ]: 1 : aModificator.SetDocumentModified();
3483 : :
3484 [ + - ]: 1 : return true;
3485 : : }
3486 : :
3487 : 2 : sal_Bool ScDocFunc::Unprotect( SCTAB nTab, const String& rPassword, sal_Bool bApi )
3488 : : {
3489 : 2 : ScDocument* pDoc = rDocShell.GetDocument();
3490 : :
3491 [ + - ]: 2 : if (nTab == TABLEID_DOC)
3492 : : {
3493 : : // document protection
3494 : :
3495 [ + - ]: 2 : ScDocProtection* pDocProtect = pDoc->GetDocProtection();
3496 [ + - ][ + - ]: 2 : if (!pDocProtect || !pDocProtect->isProtected())
[ - + ][ - + ]
3497 : : // already unprotected (should not happen)!
3498 : 0 : return true;
3499 : :
3500 : : // save the protection state before unprotect (for undo).
3501 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
3502 [ + - ][ + - ]: 2 : ::std::auto_ptr<ScDocProtection> pProtectCopy(new ScDocProtection(*pDocProtect));
3503 : : SAL_WNODEPRECATED_DECLARATIONS_POP
3504 : :
3505 [ + + ][ + - ]: 2 : if (!pDocProtect->verifyPassword(rPassword))
3506 : : {
3507 [ - + ]: 1 : if (!bApi)
3508 : : {
3509 [ # # ][ # # ]: 0 : InfoBox aBox( rDocShell.GetActiveDialogParent(), String( ScResId( SCSTR_WRONGPASSWORD ) ) );
[ # # ][ # # ]
[ # # ]
3510 [ # # ][ # # ]: 0 : aBox.Execute();
3511 : : }
3512 : 1 : return false;
3513 : : }
3514 : :
3515 [ + - ]: 1 : pDoc->SetDocProtection(NULL);
3516 [ + - ]: 1 : if (pDoc->IsUndoEnabled())
3517 : : {
3518 [ + - ]: 1 : pProtectCopy->setProtected(false);
3519 [ + - ]: 1 : rDocShell.GetUndoManager()->AddUndoAction(
3520 [ + - ][ + - ]: 1 : new ScUndoDocProtect(&rDocShell, pProtectCopy) );
[ + - ][ + - ]
3521 : : // ownership of auto_ptr now transferred to ScUndoDocProtect.
3522 [ + - ][ + + ]: 2 : }
3523 : : }
3524 : : else
3525 : : {
3526 : : // sheet protection
3527 : :
3528 [ # # ]: 0 : ScTableProtection* pTabProtect = pDoc->GetTabProtection(nTab);
3529 [ # # ][ # # ]: 0 : if (!pTabProtect || !pTabProtect->isProtected())
[ # # ][ # # ]
3530 : : // already unprotected (should not happen)!
3531 : 0 : return true;
3532 : :
3533 : : // save the protection state before unprotect (for undo).
3534 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
3535 [ # # ][ # # ]: 0 : ::std::auto_ptr<ScTableProtection> pProtectCopy(new ScTableProtection(*pTabProtect));
3536 : : SAL_WNODEPRECATED_DECLARATIONS_POP
3537 [ # # ][ # # ]: 0 : if (!pTabProtect->verifyPassword(rPassword))
3538 : : {
3539 [ # # ]: 0 : if (!bApi)
3540 : : {
3541 [ # # ][ # # ]: 0 : InfoBox aBox( rDocShell.GetActiveDialogParent(), String( ScResId( SCSTR_WRONGPASSWORD ) ) );
[ # # ][ # # ]
[ # # ]
3542 [ # # ][ # # ]: 0 : aBox.Execute();
3543 : : }
3544 : 0 : return false;
3545 : : }
3546 : :
3547 [ # # ]: 0 : pDoc->SetTabProtection(nTab, NULL);
3548 [ # # ]: 0 : if (pDoc->IsUndoEnabled())
3549 : : {
3550 [ # # ]: 0 : pProtectCopy->setProtected(false);
3551 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
3552 [ # # ][ # # ]: 0 : new ScUndoTabProtect(&rDocShell, nTab, pProtectCopy) );
[ # # ][ # # ]
3553 : : // ownership of auto_ptr now transferred to ScUndoTabProtect.
3554 [ # # ][ # # ]: 0 : }
3555 : : }
3556 : :
3557 [ + - ]: 1 : rDocShell.PostPaintGridAll();
3558 [ + - ]: 1 : ScDocShellModificator aModificator( rDocShell );
3559 [ + - ]: 1 : aModificator.SetDocumentModified();
3560 : :
3561 [ + - ]: 2 : return true;
3562 : : }
3563 : :
3564 : : //------------------------------------------------------------------------
3565 : :
3566 : 0 : sal_Bool ScDocFunc::ClearItems( const ScMarkData& rMark, const sal_uInt16* pWhich, sal_Bool bApi )
3567 : : {
3568 [ # # ]: 0 : ScDocShellModificator aModificator( rDocShell );
3569 : :
3570 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
3571 : 0 : bool bUndo (pDoc->IsUndoEnabled());
3572 [ # # ]: 0 : ScEditableTester aTester( pDoc, rMark );
3573 [ # # ]: 0 : if (!aTester.IsEditable())
3574 : : {
3575 [ # # ]: 0 : if (!bApi)
3576 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
3577 : 0 : return false;
3578 : : }
3579 : :
3580 : : // #i12940# ClearItems is called (from setPropertyToDefault) directly with uno object's cached
3581 : : // MarkData (GetMarkData), so rMark must be changed to multi selection for ClearSelectionItems
3582 : : // here.
3583 : :
3584 : 0 : ScRange aMarkRange;
3585 [ # # ]: 0 : ScMarkData aMultiMark = rMark;
3586 : 0 : aMultiMark.SetMarking(false); // for MarkToMulti
3587 [ # # ]: 0 : aMultiMark.MarkToMulti();
3588 [ # # ]: 0 : aMultiMark.GetMultiMarkArea( aMarkRange );
3589 : :
3590 [ # # ]: 0 : if (bUndo)
3591 : : {
3592 : 0 : SCTAB nStartTab = aMarkRange.aStart.Tab();
3593 : 0 : SCTAB nEndTab = aMarkRange.aEnd.Tab();
3594 : :
3595 [ # # ][ # # ]: 0 : ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
3596 [ # # ]: 0 : pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab );
3597 [ # # ]: 0 : pDoc->CopyToDocument( aMarkRange, IDF_ATTRIB, sal_True, pUndoDoc, (ScMarkData*)&aMultiMark );
3598 : :
3599 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
3600 [ # # ][ # # ]: 0 : new ScUndoClearItems( &rDocShell, aMultiMark, pUndoDoc, pWhich ) );
[ # # ]
3601 : : }
3602 : :
3603 [ # # ]: 0 : pDoc->ClearSelectionItems( pWhich, aMultiMark );
3604 : :
3605 [ # # ][ # # ]: 0 : rDocShell.PostPaint( aMarkRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
[ # # ]
3606 [ # # ]: 0 : aModificator.SetDocumentModified();
3607 : :
3608 : : //! Bindings-Invalidate etc.?
3609 : :
3610 [ # # ][ # # ]: 0 : return sal_True;
3611 : : }
3612 : :
3613 : 8 : sal_Bool ScDocFunc::ChangeIndent( const ScMarkData& rMark, sal_Bool bIncrement, sal_Bool bApi )
3614 : : {
3615 [ + - ]: 8 : ScDocShellModificator aModificator( rDocShell );
3616 : :
3617 : 8 : ScDocument* pDoc = rDocShell.GetDocument();
3618 : 8 : bool bUndo(pDoc->IsUndoEnabled());
3619 [ + - ]: 8 : ScEditableTester aTester( pDoc, rMark );
3620 [ - + ]: 8 : if (!aTester.IsEditable())
3621 : : {
3622 [ # # ]: 0 : if (!bApi)
3623 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
3624 : 0 : return false;
3625 : : }
3626 : :
3627 : 8 : ScRange aMarkRange;
3628 [ + - ]: 8 : rMark.GetMultiMarkArea( aMarkRange );
3629 : :
3630 [ + - ]: 8 : if (bUndo)
3631 : : {
3632 : 8 : SCTAB nStartTab = aMarkRange.aStart.Tab();
3633 [ + - ]: 8 : SCTAB nTabCount = pDoc->GetTableCount();
3634 : :
3635 [ + - ][ + - ]: 8 : ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
3636 [ + - ]: 8 : pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab );
3637 [ + - ][ + - ]: 8 : ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
3638 [ + - ][ + - ]: 16 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ + + ][ + - ]
[ + - ][ + + ]
3639 [ + - ][ - + ]: 8 : if (*itr != nStartTab)
3640 [ # # ][ # # ]: 0 : pUndoDoc->AddUndoTab( *itr, *itr );
[ # # ]
3641 : :
3642 : 8 : ScRange aCopyRange = aMarkRange;
3643 : 8 : aCopyRange.aStart.SetTab(0);
3644 : 8 : aCopyRange.aEnd.SetTab(nTabCount-1);
3645 [ + - ]: 8 : pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, sal_True, pUndoDoc, (ScMarkData*)&rMark );
3646 : :
3647 [ + - ]: 8 : rDocShell.GetUndoManager()->AddUndoAction(
3648 [ + - ][ + - ]: 8 : new ScUndoIndent( &rDocShell, rMark, pUndoDoc, bIncrement ) );
[ + - ]
3649 : : }
3650 : :
3651 [ + - ]: 8 : pDoc->ChangeSelectionIndent( bIncrement, rMark );
3652 : :
3653 [ + - ][ + - ]: 8 : rDocShell.PostPaint( aMarkRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
[ + - ]
3654 [ + - ]: 8 : aModificator.SetDocumentModified();
3655 : :
3656 [ + - ]: 8 : SfxBindings* pBindings = rDocShell.GetViewBindings();
3657 [ + - ]: 8 : if (pBindings)
3658 : : {
3659 [ + - ]: 8 : pBindings->Invalidate( SID_ALIGNLEFT ); // ChangeIndent setzt auf links
3660 [ + - ]: 8 : pBindings->Invalidate( SID_ALIGNRIGHT );
3661 [ + - ]: 8 : pBindings->Invalidate( SID_ALIGNBLOCK );
3662 [ + - ]: 8 : pBindings->Invalidate( SID_ALIGNCENTERHOR );
3663 : : // pseudo slots for Format menu
3664 [ + - ]: 8 : pBindings->Invalidate( SID_ALIGN_ANY_HDEFAULT );
3665 [ + - ]: 8 : pBindings->Invalidate( SID_ALIGN_ANY_LEFT );
3666 [ + - ]: 8 : pBindings->Invalidate( SID_ALIGN_ANY_HCENTER );
3667 [ + - ]: 8 : pBindings->Invalidate( SID_ALIGN_ANY_RIGHT );
3668 [ + - ]: 8 : pBindings->Invalidate( SID_ALIGN_ANY_JUSTIFIED );
3669 : : }
3670 : :
3671 [ + - ]: 8 : return sal_True;
3672 : : }
3673 : :
3674 : 0 : bool ScDocFunc::AutoFormat( const ScRange& rRange, const ScMarkData* pTabMark,
3675 : : sal_uInt16 nFormatNo, bool bRecord, bool bApi )
3676 : : {
3677 [ # # ]: 0 : ScDocShellModificator aModificator( rDocShell );
3678 : :
3679 : 0 : sal_Bool bSuccess = false;
3680 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
3681 : 0 : SCCOL nStartCol = rRange.aStart.Col();
3682 : 0 : SCROW nStartRow = rRange.aStart.Row();
3683 : 0 : SCTAB nStartTab = rRange.aStart.Tab();
3684 : 0 : SCCOL nEndCol = rRange.aEnd.Col();
3685 : 0 : SCROW nEndRow = rRange.aEnd.Row();
3686 : 0 : SCTAB nEndTab = rRange.aEnd.Tab();
3687 : :
3688 [ # # ][ # # ]: 0 : if (bRecord && !pDoc->IsUndoEnabled())
[ # # ]
3689 : 0 : bRecord = false;
3690 [ # # ]: 0 : ScMarkData aMark;
3691 [ # # ]: 0 : if (pTabMark)
3692 [ # # ]: 0 : aMark = *pTabMark;
3693 : : else
3694 : : {
3695 [ # # ]: 0 : for (SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
3696 [ # # ]: 0 : aMark.SelectTable( nTab, sal_True );
3697 : : }
3698 : :
3699 [ # # ]: 0 : ScAutoFormat* pAutoFormat = ScGlobal::GetOrCreateAutoFormat();
3700 [ # # ]: 0 : ScEditableTester aTester( pDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark );
3701 [ # # ][ # # ]: 0 : if ( nFormatNo < pAutoFormat->size() && aTester.IsEditable() )
[ # # ][ # # ]
3702 : : {
3703 [ # # ][ # # ]: 0 : WaitObject aWait( rDocShell.GetActiveDialogParent() );
3704 : :
3705 [ # # ]: 0 : bool bSize = pAutoFormat->findByIndex(nFormatNo)->GetIncludeWidthHeight();
3706 : :
3707 [ # # ]: 0 : SCTAB nTabCount = pDoc->GetTableCount();
3708 : 0 : ScDocument* pUndoDoc = NULL;
3709 [ # # ]: 0 : if ( bRecord )
3710 : : {
3711 [ # # ][ # # ]: 0 : pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
3712 [ # # ]: 0 : pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab, bSize, bSize );
3713 [ # # ][ # # ]: 0 : ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
3714 [ # # ][ # # ]: 0 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ # # ][ # # ]
[ # # ][ # # ]
3715 [ # # ][ # # ]: 0 : if (*itr != nStartTab)
3716 [ # # ][ # # ]: 0 : pUndoDoc->AddUndoTab( *itr, *itr, bSize, bSize );
[ # # ]
3717 : :
3718 : 0 : ScRange aCopyRange = rRange;
3719 : 0 : aCopyRange.aStart.SetTab(0);
3720 : 0 : aCopyRange.aStart.SetTab(nTabCount-1);
3721 [ # # ]: 0 : pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, false, pUndoDoc, &aMark );
3722 [ # # ]: 0 : if (bSize)
3723 : : {
3724 : : pDoc->CopyToDocument( nStartCol,0,0, nEndCol,MAXROW,nTabCount-1,
3725 [ # # ]: 0 : IDF_NONE, false, pUndoDoc, &aMark );
3726 : : pDoc->CopyToDocument( 0,nStartRow,0, MAXCOL,nEndRow,nTabCount-1,
3727 [ # # ]: 0 : IDF_NONE, false, pUndoDoc, &aMark );
3728 : : }
3729 [ # # ]: 0 : pDoc->BeginDrawUndo();
3730 : : }
3731 : :
3732 [ # # ]: 0 : pDoc->AutoFormat( nStartCol, nStartRow, nEndCol, nEndRow, nFormatNo, aMark );
3733 : :
3734 [ # # ]: 0 : if (bSize)
3735 : : {
3736 : 0 : SCCOLROW nCols[2] = { nStartCol, nEndCol };
3737 : 0 : SCCOLROW nRows[2] = { nStartRow, nEndRow };
3738 : :
3739 [ # # ][ # # ]: 0 : ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
3740 [ # # ][ # # ]: 0 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ # # ][ # # ]
[ # # ][ # # ]
3741 [ # # ][ # # ]: 0 : SetWidthOrHeight( sal_True, 1,nCols, *itr, SC_SIZE_VISOPT, STD_EXTRA_WIDTH, false, sal_True);
3742 [ # # ][ # # ]: 0 : SetWidthOrHeight( false,1,nRows, *itr, SC_SIZE_VISOPT, 0, false, false);
3743 [ # # ][ # # ]: 0 : rDocShell.PostPaint( 0,0,*itr, MAXCOL,MAXROW,*itr,
3744 [ # # ]: 0 : PAINT_GRID | PAINT_LEFT | PAINT_TOP );
3745 : : }
3746 : : else
3747 : : {
3748 [ # # ][ # # ]: 0 : ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
3749 [ # # ][ # # ]: 0 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ # # ][ # # ]
[ # # ][ # # ]
3750 : : {
3751 [ # # ]: 0 : sal_Bool bAdj = AdjustRowHeight( ScRange(nStartCol, nStartRow, *itr,
3752 [ # # ][ # # ]: 0 : nEndCol, nEndRow, *itr), false );
3753 [ # # ]: 0 : if (bAdj)
3754 [ # # ][ # # ]: 0 : rDocShell.PostPaint( 0,nStartRow,*itr, MAXCOL,MAXROW,*itr,
3755 [ # # ]: 0 : PAINT_GRID | PAINT_LEFT );
3756 : : else
3757 [ # # ]: 0 : rDocShell.PostPaint( nStartCol, nStartRow, *itr,
3758 [ # # ][ # # ]: 0 : nEndCol, nEndRow, *itr, PAINT_GRID );
3759 : : }
3760 : : }
3761 : :
3762 [ # # ]: 0 : if ( bRecord ) // Draw-Undo erst jetzt verfuegbar
3763 : : {
3764 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
3765 [ # # ][ # # ]: 0 : new ScUndoAutoFormat( &rDocShell, rRange, pUndoDoc, aMark, bSize, nFormatNo ) );
[ # # ]
3766 : : }
3767 : :
3768 [ # # ][ # # ]: 0 : aModificator.SetDocumentModified();
3769 : : }
3770 [ # # ]: 0 : else if (!bApi)
3771 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
3772 : :
3773 [ # # ][ # # ]: 0 : return bSuccess;
3774 : : }
3775 : :
3776 : : //------------------------------------------------------------------------
3777 : :
3778 : 3 : sal_Bool ScDocFunc::EnterMatrix( const ScRange& rRange, const ScMarkData* pTabMark,
3779 : : const ScTokenArray* pTokenArray, const String& rString, sal_Bool bApi, sal_Bool bEnglish,
3780 : : const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar )
3781 : : {
3782 [ + - ]: 3 : ScDocShellModificator aModificator( rDocShell );
3783 : :
3784 : 3 : sal_Bool bSuccess = false;
3785 : 3 : ScDocument* pDoc = rDocShell.GetDocument();
3786 : 3 : SCCOL nStartCol = rRange.aStart.Col();
3787 : 3 : SCROW nStartRow = rRange.aStart.Row();
3788 : 3 : SCTAB nStartTab = rRange.aStart.Tab();
3789 : 3 : SCCOL nEndCol = rRange.aEnd.Col();
3790 : 3 : SCROW nEndRow = rRange.aEnd.Row();
3791 : 3 : SCTAB nEndTab = rRange.aEnd.Tab();
3792 : :
3793 : 3 : bool bUndo(pDoc->IsUndoEnabled());
3794 : :
3795 [ + - ]: 3 : ScMarkData aMark;
3796 [ - + ]: 3 : if (pTabMark)
3797 [ # # ]: 0 : aMark = *pTabMark;
3798 : : else
3799 : : {
3800 [ + + ]: 6 : for (SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
3801 [ + - ]: 3 : aMark.SelectTable( nTab, sal_True );
3802 : : }
3803 : :
3804 [ + - ]: 3 : ScEditableTester aTester( pDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark );
3805 [ + - ]: 3 : if ( aTester.IsEditable() )
3806 : : {
3807 [ + - ][ + - ]: 3 : WaitObject aWait( rDocShell.GetActiveDialogParent() );
3808 : :
3809 : 3 : ScDocument* pUndoDoc = NULL;
3810 : :
3811 [ + - ]: 3 : if (bUndo)
3812 : : {
3813 : : //! auch bei Undo selektierte Tabellen beruecksichtigen
3814 [ + - ][ + - ]: 3 : pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
3815 [ + - ]: 3 : pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab );
3816 [ + - ]: 3 : pDoc->CopyToDocument( rRange, IDF_ALL & ~IDF_NOTE, false, pUndoDoc );
3817 : : }
3818 : :
3819 : : // use TokenArray if given, string (and flags) otherwise
3820 [ - + ]: 3 : if ( pTokenArray )
3821 : : {
3822 : : pDoc->InsertMatrixFormula( nStartCol, nStartRow, nEndCol, nEndRow,
3823 [ # # ][ # # ]: 0 : aMark, EMPTY_STRING, pTokenArray, eGrammar);
[ # # ]
3824 : : }
3825 [ - + ]: 3 : else if ( pDoc->IsImportingXML() )
3826 : : {
3827 [ # # ]: 0 : ScTokenArray* pCode = lcl_ScDocFunc_CreateTokenArrayXML( rString, rFormulaNmsp, eGrammar );
3828 : : pDoc->InsertMatrixFormula( nStartCol, nStartRow, nEndCol, nEndRow,
3829 [ # # ][ # # ]: 0 : aMark, EMPTY_STRING, pCode, eGrammar);
[ # # ]
3830 [ # # ][ # # ]: 0 : delete pCode;
3831 : 0 : pDoc->IncXMLImportedFormulaCount( rString.Len() );
3832 : : }
3833 [ + - ]: 3 : else if (bEnglish)
3834 : : {
3835 [ + - ]: 3 : ScCompiler aComp( pDoc, rRange.aStart);
3836 [ + - ]: 3 : aComp.SetGrammar(eGrammar);
3837 [ + - ]: 3 : ScTokenArray* pCode = aComp.CompileString( rString );
3838 : : pDoc->InsertMatrixFormula( nStartCol, nStartRow, nEndCol, nEndRow,
3839 [ + - ][ + - ]: 3 : aMark, EMPTY_STRING, pCode, eGrammar);
[ + - ]
3840 [ + - ][ + - ]: 3 : delete pCode;
[ + - ]
3841 : : }
3842 : : else
3843 : : pDoc->InsertMatrixFormula( nStartCol, nStartRow, nEndCol, nEndRow,
3844 [ # # ][ # # ]: 0 : aMark, rString, NULL, eGrammar);
3845 : :
3846 [ + - ]: 3 : if (bUndo)
3847 : : {
3848 : : //! auch bei Undo selektierte Tabellen beruecksichtigen
3849 [ + - ]: 3 : rDocShell.GetUndoManager()->AddUndoAction(
3850 [ + - ][ + - ]: 3 : new ScUndoEnterMatrix( &rDocShell, rRange, pUndoDoc, rString ) );
[ + - ]
3851 : : }
3852 : :
3853 : : // Err522 beim Paint von DDE-Formeln werden jetzt beim Interpretieren abgefangen
3854 [ + - ]: 3 : rDocShell.PostPaint( nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab, PAINT_GRID );
3855 [ + - ]: 3 : aModificator.SetDocumentModified();
3856 : :
3857 [ + - ]: 3 : bSuccess = sal_True;
3858 : : }
3859 [ # # ]: 0 : else if (!bApi)
3860 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
3861 : :
3862 [ + - ][ + - ]: 3 : return bSuccess;
3863 : : }
3864 : :
3865 : : //------------------------------------------------------------------------
3866 : :
3867 : 6 : sal_Bool ScDocFunc::TabOp( const ScRange& rRange, const ScMarkData* pTabMark,
3868 : : const ScTabOpParam& rParam, sal_Bool bRecord, sal_Bool bApi )
3869 : : {
3870 [ + - ]: 6 : ScDocShellModificator aModificator( rDocShell );
3871 : :
3872 : 6 : sal_Bool bSuccess = false;
3873 : 6 : ScDocument* pDoc = rDocShell.GetDocument();
3874 : 6 : SCCOL nStartCol = rRange.aStart.Col();
3875 : 6 : SCROW nStartRow = rRange.aStart.Row();
3876 : 6 : SCTAB nStartTab = rRange.aStart.Tab();
3877 : 6 : SCCOL nEndCol = rRange.aEnd.Col();
3878 : 6 : SCROW nEndRow = rRange.aEnd.Row();
3879 : 6 : SCTAB nEndTab = rRange.aEnd.Tab();
3880 : :
3881 [ - + ][ - + ]: 6 : if (bRecord && !pDoc->IsUndoEnabled())
[ + - ]
3882 : 0 : bRecord = false;
3883 : :
3884 [ + - ]: 6 : ScMarkData aMark;
3885 [ - + ]: 6 : if (pTabMark)
3886 [ # # ]: 0 : aMark = *pTabMark;
3887 : : else
3888 : : {
3889 [ + + ]: 12 : for (SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
3890 [ + - ]: 6 : aMark.SelectTable( nTab, sal_True );
3891 : : }
3892 : :
3893 [ + - ]: 6 : ScEditableTester aTester( pDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark );
3894 [ + - ]: 6 : if ( aTester.IsEditable() )
3895 : : {
3896 [ + - ][ + - ]: 6 : WaitObject aWait( rDocShell.GetActiveDialogParent() );
3897 [ + - ]: 6 : pDoc->SetDirty( rRange );
3898 [ + - ]: 6 : if ( bRecord )
3899 : : {
3900 : : //! auch bei Undo selektierte Tabellen beruecksichtigen
3901 [ + - ][ + - ]: 6 : ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
3902 [ + - ]: 6 : pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab );
3903 [ + - ]: 6 : pDoc->CopyToDocument( rRange, IDF_ALL & ~IDF_NOTE, false, pUndoDoc );
3904 : :
3905 [ + - ]: 6 : rDocShell.GetUndoManager()->AddUndoAction(
3906 : : new ScUndoTabOp( &rDocShell,
3907 : : nStartCol, nStartRow, nStartTab,
3908 : : nEndCol, nEndRow, nEndTab, pUndoDoc,
3909 : : rParam.aRefFormulaCell,
3910 : : rParam.aRefFormulaEnd,
3911 : : rParam.aRefRowCell,
3912 : : rParam.aRefColCell,
3913 [ + - ][ + - ]: 6 : rParam.nMode) );
[ + - ]
3914 : : }
3915 [ + - ]: 6 : pDoc->InsertTableOp(rParam, nStartCol, nStartRow, nEndCol, nEndRow, aMark);
3916 [ + - ]: 6 : rDocShell.PostPaintGridAll();
3917 [ + - ]: 6 : aModificator.SetDocumentModified();
3918 [ + - ]: 6 : bSuccess = sal_True;
3919 : : }
3920 [ # # ]: 0 : else if (!bApi)
3921 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
3922 : :
3923 [ + - ][ + - ]: 6 : return bSuccess;
3924 : : }
3925 : :
3926 : : //------------------------------------------------------------------------
3927 : :
3928 : 8 : inline ScDirection DirFromFillDir( FillDir eDir )
3929 : : {
3930 [ + + ]: 8 : if (eDir==FILL_TO_BOTTOM)
3931 : 4 : return DIR_BOTTOM;
3932 [ + - ]: 4 : else if (eDir==FILL_TO_RIGHT)
3933 : 4 : return DIR_RIGHT;
3934 [ # # ]: 0 : else if (eDir==FILL_TO_TOP)
3935 : 0 : return DIR_TOP;
3936 : : else // if (eDir==FILL_TO_LEFT)
3937 : 8 : return DIR_LEFT;
3938 : : }
3939 : :
3940 : : namespace {
3941 : :
3942 : : /**
3943 : : * Expand the fill range as necessary, to allow copying of adjacent cell(s)
3944 : : * even when those cells are not in the original range.
3945 : : */
3946 : 0 : void adjustFillRangeForAdjacentCopy(ScRange& rRange, FillDir eDir)
3947 : : {
3948 [ # # # # : 0 : switch (eDir)
# ]
3949 : : {
3950 : : case FILL_TO_BOTTOM:
3951 : : {
3952 [ # # ]: 0 : if (rRange.aStart.Row() == 0)
3953 : 0 : return;
3954 : :
3955 [ # # ]: 0 : if (rRange.aStart.Row() != rRange.aEnd.Row())
3956 : 0 : return;
3957 : :
3958 : : // Include the above row.
3959 : 0 : ScAddress& s = rRange.aStart;
3960 : 0 : s.SetRow(s.Row()-1);
3961 : : }
3962 : 0 : break;
3963 : : case FILL_TO_TOP:
3964 : : {
3965 [ # # ]: 0 : if (rRange.aStart.Row() == MAXROW)
3966 : 0 : return;
3967 : :
3968 [ # # ]: 0 : if (rRange.aStart.Row() != rRange.aEnd.Row())
3969 : 0 : return;
3970 : :
3971 : : // Include the row below.
3972 : 0 : ScAddress& e = rRange.aEnd;
3973 : 0 : e.SetRow(e.Row()+1);
3974 : : }
3975 : 0 : break;
3976 : : case FILL_TO_LEFT:
3977 : : {
3978 [ # # ]: 0 : if (rRange.aStart.Col() == MAXCOL)
3979 : 0 : return;
3980 : :
3981 [ # # ]: 0 : if (rRange.aStart.Col() != rRange.aEnd.Col())
3982 : 0 : return;
3983 : :
3984 : : // Include the column to the right.
3985 : 0 : ScAddress& e = rRange.aEnd;
3986 : 0 : e.SetCol(e.Col()+1);
3987 : : }
3988 : 0 : break;
3989 : : case FILL_TO_RIGHT:
3990 : : {
3991 [ # # ]: 0 : if (rRange.aStart.Col() == 0)
3992 : 0 : return;
3993 : :
3994 [ # # ]: 0 : if (rRange.aStart.Col() != rRange.aEnd.Col())
3995 : 0 : return;
3996 : :
3997 : : // Include the column to the left.
3998 : 0 : ScAddress& s = rRange.aStart;
3999 : 0 : s.SetCol(s.Col()-1);
4000 : : }
4001 : 0 : break;
4002 : : default:
4003 : : ;
4004 : : }
4005 : : }
4006 : :
4007 : : }
4008 : :
4009 : 0 : bool ScDocFunc::FillSimple( const ScRange& rRange, const ScMarkData* pTabMark,
4010 : : FillDir eDir, bool bRecord, bool bApi )
4011 : : {
4012 [ # # ]: 0 : ScDocShellModificator aModificator( rDocShell );
4013 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
4014 : :
4015 : 0 : bool bSuccess = false;
4016 : 0 : ScRange aRange = rRange;
4017 : 0 : adjustFillRangeForAdjacentCopy(aRange, eDir);
4018 : :
4019 : 0 : SCCOL nStartCol = aRange.aStart.Col();
4020 : 0 : SCROW nStartRow = aRange.aStart.Row();
4021 : 0 : SCTAB nStartTab = aRange.aStart.Tab();
4022 : 0 : SCCOL nEndCol = aRange.aEnd.Col();
4023 : 0 : SCROW nEndRow = aRange.aEnd.Row();
4024 : 0 : SCTAB nEndTab = aRange.aEnd.Tab();
4025 : :
4026 [ # # ][ # # ]: 0 : if (bRecord && !pDoc->IsUndoEnabled())
[ # # ]
4027 : 0 : bRecord = false;
4028 : :
4029 [ # # ]: 0 : ScMarkData aMark;
4030 [ # # ]: 0 : if (pTabMark)
4031 [ # # ]: 0 : aMark = *pTabMark;
4032 : : else
4033 : : {
4034 [ # # ]: 0 : for (SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
4035 [ # # ]: 0 : aMark.SelectTable( nTab, sal_True );
4036 : : }
4037 : :
4038 [ # # ]: 0 : ScEditableTester aTester( pDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark );
4039 [ # # ]: 0 : if ( aTester.IsEditable() )
4040 : : {
4041 [ # # ][ # # ]: 0 : WaitObject aWait( rDocShell.GetActiveDialogParent() );
4042 : :
4043 : 0 : ScRange aSourceArea = aRange;
4044 : 0 : ScRange aDestArea = aRange;
4045 : :
4046 : 0 : SCCOLROW nCount = 0;
4047 [ # # # # : 0 : switch (eDir)
# ]
4048 : : {
4049 : : case FILL_TO_BOTTOM:
4050 : 0 : nCount = aSourceArea.aEnd.Row()-aSourceArea.aStart.Row();
4051 : 0 : aSourceArea.aEnd.SetRow( aSourceArea.aStart.Row() );
4052 : 0 : break;
4053 : : case FILL_TO_RIGHT:
4054 : 0 : nCount = aSourceArea.aEnd.Col()-aSourceArea.aStart.Col();
4055 : 0 : aSourceArea.aEnd.SetCol( aSourceArea.aStart.Col() );
4056 : 0 : break;
4057 : : case FILL_TO_TOP:
4058 : 0 : nCount = aSourceArea.aEnd.Row()-aSourceArea.aStart.Row();
4059 : 0 : aSourceArea.aStart.SetRow( aSourceArea.aEnd.Row() );
4060 : 0 : break;
4061 : : case FILL_TO_LEFT:
4062 : 0 : nCount = aSourceArea.aEnd.Col()-aSourceArea.aStart.Col();
4063 : 0 : aSourceArea.aStart.SetCol( aSourceArea.aEnd.Col() );
4064 : 0 : break;
4065 : : }
4066 : :
4067 : 0 : ScDocument* pUndoDoc = NULL;
4068 [ # # ]: 0 : if ( bRecord )
4069 : : {
4070 [ # # ]: 0 : SCTAB nTabCount = pDoc->GetTableCount();
4071 : 0 : SCTAB nDestStartTab = aDestArea.aStart.Tab();
4072 : :
4073 [ # # ][ # # ]: 0 : pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
4074 [ # # ]: 0 : pUndoDoc->InitUndo( pDoc, nDestStartTab, nDestStartTab );
4075 [ # # ][ # # ]: 0 : ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
4076 [ # # ][ # # ]: 0 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ # # ][ # # ]
[ # # ][ # # ]
4077 [ # # ][ # # ]: 0 : if (*itr != nDestStartTab)
4078 [ # # ][ # # ]: 0 : pUndoDoc->AddUndoTab( *itr, *itr );
[ # # ]
4079 : :
4080 : 0 : ScRange aCopyRange = aDestArea;
4081 : 0 : aCopyRange.aStart.SetTab(0);
4082 : 0 : aCopyRange.aEnd.SetTab(nTabCount-1);
4083 [ # # ]: 0 : pDoc->CopyToDocument( aCopyRange, IDF_AUTOFILL, false, pUndoDoc, &aMark );
4084 : : }
4085 : :
4086 : : sal_uLong nProgCount;
4087 [ # # ][ # # ]: 0 : if (eDir == FILL_TO_BOTTOM || eDir == FILL_TO_TOP)
4088 : 0 : nProgCount = aSourceArea.aEnd.Col() - aSourceArea.aStart.Col() + 1;
4089 : : else
4090 : 0 : nProgCount = aSourceArea.aEnd.Row() - aSourceArea.aStart.Row() + 1;
4091 : 0 : nProgCount *= nCount;
4092 : : ScProgress aProgress( pDoc->GetDocumentShell(),
4093 [ # # ][ # # ]: 0 : ScGlobal::GetRscString(STR_FILL_SERIES_PROGRESS), nProgCount );
4094 : :
4095 : 0 : pDoc->Fill( aSourceArea.aStart.Col(), aSourceArea.aStart.Row(),
4096 : 0 : aSourceArea.aEnd.Col(), aSourceArea.aEnd.Row(), &aProgress,
4097 [ # # ]: 0 : aMark, nCount, eDir, FILL_SIMPLE );
4098 [ # # ]: 0 : AdjustRowHeight(aRange);
4099 : :
4100 [ # # ]: 0 : if ( bRecord ) // Draw-Undo erst jetzt verfuegbar
4101 : : {
4102 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
4103 : : new ScUndoAutoFill( &rDocShell, aDestArea, aSourceArea, pUndoDoc, aMark,
4104 [ # # ][ # # ]: 0 : eDir, FILL_SIMPLE, FILL_DAY, MAXDOUBLE, 1.0, 1e307) );
[ # # ]
4105 : : }
4106 : :
4107 [ # # ]: 0 : rDocShell.PostPaintGridAll();
4108 [ # # ]: 0 : aModificator.SetDocumentModified();
4109 : :
4110 [ # # ][ # # ]: 0 : bSuccess = true;
4111 : : }
4112 [ # # ]: 0 : else if (!bApi)
4113 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
4114 : :
4115 [ # # ][ # # ]: 0 : return bSuccess;
4116 : : }
4117 : :
4118 : 8 : sal_Bool ScDocFunc::FillSeries( const ScRange& rRange, const ScMarkData* pTabMark,
4119 : : FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd,
4120 : : double fStart, double fStep, double fMax,
4121 : : sal_Bool bRecord, sal_Bool bApi )
4122 : : {
4123 [ + - ]: 8 : ScDocShellModificator aModificator( rDocShell );
4124 : :
4125 : 8 : sal_Bool bSuccess = false;
4126 : 8 : ScDocument* pDoc = rDocShell.GetDocument();
4127 : 8 : SCCOL nStartCol = rRange.aStart.Col();
4128 : 8 : SCROW nStartRow = rRange.aStart.Row();
4129 : 8 : SCTAB nStartTab = rRange.aStart.Tab();
4130 : 8 : SCCOL nEndCol = rRange.aEnd.Col();
4131 : 8 : SCROW nEndRow = rRange.aEnd.Row();
4132 : 8 : SCTAB nEndTab = rRange.aEnd.Tab();
4133 : :
4134 [ - + ][ - + ]: 8 : if (bRecord && !pDoc->IsUndoEnabled())
[ + - ]
4135 : 0 : bRecord = false;
4136 : :
4137 [ + - ]: 8 : ScMarkData aMark;
4138 [ - + ]: 8 : if (pTabMark)
4139 [ # # ]: 0 : aMark = *pTabMark;
4140 : : else
4141 : : {
4142 [ + + ]: 16 : for (SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
4143 [ + - ]: 8 : aMark.SelectTable( nTab, sal_True );
4144 : : }
4145 : :
4146 [ + - ]: 8 : ScEditableTester aTester( pDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark );
4147 [ + - ]: 8 : if ( aTester.IsEditable() )
4148 : : {
4149 [ + - ][ + - ]: 8 : WaitObject aWait( rDocShell.GetActiveDialogParent() );
4150 : :
4151 : 8 : ScRange aSourceArea = rRange;
4152 : 8 : ScRange aDestArea = rRange;
4153 : :
4154 : : SCSIZE nCount = pDoc->GetEmptyLinesInBlock(
4155 : 16 : aSourceArea.aStart.Col(), aSourceArea.aStart.Row(), aSourceArea.aStart.Tab(),
4156 : 16 : aSourceArea.aEnd.Col(), aSourceArea.aEnd.Row(), aSourceArea.aEnd.Tab(),
4157 [ + - ]: 32 : DirFromFillDir(eDir) );
4158 : :
4159 : : // mindestens eine Zeile/Spalte als Quellbereich behalten:
4160 : : SCSIZE nTotLines = ( eDir == FILL_TO_BOTTOM || eDir == FILL_TO_TOP ) ?
4161 : 4 : static_cast<SCSIZE>( aSourceArea.aEnd.Row() - aSourceArea.aStart.Row() + 1 ) :
4162 [ + + ][ - + ]: 12 : static_cast<SCSIZE>( aSourceArea.aEnd.Col() - aSourceArea.aStart.Col() + 1 );
4163 [ - + ]: 8 : if ( nCount >= nTotLines )
4164 : 0 : nCount = nTotLines - 1;
4165 : :
4166 [ + + - - : 8 : switch (eDir)
- ]
4167 : : {
4168 : : case FILL_TO_BOTTOM:
4169 : 4 : aSourceArea.aEnd.SetRow( sal::static_int_cast<SCROW>( aSourceArea.aEnd.Row() - nCount ) );
4170 : 4 : break;
4171 : : case FILL_TO_RIGHT:
4172 : 4 : aSourceArea.aEnd.SetCol( sal::static_int_cast<SCCOL>( aSourceArea.aEnd.Col() - nCount ) );
4173 : 4 : break;
4174 : : case FILL_TO_TOP:
4175 : 0 : aSourceArea.aStart.SetRow( sal::static_int_cast<SCROW>( aSourceArea.aStart.Row() + nCount ) );
4176 : 0 : break;
4177 : : case FILL_TO_LEFT:
4178 : 0 : aSourceArea.aStart.SetCol( sal::static_int_cast<SCCOL>( aSourceArea.aStart.Col() + nCount ) );
4179 : 0 : break;
4180 : : }
4181 : :
4182 : 8 : ScDocument* pUndoDoc = NULL;
4183 [ + - ]: 8 : if ( bRecord )
4184 : : {
4185 [ + - ]: 8 : SCTAB nTabCount = pDoc->GetTableCount();
4186 : 8 : SCTAB nDestStartTab = aDestArea.aStart.Tab();
4187 : :
4188 [ + - ][ + - ]: 8 : pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
4189 [ + - ]: 8 : pUndoDoc->InitUndo( pDoc, nDestStartTab, nDestStartTab );
4190 [ + - ][ + - ]: 8 : ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
4191 [ + - ][ + - ]: 16 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ + + ][ + - ]
[ + - ][ + + ]
4192 [ + - ][ - + ]: 8 : if (*itr != nDestStartTab)
4193 [ # # ][ # # ]: 0 : pUndoDoc->AddUndoTab( *itr, *itr );
[ # # ]
4194 : :
4195 : : pDoc->CopyToDocument(
4196 : 8 : aDestArea.aStart.Col(), aDestArea.aStart.Row(), 0,
4197 : 8 : aDestArea.aEnd.Col(), aDestArea.aEnd.Row(), nTabCount-1,
4198 [ + - ]: 24 : IDF_AUTOFILL, false, pUndoDoc, &aMark );
4199 : : }
4200 : :
4201 [ + - + - ]: 16 : if (aDestArea.aStart.Col() <= aDestArea.aEnd.Col() &&
[ + - ]
4202 : 8 : aDestArea.aStart.Row() <= aDestArea.aEnd.Row())
4203 : : {
4204 [ - + ]: 8 : if ( fStart != MAXDOUBLE )
4205 : : {
4206 [ # # ]: 0 : SCCOL nValX = (eDir == FILL_TO_LEFT) ? aDestArea.aEnd.Col() : aDestArea.aStart.Col();
4207 [ # # ]: 0 : SCROW nValY = (eDir == FILL_TO_TOP ) ? aDestArea.aEnd.Row() : aDestArea.aStart.Row();
4208 : 0 : SCTAB nTab = aDestArea.aStart.Tab();
4209 [ # # ]: 0 : pDoc->SetValue( nValX, nValY, nTab, fStart );
4210 : : }
4211 : :
4212 : : sal_uLong nProgCount;
4213 [ + + ][ - + ]: 8 : if (eDir == FILL_TO_BOTTOM || eDir == FILL_TO_TOP)
4214 : 4 : nProgCount = aSourceArea.aEnd.Col() - aSourceArea.aStart.Col() + 1;
4215 : : else
4216 : 4 : nProgCount = aSourceArea.aEnd.Row() - aSourceArea.aStart.Row() + 1;
4217 : 8 : nProgCount *= nCount;
4218 : : ScProgress aProgress( pDoc->GetDocumentShell(),
4219 [ + - ][ + - ]: 8 : ScGlobal::GetRscString(STR_FILL_SERIES_PROGRESS), nProgCount );
4220 : :
4221 : 8 : pDoc->Fill( aSourceArea.aStart.Col(), aSourceArea.aStart.Row(),
4222 : 8 : aSourceArea.aEnd.Col(), aSourceArea.aEnd.Row(), &aProgress,
4223 [ + - ]: 24 : aMark, nCount, eDir, eCmd, eDateCmd, fStep, fMax );
4224 [ + - ]: 8 : AdjustRowHeight(rRange);
4225 : :
4226 [ + - ]: 8 : rDocShell.PostPaintGridAll();
4227 [ + - ][ + - ]: 8 : aModificator.SetDocumentModified();
4228 : : }
4229 : :
4230 [ + - ]: 8 : if ( bRecord ) // Draw-Undo erst jetzt verfuegbar
4231 : : {
4232 [ + - ]: 8 : rDocShell.GetUndoManager()->AddUndoAction(
4233 : : new ScUndoAutoFill( &rDocShell, aDestArea, aSourceArea, pUndoDoc, aMark,
4234 [ + - ][ + - ]: 8 : eDir, eCmd, eDateCmd, fStart, fStep, fMax) );
[ + - ]
4235 : : }
4236 : :
4237 [ + - ]: 8 : bSuccess = sal_True;
4238 : : }
4239 [ # # ]: 0 : else if (!bApi)
4240 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
4241 : :
4242 [ + - ][ + - ]: 8 : return bSuccess;
4243 : : }
4244 : :
4245 : 4 : sal_Bool ScDocFunc::FillAuto( ScRange& rRange, const ScMarkData* pTabMark,
4246 : : FillDir eDir, sal_uLong nCount, sal_Bool bRecord, sal_Bool bApi )
4247 : : {
4248 : 4 : double fStep = 1.0;
4249 : 4 : double fMax = MAXDOUBLE;
4250 : 4 : return FillAuto( rRange, pTabMark, eDir, FILL_AUTO, FILL_DAY, nCount, fStep, fMax, bRecord, bApi );
4251 : : }
4252 : :
4253 : 4 : sal_Bool ScDocFunc::FillAuto( ScRange& rRange, const ScMarkData* pTabMark, FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, sal_uLong nCount, double fStep, double fMax, sal_Bool bRecord, sal_Bool bApi )
4254 : : {
4255 [ + - ]: 4 : ScDocShellModificator aModificator( rDocShell );
4256 : :
4257 : 4 : ScDocument* pDoc = rDocShell.GetDocument();
4258 : 4 : SCCOL nStartCol = rRange.aStart.Col();
4259 : 4 : SCROW nStartRow = rRange.aStart.Row();
4260 : 4 : SCTAB nStartTab = rRange.aStart.Tab();
4261 : 4 : SCCOL nEndCol = rRange.aEnd.Col();
4262 : 4 : SCROW nEndRow = rRange.aEnd.Row();
4263 : 4 : SCTAB nEndTab = rRange.aEnd.Tab();
4264 : :
4265 [ - + ][ - + ]: 4 : if (bRecord && !pDoc->IsUndoEnabled())
[ + - ]
4266 : 0 : bRecord = false;
4267 : :
4268 [ + - ]: 4 : ScMarkData aMark;
4269 [ - + ]: 4 : if (pTabMark)
4270 [ # # ]: 0 : aMark = *pTabMark;
4271 : : else
4272 : : {
4273 [ + + ]: 8 : for (SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
4274 [ + - ]: 4 : aMark.SelectTable( nTab, sal_True );
4275 : : }
4276 : :
4277 : 4 : ScRange aSourceArea = rRange;
4278 : 4 : ScRange aDestArea = rRange;
4279 : :
4280 : :
4281 [ + - + - : 4 : switch (eDir)
- ]
4282 : : {
4283 : : case FILL_TO_BOTTOM:
4284 : 2 : aDestArea.aEnd.SetRow( sal::static_int_cast<SCROW>( aSourceArea.aEnd.Row() + nCount ) );
4285 : 2 : break;
4286 : : case FILL_TO_TOP:
4287 [ # # ]: 0 : if (nCount > sal::static_int_cast<sal_uLong>( aSourceArea.aStart.Row() ))
4288 : : {
4289 : : OSL_FAIL("FillAuto: Row < 0");
4290 : 0 : nCount = aSourceArea.aStart.Row();
4291 : : }
4292 : 0 : aDestArea.aStart.SetRow( sal::static_int_cast<SCROW>( aSourceArea.aStart.Row() - nCount ) );
4293 : 0 : break;
4294 : : case FILL_TO_RIGHT:
4295 : 2 : aDestArea.aEnd.SetCol( sal::static_int_cast<SCCOL>( aSourceArea.aEnd.Col() + nCount ) );
4296 : 2 : break;
4297 : : case FILL_TO_LEFT:
4298 [ # # ]: 0 : if (nCount > sal::static_int_cast<sal_uLong>( aSourceArea.aStart.Col() ))
4299 : : {
4300 : : OSL_FAIL("FillAuto: Col < 0");
4301 : 0 : nCount = aSourceArea.aStart.Col();
4302 : : }
4303 : 0 : aDestArea.aStart.SetCol( sal::static_int_cast<SCCOL>( aSourceArea.aStart.Col() - nCount ) );
4304 : 0 : break;
4305 : : default:
4306 : : OSL_FAIL("Falsche Richtung bei FillAuto");
4307 : 0 : break;
4308 : : }
4309 : :
4310 : : // Zellschutz testen
4311 : : //! Quellbereich darf geschuetzt sein !!!
4312 : : //! aber kein Matrixfragment enthalten !!!
4313 : :
4314 [ + - ]: 4 : ScEditableTester aTester( pDoc, aDestArea );
4315 [ - + ]: 4 : if ( !aTester.IsEditable() )
4316 : : {
4317 [ # # ]: 0 : if (!bApi)
4318 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
4319 : 0 : return false;
4320 : : }
4321 : :
4322 [ + - ][ - + ]: 4 : if ( pDoc->HasSelectedBlockMatrixFragment( nStartCol, nStartRow,
4323 : 4 : nEndCol, nEndRow, aMark ) )
4324 : : {
4325 [ # # ]: 0 : if (!bApi)
4326 [ # # ]: 0 : rDocShell.ErrorMessage(STR_MATRIXFRAGMENTERR);
4327 : 0 : return false;
4328 : : }
4329 : :
4330 [ + - ][ + - ]: 4 : WaitObject aWait( rDocShell.GetActiveDialogParent() );
4331 : :
4332 : 4 : ScDocument* pUndoDoc = NULL;
4333 [ + - ]: 4 : if ( bRecord )
4334 : : {
4335 [ + - ]: 4 : SCTAB nTabCount = pDoc->GetTableCount();
4336 : 4 : SCTAB nDestStartTab = aDestArea.aStart.Tab();
4337 : :
4338 [ + - ][ + - ]: 4 : pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
4339 [ + - ]: 4 : pUndoDoc->InitUndo( pDoc, nDestStartTab, nDestStartTab );
4340 [ + - ][ + - ]: 4 : ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
4341 [ + - ][ + - ]: 8 : for (; itr != itrEnd && nTabCount; ++itr)
[ + + ][ + - ]
[ + + ]
4342 [ + - ][ - + ]: 4 : if (*itr != nDestStartTab)
4343 [ # # ][ # # ]: 0 : pUndoDoc->AddUndoTab( *itr, *itr );
[ # # ]
4344 : :
4345 : : // do not clone note captions in undo document
4346 : : pDoc->CopyToDocument(
4347 : 4 : aDestArea.aStart.Col(), aDestArea.aStart.Row(), 0,
4348 : 4 : aDestArea.aEnd.Col(), aDestArea.aEnd.Row(), nTabCount-1,
4349 [ + - ]: 12 : IDF_AUTOFILL, false, pUndoDoc, &aMark );
4350 : : }
4351 : :
4352 : : sal_uLong nProgCount;
4353 [ + + ][ - + ]: 4 : if (eDir == FILL_TO_BOTTOM || eDir == FILL_TO_TOP)
4354 : 2 : nProgCount = aSourceArea.aEnd.Col() - aSourceArea.aStart.Col() + 1;
4355 : : else
4356 : 2 : nProgCount = aSourceArea.aEnd.Row() - aSourceArea.aStart.Row() + 1;
4357 : 4 : nProgCount *= nCount;
4358 : : ScProgress aProgress( pDoc->GetDocumentShell(),
4359 [ + - ][ + - ]: 4 : ScGlobal::GetRscString(STR_FILL_SERIES_PROGRESS), nProgCount );
4360 : :
4361 : 4 : pDoc->Fill( aSourceArea.aStart.Col(), aSourceArea.aStart.Row(),
4362 : 4 : aSourceArea.aEnd.Col(), aSourceArea.aEnd.Row(), &aProgress,
4363 [ + - ]: 12 : aMark, nCount, eDir, eCmd, eDateCmd, fStep, fMax );
4364 : :
4365 [ + - ]: 4 : AdjustRowHeight(aDestArea);
4366 : :
4367 [ + - ]: 4 : if ( bRecord ) // Draw-Undo erst jetzt verfuegbar
4368 : : {
4369 [ + - ]: 4 : rDocShell.GetUndoManager()->AddUndoAction(
4370 : : new ScUndoAutoFill( &rDocShell, aDestArea, aSourceArea, pUndoDoc, aMark,
4371 [ + - ][ + - ]: 4 : eDir, eCmd, eDateCmd, MAXDOUBLE, fStep, fMax) );
[ + - ]
4372 : : }
4373 : :
4374 [ + - ]: 4 : rDocShell.PostPaintGridAll();
4375 [ + - ]: 4 : aModificator.SetDocumentModified();
4376 : :
4377 : 4 : rRange = aDestArea; // Zielbereich zurueckgeben (zum Markieren)
4378 [ + - ][ + - ]: 4 : return sal_True;
[ + - ][ + - ]
4379 : : }
4380 : :
4381 : : //------------------------------------------------------------------------
4382 : :
4383 : 6 : sal_Bool ScDocFunc::MergeCells( const ScCellMergeOption& rOption, sal_Bool bContents, sal_Bool bRecord, sal_Bool bApi )
4384 : : {
4385 : : using ::std::set;
4386 : :
4387 [ + - ]: 6 : ScDocShellModificator aModificator( rDocShell );
4388 : :
4389 : 6 : SCCOL nStartCol = rOption.mnStartCol;
4390 : 6 : SCROW nStartRow = rOption.mnStartRow;
4391 : 6 : SCCOL nEndCol = rOption.mnEndCol;
4392 : 6 : SCROW nEndRow = rOption.mnEndRow;
4393 [ - + ][ # # ]: 6 : if ((nStartCol == nEndCol && nStartRow == nEndRow) || rOption.maTabs.empty())
[ - + ][ - + ]
4394 : : {
4395 : : // Nothing to do. Bail out quick.
4396 : 0 : return true;
4397 : : }
4398 : :
4399 : 6 : ScDocument* pDoc = rDocShell.GetDocument();
4400 : 6 : set<SCTAB>::const_iterator itrBeg = rOption.maTabs.begin(), itrEnd = rOption.maTabs.end();
4401 [ + - ][ + - ]: 6 : SCTAB nTab1 = *itrBeg, nTab2 = *rOption.maTabs.rbegin();
4402 : :
4403 [ + - ][ - + ]: 6 : if (bRecord && !pDoc->IsUndoEnabled())
[ - + ]
4404 : 0 : bRecord = false;
4405 : :
4406 [ + - ][ + - ]: 12 : for (set<SCTAB>::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
[ + + ]
4407 : : {
4408 [ + - ][ + - ]: 6 : ScEditableTester aTester( pDoc, *itr, nStartCol, nStartRow, nEndCol, nEndRow );
4409 [ - + ]: 6 : if (!aTester.IsEditable())
4410 : : {
4411 [ # # ]: 0 : if (!bApi)
4412 [ # # ][ # # ]: 0 : rDocShell.ErrorMessage(aTester.GetMessageId());
4413 : 0 : return false;
4414 : : }
4415 : :
4416 [ + - ][ + - ]: 6 : if ( pDoc->HasAttrib( nStartCol, nStartRow, *itr, nEndCol, nEndRow, *itr,
[ + - ][ - + ]
4417 : 12 : HASATTR_MERGED | HASATTR_OVERLAPPED ) )
4418 : : {
4419 : : // "Zusammenfassen nicht verschachteln !"
4420 [ # # ]: 0 : if (!bApi)
4421 [ # # ]: 0 : rDocShell.ErrorMessage(STR_MSSG_MERGECELLS_0);
4422 : 6 : return false;
4423 : : }
4424 [ + - ]: 6 : }
4425 : :
4426 : 6 : ScDocument* pUndoDoc = NULL;
4427 : 6 : bool bNeedContentsUndo = false;
4428 [ + - ][ + - ]: 12 : for (set<SCTAB>::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
[ + + ]
4429 : : {
4430 [ + - ]: 6 : SCTAB nTab = *itr;
4431 : : bool bNeedContents = bContents &&
4432 [ # # ]: 0 : ( !pDoc->IsBlockEmpty( nTab, nStartCol,nStartRow+1, nStartCol,nEndRow, true ) ||
4433 [ - + ][ # # ]: 6 : !pDoc->IsBlockEmpty( nTab, nStartCol+1,nStartRow, nEndCol,nEndRow, true ) );
[ # # ][ # # ]
4434 : :
4435 [ + - ]: 6 : if (bRecord)
4436 : : {
4437 : : // test if the range contains other notes which also implies that we need an undo document
4438 : 6 : bool bHasNotes = false;
4439 [ + - ][ + - ]: 25 : for( ScAddress aPos( nStartCol, nStartRow, nTab ); !bHasNotes && (aPos.Col() <= nEndCol); aPos.IncCol() )
[ + + ][ + + ]
4440 [ + - ][ + - ]: 95 : for( aPos.SetRow( nStartRow ); !bHasNotes && (aPos.Row() <= nEndRow); aPos.IncRow() )
[ + + ][ + + ]
4441 [ + + ][ + + ]: 76 : bHasNotes = ((aPos.Col() != nStartCol) || (aPos.Row() != nStartRow)) && (pDoc->GetNotes( aPos.Tab() )->findByAddress(aPos) != 0);
[ + - ][ + - ]
[ - + ]
4442 : :
4443 [ + - ]: 6 : if (!pUndoDoc)
4444 : : {
4445 [ + - ][ + - ]: 6 : pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
4446 [ + - ]: 6 : pUndoDoc->InitUndo(pDoc, nTab1, nTab2);
4447 : : }
4448 : : // note captions are collected by drawing undo
4449 : : pDoc->CopyToDocument( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab,
4450 [ + - ]: 6 : IDF_ALL|IDF_NOCAPTIONS, false, pUndoDoc );
4451 [ - + ]: 6 : if( bHasNotes )
4452 [ # # ]: 0 : pDoc->BeginDrawUndo();
4453 : : }
4454 : :
4455 [ - + ]: 6 : if (bNeedContents)
4456 [ # # ]: 0 : pDoc->DoMergeContents( nTab, nStartCol,nStartRow, nEndCol,nEndRow );
4457 [ + - ]: 6 : pDoc->DoMerge( nTab, nStartCol,nStartRow, nEndCol,nEndRow );
4458 : :
4459 [ - + ]: 6 : if (rOption.mbCenter)
4460 : : {
4461 [ # # ][ # # ]: 0 : pDoc->ApplyAttr( nStartCol, nStartRow, nTab, SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY ) );
[ # # ]
4462 [ # # ][ # # ]: 0 : pDoc->ApplyAttr( nStartCol, nStartRow, nTab, SvxVerJustifyItem( SVX_VER_JUSTIFY_CENTER, ATTR_VER_JUSTIFY ) );
[ # # ]
4463 : : }
4464 : :
4465 [ + - ][ + + ]: 6 : if ( !AdjustRowHeight( ScRange( 0,nStartRow,nTab, MAXCOL,nEndRow,nTab ) ) )
4466 : : rDocShell.PostPaint( nStartCol, nStartRow, nTab,
4467 [ + - ]: 4 : nEndCol, nEndRow, nTab, PAINT_GRID );
4468 [ + - ][ - + ]: 6 : if (bNeedContents || rOption.mbCenter)
4469 : : {
4470 : 0 : ScRange aRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab);
4471 [ # # ]: 0 : pDoc->SetDirty(aRange);
4472 : : }
4473 : :
4474 : 6 : bNeedContentsUndo |= bNeedContents;
4475 : : }
4476 : :
4477 [ + - ]: 6 : if (pUndoDoc)
4478 : : {
4479 [ + - ][ + + ]: 6 : SdrUndoGroup* pDrawUndo = pDoc->GetDrawLayer() ? pDoc->GetDrawLayer()->GetCalcUndo() : NULL;
[ + - ][ + - ]
4480 [ + - ]: 6 : rDocShell.GetUndoManager()->AddUndoAction(
4481 [ + - ][ + - ]: 6 : new ScUndoMerge(&rDocShell, rOption, bNeedContentsUndo, pUndoDoc, pDrawUndo) );
[ + - ]
4482 : : }
4483 : :
4484 [ + - ]: 6 : aModificator.SetDocumentModified();
4485 : :
4486 [ + - ]: 6 : SfxBindings* pBindings = rDocShell.GetViewBindings();
4487 [ + + ]: 6 : if (pBindings)
4488 : : {
4489 [ + - ]: 3 : pBindings->Invalidate( FID_MERGE_ON );
4490 [ + - ]: 3 : pBindings->Invalidate( FID_MERGE_OFF );
4491 [ + - ]: 3 : pBindings->Invalidate( FID_MERGE_TOGGLE );
4492 : : }
4493 : :
4494 [ + - ]: 6 : return sal_True;
4495 : : }
4496 : :
4497 : 3 : sal_Bool ScDocFunc::UnmergeCells( const ScRange& rRange, sal_Bool bRecord )
4498 : : {
4499 [ + - ]: 3 : ScCellMergeOption aOption(rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row());
4500 : 3 : SCTAB nTab1 = rRange.aStart.Tab(), nTab2 = rRange.aEnd.Tab();
4501 [ + + ]: 6 : for (SCTAB i = nTab1; i <= nTab2; ++i)
4502 [ + - ]: 3 : aOption.maTabs.insert(i);
4503 : :
4504 [ + - ]: 3 : return UnmergeCells(aOption, bRecord);
4505 : : }
4506 : :
4507 : 6 : bool ScDocFunc::UnmergeCells( const ScCellMergeOption& rOption, sal_Bool bRecord )
4508 : : {
4509 : : using ::std::set;
4510 : :
4511 [ - + ]: 6 : if (rOption.maTabs.empty())
4512 : : // Nothing to unmerge.
4513 : 0 : return true;
4514 : :
4515 [ + - ]: 6 : ScDocShellModificator aModificator( rDocShell );
4516 : 6 : ScDocument* pDoc = rDocShell.GetDocument();
4517 : :
4518 [ - + ][ - + ]: 6 : if (bRecord && !pDoc->IsUndoEnabled())
[ + - ]
4519 : 0 : bRecord = false;
4520 : :
4521 : 6 : ScDocument* pUndoDoc = NULL;
4522 [ + - ][ + - ]: 12 : for (set<SCTAB>::const_iterator itr = rOption.maTabs.begin(), itrEnd = rOption.maTabs.end();
[ + + ]
4523 : : itr != itrEnd; ++itr)
4524 : : {
4525 [ + - ]: 6 : SCTAB nTab = *itr;
4526 [ + - ]: 6 : ScRange aRange = rOption.getSingleRange(nTab);
4527 [ + - ][ - + ]: 6 : if ( !pDoc->HasAttrib(aRange, HASATTR_MERGED) )
4528 : 0 : continue;
4529 : :
4530 : 6 : ScRange aExtended = aRange;
4531 [ + - ]: 6 : pDoc->ExtendMerge(aExtended);
4532 : 6 : ScRange aRefresh = aExtended;
4533 [ + - ]: 6 : pDoc->ExtendOverlapped(aRefresh);
4534 : :
4535 [ + - ]: 6 : if (bRecord)
4536 : : {
4537 [ + - ]: 6 : if (!pUndoDoc)
4538 : : {
4539 [ + - ][ + - ]: 6 : pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
4540 [ + - ][ + - ]: 6 : pUndoDoc->InitUndo(pDoc, *rOption.maTabs.begin(), *rOption.maTabs.rbegin());
[ + - ]
4541 : : }
4542 [ + - ]: 6 : pDoc->CopyToDocument(aExtended, IDF_ATTRIB, false, pUndoDoc);
4543 : : }
4544 : :
4545 [ + - ][ + - ]: 6 : const SfxPoolItem& rDefAttr = pDoc->GetPool()->GetDefaultItem( ATTR_MERGE );
4546 [ + - ][ + - ]: 6 : ScPatternAttr aPattern( pDoc->GetPool() );
4547 [ + - ]: 6 : aPattern.GetItemSet().Put( rDefAttr );
4548 : 6 : pDoc->ApplyPatternAreaTab( aRange.aStart.Col(), aRange.aStart.Row(),
4549 : 6 : aRange.aEnd.Col(), aRange.aEnd.Row(), nTab,
4550 [ + - ]: 18 : aPattern );
4551 : :
4552 : 6 : pDoc->RemoveFlagsTab( aExtended.aStart.Col(), aExtended.aStart.Row(),
4553 : 6 : aExtended.aEnd.Col(), aExtended.aEnd.Row(), nTab,
4554 [ + - ]: 18 : SC_MF_HOR | SC_MF_VER );
4555 : :
4556 [ + - ]: 6 : pDoc->ExtendMerge( aRefresh, sal_True );
4557 : :
4558 [ + - ][ + + ]: 6 : if ( !AdjustRowHeight( aExtended ) )
4559 [ + - ][ + - ]: 3 : rDocShell.PostPaint( aExtended, PAINT_GRID );
[ + - ]
4560 [ + - ]: 6 : }
4561 : :
4562 [ + - ]: 6 : if (bRecord)
4563 : : {
4564 [ + - ]: 6 : rDocShell.GetUndoManager()->AddUndoAction(
4565 [ + - ][ + - ]: 6 : new ScUndoRemoveMerge( &rDocShell, rOption, pUndoDoc ) );
[ + - ]
4566 : : }
4567 [ + - ]: 6 : aModificator.SetDocumentModified();
4568 : :
4569 [ + - ]: 6 : return sal_True;
4570 : : }
4571 : :
4572 : : //------------------------------------------------------------------------
4573 : :
4574 : 4 : bool ScDocFunc::ModifyRangeNames( const ScRangeName& rNewRanges, SCTAB nTab )
4575 : : {
4576 [ + - ]: 4 : return SetNewRangeNames( new ScRangeName(rNewRanges), true, nTab );
4577 : : }
4578 : :
4579 : 39 : bool ScDocFunc::SetNewRangeNames( ScRangeName* pNewRanges, bool bModifyDoc, SCTAB nTab ) // takes ownership of pNewRanges
4580 : : {
4581 [ + - ]: 39 : ScDocShellModificator aModificator( rDocShell );
4582 : :
4583 : : OSL_ENSURE( pNewRanges, "pNewRanges is 0" );
4584 : 39 : ScDocument* pDoc = rDocShell.GetDocument();
4585 : 39 : bool bUndo(pDoc->IsUndoEnabled());
4586 : :
4587 [ + - ]: 39 : if (bUndo)
4588 : : {
4589 : : ScRangeName* pOld;
4590 [ - + ]: 39 : if (nTab >=0)
4591 : : {
4592 [ # # ]: 0 : pOld = pDoc->GetRangeName(nTab);
4593 : : }
4594 : : else
4595 : : {
4596 [ + - ]: 39 : pOld = pDoc->GetRangeName();
4597 : : }
4598 [ + - ][ + - ]: 39 : ScRangeName* pUndoRanges = new ScRangeName(*pOld);
4599 [ + - ][ + - ]: 39 : ScRangeName* pRedoRanges = new ScRangeName(*pNewRanges);
4600 [ + - ]: 39 : rDocShell.GetUndoManager()->AddUndoAction(
4601 [ + - ][ + - ]: 39 : new ScUndoRangeNames( &rDocShell, pUndoRanges, pRedoRanges, nTab ) );
[ + - ]
4602 : : }
4603 : :
4604 : : // #i55926# While loading XML, formula cells only have a single string token,
4605 : : // so CompileNameFormula would never find any name (index) tokens, and would
4606 : : // unnecessarily loop through all cells.
4607 [ + - ][ + - ]: 39 : sal_Bool bCompile = ( !pDoc->IsImportingXML() && pDoc->GetNamedRangesLockCount() == 0 );
[ + - ]
4608 : :
4609 [ + - ]: 39 : if ( bCompile )
4610 [ + - ]: 39 : pDoc->CompileNameFormula( sal_True ); // CreateFormulaString
4611 [ - + ]: 39 : if (nTab >= 0)
4612 [ # # ]: 0 : pDoc->SetRangeName( nTab, pNewRanges ); // takes ownership
4613 : : else
4614 [ + - ]: 39 : pDoc->SetRangeName( pNewRanges ); // takes ownership
4615 [ + - ]: 39 : if ( bCompile )
4616 [ + - ]: 39 : pDoc->CompileNameFormula( false ); // CompileFormulaString
4617 : :
4618 [ + - ]: 39 : if (bModifyDoc)
4619 : : {
4620 [ + - ]: 39 : aModificator.SetDocumentModified();
4621 [ + - ][ + - ]: 39 : SFX_APP()->Broadcast( SfxSimpleHint(SC_HINT_AREAS_CHANGED) );
[ + - ][ + - ]
4622 : : }
4623 : :
4624 [ + - ]: 39 : return true;
4625 : : }
4626 : :
4627 : 0 : void ScDocFunc::ModifyAllRangeNames( const boost::ptr_map<rtl::OUString, ScRangeName>& rRangeMap )
4628 : : {
4629 [ # # ]: 0 : ScDocShellModificator aModificator(rDocShell);
4630 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
4631 : :
4632 [ # # ]: 0 : if (pDoc->IsUndoEnabled())
4633 : : {
4634 [ # # ]: 0 : std::map<rtl::OUString, ScRangeName*> aOldRangeMap;
4635 [ # # ]: 0 : pDoc->GetRangeNameMap(aOldRangeMap);
4636 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
4637 [ # # ][ # # ]: 0 : new ScUndoAllRangeNames(&rDocShell, aOldRangeMap, rRangeMap));
[ # # ]
4638 : : }
4639 : :
4640 [ # # ]: 0 : pDoc->CompileNameFormula(true);
4641 : :
4642 : : // set all range names
4643 [ # # ]: 0 : pDoc->SetAllRangeNames(rRangeMap);
4644 : :
4645 [ # # ]: 0 : pDoc->CompileNameFormula(false);
4646 : :
4647 [ # # ]: 0 : aModificator.SetDocumentModified();
4648 [ # # ][ # # ]: 0 : SFX_APP()->Broadcast(SfxSimpleHint(SC_HINT_AREAS_CHANGED));
[ # # ][ # # ]
[ # # ]
4649 : 0 : }
4650 : :
4651 : : //------------------------------------------------------------------------
4652 : :
4653 : 16 : void ScDocFunc::CreateOneName( ScRangeName& rList,
4654 : : SCCOL nPosX, SCROW nPosY, SCTAB nTab,
4655 : : SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
4656 : : sal_Bool& rCancel, sal_Bool bApi )
4657 : : {
4658 [ - + ]: 16 : if (rCancel)
4659 : 16 : return;
4660 : :
4661 : 16 : ScDocument* pDoc = rDocShell.GetDocument();
4662 [ + - ]: 16 : if (!pDoc->HasValueData( nPosX, nPosY, nTab ))
4663 : : {
4664 [ + - ]: 16 : String aName;
4665 [ + - ]: 16 : pDoc->GetString( nPosX, nPosY, nTab, aName );
4666 [ + - ]: 16 : ScRangeData::MakeValidName(aName);
4667 [ + + ]: 16 : if (aName.Len())
4668 : : {
4669 [ + - ]: 12 : String aContent;
4670 [ + - ]: 12 : ScRange( nX1, nY1, nTab, nX2, nY2, nTab ).Format( aContent, SCR_ABS_3D, pDoc );
4671 : :
4672 : 12 : bool bInsert = false;
4673 [ + - ][ + - ]: 12 : ScRangeData* pOld = rList.findByUpperName(ScGlobal::pCharClass->uppercase(aName));
[ + - ]
4674 [ - + ]: 12 : if (pOld)
4675 : : {
4676 [ # # ]: 0 : String aOldStr;
4677 [ # # ]: 0 : pOld->GetSymbol( aOldStr );
4678 [ # # ][ # # ]: 0 : if (aOldStr != aContent)
4679 : : {
4680 [ # # ]: 0 : if (bApi)
4681 : 0 : bInsert = sal_True; // per API nicht nachfragen
4682 : : else
4683 : : {
4684 [ # # ][ # # ]: 0 : String aTemplate = ScGlobal::GetRscString( STR_CREATENAME_REPLACE );
4685 : :
4686 [ # # ]: 0 : String aMessage = aTemplate.GetToken( 0, '#' );
4687 [ # # ]: 0 : aMessage += aName;
4688 [ # # ][ # # ]: 0 : aMessage += aTemplate.GetToken( 1, '#' );
[ # # ]
4689 : :
4690 : : short nResult = QueryBox( rDocShell.GetActiveDialogParent(),
4691 : : WinBits(WB_YES_NO_CANCEL | WB_DEF_YES),
4692 [ # # ][ # # ]: 0 : aMessage ).Execute();
[ # # ][ # # ]
4693 [ # # ]: 0 : if ( nResult == RET_YES )
4694 : : {
4695 [ # # ]: 0 : rList.erase(*pOld);
4696 : 0 : bInsert = true;
4697 : : }
4698 [ # # ]: 0 : else if ( nResult == RET_CANCEL )
4699 [ # # ][ # # ]: 0 : rCancel = sal_True;
4700 : : }
4701 [ # # ]: 0 : }
4702 : : }
4703 : : else
4704 : 12 : bInsert = true;
4705 : :
4706 [ + - ]: 12 : if (bInsert)
4707 : : {
4708 : : ScRangeData* pData = new ScRangeData( pDoc, aName, aContent,
4709 [ + - ][ + - ]: 12 : ScAddress( nPosX, nPosY, nTab));
[ + - ]
4710 [ + - ]: 12 : if (!rList.insert(pData))
4711 : : {
4712 : : OSL_FAIL("nanu?");
4713 : : }
4714 [ + - ]: 12 : }
4715 [ + - ]: 16 : }
4716 : : }
4717 : : }
4718 : :
4719 : 4 : sal_Bool ScDocFunc::CreateNames( const ScRange& rRange, sal_uInt16 nFlags, sal_Bool bApi, SCTAB aTab )
4720 : : {
4721 [ - + ]: 4 : if (!nFlags)
4722 : 0 : return false; // war nix
4723 : :
4724 [ + - ]: 4 : ScDocShellModificator aModificator( rDocShell );
4725 : :
4726 : 4 : sal_Bool bDone = false;
4727 : 4 : SCCOL nStartCol = rRange.aStart.Col();
4728 : 4 : SCROW nStartRow = rRange.aStart.Row();
4729 : 4 : SCCOL nEndCol = rRange.aEnd.Col();
4730 : 4 : SCROW nEndRow = rRange.aEnd.Row();
4731 : 4 : SCTAB nTab = rRange.aStart.Tab();
4732 : : OSL_ENSURE(rRange.aEnd.Tab() == nTab, "CreateNames: mehrere Tabellen geht nicht");
4733 : :
4734 : 4 : sal_Bool bValid = sal_True;
4735 [ + + ]: 4 : if ( nFlags & ( NAME_TOP | NAME_BOTTOM ) )
4736 [ - + ]: 2 : if ( nStartRow == nEndRow )
4737 : 0 : bValid = false;
4738 [ + + ]: 4 : if ( nFlags & ( NAME_LEFT | NAME_RIGHT ) )
4739 [ - + ]: 2 : if ( nStartCol == nEndCol )
4740 : 0 : bValid = false;
4741 : :
4742 [ + - ]: 4 : if (bValid)
4743 : : {
4744 : 4 : ScDocument* pDoc = rDocShell.GetDocument();
4745 : : ScRangeName* pNames;
4746 [ - + ]: 4 : if (aTab >=0)
4747 [ # # ]: 0 : pNames = pDoc->GetRangeName(nTab);
4748 : : else
4749 [ + - ]: 4 : pNames = pDoc->GetRangeName();
4750 : :
4751 [ - + ]: 4 : if (!pNames)
4752 : 0 : return false; // soll nicht sein
4753 [ + - ]: 4 : ScRangeName aNewRanges( *pNames );
4754 : :
4755 : 4 : sal_Bool bTop = ( ( nFlags & NAME_TOP ) != 0 );
4756 : 4 : sal_Bool bLeft = ( ( nFlags & NAME_LEFT ) != 0 );
4757 : 4 : sal_Bool bBottom = ( ( nFlags & NAME_BOTTOM ) != 0 );
4758 : 4 : sal_Bool bRight = ( ( nFlags & NAME_RIGHT ) != 0 );
4759 : :
4760 : 4 : SCCOL nContX1 = nStartCol;
4761 : 4 : SCROW nContY1 = nStartRow;
4762 : 4 : SCCOL nContX2 = nEndCol;
4763 : 4 : SCROW nContY2 = nEndRow;
4764 : :
4765 [ + + ]: 4 : if ( bTop )
4766 : 2 : ++nContY1;
4767 [ + + ]: 4 : if ( bLeft )
4768 : 2 : ++nContX1;
4769 [ - + ]: 4 : if ( bBottom )
4770 : 0 : --nContY2;
4771 [ - + ]: 4 : if ( bRight )
4772 : 0 : --nContX2;
4773 : :
4774 : 4 : sal_Bool bCancel = false;
4775 : : SCCOL i;
4776 : : SCROW j;
4777 : :
4778 [ + + ]: 4 : if ( bTop )
4779 [ + + ]: 10 : for (i=nContX1; i<=nContX2; i++)
4780 [ + - ]: 8 : CreateOneName( aNewRanges, i,nStartRow,nTab, i,nContY1,i,nContY2, bCancel, bApi );
4781 [ + + ]: 4 : if ( bLeft )
4782 [ + + ]: 10 : for (j=nContY1; j<=nContY2; j++)
4783 [ + - ]: 8 : CreateOneName( aNewRanges, nStartCol,j,nTab, nContX1,j,nContX2,j, bCancel, bApi );
4784 [ - + ]: 4 : if ( bBottom )
4785 [ # # ]: 0 : for (i=nContX1; i<=nContX2; i++)
4786 [ # # ]: 0 : CreateOneName( aNewRanges, i,nEndRow,nTab, i,nContY1,i,nContY2, bCancel, bApi );
4787 [ - + ]: 4 : if ( bRight )
4788 [ # # ]: 0 : for (j=nContY1; j<=nContY2; j++)
4789 [ # # ]: 0 : CreateOneName( aNewRanges, nEndCol,j,nTab, nContX1,j,nContX2,j, bCancel, bApi );
4790 : :
4791 [ + + ][ - + ]: 4 : if ( bTop && bLeft )
4792 [ # # ]: 0 : CreateOneName( aNewRanges, nStartCol,nStartRow,nTab, nContX1,nContY1,nContX2,nContY2, bCancel, bApi );
4793 [ + + ][ - + ]: 4 : if ( bTop && bRight )
4794 [ # # ]: 0 : CreateOneName( aNewRanges, nEndCol,nStartRow,nTab, nContX1,nContY1,nContX2,nContY2, bCancel, bApi );
4795 [ - + ][ # # ]: 4 : if ( bBottom && bLeft )
4796 [ # # ]: 0 : CreateOneName( aNewRanges, nStartCol,nEndRow,nTab, nContX1,nContY1,nContX2,nContY2, bCancel, bApi );
4797 [ - + ][ # # ]: 4 : if ( bBottom && bRight )
4798 [ # # ]: 0 : CreateOneName( aNewRanges, nEndCol,nEndRow,nTab, nContX1,nContY1,nContX2,nContY2, bCancel, bApi );
4799 : :
4800 [ + - ]: 4 : bDone = ModifyRangeNames( aNewRanges, aTab );
4801 : :
4802 [ + - ]: 4 : aModificator.SetDocumentModified();
4803 [ + - ][ + - ]: 4 : SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
[ + - ][ + - ]
[ + - ]
4804 : : }
4805 : :
4806 [ + - ]: 4 : return bDone;
4807 : : }
4808 : :
4809 : : //------------------------------------------------------------------------
4810 : :
4811 : 5 : sal_Bool ScDocFunc::InsertNameList( const ScAddress& rStartPos, sal_Bool bApi )
4812 : : {
4813 [ + - ]: 5 : ScDocShellModificator aModificator( rDocShell );
4814 : :
4815 : 5 : sal_Bool bDone = false;
4816 : 5 : ScDocument* pDoc = rDocShell.GetDocument();
4817 : 5 : const bool bRecord = pDoc->IsUndoEnabled();
4818 : 5 : SCTAB nTab = rStartPos.Tab();
4819 : 5 : ScDocument* pUndoDoc = NULL;
4820 : :
4821 : : //local names have higher priority than global names
4822 [ + - ]: 5 : ScRangeName* pLocalList = pDoc->GetRangeName(nTab);
4823 : 5 : sal_uInt16 nValidCount = 0;
4824 [ + - ][ + - ]: 5 : ScRangeName::iterator itrLocalBeg = pLocalList->begin(), itrLocalEnd = pLocalList->end();
4825 [ # # ][ + - ]: 5 : for (ScRangeName::iterator itr = itrLocalBeg; itr != itrLocalEnd; ++itr)
[ - + ]
4826 : : {
4827 [ # # ]: 0 : const ScRangeData& r = *itr->second;
4828 [ # # ][ # # ]: 0 : if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED))
[ # # ]
4829 : 0 : ++nValidCount;
4830 : : }
4831 [ + - ]: 5 : ScRangeName* pList = pDoc->GetRangeName();
4832 [ + - ][ + - ]: 5 : ScRangeName::iterator itrBeg = pList->begin(), itrEnd = pList->end();
4833 [ + - ][ + - ]: 38 : for (ScRangeName::iterator itr = itrBeg; itr != itrEnd; ++itr)
[ + + ]
4834 : : {
4835 [ + - ]: 33 : const ScRangeData& r = *itr->second;
4836 [ + - ][ + - ]: 33 : if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED) && !pLocalList->findByUpperName(r.GetUpperName()))
[ + - ][ + - ]
[ + - ]
4837 : 33 : ++nValidCount;
4838 : : }
4839 : :
4840 [ + - ]: 5 : if (nValidCount)
4841 : : {
4842 : 5 : SCCOL nStartCol = rStartPos.Col();
4843 : 5 : SCROW nStartRow = rStartPos.Row();
4844 : 5 : SCCOL nEndCol = nStartCol + 1;
4845 : 5 : SCROW nEndRow = nStartRow + static_cast<SCROW>(nValidCount) - 1;
4846 : :
4847 [ + - ]: 5 : ScEditableTester aTester( pDoc, nTab, nStartCol,nStartRow, nEndCol,nEndRow );
4848 [ + - ]: 5 : if (aTester.IsEditable())
4849 : : {
4850 [ + - ]: 5 : if (bRecord)
4851 : : {
4852 [ + - ][ + - ]: 5 : pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
4853 [ + - ]: 5 : pUndoDoc->InitUndo( pDoc, nTab, nTab );
4854 : : pDoc->CopyToDocument( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab,
4855 [ + - ]: 5 : IDF_ALL, false, pUndoDoc );
4856 : :
4857 [ + - ]: 5 : pDoc->BeginDrawUndo(); // wegen Hoehenanpassung
4858 : : }
4859 : :
4860 [ + - ]: 5 : ScRangeData** ppSortArray = new ScRangeData* [ nValidCount ];
4861 : 5 : sal_uInt16 j = 0;
4862 [ # # ][ + - ]: 5 : for (ScRangeName::iterator itr = itrLocalBeg; itr != itrLocalEnd; ++itr)
[ - + ]
4863 : : {
4864 [ # # ]: 0 : ScRangeData& r = *itr->second;
4865 [ # # ][ # # ]: 0 : if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED))
[ # # ]
4866 : 0 : ppSortArray[j++] = &r;
4867 : : }
4868 [ + - ][ + - ]: 38 : for (ScRangeName::iterator itr = itrBeg; itr != itrEnd; ++itr)
[ + + ]
4869 : : {
4870 [ + - ]: 33 : ScRangeData& r = *itr->second;
4871 [ + - ][ + - ]: 33 : if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED) && !pLocalList->findByUpperName(itr->first))
[ + - ][ + - ]
[ + - ]
[ + - # # ]
[ + - ]
4872 : 33 : ppSortArray[j++] = &r;
4873 : : }
4874 : : #ifndef ICC
4875 : : qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
4876 [ + - ]: 5 : &ScRangeData_QsortNameCompare );
4877 : : #else
4878 : : qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
4879 : : ICCQsortNameCompare );
4880 : : #endif
4881 : 5 : rtl::OUString aName;
4882 : 5 : rtl::OUStringBuffer aContent;
4883 [ + - ]: 5 : String aFormula;
4884 : 5 : SCROW nOutRow = nStartRow;
4885 [ + + ]: 38 : for (j=0; j<nValidCount; j++)
4886 : : {
4887 : 33 : ScRangeData* pData = ppSortArray[j];
4888 : 33 : pData->GetName(aName);
4889 : : // relative Referenzen Excel-konform auf die linke Spalte anpassen:
4890 [ + - ]: 33 : pData->UpdateSymbol(aContent, ScAddress( nStartCol, nOutRow, nTab ));
4891 [ + - ]: 33 : aFormula = '=';
4892 [ + - ]: 33 : aFormula += aContent.toString();
4893 [ + - ][ + - ]: 33 : pDoc->PutCell( nStartCol,nOutRow,nTab, new ScStringCell( aName ) );
[ + - ]
4894 [ + - ][ + - ]: 33 : pDoc->PutCell( nEndCol ,nOutRow,nTab, new ScStringCell( aFormula ) );
[ + - ][ + - ]
4895 : 33 : ++nOutRow;
4896 : : }
4897 : :
4898 [ + - ]: 5 : delete [] ppSortArray;
4899 : :
4900 [ + - ]: 5 : if (bRecord)
4901 : : {
4902 [ + - ][ + - ]: 5 : ScDocument* pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
4903 [ + - ]: 5 : pRedoDoc->InitUndo( pDoc, nTab, nTab );
4904 : : pDoc->CopyToDocument( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab,
4905 [ + - ]: 5 : IDF_ALL, false, pRedoDoc );
4906 : :
4907 [ + - ]: 5 : rDocShell.GetUndoManager()->AddUndoAction(
4908 : : new ScUndoListNames( &rDocShell,
4909 : : ScRange( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab ),
4910 [ + - ][ + - ]: 5 : pUndoDoc, pRedoDoc ) );
[ + - ]
4911 : : }
4912 : :
4913 [ + - ][ + + ]: 5 : if (!AdjustRowHeight(ScRange(0,nStartRow,nTab,MAXCOL,nEndRow,nTab)))
4914 [ + - ]: 2 : rDocShell.PostPaint( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab, PAINT_GRID );
4915 : :
4916 [ + - ]: 5 : aModificator.SetDocumentModified();
4917 [ + - ]: 5 : bDone = sal_True;
4918 : : }
4919 [ # # ]: 0 : else if (!bApi)
4920 [ # # ][ # # ]: 5 : rDocShell.ErrorMessage(aTester.GetMessageId());
4921 : : }
4922 [ + - ]: 5 : return bDone;
4923 : : }
4924 : :
4925 : : //------------------------------------------------------------------------
4926 : :
4927 : 0 : sal_Bool ScDocFunc::ResizeMatrix( const ScRange& rOldRange, const ScAddress& rNewEnd, sal_Bool bApi )
4928 : : {
4929 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
4930 : 0 : SCCOL nStartCol = rOldRange.aStart.Col();
4931 : 0 : SCROW nStartRow = rOldRange.aStart.Row();
4932 : 0 : SCTAB nTab = rOldRange.aStart.Tab();
4933 : :
4934 : 0 : bool bUndo(pDoc->IsUndoEnabled());
4935 : :
4936 : 0 : sal_Bool bRet = false;
4937 : :
4938 [ # # ]: 0 : String aFormula;
4939 [ # # ]: 0 : pDoc->GetFormula( nStartCol, nStartRow, nTab, aFormula );
4940 [ # # ][ # # ]: 0 : if ( aFormula.GetChar(0) == '{' && aFormula.GetChar(aFormula.Len()-1) == '}' )
[ # # ]
4941 : : {
4942 [ # # ][ # # ]: 0 : String aUndo = ScGlobal::GetRscString( STR_UNDO_RESIZEMATRIX );
4943 [ # # ]: 0 : if (bUndo)
4944 [ # # ][ # # ]: 0 : rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo );
4945 : :
4946 [ # # ]: 0 : aFormula.Erase(0,1);
4947 [ # # ]: 0 : aFormula.Erase(aFormula.Len()-1,1);
4948 : :
4949 [ # # ]: 0 : ScMarkData aMark;
4950 [ # # ]: 0 : aMark.SetMarkArea( rOldRange );
4951 [ # # ]: 0 : aMark.SelectTable( nTab, sal_True );
4952 : 0 : ScRange aNewRange( rOldRange.aStart, rNewEnd );
4953 : :
4954 [ # # ][ # # ]: 0 : if ( DeleteContents( aMark, IDF_CONTENTS, sal_True, bApi ) )
4955 : : {
4956 : : // GRAM_PODF_A1 for API compatibility.
4957 [ # # ][ # # ]: 0 : bRet = EnterMatrix( aNewRange, &aMark, NULL, aFormula, bApi, false, EMPTY_STRING, formula::FormulaGrammar::GRAM_PODF_A1 );
4958 [ # # ]: 0 : if (!bRet)
4959 : : {
4960 : : // versuchen, alten Zustand wiederherzustellen
4961 [ # # ][ # # ]: 0 : EnterMatrix( rOldRange, &aMark, NULL, aFormula, bApi, false, EMPTY_STRING, formula::FormulaGrammar::GRAM_PODF_A1 );
4962 : : }
4963 : : }
4964 : :
4965 [ # # ]: 0 : if (bUndo)
4966 [ # # ][ # # ]: 0 : rDocShell.GetUndoManager()->LeaveListAction();
[ # # ][ # # ]
4967 : : }
4968 : :
4969 [ # # ]: 0 : return bRet;
4970 : : }
4971 : :
4972 : : //------------------------------------------------------------------------
4973 : :
4974 : 16 : sal_Bool ScDocFunc::InsertAreaLink( const String& rFile, const String& rFilter,
4975 : : const String& rOptions, const String& rSource,
4976 : : const ScRange& rDestRange, sal_uLong nRefresh,
4977 : : sal_Bool bFitBlock, sal_Bool bApi )
4978 : : {
4979 : 16 : ScDocument* pDoc = rDocShell.GetDocument();
4980 : 16 : sal_Bool bUndo (pDoc->IsUndoEnabled());
4981 : :
4982 [ + - ]: 16 : sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
4983 : :
4984 : : // #i52120# if other area links exist at the same start position,
4985 : : // remove them first (file format specifies only one link definition
4986 : : // for a cell)
4987 : :
4988 : 16 : sal_uInt16 nLinkCount = pLinkManager->GetLinks().size();
4989 : 16 : sal_uInt16 nRemoved = 0;
4990 : 16 : sal_uInt16 nLinkPos = 0;
4991 [ - + ]: 16 : while (nLinkPos<nLinkCount)
4992 : : {
4993 : 0 : ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[nLinkPos];
4994 [ # # ]: 0 : if ( pBase->ISA(ScAreaLink) &&
[ # # # # ]
[ # # ][ # # ]
4995 : 0 : static_cast<ScAreaLink*>(pBase)->GetDestArea().aStart == rDestRange.aStart )
4996 : : {
4997 [ # # ]: 0 : if ( bUndo )
4998 : : {
4999 [ # # ]: 0 : if ( !nRemoved )
5000 : : {
5001 : : // group all remove and the insert action
5002 [ # # ][ # # ]: 0 : String aUndo = ScGlobal::GetRscString( STR_UNDO_INSERTAREALINK );
5003 [ # # ][ # # ]: 0 : rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo );
[ # # ]
5004 : : }
5005 : :
5006 : 0 : ScAreaLink* pOldArea = static_cast<ScAreaLink*>(pBase);
5007 [ # # ]: 0 : rDocShell.GetUndoManager()->AddUndoAction(
5008 : : new ScUndoRemoveAreaLink( &rDocShell,
5009 : : pOldArea->GetFile(), pOldArea->GetFilter(), pOldArea->GetOptions(),
5010 [ # # ][ # # ]: 0 : pOldArea->GetSource(), pOldArea->GetDestArea(), pOldArea->GetRefreshDelay() ) );
[ # # ]
5011 : : }
5012 [ # # ]: 0 : pLinkManager->Remove( pBase );
5013 : 0 : nLinkCount = pLinkManager->GetLinks().size();
5014 : 0 : ++nRemoved;
5015 : : }
5016 : : else
5017 : 0 : ++nLinkPos;
5018 : : }
5019 : :
5020 [ + - ]: 16 : rtl::OUString aFilterName = rFilter;
5021 [ + - ]: 16 : rtl::OUString aNewOptions = rOptions;
5022 [ + + ]: 16 : if (aFilterName.isEmpty())
5023 [ + - ][ + - ]: 3 : ScDocumentLoader::GetFilterName( rFile, aFilterName, aNewOptions, true, !bApi );
5024 : :
5025 : : // remove application prefix from filter name here, so the filter options
5026 : : // aren't reset when the filter name is changed in ScAreaLink::DataChanged
5027 [ + - ]: 16 : ScDocumentLoader::RemoveAppPrefix( aFilterName );
5028 : :
5029 : : ScAreaLink* pLink = new ScAreaLink( &rDocShell, rFile, aFilterName,
5030 [ + - ][ + - ]: 16 : aNewOptions, rSource, rDestRange, nRefresh );
[ + - ][ + - ]
[ + - ][ + - ]
5031 [ + - ]: 16 : String aTmp = aFilterName;
5032 [ + - ]: 16 : pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, rFile, &aTmp, &rSource );
5033 : :
5034 : : // Undo fuer den leeren Link
5035 : :
5036 [ + - ]: 16 : if (bUndo)
5037 : : {
5038 [ + - ]: 16 : rDocShell.GetUndoManager()->AddUndoAction( new ScUndoInsertAreaLink( &rDocShell,
5039 : : rFile, aFilterName, aNewOptions,
5040 [ + - ][ + - ]: 16 : rSource, rDestRange, nRefresh ) );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
5041 [ - + ]: 16 : if ( nRemoved )
5042 [ # # ][ # # ]: 0 : rDocShell.GetUndoManager()->LeaveListAction(); // undo for link update is still separate
5043 : : }
5044 : :
5045 : : // Update hat sein eigenes Undo
5046 [ + - ]: 16 : if (pDoc->IsExecuteLinkEnabled())
5047 : : {
5048 : 16 : pLink->SetDoInsert(bFitBlock); // beim ersten Update ggf. nichts einfuegen
5049 [ + - ]: 16 : pLink->Update(); // kein SetInCreate -> Update ausfuehren
5050 : : }
5051 : 16 : pLink->SetDoInsert(sal_True); // Default = sal_True
5052 : :
5053 [ + - ]: 16 : SfxBindings* pBindings = rDocShell.GetViewBindings();
5054 [ + - ]: 16 : if (pBindings)
5055 [ + - ]: 16 : pBindings->Invalidate( SID_LINKS );
5056 : :
5057 [ + - ][ + - ]: 16 : SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator
[ + - ][ + - ]
5058 : :
5059 [ + - ]: 16 : return sal_True;
5060 : : }
5061 : :
5062 : 0 : void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFormat* pFormat, SCTAB nTab, const ScRangeList& rRanges )
5063 : : {
5064 [ # # ]: 0 : ScDocShellModificator aModificator(rDocShell);
5065 : 0 : ScDocument* pDoc = rDocShell.GetDocument();
5066 [ # # ]: 0 : if(nOldFormat)
5067 : : {
5068 [ # # ]: 0 : pDoc->DeleteConditionalFormat(nOldFormat, nTab);
5069 : : }
5070 [ # # ]: 0 : if(pFormat)
5071 : : {
5072 [ # # ]: 0 : sal_uLong nIndex = pDoc->AddCondFormat(pFormat, nTab);
5073 : :
5074 [ # # ][ # # ]: 0 : ScPatternAttr aPattern( pDoc->GetPool() );
5075 [ # # ][ # # ]: 0 : aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
[ # # ]
5076 [ # # ]: 0 : ScMarkData aMarkData;
5077 [ # # ]: 0 : aMarkData.MarkFromRangeList(rRanges, true);
5078 [ # # ]: 0 : pDoc->ApplySelectionPattern( aPattern , aMarkData );
5079 [ # # ]: 0 : size_t n = rRanges.size();
5080 [ # # ]: 0 : for(size_t i = 0; i < n; ++i)
5081 [ # # ][ # # ]: 0 : pFormat->DoRepaint(rRanges[i]);
[ # # ][ # # ]
5082 : : }
5083 [ # # ]: 0 : aModificator.SetDocumentModified();
5084 [ # # ][ # # ]: 0 : SFX_APP()->Broadcast(SfxSimpleHint(SC_HINT_AREAS_CHANGED));
[ # # ][ # # ]
[ # # ]
5085 : 0 : }
5086 : :
5087 : 0 : void ScDocFunc::EnterListAction( sal_uInt16 nNameResId )
5088 : : {
5089 [ # # ][ # # ]: 0 : String aUndo( ScGlobal::GetRscString( nNameResId ) );
5090 [ # # ][ # # ]: 0 : rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo );
[ # # ]
5091 : 0 : }
5092 : :
5093 : 0 : void ScDocFunc::EndListAction()
5094 : : {
5095 : 0 : rDocShell.GetUndoManager()->LeaveListAction();
5096 : 0 : }
5097 : :
5098 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|