Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #define _SVX_PARAITEM_HXX
22 : #define _SVX_TEXTITEM_HXX
23 :
24 : #include <com/sun/star/accessibility/XAccessible.hpp>
25 :
26 : #include <sfx2/viewfrm.hxx>
27 : #include <sfx2/progress.hxx>
28 : #include <svx/srchdlg.hxx>
29 : #include <svx/svdobj.hxx>
30 : #include <sfx2/viewsh.hxx>
31 : #include <swwait.hxx>
32 : #include <swmodule.hxx>
33 : #include <fesh.hxx>
34 : #include <doc.hxx>
35 : #include <rootfrm.hxx>
36 : #include <pagefrm.hxx>
37 : #include <cntfrm.hxx>
38 : #include <viewimp.hxx>
39 : #include <frmtool.hxx>
40 : #include <viewopt.hxx>
41 : #include <dview.hxx>
42 : #include <swregion.hxx>
43 : #include <hints.hxx>
44 : #include <fmtfsize.hxx>
45 : #include <docufld.hxx>
46 : #include <txtfrm.hxx>
47 : #include <layact.hxx>
48 : #include <mdiexp.hxx>
49 : #include <fntcache.hxx>
50 : #include <ptqueue.hxx>
51 : #include <tabfrm.hxx>
52 : #include <docsh.hxx>
53 : #include <pagedesc.hxx>
54 : #include <ndole.hxx>
55 : #include <ndindex.hxx>
56 : #include <accmap.hxx>
57 : #include <svtools/colorcfg.hxx>
58 : #include <svtools/accessibilityoptions.hxx>
59 : #include <accessibilityoptions.hxx>
60 : #include <statstr.hrc>
61 : #include <comcore.hrc>
62 : #include <pagepreviewlayout.hxx>
63 : #include <sortedobjs.hxx>
64 : #include <anchoredobject.hxx>
65 :
66 : #include "../../ui/inc/view.hxx"
67 : #include <PostItMgr.hxx>
68 : #include <vcl/virdev.hxx>
69 :
70 : #include <vcl/svapp.hxx>
71 :
72 : #include <svx/sdrpaintwindow.hxx>
73 :
74 : sal_Bool ViewShell::bLstAct = sal_False;
75 : ShellResource *ViewShell::pShellRes = 0;
76 : Window *ViewShell::pCareWindow = 0;
77 : BitmapEx* ViewShell::pErrorBmp = NULL;
78 : BitmapEx* ViewShell::pReplaceBmp = NULL;
79 :
80 : bool bInSizeNotify = false;
81 :
82 : DBG_NAME(LayoutIdle)
83 :
84 3414 : TYPEINIT0(ViewShell);
85 :
86 : using namespace ::com::sun::star;
87 :
88 0 : void ViewShell::ToggleHeaderFooterEdit()
89 : {
90 0 : bHeaderFooterEdit = !bHeaderFooterEdit;
91 0 : if ( !bHeaderFooterEdit )
92 : {
93 0 : SetShowHeaderFooterSeparator( Header, false );
94 0 : SetShowHeaderFooterSeparator( Footer, false );
95 : }
96 :
97 : // Avoid corner case
98 0 : if ( !IsShowHeaderFooterSeparator( Header ) &&
99 0 : !IsShowHeaderFooterSeparator( Footer ) )
100 : {
101 0 : bHeaderFooterEdit = false;
102 : }
103 :
104 : // Repaint everything
105 0 : GetWin()->Invalidate();
106 0 : }
107 :
108 : //////////////////////////////////////////////////////////////////////////////
109 : // #i72754# 2nd set of Pre/PostPaints
110 : // This time it uses the lock counter (mPrePostPaintRegions empty/non-empty) to allow only one activation
111 : // and deactivation and mpPrePostOutDev to remember the OutDev from the BeginDrawLayers
112 : // call. That way, all places where paint take place can be handled the same way, even
113 : // when calling other paint methods. This is the case at the places where SW paints
114 : // buffered into VDevs to avoid flicker. Tis is in general problematic and should be
115 : // solved once using the BufferedOutput functionality of the DrawView.
116 :
117 1049 : void ViewShell::PrePaint()
118 : {
119 : // forward PrePaint event from VCL Window to DrawingLayer
120 1049 : if(HasDrawView())
121 : {
122 1049 : Imp()->GetDrawView()->PrePaint();
123 : }
124 1049 : }
125 :
126 1056 : void ViewShell::DLPrePaint2(const Region& rRegion)
127 : {
128 1056 : if(mPrePostPaintRegions.empty())
129 : {
130 264 : mPrePostPaintRegions.push( rRegion );
131 : // #i75172# ensure DrawView to use DrawingLayer bufferings
132 264 : if ( !HasDrawView() )
133 0 : MakeDrawView();
134 :
135 : // Prefer window; if tot available, get pOut (e.g. printer)
136 264 : mpPrePostOutDev = (GetWin() ? GetWin() : GetOut());
137 :
138 : // #i74769# use SdrPaintWindow now direct
139 264 : mpTargetPaintWindow = Imp()->GetDrawView()->BeginDrawLayers(mpPrePostOutDev, rRegion);
140 : OSL_ENSURE(mpTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
141 :
142 : // #i74769# if prerender, save OutDev and redirect to PreRenderDevice
143 264 : if(mpTargetPaintWindow->GetPreRenderDevice())
144 : {
145 262 : mpBufferedOut = pOut;
146 262 : pOut = &(mpTargetPaintWindow->GetTargetOutputDevice());
147 : }
148 :
149 : // remember original paint MapMode for wrapped FlyFrame paints
150 264 : maPrePostMapMode = pOut->GetMapMode();
151 : }
152 : else
153 : {
154 : // region needs to be updated to the given one
155 792 : if( mPrePostPaintRegions.top() != rRegion )
156 789 : Imp()->GetDrawView()->UpdateDrawLayersRegion(mpPrePostOutDev, rRegion);
157 792 : mPrePostPaintRegions.push( rRegion );
158 : }
159 1056 : }
160 :
161 1056 : void ViewShell::DLPostPaint2(bool bPaintFormLayer)
162 : {
163 : OSL_ENSURE(!mPrePostPaintRegions.empty(), "ViewShell::DLPostPaint2: Pre/PostPaint encapsulation broken (!)");
164 :
165 1056 : if( mPrePostPaintRegions.size() > 1 )
166 : {
167 792 : Region current = mPrePostPaintRegions.top();
168 792 : mPrePostPaintRegions.pop();
169 792 : if( current != mPrePostPaintRegions.top())
170 789 : Imp()->GetDrawView()->UpdateDrawLayersRegion(mpPrePostOutDev, mPrePostPaintRegions.top());
171 1848 : return;
172 : }
173 264 : mPrePostPaintRegions.pop(); // clear
174 264 : if(0 != mpTargetPaintWindow)
175 : {
176 : // #i74769# restore buffered OutDev
177 264 : if(mpTargetPaintWindow->GetPreRenderDevice())
178 : {
179 262 : pOut = mpBufferedOut;
180 : }
181 :
182 : // #i74769# use SdrPaintWindow now direct
183 264 : Imp()->GetDrawView()->EndDrawLayers(*mpTargetPaintWindow, bPaintFormLayer);
184 264 : mpTargetPaintWindow = 0;
185 : }
186 : }
187 :
188 : //////////////////////////////////////////////////////////////////////////////
189 :
190 :
191 1333 : void ViewShell::ImplEndAction( const sal_Bool bIdleEnd )
192 : {
193 : // Nothing to do for the printer?
194 1333 : if ( !GetWin() || IsPreView() )
195 : {
196 0 : bPaintWorks = sal_True;
197 0 : UISizeNotify();
198 1333 : return;
199 : }
200 :
201 1333 : bInEndAction = sal_True;
202 : //Laeuft hiermit das EndAction der Letzten Shell im Ring?
203 :
204 1333 : ViewShell::bLstAct = sal_True;
205 1333 : ViewShell *pSh = (ViewShell*)this->GetNext();
206 2666 : while ( pSh != this )
207 : {
208 0 : if ( pSh->ActionPend() )
209 : {
210 0 : ViewShell::bLstAct = sal_False;
211 0 : pSh = this;
212 : }
213 : else
214 0 : pSh = (ViewShell*)pSh->GetNext();
215 : }
216 :
217 1333 : const bool bIsShellForCheckViewLayout = ( this == GetLayout()->GetCurrShell() );
218 :
219 1333 : SET_CURR_SHELL( this );
220 1333 : if ( Imp()->HasDrawView() && !Imp()->GetDrawView()->areMarkHandlesHidden() )
221 721 : Imp()->StartAction();
222 :
223 1333 : if ( Imp()->GetRegion() && Imp()->GetRegion()->GetOrigin() != VisArea() )
224 0 : Imp()->DelRegion();
225 :
226 1333 : const bool bExtraData = ::IsExtraData( GetDoc() );
227 :
228 1333 : if ( !bIdleEnd )
229 : {
230 1097 : SwLayAction aAction( GetLayout(), Imp() );
231 1097 : aAction.SetComplete( sal_False );
232 1097 : if ( nLockPaint )
233 612 : aAction.SetPaint( sal_False );
234 1097 : aAction.SetInputType( VCL_INPUT_KEYBOARD );
235 1097 : aAction.Action();
236 : }
237 :
238 1333 : if ( bIsShellForCheckViewLayout )
239 1333 : GetLayout()->CheckViewLayout( GetViewOptions(), &aVisArea );
240 :
241 : //Wenn wir selbst keine Paints erzeugen, so warten wir auf das Paint
242 : //vom System. Dann ist das Clipping korrekt gesetzt; Beispiel: verschieben
243 : //eines DrawObjektes.
244 2660 : if ( Imp()->GetRegion() ||
245 1327 : aInvalidRect.HasArea() ||
246 : bExtraData )
247 : {
248 26 : if ( !nLockPaint )
249 : {
250 24 : SolarMutexGuard aGuard;
251 :
252 24 : sal_Bool bPaintsFromSystem = aInvalidRect.HasArea();
253 24 : GetWin()->Update();
254 24 : if ( aInvalidRect.HasArea() )
255 : {
256 18 : if ( bPaintsFromSystem )
257 14 : Imp()->AddPaintRect( aInvalidRect );
258 :
259 18 : ResetInvalidRect();
260 18 : bPaintsFromSystem = sal_True;
261 : }
262 24 : bPaintWorks = sal_True;
263 :
264 24 : SwRegionRects *pRegion = Imp()->GetRegion();
265 :
266 : //JP 27.11.97: wer die Selection hided, muss sie aber auch
267 : // wieder Showen. Sonst gibt es Paintfehler!
268 : // z.B.: addional Mode, Seite vertikal hab zu sehen, in der
269 : // Mitte eine Selektion und mit einem anderen Cursor an linken
270 : // rechten Rand springen. Ohne ShowCrsr verschwindet die
271 : // Selektion
272 24 : bool bShowCrsr = pRegion && IsA( TYPE(SwCrsrShell) );
273 24 : if( bShowCrsr )
274 20 : ((SwCrsrShell*)this)->HideCrsrs();
275 :
276 24 : if ( pRegion )
277 : {
278 20 : SwRootFrm* pCurrentLayout = GetLayout();
279 :
280 20 : Imp()->pRegion = NULL;
281 :
282 : //Erst Invert dann Compress, niemals andersherum!
283 20 : pRegion->Invert();
284 :
285 20 : pRegion->Compress();
286 :
287 20 : VirtualDevice *pVout = 0;
288 60 : while ( !pRegion->empty() )
289 : {
290 20 : SwRect aRect( pRegion->back() );
291 20 : pRegion->pop_back();
292 :
293 20 : bool bPaint = true;
294 20 : if ( IsEndActionByVirDev() )
295 : {
296 : //virtuelles device erzeugen und einstellen.
297 0 : if ( !pVout )
298 0 : pVout = new VirtualDevice( *GetOut() );
299 0 : MapMode aMapMode( GetOut()->GetMapMode() );
300 0 : pVout->SetMapMode( aMapMode );
301 :
302 0 : sal_Bool bSizeOK = sal_True;
303 :
304 0 : Rectangle aTmp1( aRect.SVRect() );
305 0 : aTmp1 = GetOut()->LogicToPixel( aTmp1 );
306 0 : Rectangle aTmp2( GetOut()->PixelToLogic( aTmp1 ) );
307 0 : if ( aTmp2.Left() > aRect.Left() )
308 0 : aTmp1.Left() = Max( 0L, aTmp1.Left() - 1L );
309 0 : if ( aTmp2.Top() > aRect.Top() )
310 0 : aTmp1.Top() = Max( 0L, aTmp1.Top() - 1L );
311 0 : aTmp1.Right() += 1;
312 0 : aTmp1.Bottom() += 1;
313 0 : aTmp1 = GetOut()->PixelToLogic( aTmp1 );
314 0 : aRect = SwRect( aTmp1 );
315 :
316 0 : const Size aTmp( pVout->GetOutputSize() );
317 0 : if ( aTmp.Height() < aRect.Height() ||
318 0 : aTmp.Width() < aRect.Width() )
319 : {
320 0 : bSizeOK = pVout->SetOutputSize( aRect.SSize() );
321 : }
322 0 : if ( bSizeOK )
323 : {
324 0 : bPaint = false;
325 :
326 : // --> OD 2007-07-26 #i79947#
327 : // #i72754# start Pre/PostPaint encapsulation before pOut is changed to the buffering VDev
328 0 : const Region aRepaintRegion(aRect.SVRect());
329 0 : DLPrePaint2(aRepaintRegion);
330 : // <--
331 :
332 0 : OutputDevice *pOld = GetOut();
333 0 : pVout->SetLineColor( pOld->GetLineColor() );
334 0 : pVout->SetFillColor( pOld->GetFillColor() );
335 0 : Point aOrigin( aRect.Pos() );
336 0 : aOrigin.X() = -aOrigin.X(); aOrigin.Y() = -aOrigin.Y();
337 0 : aMapMode.SetOrigin( aOrigin );
338 0 : pVout->SetMapMode( aMapMode );
339 :
340 0 : pOut = pVout;
341 0 : if ( bPaintsFromSystem )
342 0 : PaintDesktop( aRect );
343 0 : pCurrentLayout->Paint( aRect );
344 0 : pOld->DrawOutDev( aRect.Pos(), aRect.SSize(),
345 0 : aRect.Pos(), aRect.SSize(), *pVout );
346 0 : pOut = pOld;
347 :
348 : // #i72754# end Pre/PostPaint encapsulation when pOut is back and content is painted
349 0 : DLPostPaint2(true);
350 0 : }
351 : }
352 20 : if ( bPaint )
353 : {
354 : // #i75172# begin DrawingLayer paint
355 : // need to do begin/end DrawingLayer preparation for each single rectangle of the
356 : // repaint region. I already tried to prepare only once for the whole Region. This
357 : // seems to work (and does technically) but fails with transparent objects. Since the
358 : // region given to BeginDarwLayers() defines the clip region for DrawingLayer paint,
359 : // transparent objects in the single rectangles will indeed be painted multiple times.
360 20 : DLPrePaint2(Region(aRect.SVRect()));
361 :
362 20 : if ( bPaintsFromSystem )
363 18 : PaintDesktop( aRect );
364 20 : pCurrentLayout->Paint( aRect );
365 :
366 : // #i75172# end DrawingLayer paint
367 20 : DLPostPaint2(true);
368 : }
369 :
370 : // #i107365#
371 : // Direct paint has been performed. Thus, take care of
372 : // transparent child windows.
373 20 : if ( GetWin() )
374 : {
375 20 : Window& rWindow = *(GetWin());
376 20 : if (rWindow.IsChildTransparentModeEnabled())
377 : {
378 20 : Window* pCandidate = rWindow.GetWindow( WINDOW_FIRSTCHILD );
379 20 : if (pCandidate)
380 : {
381 8 : const Rectangle aRectanglePixel(rWindow.LogicToPixel(aRect.SVRect()));
382 :
383 40 : while (pCandidate)
384 : {
385 24 : if ( pCandidate->IsPaintTransparent() )
386 : {
387 : const Rectangle aCandidatePosSizePixel(
388 12 : pCandidate->GetPosPixel(),
389 24 : pCandidate->GetSizePixel());
390 :
391 12 : if ( aCandidatePosSizePixel.IsOver(aRectanglePixel) )
392 : {
393 6 : pCandidate->Invalidate( INVALIDATE_NOTRANSPARENT|INVALIDATE_CHILDREN );
394 6 : pCandidate->Update();
395 : }
396 : }
397 :
398 24 : pCandidate = pCandidate->GetWindow( WINDOW_NEXT );
399 : }
400 : }
401 : }
402 : }
403 : }
404 :
405 20 : delete pVout;
406 20 : delete pRegion;
407 20 : Imp()->DelRegion();
408 : }
409 24 : if( bShowCrsr )
410 20 : ((SwCrsrShell*)this)->ShowCrsrs( sal_True );
411 : }
412 : else
413 : {
414 2 : Imp()->DelRegion();
415 2 : bPaintWorks = sal_True;
416 : }
417 : }
418 : else
419 1307 : bPaintWorks = sal_True;
420 :
421 1333 : bInEndAction = sal_False;
422 1333 : ViewShell::bLstAct = sal_False;
423 1333 : Imp()->EndAction();
424 :
425 :
426 : //Damit sich die automatischen Scrollbars auch richtig anordnen k?nnen
427 : //muessen wir die Aktion hier kuenstlich beenden (EndAction loesst ein
428 : //Notify aus, und das muss Start-/EndAction rufen um die Scrollbars
429 : //klarzubekommen.
430 1333 : --nStartAction;
431 1333 : UISizeNotify();
432 1333 : ++nStartAction;
433 :
434 1333 : if( Imp()->IsAccessible() )
435 0 : Imp()->FireAccessibleEvents();
436 : }
437 :
438 :
439 1333 : void ViewShell::ImplStartAction()
440 : {
441 1333 : bPaintWorks = sal_False;
442 1333 : Imp()->StartAction();
443 1333 : }
444 :
445 :
446 644 : void ViewShell::ImplLockPaint()
447 : {
448 644 : if ( GetWin() && GetWin()->IsVisible() )
449 644 : GetWin()->EnablePaint( sal_False ); //Auch die Controls abklemmen.
450 644 : Imp()->LockPaint();
451 644 : }
452 :
453 :
454 644 : void ViewShell::ImplUnlockPaint( sal_Bool bVirDev )
455 : {
456 644 : SET_CURR_SHELL( this );
457 644 : if ( GetWin() && GetWin()->IsVisible() )
458 : {
459 644 : if ( (bInSizeNotify || bVirDev ) && VisArea().HasArea() )
460 : {
461 : //Refresh mit virtuellem Device um das Flackern zu verhindern.
462 0 : VirtualDevice *pVout = new VirtualDevice( *pOut );
463 0 : pVout->SetMapMode( pOut->GetMapMode() );
464 0 : Size aSize( VisArea().SSize() );
465 0 : aSize.Width() += 20;
466 0 : aSize.Height()+= 20;
467 0 : if( pVout->SetOutputSize( aSize ) )
468 : {
469 0 : GetWin()->EnablePaint( sal_True );
470 0 : GetWin()->Validate();
471 :
472 0 : Imp()->UnlockPaint();
473 0 : pVout->SetLineColor( pOut->GetLineColor() );
474 0 : pVout->SetFillColor( pOut->GetFillColor() );
475 :
476 : // #i72754# start Pre/PostPaint encapsulation before pOut is changed to the buffering VDev
477 0 : const Region aRepaintRegion(VisArea().SVRect());
478 0 : DLPrePaint2(aRepaintRegion);
479 :
480 0 : OutputDevice *pOld = pOut;
481 0 : pOut = pVout;
482 0 : Paint( VisArea().SVRect() );
483 0 : pOut = pOld;
484 0 : pOut->DrawOutDev( VisArea().Pos(), aSize,
485 0 : VisArea().Pos(), aSize, *pVout );
486 :
487 : // #i72754# end Pre/PostPaint encapsulation when pOut is back and content is painted
488 0 : DLPostPaint2(true);
489 : }
490 : else
491 : {
492 0 : Imp()->UnlockPaint();
493 0 : GetWin()->EnablePaint( sal_True );
494 0 : GetWin()->Invalidate( INVALIDATE_CHILDREN );
495 : }
496 0 : delete pVout;
497 : }
498 : else
499 : {
500 644 : Imp()->UnlockPaint();
501 644 : GetWin()->EnablePaint( sal_True );
502 644 : GetWin()->Invalidate( INVALIDATE_CHILDREN );
503 : }
504 : }
505 : else
506 0 : Imp()->UnlockPaint();
507 644 : }
508 :
509 :
510 136 : sal_Bool ViewShell::AddPaintRect( const SwRect & rRect )
511 : {
512 136 : sal_Bool bRet = sal_False;
513 136 : ViewShell *pSh = this;
514 136 : do
515 : {
516 136 : if( pSh->Imp() )
517 : {
518 136 : if ( pSh->IsPreView() && pSh->GetWin() )
519 0 : ::RepaintPagePreview( pSh, rRect );
520 : else
521 136 : bRet |= pSh->Imp()->AddPaintRect( rRect );
522 : }
523 136 : pSh = (ViewShell*)pSh->GetNext();
524 : } while ( pSh != this );
525 136 : return bRet;
526 : }
527 :
528 :
529 229 : void ViewShell::InvalidateWindows( const SwRect &rRect )
530 : {
531 229 : if ( !Imp()->IsCalcLayoutProgress() )
532 : {
533 176 : ViewShell *pSh = this;
534 176 : do
535 : {
536 176 : if ( pSh->GetWin() )
537 : {
538 176 : if ( pSh->IsPreView() )
539 0 : ::RepaintPagePreview( pSh, rRect );
540 176 : else if ( pSh->VisArea().IsOver( rRect ) )
541 126 : pSh->GetWin()->Invalidate( rRect.SVRect() );
542 : }
543 176 : pSh = (ViewShell*)pSh->GetNext();
544 :
545 : } while ( pSh != this );
546 : }
547 229 : }
548 :
549 :
550 1110 : void ViewShell::MakeVisible( const SwRect &rRect )
551 : {
552 1110 : if ( !VisArea().IsInside( rRect ) || IsScrollMDI( this, rRect ) || GetCareWin(*this) )
553 : {
554 174 : if ( !IsViewLocked() )
555 : {
556 60 : if( pWin )
557 : {
558 60 : const SwFrm* pRoot = GetLayout();
559 60 : int nLoopCnt = 3;
560 : long nOldH;
561 60 : do{
562 60 : nOldH = pRoot->Frm().Height();
563 60 : StartAction();
564 60 : ScrollMDI( this, rRect, USHRT_MAX, USHRT_MAX );
565 60 : EndAction();
566 60 : } while( nOldH != pRoot->Frm().Height() && nLoopCnt-- ); //swmod 071108//swmod 071225
567 : }
568 : #if OSL_DEBUG_LEVEL > 0
569 : else
570 : {
571 : //MA: 04. Nov. 94, braucht doch keiner oder??
572 : OSL_ENSURE( !this, "MakeVisible fuer Drucker wird doch gebraucht?" );
573 : }
574 :
575 : #endif
576 : }
577 : }
578 1110 : }
579 :
580 :
581 952 : Window* ViewShell::CareChildWin(ViewShell& rVSh)
582 : {
583 952 : if(rVSh.pSfxViewShell)
584 : {
585 952 : const sal_uInt16 nId = SvxSearchDialogWrapper::GetChildWindowId();
586 952 : SfxViewFrame* pVFrame = rVSh.pSfxViewShell->GetViewFrame();
587 952 : const SfxChildWindow* pChWin = pVFrame->GetChildWindow( nId );
588 952 : Window *pWin = pChWin ? pChWin->GetWindow() : NULL;
589 952 : if ( pWin && pWin->IsVisible() )
590 0 : return pWin;
591 : }
592 952 : return NULL;
593 : }
594 :
595 :
596 0 : Point ViewShell::GetPagePos( sal_uInt16 nPageNum ) const
597 : {
598 0 : return GetLayout()->GetPagePos( nPageNum );
599 : }
600 :
601 :
602 1211 : sal_uInt16 ViewShell::GetNumPages()
603 : {
604 : //Es kann sein, das noch kein Layout existiert weil die Methode vom
605 : //Root-Ctor gerufen wird.
606 1211 : return GetLayout() ? GetLayout()->GetPageNum() : 0;
607 : }
608 :
609 0 : sal_Bool ViewShell::IsDummyPage( sal_uInt16 nPageNum ) const
610 : {
611 0 : return GetLayout() ? GetLayout()->IsDummyPage( nPageNum ) : 0;
612 : }
613 :
614 : /**
615 : * Forces update of each field.
616 : * It notifies all fields with pNewHt. If that is 0 (default), the field
617 : * type is sent (???).
618 : * @param[in] bCloseDB Passed in to GetDoc()->UpdateFlds. [TODO] Purpose???
619 : */
620 0 : void ViewShell::UpdateFlds(sal_Bool bCloseDB)
621 : {
622 0 : SET_CURR_SHELL( this );
623 :
624 0 : sal_Bool bCrsr = ISA(SwCrsrShell);
625 0 : if ( bCrsr )
626 0 : ((SwCrsrShell*)this)->StartAction();
627 : else
628 0 : StartAction();
629 :
630 0 : GetDoc()->UpdateFlds(0, bCloseDB);
631 :
632 0 : if ( bCrsr )
633 0 : ((SwCrsrShell*)this)->EndAction();
634 : else
635 0 : EndAction();
636 0 : }
637 :
638 : /** update all charts for which any table exists */
639 0 : void ViewShell::UpdateAllCharts()
640 : {
641 0 : SET_CURR_SHELL( this );
642 : // Start-/EndAction handled in the SwDoc-Method!
643 0 : GetDoc()->UpdateAllCharts();
644 0 : }
645 :
646 0 : sal_Bool ViewShell::HasCharts() const
647 : {
648 0 : sal_Bool bRet = sal_False;
649 : const SwStartNode *pStNd;
650 0 : SwNodeIndex aIdx( *GetDoc()->GetNodes().GetEndOfAutotext().
651 0 : StartOfSectionNode(), 1 );
652 0 : while ( 0 != (pStNd = aIdx.GetNode().GetStartNode()) )
653 : {
654 0 : ++aIdx;
655 0 : const SwOLENode *pNd = aIdx.GetNode().GetOLENode();
656 0 : if( pNd && pNd->GetChartTblName().Len() )
657 : {
658 0 : bRet = sal_True;
659 0 : break;
660 : }
661 : }
662 0 : return bRet;
663 : }
664 :
665 :
666 379 : void ViewShell::LayoutIdle()
667 : {
668 : #ifdef TCOVER
669 : //fuer TCV-Version: Ende der Startphase des Programmes
670 : TCovCall::Idle();
671 : #endif
672 1137 : if( !pOpt->IsIdle() || !GetWin() ||
673 758 : ( Imp()->HasDrawView() && Imp()->GetDrawView()->IsDragObj() ) )
674 : return;
675 :
676 : //Kein Idle wenn gerade gedruckt wird.
677 379 : ViewShell *pSh = this;
678 379 : do
679 379 : { if ( !pSh->GetWin() )
680 : return;
681 379 : pSh = (ViewShell*)pSh->GetNext();
682 :
683 : } while ( pSh != this );
684 :
685 379 : SET_CURR_SHELL( this );
686 :
687 : #ifdef DBG_UTIL
688 : // Wenn Test5 gedrueckt ist, wird der IdleFormatierer abgeknipst.
689 : if( pOpt->IsTest5() )
690 : return;
691 : #endif
692 :
693 : {
694 : DBG_PROFSTART( LayoutIdle );
695 :
696 : //Cache vorbereiten und restaurieren, damit er nicht versaut wird.
697 379 : SwSaveSetLRUOfst aSave( *SwTxtFrm::GetTxtCache(),
698 758 : SwTxtFrm::GetTxtCache()->GetCurMax() - 50 );
699 : // #125243# there are lots of stacktraces indicating that Imp() returns NULL
700 : // this ViewShell seems to be invalid - but it's not clear why
701 : // this return is only a workaround!
702 : OSL_ENSURE(Imp(), "ViewShell already deleted?");
703 379 : if(!Imp())
704 : return;
705 379 : SwLayIdle aIdle( GetLayout(), Imp() );
706 379 : DBG_PROFSTOP( LayoutIdle );
707 379 : }
708 : }
709 :
710 :
711 0 : static void lcl_InvalidateAllCntnt( ViewShell& rSh, sal_uInt8 nInv )
712 : {
713 0 : sal_Bool bCrsr = rSh.ISA(SwCrsrShell);
714 0 : if ( bCrsr )
715 0 : ((SwCrsrShell&)rSh).StartAction();
716 : else
717 0 : rSh.StartAction();
718 0 : rSh.GetLayout()->InvalidateAllCntnt( nInv );
719 0 : if ( bCrsr )
720 0 : ((SwCrsrShell&)rSh).EndAction();
721 : else
722 0 : rSh.EndAction();
723 :
724 0 : rSh.GetDoc()->SetModified();
725 0 : }
726 :
727 : /** local method to invalidate/re-calculate positions of floating screen
728 : * objects (Writer fly frame and drawing objects), which are anchored
729 : * to paragraph or to character. #i11860#
730 : */
731 0 : static void lcl_InvalidateAllObjPos( ViewShell &_rSh )
732 : {
733 0 : const bool bIsCrsrShell = _rSh.ISA(SwCrsrShell);
734 0 : if ( bIsCrsrShell )
735 0 : static_cast<SwCrsrShell&>(_rSh).StartAction();
736 : else
737 0 : _rSh.StartAction();
738 :
739 0 : _rSh.GetLayout()->InvalidateAllObjPos();
740 :
741 0 : if ( bIsCrsrShell )
742 0 : static_cast<SwCrsrShell&>(_rSh).EndAction();
743 : else
744 0 : _rSh.EndAction();
745 :
746 0 : _rSh.GetDoc()->SetModified();
747 0 : }
748 :
749 0 : void ViewShell::SetParaSpaceMax( bool bNew )
750 : {
751 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
752 0 : if( pIDSA->get(IDocumentSettingAccess::PARA_SPACE_MAX) != bNew )
753 : {
754 0 : SwWait aWait( *GetDoc()->GetDocShell(), sal_True );
755 0 : pIDSA->set(IDocumentSettingAccess::PARA_SPACE_MAX, bNew );
756 0 : const sal_uInt8 nInv = INV_PRTAREA | INV_TABLE | INV_SECTION;
757 0 : lcl_InvalidateAllCntnt( *this, nInv );
758 : }
759 0 : }
760 :
761 0 : void ViewShell::SetParaSpaceMaxAtPages( bool bNew )
762 : {
763 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
764 0 : if( pIDSA->get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES) != bNew )
765 : {
766 0 : SwWait aWait( *GetDoc()->GetDocShell(), sal_True );
767 0 : pIDSA->set(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES, bNew );
768 0 : const sal_uInt8 nInv = INV_PRTAREA | INV_TABLE | INV_SECTION;
769 0 : lcl_InvalidateAllCntnt( *this, nInv );
770 : }
771 0 : }
772 :
773 0 : void ViewShell::SetTabCompat( bool bNew )
774 : {
775 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
776 0 : if( pIDSA->get(IDocumentSettingAccess::TAB_COMPAT) != bNew )
777 : {
778 0 : SwWait aWait( *GetDoc()->GetDocShell(), sal_True );
779 0 : pIDSA->set(IDocumentSettingAccess::TAB_COMPAT, bNew );
780 0 : const sal_uInt8 nInv = INV_PRTAREA | INV_SIZE | INV_TABLE | INV_SECTION;
781 0 : lcl_InvalidateAllCntnt( *this, nInv );
782 : }
783 0 : }
784 :
785 0 : void ViewShell::SetAddExtLeading( bool bNew )
786 : {
787 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
788 0 : if ( pIDSA->get(IDocumentSettingAccess::ADD_EXT_LEADING) != bNew )
789 : {
790 0 : SwWait aWait( *GetDoc()->GetDocShell(), sal_True );
791 0 : pIDSA->set(IDocumentSettingAccess::ADD_EXT_LEADING, bNew );
792 0 : SdrModel* pTmpDrawModel = getIDocumentDrawModelAccess()->GetDrawModel();
793 0 : if ( pTmpDrawModel )
794 0 : pTmpDrawModel->SetAddExtLeading( bNew );
795 0 : const sal_uInt8 nInv = INV_PRTAREA | INV_SIZE | INV_TABLE | INV_SECTION;
796 0 : lcl_InvalidateAllCntnt( *this, nInv );
797 : }
798 0 : }
799 :
800 0 : void ViewShell::SetUseVirDev( bool bNewVirtual )
801 : {
802 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
803 0 : if ( pIDSA->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) != bNewVirtual )
804 : {
805 0 : SwWait aWait( *GetDoc()->GetDocShell(), sal_True );
806 : // this sets the flag at the document and calls PrtDataChanged
807 0 : IDocumentDeviceAccess* pIDDA = getIDocumentDeviceAccess();
808 0 : pIDDA->setReferenceDeviceType( bNewVirtual, true );
809 : }
810 0 : }
811 :
812 : /** Sets if paragraph and table spacing is added at bottom of table cells.
813 : * #106629#
814 : * @param[in] (bool) setting of the new value
815 : */
816 0 : void ViewShell::SetAddParaSpacingToTableCells( bool _bAddParaSpacingToTableCells )
817 : {
818 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
819 0 : if ( pIDSA->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS) != _bAddParaSpacingToTableCells )
820 : {
821 0 : SwWait aWait( *GetDoc()->GetDocShell(), sal_True );
822 0 : pIDSA->set(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS, _bAddParaSpacingToTableCells );
823 0 : const sal_uInt8 nInv = INV_PRTAREA;
824 0 : lcl_InvalidateAllCntnt( *this, nInv );
825 : }
826 0 : }
827 :
828 : /**
829 : * Sets if former formatting of text lines with proportional line spacing should used.
830 : * #i11859#
831 : * @param[in] (bool) setting of the new value
832 : */
833 0 : void ViewShell::SetUseFormerLineSpacing( bool _bUseFormerLineSpacing )
834 : {
835 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
836 0 : if ( pIDSA->get(IDocumentSettingAccess::OLD_LINE_SPACING) != _bUseFormerLineSpacing )
837 : {
838 0 : SwWait aWait( *GetDoc()->GetDocShell(), sal_True );
839 0 : pIDSA->set(IDocumentSettingAccess::OLD_LINE_SPACING, _bUseFormerLineSpacing );
840 0 : const sal_uInt8 nInv = INV_PRTAREA;
841 0 : lcl_InvalidateAllCntnt( *this, nInv );
842 : }
843 0 : }
844 :
845 :
846 : /**
847 : * Sets IDocumentSettingAccess if former object positioning should be used.
848 : * #i11860#
849 : * @param[in] (bool) setting the new value
850 : */
851 0 : void ViewShell::SetUseFormerObjectPositioning( bool _bUseFormerObjPos )
852 : {
853 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
854 0 : if ( pIDSA->get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS) != _bUseFormerObjPos )
855 : {
856 0 : SwWait aWait( *GetDoc()->GetDocShell(), sal_True );
857 0 : pIDSA->set(IDocumentSettingAccess::USE_FORMER_OBJECT_POS, _bUseFormerObjPos );
858 0 : lcl_InvalidateAllObjPos( *this );
859 : }
860 0 : }
861 :
862 :
863 : // #i28701#
864 0 : void ViewShell::SetConsiderWrapOnObjPos( bool _bConsiderWrapOnObjPos )
865 : {
866 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
867 0 : if ( pIDSA->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) != _bConsiderWrapOnObjPos )
868 : {
869 0 : SwWait aWait( *GetDoc()->GetDocShell(), sal_True );
870 0 : pIDSA->set(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION, _bConsiderWrapOnObjPos );
871 0 : lcl_InvalidateAllObjPos( *this );
872 : }
873 0 : }
874 :
875 :
876 0 : void ViewShell::SetUseFormerTextWrapping( bool _bUseFormerTextWrapping )
877 : {
878 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
879 0 : if ( pIDSA->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) != _bUseFormerTextWrapping )
880 : {
881 0 : SwWait aWait( *GetDoc()->GetDocShell(), sal_True );
882 0 : pIDSA->set(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING, _bUseFormerTextWrapping );
883 0 : const sal_uInt8 nInv = INV_PRTAREA | INV_SIZE | INV_TABLE | INV_SECTION;
884 0 : lcl_InvalidateAllCntnt( *this, nInv );
885 : }
886 0 : }
887 :
888 :
889 : // #i45491#
890 0 : void ViewShell::SetDoNotJustifyLinesWithManualBreak( bool _bDoNotJustifyLinesWithManualBreak )
891 : {
892 0 : IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
893 0 : if ( pIDSA->get(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK) != _bDoNotJustifyLinesWithManualBreak )
894 : {
895 0 : SwWait aWait( *GetDoc()->GetDocShell(), sal_True );
896 0 : pIDSA->set(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, _bDoNotJustifyLinesWithManualBreak );
897 0 : const sal_uInt8 nInv = INV_PRTAREA | INV_SIZE | INV_TABLE | INV_SECTION;
898 0 : lcl_InvalidateAllCntnt( *this, nInv );
899 : }
900 0 : }
901 :
902 :
903 0 : void ViewShell::Reformat()
904 : {
905 0 : SwWait aWait( *GetDoc()->GetDocShell(), sal_True );
906 :
907 : // Wir gehen auf Nummer sicher:
908 : // Wir muessen die alten Fontinformationen wegschmeissen,
909 : // wenn die Druckeraufloesung oder der Zoomfaktor sich aendert.
910 : // Init() und Reformat() sind die sichersten Stellen.
911 : #ifdef FNTMET
912 : aFntMetList.Flush();
913 : #else
914 0 : pFntCache->Flush( );
915 : #endif
916 :
917 0 : if( GetLayout()->IsCallbackActionEnabled() )
918 : {
919 :
920 0 : StartAction();
921 0 : GetLayout()->InvalidateAllCntnt( INV_SIZE | INV_POS | INV_PRTAREA );
922 0 : EndAction();
923 0 : }
924 0 : }
925 :
926 0 : void ViewShell::ChgNumberDigits()
927 : {
928 0 : SdrModel* pTmpDrawModel = getIDocumentDrawModelAccess()->GetDrawModel();
929 0 : if ( pTmpDrawModel )
930 0 : pTmpDrawModel->ReformatAllTextObjects();
931 0 : Reformat();
932 0 : }
933 :
934 :
935 53 : void ViewShell::CalcLayout()
936 : {
937 53 : SET_CURR_SHELL( this );
938 53 : SwWait aWait( *GetDoc()->GetDocShell(), sal_True );
939 :
940 : //Cache vorbereiten und restaurieren, damit er nicht versaut wird.
941 53 : SwSaveSetLRUOfst aSaveLRU( *SwTxtFrm::GetTxtCache(),
942 106 : SwTxtFrm::GetTxtCache()->GetCurMax() - 50 );
943 :
944 : //Progress einschalten wenn noch keiner Lauft.
945 53 : const bool bEndProgress = SfxProgress::GetActiveProgress( GetDoc()->GetDocShell() ) == 0;
946 53 : if ( bEndProgress )
947 : {
948 53 : sal_uInt16 nEndPage = GetLayout()->GetPageNum();
949 53 : nEndPage += nEndPage * 10 / 100;
950 53 : ::StartProgress( STR_STATSTR_REFORMAT, 0, nEndPage, GetDoc()->GetDocShell() );
951 : }
952 :
953 53 : SwLayAction aAction( GetLayout(), Imp() );
954 53 : aAction.SetPaint( sal_False );
955 53 : aAction.SetStatBar( sal_True );
956 53 : aAction.SetCalcLayout( sal_True );
957 53 : aAction.SetReschedule( sal_True );
958 53 : GetDoc()->LockExpFlds();
959 53 : aAction.Action();
960 53 : GetDoc()->UnlockExpFlds();
961 :
962 : //Das SetNewFldLst() am Doc wurde unterbunden und muss nachgeholt
963 : //werden (siehe flowfrm.cxx, txtfld.cxx)
964 53 : if ( aAction.IsExpFlds() )
965 : {
966 0 : aAction.Reset();
967 0 : aAction.SetPaint( sal_False );
968 0 : aAction.SetStatBar( sal_True );
969 0 : aAction.SetReschedule( sal_True );
970 :
971 0 : SwDocPosUpdate aMsgHnt( 0 );
972 0 : GetDoc()->UpdatePageFlds( &aMsgHnt );
973 0 : GetDoc()->UpdateExpFlds(NULL, true);
974 :
975 0 : aAction.Action();
976 : }
977 :
978 53 : if ( VisArea().HasArea() )
979 53 : InvalidateWindows( VisArea() );
980 53 : if ( bEndProgress )
981 53 : ::EndProgress( GetDoc()->GetDocShell() );
982 53 : }
983 :
984 :
985 1080 : void ViewShell::SetFirstVisPageInvalid()
986 : {
987 1080 : ViewShell *pSh = this;
988 1080 : do
989 : {
990 1080 : if ( pSh->Imp() )
991 1080 : pSh->Imp()->SetFirstVisPageInvalid();
992 1080 : pSh = (ViewShell*)pSh->GetNext();
993 :
994 : } while ( pSh != this );
995 1080 : }
996 :
997 :
998 521 : void ViewShell::SizeChgNotify()
999 : {
1000 521 : if ( !pWin )
1001 2 : bDocSizeChgd = sal_True;
1002 519 : else if( ActionPend() || Imp()->IsCalcLayoutProgress() || bPaintInProgress )
1003 : {
1004 16 : bDocSizeChgd = sal_True;
1005 :
1006 16 : if ( !Imp()->IsCalcLayoutProgress() && ISA( SwCrsrShell ) )
1007 : {
1008 16 : const SwFrm *pCnt = ((SwCrsrShell*)this)->GetCurrFrm( sal_False );
1009 : const SwPageFrm *pPage;
1010 16 : if ( pCnt && 0 != (pPage = pCnt->FindPageFrm()) )
1011 : {
1012 16 : sal_uInt16 nVirtNum = pPage->GetVirtPageNum();
1013 16 : const SvxNumberType& rNum = pPage->GetPageDesc()->GetNumType();
1014 16 : String sDisplay = rNum.GetNumStr( nVirtNum );
1015 16 : PageNumNotify( this, pCnt->GetPhyPageNum(), nVirtNum, sDisplay );
1016 : }
1017 : }
1018 : }
1019 : else
1020 : {
1021 503 : bDocSizeChgd = sal_False;
1022 503 : ::SizeNotify( this, GetDocSize() );
1023 : }
1024 521 : }
1025 :
1026 :
1027 527 : void ViewShell::VisPortChgd( const SwRect &rRect)
1028 : {
1029 : OSL_ENSURE( GetWin(), "VisPortChgd ohne Window." );
1030 :
1031 527 : if ( rRect == VisArea() )
1032 : return;
1033 :
1034 : #if OSL_DEBUG_LEVEL > 1
1035 : if ( bInEndAction )
1036 : {
1037 : //Da Rescheduled doch schon wieder irgendwo einer?
1038 : OSL_ENSURE( !this, "Scroll waehrend einer EndAction." );
1039 : }
1040 : #endif
1041 :
1042 : //Ersteinmal die alte sichtbare Seite holen, dann braucht nacher nicht
1043 : //lange gesucht werden.
1044 527 : const SwFrm *pOldPage = Imp()->GetFirstVisPage();
1045 :
1046 527 : const SwRect aPrevArea( VisArea() );
1047 527 : const sal_Bool bFull = aPrevArea.IsEmpty();
1048 527 : aVisArea = rRect;
1049 527 : SetFirstVisPageInvalid();
1050 :
1051 : //Wenn noch eine PaintRegion herumsteht und sich die VisArea geaendert hat,
1052 : //so ist die PaintRegion spaetestens jetzt obsolete. Die PaintRegion kann
1053 : //vom RootFrm::Paint erzeugt worden sein.
1054 1054 : if ( !bInEndAction &&
1055 527 : Imp()->GetRegion() && Imp()->GetRegion()->GetOrigin() != VisArea() )
1056 0 : Imp()->DelRegion();
1057 :
1058 527 : SET_CURR_SHELL( this );
1059 :
1060 527 : bool bScrolled = false;
1061 :
1062 527 : SwPostItMgr* pPostItMgr = GetPostItMgr();
1063 :
1064 527 : if ( bFull )
1065 199 : GetWin()->Invalidate();
1066 : else
1067 : {
1068 : // Betrag ausrechnen, um den gescrolled werden muss.
1069 328 : const long nXDiff = aPrevArea.Left() - VisArea().Left();
1070 328 : const long nYDiff = aPrevArea.Top() - VisArea().Top();
1071 :
1072 976 : if( !nXDiff && !GetViewOptions()->getBrowseMode() &&
1073 648 : (!Imp()->HasDrawView() || !Imp()->GetDrawView()->IsGridVisible() ) )
1074 : {
1075 : //Falls moeglich die Wiese nicht mit Scrollen.
1076 : //Also linke und rechte Kante des Scrollbereiches auf die
1077 : //Seiten begrenzen.
1078 324 : const SwPageFrm *pPage = (SwPageFrm*)GetLayout()->Lower(); //swmod 071108//swmod 071225
1079 324 : if ( pPage->Frm().Top() > pOldPage->Frm().Top() )
1080 0 : pPage = (SwPageFrm*)pOldPage;
1081 324 : SwRect aBoth( VisArea() );
1082 324 : aBoth.Union( aPrevArea );
1083 324 : const SwTwips nBottom = aBoth.Bottom();
1084 324 : SwTwips nMinLeft = LONG_MAX;
1085 324 : SwTwips nMaxRight= 0;
1086 :
1087 324 : const bool bBookMode = GetViewOptions()->IsViewLayoutBookMode();
1088 :
1089 983 : while ( pPage && pPage->Frm().Top() <= nBottom )
1090 : {
1091 335 : SwRect aPageRect( pPage->GetBoundRect() );
1092 335 : if ( bBookMode )
1093 : {
1094 0 : const SwPageFrm& rFormatPage = static_cast<const SwPageFrm*>(pPage)->GetFormatPage();
1095 0 : aPageRect.SSize() = rFormatPage.GetBoundRect().SSize();
1096 : }
1097 :
1098 : // OD 12.02.2003 #i9719#, #105645# - consider new border
1099 : // and shadow width
1100 335 : if ( aPageRect.IsOver( aBoth ) )
1101 : {
1102 335 : SwTwips nPageLeft = 0;
1103 335 : SwTwips nPageRight = 0;
1104 335 : const sw::sidebarwindows::SidebarPosition aSidebarPos = pPage->SidebarPosition();
1105 :
1106 335 : if( aSidebarPos != sw::sidebarwindows::SIDEBAR_NONE )
1107 : {
1108 335 : nPageLeft = aPageRect.Left();
1109 335 : nPageRight = aPageRect.Right();
1110 : }
1111 :
1112 335 : if( nPageLeft < nMinLeft )
1113 324 : nMinLeft = nPageLeft;
1114 335 : if( nPageRight > nMaxRight )
1115 324 : nMaxRight = nPageRight;
1116 : //Zus. auf die Zeichenobjekte abgleichen.
1117 : //Einen Ofst beruecksichtigen, weil die Objekte u.U.
1118 : //selektiert sind und die Henkel dann hinausstehen.
1119 335 : if ( pPage->GetSortedObjs() )
1120 : {
1121 : const long nOfst = GetOut()->PixelToLogic(
1122 46 : Size(Imp()->GetDrawView()->GetMarkHdlSizePixel()/2,0)).Width();
1123 276 : for ( sal_uInt16 i = 0;
1124 138 : i < pPage->GetSortedObjs()->Count(); ++i )
1125 : {
1126 92 : SwAnchoredObject* pObj = (*pPage->GetSortedObjs())[i];
1127 : // ignore objects that are not actually placed on the page
1128 92 : if (pObj->IsFormatPossible())
1129 : {
1130 92 : const Rectangle &rBound = pObj->GetObjRect().SVRect();
1131 : // OD 03.03.2003 #107927# - use correct datatype
1132 92 : const SwTwips nL = Max( 0L, rBound.Left() - nOfst );
1133 92 : if ( nL < nMinLeft )
1134 0 : nMinLeft = nL;
1135 92 : if( rBound.Right() + nOfst > nMaxRight )
1136 0 : nMaxRight = rBound.Right() + nOfst;
1137 : }
1138 : }
1139 : }
1140 : }
1141 335 : pPage = (SwPageFrm*)pPage->GetNext();
1142 : }
1143 324 : Rectangle aRect( aPrevArea.SVRect() );
1144 324 : aRect.Left() = nMinLeft;
1145 324 : aRect.Right() = nMaxRight;
1146 324 : if( VisArea().IsOver( aPrevArea ) && !nLockPaint )
1147 : {
1148 9 : bScrolled = true;
1149 9 : aVisArea.Pos() = aPrevArea.Pos();
1150 9 : if ( SmoothScroll( nXDiff, nYDiff, &aRect ) )
1151 : return;
1152 9 : aVisArea.Pos() = rRect.Pos();
1153 : }
1154 : else
1155 315 : GetWin()->Invalidate( aRect );
1156 : }
1157 4 : else if ( !nLockPaint ) //Wird im UnLock erledigt
1158 : {
1159 4 : if( VisArea().IsOver( aPrevArea ) )
1160 : {
1161 0 : bScrolled = true;
1162 0 : aVisArea.Pos() = aPrevArea.Pos();
1163 0 : if ( SmoothScroll( nXDiff, nYDiff, 0 ) )
1164 : return;
1165 0 : aVisArea.Pos() = rRect.Pos();
1166 : }
1167 : else
1168 4 : GetWin()->Invalidate();
1169 : }
1170 : }
1171 :
1172 527 : Point aPt( VisArea().Pos() );
1173 527 : aPt.X() = -aPt.X(); aPt.Y() = -aPt.Y();
1174 527 : MapMode aMapMode( GetWin()->GetMapMode() );
1175 527 : aMapMode.SetOrigin( aPt );
1176 527 : GetWin()->SetMapMode( aMapMode );
1177 527 : if ( HasDrawView() )
1178 : {
1179 527 : Imp()->GetDrawView()->VisAreaChanged( GetWin() );
1180 527 : Imp()->GetDrawView()->SetActualWin( GetWin() );
1181 : }
1182 527 : GetWin()->Update();
1183 :
1184 : // --> OD 2010-02-11 #i88070#
1185 527 : if ( pPostItMgr )
1186 : {
1187 527 : pPostItMgr->Rescale();
1188 527 : pPostItMgr->CalcRects();
1189 527 : pPostItMgr->LayoutPostIts();
1190 : }
1191 : // <--
1192 :
1193 527 : if ( !bScrolled && pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
1194 14 : pPostItMgr->CorrectPositions();
1195 :
1196 527 : if( Imp()->IsAccessible() )
1197 0 : Imp()->UpdateAccessible();
1198 :
1199 : }
1200 :
1201 :
1202 9 : sal_Bool ViewShell::SmoothScroll( long lXDiff, long lYDiff, const Rectangle *pRect )
1203 : {
1204 9 : const sal_uLong nColCnt = pOut->GetColorCount();
1205 9 : long lMult = 1, lMax = LONG_MAX;
1206 9 : if ( nColCnt == 65536 )
1207 : {
1208 0 : lMax = 7000;
1209 0 : lMult = 2;
1210 : }
1211 9 : if ( nColCnt == 16777216 )
1212 : {
1213 9 : lMax = 5000;
1214 9 : lMult = 6;
1215 : }
1216 0 : else if ( nColCnt == 1 )
1217 : {
1218 0 : lMax = 3000;
1219 0 : lMult = 12;
1220 : }
1221 :
1222 : // #i75172# isolated static conditions
1223 9 : const bool bOnlyYScroll(!lXDiff && Abs(lYDiff) != 0 && Abs(lYDiff) < lMax);
1224 9 : const bool bAllowedWithChildWindows(GetWin()->GetWindowClipRegionPixel(WINDOW_GETCLIPREGION_NOCHILDREN|WINDOW_GETCLIPREGION_NULL).IsNull());
1225 : // --> OD 2009-08-12 #i98766# - disable smooth scrolling for Mac port builds
1226 : #ifdef QUARTZ
1227 : const bool bSmoothScrollAllowed(false);
1228 : (void) bOnlyYScroll;
1229 : (void) bAllowedWithChildWindows;
1230 : #else
1231 9 : const bool bSmoothScrollAllowed(bOnlyYScroll && bEnableSmooth && GetViewOptions()->IsSmoothScroll() && bAllowedWithChildWindows);
1232 : #endif
1233 : // <-
1234 9 : const bool bIAmCursorShell(ISA(SwCrsrShell));
1235 : (void) bIAmCursorShell;
1236 :
1237 : // #i75172# with selection on overlay, smooth scroll should be allowed with it
1238 9 : const bool bAllowedForSelection(true || (bIAmCursorShell && !((SwCrsrShell*)this)->HasSelection()));
1239 :
1240 : // #i75172# with cursors on overlay, smooth scroll should be allowed with it
1241 9 : const bool bAllowedForMultipleCursors(true || (bIAmCursorShell && ((SwCrsrShell*)this)->GetCrsrCnt() < 2));
1242 :
1243 9 : if(bSmoothScrollAllowed && bAllowedForSelection && bAllowedForMultipleCursors)
1244 : {
1245 0 : Imp()->bStopSmooth = sal_False;
1246 :
1247 0 : const SwRect aOldVis( VisArea() );
1248 :
1249 : //Virtuelles Device erzeugen und einstellen.
1250 0 : const Size aPixSz = GetWin()->PixelToLogic(Size(1,1));
1251 0 : VirtualDevice *pVout = new VirtualDevice( *GetWin() );
1252 0 : pVout->SetLineColor( GetWin()->GetLineColor() );
1253 0 : pVout->SetFillColor( GetWin()->GetFillColor() );
1254 0 : MapMode aMapMode( GetWin()->GetMapMode() );
1255 0 : pVout->SetMapMode( aMapMode );
1256 0 : Size aSize( aVisArea.Width()+2*aPixSz.Width(), Abs(lYDiff)+(2*aPixSz.Height()) );
1257 0 : if ( pRect )
1258 0 : aSize.Width() = Min(aSize.Width(), pRect->GetWidth()+2*aPixSz.Width());
1259 0 : if ( pVout->SetOutputSize( aSize ) )
1260 : {
1261 0 : nLockPaint++;
1262 :
1263 : //Ersteinmal alles neue in das VirDev Painten.
1264 0 : SwRect aRect( VisArea() );
1265 0 : aRect.Height( aSize.Height() );
1266 0 : if ( pRect )
1267 : {
1268 0 : aRect.Pos().X() = Max(aRect.Left(),pRect->Left()-aPixSz.Width());
1269 0 : aRect.Right( Min(aRect.Right()+2*aPixSz.Width(), pRect->Right()+aPixSz.Width()));
1270 : }
1271 : else
1272 0 : aRect.SSize().Width() += 2*aPixSz.Width();
1273 0 : aRect.Pos().Y() = lYDiff < 0 ? aOldVis.Bottom() - aPixSz.Height()
1274 0 : : aRect.Top() - aSize.Height() + aPixSz.Height();
1275 0 : aRect.Pos().X() = Max( 0L, aRect.Left()-aPixSz.Width() );
1276 0 : aRect.Pos() = GetWin()->PixelToLogic( GetWin()->LogicToPixel( aRect.Pos()));
1277 0 : aRect.SSize()= GetWin()->PixelToLogic( GetWin()->LogicToPixel( aRect.SSize()));
1278 0 : aVisArea = aRect;
1279 0 : const Point aPt( -aRect.Left(), -aRect.Top() );
1280 0 : aMapMode.SetOrigin( aPt );
1281 0 : pVout->SetMapMode( aMapMode );
1282 0 : OutputDevice *pOld = pOut;
1283 0 : pOut = pVout;
1284 :
1285 : {
1286 : // #i75172# To get a clean repaint, a new ObjectContact is needed here. Without, the
1287 : // repaint would not be correct since it would use the wrong DrawPage visible region.
1288 : // This repaint IS about painting something currently outside the visible part (!).
1289 : // For that purpose, AddWindowToPaintView is used which creates a new SdrPageViewWindow
1290 : // and all the necessary stuff. It's not cheap, but necessary here. Alone because repaint
1291 : // target really is NOT the current window.
1292 : // Also will automatically NOT use PreRendering and overlay (since target is VirtualDevice)
1293 0 : if(!HasDrawView())
1294 0 : MakeDrawView();
1295 0 : SdrView* pDrawView = GetDrawView();
1296 0 : pDrawView->AddWindowToPaintView(pVout);
1297 :
1298 : // clear pWin during DLPrePaint2 to get paint preparation for pOut, but set it again
1299 : // immediately afterwards. There are many decisions in SW which imply that Printing
1300 : // is used when pWin == 0 (wrong but widely used).
1301 0 : Window* pOldWin = pWin;
1302 0 : pWin = 0;
1303 0 : DLPrePaint2(Region(aRect.SVRect()));
1304 0 : pWin = pOldWin;
1305 :
1306 : // SW paint stuff
1307 0 : PaintDesktop( aRect );
1308 0 : ViewShell::bLstAct = sal_True;
1309 0 : GetLayout()->Paint( aRect );
1310 0 : ViewShell::bLstAct = sal_False;
1311 :
1312 : // end paint and destroy ObjectContact again
1313 0 : DLPostPaint2(true);
1314 0 : pDrawView->DeleteWindowFromPaintView(pVout);
1315 : }
1316 :
1317 0 : pOut = pOld;
1318 0 : aVisArea = aOldVis;
1319 :
1320 : //Jetzt Stueckchenweise schieben und die neuen Pixel aus dem
1321 : //VirDev kopieren.
1322 :
1323 : // ??????????????????????
1324 : // or is it better to get the scrollfactor from the User
1325 : // as option?
1326 : // ??????????????????????
1327 0 : long lMaDelta = aPixSz.Height();
1328 0 : if ( Abs(lYDiff) > ( aVisArea.Height() / 3 ) )
1329 0 : lMaDelta *= 6;
1330 : else
1331 0 : lMaDelta *= 2;
1332 :
1333 0 : lMaDelta *= lMult;
1334 :
1335 0 : if ( lYDiff < 0 )
1336 0 : lMaDelta = -lMaDelta;
1337 :
1338 0 : long lDiff = lYDiff;
1339 0 : while ( lDiff )
1340 : {
1341 : long lScroll;
1342 0 : if ( Imp()->bStopSmooth || Abs(lDiff) <= Abs(lMaDelta) )
1343 : {
1344 0 : lScroll = lDiff;
1345 0 : lDiff = 0;
1346 : }
1347 : else
1348 : {
1349 0 : lScroll = lMaDelta;
1350 0 : lDiff -= lMaDelta;
1351 : }
1352 :
1353 0 : const SwRect aTmpOldVis = VisArea();
1354 0 : aVisArea.Pos().Y() -= lScroll;
1355 0 : aVisArea.Pos() = GetWin()->PixelToLogic( GetWin()->LogicToPixel( VisArea().Pos()));
1356 0 : lScroll = aTmpOldVis.Top() - VisArea().Top();
1357 0 : if ( pRect )
1358 : {
1359 0 : Rectangle aTmp( aTmpOldVis.SVRect() );
1360 0 : aTmp.Left() = pRect->Left();
1361 0 : aTmp.Right()= pRect->Right();
1362 0 : GetWin()->Scroll( 0, lScroll, aTmp, SCROLL_CHILDREN);
1363 : }
1364 : else
1365 0 : GetWin()->Scroll( 0, lScroll, SCROLL_CHILDREN );
1366 :
1367 0 : const Point aTmpPt( -VisArea().Left(), -VisArea().Top() );
1368 0 : MapMode aTmpMapMode( GetWin()->GetMapMode() );
1369 0 : aTmpMapMode.SetOrigin( aTmpPt );
1370 0 : GetWin()->SetMapMode( aTmpMapMode );
1371 :
1372 0 : if ( Imp()->HasDrawView() )
1373 0 : Imp()->GetDrawView()->VisAreaChanged( GetWin() );
1374 :
1375 0 : SetFirstVisPageInvalid();
1376 0 : if ( !Imp()->bStopSmooth )
1377 : {
1378 0 : const bool bScrollDirectionIsUp(lScroll > 0);
1379 0 : Imp()->aSmoothRect = VisArea();
1380 :
1381 0 : if(bScrollDirectionIsUp)
1382 : {
1383 0 : Imp()->aSmoothRect.Bottom( VisArea().Top() + lScroll + aPixSz.Height());
1384 : }
1385 : else
1386 : {
1387 0 : Imp()->aSmoothRect.Top( VisArea().Bottom() + lScroll - aPixSz.Height());
1388 : }
1389 :
1390 0 : Imp()->bSmoothUpdate = sal_True;
1391 0 : GetWin()->Update();
1392 0 : Imp()->bSmoothUpdate = sal_False;
1393 :
1394 0 : if(!Imp()->bStopSmooth)
1395 : {
1396 : // start paint on logic base
1397 0 : const Rectangle aTargetLogic(Imp()->aSmoothRect.SVRect());
1398 0 : DLPrePaint2(Region(aTargetLogic));
1399 :
1400 : // get target rectangle in discrete pixels
1401 0 : OutputDevice& rTargetDevice = mpTargetPaintWindow->GetTargetOutputDevice();
1402 0 : const Rectangle aTargetPixel(rTargetDevice.LogicToPixel(aTargetLogic));
1403 :
1404 : // get source top-left in discrete pixels
1405 0 : const Point aSourceTopLeft(pVout->LogicToPixel(aTargetLogic.TopLeft()));
1406 :
1407 : // switch off MapModes
1408 0 : const bool bMapModeWasEnabledDest(rTargetDevice.IsMapModeEnabled());
1409 0 : const bool bMapModeWasEnabledSource(pVout->IsMapModeEnabled());
1410 0 : rTargetDevice.EnableMapMode(false);
1411 0 : pVout->EnableMapMode(false);
1412 :
1413 : rTargetDevice.DrawOutDev(
1414 : aTargetPixel.TopLeft(), aTargetPixel.GetSize(), // dest
1415 : aSourceTopLeft, aTargetPixel.GetSize(), // source
1416 0 : *pVout);
1417 :
1418 : // restore MapModes
1419 0 : rTargetDevice.EnableMapMode(bMapModeWasEnabledDest);
1420 0 : pVout->EnableMapMode(bMapModeWasEnabledSource);
1421 :
1422 : // end paint on logoc base
1423 0 : DLPostPaint2(true);
1424 : }
1425 : else
1426 0 : --nLockPaint;
1427 : }
1428 0 : }
1429 0 : delete pVout;
1430 0 : GetWin()->Update();
1431 0 : if ( !Imp()->bStopSmooth )
1432 0 : --nLockPaint;
1433 0 : SetFirstVisPageInvalid();
1434 0 : return sal_True;
1435 : }
1436 0 : delete pVout;
1437 : }
1438 :
1439 9 : aVisArea.Pos().X() -= lXDiff;
1440 9 : aVisArea.Pos().Y() -= lYDiff;
1441 9 : if ( pRect )
1442 9 : GetWin()->Scroll( lXDiff, lYDiff, *pRect, SCROLL_CHILDREN);
1443 : else
1444 0 : GetWin()->Scroll( lXDiff, lYDiff, SCROLL_CHILDREN);
1445 9 : return sal_False;
1446 : }
1447 :
1448 :
1449 260 : void ViewShell::PaintDesktop( const SwRect &rRect )
1450 : {
1451 260 : if ( !GetWin() && !GetOut()->GetConnectMetaFile() )
1452 260 : return; //Fuer den Drucker tun wir hier nix
1453 :
1454 : //Sonderfaelle abfangen, damit es nicht gar so ueberraschend aussieht.
1455 : //Kann z.B. waehrend des Idle'ns zwischenzeitlich auftreten.
1456 : //Die Rechtecke neben den Seiten muessen wir leider auf jedenfall Painten,
1457 : //den diese werden spaeter beim VisPortChgd ausgespart.
1458 260 : bool bBorderOnly = false;
1459 260 : const SwRootFrm *pRoot = GetLayout();//swmod 080305
1460 260 : if ( rRect.Top() > pRoot->Frm().Bottom() )
1461 : {
1462 0 : const SwFrm *pPg = pRoot->Lower();
1463 0 : while ( pPg && pPg->GetNext() )
1464 0 : pPg = pPg->GetNext();
1465 0 : if ( !pPg || !pPg->Frm().IsOver( VisArea() ) )
1466 0 : bBorderOnly = true;
1467 : }
1468 :
1469 260 : const bool bBookMode = GetViewOptions()->IsViewLayoutBookMode();
1470 :
1471 260 : SwRegionRects aRegion( rRect );
1472 :
1473 : //mod #i6193: remove sidebar area to avoid flickering
1474 260 : const SwPostItMgr* pPostItMgr = GetPostItMgr();
1475 266 : const SwTwips nSidebarWidth = pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() ?
1476 6 : pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth() :
1477 532 : 0;
1478 :
1479 260 : if ( bBorderOnly )
1480 : {
1481 0 : const SwFrm *pPage =pRoot->Lower(); //swmod 071108//swmod 071225
1482 0 : SwRect aLeft( rRect ), aRight( rRect );
1483 0 : while ( pPage )
1484 : {
1485 0 : long nTmp = pPage->Frm().Left();
1486 0 : if ( nTmp < aLeft.Right() )
1487 0 : aLeft.Right( nTmp );
1488 0 : nTmp = pPage->Frm().Right();
1489 0 : if ( nTmp > aRight.Left() )
1490 : {
1491 0 : aRight.Left( nTmp + nSidebarWidth );
1492 : }
1493 0 : pPage = pPage->GetNext();
1494 : }
1495 0 : aRegion.clear();
1496 0 : if ( aLeft.HasArea() )
1497 0 : aRegion.push_back( aLeft );
1498 0 : if ( aRight.HasArea() )
1499 0 : aRegion.push_back( aRight );
1500 : }
1501 : else
1502 : {
1503 260 : const SwFrm *pPage = Imp()->GetFirstVisPage();
1504 260 : const SwTwips nBottom = rRect.Bottom();
1505 : //const SwTwips nRight = rRect.Right();
1506 1058 : while ( pPage && !aRegion.empty() &&
1507 275 : (pPage->Frm().Top() <= nBottom) ) // PAGES01 && (pPage->Frm().Left() <= nRight))
1508 : {
1509 263 : SwRect aPageRect( pPage->Frm() );
1510 263 : if ( bBookMode )
1511 : {
1512 0 : const SwPageFrm& rFormatPage = static_cast<const SwPageFrm*>(pPage)->GetFormatPage();
1513 0 : aPageRect.SSize() = rFormatPage.Frm().SSize();
1514 : }
1515 :
1516 : const bool bSidebarRight =
1517 263 : static_cast<const SwPageFrm*>(pPage)->SidebarPosition() == sw::sidebarwindows::SIDEBAR_RIGHT;
1518 263 : aPageRect.Pos().X() -= bSidebarRight ? 0 : nSidebarWidth;
1519 263 : aPageRect.SSize().Width() += nSidebarWidth;
1520 :
1521 263 : if ( aPageRect.IsOver( rRect ) )
1522 263 : aRegion -= aPageRect;
1523 :
1524 263 : pPage = pPage->GetNext();
1525 : }
1526 : }
1527 260 : if ( !aRegion.empty() )
1528 260 : _PaintDesktop( aRegion );
1529 : }
1530 :
1531 :
1532 : // PaintDesktop gesplittet, dieser Teil wird auch von PreViewPage benutzt
1533 260 : void ViewShell::_PaintDesktop( const SwRegionRects &rRegion )
1534 : {
1535 : // OD 2004-04-23 #116347#
1536 260 : GetOut()->Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
1537 260 : GetOut()->SetLineColor();
1538 :
1539 784 : for ( sal_uInt16 i = 0; i < rRegion.size(); ++i )
1540 : {
1541 524 : const Rectangle aRectangle(rRegion[i].SVRect());
1542 :
1543 : // #i93170#
1544 : // Here we have a real Problem. On the one hand we have the buffering for paint
1545 : // and overlay which needs an embracing pair of DLPrePaint2/DLPostPaint2 calls,
1546 : // on the other hand the MapMode is not set correctly when this code is executed.
1547 : // This is done in the users of this method, for each SWpage before painting it.
1548 : // Since the MapMode is not correct here, the call to DLPostPaint2 will paint
1549 : // existing FormControls due to the current MapMode.
1550 : //
1551 : // There are basically three solutions for this:
1552 : //
1553 : // (1) Set the MapMode correct, move the background painting to the users of
1554 : // this code
1555 : //
1556 : // (2) Do no DLPrePaint2/DLPostPaint2 here; no SdrObjects are allowed to lie in
1557 : // the desktop region. Disadvantage: the desktop will not be part of the
1558 : // buffers, e.g. overlay. Thus, as soon as overlay will be used over the
1559 : // desktop, it will not work.
1560 : //
1561 : // (3) expand DLPostPaint2 with a flag to signal if FormControl paints shall
1562 : // be done or not
1563 : //
1564 : // Currently, (3) will be the best possible solution. It will keep overlay and
1565 : // buffering intact and work without MapMode for single pages. In the medium
1566 : // to long run, (1) will need to be used and the bool bPaintFormLayer needs
1567 : // to be removed again
1568 :
1569 : // #i68597# inform Drawinglayer about display change
1570 524 : DLPrePaint2(Region(aRectangle));
1571 :
1572 : // #i75172# needed to move line/Fill color setters into loop since DLPrePaint2
1573 : // may exchange GetOut(), that's it's purpose. This happens e.g. at print preview.
1574 524 : GetOut()->SetFillColor( SwViewOption::GetAppBackgroundColor());
1575 524 : GetOut()->SetLineColor();
1576 524 : GetOut()->DrawRect(aRectangle);
1577 :
1578 524 : DLPostPaint2(false);
1579 : }
1580 :
1581 260 : GetOut()->Pop();
1582 260 : }
1583 :
1584 :
1585 242 : sal_Bool ViewShell::CheckInvalidForPaint( const SwRect &rRect )
1586 : {
1587 242 : if ( !GetWin() )
1588 0 : return sal_False;
1589 :
1590 242 : const SwPageFrm *pPage = Imp()->GetFirstVisPage();
1591 242 : const SwTwips nBottom = VisArea().Bottom();
1592 242 : const SwTwips nRight = VisArea().Right();
1593 242 : sal_Bool bRet = sal_False;
1594 968 : while ( !bRet && pPage && !((pPage->Frm().Top() > nBottom) ||
1595 242 : (pPage->Frm().Left() > nRight)))
1596 : {
1597 242 : if ( pPage->IsInvalid() || pPage->IsInvalidFly() )
1598 1 : bRet = sal_True;
1599 242 : pPage = (SwPageFrm*)pPage->GetNext();
1600 : }
1601 :
1602 242 : if ( bRet )
1603 : {
1604 : //Start/EndAction wuerden hier leider nix helfen, weil das Paint vom
1605 : //GUI 'reinkam und somit ein Clipping gesetzt ist gegen das wir nicht
1606 : //nicht ankommen.
1607 : //Ergo: Alles selbst machen (siehe ImplEndAction())
1608 1 : if ( Imp()->GetRegion() && Imp()->GetRegion()->GetOrigin() != VisArea())
1609 0 : Imp()->DelRegion();
1610 :
1611 1 : SwLayAction aAction( GetLayout(), Imp() );
1612 1 : aAction.SetComplete( sal_False );
1613 : // We increment the action counter to avoid a recursive call of actions
1614 : // e.g. from a SwFEShell::RequestObjectResize(..) in bug 95829.
1615 : // A recursive call of actions is no good idea because the inner action
1616 : // can't format frames which are locked by the outer action. This may
1617 : // cause and endless loop.
1618 1 : ++nStartAction;
1619 1 : aAction.Action();
1620 1 : --nStartAction;
1621 :
1622 1 : SwRegionRects *pRegion = Imp()->GetRegion();
1623 1 : if ( pRegion && aAction.IsBrowseActionStop() )
1624 : {
1625 : //Nur dann interessant, wenn sich im sichtbaren Bereich etwas
1626 : //veraendert hat.
1627 0 : sal_Bool bStop = sal_True;
1628 0 : for ( sal_uInt16 i = 0; i < pRegion->size(); ++i )
1629 : {
1630 0 : const SwRect &rTmp = (*pRegion)[i];
1631 0 : if ( sal_False == (bStop = rTmp.IsOver( VisArea() )) )
1632 0 : break;
1633 : }
1634 0 : if ( bStop )
1635 : {
1636 0 : Imp()->DelRegion();
1637 0 : pRegion = 0;
1638 : }
1639 : }
1640 :
1641 1 : if ( pRegion )
1642 : {
1643 : //Erst Invert dann Compress, niemals andersherum!
1644 1 : pRegion->Invert();
1645 1 : pRegion->Compress();
1646 1 : bRet = sal_False;
1647 1 : if ( !pRegion->empty() )
1648 : {
1649 1 : SwRegionRects aRegion( rRect );
1650 2 : for ( sal_uInt16 i = 0; i < pRegion->size(); ++i )
1651 1 : { const SwRect &rTmp = (*pRegion)[i];
1652 1 : if ( !rRect.IsInside( rTmp ) )
1653 : {
1654 0 : InvalidateWindows( rTmp );
1655 0 : if ( rTmp.IsOver( VisArea() ) )
1656 0 : { aRegion -= rTmp;
1657 0 : bRet = sal_True;
1658 : }
1659 : }
1660 : }
1661 1 : if ( bRet )
1662 : {
1663 0 : for ( sal_uInt16 i = 0; i < aRegion.size(); ++i )
1664 0 : GetWin()->Invalidate( aRegion[i].SVRect() );
1665 :
1666 0 : if ( rRect != VisArea() )
1667 : {
1668 : //rRect == VisArea ist der spezialfall fuer neu bzw.
1669 : //Shift-Ctrl-R, dafuer sollte es nicht notwendig sein
1670 : //das Rechteck nocheinmal in Dokumentkoordinaten v
1671 : //vorzuhalten.
1672 0 : if ( aInvalidRect.IsEmpty() )
1673 0 : aInvalidRect = rRect;
1674 : else
1675 0 : aInvalidRect.Union( rRect );
1676 : }
1677 1 : }
1678 : }
1679 : else
1680 0 : bRet = sal_False;
1681 1 : Imp()->DelRegion();
1682 : }
1683 : else
1684 0 : bRet = sal_False;
1685 : }
1686 242 : return bRet;
1687 : }
1688 :
1689 :
1690 282 : void ViewShell::Paint(const Rectangle &rRect)
1691 : {
1692 282 : if ( nLockPaint )
1693 : {
1694 0 : if ( Imp()->bSmoothUpdate )
1695 : {
1696 0 : SwRect aTmp( rRect );
1697 0 : if ( !Imp()->aSmoothRect.IsInside( aTmp ) )
1698 0 : Imp()->bStopSmooth = sal_True;
1699 : else
1700 : {
1701 0 : Imp()->aSmoothRect = aTmp;
1702 : return;
1703 : }
1704 : }
1705 : else
1706 0 : return;
1707 : }
1708 :
1709 282 : if ( SwRootFrm::IsInPaint() )
1710 : {
1711 : //Waehrend der Ausgabe einer Seite beim Druckvorgang wird das
1712 : //Paint gepuffert.
1713 0 : SwPaintQueue::Add( this, SwRect( rRect ) );
1714 0 : return;
1715 : }
1716 :
1717 : // mit !nStartAction versuche ich mal mich gegen
1718 : //fehlerhaften Code an anderen Stellen zu wehren. Hoffentlich fuehrt das
1719 : //nicht zu Problemen!?
1720 282 : if ( bPaintWorks && !nStartAction )
1721 : {
1722 242 : if( GetWin() && GetWin()->IsVisible() )
1723 : {
1724 242 : SwRect aRect( rRect );
1725 242 : if ( bPaintInProgress ) //Schutz gegen doppelte Paints!
1726 : {
1727 0 : GetWin()->Invalidate( rRect );
1728 : return;
1729 : }
1730 :
1731 242 : bPaintInProgress = sal_True;
1732 242 : SET_CURR_SHELL( this );
1733 242 : SwRootFrm::SetNoVirDev( sal_True );
1734 :
1735 : //Wir wollen nicht staendig hin und her Clippen, wir verlassen
1736 : //uns darauf, das sich alle auf das Rechteck beschraeken und
1737 : //brauchen das Clipping hier nur einmalig einkalkulieren. Das
1738 : //ClipRect wird hier einmal entfernt und nicht Restauriert, denn
1739 : //von aussen braucht es sowieso keiner mehr.
1740 : //Nicht wenn wir ein MetaFile aufzeichnen.
1741 242 : if( !GetOut()->GetConnectMetaFile() && GetOut()->IsClipRegion())
1742 0 : GetOut()->SetClipRegion();
1743 :
1744 242 : if ( IsPreView() )
1745 : {
1746 : //Falls sinnvoll gleich das alte InvalidRect verarbeiten bzw.
1747 : //vernichten.
1748 0 : if ( aRect.IsInside( aInvalidRect ) )
1749 0 : ResetInvalidRect();
1750 0 : ViewShell::bLstAct = sal_True;
1751 0 : GetLayout()->Paint( aRect );
1752 0 : ViewShell::bLstAct = sal_False;
1753 : }
1754 : else
1755 : {
1756 : //SwSaveHdl *pSaveHdl = 0;
1757 : //if ( Imp()->HasDrawView() )
1758 : // pSaveHdl = new SwSaveHdl( Imp() );
1759 :
1760 : //Wenn eine der sichtbaren Seiten noch irgendetwas zum Repaint
1761 : //angemeldet hat, so muessen Repaints ausgeloest werden.
1762 242 : if ( !CheckInvalidForPaint( aRect ) )
1763 : {
1764 : // --> OD 2009-08-12 #i101192#
1765 : // start Pre/PostPaint encapsulation to avoid screen blinking
1766 242 : const Region aRepaintRegion(aRect.SVRect());
1767 242 : DLPrePaint2(aRepaintRegion);
1768 :
1769 : // <--
1770 242 : PaintDesktop( aRect );
1771 :
1772 : //Falls sinnvoll gleich das alte InvalidRect verarbeiten bzw.
1773 : //vernichten.
1774 242 : if ( aRect.IsInside( aInvalidRect ) )
1775 241 : ResetInvalidRect();
1776 242 : ViewShell::bLstAct = sal_True;
1777 242 : GetLayout()->Paint( aRect );
1778 242 : ViewShell::bLstAct = sal_False;
1779 : // --> OD 2009-08-12 #i101192#
1780 : // end Pre/PostPaint encapsulation
1781 242 : DLPostPaint2(true);
1782 : // <--
1783 : }
1784 : //delete pSaveHdl;
1785 : }
1786 242 : SwRootFrm::SetNoVirDev( sal_False );
1787 242 : bPaintInProgress = sal_False;
1788 242 : UISizeNotify();
1789 242 : }
1790 : }
1791 : else
1792 : {
1793 40 : if ( aInvalidRect.IsEmpty() )
1794 21 : aInvalidRect = SwRect( rRect );
1795 : else
1796 19 : aInvalidRect.Union( SwRect( rRect ) );
1797 :
1798 40 : if ( bInEndAction && GetWin() )
1799 : {
1800 18 : Region aRegion( GetWin()->GetPaintRegion() );
1801 18 : RegionHandle hHdl( aRegion.BeginEnumRects() );
1802 18 : Rectangle aRect;
1803 54 : while ( aRegion.GetNextEnumRect( hHdl, aRect ) )
1804 18 : Imp()->AddPaintRect( aRect );
1805 18 : aRegion.EndEnumRects( hHdl );
1806 : }
1807 22 : else if ( SfxProgress::GetActiveProgress( GetDoc()->GetDocShell() ) &&
1808 0 : GetOut() == GetWin() )
1809 : {
1810 : // #i68597#
1811 0 : const Region aDLRegion(rRect);
1812 0 : DLPrePaint2(aDLRegion);
1813 :
1814 0 : pOut->Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
1815 0 : pOut->SetFillColor( Imp()->GetRetoucheColor() );
1816 0 : pOut->SetLineColor();
1817 0 : pOut->DrawRect( rRect );
1818 0 : pOut->Pop();
1819 : // #i68597#
1820 0 : DLPostPaint2(true);
1821 : }
1822 : }
1823 : }
1824 :
1825 :
1826 236 : void ViewShell::SetBrowseBorder( const Size& rNew )
1827 : {
1828 236 : if( rNew != aBrowseBorder )
1829 : {
1830 236 : aBrowseBorder = rNew;
1831 236 : if ( aVisArea.HasArea() )
1832 0 : CheckBrowseView( sal_False );
1833 : }
1834 236 : }
1835 :
1836 0 : const Size& ViewShell::GetBrowseBorder() const
1837 : {
1838 0 : return aBrowseBorder;
1839 : }
1840 :
1841 0 : sal_Int32 ViewShell::GetBrowseWidth() const
1842 : {
1843 0 : const SwPostItMgr* pPostItMgr = GetPostItMgr();
1844 0 : if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
1845 : {
1846 0 : Size aBorder( aBrowseBorder );
1847 0 : aBorder.Width() += aBrowseBorder.Width();
1848 0 : aBorder.Width() += pPostItMgr->GetSidebarWidth(true) + pPostItMgr->GetSidebarBorderWidth(true);
1849 0 : return aVisArea.Width() - GetOut()->PixelToLogic(aBorder).Width();
1850 : }
1851 : else
1852 0 : return aVisArea.Width() - 2 * GetOut()->PixelToLogic(aBrowseBorder).Width();
1853 : }
1854 :
1855 :
1856 489 : void ViewShell::CheckBrowseView( sal_Bool bBrowseChgd )
1857 : {
1858 489 : if ( !bBrowseChgd && !GetViewOptions()->getBrowseMode() )
1859 : return;
1860 :
1861 0 : SET_CURR_SHELL( this );
1862 :
1863 : OSL_ENSURE( GetLayout(), "Layout not ready" );
1864 :
1865 : // Wenn das Layout noch nicht einmal eine Hoehe hat,
1866 : // ist sowieso nichts formatiert.
1867 : // Dann eruebrigt sich die Invalidierung
1868 : // Falsch, z.B. beim Anlegen einer neuen View wird der Inhalt eingef?gt
1869 : // und formatiert (trotz einer leeren VisArea). Hier muessen deshalb
1870 : // die Seiten zur Formatierung angeregt werden.
1871 0 : if( !GetLayout()->Frm().Height() )
1872 : {
1873 0 : SwFrm* pPage = GetLayout()->Lower();
1874 0 : while( pPage )
1875 : {
1876 0 : pPage->_InvalidateSize();
1877 0 : pPage = pPage->GetNext();
1878 : }
1879 : return;
1880 : }
1881 :
1882 0 : LockPaint();
1883 0 : StartAction();
1884 :
1885 0 : SwPageFrm *pPg = (SwPageFrm*)GetLayout()->Lower();
1886 0 : do
1887 0 : { pPg->InvalidateSize();
1888 0 : pPg->_InvalidatePrt();
1889 0 : pPg->InvaPercentLowers();
1890 0 : if ( bBrowseChgd )
1891 : {
1892 0 : pPg->PrepareHeader();
1893 0 : pPg->PrepareFooter();
1894 : }
1895 0 : pPg = (SwPageFrm*)pPg->GetNext();
1896 : } while ( pPg );
1897 :
1898 : // Wenn sich die Groessenverhaeltnise im BrowseModus aendern,
1899 : // muss die Position und PrtArea der Cntnt- und Tab-Frames invalidiert werden.
1900 0 : sal_uInt8 nInv = INV_PRTAREA | INV_TABLE | INV_POS;
1901 : // Beim BrowseModus-Wechsel benoetigen die CntntFrms
1902 : // wg. der Drucker/Bildschirmformatierung eine Size-Invalidierung
1903 0 : if( bBrowseChgd )
1904 0 : nInv |= INV_SIZE | INV_DIRECTION;
1905 :
1906 0 : GetLayout()->InvalidateAllCntnt( nInv );
1907 :
1908 0 : SwFrm::CheckPageDescs( (SwPageFrm*)GetLayout()->Lower() );
1909 :
1910 0 : EndAction();
1911 0 : UnlockPaint();
1912 : }
1913 :
1914 :
1915 57390 : SwRootFrm *ViewShell::GetLayout() const
1916 : {
1917 57390 : return pLayout.get(); //swmod 080116
1918 : }
1919 : /***********************************************************************/
1920 :
1921 20518 : OutputDevice& ViewShell::GetRefDev() const
1922 : {
1923 20518 : OutputDevice* pTmpOut = 0;
1924 41009 : if ( GetWin() &&
1925 20491 : GetViewOptions()->getBrowseMode() &&
1926 0 : !GetViewOptions()->IsPrtFormat() )
1927 0 : pTmpOut = GetWin();
1928 20518 : else if ( 0 != mpTmpRef )
1929 0 : pTmpOut = mpTmpRef;
1930 : else
1931 20518 : pTmpOut = GetDoc()->getReferenceDevice( true );
1932 :
1933 20518 : return *pTmpOut;
1934 : }
1935 :
1936 0 : const SwNodes& ViewShell::GetNodes() const
1937 : {
1938 0 : return pDoc->GetNodes();
1939 : }
1940 :
1941 :
1942 238 : void ViewShell::DrawSelChanged()
1943 : {
1944 238 : }
1945 :
1946 :
1947 5062 : Size ViewShell::GetDocSize() const
1948 : {
1949 5062 : Size aSz;
1950 5062 : const SwRootFrm* pRoot = GetLayout();
1951 5062 : if( pRoot )
1952 5062 : aSz = pRoot->Frm().SSize();
1953 :
1954 5062 : return aSz;
1955 : }
1956 :
1957 :
1958 498 : SfxItemPool& ViewShell::GetAttrPool()
1959 : {
1960 498 : return GetDoc()->GetAttrPool();
1961 : }
1962 :
1963 :
1964 33 : void ViewShell::ApplyViewOptions( const SwViewOption &rOpt )
1965 : {
1966 :
1967 33 : ViewShell *pSh = this;
1968 33 : do
1969 33 : { pSh->StartAction();
1970 33 : pSh = (ViewShell*)pSh->GetNext();
1971 : } while ( pSh != this );
1972 :
1973 33 : ImplApplyViewOptions( rOpt );
1974 :
1975 : // With one layout per view it is not longer necessary
1976 : // to sync these "layout related" view options
1977 : // But as long as we have to disable "multiple layout"
1978 33 : pSh = (ViewShell*)this->GetNext();
1979 66 : while ( pSh != this )
1980 : {
1981 0 : SwViewOption aOpt( *pSh->GetViewOptions() );
1982 0 : aOpt.SetFldName( rOpt.IsFldName() );
1983 0 : aOpt.SetShowHiddenField( rOpt.IsShowHiddenField() );
1984 0 : aOpt.SetShowHiddenPara( rOpt.IsShowHiddenPara() );
1985 0 : aOpt.SetShowHiddenChar( rOpt.IsShowHiddenChar() );
1986 0 : aOpt.SetViewLayoutBookMode( rOpt.IsViewLayoutBookMode() );
1987 0 : aOpt.SetViewLayoutColumns( rOpt.GetViewLayoutColumns() );
1988 0 : aOpt.SetPostIts(rOpt.IsPostIts());
1989 0 : if ( !(aOpt == *pSh->GetViewOptions()) )
1990 0 : pSh->ImplApplyViewOptions( aOpt );
1991 0 : pSh = (ViewShell*)pSh->GetNext();
1992 0 : }
1993 : // End of disabled multiple window
1994 :
1995 33 : pSh = this;
1996 33 : do
1997 33 : { pSh->EndAction();
1998 33 : pSh = (ViewShell*)pSh->GetNext();
1999 : } while ( pSh != this );
2000 :
2001 33 : }
2002 :
2003 33 : void ViewShell::ImplApplyViewOptions( const SwViewOption &rOpt )
2004 : {
2005 33 : if (*pOpt == rOpt)
2006 : return;
2007 :
2008 33 : Window *pMyWin = GetWin();
2009 33 : if( !pMyWin )
2010 : {
2011 : OSL_ENSURE( pMyWin, "ViewShell::ApplyViewOptions: no window" );
2012 : return;
2013 : }
2014 :
2015 33 : SET_CURR_SHELL( this );
2016 :
2017 33 : sal_Bool bReformat = sal_False;
2018 :
2019 33 : if( pOpt->IsShowHiddenField() != rOpt.IsShowHiddenField() )
2020 : {
2021 0 : ((SwHiddenTxtFieldType*)pDoc->GetSysFldType( RES_HIDDENTXTFLD ))->
2022 0 : SetHiddenFlag( !rOpt.IsShowHiddenField() );
2023 0 : bReformat = sal_True;
2024 : }
2025 33 : if ( pOpt->IsShowHiddenPara() != rOpt.IsShowHiddenPara() )
2026 : {
2027 0 : SwHiddenParaFieldType* pFldType = (SwHiddenParaFieldType*)GetDoc()->
2028 0 : GetSysFldType(RES_HIDDENPARAFLD);
2029 0 : if( pFldType && pFldType->GetDepends() )
2030 : {
2031 0 : SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
2032 0 : pFldType->ModifyNotification( &aHnt, 0);
2033 : }
2034 0 : bReformat = sal_True;
2035 : }
2036 33 : if ( !bReformat && pOpt->IsShowHiddenChar() != rOpt.IsShowHiddenChar() )
2037 : {
2038 0 : bReformat = GetDoc()->ContainsHiddenChars();
2039 : }
2040 :
2041 : // bReformat wird sal_True, wenn ...
2042 : // - Feldnamen anzeigen oder nicht ...
2043 : // ( - SwEndPortion muessen _nicht_ mehr generiert werden. )
2044 : // - Das Window ist natuerlich was ganz anderes als der Drucker...
2045 33 : bReformat = bReformat || pOpt->IsFldName() != rOpt.IsFldName();
2046 :
2047 : // Der Mapmode wird veraendert, Minima/Maxima werden von der UI beachtet
2048 33 : if( pOpt->GetZoom() != rOpt.GetZoom() && !IsPreView() )
2049 : {
2050 33 : MapMode aMode( pMyWin->GetMapMode() );
2051 33 : Fraction aNewFactor( rOpt.GetZoom(), 100 );
2052 33 : aMode.SetScaleX( aNewFactor );
2053 33 : aMode.SetScaleY( aNewFactor );
2054 33 : pMyWin->SetMapMode( aMode );
2055 : // Wenn kein ReferenzDevice (Drucker) zum Formatieren benutzt wird,
2056 : // sondern der Bildschirm, muss bei Zoomfaktoraenderung neu formatiert
2057 : // werden.
2058 33 : if( pOpt->getBrowseMode() )
2059 0 : bReformat = sal_True;
2060 : }
2061 :
2062 33 : bool bBrowseModeChanged = false;
2063 33 : if( pOpt->getBrowseMode() != rOpt.getBrowseMode() )
2064 : {
2065 0 : bBrowseModeChanged = true;
2066 0 : bReformat = sal_True;
2067 : }
2068 33 : else if( pOpt->getBrowseMode() && pOpt->IsPrtFormat() != rOpt.IsPrtFormat() )
2069 0 : bReformat = sal_True;
2070 :
2071 33 : if ( HasDrawView() || rOpt.IsGridVisible() )
2072 : {
2073 33 : if ( !HasDrawView() )
2074 0 : MakeDrawView();
2075 :
2076 33 : SwDrawView *pDView = Imp()->GetDrawView();
2077 33 : if ( pDView->IsDragStripes() != rOpt.IsCrossHair() )
2078 0 : pDView->SetDragStripes( rOpt.IsCrossHair() );
2079 :
2080 33 : if ( pDView->IsGridSnap() != rOpt.IsSnap() )
2081 0 : pDView->SetGridSnap( rOpt.IsSnap() );
2082 :
2083 33 : if ( pDView->IsGridVisible() != rOpt.IsGridVisible() )
2084 0 : pDView->SetGridVisible( rOpt.IsGridVisible() );
2085 :
2086 33 : const Size &rSz = rOpt.GetSnapSize();
2087 33 : pDView->SetGridCoarse( rSz );
2088 :
2089 : const Size aFSize
2090 66 : ( rSz.Width() ? rSz.Width() / (rOpt.GetDivisionX()+1) : 0,
2091 99 : rSz.Height()? rSz.Height()/ (rOpt.GetDivisionY()+1) : 0);
2092 33 : pDView->SetGridFine( aFSize );
2093 33 : Fraction aSnGrWdtX(rSz.Width(), rOpt.GetDivisionX() + 1);
2094 33 : Fraction aSnGrWdtY(rSz.Height(), rOpt.GetDivisionY() + 1);
2095 33 : pDView->SetSnapGridWidth( aSnGrWdtX, aSnGrWdtY );
2096 :
2097 : // set handle size to 9 pixels, always
2098 33 : pDView->SetMarkHdlSizePixel(9);
2099 : }
2100 :
2101 33 : bool bOnlineSpellChgd = pOpt->IsOnlineSpell() != rOpt.IsOnlineSpell();
2102 :
2103 33 : *pOpt = rOpt; // Erst jetzt werden die Options uebernommen.
2104 33 : pOpt->SetUIOptions(rOpt);
2105 :
2106 33 : pDoc->set(IDocumentSettingAccess::HTML_MODE, 0 != ::GetHtmlMode(pDoc->GetDocShell()));
2107 :
2108 33 : if( bBrowseModeChanged )
2109 : {
2110 : // #i44963# Good occasion to check if page sizes in
2111 : // page descriptions are still set to (LONG_MAX, LONG_MAX) (html import)
2112 0 : pDoc->CheckDefaultPageFmt();
2113 0 : CheckBrowseView( sal_True );
2114 : }
2115 :
2116 33 : pMyWin->Invalidate();
2117 33 : if ( bReformat )
2118 : {
2119 : // Es hilft alles nichts, wir muessen an alle CntntFrms ein
2120 : // Prepare verschicken, wir formatieren neu:
2121 0 : StartAction();
2122 0 : Reformat();
2123 0 : EndAction();
2124 : }
2125 :
2126 33 : if( bOnlineSpellChgd )
2127 : {
2128 0 : ViewShell *pSh = (ViewShell*)this->GetNext();
2129 0 : sal_Bool bOnlineSpl = rOpt.IsOnlineSpell();
2130 0 : while( pSh != this )
2131 0 : { pSh->pOpt->SetOnlineSpell( bOnlineSpl );
2132 0 : Window *pTmpWin = pSh->GetWin();
2133 0 : if( pTmpWin )
2134 0 : pTmpWin->Invalidate();
2135 0 : pSh = (ViewShell*)pSh->GetNext();
2136 : }
2137 33 : }
2138 :
2139 : }
2140 :
2141 :
2142 236 : void ViewShell::SetUIOptions( const SwViewOption &rOpt )
2143 : {
2144 236 : pOpt->SetUIOptions(rOpt);
2145 : //the API-Flag of the view options is set but never reset
2146 : //it is required to set scroll bars in readonly documents
2147 236 : if(rOpt.IsStarOneSetting())
2148 0 : pOpt->SetStarOneSetting(sal_True);
2149 :
2150 236 : pOpt->SetSymbolFont(rOpt.GetSymbolFont());
2151 236 : }
2152 :
2153 :
2154 0 : void ViewShell::SetReadonlyOption(sal_Bool bSet)
2155 : {
2156 : //JP 01.02.99: bei ReadOnly Flag richtig abfragen und ggfs. neu
2157 : // formatieren; Bug 61335
2158 :
2159 : // Schalten wir gerade von Readonly auf Bearbeiten um?
2160 0 : if( bSet != pOpt->IsReadonly() )
2161 : {
2162 : // damit die Flags richtig erfragt werden koennen.
2163 0 : pOpt->SetReadonly( sal_False );
2164 :
2165 0 : sal_Bool bReformat = pOpt->IsFldName();
2166 :
2167 0 : pOpt->SetReadonly( bSet );
2168 :
2169 0 : if( bReformat )
2170 : {
2171 0 : StartAction();
2172 0 : Reformat();
2173 0 : if ( GetWin() )
2174 0 : GetWin()->Invalidate();
2175 0 : EndAction();
2176 : }
2177 0 : else if ( GetWin() )
2178 0 : GetWin()->Invalidate();
2179 0 : if( Imp()->IsAccessible() )
2180 0 : Imp()->InvalidateAccessibleEditableState( sal_False );
2181 : }
2182 0 : }
2183 :
2184 :
2185 0 : void ViewShell::SetPDFExportOption(sal_Bool bSet)
2186 : {
2187 0 : if( bSet != pOpt->IsPDFExport() )
2188 : {
2189 0 : if( bSet && pOpt->getBrowseMode() )
2190 0 : pOpt->SetPrtFormat( sal_True );
2191 0 : pOpt->SetPDFExport(bSet);
2192 : }
2193 0 : }
2194 :
2195 :
2196 0 : void ViewShell::SetReadonlySelectionOption(sal_Bool bSet)
2197 : {
2198 0 : if( bSet != pOpt->IsSelectionInReadonly() )
2199 : {
2200 0 : pOpt->SetSelectionInReadonly(bSet);
2201 : }
2202 0 : }
2203 :
2204 :
2205 2 : void ViewShell::SetPrtFormatOption( sal_Bool bSet )
2206 : {
2207 2 : pOpt->SetPrtFormat( bSet );
2208 2 : }
2209 :
2210 :
2211 1954 : void ViewShell::UISizeNotify()
2212 : {
2213 1954 : if ( bDocSizeChgd )
2214 : {
2215 16 : bDocSizeChgd = sal_False;
2216 16 : bool bOld = bInSizeNotify;
2217 16 : bInSizeNotify = true;
2218 16 : ::SizeNotify( this, GetDocSize() );
2219 16 : bInSizeNotify = bOld;
2220 : }
2221 1954 : }
2222 :
2223 :
2224 4 : void ViewShell::SetRestoreActions(sal_uInt16 nSet)
2225 : {
2226 : OSL_ENSURE(!GetRestoreActions()||!nSet, "multiple restore of the Actions ?");
2227 4 : Imp()->SetRestoreActions(nSet);
2228 4 : }
2229 2 : sal_uInt16 ViewShell::GetRestoreActions() const
2230 : {
2231 2 : return Imp()->GetRestoreActions();
2232 : }
2233 :
2234 236 : sal_Bool ViewShell::IsNewLayout() const
2235 : {
2236 236 : return GetLayout()->IsNewLayout();
2237 : }
2238 :
2239 0 : uno::Reference< ::com::sun::star::accessibility::XAccessible > ViewShell::CreateAccessible()
2240 : {
2241 0 : uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc;
2242 :
2243 : // We require a layout and an XModel to be accessible.
2244 : OSL_ENSURE( pLayout, "no layout, no access" );
2245 : OSL_ENSURE( GetWin(), "no window, no access" );
2246 :
2247 0 : if( pDoc->GetCurrentViewShell() && GetWin() ) //swmod 071108
2248 0 : xAcc = Imp()->GetAccessibleMap().GetDocumentView();
2249 :
2250 0 : return xAcc;
2251 : }
2252 :
2253 : uno::Reference< ::com::sun::star::accessibility::XAccessible >
2254 0 : ViewShell::CreateAccessiblePreview()
2255 : {
2256 : OSL_ENSURE( IsPreView(),
2257 : "Can't create accessible preview for non-preview ViewShell" );
2258 :
2259 : // We require a layout and an XModel to be accessible.
2260 : OSL_ENSURE( pLayout, "no layout, no access" );
2261 : OSL_ENSURE( GetWin(), "no window, no access" );
2262 :
2263 0 : if ( IsPreView() && GetLayout()&& GetWin() )
2264 : {
2265 0 : return Imp()->GetAccessibleMap().GetDocumentPreview(
2266 0 : PagePreviewLayout()->maPrevwPages,
2267 0 : GetWin()->GetMapMode().GetScaleX(),
2268 0 : GetLayout()->GetPageByPageNum( PagePreviewLayout()->mnSelectedPageNum ),
2269 0 : PagePreviewLayout()->maWinSize ); //swmod 080305
2270 : }
2271 0 : return NULL;
2272 : }
2273 :
2274 284 : void ViewShell::InvalidateAccessibleFocus()
2275 : {
2276 284 : if( Imp()->IsAccessible() )
2277 0 : Imp()->GetAccessibleMap().InvalidateFocus();
2278 284 : }
2279 :
2280 : /*
2281 : * invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs #i27138#
2282 : */
2283 0 : void ViewShell::InvalidateAccessibleParaFlowRelation( const SwTxtFrm* _pFromTxtFrm,
2284 : const SwTxtFrm* _pToTxtFrm )
2285 : {
2286 0 : if ( GetLayout() && GetLayout()->IsAnyShellAccessible() )
2287 : {
2288 0 : Imp()->_InvalidateAccessibleParaFlowRelation( _pFromTxtFrm, _pToTxtFrm );
2289 : }
2290 0 : }
2291 :
2292 : /*
2293 : * invalidate text selection for paragraphs #i27301#
2294 : */
2295 1492 : void ViewShell::InvalidateAccessibleParaTextSelection()
2296 : {
2297 1492 : if ( GetLayout() && GetLayout()->IsAnyShellAccessible() )
2298 : {
2299 0 : Imp()->_InvalidateAccessibleParaTextSelection();
2300 : }
2301 1492 : }
2302 :
2303 : /**
2304 : * invalidate attributes for paragraphs #i88069#
2305 : */
2306 0 : void ViewShell::InvalidateAccessibleParaAttrs( const SwTxtFrm& rTxtFrm )
2307 : {
2308 0 : if ( GetLayout() && GetLayout()->IsAnyShellAccessible() )
2309 : {
2310 0 : Imp()->_InvalidateAccessibleParaAttrs( rTxtFrm );
2311 : }
2312 0 : }
2313 :
2314 9 : SwAccessibleMap* ViewShell::GetAccessibleMap()
2315 : {
2316 9 : if ( Imp()->IsAccessible() )
2317 : {
2318 0 : return &(Imp()->GetAccessibleMap());
2319 : }
2320 :
2321 9 : return 0;
2322 : }
2323 :
2324 :
2325 236 : void ViewShell::ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions)
2326 : {
2327 236 : if(pOpt->IsPagePreview() && !rAccessibilityOptions.GetIsForPagePreviews())
2328 : {
2329 0 : pAccOptions->SetAlwaysAutoColor(sal_False);
2330 0 : pAccOptions->SetStopAnimatedGraphics(sal_False);
2331 0 : pAccOptions->SetStopAnimatedText(sal_False);
2332 : }
2333 : else
2334 : {
2335 236 : pAccOptions->SetAlwaysAutoColor(rAccessibilityOptions.GetIsAutomaticFontColor());
2336 236 : pAccOptions->SetStopAnimatedGraphics(! rAccessibilityOptions.GetIsAllowAnimatedGraphics());
2337 236 : pAccOptions->SetStopAnimatedText(! rAccessibilityOptions.GetIsAllowAnimatedText());
2338 :
2339 : // Formular view
2340 : // Always set this option, not only if document is read-only:
2341 236 : pOpt->SetSelectionInReadonly(rAccessibilityOptions.IsSelectionInReadonly());
2342 : }
2343 236 : }
2344 :
2345 298 : ShellResource* ViewShell::GetShellRes()
2346 : {
2347 298 : return pShellRes;
2348 : }
2349 :
2350 0 : void ViewShell::SetCareWin( Window* pNew )
2351 : {
2352 0 : pCareWindow = pNew;
2353 0 : }
2354 :
2355 2 : sal_uInt16 ViewShell::GetPageCount() const
2356 : {
2357 2 : return GetLayout() ? GetLayout()->GetPageNum() : 1;
2358 : }
2359 :
2360 0 : const Size ViewShell::GetPageSize( sal_uInt16 nPageNum, bool bSkipEmptyPages ) const
2361 : {
2362 0 : Size aSize;
2363 0 : const SwRootFrm* pTmpRoot = GetLayout();
2364 0 : if( pTmpRoot && nPageNum )
2365 : {
2366 : const SwPageFrm* pPage = static_cast<const SwPageFrm*>
2367 0 : (pTmpRoot->Lower());
2368 :
2369 0 : while( --nPageNum && pPage->GetNext() )
2370 0 : pPage = static_cast<const SwPageFrm*>( pPage->GetNext() );
2371 :
2372 0 : if( !bSkipEmptyPages && pPage->IsEmptyPage() && pPage->GetNext() )
2373 0 : pPage = static_cast<const SwPageFrm*>( pPage->GetNext() );
2374 :
2375 0 : aSize = pPage->Frm().SSize();
2376 : }
2377 0 : return aSize;
2378 : }
2379 :
2380 :
2381 : // #i12836# enhanced pdf export
2382 0 : sal_Int32 ViewShell::GetPageNumAndSetOffsetForPDF( OutputDevice& rOut, const SwRect& rRect ) const
2383 : {
2384 : OSL_ENSURE( GetLayout(), "GetPageNumAndSetOffsetForPDF assumes presence of layout" );
2385 :
2386 0 : sal_Int32 nRet = -1;
2387 :
2388 : // #i40059# Position out of bounds:
2389 0 : SwRect aRect( rRect );
2390 0 : aRect.Pos().X() = Max( aRect.Left(), GetLayout()->Frm().Left() );
2391 :
2392 0 : const SwPageFrm* pPage = GetLayout()->GetPageAtPos( aRect.Center() );
2393 0 : if ( pPage )
2394 : {
2395 : OSL_ENSURE( pPage, "GetPageNumAndSetOffsetForPDF: No page found" );
2396 :
2397 0 : Point aOffset( pPage->Frm().Pos() );
2398 0 : aOffset.X() = -aOffset.X();
2399 0 : aOffset.Y() = -aOffset.Y();
2400 :
2401 0 : MapMode aMapMode( rOut.GetMapMode() );
2402 0 : aMapMode.SetOrigin( aOffset );
2403 0 : rOut.SetMapMode( aMapMode );
2404 :
2405 0 : nRet = pPage->GetPhyPageNum() - 1;
2406 : }
2407 :
2408 0 : return nRet;
2409 : }
2410 :
2411 :
2412 : // --> PB 2007-05-30 #146850#
2413 0 : const BitmapEx& ViewShell::GetReplacementBitmap( bool bIsErrorState )
2414 : {
2415 : BitmapEx** ppRet;
2416 0 : sal_uInt16 nResId = 0;
2417 0 : if( bIsErrorState )
2418 : {
2419 0 : ppRet = &pErrorBmp;
2420 0 : nResId = RID_GRAPHIC_ERRORBMP;
2421 : }
2422 : else
2423 : {
2424 0 : ppRet = &pReplaceBmp;
2425 0 : nResId = RID_GRAPHIC_REPLACEBMP;
2426 : }
2427 :
2428 0 : if( !*ppRet )
2429 : {
2430 0 : *ppRet = new BitmapEx( SW_RES( nResId ) );
2431 : }
2432 0 : return **ppRet;
2433 : }
2434 :
2435 0 : void ViewShell::DeleteReplacementBitmaps()
2436 : {
2437 0 : DELETEZ( pErrorBmp );
2438 0 : DELETEZ( pReplaceBmp );
2439 0 : }
2440 :
2441 3778 : SwPostItMgr* ViewShell::GetPostItMgr()
2442 : {
2443 3778 : SwView* pView = GetDoc()->GetDocShell() ? GetDoc()->GetDocShell()->GetView() : 0;
2444 3778 : if ( pView )
2445 3510 : return pView->GetPostItMgr();
2446 :
2447 268 : return 0;
2448 : }
2449 :
2450 : /*
2451 : * Document Interface Access
2452 : */
2453 11485 : const IDocumentSettingAccess* ViewShell::getIDocumentSettingAccess() const { return pDoc; }
2454 651 : IDocumentSettingAccess* ViewShell::getIDocumentSettingAccess() { return pDoc; }
2455 52 : const IDocumentDeviceAccess* ViewShell::getIDocumentDeviceAccess() const { return pDoc; }
2456 128 : IDocumentDeviceAccess* ViewShell::getIDocumentDeviceAccess() { return pDoc; }
2457 0 : const IDocumentMarkAccess* ViewShell::getIDocumentMarkAccess() const { return pDoc->getIDocumentMarkAccess(); }
2458 0 : IDocumentMarkAccess* ViewShell::getIDocumentMarkAccess() { return pDoc->getIDocumentMarkAccess(); }
2459 548 : const IDocumentDrawModelAccess* ViewShell::getIDocumentDrawModelAccess() const { return pDoc; }
2460 989 : IDocumentDrawModelAccess* ViewShell::getIDocumentDrawModelAccess() { return pDoc; }
2461 0 : const IDocumentRedlineAccess* ViewShell::getIDocumentRedlineAccess() const { return pDoc; }
2462 0 : IDocumentRedlineAccess* ViewShell::getIDocumentRedlineAccess() { return pDoc; }
2463 0 : const IDocumentLayoutAccess* ViewShell::getIDocumentLayoutAccess() const { return pDoc; }
2464 0 : IDocumentLayoutAccess* ViewShell::getIDocumentLayoutAccess() { return pDoc; }
2465 0 : IDocumentContentOperations* ViewShell::getIDocumentContentOperations() { return pDoc; }
2466 0 : IDocumentStylePoolAccess* ViewShell::getIDocumentStylePoolAccess() { return pDoc; }
2467 751 : const IDocumentStatistics* ViewShell::getIDocumentStatistics() const { return pDoc; }
2468 :
2469 0 : IDocumentUndoRedo & ViewShell::GetIDocumentUndoRedo()
2470 0 : { return pDoc->GetIDocumentUndoRedo(); }
2471 0 : IDocumentUndoRedo const& ViewShell::GetIDocumentUndoRedo() const
2472 0 : { return pDoc->GetIDocumentUndoRedo(); }
2473 :
2474 : // --> OD 2007-11-14 #i83479#
2475 0 : const IDocumentListItems* ViewShell::getIDocumentListItemsAccess() const
2476 : {
2477 0 : return pDoc;
2478 : }
2479 0 : const IDocumentOutlineNodes* ViewShell::getIDocumentOutlineNodesAccess() const
2480 : {
2481 0 : return pDoc;
2482 : }
2483 :
2484 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|