Update ooo320-m1
[ooovba.git] / sw / source / core / view / viewsh.cxx
blobfa038871c0e201ad8187a7c1cfdf0f2a63fbd009
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewsh.cxx,v $
10 * $Revision: 1.87.42.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #define _SVX_PARAITEM_HXX
36 #define _SVX_TEXTITEM_HXX
38 #include <com/sun/star/accessibility/XAccessible.hpp>
40 #include <sfx2/viewfrm.hxx>
41 #include <sfx2/progress.hxx>
42 #include <svx/srchdlg.hxx>
43 #include <svx/svdobj.hxx>
44 #include <sfx2/viewsh.hxx>
45 #ifndef _SHL_HXX
46 //#include <tools/shl.hxx>
47 #endif
48 #include <swwait.hxx>
49 #include <swmodule.hxx>
50 #include <fesh.hxx>
51 #include <doc.hxx>
52 #include <rootfrm.hxx>
53 #include <pagefrm.hxx>
54 #include <cntfrm.hxx>
55 #include <viewimp.hxx>
56 #include <frmtool.hxx>
57 #include <viewopt.hxx>
58 #include <dview.hxx>
59 #include <swregion.hxx>
60 #include <hints.hxx>
61 #include <fmtfsize.hxx>
62 #include <docufld.hxx>
63 #include <txtfrm.hxx>
64 #include <layact.hxx>
65 #include <mdiexp.hxx>
66 #include <fntcache.hxx>
67 #include <ptqueue.hxx>
68 #include <tabfrm.hxx>
69 #ifndef _DOCSH_HXX
70 #include <docsh.hxx>
71 #endif
72 #include <pagedesc.hxx>
73 #include <ndole.hxx>
74 #include <ndindex.hxx>
75 #include <accmap.hxx>
76 #include <svtools/colorcfg.hxx>
77 #include <svtools/accessibilityoptions.hxx>
78 #include <accessibilityoptions.hxx>
79 #ifndef _STATSTR_HRC
80 #include <statstr.hrc>
81 #endif
82 #ifndef _COMCORE_HRC
83 #include <comcore.hrc>
84 #endif
85 // OD 14.01.2003 #103492#
86 #include <pagepreviewlayout.hxx>
87 // --> OD 2004-05-24 #i28701#
88 #include <sortedobjs.hxx>
89 #include <anchoredobject.hxx>
90 // <--
92 #include "../../ui/inc/view.hxx"
93 #include <PostItMgr.hxx>
94 #include <vcl/virdev.hxx>
96 #include <vcl/svapp.hxx>
98 // #i74769#
99 #include <svx/sdrpaintwindow.hxx>
101 BOOL ViewShell::bLstAct = FALSE;
102 ShellResource *ViewShell::pShellRes = 0;
103 Window *ViewShell::pCareWindow = 0;
104 BitmapEx* ViewShell::pErrorBmp = NULL;
105 BitmapEx* ViewShell::pReplaceBmp = NULL;
107 BOOL bInSizeNotify = FALSE;
109 DBG_NAME(LayoutIdle)
111 TYPEINIT0(ViewShell);
113 using namespace ::com::sun::star;
115 //////////////////////////////////////////////////////////////////////////////
116 // #i72754# 2nd set of Pre/PostPaints
117 // This time it uses the lock counter mnPrePostPaintCount to allow only one activation
118 // and deactivation and mpPrePostOutDev to remember the OutDev from the BeginDrawLayers
119 // call. That way, all places where paint take place can be handled the same way, even
120 // when calling other paint methods. This is the case at the places where SW paints
121 // buffered into VDevs to avoid flicker. Tis is in general problematic and should be
122 // solved once using the BufferedOutput functionality of the DrawView.
124 void ViewShell::PrePaint()
126 // forward PrePaint event from VCL Window to DrawingLayer
127 if(HasDrawView())
129 Imp()->GetDrawView()->PrePaint();
133 void ViewShell::DLPrePaint2(const Region& rRegion)
135 if(0L == mnPrePostPaintCount)
137 // #i75172# ensure DrawView to use DrawingLayer bufferings
138 if ( !HasDrawView() )
139 MakeDrawView();
141 // Prefer window; if tot available, get pOut (e.g. printer)
142 mpPrePostOutDev = (GetWin() ? GetWin() : GetOut());
144 // #i74769# use SdrPaintWindow now direct
145 mpTargetPaintWindow = Imp()->GetDrawView()->BeginDrawLayers(mpPrePostOutDev, rRegion);
146 OSL_ENSURE(mpTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
148 // #i74769# if prerender, save OutDev and redirect to PreRenderDevice
149 if(mpTargetPaintWindow->GetPreRenderDevice())
151 mpBufferedOut = pOut;
152 pOut = &(mpTargetPaintWindow->GetTargetOutputDevice());
155 // remember original paint MapMode for wrapped FlyFrame paints
156 maPrePostMapMode = pOut->GetMapMode();
159 mnPrePostPaintCount++;
162 void ViewShell::DLPostPaint2(bool bPaintFormLayer)
164 OSL_ENSURE(mnPrePostPaintCount > 0L, "ViewShell::DLPostPaint2: Pre/PostPaint encapsulation broken (!)");
165 mnPrePostPaintCount--;
167 if((0L == mnPrePostPaintCount) && (0 != mpTargetPaintWindow))
169 // #i74769# restore buffered OutDev
170 if(mpTargetPaintWindow->GetPreRenderDevice())
172 pOut = mpBufferedOut;
175 // #i74769# use SdrPaintWindow now direct
176 Imp()->GetDrawView()->EndDrawLayers(*mpTargetPaintWindow, bPaintFormLayer);
177 mpTargetPaintWindow = 0;
181 //////////////////////////////////////////////////////////////////////////////
183 /******************************************************************************
185 |* ViewShell::ImplEndAction()
187 |* Letzte Aenderung MA 04. Sep. 96
189 ******************************************************************************/
191 void ViewShell::ImplEndAction( const BOOL bIdleEnd )
193 //Fuer den Drucker gibt es hier nichts zu tun.
194 if ( !GetWin() || IsPreView() )
196 bPaintWorks = TRUE;
197 UISizeNotify();
198 return;
201 bInEndAction = TRUE;
203 //Laeuft hiermit das EndAction der Letzten Shell im Ring?
204 ViewShell::bLstAct = TRUE;
205 ViewShell *pSh = (ViewShell*)this->GetNext();
206 while ( pSh != this )
207 { if ( pSh->ActionPend() )
208 { ViewShell::bLstAct = FALSE;
209 pSh = this;
211 else
212 pSh = (ViewShell*)pSh->GetNext();
215 const bool bIsShellForCheckViewLayout = ( this == GetLayout()->GetCurrShell() );
217 SET_CURR_SHELL( this );
218 if ( Imp()->HasDrawView() && !Imp()->GetDrawView()->areMarkHandlesHidden() )
219 Imp()->StartAction();
221 if ( Imp()->GetRegion() && Imp()->GetRegion()->GetOrigin() != VisArea() )
222 Imp()->DelRegions();
224 const BOOL bExtraData = ::IsExtraData( GetDoc() );
226 if ( !bIdleEnd )
228 if ( Imp()->IsNextScroll() && !bExtraData )
229 Imp()->SetScroll();
230 else
232 if ( bExtraData )
233 Imp()->bScroll = FALSE;
234 Imp()->SetNextScroll();
235 Imp()->ResetScroll();
237 SwLayAction aAction( GetLayout(), Imp() );
238 aAction.SetComplete( FALSE );
239 if ( nLockPaint )
240 aAction.SetPaint( FALSE );
241 aAction.SetInputType( INPUT_KEYBOARD );
242 aAction.Action();
243 Imp()->SetScroll();
246 if ( bIsShellForCheckViewLayout )
247 GetLayout()->CheckViewLayout( GetViewOptions(), &aVisArea );
249 //Wenn wir selbst keine Paints erzeugen, so warten wir auf das Paint
250 //vom System. Dann ist das Clipping korrekt gesetzt; Beispiel: verschieben
251 //eines DrawObjektes.
252 if ( Imp()->GetRegion() || Imp()->GetScrollRects() ||
253 aInvalidRect.HasArea() || bExtraData )
255 if ( !nLockPaint )
257 BOOL bPaintsFromSystem = aInvalidRect.HasArea();
258 GetWin()->Update();
259 if ( aInvalidRect.HasArea() )
261 if ( bPaintsFromSystem )
262 Imp()->AddPaintRect( aInvalidRect );
264 ResetInvalidRect();
265 bPaintsFromSystem = TRUE;
267 bPaintWorks = TRUE;
269 SwRegionRects *pRegion = Imp()->GetRegion();
271 //JP 27.11.97: wer die Selection hided, muss sie aber auch
272 // wieder Showen. Sonst gibt es Paintfehler!
273 // z.B.: addional Mode, Seite vertikal hab zu sehen, in der
274 // Mitte eine Selektion und mit einem anderen Cursor an linken
275 // rechten Rand springen. Ohne ShowCrsr verschwindet die
276 // Selektion
277 BOOL bShowCrsr = (pRegion || Imp()->GetScrollRects()) &&
278 IsA( TYPE(SwCrsrShell) );
279 if( bShowCrsr )
280 ((SwCrsrShell*)this)->HideCrsrs();
282 Scroll();
283 if ( bPaintsFromSystem && Imp()->pScrolledArea )
284 Imp()->FlushScrolledArea();
286 if ( pRegion )
288 SwRootFrm* pLayout = GetLayout();
290 Imp()->pRegion = NULL;
292 //Erst Invert dann Compress, niemals andersherum!
293 pRegion->Invert();
295 pRegion->Compress();
297 VirtualDevice *pVout = 0;
298 while ( pRegion->Count() )
300 SwRect aRect( (*pRegion)[ pRegion->Count() - 1 ] );
301 pRegion->Remove( pRegion->Count() - 1 );
303 BOOL bPaint = TRUE;
304 if ( IsEndActionByVirDev() )
306 //virtuelles device erzeugen und einstellen.
307 if ( !pVout )
308 pVout = new VirtualDevice( *GetOut() );
309 MapMode aMapMode( GetOut()->GetMapMode() );
310 pVout->SetMapMode( aMapMode );
312 BOOL bSizeOK = TRUE;
314 Rectangle aTmp1( aRect.SVRect() );
315 aTmp1 = GetOut()->LogicToPixel( aTmp1 );
316 Rectangle aTmp2( GetOut()->PixelToLogic( aTmp1 ) );
317 if ( aTmp2.Left() > aRect.Left() )
318 aTmp1.Left() = Max( 0L, aTmp1.Left() - 1L );
319 if ( aTmp2.Top() > aRect.Top() )
320 aTmp1.Top() = Max( 0L, aTmp1.Top() - 1L );
321 aTmp1.Right() += 1;
322 aTmp1.Bottom() += 1;
323 aTmp1 = GetOut()->PixelToLogic( aTmp1 );
324 aRect = SwRect( aTmp1 );
326 const Size aTmp( pVout->GetOutputSize() );
327 if ( aTmp.Height() < aRect.Height() ||
328 aTmp.Width() < aRect.Width() )
330 bSizeOK = pVout->SetOutputSize( aRect.SSize() );
332 if ( bSizeOK )
334 bPaint = FALSE;
336 // --> OD 2007-07-26 #i79947#
337 // #i72754# start Pre/PostPaint encapsulation before pOut is changed to the buffering VDev
338 const Region aRepaintRegion(aRect.SVRect());
339 DLPrePaint2(aRepaintRegion);
340 // <--
342 OutputDevice *pOld = GetOut();
343 pVout->SetLineColor( pOld->GetLineColor() );
344 pVout->SetFillColor( pOld->GetFillColor() );
345 Point aOrigin( aRect.Pos() );
346 aOrigin.X() = -aOrigin.X(); aOrigin.Y() = -aOrigin.Y();
347 aMapMode.SetOrigin( aOrigin );
348 pVout->SetMapMode( aMapMode );
350 pOut = pVout;
351 if ( bPaintsFromSystem )
352 PaintDesktop( aRect );
353 pLayout->Paint( aRect );
354 pOld->DrawOutDev( aRect.Pos(), aRect.SSize(),
355 aRect.Pos(), aRect.SSize(), *pVout );
356 pOut = pOld;
358 // #i72754# end Pre/PostPaint encapsulation when pOut is back and content is painted
359 DLPostPaint2(true);
362 if ( bPaint )
364 // #i75172# begin DrawingLayer paint
365 // need to do begin/end DrawingLayer preparation for each single rectangle of the
366 // repaint region. I already tried to prepare only once for the whole Region. This
367 // seems to work (and does technically) but fails with transparent objects. Since the
368 // region given to BeginDarwLayers() defines the clip region for DrawingLayer paint,
369 // transparent objects in the single rectangles will indeed be painted multiple times.
370 DLPrePaint2(Region(aRect.SVRect()));
372 if ( bPaintsFromSystem )
373 PaintDesktop( aRect );
374 pLayout->Paint( aRect );
376 // #i75172# end DrawingLayer paint
377 DLPostPaint2(true);
381 delete pVout;
382 delete pRegion;
383 Imp()->DelRegions();
385 if( bShowCrsr )
386 ((SwCrsrShell*)this)->ShowCrsrs( TRUE );
388 else
390 Imp()->DelRegions();
391 bPaintWorks = TRUE;
394 else
395 bPaintWorks = TRUE;
397 bInEndAction = FALSE;
398 ViewShell::bLstAct = FALSE;
399 Imp()->EndAction();
402 //Damit sich die automatischen Scrollbars auch richtig anordnen k?nnen
403 //muessen wir die Aktion hier kuenstlich beenden (EndAction loesst ein
404 //Notify aus, und das muss Start-/EndAction rufen um die Scrollbars
405 //klarzubekommen.
406 --nStartAction;
407 UISizeNotify();
408 ++nStartAction;
410 #ifndef PRODUCT
411 // test option 'No Scroll' suppresses the automatic repair of the scrolled area
412 if ( !GetViewOptions()->IsTest8() )
413 #endif
414 if ( Imp()->IsScrolled() )
415 Imp()->RestartScrollTimer();
417 if( Imp()->IsAccessible() )
418 Imp()->FireAccessibleEvents();
421 /******************************************************************************
423 |* ViewShell::ImplStartAction()
425 |* Ersterstellung MA 25. Jul. 94
426 |* Letzte Aenderung MA 25. Jul. 94
428 ******************************************************************************/
430 void ViewShell::ImplStartAction()
432 bPaintWorks = FALSE;
433 Imp()->StartAction();
437 /******************************************************************************
439 |* ViewShell::ImplLockPaint(), ImplUnlockPaint()
441 |* Ersterstellung MA 11. Jun. 96
442 |* Letzte Aenderung MA 11. Jun. 96
444 ******************************************************************************/
446 void ViewShell::ImplLockPaint()
448 if ( GetWin() && GetWin()->IsVisible() )
449 GetWin()->EnablePaint( FALSE ); //Auch die Controls abklemmen.
450 Imp()->LockPaint();
454 void ViewShell::ImplUnlockPaint( BOOL bVirDev )
456 SET_CURR_SHELL( this );
457 if ( GetWin() && GetWin()->IsVisible() )
459 if ( (bInSizeNotify || bVirDev ) && VisArea().HasArea() )
461 //Refresh mit virtuellem Device um das Flackern zu verhindern.
462 VirtualDevice *pVout = new VirtualDevice( *pOut );
463 pVout->SetMapMode( pOut->GetMapMode() );
464 Size aSize( VisArea().SSize() );
465 aSize.Width() += 20;
466 aSize.Height()+= 20;
467 if( pVout->SetOutputSize( aSize ) )
469 GetWin()->EnablePaint( TRUE );
470 GetWin()->Validate();
472 Imp()->UnlockPaint();
473 pVout->SetLineColor( pOut->GetLineColor() );
474 pVout->SetFillColor( pOut->GetFillColor() );
476 // #i72754# start Pre/PostPaint encapsulation before pOut is changed to the buffering VDev
477 const Region aRepaintRegion(VisArea().SVRect());
478 DLPrePaint2(aRepaintRegion);
480 OutputDevice *pOld = pOut;
481 pOut = pVout;
482 Paint( VisArea().SVRect() );
483 pOut = pOld;
484 pOut->DrawOutDev( VisArea().Pos(), aSize,
485 VisArea().Pos(), aSize, *pVout );
487 // #i72754# end Pre/PostPaint encapsulation when pOut is back and content is painted
488 DLPostPaint2(true);
490 else
492 Imp()->UnlockPaint();
493 GetWin()->EnablePaint( TRUE );
494 GetWin()->Invalidate( INVALIDATE_CHILDREN );
496 delete pVout;
498 else
500 Imp()->UnlockPaint();
501 GetWin()->EnablePaint( TRUE );
502 GetWin()->Invalidate( INVALIDATE_CHILDREN );
505 else
506 Imp()->UnlockPaint();
509 /******************************************************************************
511 |* ViewShell::AddPaintRect()
513 |* Ersterstellung MA ??
514 |* Letzte Aenderung MA 09. Feb. 97
516 ******************************************************************************/
518 BOOL ViewShell::AddPaintRect( const SwRect & rRect )
520 BOOL bRet = FALSE;
521 ViewShell *pSh = this;
524 if ( pSh->IsPreView() && pSh->GetWin() )
525 // pSh->GetWin()->Invalidate();
526 ::RepaintPagePreview( pSh, rRect );
527 else
528 bRet |= pSh->Imp()->AddPaintRect( rRect );
529 pSh = (ViewShell*)pSh->GetNext();
531 } while ( pSh != this );
532 return bRet;
535 /******************************************************************************
537 |* ViewShell::InvalidateWindows()
539 |* Ersterstellung MA ??
540 |* Letzte Aenderung MA 09. Feb. 97
542 ******************************************************************************/
544 void ViewShell::InvalidateWindows( const SwRect &rRect )
546 if ( !Imp()->IsCalcLayoutProgress() )
548 ViewShell *pSh = this;
551 if ( pSh->GetWin() )
553 if ( pSh->IsPreView() )
554 // pSh->GetWin()->Invalidate();
555 ::RepaintPagePreview( pSh, rRect );
556 else if ( pSh->VisArea().IsOver( rRect ) )
557 pSh->GetWin()->Invalidate( rRect.SVRect() );
559 pSh = (ViewShell*)pSh->GetNext();
561 } while ( pSh != this );
565 /******************************************************************************
567 |* ViewShell::MakeVisible()
569 |* Ersterstellung MA ??
570 |* Letzte Aenderung AMA 10. Okt. 95
572 ******************************************************************************/
574 void ViewShell::MakeVisible( const SwRect &rRect )
576 if ( !VisArea().IsInside( rRect ) || IsScrollMDI( this, rRect ) || GetCareWin(*this) )
578 if ( !IsViewLocked() )
580 if( pWin )
582 const SwFrm* pRoot = GetDoc()->GetRootFrm();
583 int nLoopCnt = 3;
584 long nOldH;
586 nOldH = pRoot->Frm().Height();
587 StartAction();
588 ScrollMDI( this, rRect, USHRT_MAX, USHRT_MAX );
589 EndAction();
590 } while( nOldH != pRoot->Frm().Height() && nLoopCnt-- );
592 #ifndef PRODUCT
593 else
595 //MA: 04. Nov. 94, braucht doch keiner oder??
596 ASSERT( !this, "MakeVisible fuer Drucker wird doch gebraucht?" );
599 #endif
604 /******************************************************************************
606 |* ViewShell::CareChildWindow()
608 |* Ersterstellung AMA 10. Okt. 95
609 |* Letzte Aenderung AMA 10. Okt. 95
611 ******************************************************************************/
613 Window* ViewShell::CareChildWin(ViewShell& rVSh)
615 if(rVSh.pSfxViewShell)
617 const USHORT nId = SvxSearchDialogWrapper::GetChildWindowId();
618 SfxViewFrame* pVFrame = rVSh.pSfxViewShell->GetViewFrame();
619 const SfxChildWindow* pChWin = pVFrame->GetChildWindow( nId );
620 Window *pWin = pChWin ? pChWin->GetWindow() : NULL;
621 if ( pWin && pWin->IsVisible() )
622 return pWin;
624 return NULL;
627 /******************************************************************************
629 |* ViewShell::GetPagePos()
631 |* Ersterstellung MA ??
632 |* Letzte Aenderung MA 04. Aug. 93
634 ******************************************************************************/
636 Point ViewShell::GetPagePos( USHORT nPageNum ) const
638 return GetLayout()->GetPagePos( nPageNum );
641 /******************************************************************************
643 |* ViewShell::GetNumPages()
645 |* Ersterstellung MA ??
646 |* Letzte Aenderung MA 20. Apr. 94
648 ******************************************************************************/
650 USHORT ViewShell::GetNumPages()
652 //Es kann sein, das noch kein Layout existiert weil die Methode vom
653 //Root-Ctor gerufen wird.
654 return GetLayout() ? GetLayout()->GetPageNum() : 0;
657 sal_Bool ViewShell::IsDummyPage( USHORT nPageNum ) const
659 return GetLayout() ? GetLayout()->IsDummyPage( nPageNum ) : 0;
662 /*************************************************************************
664 |* ViewShell::UpdateFlds()
666 |* Ersterstellung BP 04.05.92
667 |* Beschreibung erzwingt ein Update fuer jedes Feld
669 |* UpdateFlds benachrichtigt alle Felder mit pNewHt.
670 |* Wenn pNewHt == 0 ist (default), wird der Feldtyp verschickt.
672 *************************************************************************/
674 void ViewShell::UpdateFlds(BOOL bCloseDB)
676 SET_CURR_SHELL( this );
678 BOOL bCrsr = ISA(SwCrsrShell);
679 if ( bCrsr )
680 ((SwCrsrShell*)this)->StartAction();
681 else
682 StartAction();
684 GetDoc()->UpdateFlds(0, bCloseDB);
686 if ( bCrsr )
687 ((SwCrsrShell*)this)->EndAction();
688 else
689 EndAction();
692 // update all charts, for that exists any table
693 void ViewShell::UpdateAllCharts()
695 SET_CURR_SHELL( this );
696 // Start-/EndAction handled in the SwDoc-Method!
697 GetDoc()->UpdateAllCharts();
700 BOOL ViewShell::HasCharts() const
702 BOOL bRet = FALSE;
703 const SwStartNode *pStNd;
704 SwNodeIndex aIdx( *GetDoc()->GetNodes().GetEndOfAutotext().
705 StartOfSectionNode(), 1 );
706 while ( 0 != (pStNd = aIdx.GetNode().GetStartNode()) )
708 aIdx++;
709 const SwOLENode *pNd = aIdx.GetNode().GetOLENode();
710 if( pNd && pNd->GetChartTblName().Len() )
712 bRet = TRUE;
713 break;
716 return bRet;
719 /*************************************************************************
721 |* ViewShell::LayoutIdle()
723 |* Ersterstellung MA 26. May. 92
724 |* Letzte Aenderung OG 19. Mar. 96
726 *************************************************************************/
728 void ViewShell::LayoutIdle()
730 #ifdef TCOVER
731 //fuer TCV-Version: Ende der Startphase des Programmes
732 TCovCall::Idle();
733 #endif
734 if( !pOpt->IsIdle() || !GetWin() ||
735 ( Imp()->HasDrawView() && Imp()->GetDrawView()->IsDragObj() ) )
736 return;
738 //Kein Idle wenn gerade gedruckt wird.
739 ViewShell *pSh = this;
741 { if ( !pSh->GetWin() )
742 return;
743 pSh = (ViewShell*)pSh->GetNext();
745 } while ( pSh != this );
747 SET_CURR_SHELL( this );
749 #ifndef PRODUCT
750 // Wenn Test5 gedrueckt ist, wird der IdleFormatierer abgeknipst.
751 if( pOpt->IsTest5() )
752 return;
753 #endif
756 DBG_PROFSTART( LayoutIdle );
758 //Cache vorbereiten und restaurieren, damit er nicht versaut wird.
759 SwSaveSetLRUOfst aSave( *SwTxtFrm::GetTxtCache(),
760 SwTxtFrm::GetTxtCache()->GetCurMax() - 50 );
761 // #125243# there are lots of stacktraces indicating that Imp() returns NULL
762 // this ViewShell seems to be invalid - but it's not clear why
763 // this return is only a workaround!
764 DBG_ASSERT(Imp(), "ViewShell already deleted?");
765 if(!Imp())
766 return;
767 SwLayIdle aIdle( GetLayout(), Imp() );
768 DBG_PROFSTOP( LayoutIdle );
772 /*************************************************************************
774 |* DOCUMENT COMPATIBILITY FLAGS
776 *************************************************************************/
778 void lcl_InvalidateAllCntnt( ViewShell& rSh, BYTE nInv )
780 BOOL bCrsr = rSh.ISA(SwCrsrShell);
781 if ( bCrsr )
782 ((SwCrsrShell&)rSh).StartAction();
783 else
784 rSh.StartAction();
785 rSh.GetLayout()->InvalidateAllCntnt( nInv );
786 if ( bCrsr )
787 ((SwCrsrShell&)rSh).EndAction();
788 else
789 rSh.EndAction();
791 rSh.GetDoc()->SetModified();
794 /** local method to invalidate/re-calculate positions of floating screen
795 objects (Writer fly frame and drawing objects), which are anchored
796 to paragraph or to character.
798 OD 2004-03-16 #i11860#
800 @author OD
802 void lcl_InvalidateAllObjPos( ViewShell &_rSh )
804 const bool bIsCrsrShell = _rSh.ISA(SwCrsrShell);
805 if ( bIsCrsrShell )
806 static_cast<SwCrsrShell&>(_rSh).StartAction();
807 else
808 _rSh.StartAction();
810 _rSh.GetLayout()->InvalidateAllObjPos();
812 if ( bIsCrsrShell )
813 static_cast<SwCrsrShell&>(_rSh).EndAction();
814 else
815 _rSh.EndAction();
817 _rSh.GetDoc()->SetModified();
820 void ViewShell::SetParaSpaceMax( bool bNew )
822 IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
823 if( pIDSA->get(IDocumentSettingAccess::PARA_SPACE_MAX) != bNew )
825 SwWait aWait( *GetDoc()->GetDocShell(), TRUE );
826 pIDSA->set(IDocumentSettingAccess::PARA_SPACE_MAX, bNew );
827 const BYTE nInv = INV_PRTAREA | INV_TABLE | INV_SECTION;
828 lcl_InvalidateAllCntnt( *this, nInv );
832 void ViewShell::SetParaSpaceMaxAtPages( bool bNew )
834 IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
835 if( pIDSA->get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES) != bNew )
837 SwWait aWait( *GetDoc()->GetDocShell(), TRUE );
838 pIDSA->set(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES, bNew );
839 const BYTE nInv = INV_PRTAREA | INV_TABLE | INV_SECTION;
840 lcl_InvalidateAllCntnt( *this, nInv );
844 void ViewShell::SetTabCompat( bool bNew )
846 IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
847 if( pIDSA->get(IDocumentSettingAccess::TAB_COMPAT) != bNew )
849 SwWait aWait( *GetDoc()->GetDocShell(), TRUE );
850 pIDSA->set(IDocumentSettingAccess::TAB_COMPAT, bNew );
851 const BYTE nInv = INV_PRTAREA | INV_SIZE | INV_TABLE | INV_SECTION;
852 lcl_InvalidateAllCntnt( *this, nInv );
856 /*-- 29.11.2007 09:03:18---------------------------------------------------
857 //#i24363# tab stops relative to indent
858 -----------------------------------------------------------------------*/
859 void ViewShell::SetTabsRelativeToIndent(bool bNew)
861 IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
862 if( pIDSA->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT) != bNew )
864 SwWait aWait( *GetDoc()->GetDocShell(), TRUE );
865 pIDSA->set(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT, bNew );
866 const BYTE nInv = INV_PRTAREA | INV_SIZE | INV_TABLE | INV_SECTION;
867 lcl_InvalidateAllCntnt( *this, nInv );
871 void ViewShell::SetAddExtLeading( bool bNew )
873 IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
874 if ( pIDSA->get(IDocumentSettingAccess::ADD_EXT_LEADING) != bNew )
876 SwWait aWait( *GetDoc()->GetDocShell(), TRUE );
877 pIDSA->set(IDocumentSettingAccess::ADD_EXT_LEADING, bNew );
878 SdrModel* pTmpDrawModel = getIDocumentDrawModelAccess()->GetDrawModel();
879 if ( pTmpDrawModel )
880 pTmpDrawModel->SetAddExtLeading( bNew );
881 const BYTE nInv = INV_PRTAREA | INV_SIZE | INV_TABLE | INV_SECTION;
882 lcl_InvalidateAllCntnt( *this, nInv );
886 void ViewShell::SetUseVirDev( bool bNewVirtual )
888 IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
889 if ( pIDSA->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) != bNewVirtual )
891 SwWait aWait( *GetDoc()->GetDocShell(), TRUE );
892 // this sets the flag at the document and calls PrtDataChanged
893 IDocumentDeviceAccess* pIDDA = getIDocumentDeviceAccess();
894 pIDDA->setReferenceDeviceType( bNewVirtual, true );
898 // OD 2004-02-16 #106629# - control, if paragraph and table spacing is added
899 // at bottom of table cells
900 void ViewShell::SetAddParaSpacingToTableCells( bool _bAddParaSpacingToTableCells )
902 IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
903 if ( pIDSA->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS) != _bAddParaSpacingToTableCells )
905 SwWait aWait( *GetDoc()->GetDocShell(), TRUE );
906 pIDSA->set(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS, _bAddParaSpacingToTableCells );
907 const BYTE nInv = INV_PRTAREA;
908 lcl_InvalidateAllCntnt( *this, nInv );
912 // OD 06.01.2004 #i11859# - control, if former formatting of text lines with
913 // proportional line spacing is used or not.
914 void ViewShell::SetUseFormerLineSpacing( bool _bUseFormerLineSpacing )
916 IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
917 if ( pIDSA->get(IDocumentSettingAccess::OLD_LINE_SPACING) != _bUseFormerLineSpacing )
919 SwWait aWait( *GetDoc()->GetDocShell(), TRUE );
920 pIDSA->set(IDocumentSettingAccess::OLD_LINE_SPACING, _bUseFormerLineSpacing );
921 const BYTE nInv = INV_PRTAREA;
922 lcl_InvalidateAllCntnt( *this, nInv );
926 // OD 2004-03-12 #i11860# - control, if former object positioning is used or not.
927 void ViewShell::SetUseFormerObjectPositioning( bool _bUseFormerObjPos )
929 IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
930 if ( pIDSA->get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS) != _bUseFormerObjPos )
932 SwWait aWait( *GetDoc()->GetDocShell(), TRUE );
933 pIDSA->set(IDocumentSettingAccess::USE_FORMER_OBJECT_POS, _bUseFormerObjPos );
934 lcl_InvalidateAllObjPos( *this );
938 // OD 2004-05-05 #i28701#
939 void ViewShell::SetConsiderWrapOnObjPos( bool _bConsiderWrapOnObjPos )
941 IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
942 if ( pIDSA->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) != _bConsiderWrapOnObjPos )
944 SwWait aWait( *GetDoc()->GetDocShell(), TRUE );
945 pIDSA->set(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION, _bConsiderWrapOnObjPos );
946 lcl_InvalidateAllObjPos( *this );
950 // --> FME #108724#
951 void ViewShell::SetUseFormerTextWrapping( bool _bUseFormerTextWrapping )
953 IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
954 if ( pIDSA->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) != _bUseFormerTextWrapping )
956 SwWait aWait( *GetDoc()->GetDocShell(), TRUE );
957 pIDSA->set(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING, _bUseFormerTextWrapping );
958 const BYTE nInv = INV_PRTAREA | INV_SIZE | INV_TABLE | INV_SECTION;
959 lcl_InvalidateAllCntnt( *this, nInv );
962 // <--
964 // -> PB 2007-06-11 #i45491#
965 void ViewShell::SetDoNotJustifyLinesWithManualBreak( bool _bDoNotJustifyLinesWithManualBreak )
967 IDocumentSettingAccess* pIDSA = getIDocumentSettingAccess();
968 if ( pIDSA->get(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK) != _bDoNotJustifyLinesWithManualBreak )
970 SwWait aWait( *GetDoc()->GetDocShell(), TRUE );
971 pIDSA->set(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, _bDoNotJustifyLinesWithManualBreak );
972 const BYTE nInv = INV_PRTAREA | INV_SIZE | INV_TABLE | INV_SECTION;
973 lcl_InvalidateAllCntnt( *this, nInv );
976 // <--
978 /******************************************************************************
980 |* ViewShell::Reformat
982 |* Ersterstellung BP ???
983 |* Letzte Aenderung MA 13. Feb. 98
985 ******************************************************************************/
987 void ViewShell::Reformat()
989 SwWait aWait( *GetDoc()->GetDocShell(), TRUE );
991 // Wir gehen auf Nummer sicher:
992 // Wir muessen die alten Fontinformationen wegschmeissen,
993 // wenn die Druckeraufloesung oder der Zoomfaktor sich aendert.
994 // Init() und Reformat() sind die sichersten Stellen.
995 #ifdef FNTMET
996 aFntMetList.Flush();
997 #else
998 pFntCache->Flush( );
999 #endif
1001 if( GetLayout()->IsCallbackActionEnabled() )
1004 StartAction();
1005 GetLayout()->InvalidateAllCntnt( INV_SIZE | INV_POS | INV_PRTAREA );
1006 EndAction();
1010 void ViewShell::ChgNumberDigits()
1012 SdrModel* pTmpDrawModel = getIDocumentDrawModelAccess()->GetDrawModel();
1013 if ( pTmpDrawModel )
1014 pTmpDrawModel->ReformatAllTextObjects();
1015 Reformat();
1018 /******************************************************************************
1020 |* ViewShell::CalcLayout()
1021 |* Vollstaendige Formatierung von Layout und Inhalt.
1023 |* Ersterstellung MA 31. Jan. 94
1024 |* Letzte Aenderung MA 08. Oct. 96
1026 ******************************************************************************/
1028 void ViewShell::CalcLayout()
1030 SET_CURR_SHELL( this );
1031 SwWait aWait( *GetDoc()->GetDocShell(), TRUE );
1033 //Cache vorbereiten und restaurieren, damit er nicht versaut wird.
1034 SwSaveSetLRUOfst aSaveLRU( *SwTxtFrm::GetTxtCache(),
1035 SwTxtFrm::GetTxtCache()->GetCurMax() - 50 );
1037 //Progress einschalten wenn noch keiner Lauft.
1038 const BOOL bEndProgress = SfxProgress::GetActiveProgress( GetDoc()->GetDocShell() ) == 0;
1039 if ( bEndProgress )
1041 USHORT nEndPage = GetLayout()->GetPageNum();
1042 nEndPage += nEndPage * 10 / 100;
1043 ::StartProgress( STR_STATSTR_REFORMAT, 0, nEndPage, GetDoc()->GetDocShell() );
1046 SwLayAction aAction( GetLayout(), Imp() );
1047 aAction.SetPaint( FALSE );
1048 aAction.SetStatBar( TRUE );
1049 aAction.SetCalcLayout( TRUE );
1050 aAction.SetReschedule( TRUE );
1051 GetDoc()->LockExpFlds();
1052 aAction.Action();
1053 GetDoc()->UnlockExpFlds();
1055 //Das SetNewFldLst() am Doc wurde unterbunden und muss nachgeholt
1056 //werden (siehe flowfrm.cxx, txtfld.cxx)
1057 if ( aAction.IsExpFlds() )
1059 aAction.Reset();
1060 aAction.SetPaint( FALSE );
1061 aAction.SetStatBar( TRUE );
1062 aAction.SetReschedule( TRUE );
1064 SwDocPosUpdate aMsgHnt( 0 );
1065 GetDoc()->UpdatePageFlds( &aMsgHnt );
1066 GetDoc()->UpdateExpFlds(NULL, true);
1068 aAction.Action();
1071 if ( VisArea().HasArea() )
1072 InvalidateWindows( VisArea() );
1073 if ( bEndProgress )
1074 ::EndProgress( GetDoc()->GetDocShell() );
1077 /******************************************************************************
1079 |* ViewShell::SetFirstVisPageInvalid()
1081 |* Ersterstellung MA 19. May. 94
1082 |* Letzte Aenderung MA 19. May. 94
1084 ******************************************************************************/
1086 void ViewShell::SetFirstVisPageInvalid()
1088 ViewShell *pSh = this;
1090 { pSh->Imp()->SetFirstVisPageInvalid();
1091 pSh = (ViewShell*)pSh->GetNext();
1093 } while ( pSh != this );
1096 /******************************************************************************
1098 |* ViewShell::SizeChgNotify()
1100 |* Ersterstellung MA ??
1101 |* Letzte Aenderung MA 17. Sep. 96
1103 ******************************************************************************/
1105 void ViewShell::SizeChgNotify()
1107 if ( !pWin )
1108 bDocSizeChgd = TRUE;
1109 else if( ActionPend() || Imp()->IsCalcLayoutProgress() || bPaintInProgress )
1111 bDocSizeChgd = TRUE;
1113 if ( !Imp()->IsCalcLayoutProgress() && ISA( SwCrsrShell ) )
1115 const SwFrm *pCnt = ((SwCrsrShell*)this)->GetCurrFrm( FALSE );
1116 const SwPageFrm *pPage;
1117 if ( pCnt && 0 != (pPage = pCnt->FindPageFrm()) )
1119 USHORT nVirtNum = pPage->GetVirtPageNum();
1120 const SvxNumberType& rNum = pPage->GetPageDesc()->GetNumType();
1121 String sDisplay = rNum.GetNumStr( nVirtNum );
1122 PageNumNotify( this, pCnt->GetPhyPageNum(), nVirtNum, sDisplay );
1126 else
1128 bDocSizeChgd = FALSE;
1129 ::SizeNotify( this, GetDocSize() );
1133 /******************************************************************************
1135 |* ViewShell::VisPortChgd()
1137 |* Ersterstellung MA ??
1138 |* Letzte Aenderung MA 22. Jul. 96
1140 ******************************************************************************/
1142 void ViewShell::VisPortChgd( const SwRect &rRect)
1144 ASSERT( GetWin(), "VisPortChgd ohne Window." );
1146 if ( rRect == VisArea() )
1147 return;
1149 #ifndef PRODUCT
1150 if ( bInEndAction )
1152 //Da Rescheduled doch schon wieder irgendwo einer?
1153 ASSERT( !this, "Scroll waehrend einer EndAction." );
1155 #endif
1157 //Ersteinmal die alte sichtbare Seite holen, dann braucht nacher nicht
1158 //lange gesucht werden.
1159 const SwFrm *pOldPage = Imp()->GetFirstVisPage();
1161 const SwRect aPrevArea( VisArea() );
1162 const BOOL bFull = aPrevArea.IsEmpty();
1163 aVisArea = rRect;
1164 SetFirstVisPageInvalid();
1166 //Wenn noch eine PaintRegion herumsteht und sich die VisArea geaendert hat,
1167 //so ist die PaintRegion spaetestens jetzt obsolete. Die PaintRegion kann
1168 //vom RootFrm::Paint erzeugt worden sein.
1169 if ( !bInEndAction &&
1170 Imp()->GetRegion() && Imp()->GetRegion()->GetOrigin() != VisArea() )
1171 Imp()->DelRegions();
1173 SET_CURR_SHELL( this );
1175 //SwSaveHdl aSaveHdl( Imp() );
1177 bool bScrolled = false;
1179 SwPostItMgr* pPostItMgr = GetPostItMgr();
1181 if ( bFull )
1182 GetWin()->Invalidate();
1183 else
1185 // Betrag ausrechnen, um den gescrolled werden muss.
1186 const long nXDiff = aPrevArea.Left() - VisArea().Left();
1187 const long nYDiff = aPrevArea.Top() - VisArea().Top();
1189 if( !nXDiff && !getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) &&
1190 (!Imp()->HasDrawView() || !Imp()->GetDrawView()->IsGridVisible() ) )
1192 //Falls moeglich die Wiese nicht mit Scrollen.
1193 //Also linke und rechte Kante des Scrollbereiches auf die
1194 //Seiten begrenzen.
1195 const SwPageFrm *pPage = (SwPageFrm*)GetDoc()->GetRootFrm()->Lower();
1196 if ( pPage->Frm().Top() > pOldPage->Frm().Top() )
1197 pPage = (SwPageFrm*)pOldPage;
1198 SwRect aBoth( VisArea() );
1199 aBoth.Union( aPrevArea );
1200 const SwTwips nBottom = aBoth.Bottom();
1201 SwTwips nMinLeft = LONG_MAX;
1202 SwTwips nMaxRight= 0;
1204 const SwTwips nSidebarWidth = pPostItMgr && pPostItMgr->ShowNotes() && pPostItMgr->HasNotes() ?
1205 pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth() :
1207 const bool bBookMode = GetViewOptions()->IsViewLayoutBookMode();
1209 while ( pPage && pPage->Frm().Top() <= nBottom )
1211 SwRect aPageRect( pPage->Frm() );
1212 if ( bBookMode )
1214 const SwPageFrm& rFormatPage = static_cast<const SwPageFrm*>(pPage)->GetFormatPage();
1215 aPageRect.SSize() = rFormatPage.Frm().SSize();
1218 if ( aPageRect.IsOver( aBoth ) )
1220 // OD 12.02.2003 #i9719#, #105645# - consider new border
1221 // and shadow width
1222 const SwTwips nBorderWidth =
1223 GetOut()->PixelToLogic( Size( pPage->BorderPxWidth(), 0 ) ).Width();
1224 const SwTwips nShadowWidth =
1225 GetOut()->PixelToLogic( Size( pPage->ShadowPxWidth(), 0 ) ).Width();
1227 SwTwips nPageLeft = 0;
1228 SwTwips nPageRight = 0;
1229 if (pPage->MarginSide())
1231 nPageLeft = aPageRect.Left() - nBorderWidth - nSidebarWidth;
1232 nPageRight = aPageRect.Right() + nBorderWidth + nShadowWidth;
1234 else
1236 // OD 03.03.2003 #107927# - use correct datatype
1237 nPageLeft = aPageRect.Left() - nBorderWidth;
1238 nPageRight = aPageRect.Right() + nBorderWidth + nShadowWidth + nSidebarWidth;
1240 if( nPageLeft < nMinLeft )
1241 nMinLeft = nPageLeft;
1242 if( nPageRight > nMaxRight )
1243 nMaxRight = nPageRight;
1244 //Zus. auf die Zeichenobjekte abgleichen.
1245 //Einen Ofst beruecksichtigen, weil die Objekte u.U.
1246 //selektiert sind und die Henkel dann hinausstehen.
1247 if ( pPage->GetSortedObjs() )
1249 const long nOfst = GetOut()->PixelToLogic(
1250 Size(Imp()->GetDrawView()->GetMarkHdlSizePixel()/2,0)).Width();
1251 for ( USHORT i = 0;
1252 i < pPage->GetSortedObjs()->Count(); ++i )
1254 SwAnchoredObject* pObj = (*pPage->GetSortedObjs())[i];
1255 const Rectangle &rBound = pObj->GetObjRect().SVRect();
1256 // OD 03.03.2003 #107927# - use correct datatype
1257 const SwTwips nL = Max( 0L, rBound.Left() - nOfst );
1258 if ( nL < nMinLeft )
1259 nMinLeft = nL;
1260 if( rBound.Right() + nOfst > nMaxRight )
1261 nMaxRight = rBound.Right() + nOfst;
1265 pPage = (SwPageFrm*)pPage->GetNext();
1267 Rectangle aRect( aPrevArea.SVRect() );
1268 aRect.Left() = nMinLeft;
1269 aRect.Right() = nMaxRight;
1270 if( VisArea().IsOver( aPrevArea ) && !nLockPaint )
1272 bScrolled = true;
1273 aVisArea.Pos() = aPrevArea.Pos();
1274 if ( SmoothScroll( nXDiff, nYDiff, &aRect ) )
1275 return;
1276 aVisArea.Pos() = rRect.Pos();
1278 else
1279 GetWin()->Invalidate( aRect );
1281 else if ( !nLockPaint ) //Wird im UnLock erledigt
1283 if( VisArea().IsOver( aPrevArea ) )
1285 bScrolled = true;
1286 aVisArea.Pos() = aPrevArea.Pos();
1287 if ( SmoothScroll( nXDiff, nYDiff, 0 ) )
1288 return;
1289 aVisArea.Pos() = rRect.Pos();
1291 else
1292 GetWin()->Invalidate();
1296 Point aPt( VisArea().Pos() );
1297 aPt.X() = -aPt.X(); aPt.Y() = -aPt.Y();
1298 MapMode aMapMode( GetWin()->GetMapMode() );
1299 aMapMode.SetOrigin( aPt );
1300 GetWin()->SetMapMode( aMapMode );
1301 if ( HasDrawView() )
1303 Imp()->GetDrawView()->VisAreaChanged( GetWin() );
1304 Imp()->GetDrawView()->SetActualWin( GetWin() );
1306 Imp()->bPaintInScroll = TRUE;
1307 GetWin()->Update();
1308 Imp()->bPaintInScroll = FALSE;
1310 if ( !bScrolled && pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
1311 pPostItMgr->CorrectPositions();
1313 if( Imp()->IsAccessible() )
1314 Imp()->UpdateAccessible();
1318 /******************************************************************************
1320 |* ViewShell::SmoothScroll()
1322 |* Ersterstellung MA 04. Jul. 96
1323 |* Letzte Aenderung MA 25. Mar. 97
1325 ******************************************************************************/
1327 BOOL ViewShell::SmoothScroll( long lXDiff, long lYDiff, const Rectangle *pRect )
1329 const ULONG nColCnt = pOut->GetColorCount();
1330 long lMult = 1, lMax = LONG_MAX;
1331 if ( nColCnt == 65536 )
1333 lMax = 7000;
1334 lMult = 2;
1336 if ( nColCnt == 16777216 )
1338 lMax = 5000;
1339 lMult = 6;
1341 else if ( nColCnt == 1 )
1343 lMax = 3000;
1344 lMult = 12;
1347 // #i75172# isolated static conditions
1348 const bool bOnlyYScroll(!lXDiff && Abs(lYDiff) != 0 && Abs(lYDiff) < lMax);
1349 const bool bAllowedWithChildWindows(GetWin()->GetWindowClipRegionPixel(WINDOW_GETCLIPREGION_NOCHILDREN|WINDOW_GETCLIPREGION_NULL).IsNull());
1350 // --> OD 2009-08-12 #i98766# - disable smooth scrolling for Mac port builds
1351 #ifdef QUARTZ
1352 const bool bSmoothScrollAllowed(false);
1353 (void) bOnlyYScroll;
1354 (void) bAllowedWithChildWindows;
1355 #else
1356 const bool bSmoothScrollAllowed(bOnlyYScroll && bEnableSmooth && GetViewOptions()->IsSmoothScroll() && bAllowedWithChildWindows);
1357 #endif
1358 // <-
1359 const bool bIAmCursorShell(ISA(SwCrsrShell));
1360 (void) bIAmCursorShell;
1362 // #i75172# with selection on overlay, smooth scroll should be allowed with it
1363 const bool bAllowedForSelection(true || (bIAmCursorShell && !((SwCrsrShell*)this)->HasSelection()));
1365 // #i75172# with cursors on overlay, smooth scroll should be allowed with it
1366 const bool bAllowedForMultipleCursors(true || (bIAmCursorShell && ((SwCrsrShell*)this)->GetCrsrCnt() < 2));
1368 if(bSmoothScrollAllowed && bAllowedForSelection && bAllowedForMultipleCursors)
1370 Imp()->bStopSmooth = FALSE;
1372 const SwRect aOldVis( VisArea() );
1374 //Virtuelles Device erzeugen und einstellen.
1375 const Size aPixSz = GetWin()->PixelToLogic(Size(1,1));
1376 VirtualDevice *pVout = new VirtualDevice( *GetWin() );
1377 pVout->SetLineColor( GetWin()->GetLineColor() );
1378 pVout->SetFillColor( GetWin()->GetFillColor() );
1379 MapMode aMapMode( GetWin()->GetMapMode() );
1380 pVout->SetMapMode( aMapMode );
1381 Size aSize( aVisArea.Width()+2*aPixSz.Width(), Abs(lYDiff)+(2*aPixSz.Height()) );
1382 if ( pRect )
1383 aSize.Width() = Min(aSize.Width(), pRect->GetWidth()+2*aPixSz.Width());
1384 if ( pVout->SetOutputSize( aSize ) )
1386 nLockPaint++;
1388 //Ersteinmal alles neue in das VirDev Painten.
1389 SwRect aRect( VisArea() );
1390 aRect.Height( aSize.Height() );
1391 if ( pRect )
1393 aRect.Pos().X() = Max(aRect.Left(),pRect->Left()-aPixSz.Width());
1394 aRect.Right( Min(aRect.Right()+2*aPixSz.Width(), pRect->Right()+aPixSz.Width()));
1396 else
1397 aRect.SSize().Width() += 2*aPixSz.Width();
1398 aRect.Pos().Y() = lYDiff < 0 ? aOldVis.Bottom() - aPixSz.Height()
1399 : aRect.Top() - aSize.Height() + aPixSz.Height();
1400 aRect.Pos().X() = Max( 0L, aRect.Left()-aPixSz.Width() );
1401 aRect.Pos() = GetWin()->PixelToLogic( GetWin()->LogicToPixel( aRect.Pos()));
1402 aRect.SSize()= GetWin()->PixelToLogic( GetWin()->LogicToPixel( aRect.SSize()));
1403 aVisArea = aRect;
1404 const Point aPt( -aRect.Left(), -aRect.Top() );
1405 aMapMode.SetOrigin( aPt );
1406 pVout->SetMapMode( aMapMode );
1407 OutputDevice *pOld = pOut;
1408 pOut = pVout;
1411 // #i75172# To get a clean repaint, a new ObjectContact is needed here. Without, the
1412 // repaint would not be correct since it would use the wrong DrawPage visible region.
1413 // This repaint IS about painting something currently outside the visible part (!).
1414 // For that purpose, AddWindowToPaintView is used which creates a new SdrPageViewWindow
1415 // and all the necessary stuff. It's not cheap, but necessary here. Alone because repaint
1416 // target really is NOT the current window.
1417 // Also will automatically NOT use PreRendering and overlay (since target is VirtualDevice)
1418 if(!HasDrawView())
1419 MakeDrawView();
1420 SdrView* pDrawView = GetDrawView();
1421 pDrawView->AddWindowToPaintView(pVout);
1423 // clear pWin during DLPrePaint2 to get paint preparation for pOut, but set it again
1424 // immediately afterwards. There are many decisions in SW which imply that Printing
1425 // is used when pWin == 0 (wrong but widely used).
1426 Window* pOldWin = pWin;
1427 pWin = 0;
1428 DLPrePaint2(Region(aRect.SVRect()));
1429 pWin = pOldWin;
1431 // SW paint stuff
1432 PaintDesktop( aRect );
1433 ViewShell::bLstAct = TRUE;
1434 GetLayout()->Paint( aRect );
1435 ViewShell::bLstAct = FALSE;
1437 // end paint and destroy ObjectContact again
1438 DLPostPaint2(true);
1439 pDrawView->DeleteWindowFromPaintView(pVout);
1441 // temporary debug paint checking...
1442 static bool bDoSaveForVisualControl(false);
1443 if(bDoSaveForVisualControl)
1445 const bool bMapModeWasEnabledVDev(pVout->IsMapModeEnabled());
1446 pVout->EnableMapMode(false);
1447 const Bitmap aBitmap(pVout->GetBitmap(Point(), pVout->GetOutputSizePixel()));
1448 const String aTmpString(ByteString( "c:\\test.bmp" ), RTL_TEXTENCODING_UTF8);
1449 SvFileStream aNew(aTmpString, STREAM_WRITE|STREAM_TRUNC);
1450 aNew << aBitmap;
1451 pVout->EnableMapMode(bMapModeWasEnabledVDev);
1455 pOut = pOld;
1456 aVisArea = aOldVis;
1458 //Jetzt Stueckchenweise schieben und die neuen Pixel aus dem
1459 //VirDev kopieren.
1461 // ??????????????????????
1462 // or is it better to get the scrollfactor from the User
1463 // as option?
1464 // ??????????????????????
1465 long lMaDelta = aPixSz.Height();
1466 if ( Abs(lYDiff) > ( aVisArea.Height() / 3 ) )
1467 lMaDelta *= 6;
1468 else
1469 lMaDelta *= 2;
1471 lMaDelta *= lMult;
1473 if ( lYDiff < 0 )
1474 lMaDelta = -lMaDelta;
1476 long lDiff = lYDiff;
1477 while ( lDiff )
1479 long lScroll;
1480 if ( Imp()->bStopSmooth || Abs(lDiff) <= Abs(lMaDelta) )
1482 lScroll = lDiff;
1483 lDiff = 0;
1485 else
1487 lScroll = lMaDelta;
1488 lDiff -= lMaDelta;
1491 const SwRect aTmpOldVis = VisArea();
1492 aVisArea.Pos().Y() -= lScroll;
1493 aVisArea.Pos() = GetWin()->PixelToLogic( GetWin()->LogicToPixel( VisArea().Pos()));
1494 lScroll = aTmpOldVis.Top() - VisArea().Top();
1495 if ( pRect )
1497 Rectangle aTmp( aTmpOldVis.SVRect() );
1498 aTmp.Left() = pRect->Left();
1499 aTmp.Right()= pRect->Right();
1500 GetWin()->Scroll( 0, lScroll, aTmp, SCROLL_CHILDREN);
1502 else
1503 GetWin()->Scroll( 0, lScroll, SCROLL_CHILDREN );
1505 const Point aTmpPt( -VisArea().Left(), -VisArea().Top() );
1506 MapMode aTmpMapMode( GetWin()->GetMapMode() );
1507 aTmpMapMode.SetOrigin( aTmpPt );
1508 GetWin()->SetMapMode( aTmpMapMode );
1510 if ( Imp()->HasDrawView() )
1511 Imp()->GetDrawView()->VisAreaChanged( GetWin() );
1513 SetFirstVisPageInvalid();
1514 if ( !Imp()->bStopSmooth )
1516 const bool bScrollDirectionIsUp(lScroll > 0);
1517 Imp()->aSmoothRect = VisArea();
1519 if(bScrollDirectionIsUp)
1521 Imp()->aSmoothRect.Bottom( VisArea().Top() + lScroll + aPixSz.Height());
1523 else
1525 Imp()->aSmoothRect.Top( VisArea().Bottom() + lScroll - aPixSz.Height());
1528 Imp()->bSmoothUpdate = TRUE;
1529 GetWin()->Update();
1530 Imp()->bSmoothUpdate = FALSE;
1532 if(!Imp()->bStopSmooth)
1534 static bool bDoItOnPixels(true);
1535 if(bDoItOnPixels)
1537 // start paint on logic base
1538 const Rectangle aTargetLogic(Imp()->aSmoothRect.SVRect());
1539 DLPrePaint2(Region(aTargetLogic));
1541 // get target rectangle in discrete pixels
1542 OutputDevice& rTargetDevice = mpTargetPaintWindow->GetTargetOutputDevice();
1543 const Rectangle aTargetPixel(rTargetDevice.LogicToPixel(aTargetLogic));
1545 // get source top-left in discrete pixels
1546 const Point aSourceTopLeft(pVout->LogicToPixel(aTargetLogic.TopLeft()));
1548 // switch off MapModes
1549 const bool bMapModeWasEnabledDest(rTargetDevice.IsMapModeEnabled());
1550 const bool bMapModeWasEnabledSource(pVout->IsMapModeEnabled());
1551 rTargetDevice.EnableMapMode(false);
1552 pVout->EnableMapMode(false);
1554 // copy content
1555 static bool bTestDirectToWindowPaint(false);
1556 if(bTestDirectToWindowPaint)
1558 const bool bMapModeWasEnabledWin(GetWin()->IsMapModeEnabled());
1559 GetWin()->EnableMapMode(false);
1561 GetWin()->DrawOutDev(
1562 aTargetPixel.TopLeft(), aTargetPixel.GetSize(), // dest
1563 aSourceTopLeft, aTargetPixel.GetSize(), // source
1564 *pVout);
1566 GetWin()->EnableMapMode(bMapModeWasEnabledWin);
1569 rTargetDevice.DrawOutDev(
1570 aTargetPixel.TopLeft(), aTargetPixel.GetSize(), // dest
1571 aSourceTopLeft, aTargetPixel.GetSize(), // source
1572 *pVout);
1574 // restore MapModes
1575 rTargetDevice.EnableMapMode(bMapModeWasEnabledDest);
1576 pVout->EnableMapMode(bMapModeWasEnabledSource);
1578 // end paint on logoc base
1579 DLPostPaint2(true);
1581 else
1583 Rectangle aRectangle(Imp()->aSmoothRect.SVRect());
1584 aRectangle.Left() -= aPixSz.Width();
1585 aRectangle.Right() += aPixSz.Width();
1586 aRectangle.Top() -= aPixSz.Height();
1587 aRectangle.Bottom() += aPixSz.Height();
1588 const Point aUpdateTopLeft(aRectangle.TopLeft());
1589 const Size aUpdateSize(aRectangle.GetSize());
1591 // #i75172# the part getting visible needs to be handled like a repaint.
1592 // For that, start with DLPrePaint2 and the correct Rectangle
1593 DLPrePaint2(Region(aRectangle));
1595 static bool bTestDirectToWindowPaint(false);
1596 if(bTestDirectToWindowPaint)
1598 GetWin()->DrawOutDev(aUpdateTopLeft, aUpdateSize, aUpdateTopLeft, aUpdateSize, *pVout);
1601 mpTargetPaintWindow->GetTargetOutputDevice().DrawOutDev(aUpdateTopLeft, aUpdateSize, aUpdateTopLeft, aUpdateSize, *pVout);
1603 // #i75172# Corret repaint end
1604 // Note: This also correcty creates the overlay, thus smooth scroll will
1605 // also be allowed now wth selection (see big IF above)
1606 DLPostPaint2(true);
1609 else
1610 --nLockPaint;
1613 delete pVout;
1614 GetWin()->Update();
1615 if ( !Imp()->bStopSmooth )
1616 --nLockPaint;
1617 SetFirstVisPageInvalid();
1618 return TRUE;
1620 delete pVout;
1623 aVisArea.Pos().X() -= lXDiff;
1624 aVisArea.Pos().Y() -= lYDiff;
1625 if ( pRect )
1626 GetWin()->Scroll( lXDiff, lYDiff, *pRect, SCROLL_CHILDREN);
1627 else
1628 GetWin()->Scroll( lXDiff, lYDiff, SCROLL_CHILDREN);
1629 return FALSE;
1632 /******************************************************************************
1634 |* ViewShell::PaintDesktop()
1636 |* Ersterstellung MA 16. Dec. 93
1637 |* Letzte Aenderung MA 30. Nov. 95
1639 ******************************************************************************/
1641 void ViewShell::PaintDesktop( const SwRect &rRect )
1643 if ( !GetWin() && !GetOut()->GetConnectMetaFile() )
1644 return; //Fuer den Drucker tun wir hier nix
1646 //Sonderfaelle abfangen, damit es nicht gar so ueberraschend aussieht.
1647 //Kann z.B. waehrend des Idle'ns zwischenzeitlich auftreten.
1648 //Die Rechtecke neben den Seiten muessen wir leider auf jedenfall Painten,
1649 //den diese werden spaeter beim VisPortChgd ausgespart.
1650 BOOL bBorderOnly = FALSE;
1651 const SwRootFrm *pRoot = GetDoc()->GetRootFrm();
1652 if ( rRect.Top() > pRoot->Frm().Bottom() )
1654 const SwFrm *pPg = pRoot->Lower();
1655 while ( pPg && pPg->GetNext() )
1656 pPg = pPg->GetNext();
1657 if ( !pPg || !pPg->Frm().IsOver( VisArea() ) )
1658 bBorderOnly = TRUE;
1661 const bool bBookMode = GetViewOptions()->IsViewLayoutBookMode();
1663 SwRegionRects aRegion( rRect );
1665 //mod #i6193: remove sidebar area to avoid flickering
1666 const SwPostItMgr* pPostItMgr = GetPostItMgr();
1667 const SwTwips nSidebarWidth = pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() ?
1668 pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth() :
1671 if ( bBorderOnly )
1673 const SwFrm *pPage = pRoot->Lower();
1674 SwRect aLeft( rRect ), aRight( rRect );
1675 while ( pPage )
1677 long nTmp = pPage->Frm().Left();
1678 if ( nTmp < aLeft.Right() )
1679 aLeft.Right( nTmp );
1680 nTmp = pPage->Frm().Right();
1681 if ( nTmp > aRight.Left() )
1683 aRight.Left( nTmp + nSidebarWidth );
1685 pPage = pPage->GetNext();
1687 aRegion.Remove( 0, aRegion.Count() );
1688 if ( aLeft.HasArea() )
1689 aRegion.Insert( aLeft, 0 );
1690 if ( aRight.HasArea() )
1691 aRegion.Insert( aRight, 1 );
1693 else
1695 const SwFrm *pPage = Imp()->GetFirstVisPage();
1696 const SwTwips nBottom = rRect.Bottom();
1697 //const SwTwips nRight = rRect.Right();
1698 while ( pPage && aRegion.Count() &&
1699 (pPage->Frm().Top() <= nBottom) ) // PAGES01 && (pPage->Frm().Left() <= nRight))
1701 SwRect aPageRect( pPage->Frm() );
1702 if ( bBookMode )
1704 const SwPageFrm& rFormatPage = static_cast<const SwPageFrm*>(pPage)->GetFormatPage();
1705 aPageRect.SSize() = rFormatPage.Frm().SSize();
1708 const bool bSidebarRight = !static_cast<const SwPageFrm*>(pPage)->MarginSide();
1709 aPageRect.Pos().X() -= bSidebarRight ? 0 : nSidebarWidth;
1710 aPageRect.SSize().Width() += nSidebarWidth;
1712 if ( aPageRect.IsOver( rRect ) )
1713 aRegion -= aPageRect;
1715 pPage = pPage->GetNext();
1718 if ( aRegion.Count() )
1719 _PaintDesktop( aRegion );
1723 // PaintDesktop gesplittet, dieser Teil wird auch von PreViewPage benutzt
1724 void ViewShell::_PaintDesktop( const SwRegionRects &rRegion )
1726 // OD 2004-04-23 #116347#
1727 GetOut()->Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
1728 GetOut()->SetLineColor();
1730 for ( USHORT i = 0; i < rRegion.Count(); ++i )
1732 const Rectangle aRectangle(rRegion[i].SVRect());
1734 // #i93170#
1735 // Here we have a real Problem. On the one hand we have the buffering for paint
1736 // and overlay which needs an embracing pair of DLPrePaint2/DLPostPaint2 calls,
1737 // on the other hand the MapMode is not set correctly when this code is executed.
1738 // This is done in the users of this method, for each SWpage before painting it.
1739 // Since the MapMode is not correct here, the call to DLPostPaint2 will paint
1740 // existing FormControls due to the current MapMode.
1742 // There are basically three solutions for this:
1744 // (1) Set the MapMode correct, move the background painting to the users of
1745 // this code
1747 // (2) Do no DLPrePaint2/DLPostPaint2 here; no SdrObjects are allowed to lie in
1748 // the desktop region. Disadvantage: the desktop will not be part of the
1749 // buffers, e.g. overlay. Thus, as soon as overlay will be used over the
1750 // desktop, it will not work.
1752 // (3) expand DLPostPaint2 with a flag to signal if FormControl paints shall
1753 // be done or not
1755 // Currently, (3) will be the best possible solution. It will keep overlay and
1756 // buffering intact and work without MapMode for single pages. In the medium
1757 // to long run, (1) will need to be used and the bool bPaintFormLayer needs
1758 // to be removed again
1760 // #i68597# inform Drawinglayer about display change
1761 DLPrePaint2(Region(aRectangle));
1763 // #i75172# needed to move line/Fill color setters into loop since DLPrePaint2
1764 // may exchange GetOut(), that's it's purpose. This happens e.g. at print preview.
1765 GetOut()->SetFillColor( SwViewOption::GetAppBackgroundColor());
1766 GetOut()->SetLineColor();
1767 GetOut()->DrawRect(aRectangle);
1769 DLPostPaint2(false);
1772 GetOut()->Pop();
1775 /******************************************************************************
1777 |* ViewShell::CheckInvalidForPaint()
1779 |* Ersterstellung MA 19. May. 94
1780 |* Letzte Aenderung MA 09. Jun. 94
1782 ******************************************************************************/
1784 BOOL ViewShell::CheckInvalidForPaint( const SwRect &rRect )
1786 if ( !GetWin() )
1787 return FALSE;
1789 const SwPageFrm *pPage = Imp()->GetFirstVisPage();
1790 const SwTwips nBottom = VisArea().Bottom();
1791 const SwTwips nRight = VisArea().Right();
1792 BOOL bRet = FALSE;
1793 while ( !bRet && pPage && !((pPage->Frm().Top() > nBottom) ||
1794 (pPage->Frm().Left() > nRight)))
1796 if ( pPage->IsInvalid() || pPage->IsInvalidFly() )
1797 bRet = TRUE;
1798 pPage = (SwPageFrm*)pPage->GetNext();
1801 if ( bRet )
1803 //Start/EndAction wuerden hier leider nix helfen, weil das Paint vom
1804 //GUI 'reinkam und somit ein Clipping gesetzt ist gegen das wir nicht
1805 //nicht ankommen.
1806 //Ergo: Alles selbst machen (siehe ImplEndAction())
1807 if ( Imp()->GetRegion() && Imp()->GetRegion()->GetOrigin() != VisArea())
1808 Imp()->DelRegions();
1810 Imp()->ResetScroll();
1811 SwLayAction aAction( GetLayout(), Imp() );
1812 aAction.SetComplete( FALSE );
1813 // We increment the action counter to avoid a recursive call of actions
1814 // e.g. from a SwFEShell::RequestObjectResize(..) in bug 95829.
1815 // A recursive call of actions is no good idea because the inner action
1816 // can't format frames which are locked by the outer action. This may
1817 // cause and endless loop.
1818 ++nStartAction;
1819 aAction.Action();
1820 --nStartAction;
1822 SwRegionRects *pRegion = Imp()->GetRegion();
1823 if ( pRegion && aAction.IsBrowseActionStop() )
1825 //Nur dann interessant, wenn sich im sichtbaren Bereich etwas
1826 //veraendert hat.
1827 BOOL bStop = TRUE;
1828 for ( USHORT i = 0; i < pRegion->Count(); ++i )
1830 const SwRect &rTmp = (*pRegion)[i];
1831 if ( FALSE == (bStop = rTmp.IsOver( VisArea() )) )
1832 break;
1834 if ( bStop )
1836 Imp()->DelRegions();
1837 pRegion = 0;
1841 if ( pRegion )
1843 //Erst Invert dann Compress, niemals andersherum!
1844 pRegion->Invert();
1845 pRegion->Compress();
1846 bRet = FALSE;
1847 if ( pRegion->Count() )
1849 SwRegionRects aRegion( rRect );
1850 for ( USHORT i = 0; i < pRegion->Count(); ++i )
1851 { const SwRect &rTmp = (*pRegion)[i];
1852 if ( !rRect.IsInside( rTmp ) )
1854 InvalidateWindows( rTmp );
1855 if ( rTmp.IsOver( VisArea() ) )
1856 { aRegion -= rTmp;
1857 bRet = TRUE;
1861 if ( bRet )
1863 for ( USHORT i = 0; i < aRegion.Count(); ++i )
1864 GetWin()->Invalidate( aRegion[i].SVRect() );
1866 if ( rRect != VisArea() )
1868 //rRect == VisArea ist der spezialfall fuer neu bzw.
1869 //Shift-Ctrl-R, dafuer sollte es nicht notwendig sein
1870 //das Rechteck nocheinmal in Dokumentkoordinaten v
1871 //vorzuhalten.
1872 if ( aInvalidRect.IsEmpty() )
1873 aInvalidRect = rRect;
1874 else
1875 aInvalidRect.Union( rRect );
1879 else
1880 bRet = FALSE;
1881 Imp()->DelRegions();
1883 else
1884 bRet = FALSE;
1886 return bRet;
1889 /******************************************************************************
1891 |* ViewShell::Paint()
1893 |* Ersterstellung MA ??
1894 |* Letzte Aenderung MA 17. Sep. 96
1896 ******************************************************************************/
1898 void ViewShell::Paint(const Rectangle &rRect)
1900 if ( nLockPaint )
1902 if ( Imp()->bSmoothUpdate )
1904 SwRect aTmp( rRect );
1905 if ( !Imp()->aSmoothRect.IsInside( aTmp ) )
1906 Imp()->bStopSmooth = TRUE;
1907 else
1909 Imp()->aSmoothRect = aTmp;
1910 return;
1913 else
1914 return;
1917 if ( SwRootFrm::IsInPaint() )
1919 //Waehrend der Ausgabe einer Seite beim Druckvorgang wird das
1920 //Paint gepuffert.
1921 SwPaintQueue::Add( this, SwRect( rRect ) );
1922 return;
1925 //MA 30. Jul. 95: fix(16787): mit !nStartAction versuche ich mal mich gegen
1926 //fehlerhaften Code an anderen Stellen zu wehren. Hoffentlich fuehrt das
1927 //nicht zu Problemen!?
1928 if ( bPaintWorks && !nStartAction )
1930 if( GetWin() && GetWin()->IsVisible() )
1932 //Wenn mit dem Paint ein Bereich betroffen ist, der vorher gescrolled
1933 //wurde, so wiederholen wir das Paint mit dem Gesamtbereich. Nur so
1934 //koennen wir sicherstellen, das (nicht mal kurzfristig) durch das Paint
1935 //keine Alignmentfehler sichtbar werden.
1936 SwRect aRect( rRect );
1937 if ( Imp()->IsScrolled() && Imp()->FlushScrolledArea( aRect ) )
1939 GetWin()->Invalidate( aRect.SVRect() );
1940 return;
1943 if ( bPaintInProgress ) //Schutz gegen doppelte Paints!
1945 GetWin()->Invalidate( rRect );
1946 return;
1949 bPaintInProgress = TRUE;
1950 SET_CURR_SHELL( this );
1951 SwRootFrm::SetNoVirDev( TRUE );
1953 //Wir wollen nicht staendig hin und her Clippen, wir verlassen
1954 //uns darauf, das sich alle auf das Rechteck beschraeken und
1955 //brauchen das Clipping hier nur einmalig einkalkulieren. Das
1956 //ClipRect wird hier einmal entfernt und nicht Restauriert, denn
1957 //von aussen braucht es sowieso keiner mehr.
1958 //Nicht wenn wir ein MetaFile aufzeichnen.
1959 if( !GetOut()->GetConnectMetaFile() && GetOut()->IsClipRegion())
1960 GetOut()->SetClipRegion();
1962 if ( IsPreView() )
1964 //Falls sinnvoll gleich das alte InvalidRect verarbeiten bzw.
1965 //vernichten.
1966 if ( aRect.IsInside( aInvalidRect ) )
1967 ResetInvalidRect();
1968 ViewShell::bLstAct = TRUE;
1969 GetLayout()->Paint( aRect );
1970 ViewShell::bLstAct = FALSE;
1972 else
1974 //SwSaveHdl *pSaveHdl = 0;
1975 //if ( Imp()->HasDrawView() )
1976 // pSaveHdl = new SwSaveHdl( Imp() );
1978 //Wenn eine der sichtbaren Seiten noch irgendetwas zum Repaint
1979 //angemeldet hat, so muessen Repaints ausgeloest werden.
1980 if ( !CheckInvalidForPaint( aRect ) )
1982 // --> OD 2009-08-12 #i101192#
1983 // start Pre/PostPaint encapsulation to avoid screen blinking
1984 const Region aRepaintRegion(aRect.SVRect());
1985 DLPrePaint2(aRepaintRegion);
1986 // <--
1987 PaintDesktop( aRect );
1988 //Falls sinnvoll gleich das alte InvalidRect verarbeiten bzw.
1989 //vernichten.
1990 if ( aRect.IsInside( aInvalidRect ) )
1991 ResetInvalidRect();
1992 ViewShell::bLstAct = TRUE;
1993 GetLayout()->Paint( aRect );
1994 ViewShell::bLstAct = FALSE;
1995 // --> OD 2009-08-12 #i101192#
1996 // end Pre/PostPaint encapsulation
1997 DLPostPaint2(true);
1998 // <--
2001 //delete pSaveHdl;
2003 SwRootFrm::SetNoVirDev( FALSE );
2004 bPaintInProgress = FALSE;
2005 UISizeNotify();
2008 else
2010 if ( aInvalidRect.IsEmpty() )
2011 aInvalidRect = SwRect( rRect );
2012 else
2013 aInvalidRect.Union( SwRect( rRect ) );
2015 if ( bInEndAction && GetWin() )
2017 Region aRegion( GetWin()->GetPaintRegion() );
2018 RegionHandle hHdl( aRegion.BeginEnumRects() );
2019 Rectangle aRect;
2020 while ( aRegion.GetNextEnumRect( hHdl, aRect ) )
2021 Imp()->AddPaintRect( aRect );
2022 aRegion.EndEnumRects( hHdl );
2024 else if ( SfxProgress::GetActiveProgress( GetDoc()->GetDocShell() ) &&
2025 GetOut() == GetWin() )
2027 // #i68597#
2028 const Region aDLRegion(rRect);
2029 DLPrePaint2(aDLRegion);
2031 // OD 2004-04-23 #116347#
2032 pOut->Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
2033 pOut->SetFillColor( Imp()->GetRetoucheColor() );
2034 pOut->SetLineColor();
2035 pOut->DrawRect( rRect );
2036 pOut->Pop();
2038 // #i68597#
2039 DLPostPaint2(true);
2044 /******************************************************************************
2046 |* ViewShell::SetBrowseBorder()
2048 |* Ersterstellung AMA 20. Aug. 96
2049 |* Letzte Aenderung AMA 20. Aug. 96
2051 ******************************************************************************/
2053 void ViewShell::SetBrowseBorder( const Size& rNew )
2055 if( rNew != aBrowseBorder )
2057 aBrowseBorder = rNew;
2058 if ( aVisArea.HasArea() )
2059 CheckBrowseView( FALSE );
2063 const Size& ViewShell::GetBrowseBorder() const
2065 return aBrowseBorder;
2068 sal_Int32 ViewShell::GetBrowseWidth() const
2070 const SwPostItMgr* pPostItMgr = GetPostItMgr();
2071 if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
2073 Size aBorder( aBrowseBorder );
2074 aBorder.Width() += aBrowseBorder.Width();
2075 aBorder.Width() += pPostItMgr->GetSidebarWidth(true) + pPostItMgr->GetSidebarBorderWidth(true);
2076 return aVisArea.Width() - GetOut()->PixelToLogic(aBorder).Width();
2078 else
2079 return aVisArea.Width() - 2 * GetOut()->PixelToLogic(aBrowseBorder).Width();
2082 /******************************************************************************
2084 |* ViewShell::CheckBrowseView()
2086 |* Ersterstellung MA 04. Mar. 96
2087 |* Letzte Aenderung MA 04. Jul. 96
2089 ******************************************************************************/
2091 void ViewShell::CheckBrowseView( BOOL bBrowseChgd )
2093 if ( !bBrowseChgd &&
2094 !getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
2095 return;
2097 SET_CURR_SHELL( this );
2099 ASSERT( GetLayout(), "Layout not ready" );
2101 // Wenn das Layout noch nicht einmal eine Hoehe hat,
2102 // ist sowieso nichts formatiert.
2103 // Dann eruebrigt sich die Invalidierung
2104 // Falsch, z.B. beim Anlegen einer neuen View wird der Inhalt eingef?gt
2105 // und formatiert (trotz einer leeren VisArea). Hier muessen deshalb
2106 // die Seiten zur Formatierung angeregt werden.
2107 if( !GetLayout()->Frm().Height() )
2109 SwFrm* pPage = GetLayout()->Lower();
2110 while( pPage )
2112 pPage->_InvalidateSize();
2113 pPage = pPage->GetNext();
2115 return;
2118 LockPaint();
2119 StartAction();
2121 SwPageFrm *pPg = (SwPageFrm*)GetLayout()->Lower();
2123 { pPg->InvalidateSize();
2124 pPg->_InvalidatePrt();
2125 pPg->InvaPercentLowers();
2126 if ( bBrowseChgd )
2128 pPg->PrepareHeader();
2129 pPg->PrepareFooter();
2131 pPg = (SwPageFrm*)pPg->GetNext();
2132 } while ( pPg );
2134 // Wenn sich die Groessenverhaeltnise im BrowseModus aendern,
2135 // muss die Position und PrtArea der Cntnt- und Tab-Frames invalidiert werden.
2136 BYTE nInv = INV_PRTAREA | INV_TABLE | INV_POS;
2137 // Beim BrowseModus-Wechsel benoetigen die CntntFrms
2138 // wg. der Drucker/Bildschirmformatierung eine Size-Invalidierung
2139 if( bBrowseChgd )
2140 nInv |= INV_SIZE | INV_DIRECTION;
2142 GetLayout()->InvalidateAllCntnt( nInv );
2144 SwFrm::CheckPageDescs( (SwPageFrm*)GetLayout()->Lower() );
2146 EndAction();
2147 UnlockPaint();
2150 /*************************************************************************
2152 |* ViewShell::GetLayout()
2153 |* ViewShell::GetNodes()
2155 |* Ersterstellung OK 26. May. 92
2156 |* Letzte Aenderung MA 16. Sep. 93
2158 *************************************************************************/
2160 SwRootFrm *ViewShell::GetLayout() const
2162 return GetDoc()->GetRootFrm();
2165 OutputDevice& ViewShell::GetRefDev() const
2167 OutputDevice* pTmpOut = 0;
2168 if ( GetWin() &&
2169 getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) &&
2170 !GetViewOptions()->IsPrtFormat() )
2171 pTmpOut = GetWin();
2172 else if ( 0 != mpTmpRef )
2173 pTmpOut = mpTmpRef;
2174 else
2175 pTmpOut = GetDoc()->getReferenceDevice( true );
2177 return *pTmpOut;
2180 const SwNodes& ViewShell::GetNodes() const
2182 return pDoc->GetNodes();
2186 void ViewShell::DrawSelChanged()
2191 Size ViewShell::GetDocSize() const
2193 Size aSz;
2194 const SwRootFrm* pRoot = GetLayout();
2195 if( pRoot )
2196 aSz = pRoot->Frm().SSize();
2198 return aSz;
2202 SfxItemPool& ViewShell::GetAttrPool()
2204 return GetDoc()->GetAttrPool();
2207 /******************************************************************************
2209 |* ViewShell::ApplyViewOptions(), ImplApplyViewOptions()
2211 |* Ersterstellung ??
2212 |* Letzte Aenderung MA 03. Mar. 98
2214 ******************************************************************************/
2216 void ViewShell::ApplyViewOptions( const SwViewOption &rOpt )
2219 ViewShell *pSh = this;
2221 { pSh->StartAction();
2222 pSh = (ViewShell*)pSh->GetNext();
2223 } while ( pSh != this );
2225 ImplApplyViewOptions( rOpt );
2227 //Einige Aenderungen muessen synchronisiert werden.
2228 pSh = (ViewShell*)this->GetNext();
2229 while ( pSh != this )
2231 SwViewOption aOpt( *pSh->GetViewOptions() );
2232 aOpt.SetFldName( rOpt.IsFldName() );
2233 aOpt.SetShowHiddenField( rOpt.IsShowHiddenField() );
2234 aOpt.SetShowHiddenPara( rOpt.IsShowHiddenPara() );
2235 aOpt.SetShowHiddenChar( rOpt.IsShowHiddenChar() );
2236 aOpt.SetViewLayoutBookMode( rOpt.IsViewLayoutBookMode() );
2237 aOpt.SetViewLayoutColumns( rOpt.GetViewLayoutColumns() );
2238 aOpt.SetPostIts(rOpt.IsPostIts());
2239 if ( !(aOpt == *pSh->GetViewOptions()) )
2240 pSh->ImplApplyViewOptions( aOpt );
2241 pSh = (ViewShell*)pSh->GetNext();
2244 pSh = this;
2246 { pSh->EndAction();
2247 pSh = (ViewShell*)pSh->GetNext();
2248 } while ( pSh != this );
2252 void ViewShell::ImplApplyViewOptions( const SwViewOption &rOpt )
2254 ASSERT( !(*pOpt == rOpt), "ViewShell::ApplyViewOptions: ");
2256 Window *pMyWin = GetWin();
2257 if( !pMyWin )
2259 ASSERT( pMyWin, "ViewShell::ApplyViewOptions: no window" );
2260 return;
2263 SET_CURR_SHELL( this );
2265 BOOL bReformat = FALSE;
2267 if( pOpt->IsShowHiddenField() != rOpt.IsShowHiddenField() )
2269 ((SwHiddenTxtFieldType*)pDoc->GetSysFldType( RES_HIDDENTXTFLD ))->
2270 SetHiddenFlag( !rOpt.IsShowHiddenField() );
2271 bReformat = TRUE;
2273 if ( pOpt->IsShowHiddenPara() != rOpt.IsShowHiddenPara() )
2275 SwHiddenParaFieldType* pFldType = (SwHiddenParaFieldType*)GetDoc()->
2276 GetSysFldType(RES_HIDDENPARAFLD);
2277 if( pFldType && pFldType->GetDepends() )
2279 SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
2280 pFldType->Modify( &aHnt, 0);
2282 bReformat = TRUE;
2284 if ( !bReformat && pOpt->IsShowHiddenChar() != rOpt.IsShowHiddenChar() )
2286 bReformat = GetDoc()->ContainsHiddenChars();
2289 // bReformat wird TRUE, wenn ...
2290 // - Feldnamen anzeigen oder nicht ...
2291 // ( - SwEndPortion muessen _nicht_ mehr generiert werden. )
2292 // - Das Window ist natuerlich was ganz anderes als der Drucker...
2293 bReformat = bReformat || pOpt->IsFldName() != rOpt.IsFldName();
2295 // Der Mapmode wird veraendert, Minima/Maxima werden von der UI beachtet
2296 if( pOpt->GetZoom() != rOpt.GetZoom() && !IsPreView() )
2298 MapMode aMode( pMyWin->GetMapMode() );
2299 Fraction aNewFactor( rOpt.GetZoom(), 100 );
2300 aMode.SetScaleX( aNewFactor );
2301 aMode.SetScaleY( aNewFactor );
2302 pMyWin->SetMapMode( aMode );
2303 // Wenn kein ReferenzDevice (Drucker) zum Formatieren benutzt wird,
2304 // sondern der Bildschirm, muss bei Zoomfaktoraenderung neu formatiert
2305 // werden.
2306 if( getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
2307 bReformat = TRUE;
2310 if ( getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) &&
2311 pOpt->IsPrtFormat() != rOpt.IsPrtFormat() )
2312 bReformat = TRUE;
2314 if ( HasDrawView() || rOpt.IsGridVisible() )
2316 if ( !HasDrawView() )
2317 MakeDrawView();
2319 SwDrawView *pDView = Imp()->GetDrawView();
2320 if ( pDView->IsDragStripes() != rOpt.IsCrossHair() )
2321 pDView->SetDragStripes( rOpt.IsCrossHair() );
2323 if ( pDView->IsGridSnap() != rOpt.IsSnap() )
2324 pDView->SetGridSnap( rOpt.IsSnap() );
2326 if ( pDView->IsGridVisible() != rOpt.IsGridVisible() )
2327 pDView->SetGridVisible( rOpt.IsGridVisible() );
2329 const Size &rSz = rOpt.GetSnapSize();
2330 pDView->SetGridCoarse( rSz );
2332 const Size aFSize
2333 ( rSz.Width() ? rSz.Width() / (rOpt.GetDivisionX()+1) : 0,
2334 rSz.Height()? rSz.Height()/ (rOpt.GetDivisionY()+1) : 0);
2335 pDView->SetGridFine( aFSize );
2336 Fraction aSnGrWdtX(rSz.Width(), rOpt.GetDivisionX() + 1);
2337 Fraction aSnGrWdtY(rSz.Height(), rOpt.GetDivisionY() + 1);
2338 pDView->SetSnapGridWidth( aSnGrWdtX, aSnGrWdtY );
2340 if ( pOpt->IsSolidMarkHdl() != rOpt.IsSolidMarkHdl() )
2341 pDView->SetSolidMarkHdl( rOpt.IsSolidMarkHdl() );
2343 // it's a JOE interface !
2344 if ( pOpt->IsBigMarkHdl() != rOpt.IsBigMarkHdl() )
2345 pDView->SetMarkHdlSizePixel(rOpt.IsBigMarkHdl() ? 9 : 7);
2348 BOOL bOnlineSpellChgd = pOpt->IsOnlineSpell() != rOpt.IsOnlineSpell();
2350 *pOpt = rOpt; // Erst jetzt werden die Options uebernommen.
2351 pOpt->SetUIOptions(rOpt);
2353 pDoc->set(IDocumentSettingAccess::HTML_MODE, 0 != ::GetHtmlMode(pDoc->GetDocShell()));
2355 pMyWin->Invalidate();
2356 if ( bReformat )
2358 // Es hilft alles nichts, wir muessen an alle CntntFrms ein
2359 // Prepare verschicken, wir formatieren neu:
2360 StartAction();
2361 Reformat();
2362 EndAction();
2365 if( bOnlineSpellChgd )
2367 ViewShell *pSh = (ViewShell*)this->GetNext();
2368 BOOL bOnlineSpl = rOpt.IsOnlineSpell();
2369 while( pSh != this )
2370 { pSh->pOpt->SetOnlineSpell( bOnlineSpl );
2371 Window *pTmpWin = pSh->GetWin();
2372 if( pTmpWin )
2373 pTmpWin->Invalidate();
2374 pSh = (ViewShell*)pSh->GetNext();
2380 /******************************************************************************
2382 |* ViewShell::SetUIOptions()
2384 |* Ersterstellung OS 29.07.96
2385 |* Letzte Aenderung OS 29.07.96
2387 ******************************************************************************/
2389 void ViewShell::SetUIOptions( const SwViewOption &rOpt )
2391 pOpt->SetUIOptions(rOpt);
2392 //the API-Flag of the view options is set but never reset
2393 //it is required to set scroll bars in readonly documents
2394 if(rOpt.IsStarOneSetting())
2395 pOpt->SetStarOneSetting(TRUE);
2397 pOpt->SetSymbolFont(rOpt.GetSymbolFont());
2400 /******************************************************************************
2402 |* ViewShell::SetReadonly()
2404 |* Ersterstellung OS 05.09.96
2405 |* Letzte Aenderung MA 12. Feb. 97
2407 ******************************************************************************/
2409 void ViewShell::SetReadonlyOption(BOOL bSet)
2411 //JP 01.02.99: bei ReadOnly Flag richtig abfragen und ggfs. neu
2412 // formatieren; Bug 61335
2414 // Schalten wir gerade von Readonly auf Bearbeiten um?
2415 if( bSet != pOpt->IsReadonly() )
2417 // damit die Flags richtig erfragt werden koennen.
2418 pOpt->SetReadonly( FALSE );
2420 BOOL bReformat = pOpt->IsFldName();
2422 pOpt->SetReadonly( bSet );
2424 if( bReformat )
2426 StartAction();
2427 Reformat();
2428 if ( GetWin() )
2429 GetWin()->Invalidate();
2430 EndAction();
2432 else if ( GetWin() )
2433 GetWin()->Invalidate();
2434 if( Imp()->IsAccessible() )
2435 Imp()->InvalidateAccessibleEditableState( sal_False );
2438 /* -----------------28.08.2003 15:45-----------------
2440 --------------------------------------------------*/
2441 void ViewShell::SetPDFExportOption(sal_Bool bSet)
2443 if( bSet != pOpt->IsPDFExport() )
2445 if( bSet &&
2446 getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
2447 pOpt->SetPrtFormat( TRUE );
2448 pOpt->SetPDFExport(bSet);
2451 /* -----------------------------2002/07/31 17:06------------------------------
2453 ---------------------------------------------------------------------------*/
2454 void ViewShell::SetReadonlySelectionOption(sal_Bool bSet)
2456 if( bSet != pOpt->IsSelectionInReadonly() )
2458 pOpt->SetSelectionInReadonly(bSet);
2461 /******************************************************************************
2463 |* ViewShell::SetPrtFormatOption()
2465 |* Ersterstellung AMA 10. Sep. 97
2466 |* Letzte Aenderung AMA 10. Sep. 97
2468 ******************************************************************************/
2470 void ViewShell::SetPrtFormatOption( BOOL bSet )
2472 pOpt->SetPrtFormat( bSet );
2475 /******************************************************************************
2477 |* ViewShell::UISizeNotify()
2479 |* Ersterstellung MA 14. Jan. 97
2480 |* Letzte Aenderung MA 14. Jan. 97
2482 ******************************************************************************/
2485 void ViewShell::UISizeNotify()
2487 if ( bDocSizeChgd )
2489 bDocSizeChgd = FALSE;
2490 BOOL bOld = bInSizeNotify;
2491 bInSizeNotify = TRUE;
2492 ::SizeNotify( this, GetDocSize() );
2493 bInSizeNotify = bOld;
2498 void ViewShell::SetRestoreActions(USHORT nSet)
2500 DBG_ASSERT(!GetRestoreActions()||!nSet, "mehrfaches Restore der Actions ?");
2501 Imp()->SetRestoreActions(nSet);
2503 USHORT ViewShell::GetRestoreActions() const
2505 return Imp()->GetRestoreActions();
2508 BOOL ViewShell::IsNewLayout() const
2510 return GetLayout()->IsNewLayout();
2513 uno::Reference< ::com::sun::star::accessibility::XAccessible > ViewShell::CreateAccessible()
2515 uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc;
2517 SwDoc *pMyDoc = GetDoc();
2519 // We require a layout and an XModel to be accessible.
2520 ASSERT( pMyDoc->GetRootFrm(), "no layout, no access" );
2521 ASSERT( GetWin(), "no window, no access" );
2523 if( pMyDoc->GetRootFrm() && GetWin() )
2524 xAcc = Imp()->GetAccessibleMap().GetDocumentView();
2526 return xAcc;
2529 uno::Reference< ::com::sun::star::accessibility::XAccessible >
2530 ViewShell::CreateAccessiblePreview()
2532 DBG_ASSERT( IsPreView(),
2533 "Can't create accessible preview for non-preview ViewShell" );
2535 // We require a layout and an XModel to be accessible.
2536 ASSERT( pDoc->GetRootFrm(), "no layout, no access" );
2537 ASSERT( GetWin(), "no window, no access" );
2539 // OD 15.01.2003 #103492# - add condition <IsPreView()>
2540 if ( IsPreView() && pDoc->GetRootFrm() && GetWin() )
2542 // OD 14.01.2003 #103492# - adjustment for new method signature
2543 return Imp()->GetAccessibleMap().GetDocumentPreview(
2544 PagePreviewLayout()->maPrevwPages,
2545 GetWin()->GetMapMode().GetScaleX(),
2546 pDoc->GetRootFrm()->GetPageByPageNum( PagePreviewLayout()->mnSelectedPageNum ),
2547 PagePreviewLayout()->maWinSize );
2549 return NULL;
2552 void ViewShell::InvalidateAccessibleFocus()
2554 if( Imp()->IsAccessible() )
2555 Imp()->GetAccessibleMap().InvalidateFocus();
2558 /** invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs
2560 OD 2005-12-01 #i27138#
2562 @author OD
2564 void ViewShell::InvalidateAccessibleParaFlowRelation( const SwTxtFrm* _pFromTxtFrm,
2565 const SwTxtFrm* _pToTxtFrm )
2567 if ( GetLayout() && GetLayout()->IsAnyShellAccessible() )
2569 Imp()->_InvalidateAccessibleParaFlowRelation( _pFromTxtFrm, _pToTxtFrm );
2573 /** invalidate text selection for paragraphs
2575 OD 2005-12-12 #i27301#
2577 @author OD
2579 void ViewShell::InvalidateAccessibleParaTextSelection()
2581 if ( GetLayout() && GetLayout()->IsAnyShellAccessible() )
2583 Imp()->_InvalidateAccessibleParaTextSelection();
2587 /** invalidate attributes for paragraphs
2589 OD 2009-01-06 #i88069#
2591 @author OD
2593 void ViewShell::InvalidateAccessibleParaAttrs( const SwTxtFrm& rTxtFrm )
2595 if ( GetLayout() && GetLayout()->IsAnyShellAccessible() )
2597 Imp()->_InvalidateAccessibleParaAttrs( rTxtFrm );
2601 /* -----------------------------06.05.2002 13:23------------------------------
2603 ---------------------------------------------------------------------------*/
2604 void ViewShell::ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions)
2606 if(pOpt->IsPagePreview() && !rAccessibilityOptions.GetIsForPagePreviews())
2608 pAccOptions->SetAlwaysAutoColor(sal_False);
2609 pAccOptions->SetStopAnimatedGraphics(sal_False);
2610 pAccOptions->SetStopAnimatedText(sal_False);
2612 else
2614 pAccOptions->SetAlwaysAutoColor(rAccessibilityOptions.GetIsAutomaticFontColor());
2615 pAccOptions->SetStopAnimatedGraphics(! rAccessibilityOptions.GetIsAllowAnimatedGraphics());
2616 pAccOptions->SetStopAnimatedText(! rAccessibilityOptions.GetIsAllowAnimatedText());
2618 // --> FME 2004-06-29 #114856# Formular view
2619 // Always set this option, not only if document is read-only:
2620 pOpt->SetSelectionInReadonly(rAccessibilityOptions.IsSelectionInReadonly());
2624 ShellResource* ViewShell::GetShellRes()
2626 return pShellRes;
2629 void ViewShell::SetCareWin( Window* pNew )
2631 pCareWindow = pNew;
2635 // --> FME 2004-06-15 #i12836# enhanced pdf export
2636 sal_Int32 ViewShell::GetPageNumAndSetOffsetForPDF( OutputDevice& rOut, const SwRect& rRect ) const
2638 ASSERT( GetLayout(), "GetPageNumAndSetOffsetForPDF assumes presence of layout" )
2640 sal_Int32 nRet = -1;
2642 // --> FME 2005-01-07 #i40059# Position out of bounds:
2643 SwRect aRect( rRect );
2644 aRect.Pos().X() = Max( aRect.Left(), GetLayout()->Frm().Left() );
2645 // <--
2647 const SwPageFrm* pPage = GetLayout()->GetPageAtPos( aRect.Center() );
2648 if ( pPage )
2650 ASSERT( pPage, "GetPageNumAndSetOffsetForPDF: No page found" )
2652 Point aOffset( pPage->Frm().Pos() );
2653 aOffset.X() = -aOffset.X();
2654 aOffset.Y() = -aOffset.Y();
2656 MapMode aMapMode( rOut.GetMapMode() );
2657 aMapMode.SetOrigin( aOffset );
2658 rOut.SetMapMode( aMapMode );
2660 nRet = pPage->GetPhyPageNum() - 1;
2663 return nRet;
2665 // <--
2667 // --> PB 2007-05-30 #146850#
2668 const BitmapEx& ViewShell::GetReplacementBitmap( bool bIsErrorState )
2670 BitmapEx** ppRet;
2671 USHORT nResId = 0, nHCResId = 0;
2672 if( bIsErrorState )
2674 ppRet = &pErrorBmp;
2675 nResId = RID_GRAPHIC_ERRORBMP;
2676 nHCResId = RID_GRAPHIC_ERRORBMP_HC;
2678 else
2680 ppRet = &pReplaceBmp;
2681 nResId = RID_GRAPHIC_REPLACEBMP;
2682 nHCResId = RID_GRAPHIC_REPLACEBMP_HC;
2685 if( !*ppRet )
2687 USHORT nBmpResId =
2688 Application::GetSettings().GetStyleSettings().GetWindowColor().IsDark()
2689 ? nHCResId : nResId;
2690 *ppRet = new BitmapEx( SW_RES( nBmpResId ) );
2692 return **ppRet;
2695 void ViewShell::DeleteReplacementBitmaps()
2697 DELETEZ( pErrorBmp );
2698 DELETEZ( pReplaceBmp );
2700 // <--
2702 SwPostItMgr* ViewShell::GetPostItMgr()
2704 SwView* pView = GetDoc()->GetDocShell() ? GetDoc()->GetDocShell()->GetView() : 0;
2705 if ( pView )
2706 return pView->GetPostItMgr();
2708 return 0;
2712 * Document Interface Access
2714 const IDocumentSettingAccess* ViewShell::getIDocumentSettingAccess() const { return pDoc; }
2715 IDocumentSettingAccess* ViewShell::getIDocumentSettingAccess() { return pDoc; }
2716 const IDocumentDeviceAccess* ViewShell::getIDocumentDeviceAccess() const { return pDoc; }
2717 IDocumentDeviceAccess* ViewShell::getIDocumentDeviceAccess() { return pDoc; }
2718 const IDocumentMarkAccess* ViewShell::getIDocumentMarkAccess() const { return pDoc->getIDocumentMarkAccess(); }
2719 IDocumentMarkAccess* ViewShell::getIDocumentMarkAccess() { return pDoc->getIDocumentMarkAccess(); }
2720 const IDocumentDrawModelAccess* ViewShell::getIDocumentDrawModelAccess() const { return pDoc; }
2721 IDocumentDrawModelAccess* ViewShell::getIDocumentDrawModelAccess() { return pDoc; }
2722 const IDocumentRedlineAccess* ViewShell::getIDocumentRedlineAccess() const { return pDoc; }
2723 IDocumentRedlineAccess* ViewShell::getIDocumentRedlineAccess() { return pDoc; }
2724 const IDocumentLayoutAccess* ViewShell::getIDocumentLayoutAccess() const { return pDoc; }
2725 IDocumentLayoutAccess* ViewShell::getIDocumentLayoutAccess() { return pDoc; }
2726 const IDocumentFieldsAccess* ViewShell::getIDocumentFieldsAccess() const { return pDoc; }
2727 IDocumentContentOperations* ViewShell::getIDocumentContentOperations() { return pDoc; }
2728 IDocumentStylePoolAccess* ViewShell::getIDocumentStylePoolAccess() { return pDoc; }
2729 const IDocumentStatistics* ViewShell::getIDocumentStatistics() const { return pDoc; }
2730 IDocumentUndoRedo* ViewShell::getIDocumentUndoRedoAccess() { return pDoc; }
2731 // --> OD 2007-11-14 #i83479#
2732 const IDocumentListItems* ViewShell::getIDocumentListItemsAccess() const
2734 return pDoc;
2736 const IDocumentOutlineNodes* ViewShell::getIDocumentOutlineNodesAccess() const
2738 return pDoc;
2740 // <--