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 <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
30 : : #include <com/sun/star/document/XDocumentProperties.hpp>
31 : :
32 : : #include "scitems.hxx"
33 : : #include "rangelst.hxx"
34 : : #include <editeng/flstitem.hxx>
35 : : #include <editeng/paperinf.hxx>
36 : : #include <editeng/sizeitem.hxx>
37 : : #include <rtl/strbuf.hxx>
38 : : #include <sfx2/viewfrm.hxx>
39 : : #include <sfx2/app.hxx>
40 : : #include <sfx2/docfile.hxx>
41 : : #include <sfx2/printer.hxx>
42 : : #include <svx/postattr.hxx>
43 : : #include <unotools/misccfg.hxx>
44 : : #include <vcl/virdev.hxx>
45 : : #include <vcl/msgbox.hxx>
46 : :
47 : : #include "docsh.hxx"
48 : : #include "docshimp.hxx"
49 : : #include "scmod.hxx"
50 : : #include "tabvwsh.hxx"
51 : : #include "viewdata.hxx"
52 : : #include "docpool.hxx"
53 : : #include "stlpool.hxx"
54 : : #include "patattr.hxx"
55 : : #include "uiitems.hxx"
56 : : #include "hints.hxx"
57 : : #include "docoptio.hxx"
58 : : #include "viewopti.hxx"
59 : : #include "pntlock.hxx"
60 : : #include "chgtrack.hxx"
61 : : #include "docfunc.hxx"
62 : : #include "cell.hxx"
63 : : #include "chgviset.hxx"
64 : : #include "progress.hxx"
65 : : #include "redcom.hxx"
66 : : #include "sc.hrc"
67 : : #include "inputopt.hxx"
68 : : #include "drwlayer.hxx"
69 : : #include "inputhdl.hxx"
70 : : #include "conflictsdlg.hxx"
71 : : #include "globstr.hrc"
72 : : #include "markdata.hxx"
73 : :
74 : : //------------------------------------------------------------------
75 : :
76 : : //
77 : : // Redraw - Benachrichtigungen
78 : : //
79 : :
80 : :
81 : 0 : void ScDocShell::PostEditView( ScEditEngineDefaulter* pEditEngine, const ScAddress& rCursorPos )
82 : : {
83 : : // Broadcast( ScEditViewHint( pEditEngine, rCursorPos ) );
84 : :
85 : : // Test: nur aktive ViewShell
86 : :
87 : 0 : ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
88 [ # # ][ # # ]: 0 : if (pViewSh && pViewSh->GetViewData()->GetDocShell() == this)
[ # # ]
89 : : {
90 [ # # ]: 0 : ScEditViewHint aHint( pEditEngine, rCursorPos );
91 [ # # ][ # # ]: 0 : pViewSh->Notify( *this, aHint );
92 : : }
93 : 0 : }
94 : :
95 : 4106 : void ScDocShell::PostDataChanged()
96 : : {
97 [ + - ]: 4106 : Broadcast( SfxSimpleHint( FID_DATACHANGED ) );
98 [ + - ][ + - ]: 4106 : SFX_APP()->Broadcast(SfxSimpleHint( FID_ANYDATACHANGED )); // Navigator
99 : : //! Navigator direkt benachrichtigen!
100 : 4106 : }
101 : :
102 : 8404 : void ScDocShell::PostPaint( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
103 : : SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, sal_uInt16 nPart,
104 : : sal_uInt16 nExtFlags )
105 : : {
106 : 8404 : ScRange aRange(nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab);
107 [ + - ][ + - ]: 8404 : PostPaint(aRange, nPart, nExtFlags);
[ + - ]
108 : 8404 : }
109 : :
110 : 11863 : void ScDocShell::PostPaint( const ScRangeList& rRanges, sal_uInt16 nPart, sal_uInt16 nExtFlags )
111 : : {
112 [ + - ]: 11863 : ScRangeList aPaintRanges;
113 [ + - ][ + + ]: 23726 : for (size_t i = 0, n = rRanges.size(); i < n; ++i)
114 : : {
115 [ + - ]: 11863 : const ScRange& rRange = *rRanges[i];
116 : 11863 : SCCOL nCol1 = rRange.aStart.Col(), nCol2 = rRange.aEnd.Col();
117 : 11863 : SCROW nRow1 = rRange.aStart.Row(), nRow2 = rRange.aEnd.Row();
118 : 11863 : SCTAB nTab1 = rRange.aStart.Tab(), nTab2 = rRange.aEnd.Tab();
119 : :
120 [ - + ]: 11863 : if (!ValidCol(nCol1)) nCol1 = MAXCOL;
121 [ - + ]: 11863 : if (!ValidRow(nRow1)) nRow1 = MAXROW;
122 [ + + ]: 11863 : if (!ValidCol(nCol2)) nCol2 = MAXCOL;
123 [ + + ]: 11863 : if (!ValidRow(nRow2)) nRow2 = MAXROW;
124 : :
125 [ + + ]: 11863 : if ( pPaintLockData )
126 : : {
127 : : // #i54081# PAINT_EXTRAS still has to be brodcast because it changes the
128 : : // current sheet if it's invalid. All other flags added to pPaintLockData.
129 : 7428 : sal_uInt16 nLockPart = nPart & ~PAINT_EXTRAS;
130 [ + + ]: 7428 : if ( nLockPart )
131 : : {
132 : : //! nExtFlags ???
133 : : pPaintLockData->AddRange( ScRange( nCol1, nRow1, nTab1,
134 [ + - ]: 7392 : nCol2, nRow2, nTab2 ), nLockPart );
135 : : }
136 : :
137 : 7428 : nPart &= PAINT_EXTRAS; // for broadcasting
138 [ + + ]: 7428 : if (!nPart)
139 : 6438 : continue;
140 : : }
141 : :
142 : :
143 [ + + ]: 5425 : if (nExtFlags & SC_PF_LINES) // Platz fuer Linien beruecksichtigen
144 : : {
145 : : //! Abfrage auf versteckte Spalten/Zeilen!
146 [ + + ]: 347 : if (nCol1>0) --nCol1;
147 [ + - ]: 347 : if (nCol2<MAXCOL) ++nCol2;
148 [ + + ]: 347 : if (nRow1>0) --nRow1;
149 [ + - ]: 347 : if (nRow2<MAXROW) ++nRow2;
150 : : }
151 : :
152 : : // um zusammengefasste erweitern
153 [ + + ]: 5425 : if (nExtFlags & SC_PF_TESTMERGE)
154 [ + - ]: 2732 : aDocument.ExtendMerge( nCol1, nRow1, nCol2, nRow2, nTab1 );
155 : :
156 [ + + ][ + + ]: 5425 : if ( nCol1 != 0 || nCol2 != MAXCOL )
157 : : {
158 : : // Extend to whole rows if SC_PF_WHOLEROWS is set, or rotated or non-left
159 : : // aligned cells are contained (see UpdatePaintExt).
160 : : // Special handling for RTL text (#i9731#) is unnecessary now with full
161 : : // support of right-aligned text.
162 : :
163 [ + + ][ + + ]: 6504 : if ( ( nExtFlags & SC_PF_WHOLEROWS ) ||
[ + + ]
164 : : aDocument.HasAttrib( nCol1,nRow1,nTab1,
165 [ + - ]: 3124 : MAXCOL,nRow2,nTab2, HASATTR_ROTATE | HASATTR_RIGHTORCENTER ) )
166 : : {
167 : 261 : nCol1 = 0;
168 : 261 : nCol2 = MAXCOL;
169 : : }
170 : : }
171 [ + - ]: 5425 : aPaintRanges.Append(ScRange(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2));
172 : : }
173 : :
174 [ + - ][ + - ]: 11863 : Broadcast(ScPaintHint(aPaintRanges.Combine(), nPart));
[ + - ][ + - ]
[ + - ]
175 : 11863 : }
176 : :
177 : 247 : void ScDocShell::PostPaintGridAll()
178 : : {
179 : 247 : PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID );
180 : 247 : }
181 : :
182 : 2720 : void ScDocShell::PostPaintCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
183 : : {
184 : 2720 : PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PAINT_GRID, SC_PF_TESTMERGE );
185 : 2720 : }
186 : :
187 : 2720 : void ScDocShell::PostPaintCell( const ScAddress& rPos )
188 : : {
189 : 2720 : PostPaintCell( rPos.Col(), rPos.Row(), rPos.Tab() );
190 : 2720 : }
191 : :
192 : 113 : void ScDocShell::PostPaintExtras()
193 : : {
194 : 113 : PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_EXTRAS );
195 : 113 : }
196 : :
197 : 1400 : void ScDocShell::UpdatePaintExt( sal_uInt16& rExtFlags, const ScRange& rRange )
198 : : {
199 [ + + ][ + + ]: 1400 : if ( ( rExtFlags & SC_PF_LINES ) == 0 && aDocument.HasAttrib( rRange, HASATTR_PAINTEXT ) )
[ + + ]
200 : : {
201 : : // If the range contains lines, shadow or conditional formats,
202 : : // set SC_PF_LINES to include one extra cell in all directions.
203 : :
204 : 371 : rExtFlags |= SC_PF_LINES;
205 : : }
206 : :
207 [ + + + + : 4247 : if ( ( rExtFlags & SC_PF_WHOLEROWS ) == 0 &&
+ + + + ]
[ + + ]
208 : 1810 : ( rRange.aStart.Col() != 0 || rRange.aEnd.Col() != MAXCOL ) &&
209 : 1037 : aDocument.HasAttrib( rRange, HASATTR_ROTATE | HASATTR_RIGHTORCENTER ) )
210 : : {
211 : : // If the range contains (logically) right- or center-aligned cells,
212 : : // or rotated cells, set SC_PF_WHOLEROWS to paint the whole rows.
213 : : // This test isn't needed after the cell changes, because it's also
214 : : // tested in PostPaint. UpdatePaintExt may later be changed to do this
215 : : // only if called before the changes.
216 : :
217 : 291 : rExtFlags |= SC_PF_WHOLEROWS;
218 : : }
219 : 1400 : }
220 : :
221 : 53 : void ScDocShell::UpdatePaintExt( sal_uInt16& rExtFlags, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
222 : : SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab )
223 : : {
224 [ + - ]: 53 : UpdatePaintExt( rExtFlags, ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab ) );
225 : 53 : }
226 : :
227 : : //------------------------------------------------------------------
228 : :
229 : 405 : void ScDocShell::LockPaint_Impl(sal_Bool bDoc)
230 : : {
231 [ + + ]: 405 : if ( !pPaintLockData )
232 [ + - ]: 404 : pPaintLockData = new ScPaintLockData(0); //! Modus...
233 : 405 : pPaintLockData->IncLevel(bDoc);
234 : 405 : }
235 : :
236 : 400 : void ScDocShell::UnlockPaint_Impl(sal_Bool bDoc)
237 : : {
238 [ + - ]: 400 : if ( pPaintLockData )
239 : : {
240 [ + + ]: 400 : if ( pPaintLockData->GetLevel(bDoc) )
241 : 399 : pPaintLockData->DecLevel(bDoc);
242 [ + - ][ + - ]: 400 : if (!pPaintLockData->GetLevel(!bDoc) && !pPaintLockData->GetLevel(bDoc))
[ + - ]
243 : : {
244 : : // Paint jetzt ausfuehren
245 : :
246 : 400 : ScPaintLockData* pPaint = pPaintLockData;
247 : 400 : pPaintLockData = NULL; // nicht weitersammeln
248 : :
249 : 400 : ScRangeListRef xRangeList = pPaint->GetRangeList();
250 [ + + ]: 400 : if (xRangeList)
251 : : {
252 : 226 : sal_uInt16 nParts = pPaint->GetParts();
253 [ + + ][ + - ]: 583 : for ( size_t i = 0, nCount = xRangeList->size(); i < nCount; i++ )
254 : : {
255 : : //! nExtFlags ???
256 [ + - ]: 357 : ScRange aRange = *(*xRangeList)[i];
257 : 714 : PostPaint( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aStart.Tab(),
258 : 714 : aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aEnd.Tab(),
259 [ + - ]: 1071 : nParts );
260 : : }
261 : : }
262 : :
263 [ + + ]: 400 : if ( pPaint->GetModified() )
264 [ + - ]: 125 : SetDocumentModified();
265 : :
266 [ + - ][ + - ]: 400 : delete pPaint;
[ + - ]
267 : : }
268 : : }
269 : : else
270 : : {
271 : : OSL_FAIL("UnlockPaint ohne LockPaint");
272 : : }
273 : 400 : }
274 : :
275 : 381 : void ScDocShell::LockDocument_Impl(sal_uInt16 nNew)
276 : : {
277 [ + + ]: 381 : if (!nDocumentLock)
278 : : {
279 : 379 : ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
280 [ + + ]: 379 : if (pDrawLayer)
281 : 19 : pDrawLayer->setLock(true);
282 : : }
283 : 381 : nDocumentLock = nNew;
284 : 381 : }
285 : :
286 : 375 : void ScDocShell::UnlockDocument_Impl(sal_uInt16 nNew)
287 : : {
288 : 375 : nDocumentLock = nNew;
289 [ + - ]: 375 : if (!nDocumentLock)
290 : : {
291 : 375 : ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
292 [ + + ]: 375 : if (pDrawLayer)
293 : 39 : pDrawLayer->setLock(false);
294 : : }
295 : 375 : }
296 : :
297 : 4 : sal_uInt16 ScDocShell::GetLockCount() const
298 : : {
299 : 4 : return nDocumentLock;
300 : : }
301 : :
302 : 2 : void ScDocShell::SetLockCount(sal_uInt16 nNew)
303 : : {
304 [ + + ]: 2 : if (nNew) // setzen
305 : : {
306 [ - + ]: 1 : if ( !pPaintLockData )
307 [ # # ]: 0 : pPaintLockData = new ScPaintLockData(0); //! Modus...
308 : 1 : pPaintLockData->SetLevel(nNew-1, sal_True);
309 : 1 : LockDocument_Impl(nNew);
310 : : }
311 [ + - ]: 1 : else if (pPaintLockData) // loeschen
312 : : {
313 : 1 : pPaintLockData->SetLevel(0, sal_True); // bei Unlock sofort ausfuehren
314 : 1 : UnlockPaint_Impl(sal_True); // jetzt
315 : 1 : UnlockDocument_Impl(0);
316 : : }
317 : 2 : }
318 : :
319 : 25 : void ScDocShell::LockPaint()
320 : : {
321 : 25 : LockPaint_Impl(false);
322 : 25 : }
323 : :
324 : 25 : void ScDocShell::UnlockPaint()
325 : : {
326 : 25 : UnlockPaint_Impl(false);
327 : 25 : }
328 : :
329 : 380 : void ScDocShell::LockDocument()
330 : : {
331 : 380 : LockPaint_Impl(sal_True);
332 : 380 : LockDocument_Impl(nDocumentLock + 1);
333 : 380 : }
334 : :
335 : 374 : void ScDocShell::UnlockDocument()
336 : : {
337 [ + - ]: 374 : if (nDocumentLock)
338 : : {
339 : 374 : UnlockPaint_Impl(sal_True);
340 : 374 : UnlockDocument_Impl(nDocumentLock - 1);
341 : : }
342 : : else
343 : : {
344 : : OSL_FAIL("UnlockDocument without LockDocument");
345 : : }
346 : 374 : }
347 : :
348 : : //------------------------------------------------------------------
349 : :
350 : 0 : void ScDocShell::SetInplace( bool bInplace )
351 : : {
352 [ # # ]: 0 : if (bIsInplace != bInplace)
353 : : {
354 : 0 : bIsInplace = bInplace;
355 : 0 : CalcOutputFactor();
356 : : }
357 : 0 : }
358 : :
359 : 1377 : void ScDocShell::CalcOutputFactor()
360 : : {
361 [ + + ]: 1377 : if (bIsInplace)
362 : : {
363 : 678 : nPrtToScreenFactor = 1.0; // passt sonst nicht zur inaktiven Darstellung
364 : : return;
365 : : }
366 : :
367 [ + - ][ + - ]: 699 : sal_Bool bTextWysiwyg = SC_MOD()->GetInputOptions().GetTextWysiwyg();
368 [ + + ]: 699 : if (bTextWysiwyg)
369 : : {
370 : 78 : nPrtToScreenFactor = 1.0;
371 : : return;
372 : : }
373 : :
374 : : rtl::OUString aTestString(
375 : 621 : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890123456789");
376 : 621 : long nPrinterWidth = 0;
377 : 621 : long nWindowWidth = 0;
378 [ + - ]: 621 : const ScPatternAttr* pPattern = (const ScPatternAttr*)&aDocument.GetPool()->
379 [ + - ]: 621 : GetDefaultItem(ATTR_PATTERN);
380 : :
381 [ + - ]: 621 : Font aDefFont;
382 [ + - ]: 621 : OutputDevice* pRefDev = GetRefDevice();
383 [ + - ]: 621 : MapMode aOldMode = pRefDev->GetMapMode();
384 [ + - ]: 621 : Font aOldFont = pRefDev->GetFont();
385 : :
386 [ + - ][ + - ]: 621 : pRefDev->SetMapMode(MAP_PIXEL);
[ + - ]
387 [ + - ]: 621 : pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, pRefDev); // font color doesn't matter here
388 [ + - ]: 621 : pRefDev->SetFont(aDefFont);
389 [ + - ][ + - ]: 621 : nPrinterWidth = pRefDev->PixelToLogic( Size( pRefDev->GetTextWidth(aTestString), 0 ), MAP_100TH_MM ).Width();
[ + - ][ + - ]
[ + - ][ + - ]
390 [ + - ]: 621 : pRefDev->SetFont(aOldFont);
391 [ + - ]: 621 : pRefDev->SetMapMode(aOldMode);
392 : :
393 [ + - ][ + - ]: 621 : VirtualDevice aVirtWindow( *Application::GetDefaultDevice() );
394 [ + - ][ + - ]: 621 : aVirtWindow.SetMapMode(MAP_PIXEL);
[ + - ]
395 [ + - ]: 621 : pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, &aVirtWindow); // font color doesn't matter here
396 [ + - ]: 621 : aVirtWindow.SetFont(aDefFont);
397 [ + - ][ + - ]: 621 : nWindowWidth = aVirtWindow.GetTextWidth(aTestString);
[ + - ]
398 : 621 : nWindowWidth = (long) ( nWindowWidth / ScGlobal::nScreenPPTX * HMM_PER_TWIPS );
399 : :
400 [ + - ][ + - ]: 621 : if (nPrinterWidth && nWindowWidth)
401 : 621 : nPrtToScreenFactor = nPrinterWidth / (double) nWindowWidth;
402 : : else
403 : : {
404 : : OSL_FAIL("GetTextSize gibt 0 ??");
405 : 0 : nPrtToScreenFactor = 1.0;
406 [ + - ][ + - ]: 1377 : }
[ + - ][ + - ]
407 : : }
408 : :
409 : 2624 : double ScDocShell::GetOutputFactor() const
410 : : {
411 : 2624 : return nPrtToScreenFactor;
412 : : }
413 : :
414 : : //---------------------------------------------------------------------
415 : :
416 : 412 : void ScDocShell::InitOptions(bool bForLoading) // called from InitNew and Load
417 : : {
418 : : // Einstellungen aus dem SpellCheckCfg kommen in Doc- und ViewOptions
419 : :
420 : : sal_uInt16 nDefLang, nCjkLang, nCtlLang;
421 : : sal_Bool bAutoSpell;
422 [ + - ]: 412 : ScModule::GetSpellSettings( nDefLang, nCjkLang, nCtlLang, bAutoSpell );
423 [ + - ]: 412 : ScModule* pScMod = SC_MOD();
424 : :
425 [ + - ][ + - ]: 412 : ScDocOptions aDocOpt = pScMod->GetDocOptions();
426 [ + - ][ + - ]: 412 : ScFormulaOptions aFormulaOpt = pScMod->GetFormulaOptions();
427 [ + - ][ + - ]: 412 : ScViewOptions aViewOpt = pScMod->GetViewOptions();
428 : 412 : aDocOpt.SetAutoSpell( bAutoSpell );
429 : :
430 : : // zweistellige Jahreszahleneingabe aus Extras->Optionen->Allgemein->Sonstiges
431 [ + - ][ + - ]: 412 : aDocOpt.SetYear2000( sal::static_int_cast<sal_uInt16>( ::utl::MiscCfg().GetYear2000() ) );
[ + - ]
432 : :
433 [ + + ]: 412 : if (bForLoading)
434 : : {
435 : : // #i112123# No style:decimal-places attribute means automatic decimals, not the configured default,
436 : : // so it must not be taken from the global options.
437 : : // Calculation settings are handled separately in ScXMLBodyContext::EndElement.
438 : 93 : aDocOpt.SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION );
439 : : }
440 : :
441 [ + - ]: 412 : aDocument.SetDocOptions( aDocOpt );
442 [ + - ]: 412 : aDocument.SetViewOptions( aViewOpt );
443 [ + - ]: 412 : SetFormulaOptions( aFormulaOpt );
444 : :
445 : : // Druck-Optionen werden jetzt direkt vor dem Drucken gesetzt
446 : :
447 [ + - ][ + - ]: 412 : aDocument.SetLanguage( (LanguageType) nDefLang, (LanguageType) nCjkLang, (LanguageType) nCtlLang );
[ + - ][ + - ]
448 : 412 : }
449 : :
450 : : //---------------------------------------------------------------------
451 : :
452 : 0 : Printer* ScDocShell::GetDocumentPrinter() // fuer OLE
453 : : {
454 : 0 : return aDocument.GetPrinter();
455 : : }
456 : :
457 : 914 : SfxPrinter* ScDocShell::GetPrinter(sal_Bool bCreateIfNotExist)
458 : : {
459 : 914 : return aDocument.GetPrinter(bCreateIfNotExist);
460 : : }
461 : :
462 : 816 : void ScDocShell::UpdateFontList()
463 : : {
464 [ + + ][ + - ]: 816 : delete pImpl->pFontList;
465 : : // pImpl->pFontList = new FontList( GetPrinter(), Application::GetDefaultDevice() );
466 [ + - ][ + - ]: 816 : pImpl->pFontList = new FontList( GetRefDevice(), NULL, false ); // sal_False or sal_True???
[ + - ]
467 [ + - ]: 816 : SvxFontListItem aFontListItem( pImpl->pFontList, SID_ATTR_CHAR_FONTLIST );
468 [ + - ]: 816 : PutItem( aFontListItem );
469 : :
470 [ + - ][ + - ]: 816 : CalcOutputFactor();
471 : 816 : }
472 : :
473 : 1552 : OutputDevice* ScDocShell::GetRefDevice()
474 : : {
475 : 1552 : return aDocument.GetRefDevice();
476 : : }
477 : :
478 : 12 : sal_uInt16 ScDocShell::SetPrinter( SfxPrinter* pNewPrinter, sal_uInt16 nDiffFlags )
479 : : {
480 : 12 : SfxPrinter *pOld = aDocument.GetPrinter( false );
481 [ - + ][ - + ]: 12 : if ( pOld && pOld->IsPrinting() )
[ + + ]
482 : 0 : return SFX_PRINTERROR_BUSY;
483 : :
484 [ + - ]: 12 : if (nDiffFlags & SFX_PRINTER_PRINTER)
485 : : {
486 [ + - ]: 12 : if ( aDocument.GetPrinter() != pNewPrinter )
487 : : {
488 : 12 : aDocument.SetPrinter( pNewPrinter );
489 : 12 : aDocument.SetPrintOptions();
490 : :
491 : : // MT: Use UpdateFontList: Will use Printer fonts only if needed!
492 : : /*
493 : : delete pImpl->pFontList;
494 : : pImpl->pFontList = new FontList( pNewPrinter, Application::GetDefaultDevice() );
495 : : SvxFontListItem aFontListItem( pImpl->pFontList, SID_ATTR_CHAR_FONTLIST );
496 : : PutItem( aFontListItem );
497 : :
498 : : CalcOutputFactor();
499 : : */
500 [ - + ]: 12 : if ( SC_MOD()->GetInputOptions().GetTextWysiwyg() )
501 : 0 : UpdateFontList();
502 : :
503 : 12 : ScModule* pScMod = SC_MOD();
504 : 12 : SfxViewFrame *pFrame = SfxViewFrame::GetFirst( this );
505 [ - + ]: 12 : while (pFrame)
506 : : {
507 : 0 : SfxViewShell* pSh = pFrame->GetViewShell();
508 [ # # ][ # # ]: 0 : if (pSh && pSh->ISA(ScTabViewShell))
[ # # ]
509 : : {
510 : 0 : ScTabViewShell* pViewSh = (ScTabViewShell*)pSh;
511 : 0 : ScInputHandler* pInputHdl = pScMod->GetInputHdl(pViewSh);
512 [ # # ]: 0 : if (pInputHdl)
513 : 0 : pInputHdl->UpdateRefDevice();
514 : : }
515 : 0 : pFrame = SfxViewFrame::GetNext( *pFrame, this );
516 : : }
517 : : }
518 : : }
519 [ # # ]: 0 : else if (nDiffFlags & SFX_PRINTER_JOBSETUP)
520 : : {
521 : 0 : SfxPrinter* pOldPrinter = aDocument.GetPrinter();
522 [ # # ]: 0 : if (pOldPrinter)
523 : : {
524 : 0 : pOldPrinter->SetJobSetup( pNewPrinter->GetJobSetup() );
525 : :
526 : : // #i6706# Call SetPrinter with the old printer again, so the drawing layer
527 : : // RefDevice is set (calling ReformatAllTextObjects and rebuilding charts),
528 : : // because the JobSetup (printer device settings) may affect text layout.
529 : 0 : aDocument.SetPrinter( pOldPrinter );
530 : 0 : CalcOutputFactor(); // also with the new settings
531 : : }
532 : : }
533 : :
534 [ + - ]: 12 : if (nDiffFlags & SFX_PRINTER_OPTIONS)
535 : : {
536 : 12 : aDocument.SetPrintOptions(); //! aus neuem Printer ???
537 : : }
538 : :
539 [ + - ]: 12 : if (nDiffFlags & (SFX_PRINTER_CHG_ORIENTATION | SFX_PRINTER_CHG_SIZE))
540 : : {
541 [ + - ][ + - ]: 12 : String aStyle = aDocument.GetPageStyle( GetCurTab() );
[ + - ]
542 [ + - ]: 12 : ScStyleSheetPool* pStPl = aDocument.GetStyleSheetPool();
543 [ + - ]: 12 : SfxStyleSheet* pStyleSheet = (SfxStyleSheet*)pStPl->Find(aStyle, SFX_STYLE_FAMILY_PAGE);
544 [ + - ]: 12 : if (pStyleSheet)
545 : : {
546 [ + - ]: 12 : SfxItemSet& rSet = pStyleSheet->GetItemSet();
547 : :
548 [ + - ]: 12 : if (nDiffFlags & SFX_PRINTER_CHG_ORIENTATION)
549 : : {
550 [ + - ]: 12 : const SvxPageItem& rOldItem = (const SvxPageItem&)rSet.Get(ATTR_PAGE);
551 : 12 : sal_Bool bWasLand = rOldItem.IsLandscape();
552 [ + - ]: 12 : sal_Bool bNewLand = ( pNewPrinter->GetOrientation() == ORIENTATION_LANDSCAPE );
553 [ - + ]: 12 : if (bNewLand != bWasLand)
554 : : {
555 [ # # ]: 0 : SvxPageItem aNewItem( rOldItem );
556 : 0 : aNewItem.SetLandscape( bNewLand );
557 [ # # ]: 0 : rSet.Put( aNewItem );
558 : :
559 : : // Groesse umdrehen
560 [ # # ]: 0 : Size aOldSize = ((const SvxSizeItem&)rSet.Get(ATTR_PAGE_SIZE)).GetSize();
561 : 0 : Size aNewSize(aOldSize.Height(),aOldSize.Width());
562 [ # # ]: 0 : SvxSizeItem aNewSItem(ATTR_PAGE_SIZE,aNewSize);
563 [ # # ][ # # ]: 0 : rSet.Put( aNewSItem );
[ # # ]
564 : : }
565 : : }
566 [ + - ]: 12 : if (nDiffFlags & SFX_PRINTER_CHG_SIZE)
567 : : {
568 [ + - ][ + - ]: 12 : SvxSizeItem aPaperSizeItem( ATTR_PAGE_SIZE, SvxPaperInfo::GetPaperSize(pNewPrinter) );
569 [ + - ][ + - ]: 12 : rSet.Put( aPaperSizeItem );
570 : : }
571 [ + - ]: 12 : }
572 : : }
573 : :
574 : 12 : PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB,PAINT_ALL);
575 : :
576 : 12 : return 0;
577 : : }
578 : :
579 : : //---------------------------------------------------------------------
580 : :
581 : 0 : ScChangeAction* ScDocShell::GetChangeAction( const ScAddress& rPos )
582 : : {
583 : 0 : ScChangeTrack* pTrack = GetDocument()->GetChangeTrack();
584 [ # # ]: 0 : if (!pTrack)
585 : 0 : return NULL;
586 : :
587 : 0 : SCTAB nTab = rPos.Tab();
588 : :
589 : 0 : const ScChangeAction* pFound = NULL;
590 : 0 : long nModified = 0;
591 : 0 : const ScChangeAction* pAction = pTrack->GetFirst();
592 [ # # ]: 0 : while (pAction)
593 : : {
594 : 0 : ScChangeActionType eType = pAction->GetType();
595 : : //! ScViewUtil::IsActionShown( *pAction, *pSettings, *pDoc )...
596 [ # # ][ # # ]: 0 : if ( pAction->IsVisible() && eType != SC_CAT_DELETE_TABS )
[ # # ]
597 : : {
598 : 0 : const ScBigRange& rBig = pAction->GetBigRange();
599 [ # # ]: 0 : if ( rBig.aStart.Tab() == nTab )
600 : : {
601 : 0 : ScRange aRange = rBig.MakeRange();
602 : :
603 [ # # ]: 0 : if ( eType == SC_CAT_DELETE_ROWS )
604 : 0 : aRange.aEnd.SetRow( aRange.aStart.Row() );
605 [ # # ]: 0 : else if ( eType == SC_CAT_DELETE_COLS )
606 : 0 : aRange.aEnd.SetCol( aRange.aStart.Col() );
607 : :
608 [ # # ]: 0 : if ( aRange.In( rPos ) )
609 : : {
610 : 0 : pFound = pAction; // der letzte gewinnt
611 : 0 : ++nModified;
612 : : }
613 : : }
614 [ # # ]: 0 : if ( pAction->GetType() == SC_CAT_MOVE )
615 : : {
616 : : ScRange aRange =
617 : : ((const ScChangeActionMove*)pAction)->
618 : 0 : GetFromRange().MakeRange();
619 [ # # ]: 0 : if ( aRange.In( rPos ) )
620 : : {
621 : 0 : pFound = pAction;
622 : 0 : ++nModified;
623 : : }
624 : : }
625 : : }
626 : 0 : pAction = pAction->GetNext();
627 : : }
628 : :
629 : 0 : return (ScChangeAction*)pFound;
630 : : }
631 : :
632 : 0 : void ScDocShell::SetChangeComment( ScChangeAction* pAction, const String& rComment )
633 : : {
634 [ # # ]: 0 : if (pAction)
635 : : {
636 [ # # ]: 0 : pAction->SetComment( rComment );
637 : : //! Undo ???
638 : 0 : SetDocumentModified();
639 : :
640 : : // Dialog-Notify
641 : 0 : ScChangeTrack* pTrack = GetDocument()->GetChangeTrack();
642 [ # # ]: 0 : if (pTrack)
643 : : {
644 : 0 : sal_uLong nNumber = pAction->GetActionNumber();
645 : 0 : pTrack->NotifyModified( SC_CTM_CHANGE, nNumber, nNumber );
646 : : }
647 : : }
648 : 0 : }
649 : :
650 : 0 : void ScDocShell::ExecuteChangeCommentDialog( ScChangeAction* pAction, Window* pParent,sal_Bool bPrevNext)
651 : : {
652 [ # # ]: 0 : if (!pAction) return; // ohne Aktion ist nichts..
653 : :
654 [ # # ][ # # ]: 0 : String aComment = pAction->GetComment();
655 [ # # ][ # # ]: 0 : String aAuthor = pAction->GetUser();
656 : :
657 [ # # ]: 0 : DateTime aDT = pAction->GetDateTime();
658 [ # # ][ # # ]: 0 : String aDate = ScGlobal::pLocaleData->getDate( aDT );
659 [ # # ]: 0 : aDate += ' ';
660 [ # # ][ # # ]: 0 : aDate += ScGlobal::pLocaleData->getTime( aDT, false, false );
661 : :
662 : 0 : SfxItemSet aSet( GetPool(),
663 : : SID_ATTR_POSTIT_AUTHOR, SID_ATTR_POSTIT_AUTHOR,
664 : : SID_ATTR_POSTIT_DATE, SID_ATTR_POSTIT_DATE,
665 : : SID_ATTR_POSTIT_TEXT, SID_ATTR_POSTIT_TEXT,
666 [ # # ]: 0 : 0 );
667 : :
668 [ # # ][ # # ]: 0 : aSet.Put( SvxPostItTextItem ( aComment, SID_ATTR_POSTIT_TEXT ) );
[ # # ]
669 [ # # ][ # # ]: 0 : aSet.Put( SvxPostItAuthorItem( aAuthor, SID_ATTR_POSTIT_AUTHOR ) );
[ # # ]
670 [ # # ][ # # ]: 0 : aSet.Put( SvxPostItDateItem ( aDate, SID_ATTR_POSTIT_DATE ) );
[ # # ]
671 : :
672 [ # # ][ # # ]: 0 : ScRedComDialog* pDlg = new ScRedComDialog( pParent, aSet,this,pAction,bPrevNext);
673 : :
674 [ # # ]: 0 : pDlg->Execute();
675 : :
676 [ # # ][ # # ]: 0 : delete pDlg;
[ # # ][ # # ]
[ # # ][ # # ]
677 : : }
678 : :
679 : : //---------------------------------------------------------------------
680 : :
681 : 0 : void ScDocShell::CompareDocument( ScDocument& rOtherDoc )
682 : : {
683 : 0 : ScChangeTrack* pTrack = aDocument.GetChangeTrack();
684 [ # # ][ # # ]: 0 : if ( pTrack && pTrack->GetFirst() )
685 : : {
686 : : //! Changes vorhanden -> Nachfrage ob geloescht werden soll
687 : : }
688 : :
689 [ # # ]: 0 : aDocument.EndChangeTracking();
690 [ # # ]: 0 : aDocument.StartChangeTracking();
691 : :
692 [ # # ]: 0 : String aOldUser;
693 : 0 : pTrack = aDocument.GetChangeTrack();
694 [ # # ]: 0 : if ( pTrack )
695 : : {
696 [ # # ][ # # ]: 0 : aOldUser = pTrack->GetUser();
697 : :
698 : : // check if comparing to same document
699 : :
700 [ # # ]: 0 : String aThisFile;
701 : 0 : const SfxMedium* pThisMed = GetMedium();
702 [ # # ]: 0 : if (pThisMed)
703 [ # # ][ # # ]: 0 : aThisFile = pThisMed->GetName();
704 [ # # ]: 0 : String aOtherFile;
705 : 0 : SfxObjectShell* pOtherSh = rOtherDoc.GetDocumentShell();
706 [ # # ]: 0 : if (pOtherSh)
707 : : {
708 : 0 : const SfxMedium* pOtherMed = pOtherSh->GetMedium();
709 [ # # ]: 0 : if (pOtherMed)
710 [ # # ][ # # ]: 0 : aOtherFile = pOtherMed->GetName();
711 : : }
712 [ # # ][ # # ]: 0 : sal_Bool bSameDoc = ( aThisFile == aOtherFile && aThisFile.Len() );
[ # # ]
713 [ # # ]: 0 : if ( !bSameDoc )
714 : : {
715 : : // create change actions from comparing with the name of the user
716 : : // who last saved the document
717 : : // (only if comparing different documents)
718 : :
719 : : using namespace ::com::sun::star;
720 : : uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
721 [ # # ][ # # ]: 0 : GetModel(), uno::UNO_QUERY_THROW);
722 : : uno::Reference<document::XDocumentProperties> xDocProps(
723 [ # # ][ # # ]: 0 : xDPS->getDocumentProperties());
724 : : OSL_ENSURE(xDocProps.is(), "no DocumentProperties");
725 [ # # ][ # # ]: 0 : String aDocUser = xDocProps->getModifiedBy();
[ # # ]
726 : :
727 [ # # ]: 0 : if ( aDocUser.Len() )
728 [ # # ][ # # ]: 0 : pTrack->SetUser( aDocUser );
[ # # ]
729 [ # # ][ # # ]: 0 : }
730 : : }
731 : :
732 [ # # ]: 0 : aDocument.CompareDocument( rOtherDoc );
733 : :
734 : 0 : pTrack = aDocument.GetChangeTrack();
735 [ # # ]: 0 : if ( pTrack )
736 [ # # ][ # # ]: 0 : pTrack->SetUser( aOldUser );
737 : :
738 [ # # ]: 0 : PostPaintGridAll();
739 [ # # ][ # # ]: 0 : SetDocumentModified();
740 : 0 : }
741 : :
742 : : //---------------------------------------------------------------------
743 : : //
744 : : // Merge (Aenderungen zusammenfuehren)
745 : : //
746 : : //---------------------------------------------------------------------
747 : :
748 : 0 : inline sal_Bool lcl_Equal( const ScChangeAction* pA, const ScChangeAction* pB, sal_Bool bIgnore100Sec )
749 : : {
750 : : return pA && pB &&
751 : 0 : pA->GetActionNumber() == pB->GetActionNumber() &&
752 : 0 : pA->GetType() == pB->GetType() &&
753 : 0 : pA->GetUser() == pB->GetUser() &&
754 : : (bIgnore100Sec ?
755 : 0 : pA->GetDateTimeUTC().IsEqualIgnore100Sec( pB->GetDateTimeUTC() ) :
756 [ # # ][ # # : 0 : pA->GetDateTimeUTC() == pB->GetDateTimeUTC());
# # # # #
# ]
[ # # # # ]
[ # # ]
757 : : // State nicht vergleichen, falls eine alte Aenderung akzeptiert wurde
758 : : }
759 : :
760 : 0 : bool lcl_FindAction( ScDocument* pDoc, const ScChangeAction* pAction, ScDocument* pSearchDoc, const ScChangeAction* pFirstSearchAction, const ScChangeAction* pLastSearchAction, sal_Bool bIgnore100Sec )
761 : : {
762 [ # # ][ # # ]: 0 : if ( !pDoc || !pAction || !pSearchDoc || !pFirstSearchAction || !pLastSearchAction )
[ # # ][ # # ]
[ # # ]
763 : : {
764 : 0 : return false;
765 : : }
766 : :
767 : 0 : sal_uLong nLastSearchAction = pLastSearchAction->GetActionNumber();
768 : 0 : const ScChangeAction* pA = pFirstSearchAction;
769 [ # # ][ # # ]: 0 : while ( pA && pA->GetActionNumber() <= nLastSearchAction )
[ # # ]
770 : : {
771 [ # # # # ]: 0 : if ( pAction->GetType() == pA->GetType() &&
[ # # # #
# # ][ # # ]
772 : 0 : pAction->GetUser() == pA->GetUser() &&
773 : : (bIgnore100Sec ?
774 : 0 : pAction->GetDateTimeUTC().IsEqualIgnore100Sec( pA->GetDateTimeUTC() ) :
775 [ # # ]: 0 : pAction->GetDateTimeUTC() == pA->GetDateTimeUTC() ) &&
776 : 0 : pAction->GetBigRange() == pA->GetBigRange() )
777 : : {
778 : 0 : rtl::OUString aActionDesc;
779 [ # # ]: 0 : pAction->GetDescription(aActionDesc, pDoc, true);
780 : 0 : rtl::OUString aADesc;
781 [ # # ]: 0 : pA->GetDescription(aADesc, pSearchDoc, true);
782 [ # # ]: 0 : if (aActionDesc.equals(aADesc))
783 : : {
784 : : OSL_FAIL( "lcl_FindAction(): found equal action!" );
785 : 0 : return true;
786 [ # # ][ # # ]: 0 : }
787 : : }
788 : 0 : pA = pA->GetNext();
789 : : }
790 : :
791 : 0 : return false;
792 : : }
793 : :
794 : 0 : void ScDocShell::MergeDocument( ScDocument& rOtherDoc, bool bShared, bool bCheckDuplicates, sal_uLong nOffset, ScChangeActionMergeMap* pMergeMap, bool bInverseMap )
795 : : {
796 [ # # ]: 0 : ScTabViewShell* pViewSh = GetBestViewShell( false ); //! Funktionen an die DocShell
797 [ # # ]: 0 : if (!pViewSh)
798 : : return;
799 : :
800 : 0 : ScChangeTrack* pSourceTrack = rOtherDoc.GetChangeTrack();
801 [ # # ]: 0 : if (!pSourceTrack)
802 : : return; //! nichts zu tun - Fehlermeldung?
803 : :
804 : 0 : ScChangeTrack* pThisTrack = aDocument.GetChangeTrack();
805 [ # # ]: 0 : if ( !pThisTrack )
806 : : { // anschalten
807 [ # # ]: 0 : aDocument.StartChangeTracking();
808 : 0 : pThisTrack = aDocument.GetChangeTrack();
809 : : OSL_ENSURE(pThisTrack,"ChangeTracking nicht angeschaltet?");
810 [ # # ]: 0 : if ( !bShared )
811 : : {
812 : : // visuelles RedLining einschalten
813 [ # # ]: 0 : ScChangeViewSettings aChangeViewSet;
814 : 0 : aChangeViewSet.SetShowChanges(sal_True);
815 [ # # ][ # # ]: 0 : aDocument.SetChangeViewSettings(aChangeViewSet);
816 : : }
817 : : }
818 : :
819 : : // include 100th seconds in compare?
820 : 0 : sal_Bool bIgnore100Sec = !pSourceTrack->IsTime100thSeconds() ||
821 [ # # ][ # # ]: 0 : !pThisTrack->IsTime100thSeconds();
822 : :
823 : : // gemeinsame Ausgangsposition suchen
824 : 0 : sal_uLong nFirstNewNumber = 0;
825 : 0 : const ScChangeAction* pSourceAction = pSourceTrack->GetFirst();
826 : 0 : const ScChangeAction* pThisAction = pThisTrack->GetFirst();
827 : : // skip identical actions
828 [ # # ][ # # ]: 0 : while ( lcl_Equal( pSourceAction, pThisAction, bIgnore100Sec ) )
829 : : {
830 : 0 : nFirstNewNumber = pSourceAction->GetActionNumber() + 1;
831 : 0 : pSourceAction = pSourceAction->GetNext();
832 : 0 : pThisAction = pThisAction->GetNext();
833 : : }
834 : : // pSourceAction und pThisAction zeigen jetzt auf die ersten "eigenen" Aktionen
835 : : // Die gemeinsamen Aktionen davor interessieren ueberhaupt nicht
836 : :
837 : : //! Abfrage, ob die Dokumente vor dem Change-Tracking gleich waren !!!
838 : :
839 : :
840 : 0 : const ScChangeAction* pFirstMergeAction = pSourceAction;
841 : 0 : const ScChangeAction* pFirstSearchAction = pThisAction;
842 : :
843 : : // #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong
844 : 0 : const ScChangeAction* pLastSearchAction = pThisTrack->GetLast();
845 : :
846 : : // MergeChangeData aus den folgenden Aktionen erzeugen
847 : 0 : sal_uLong nNewActionCount = 0;
848 : 0 : const ScChangeAction* pCount = pSourceAction;
849 [ # # ]: 0 : while ( pCount )
850 : : {
851 [ # # ][ # # ]: 0 : if ( bShared || !ScChangeTrack::MergeIgnore( *pCount, nFirstNewNumber ) )
[ # # ][ # # ]
852 : 0 : ++nNewActionCount;
853 : 0 : pCount = pCount->GetNext();
854 : : }
855 [ # # ]: 0 : if (!nNewActionCount)
856 : : return; //! nichts zu tun - Fehlermeldung?
857 : : // ab hier kein return mehr
858 : :
859 : : ScProgress aProgress( this, rtl::OUString("..."),
860 [ # # ][ # # ]: 0 : nNewActionCount );
[ # # ]
861 : :
862 : 0 : sal_uLong nLastMergeAction = pSourceTrack->GetLast()->GetActionNumber();
863 : : // UpdateReference-Undo, gueltige Referenzen fuer den letzten gemeinsamen Zustand
864 [ # # ]: 0 : pSourceTrack->MergePrepare( (ScChangeAction*) pFirstMergeAction, bShared );
865 : :
866 : : // MergeChangeData an alle noch folgenden Aktionen in diesem Dokument anpassen
867 : : // -> Referenzen gueltig fuer dieses Dokument
868 [ # # ]: 0 : while ( pThisAction )
869 : : {
870 : : // #i87049# [Collaboration] Conflict between delete row and insert content is not merged correctly
871 [ # # ][ # # ]: 0 : if ( !bShared || !ScChangeTrack::MergeIgnore( *pThisAction, nFirstNewNumber ) )
[ # # ][ # # ]
872 : : {
873 : 0 : ScChangeActionType eType = pThisAction->GetType();
874 [ # # # # ]: 0 : switch ( eType )
875 : : {
876 : : case SC_CAT_INSERT_COLS :
877 : : case SC_CAT_INSERT_ROWS :
878 : : case SC_CAT_INSERT_TABS :
879 [ # # ]: 0 : pSourceTrack->AppendInsert( pThisAction->GetBigRange().MakeRange() );
880 : 0 : break;
881 : : case SC_CAT_DELETE_COLS :
882 : : case SC_CAT_DELETE_ROWS :
883 : : case SC_CAT_DELETE_TABS :
884 : : {
885 : 0 : const ScChangeActionDel* pDel = (const ScChangeActionDel*) pThisAction;
886 [ # # ][ # # ]: 0 : if ( pDel->IsTopDelete() && !pDel->IsTabDeleteCol() )
[ # # ][ # # ]
[ # # ]
887 : : { // deleted Table enthaelt deleted Cols, die nicht
888 : : sal_uLong nStart, nEnd;
889 : : pSourceTrack->AppendDeleteRange(
890 [ # # ][ # # ]: 0 : pDel->GetOverAllRange().MakeRange(), NULL, nStart, nEnd );
891 : : }
892 : : }
893 : 0 : break;
894 : : case SC_CAT_MOVE :
895 : : {
896 : 0 : const ScChangeActionMove* pMove = (const ScChangeActionMove*) pThisAction;
897 : 0 : pSourceTrack->AppendMove( pMove->GetFromRange().MakeRange(),
898 [ # # ]: 0 : pMove->GetBigRange().MakeRange(), NULL );
899 : : }
900 : 0 : break;
901 : : default:
902 : : {
903 : : // added to avoid warnings
904 : : }
905 : : }
906 : : }
907 : 0 : pThisAction = pThisAction->GetNext();
908 : : }
909 : :
910 [ # # ]: 0 : LockPaint(); // #i73877# no repainting after each action
911 : :
912 : : // MergeChangeData in das aktuelle Dokument uebernehmen
913 : 0 : sal_Bool bHasRejected = false;
914 [ # # ][ # # ]: 0 : String aOldUser = pThisTrack->GetUser();
915 : 0 : pThisTrack->SetUseFixDateTime( sal_True );
916 [ # # ]: 0 : ScMarkData& rMarkData = pViewSh->GetViewData()->GetMarkData();
917 [ # # ]: 0 : ScMarkData aOldMarkData( rMarkData );
918 : 0 : pSourceAction = pFirstMergeAction;
919 [ # # ][ # # ]: 0 : while ( pSourceAction && pSourceAction->GetActionNumber() <= nLastMergeAction )
[ # # ]
920 : : {
921 : 0 : bool bMergeAction = false;
922 [ # # ]: 0 : if ( bShared )
923 : : {
924 [ # # ][ # # ]: 0 : if ( !bCheckDuplicates || !lcl_FindAction( &rOtherDoc, pSourceAction, &aDocument, pFirstSearchAction, pLastSearchAction, bIgnore100Sec ) )
[ # # ][ # # ]
925 : : {
926 : 0 : bMergeAction = true;
927 : : }
928 : : }
929 : : else
930 : : {
931 [ # # ][ # # ]: 0 : if ( !ScChangeTrack::MergeIgnore( *pSourceAction, nFirstNewNumber ) )
932 : : {
933 : 0 : bMergeAction = true;
934 : : }
935 : : }
936 : :
937 [ # # ]: 0 : if ( bMergeAction )
938 : : {
939 : 0 : ScChangeActionType eSourceType = pSourceAction->GetType();
940 [ # # ][ # # ]: 0 : if ( !bShared && pSourceAction->IsDeletedIn() )
[ # # ][ # # ]
941 : : {
942 : : //! muss hier noch festgestellt werden, ob wirklich in
943 : : //! _diesem_ Dokument geloescht?
944 : :
945 : : // liegt in einem Bereich, der in diesem Dokument geloescht wurde
946 : : // -> wird weggelassen
947 : : //! ??? Loesch-Aktion rueckgaengig machen ???
948 : : //! ??? Aktion irgendwo anders speichern ???
949 : : #if OSL_DEBUG_LEVEL > 0
950 : : rtl::OUString aValue;
951 : : if ( eSourceType == SC_CAT_CONTENT )
952 : : ((const ScChangeActionContent*)pSourceAction)->GetNewString( aValue );
953 : : rtl::OStringBuffer aError(rtl::OUStringToOString(aValue,
954 : : osl_getThreadTextEncoding()));
955 : : aError.append(RTL_CONSTASCII_STRINGPARAM(" weggelassen"));
956 : : OSL_FAIL( aError.getStr() );
957 : : #endif
958 : : }
959 : : else
960 : : {
961 : : //! Datum/Autor/Kommentar der Source-Aktion uebernehmen!
962 : :
963 [ # # ][ # # ]: 0 : pThisTrack->SetUser( pSourceAction->GetUser() );
964 [ # # ]: 0 : pThisTrack->SetFixDateTimeUTC( pSourceAction->GetDateTimeUTC() );
965 : 0 : sal_uLong nOldActionMax = pThisTrack->GetActionMax();
966 : :
967 : 0 : bool bExecute = true;
968 : 0 : sal_uLong nReject = pSourceAction->GetRejectAction();
969 [ # # ]: 0 : if ( nReject )
970 : : {
971 [ # # ]: 0 : if ( bShared )
972 : : {
973 [ # # ]: 0 : if ( nReject >= nFirstNewNumber )
974 : : {
975 : 0 : nReject += nOffset;
976 : : }
977 [ # # ]: 0 : ScChangeAction* pOldAction = pThisTrack->GetAction( nReject );
978 [ # # ][ # # ]: 0 : if ( pOldAction && pOldAction->IsVirgin() )
[ # # ][ # # ]
979 : : {
980 [ # # ]: 0 : pThisTrack->Reject( pOldAction );
981 : 0 : bHasRejected = sal_True;
982 : 0 : bExecute = false;
983 : : }
984 : : }
985 : : else
986 : : {
987 : : // alte Aktion (aus den gemeinsamen) ablehnen
988 [ # # ]: 0 : ScChangeAction* pOldAction = pThisTrack->GetAction( nReject );
989 [ # # ][ # # ]: 0 : if (pOldAction && pOldAction->GetState() == SC_CAS_VIRGIN)
[ # # ]
990 : : {
991 : : //! was passiert bei Aktionen, die in diesem Dokument accepted worden sind???
992 : : //! Fehlermeldung oder was???
993 : : //! oder Reject-Aenderung normal ausfuehren
994 : :
995 [ # # ]: 0 : pThisTrack->Reject(pOldAction);
996 : 0 : bHasRejected = sal_True; // fuer Paint
997 : : }
998 : 0 : bExecute = false;
999 : : }
1000 : : }
1001 : :
1002 [ # # ]: 0 : if ( bExecute )
1003 : : {
1004 : : // normal ausfuehren
1005 : 0 : ScRange aSourceRange = pSourceAction->GetBigRange().MakeRange();
1006 [ # # ]: 0 : rMarkData.SelectOneTable( aSourceRange.aStart.Tab() );
1007 [ # # # # : 0 : switch ( eSourceType )
# # # #
# ]
1008 : : {
1009 : : case SC_CAT_CONTENT:
1010 : : {
1011 : : //! Test, ob es ganz unten im Dokument war, dann automatisches
1012 : : //! Zeilen-Einfuegen ???
1013 : :
1014 : : OSL_ENSURE( aSourceRange.aStart == aSourceRange.aEnd, "huch?" );
1015 : 0 : ScAddress aPos = aSourceRange.aStart;
1016 : 0 : rtl::OUString aValue;
1017 [ # # ]: 0 : ((const ScChangeActionContent*)pSourceAction)->GetNewString( aValue );
1018 : 0 : sal_uInt8 eMatrix = MM_NONE;
1019 : 0 : const ScBaseCell* pCell = ((const ScChangeActionContent*)pSourceAction)->GetNewCell();
1020 [ # # ][ # # ]: 0 : if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
[ # # ]
1021 [ # # ]: 0 : eMatrix = ((const ScFormulaCell*)pCell)->GetMatrixFlag();
1022 [ # # # # : 0 : switch ( eMatrix )
# ]
1023 : : {
1024 : : case MM_NONE :
1025 [ # # ][ # # ]: 0 : pViewSh->EnterData( aPos.Col(), aPos.Row(), aPos.Tab(), aValue );
[ # # ]
1026 : 0 : break;
1027 : : case MM_FORMULA :
1028 : : {
1029 : : SCCOL nCols;
1030 : : SCROW nRows;
1031 [ # # ][ # # ]: 0 : ((const ScFormulaCell*)pCell)->GetMatColsRows( nCols, nRows );
1032 : 0 : aSourceRange.aEnd.SetCol( aPos.Col() + nCols - 1 );
1033 : 0 : aSourceRange.aEnd.SetRow( aPos.Row() + nRows - 1 );
1034 : 0 : aValue = aValue.copy(1, aValue.getLength()-2); // remove the 1st and last characters.
1035 : 0 : GetDocFunc().EnterMatrix( aSourceRange,
1036 : : NULL, NULL, aValue, false, false,
1037 [ # # ][ # # ]: 0 : EMPTY_STRING, formula::FormulaGrammar::GRAM_DEFAULT );
[ # # ][ # # ]
1038 : : }
1039 : 0 : break;
1040 : : case MM_REFERENCE : // do nothing
1041 : 0 : break;
1042 : : case MM_FAKE :
1043 : : OSL_FAIL( "MergeDocument: MatrixFlag MM_FAKE" );
1044 [ # # ][ # # ]: 0 : pViewSh->EnterData( aPos.Col(), aPos.Row(), aPos.Tab(), aValue );
[ # # ]
1045 : 0 : break;
1046 : : default:
1047 : : OSL_FAIL( "MergeDocument: unknown MatrixFlag" );
1048 : 0 : }
1049 : : }
1050 : 0 : break;
1051 : : case SC_CAT_INSERT_TABS :
1052 : : {
1053 : 0 : rtl::OUString aName;
1054 [ # # ]: 0 : aDocument.CreateValidTabName( aName );
1055 [ # # ][ # # ]: 0 : GetDocFunc().InsertTable( aSourceRange.aStart.Tab(), aName, sal_True, false );
[ # # ]
1056 : : }
1057 : 0 : break;
1058 : : case SC_CAT_INSERT_ROWS:
1059 [ # # ]: 0 : GetDocFunc().InsertCells( aSourceRange, NULL, INS_INSROWS, sal_True, false );
1060 : 0 : break;
1061 : : case SC_CAT_INSERT_COLS:
1062 [ # # ]: 0 : GetDocFunc().InsertCells( aSourceRange, NULL, INS_INSCOLS, sal_True, false );
1063 : 0 : break;
1064 : : case SC_CAT_DELETE_TABS :
1065 [ # # ]: 0 : GetDocFunc().DeleteTable( aSourceRange.aStart.Tab(), sal_True, false );
1066 : 0 : break;
1067 : : case SC_CAT_DELETE_ROWS:
1068 : : {
1069 : 0 : const ScChangeActionDel* pDel = (const ScChangeActionDel*) pSourceAction;
1070 [ # # ][ # # ]: 0 : if ( pDel->IsTopDelete() )
1071 : : {
1072 [ # # ]: 0 : aSourceRange = pDel->GetOverAllRange().MakeRange();
1073 [ # # ]: 0 : GetDocFunc().DeleteCells( aSourceRange, NULL, DEL_DELROWS, sal_True, false );
1074 : :
1075 : : // #i101099# [Collaboration] Changes are not correctly shown
1076 [ # # ]: 0 : if ( bShared )
1077 : : {
1078 : 0 : ScChangeAction* pAct = pThisTrack->GetLast();
1079 [ # # ][ # # ]: 0 : if ( pAct && pAct->GetType() == eSourceType && pAct->IsDeletedIn() && !pSourceAction->IsDeletedIn() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1080 : : {
1081 [ # # ]: 0 : pAct->RemoveAllDeletedIn();
1082 : : }
1083 : : }
1084 : : }
1085 : : }
1086 : 0 : break;
1087 : : case SC_CAT_DELETE_COLS:
1088 : : {
1089 : 0 : const ScChangeActionDel* pDel = (const ScChangeActionDel*) pSourceAction;
1090 [ # # ][ # # ]: 0 : if ( pDel->IsTopDelete() && !pDel->IsTabDeleteCol() )
[ # # ][ # # ]
[ # # ]
1091 : : { // deleted Table enthaelt deleted Cols, die nicht
1092 [ # # ]: 0 : aSourceRange = pDel->GetOverAllRange().MakeRange();
1093 [ # # ]: 0 : GetDocFunc().DeleteCells( aSourceRange, NULL, DEL_DELCOLS, sal_True, false );
1094 : : }
1095 : : }
1096 : 0 : break;
1097 : : case SC_CAT_MOVE :
1098 : : {
1099 : 0 : const ScChangeActionMove* pMove = (const ScChangeActionMove*) pSourceAction;
1100 : 0 : ScRange aFromRange( pMove->GetFromRange().MakeRange() );
1101 : 0 : GetDocFunc().MoveBlock( aFromRange,
1102 [ # # ]: 0 : aSourceRange.aStart, sal_True, sal_True, false, false );
1103 : : }
1104 : 0 : break;
1105 : : default:
1106 : : {
1107 : : // added to avoid warnings
1108 : : }
1109 : : }
1110 : : }
1111 [ # # ][ # # ]: 0 : const String& rComment = pSourceAction->GetComment();
1112 [ # # ]: 0 : if ( rComment.Len() )
1113 : : {
1114 : 0 : ScChangeAction* pAct = pThisTrack->GetLast();
1115 [ # # ][ # # ]: 0 : if ( pAct && pAct->GetActionNumber() > nOldActionMax )
[ # # ]
1116 [ # # ][ # # ]: 0 : pAct->SetComment( rComment );
1117 : : else
1118 : : OSL_FAIL( "MergeDocument: wohin mit dem Kommentar?!?" );
1119 : : }
1120 : :
1121 : : // Referenzen anpassen
1122 [ # # ]: 0 : pSourceTrack->MergeOwn( (ScChangeAction*) pSourceAction, nFirstNewNumber, bShared );
1123 : :
1124 : : // merge action state
1125 [ # # ][ # # ]: 0 : if ( bShared && !pSourceAction->IsRejected() )
[ # # ][ # # ]
1126 : : {
1127 : 0 : ScChangeAction* pAct = pThisTrack->GetLast();
1128 [ # # ][ # # ]: 0 : if ( pAct && pAct->GetActionNumber() > nOldActionMax )
[ # # ]
1129 : : {
1130 [ # # ]: 0 : pThisTrack->MergeActionState( pAct, pSourceAction );
1131 : : }
1132 : : }
1133 : :
1134 : : // fill merge map
1135 [ # # ][ # # ]: 0 : if ( bShared && pMergeMap )
1136 : : {
1137 : 0 : ScChangeAction* pAct = pThisTrack->GetLast();
1138 [ # # ][ # # ]: 0 : if ( pAct && pAct->GetActionNumber() > nOldActionMax )
[ # # ]
1139 : : {
1140 : 0 : sal_uLong nActionMax = pAct->GetActionNumber();
1141 : 0 : sal_uLong nActionCount = nActionMax - nOldActionMax;
1142 : 0 : sal_uLong nAction = nActionMax - nActionCount + 1;
1143 : 0 : sal_uLong nSourceAction = pSourceAction->GetActionNumber() - nActionCount + 1;
1144 [ # # ]: 0 : while ( nAction <= nActionMax )
1145 : : {
1146 [ # # ]: 0 : if ( bInverseMap )
1147 : : {
1148 [ # # ]: 0 : (*pMergeMap)[ nAction++ ] = nSourceAction++;
1149 : : }
1150 : : else
1151 : : {
1152 [ # # ]: 0 : (*pMergeMap)[ nSourceAction++ ] = nAction++;
1153 : : }
1154 : : }
1155 : : }
1156 [ # # ]: 0 : }
1157 : : }
1158 [ # # ]: 0 : aProgress.SetStateCountDown( --nNewActionCount );
1159 : : }
1160 : 0 : pSourceAction = pSourceAction->GetNext();
1161 : : }
1162 : :
1163 [ # # ]: 0 : rMarkData = aOldMarkData;
1164 [ # # ][ # # ]: 0 : pThisTrack->SetUser(aOldUser);
1165 : 0 : pThisTrack->SetUseFixDateTime( false );
1166 : :
1167 [ # # ]: 0 : pSourceTrack->Clear(); //! der ist jetzt verhunzt
1168 : :
1169 [ # # ]: 0 : if (bHasRejected)
1170 [ # # ]: 0 : PostPaintGridAll(); // Reject() paintet nicht selber
1171 : :
1172 [ # # ][ # # ]: 0 : UnlockPaint();
[ # # ][ # # ]
1173 : : }
1174 : :
1175 : 0 : bool ScDocShell::MergeSharedDocument( ScDocShell* pSharedDocShell )
1176 : : {
1177 [ # # ]: 0 : if ( !pSharedDocShell )
1178 : : {
1179 : 0 : return false;
1180 : : }
1181 : :
1182 : 0 : ScChangeTrack* pThisTrack = aDocument.GetChangeTrack();
1183 [ # # ]: 0 : if ( !pThisTrack )
1184 : : {
1185 : 0 : return false;
1186 : : }
1187 : :
1188 : 0 : ScDocument& rSharedDoc = *( pSharedDocShell->GetDocument() );
1189 : 0 : ScChangeTrack* pSharedTrack = rSharedDoc.GetChangeTrack();
1190 [ # # ]: 0 : if ( !pSharedTrack )
1191 : : {
1192 : 0 : return false;
1193 : : }
1194 : :
1195 : : // reset show changes
1196 [ # # ]: 0 : ScChangeViewSettings aChangeViewSet;
1197 : 0 : aChangeViewSet.SetShowChanges( false );
1198 [ # # ]: 0 : aDocument.SetChangeViewSettings( aChangeViewSet );
1199 : :
1200 : : // find first merge action in this document
1201 [ # # ][ # # ]: 0 : sal_Bool bIgnore100Sec = !pThisTrack->IsTime100thSeconds() || !pSharedTrack->IsTime100thSeconds();
1202 : 0 : ScChangeAction* pThisAction = pThisTrack->GetFirst();
1203 : 0 : ScChangeAction* pSharedAction = pSharedTrack->GetFirst();
1204 [ # # ][ # # ]: 0 : while ( lcl_Equal( pThisAction, pSharedAction, bIgnore100Sec ) )
1205 : : {
1206 : 0 : pThisAction = pThisAction->GetNext();
1207 : 0 : pSharedAction = pSharedAction->GetNext();
1208 : : }
1209 : :
1210 [ # # ]: 0 : if ( pSharedAction )
1211 : : {
1212 [ # # ]: 0 : if ( pThisAction )
1213 : : {
1214 : : // merge own changes into shared document
1215 : 0 : sal_uLong nActStartShared = pSharedAction->GetActionNumber();
1216 : 0 : sal_uLong nActEndShared = pSharedTrack->GetActionMax();
1217 [ # # ][ # # ]: 0 : ScDocument* pTmpDoc = new ScDocument;
1218 [ # # ][ # # ]: 0 : for ( sal_Int32 nIndex = 0; nIndex < aDocument.GetTableCount(); ++nIndex )
1219 : : {
1220 : 0 : rtl::OUString sTabName;
1221 [ # # ]: 0 : pTmpDoc->CreateValidTabName( sTabName );
1222 [ # # ]: 0 : pTmpDoc->InsertTab( SC_TAB_APPEND, sTabName );
1223 : 0 : }
1224 [ # # ]: 0 : aDocument.GetChangeTrack()->Clone( pTmpDoc );
1225 [ # # ]: 0 : ScChangeActionMergeMap aOwnInverseMergeMap;
1226 [ # # ]: 0 : pSharedDocShell->MergeDocument( *pTmpDoc, true, true, 0, &aOwnInverseMergeMap, true );
1227 [ # # ][ # # ]: 0 : delete pTmpDoc;
1228 : 0 : sal_uLong nActStartOwn = nActEndShared + 1;
1229 : 0 : sal_uLong nActEndOwn = pSharedTrack->GetActionMax();
1230 : :
1231 : : // find conflicts
1232 [ # # ]: 0 : ScConflictsList aConflictsList;
1233 [ # # ]: 0 : ScConflictsFinder aFinder( pSharedTrack, nActStartShared, nActEndShared, nActStartOwn, nActEndOwn, aConflictsList );
1234 [ # # ][ # # ]: 0 : if ( aFinder.Find() )
1235 : : {
1236 [ # # ]: 0 : ScConflictsListHelper::TransformConflictsList( aConflictsList, NULL, &aOwnInverseMergeMap );
1237 : 0 : bool bLoop = true;
1238 [ # # ]: 0 : while ( bLoop )
1239 : : {
1240 : 0 : bLoop = false;
1241 [ # # ][ # # ]: 0 : ScConflictsDlg aDlg( GetActiveDialogParent(), GetViewData(), &rSharedDoc, aConflictsList );
[ # # ]
1242 [ # # ][ # # ]: 0 : if ( aDlg.Execute() == RET_CANCEL )
1243 : : {
1244 : : QueryBox aBox( GetActiveDialogParent(), WinBits( WB_YES_NO | WB_DEF_YES ),
1245 [ # # ][ # # ]: 0 : ScGlobal::GetRscString( STR_DOC_WILLNOTBESAVED ) );
[ # # ]
1246 [ # # ][ # # ]: 0 : if ( aBox.Execute() == RET_YES )
1247 : : {
1248 : 0 : return false;
1249 : : }
1250 : : else
1251 : : {
1252 [ # # ]: 0 : bLoop = true;
1253 [ # # ]: 0 : }
1254 : : }
1255 [ # # ][ # # ]: 0 : }
1256 : : }
1257 : :
1258 : : // undo own changes in shared document
1259 [ # # ]: 0 : pSharedTrack->Undo( nActStartOwn, nActEndOwn );
1260 : :
1261 : : // clone change track for merging into own document
1262 [ # # ][ # # ]: 0 : pTmpDoc = new ScDocument;
1263 [ # # ][ # # ]: 0 : for ( sal_Int32 nIndex = 0; nIndex < aDocument.GetTableCount(); ++nIndex )
1264 : : {
1265 : 0 : rtl::OUString sTabName;
1266 [ # # ]: 0 : pTmpDoc->CreateValidTabName( sTabName );
1267 [ # # ]: 0 : pTmpDoc->InsertTab( SC_TAB_APPEND, sTabName );
1268 : 0 : }
1269 [ # # ]: 0 : pThisTrack->Clone( pTmpDoc );
1270 : :
1271 : : // undo own changes since last save in own document
1272 : 0 : sal_uLong nStartShared = pThisAction->GetActionNumber();
1273 : 0 : ScChangeAction* pAction = pThisTrack->GetLast();
1274 [ # # ][ # # ]: 0 : while ( pAction && pAction->GetActionNumber() >= nStartShared )
[ # # ]
1275 : : {
1276 [ # # ]: 0 : pThisTrack->Reject( pAction, true );
1277 : 0 : pAction = pAction->GetPrev();
1278 : : }
1279 : :
1280 : : // #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong
1281 [ # # ]: 0 : pThisTrack->Undo( nStartShared, pThisTrack->GetActionMax(), true );
1282 : :
1283 : : // merge shared changes into own document
1284 [ # # ]: 0 : ScChangeActionMergeMap aSharedMergeMap;
1285 [ # # ]: 0 : MergeDocument( rSharedDoc, true, true, 0, &aSharedMergeMap );
1286 : 0 : sal_uLong nEndShared = pThisTrack->GetActionMax();
1287 : :
1288 : : // resolve conflicts for shared non-content actions
1289 [ # # ]: 0 : if ( !aConflictsList.empty() )
1290 : : {
1291 [ # # ]: 0 : ScConflictsListHelper::TransformConflictsList( aConflictsList, &aSharedMergeMap, NULL );
1292 [ # # ]: 0 : ScConflictsResolver aResolver( pThisTrack, aConflictsList );
1293 [ # # ]: 0 : pAction = pThisTrack->GetAction( nEndShared );
1294 [ # # ][ # # ]: 0 : while ( pAction && pAction->GetActionNumber() >= nStartShared )
[ # # ]
1295 : : {
1296 : : aResolver.HandleAction( pAction, true /*bIsSharedAction*/,
1297 [ # # ]: 0 : false /*bHandleContentAction*/, true /*bHandleNonContentAction*/ );
1298 : 0 : pAction = pAction->GetPrev();
1299 [ # # ]: 0 : }
1300 : : }
1301 : 0 : nEndShared = pThisTrack->GetActionMax();
1302 : :
1303 : : // only show changes from shared document
1304 : 0 : aChangeViewSet.SetShowChanges( sal_True );
1305 : 0 : aChangeViewSet.SetShowAccepted( sal_True );
1306 : 0 : aChangeViewSet.SetHasActionRange( true );
1307 : 0 : aChangeViewSet.SetTheActionRange( nStartShared, nEndShared );
1308 [ # # ]: 0 : aDocument.SetChangeViewSettings( aChangeViewSet );
1309 : :
1310 : : // merge own changes back into own document
1311 : 0 : sal_uLong nStartOwn = nEndShared + 1;
1312 [ # # ]: 0 : ScChangeActionMergeMap aOwnMergeMap;
1313 [ # # ]: 0 : MergeDocument( *pTmpDoc, true, true, nEndShared - nStartShared + 1, &aOwnMergeMap );
1314 [ # # ][ # # ]: 0 : delete pTmpDoc;
1315 : 0 : sal_uLong nEndOwn = pThisTrack->GetActionMax();
1316 : :
1317 : : // resolve conflicts for shared content actions and own actions
1318 [ # # ]: 0 : if ( !aConflictsList.empty() )
1319 : : {
1320 [ # # ]: 0 : ScConflictsListHelper::TransformConflictsList( aConflictsList, NULL, &aOwnMergeMap );
1321 [ # # ]: 0 : ScConflictsResolver aResolver( pThisTrack, aConflictsList );
1322 [ # # ]: 0 : pAction = pThisTrack->GetAction( nEndShared );
1323 [ # # ][ # # ]: 0 : while ( pAction && pAction->GetActionNumber() >= nStartShared )
[ # # ]
1324 : : {
1325 : : aResolver.HandleAction( pAction, true /*bIsSharedAction*/,
1326 [ # # ]: 0 : true /*bHandleContentAction*/, false /*bHandleNonContentAction*/ );
1327 : 0 : pAction = pAction->GetPrev();
1328 : : }
1329 : :
1330 [ # # ]: 0 : pAction = pThisTrack->GetAction( nEndOwn );
1331 [ # # ][ # # ]: 0 : while ( pAction && pAction->GetActionNumber() >= nStartOwn )
[ # # ]
1332 : : {
1333 : : aResolver.HandleAction( pAction, false /*bIsSharedAction*/,
1334 [ # # ]: 0 : true /*bHandleContentAction*/, true /*bHandleNonContentAction*/ );
1335 : 0 : pAction = pAction->GetPrev();
1336 [ # # ]: 0 : }
1337 : : }
1338 [ # # ][ # # ]: 0 : nEndOwn = pThisTrack->GetActionMax();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1339 : : }
1340 : : else
1341 : : {
1342 : : // merge shared changes into own document
1343 : 0 : sal_uLong nStartShared = pThisTrack->GetActionMax() + 1;
1344 [ # # ]: 0 : MergeDocument( rSharedDoc, true, true );
1345 : 0 : sal_uLong nEndShared = pThisTrack->GetActionMax();
1346 : :
1347 : : // only show changes from shared document
1348 : 0 : aChangeViewSet.SetShowChanges( sal_True );
1349 : 0 : aChangeViewSet.SetShowAccepted( sal_True );
1350 : 0 : aChangeViewSet.SetHasActionRange( true );
1351 : 0 : aChangeViewSet.SetTheActionRange( nStartShared, nEndShared );
1352 [ # # ]: 0 : aDocument.SetChangeViewSettings( aChangeViewSet );
1353 : : }
1354 : :
1355 : : // update view
1356 [ # # ]: 0 : PostPaintExtras();
1357 [ # # ]: 0 : PostPaintGridAll();
1358 : :
1359 [ # # ][ # # ]: 0 : InfoBox aInfoBox( GetActiveDialogParent(), ScGlobal::GetRscString( STR_DOC_UPDATED ) );
[ # # ]
1360 [ # # ][ # # ]: 0 : aInfoBox.Execute();
1361 : : }
1362 : :
1363 [ # # ]: 0 : return ( pThisAction != NULL );
1364 : : }
1365 : :
1366 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|